All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
To: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Hans de Goede <hdegoede@redhat.com>,
	Mark Gross <mgross@linux.intel.com>,
	Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
	gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	platform-driver-x86@vger.kernel.org
Subject: [PATCH v3 5/8] platform/x86: gpd pocket fan: Clean-up by using managed work init
Date: Tue, 23 Mar 2021 15:57:41 +0200	[thread overview]
Message-ID: <aa25a6781ba016772b045cd6e630da8c559a665d.1616506559.git.matti.vaittinen@fi.rohmeurope.com> (raw)
In-Reply-To: <cover.1616506559.git.matti.vaittinen@fi.rohmeurope.com>

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>
---
Changelog from RFCv2:
 - RFC dropped. No functional changes.

 drivers/platform/x86/gpd-pocket-fan.c | 17 ++++++-----------
 1 file changed, 6 insertions(+), 11 deletions(-)

diff --git a/drivers/platform/x86/gpd-pocket-fan.c b/drivers/platform/x86/gpd-pocket-fan.c
index 5b516e4c2bfb..7a20f68ae206 100644
--- a/drivers/platform/x86/gpd-pocket-fan.c
+++ b/drivers/platform/x86/gpd-pocket-fan.c
@@ -6,6 +6,7 @@
  */
 
 #include <linux/acpi.h>
+#include <linux/devm-helpers.h>
 #include <linux/gpio/consumer.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -124,7 +125,7 @@ static void gpd_pocket_fan_force_update(struct gpd_pocket_fan_data *fan)
 static int gpd_pocket_fan_probe(struct platform_device *pdev)
 {
 	struct gpd_pocket_fan_data *fan;
-	int i;
+	int i, ret;
 
 	for (i = 0; i < ARRAY_SIZE(temp_limits); i++) {
 		if (temp_limits[i] < 20000 || temp_limits[i] > 90000) {
@@ -152,7 +153,10 @@ static int gpd_pocket_fan_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	fan->dev = &pdev->dev;
-	INIT_DELAYED_WORK(&fan->work, gpd_pocket_fan_worker);
+	ret = devm_delayed_work_autocancel(&pdev->dev, &fan->work,
+					   gpd_pocket_fan_worker);
+	if (ret)
+		return ret;
 
 	/* Note this returns a "weak" reference which we don't need to free */
 	fan->dts0 = thermal_zone_get_zone_by_name("soc_dts0");
@@ -177,14 +181,6 @@ static int gpd_pocket_fan_probe(struct platform_device *pdev)
 	return 0;
 }
 
-static int gpd_pocket_fan_remove(struct platform_device *pdev)
-{
-	struct gpd_pocket_fan_data *fan = platform_get_drvdata(pdev);
-
-	cancel_delayed_work_sync(&fan->work);
-	return 0;
-}
-
 #ifdef CONFIG_PM_SLEEP
 static int gpd_pocket_fan_suspend(struct device *dev)
 {
@@ -215,7 +211,6 @@ MODULE_DEVICE_TABLE(acpi, gpd_pocket_fan_acpi_match);
 
 static struct platform_driver gpd_pocket_fan_driver = {
 	.probe	= gpd_pocket_fan_probe,
-	.remove	= gpd_pocket_fan_remove,
 	.driver	= {
 		.name			= "gpd_pocket_fan",
 		.acpi_match_table	= gpd_pocket_fan_acpi_match,
-- 
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 =] 

  parent reply	other threads:[~2021-03-23 13:58 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-23 13:49 [PATCH v3 0/8] Add managed version of delayed work init Matti Vaittinen
2021-03-23 13:56 ` [PATCH v3 1/8] workqueue: Add resource " Matti Vaittinen
2021-03-23 13:59   ` Hans de Goede
2021-03-23 13:56 ` [PATCH v3 2/8] MAINTAINERS: Add entry for devm helpers Matti Vaittinen
2021-03-23 13:58   ` Hans de Goede
2021-03-23 14:19     ` Greg KH
2021-04-21  7:51       ` Matti Vaittinen
2021-04-21 11:58         ` Hans de Goede
2021-04-21 12:09           ` Greg KH
2021-04-21 12:39             ` Matti Vaittinen
2021-04-21 12:17           ` Vaittinen, Matti
2021-04-21 12:26             ` Hans de Goede
2021-04-21 12:54               ` Vaittinen, Matti
2021-03-23 13:57 ` [PATCH v3 3/8] extconn: Clean-up few drivers by using managed work init Matti Vaittinen
2021-03-23 13:59   ` Hans de Goede
2021-03-24  2:09   ` Chanwoo Choi
2021-03-24  5:02     ` Matti Vaittinen
2021-03-24  7:19       ` Hans de Goede
2021-03-23 13:57 ` [PATCH v3 4/8] hwmon: raspberry-pi: " Matti Vaittinen
2021-03-23 13:57 ` Matti Vaittinen [this message]
2021-03-23 15:30   ` [PATCH v3 5/8] platform/x86: gpd pocket fan: Clean-up " Hans de Goede
2021-03-23 13:57 ` [PATCH v3 6/8] power: supply: Clean-up few drivers " Matti Vaittinen
2021-03-23 14:36   ` Chen-Yu Tsai
2021-03-24  7:43     ` Matti Vaittinen
2021-03-24  7:52     ` Matti Vaittinen
2021-03-23 13:58 ` [PATCH v3 7/8] regulator: qcom_spmi-regulator: Clean-up " Matti Vaittinen
2021-03-23 17:37   ` Mark Brown
2021-03-23 13:58 ` [PATCH v3 8/8] watchdog: retu_wdt: " 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=aa25a6781ba016772b045cd6e630da8c559a665d.1616506559.git.matti.vaittinen@fi.rohmeurope.com \
    --to=matti.vaittinen@fi.rohmeurope.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mazziesaccount@gmail.com \
    --cc=mgross@linux.intel.com \
    --cc=platform-driver-x86@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 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.