All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Matti Vaittinen <mazziesaccount@gmail.com>,
	Jean Delvare <jdelvare@suse.com>,
	Hans de Goede <hdegoede@redhat.com>,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org
Subject: Re: [RFC RESEND PATCH v2 4/8] hwmon: raspberry-pi: Clean-up few drivers by using managed work init
Date: Mon, 22 Mar 2021 07:05:32 -0700	[thread overview]
Message-ID: <20210322140532.GB140507@roeck-us.net> (raw)
In-Reply-To: <fc14075a0aae06678cde0bae80ec92d93378ac62.1616395565.git.matti.vaittinen@fi.rohmeurope.com>

On Mon, Mar 22, 2021 at 09:37:18AM +0200, Matti Vaittinen wrote:
> Few drivers implement remove call-back only for ensuring a delayed
> work gets cancelled prior driver removal. Clean-up these by switching
> to use devm_delayed_work_autocancel() instead.
> 
> This change is compile-tested only. All testing is appreciated.
> 
> Signed-off-by: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>

Acked-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/hwmon/raspberrypi-hwmon.c | 17 ++++++-----------
>  1 file changed, 6 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c
> index d3a64a35f7a9..805d396aa81b 100644
> --- a/drivers/hwmon/raspberrypi-hwmon.c
> +++ b/drivers/hwmon/raspberrypi-hwmon.c
> @@ -7,6 +7,7 @@
>   * Copyright (C) 2018 Stefan Wahren <stefan.wahren@i2se.com>
>   */
>  #include <linux/device.h>
> +#include <linux/devm-helpers.h>
>  #include <linux/err.h>
>  #include <linux/hwmon.h>
>  #include <linux/module.h>
> @@ -106,6 +107,7 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct rpi_hwmon_data *data;
> +	int ret;
>  
>  	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
>  	if (!data)
> @@ -119,7 +121,10 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>  							       &rpi_chip_info,
>  							       NULL);
>  
> -	INIT_DELAYED_WORK(&data->get_values_poll_work, get_values_poll);
> +	ret = devm_delayed_work_autocancel(dev, &data->get_values_poll_work,
> +					   get_values_poll);
> +	if (ret)
> +		return ret;
>  	platform_set_drvdata(pdev, data);
>  
>  	if (!PTR_ERR_OR_ZERO(data->hwmon_dev))
> @@ -128,18 +133,8 @@ static int rpi_hwmon_probe(struct platform_device *pdev)
>  	return PTR_ERR_OR_ZERO(data->hwmon_dev);
>  }
>  
> -static int rpi_hwmon_remove(struct platform_device *pdev)
> -{
> -	struct rpi_hwmon_data *data = platform_get_drvdata(pdev);
> -
> -	cancel_delayed_work_sync(&data->get_values_poll_work);
> -
> -	return 0;
> -}
> -
>  static struct platform_driver rpi_hwmon_driver = {
>  	.probe = rpi_hwmon_probe,
> -	.remove = rpi_hwmon_remove,
>  	.driver = {
>  		.name = "raspberrypi-hwmon",
>  	},
> -- 
> 2.25.4
> 
> 
> -- 
> Matti Vaittinen, Linux device drivers
> ROHM Semiconductors, Finland SWDC
> Kiviharjunlenkki 1E
> 90220 OULU
> FINLAND
> 
> ~~~ "I don't think so," said Rene Descartes. Just then he vanished ~~~
> Simon says - in Latin please.
> ~~~ "non cogito me" dixit Rene Descarte, deinde evanescavit ~~~
> Thanks to Simon Glass for the translation =] 

  reply	other threads:[~2021-03-22 14:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22  7:41 [RFC RESEND PATCH v2 0/8] Add managed version of delayed work init Matti Vaittinen
2021-03-22  7:36 ` [RFC RESEND PATCH v2 1/8] workqueue: Add resource " Matti Vaittinen
2021-03-22  7:36 ` [RFC RESEND PATCH v2 2/8] MAINTAINERS: Add entry for devm helpers Matti Vaittinen
2021-03-22  7:37 ` [RFC RESEND PATCH v2 3/8] extconn: Clean-up few drivers by using managed work init Matti Vaittinen
2021-03-22  7:37 ` [RFC RESEND PATCH v2 4/8] hwmon: raspberry-pi: " Matti Vaittinen
2021-03-22 14:05   ` Guenter Roeck [this message]
2021-03-22  7:37 ` [RFC RESEND PATCH v2 5/8] platform/x86: gpd pocket fan: Clean-up " Matti Vaittinen
2021-03-22  7:37 ` [RFC RESEND PATCH v2 6/8] power: supply: Clean-up few drivers " Matti Vaittinen
2021-03-22 14:08   ` Chen-Yu Tsai
2021-03-22  7:38 ` [RFC RESEND PATCH v2 7/8] regulator: qcom_spmi-regulator: Clean-up " Matti Vaittinen
2021-03-22  7:38 ` [RFC RESEND PATCH v2 8/8] watchdog: retu_wdt: " Matti Vaittinen
2021-03-22 14:05   ` Guenter Roeck
2021-03-23 12:43 ` [RFC RESEND PATCH v2 0/8] Add managed version of delayed " Greg KH
2021-03-23 13:16   ` Vaittinen, Matti

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=20210322140532.GB140507@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matti.vaittinen@fi.rohmeurope.com \
    --cc=mazziesaccount@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.