[PATCH 01/11] hwmon: (max6650) Use devm_add_action to unregister thermal device

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Use devm_add_action to unregister the thermal cooling device.
This lets us drop the remove function.

At the same time, use 'dev' variable in probe function consistently.

Cc: Jean-Francois Dagenais <jeff.dagenais@xxxxxxxxx>
Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>
---
 drivers/hwmon/max6650.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/hwmon/max6650.c b/drivers/hwmon/max6650.c
index 939953240827..6cce199dab6a 100644
--- a/drivers/hwmon/max6650.c
+++ b/drivers/hwmon/max6650.c
@@ -752,6 +752,11 @@ static const struct thermal_cooling_device_ops max6650_cooling_ops = {
 	.get_cur_state = max6650_get_cur_state,
 	.set_cur_state = max6650_set_cur_state,
 };
+
+static void max6650_thermal_unregister(void *data)
+{
+	thermal_cooling_device_unregister(data);
+}
 #endif
 
 static int max6650_probe(struct i2c_client *client,
@@ -794,27 +799,20 @@ static int max6650_probe(struct i2c_client *client,
 
 #if IS_ENABLED(CONFIG_THERMAL)
 	data->cooling_dev =
-		thermal_of_cooling_device_register(client->dev.of_node,
+		thermal_of_cooling_device_register(dev->of_node,
 						   client->name, data,
 						   &max6650_cooling_ops);
-	if (IS_ERR(data->cooling_dev))
-		dev_warn(&client->dev,
-			 "thermal cooling device register failed: %ld\n",
+	if (IS_ERR(data->cooling_dev)) {
+		dev_warn(dev, "thermal cooling device register failed: %ld\n",
 			 PTR_ERR(data->cooling_dev));
+	} else {
+		devm_add_action(dev, max6650_thermal_unregister,
+				data->cooling_dev);
+	}
 #endif
 	return 0;
 }
 
-static int max6650_remove(struct i2c_client *client)
-{
-	struct max6650_data *data = i2c_get_clientdata(client);
-
-	if (!IS_ERR(data->cooling_dev))
-		thermal_cooling_device_unregister(data->cooling_dev);
-
-	return 0;
-}
-
 static const struct i2c_device_id max6650_id[] = {
 	{ "max6650", 1 },
 	{ "max6651", 4 },
@@ -828,7 +826,6 @@ static struct i2c_driver max6650_driver = {
 		.of_match_table = of_match_ptr(max6650_dt_match),
 	},
 	.probe		= max6650_probe,
-	.remove		= max6650_remove,
 	.id_table	= max6650_id,
 };
 
-- 
2.7.4




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux