From patchwork Sat Jul 27 10:38:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Russell King - ARM Linux X-Patchwork-Id: 2834602 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 30CF29F243 for ; Sat, 27 Jul 2013 10:38:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3434B20131 for ; Sat, 27 Jul 2013 10:38:51 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5996F2011F for ; Sat, 27 Jul 2013 10:38:49 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V31tf-0002FO-6Q; Sat, 27 Jul 2013 10:38:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V31td-00032V-1a; Sat, 27 Jul 2013 10:38:45 +0000 Received: from caramon.arm.linux.org.uk ([78.32.30.218]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V31tZ-000320-98 for linux-arm-kernel@lists.infradead.org; Sat, 27 Jul 2013 10:38:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=arm.linux.org.uk; s=caramon; h=Sender:Content-Type:MIME-Version:Message-ID:Subject:To:From:Date; bh=MU8PbFAoJmHL/+J0TILxAK6h0pTXfiOesOawGTRbNUE=; b=MY9gSCtnZ6mbhtPGBxJF61jrs554cO/bPCXcskcIZ5cmAozekH6Fg8m4DflqeZGrNCjitE9dti/Vx2DDOTeMbG71wtxLLznHfqQTHKUukdne7wU/Z3kaB51eKYUVJvpiqB0T8ZNSaB7qBcNGZQvi/q2Pqen+PpXxB8iuMXm+XQ0=; Received: from n2100.arm.linux.org.uk ([2002:4e20:1eda:1:214:fdff:fe10:4f86]:55046) by caramon.arm.linux.org.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76) (envelope-from ) id 1V31t7-0004uT-FZ; Sat, 27 Jul 2013 11:38:13 +0100 Received: from linux by n2100.arm.linux.org.uk with local (Exim 4.76) (envelope-from ) id 1V31t6-0007ah-3n; Sat, 27 Jul 2013 11:38:12 +0100 Date: Sat, 27 Jul 2013 11:38:11 +0100 From: Russell King - ARM Linux To: linux-arm-kernel@lists.infradead.org, Linus Walleij Subject: [PATCH] pinctrl: shut up a couple of pinctrl warnings Message-ID: <20130727103811.GD24642@n2100.arm.linux.org.uk> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130727_063841_860704_49BD0C00 X-CRM114-Status: GOOD ( 15.20 ) X-Spam-Score: -5.8 (-----) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP So, I notice that we get a couple of warnings from the pinctrl code: drivers/pinctrl/pinconf.c: In function 'pinconf_dbg_config_print': drivers/pinctrl/pinconf.c:433:36: warning: 'configs' may be used uninitialized in this function drivers/pinctrl/pinconf.c: In function 'pinconf_dbg_config_write': drivers/pinctrl/pinconf.c:511:36: warning: 'configs' may be used uninitialized in this function While the compiler might not be able to work out that "configs" is safe, the code doesn't lend itself very well to identifying that fact when reading it either. This can be trivially solved by a slight restructuring of the code - which also reduces the LOC. Signed-off-by: Russell King --- This patch is not yet build tested; it'll go through the build system tonight though. drivers/pinctrl/pinconf.c | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index e875f21..0674df3 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c @@ -428,12 +428,11 @@ static int pinconf_dbg_config_print(struct seq_file *s, void *d) { struct pinctrl_maps *maps_node; const struct pinctrl_map *map; - struct pinctrl_dev *pctldev = NULL; + const struct pinctrl_map *found = NULL; + struct pinctrl_dev *pctldev; const struct pinconf_ops *confops = NULL; - const struct pinctrl_map_configs *configs; struct dbg_cfg *dbg = &pinconf_dbg_conf; int i, j; - bool found = false; unsigned long config; mutex_lock(&pinctrl_maps_mutex); @@ -450,14 +449,8 @@ static int pinconf_dbg_config_print(struct seq_file *s, void *d) for (j = 0; j < map->data.configs.num_configs; j++) { if (!strcmp(map->data.configs.group_or_pin, dbg->pin_name)) { - /* - * We found the right pin / state, read the - * config and he pctldev for later use - */ - configs = &map->data.configs; - pctldev = get_pinctrl_dev_from_devname - (map->ctrl_dev_name); - found = true; + /* We found the right pin / state */ + found = map; break; } } @@ -473,7 +466,8 @@ static int pinconf_dbg_config_print(struct seq_file *s, void *d) goto exit; } - config = *(configs->configs); + pctldev = get_pinctrl_dev_from_devname(found->ctrl_dev_name); + config = *found->data.configs.configs; seq_printf(s, "Dev %s has config of %s in state %s: 0x%08lX\n", dbg->dev_name, dbg->pin_name, dbg->state_name, config); @@ -505,12 +499,12 @@ static int pinconf_dbg_config_write(struct file *file, { struct pinctrl_maps *maps_node; const struct pinctrl_map *map; - struct pinctrl_dev *pctldev = NULL; + const struct pinctrl_map *found = NULL; + struct pinctrl_dev *pctldev; const struct pinconf_ops *confops = NULL; struct dbg_cfg *dbg = &pinconf_dbg_conf; const struct pinctrl_map_configs *configs; char config[MAX_NAME_LEN+1]; - bool found = false; char buf[128]; char *b = &buf[0]; int buf_size; @@ -588,10 +582,7 @@ static int pinconf_dbg_config_write(struct file *file, /* we found the right pin / state, so overwrite config */ if (!strcmp(map->data.configs.group_or_pin, dbg->pin_name)) { - found = true; - pctldev = get_pinctrl_dev_from_devname( - map->ctrl_dev_name); - configs = &map->data.configs; + found = map; break; } } @@ -601,10 +592,12 @@ static int pinconf_dbg_config_write(struct file *file, goto exit; } + pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name); if (pctldev) confops = pctldev->desc->confops; if (confops && confops->pin_config_dbg_parse_modify) { + configs = &map->data.configs; for (i = 0; i < configs->num_configs; i++) { confops->pin_config_dbg_parse_modify(pctldev, config,