public inbox for linux-input@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Fabio Estevam <festevam@gmail.com>
Cc: linux-input@vger.kernel.org, Fabio Estevam <fabio.estevam@freescale.com>
Subject: Re: [PATCH] Input: imx_keypad - use the preferred form for passing a size of a struct
Date: Sun, 4 Jan 2015 14:29:24 -0800	[thread overview]
Message-ID: <20150104222924.GB31987@dtor-ws> (raw)
In-Reply-To: <1419947236-17328-1-git-send-email-festevam@gmail.com>

On Tue, Dec 30, 2014 at 11:47:16AM -0200, Fabio Estevam wrote:
> From: Fabio Estevam <fabio.estevam@freescale.com>
> 
> According to Documentation/CodingStyle - Chapter 14:
> 
> "The preferred form for passing a size of a struct is the following:
> 
>         p = kmalloc(sizeof(*p), ...);
> 
> The alternative form where struct name is spelled out hurts readability and
> introduces an opportunity for a bug when the pointer variable type is changed
> but the corresponding sizeof that is passed to a memory allocator is not."
> 
> So do it as recommeded.
> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>

Applied, thank you.

> ---
>  drivers/input/keyboard/imx_keypad.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/input/keyboard/imx_keypad.c b/drivers/input/keyboard/imx_keypad.c
> index e53f232..2e855e6 100644
> --- a/drivers/input/keyboard/imx_keypad.c
> +++ b/drivers/input/keyboard/imx_keypad.c
> @@ -448,8 +448,7 @@ static int imx_keypad_probe(struct platform_device *pdev)
>  		return -ENOMEM;
>  	}
>  
> -	keypad = devm_kzalloc(&pdev->dev, sizeof(struct imx_keypad),
> -			      GFP_KERNEL);
> +	keypad = devm_kzalloc(&pdev->dev, sizeof(*keypad), GFP_KERNEL);
>  	if (!keypad) {
>  		dev_err(&pdev->dev, "not enough memory for driver data\n");
>  		return -ENOMEM;
> -- 
> 1.9.1
> 

-- 
Dmitry

      reply	other threads:[~2015-01-04 22:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-30 13:47 [PATCH] Input: imx_keypad - use the preferred form for passing a size of a struct Fabio Estevam
2015-01-04 22:29 ` Dmitry Torokhov [this message]

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=20150104222924.GB31987@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=fabio.estevam@freescale.com \
    --cc=festevam@gmail.com \
    --cc=linux-input@vger.kernel.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