public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: mazziesaccount@gmail.com, Guenter Roeck <linux@roeck-us.net>,
	linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org
Subject: Re: [RFC PATCH 3/7] hwmon: raspberry-pi: Clean-up few drivers by using managed work init
Date: Sat, 13 Feb 2021 13:16:52 +0100	[thread overview]
Message-ID: <YCfDNG4rx0sRZEaG@kroah.com> (raw)
In-Reply-To: <1ee4b1bcc926b60e513e8f5cd586e744de2cb12d.1613216412.git.matti.vaittinen@fi.rohmeurope.com>

On Sat, Feb 13, 2021 at 02:07:02PM +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>
> ---
>  drivers/hwmon/raspberrypi-hwmon.c | 16 +++++-----------
>  1 file changed, 5 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/hwmon/raspberrypi-hwmon.c b/drivers/hwmon/raspberrypi-hwmon.c
> index d3a64a35f7a9..acfa674932bc 100644
> --- a/drivers/hwmon/raspberrypi-hwmon.c
> +++ b/drivers/hwmon/raspberrypi-hwmon.c
> @@ -106,6 +106,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 +120,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 +132,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",
>  	},

So if I manually unbind the driver from the device, and then unload the
driver, what happens?

thanks,

greg k-h

  reply	other threads:[~2021-02-13 12:17 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13 11:58 [RFC PATCH 0/7] Add managed version of delayed work init Matti Vaittinen
2021-02-13 11:58 ` [RFC PATCH 1/7] drivers: base: Add resource " Matti Vaittinen
2021-02-13 12:16   ` Greg Kroah-Hartman
2021-02-13 12:26     ` Vaittinen, Matti
2021-02-13 12:38       ` gregkh
2021-02-13 13:18     ` Hans de Goede
2021-02-13 13:33       ` Greg Kroah-Hartman
2021-02-13 14:38         ` Hans de Goede
2021-02-13 14:52           ` Hans de Goede
2021-02-15  6:58       ` Matti Vaittinen
2021-02-13 15:03   ` Hans de Goede
2021-02-13 15:27     ` Guenter Roeck
2021-02-13 15:59       ` Hans de Goede
2021-02-13 18:17         ` Guenter Roeck
2021-02-15  7:22         ` Vaittinen, Matti
2021-02-15 10:37           ` Hans de Goede
2021-02-15 11:31             ` gregkh
2021-02-15 11:43               ` Hans de Goede
2021-02-15 13:12                 ` Vaittinen, Matti
2021-02-13 12:03 ` [RFC PATCH 2/7] extconn: Clean-up few drivers by using managed " Matti Vaittinen
2021-02-13 12:07 ` [RFC PATCH 3/7] hwmon: raspberry-pi: " Matti Vaittinen
2021-02-13 12:16   ` Greg Kroah-Hartman [this message]
2021-02-13 12:09 ` [RFC PATCH 4/7] platform/x86: gpd pocket fan: Clean-up " Matti Vaittinen
2021-02-13 12:12 ` [RFC PATCH 5/7] power: supply: Clean-up few drivers " Matti Vaittinen
2021-02-13 12:17   ` Greg Kroah-Hartman
2021-02-13 12:16 ` [RFC PATCH 6/7] regulator: qcom_spmi-regulator: Clean-up " Matti Vaittinen
2021-02-13 12:18 ` [RFC PATCH 7/7] watchdog: retu_wdt: " Matti Vaittinen
2021-02-18 16:28 ` [RFC PATCH 0/7] Add managed version of delayed " mark gross
2021-02-19 10:35   ` Matti Vaittinen

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=YCfDNG4rx0sRZEaG@kroah.com \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox