From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755253Ab0IMUIC (ORCPT ); Mon, 13 Sep 2010 16:08:02 -0400 Received: from ppsw-31.csi.cam.ac.uk ([131.111.8.131]:36211 "EHLO ppsw-31.csi.cam.ac.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754970Ab0IMUH7 (ORCPT ); Mon, 13 Sep 2010 16:07:59 -0400 X-Cam-AntiVirus: no malware found X-Cam-SpamDetails: not scanned X-Cam-ScannerInfo: http://www.cam.ac.uk/cs/email/scanner/ Message-ID: <4C8E84A0.1010606@jic23.retrosnub.co.uk> Date: Mon, 13 Sep 2010 21:08:00 +0100 From: Jonathan Cameron User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.9) Gecko/20100909 Lightning/1.0b3pre Thunderbird/3.1.3 MIME-Version: 1.0 To: Joe Perches CC: linux-kernel@vger.kernel.org, "Jean Delvare \(PC drivers, core\)" , linux-i2c@vger.kernel.org, Linus Walleij , "Ben Dooks (embedded platforms)" , linux-arm-kernel@lists.infradead.org Subject: Re: [PATCH 05/25] drivers/i2c: Use static const char arrays References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit message is somewhat inaccurate... On 09/13/10 20:47, Joe Perches wrote: > Signed-off-by: Joe Perches > --- > drivers/i2c/busses/i2c-stu300.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c > index 495be45..2f7c09c 100644 > --- a/drivers/i2c/busses/i2c-stu300.c > +++ b/drivers/i2c/busses/i2c-stu300.c > @@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev) > struct resource *res; > int bus_nr; > int ret = 0; > - char clk_name[] = "I2C0"; > + char clk_name[sizeof("I2Cx")]; > > dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL); > if (!dev) { > @@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) > } > > bus_nr = pdev->id; > - clk_name[3] += (char)bus_nr; > + sprintf(clk_name, "I2C%c", '0' + bus_nr); I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d? > dev->clk = clk_get(&pdev->dev, clk_name); > if (IS_ERR(dev->clk)) { > ret = PTR_ERR(dev->clk); From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonathan Cameron Subject: Re: [PATCH 05/25] drivers/i2c: Use static const char arrays Date: Mon, 13 Sep 2010 21:08:00 +0100 Message-ID: <4C8E84A0.1010606@jic23.retrosnub.co.uk> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-i2c-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Joe Perches Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, "Jean Delvare (PC drivers, core)" , linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Linus Walleij , "Ben Dooks (embedded platforms)" , linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org List-Id: linux-i2c@vger.kernel.org Commit message is somewhat inaccurate... On 09/13/10 20:47, Joe Perches wrote: > Signed-off-by: Joe Perches > --- > drivers/i2c/busses/i2c-stu300.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c > index 495be45..2f7c09c 100644 > --- a/drivers/i2c/busses/i2c-stu300.c > +++ b/drivers/i2c/busses/i2c-stu300.c > @@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev) > struct resource *res; > int bus_nr; > int ret = 0; > - char clk_name[] = "I2C0"; > + char clk_name[sizeof("I2Cx")]; > > dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL); > if (!dev) { > @@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) > } > > bus_nr = pdev->id; > - clk_name[3] += (char)bus_nr; > + sprintf(clk_name, "I2C%c", '0' + bus_nr); I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d? > dev->clk = clk_get(&pdev->dev, clk_name); > if (IS_ERR(dev->clk)) { > ret = PTR_ERR(dev->clk); From mboxrd@z Thu Jan 1 00:00:00 1970 From: arm@jic23.retrosnub.co.uk (Jonathan Cameron) Date: Mon, 13 Sep 2010 21:08:00 +0100 Subject: [PATCH 05/25] drivers/i2c: Use static const char arrays In-Reply-To: References: Message-ID: <4C8E84A0.1010606@jic23.retrosnub.co.uk> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Commit message is somewhat inaccurate... On 09/13/10 20:47, Joe Perches wrote: > Signed-off-by: Joe Perches > --- > drivers/i2c/busses/i2c-stu300.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-stu300.c b/drivers/i2c/busses/i2c-stu300.c > index 495be45..2f7c09c 100644 > --- a/drivers/i2c/busses/i2c-stu300.c > +++ b/drivers/i2c/busses/i2c-stu300.c > @@ -871,7 +871,7 @@ stu300_probe(struct platform_device *pdev) > struct resource *res; > int bus_nr; > int ret = 0; > - char clk_name[] = "I2C0"; > + char clk_name[sizeof("I2Cx")]; > > dev = kzalloc(sizeof(struct stu300_dev), GFP_KERNEL); > if (!dev) { > @@ -881,7 +881,7 @@ stu300_probe(struct platform_device *pdev) > } > > bus_nr = pdev->id; > - clk_name[3] += (char)bus_nr; > + sprintf(clk_name, "I2C%c", '0' + bus_nr); I'm guessing that there are never more than a couple of these. Why is this method a better bet than just putting %d? > dev->clk = clk_get(&pdev->dev, clk_name); > if (IS_ERR(dev->clk)) { > ret = PTR_ERR(dev->clk);