mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Lechner <david@lechnology.com>,
	Frieder Schrempf <frieder.schrempf@exceet.de>
Subject: Re: [PATCH v2 2/7] Input: pwm-beeper - switch to using managed resources
Date: Fri, 20 Jan 2017 11:10:54 +0100	[thread overview]
Message-ID: <20170120101054.GB3824@ulmo.ba.sec> (raw)
In-Reply-To: <20170119224057.9995-2-dmitry.torokhov@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1481 bytes --]

On Thu, Jan 19, 2017 at 02:40:52PM -0800, Dmitry Torokhov wrote:
> Use of managed resources (devm) simplifies error handling and tear down
> of the driver.
> 
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> ---
>  drivers/input/misc/pwm-beeper.c | 44 ++++++++++-------------------------------
>  1 file changed, 10 insertions(+), 34 deletions(-)
> 
> diff --git a/drivers/input/misc/pwm-beeper.c b/drivers/input/misc/pwm-beeper.c
> index cb87e475bd23..14c52054f5b7 100644
> --- a/drivers/input/misc/pwm-beeper.c
> +++ b/drivers/input/misc/pwm-beeper.c
> @@ -95,18 +95,19 @@ static void pwm_beeper_close(struct input_dev *input)
>  
>  static int pwm_beeper_probe(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
>  	struct pwm_beeper *beeper;
>  	int error;
>  
> -	beeper = kzalloc(sizeof(*beeper), GFP_KERNEL);
> +	beeper = devm_kzalloc(dev, sizeof(*beeper), GFP_KERNEL);
>  	if (!beeper)
>  		return -ENOMEM;
>  
> -	beeper->pwm = pwm_get(&pdev->dev, NULL);
> +	beeper->pwm = devm_pwm_get(dev, NULL);
>  	if (IS_ERR(beeper->pwm)) {
>  		error = PTR_ERR(beeper->pwm);
> -		dev_err(&pdev->dev, "Failed to request pwm device: %d\n", error);
> -		goto err_free;
> +		dev_err(dev, "Failed to request pwm device: %d\n", error);

While at it, could you do a "pwm" -> "PWM" in the above. It's an
abbreviation.

Otherwise this looks like great cleanup:

Reviewed-by: Thierry Reding <thierry.reding@gmail.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-01-20 10:17 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19 22:40 [PATCH v2 1/7] Input: pwm-beeper - remove calls to legacy pwm_request API Dmitry Torokhov
2017-01-19 22:40 ` [PATCH v2 2/7] Input: pwm-beeper - switch to using managed resources Dmitry Torokhov
2017-01-20 10:10   ` Thierry Reding [this message]
2017-01-19 22:40 ` [PATCH v2 3/7] Input: pwm-beeper - use input_set_capability() Dmitry Torokhov
2017-01-20 10:12   ` Thierry Reding
2017-01-19 22:40 ` [PATCH v2 4/7] Input: pwm-beeper - fix race when suspending Dmitry Torokhov
2017-01-20 10:14   ` Thierry Reding
2017-01-19 22:40 ` [PATCH v2 5/7] Input: pwm-beeper - suppress error message on probe defer Dmitry Torokhov
2017-01-20 10:16   ` Thierry Reding
2017-01-20 18:43     ` David Lechner
2017-01-19 22:40 ` [PATCH v2 6/7] Input: pwm-beeper - add optional amplifier regulator Dmitry Torokhov
2017-01-20 10:19   ` Thierry Reding
2017-01-20 17:47     ` Dmitry Torokhov
2017-01-19 22:40 ` [PATCH v2 7/7] Input: pwm-beeper - switch to using "atomic" PWM API Dmitry Torokhov
2017-01-20 10:23   ` Thierry Reding
2017-01-20 10:08 ` [PATCH v2 1/7] Input: pwm-beeper - remove calls to legacy pwm_request API Thierry Reding
2017-01-20 19:37 ` David Lechner

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=20170120101054.GB3824@ulmo.ba.sec \
    --to=thierry.reding@gmail.com \
    --cc=david@lechnology.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=frieder.schrempf@exceet.de \
    --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

Powered by JetHome