From patchwork Wed Jul 9 13:04:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 33308 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f200.google.com (mail-yk0-f200.google.com [209.85.160.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 48EDC208CF for ; Wed, 9 Jul 2014 13:04:38 +0000 (UTC) Received: by mail-yk0-f200.google.com with SMTP id 20sf17214033yks.11 for ; Wed, 09 Jul 2014 06:04:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=D+nJqrZ1sZ5UE0iGbMcIP9CsTLGnbVZoIPLvPIkjfZM=; b=AuvVR+iwaDLMhApvjhcKYTLOdPtIHQa7v08nFl1oKj1u7th2pRUu8Zr6BIJy50qe89 VygrJSIEzjeaqrbKk06oPUeMFX+KJTrKVpacYJUQefq9NafphhoOoDZoH/LGLPqbabsz oonJQWm0t7z3WhS8mhRgVMulcDE1qS/4ZtyAi83b20oXgR88G2bBUHKeVeX8s4ZgTPIp 0o+9g38xE5GnqLe+YjB14O5VO/l47GJJHnksgnCCFV1ALRMUvZuT8xaAtgb6FkESFAzT cyKGTrIlyGao780CT3MYzY0UHZuyDvbLrQdX+KgfUYoR34ckfjA3hgb+t2A/CfqrvhOX G59w== X-Gm-Message-State: ALoCoQmjTBRDiVxpS6VJAO5vHbeNWBTyJPat0b2a65vKlpiF0jqr6k6w5C5rIeu2YiGzn3UMPxSe X-Received: by 10.58.152.143 with SMTP id uy15mr21042360veb.27.1404911078010; Wed, 09 Jul 2014 06:04:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.29.55 with SMTP id a52ls101905qga.14.gmail; Wed, 09 Jul 2014 06:04:37 -0700 (PDT) X-Received: by 10.52.231.226 with SMTP id tj2mr19946350vdc.16.1404911077774; Wed, 09 Jul 2014 06:04:37 -0700 (PDT) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id uw7si21477315vec.24.2014.07.09.06.04.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 09 Jul 2014 06:04:37 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) client-ip=209.85.128.178; Received: by mail-ve0-f178.google.com with SMTP id jx11so227358veb.9 for ; Wed, 09 Jul 2014 06:04:37 -0700 (PDT) X-Received: by 10.52.144.235 with SMTP id sp11mr16715950vdb.25.1404911077654; Wed, 09 Jul 2014 06:04:37 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp46054vcb; Wed, 9 Jul 2014 06:04:37 -0700 (PDT) X-Received: by 10.70.41.42 with SMTP id c10mr11142212pdl.10.1404911076829; Wed, 09 Jul 2014 06:04:36 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bk5si7315259pdb.287.2014.07.09.06.04.36; Wed, 09 Jul 2014 06:04:36 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932143AbaGINEZ (ORCPT + 28 others); Wed, 9 Jul 2014 09:04:25 -0400 Received: from mail-ie0-f174.google.com ([209.85.223.174]:50025 "EHLO mail-ie0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755979AbaGINEV (ORCPT ); Wed, 9 Jul 2014 09:04:21 -0400 Received: by mail-ie0-f174.google.com with SMTP id rd18so5972673iec.5 for ; Wed, 09 Jul 2014 06:04:20 -0700 (PDT) X-Received: by 10.42.58.207 with SMTP id j15mr45427585ich.14.1404911060662; Wed, 09 Jul 2014 06:04:20 -0700 (PDT) Received: from localhost.localdomain (c-24-245-18-91.hsd1.mn.comcast.net. [24.245.18.91]) by mx.google.com with ESMTPSA id lo3sm15293753igb.22.2014.07.09.06.04.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Jul 2014 06:04:20 -0700 (PDT) From: Alex Elder To: akpm@linux-foundation.org Cc: ak@linux.intel.com, bp@suse.de, jack@suse.cz, john.stultz@linaro.org, pmladek@suse.cz, rostedt@goodmis.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] printk: miscellaneous cleanups Date: Wed, 9 Jul 2014 08:04:16 -0500 Message-Id: <1404911056-29064-5-git-send-email-elder@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1404911056-29064-1-git-send-email-elder@linaro.org> References: <1404911056-29064-1-git-send-email-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: elder@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch contains some small cleanups to kernel/printk/printk.c. None of them should cause any change in behavior. - When CONFIG_PRINTK is defined, parenthesize the value of LOG_LINE_MAX. - When CONFIG_PRINTK is *not* defined, there is an extra LOG_LINE_MAX definition; delete it. - Pull an assignment out of a conditional expression in console_setup(). - Use isdigit() in console_setup() rather than open coding it. - In update_console_cmdline(), drop a NUL-termination assignment; the strlcpy() call that precedes it guarantees it's not needed. - Simplify some logic in printk_timed_ratelimit(). Signed-off-by: Alex Elder Reviewed-by: Petr Mladek --- kernel/printk/printk.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 6f75e8a..909029e 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -45,6 +45,7 @@ #include #include #include +#include #include @@ -257,7 +258,7 @@ static u64 clear_seq; static u32 clear_idx; #define PREFIX_MAX 32 -#define LOG_LINE_MAX 1024 - PREFIX_MAX +#define LOG_LINE_MAX (1024 - PREFIX_MAX) /* record buffer */ #if defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS) @@ -1794,7 +1795,7 @@ EXPORT_SYMBOL(printk); #define LOG_LINE_MAX 0 #define PREFIX_MAX 0 -#define LOG_LINE_MAX 0 + static u64 syslog_seq; static u32 syslog_idx; static u64 console_seq; @@ -1895,7 +1896,8 @@ static int __init console_setup(char *str) strncpy(buf, str, sizeof(buf) - 1); } buf[sizeof(buf) - 1] = 0; - if ((options = strchr(str, ',')) != NULL) + options = strchr(str, ','); + if (options) *(options++) = 0; #ifdef __sparc__ if (!strcmp(str, "ttya")) @@ -1904,7 +1906,7 @@ static int __init console_setup(char *str) strcpy(buf, "ttyS1"); #endif for (s = buf; *s; s++) - if ((*s >= '0' && *s <= '9') || *s == ',') + if (isdigit(*s) || *s == ',') break; idx = simple_strtoul(s, NULL, 10); *s = 0; @@ -1943,7 +1945,6 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha i++, c++) if (strcmp(c->name, name) == 0 && c->index == idx) { strlcpy(c->name, name_new, sizeof(c->name)); - c->name[sizeof(c->name) - 1] = 0; c->options = options; c->index = idx_new; return i; @@ -2611,14 +2612,13 @@ EXPORT_SYMBOL(__printk_ratelimit); bool printk_timed_ratelimit(unsigned long *caller_jiffies, unsigned int interval_msecs) { - if (*caller_jiffies == 0 - || !time_in_range(jiffies, *caller_jiffies, - *caller_jiffies - + msecs_to_jiffies(interval_msecs))) { - *caller_jiffies = jiffies; - return true; - } - return false; + unsigned long elapsed = jiffies - *caller_jiffies; + + if (*caller_jiffies && elapsed <= msecs_to_jiffies(interval_msecs)) + return false; + + *caller_jiffies = jiffies; + return true; } EXPORT_SYMBOL(printk_timed_ratelimit);