linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: "Enrico Weigelt, metux IT consult" <info@metux.net>
Cc: linux-kernel@vger.kernel.org, linux-input@vger.kernel.org
Subject: Re: [PATCH v2] (submitted) input: misc: soc_button_array: use platform_device_register_resndata()
Date: Tue, 20 Aug 2019 20:20:15 -0700	[thread overview]
Message-ID: <20190821032015.GR121898@dtor-ws> (raw)
In-Reply-To: <1566303944-15321-1-git-send-email-info@metux.net>

Hi Enrico,

On Tue, Aug 20, 2019 at 02:25:44PM +0200, Enrico Weigelt, metux IT consult wrote:
> From: Enrico Weigelt <info@metux.net>
> 
> The registration of gpio-keys device can be written much shorter
> by using the platform_device_register_resndata() helper.
> 
> v2:
>     * pass &pdev->dev to platform_device_register_resndata()
>     * fixed errval on failed platform_device_register_resndata()
> 
> Signed-off-by: Enrico Weigelt <info@metux.net>
> ---
>  drivers/input/misc/soc_button_array.c | 27 +++++++++++++--------------
>  1 file changed, 13 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/input/misc/soc_button_array.c b/drivers/input/misc/soc_button_array.c
> index 5e59f8e5..27550f9 100644
> --- a/drivers/input/misc/soc_button_array.c
> +++ b/drivers/input/misc/soc_button_array.c
> @@ -110,25 +110,24 @@ static int soc_button_lookup_gpio(struct device *dev, int acpi_index)
>  	gpio_keys_pdata->nbuttons = n_buttons;
>  	gpio_keys_pdata->rep = autorepeat;
>  
> -	pd = platform_device_alloc("gpio-keys", PLATFORM_DEVID_AUTO);
> -	if (!pd) {
> -		error = -ENOMEM;
> +	pd = platform_device_register_resndata(
> +		&pdev->dev,
> +		"gpio-keys",
> +		PLATFORM_DEVID_AUTO,
> +		NULL,
> +		0,
> +		gpio_keys_pdata,
> +		sizeof(*gpio_keys_pdata));
> +
> +	error = PTR_ERR_OR_ZERO(pd);
> +
> +	if (IS_ERR(pd)) {

I changed this and the PTR_ERR() to simply "error" and applied.

> +		dev_err(&pdev->dev, "failed registering gpio-keys: %ld\n", PTR_ERR(pd));
>  		goto err_free_mem;
>  	}
>  
> -	error = platform_device_add_data(pd, gpio_keys_pdata,
> -					 sizeof(*gpio_keys_pdata));
> -	if (error)
> -		goto err_free_pdev;
> -
> -	error = platform_device_add(pd);
> -	if (error)
> -		goto err_free_pdev;
> -
>  	return pd;
>  
> -err_free_pdev:
> -	platform_device_put(pd);
>  err_free_mem:
>  	devm_kfree(&pdev->dev, gpio_keys_pdata);
>  	return ERR_PTR(error);
> -- 
> 1.9.1
> 

Thanks.

-- 
Dmitry

      reply	other threads:[~2019-08-21  3:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 12:25 [PATCH v2] (submitted) input: misc: soc_button_array: use platform_device_register_resndata() Enrico Weigelt, metux IT consult
2019-08-21  3:20 ` 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=20190821032015.GR121898@dtor-ws \
    --to=dmitry.torokhov@gmail.com \
    --cc=info@metux.net \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@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;
as well as URLs for NNTP newsgroup(s).