public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: joe@perches.com (Joe Perches)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] pinctrl: use kasprintf() in pinmux_request_gpio()
Date: Thu, 13 Sep 2012 22:19:04 -0700	[thread overview]
Message-ID: <1347599944.9481.3.camel@joe2Laptop> (raw)
In-Reply-To: <1347565754-9534-1-git-send-email-thomas.petazzoni@free-electrons.com>

On Thu, 2012-09-13 at 21:49 +0200, Thomas Petazzoni wrote:
> Instead of using a temporary buffer, snprintf() and kstrdup(), just
> use kasprintf() that does the same thing in just oneline.
> 
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
>  drivers/pinctrl/pinmux.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
> index 3d5ac73..9301a7a 100644
> --- a/drivers/pinctrl/pinmux.c
> +++ b/drivers/pinctrl/pinmux.c
> @@ -232,14 +232,11 @@ int pinmux_request_gpio(struct pinctrl_dev *pctldev,
>  			struct pinctrl_gpio_range *range,
>  			unsigned pin, unsigned gpio)
>  {
> -	char gpiostr[16];
>  	const char *owner;
>  	int ret;
>  
>  	/* Conjure some name stating what chip and pin this is taken by */
> -	snprintf(gpiostr, 15, "%s:%d", range->name, gpio);
> -
> -	owner = kstrdup(gpiostr, GFP_KERNEL);
> +	owner = kasprintf(GFP_KERNEL, "%s:%d", range->name, gpio);
>  	if (!owner)
>  		return -EINVAL;
>  

No not really.  It's a bit different because the first
snprintf is length limited but the kasprintf is not.

  reply	other threads:[~2012-09-14  5:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 19:49 [PATCH] pinctrl: use kasprintf() in pinmux_request_gpio() Thomas Petazzoni
2012-09-14  5:19 ` Joe Perches [this message]
2012-09-14  7:18   ` Colin Cross
2012-09-14 13:54     ` Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347599944.9481.3.camel@joe2Laptop \
    --to=joe@perches.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox