Skip to content

Commit 2115cbe

Browse files
Florin Leotescugroeck
authored andcommitted
hwmon: emc2305: Use devm_thermal_of_cooling_device_register
Prepare the emc2305 driver to use configuration from Device Tree nodes. Switch to devm_thermal_of_cooling_device_register to simplify the cleanup procedure, allowing the removal of emc2305_unset_tz and emc2305_remove, which are no longer needed. Signed-off-by: Florin Leotescu <florin.leotescu@nxp.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Link: https://lore.kernel.org/r/20250321143308.4008623-4-florin.leotescu@oss.nxp.com Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 882bd6d commit 2115cbe

File tree

1 file changed

+4
-29
lines changed

1 file changed

+4
-29
lines changed

drivers/hwmon/emc2305.c

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ static char *emc2305_fan_name[] = {
112112
"emc2305_fan5",
113113
};
114114

115-
static void emc2305_unset_tz(struct device *dev);
116-
117115
static int emc2305_get_max_channel(const struct emc2305_data *data)
118116
{
119117
return data->pwm_num;
@@ -293,8 +291,9 @@ static int emc2305_set_single_tz(struct device *dev, int idx)
293291
pwm = data->pwm_min[cdev_idx];
294292

295293
data->cdev_data[cdev_idx].cdev =
296-
thermal_cooling_device_register(emc2305_fan_name[idx], data,
297-
&emc2305_cooling_ops);
294+
devm_thermal_of_cooling_device_register(dev, dev->of_node,
295+
emc2305_fan_name[idx], data,
296+
&emc2305_cooling_ops);
298297

299298
if (IS_ERR(data->cdev_data[cdev_idx].cdev)) {
300299
dev_err(dev, "Failed to register cooling device %s\n", emc2305_fan_name[idx]);
@@ -332,24 +331,9 @@ static int emc2305_set_tz(struct device *dev)
332331
for (i = 0; i < data->pwm_num; i++) {
333332
ret = emc2305_set_single_tz(dev, i + 1);
334333
if (ret)
335-
goto thermal_cooling_device_register_fail;
334+
return ret;
336335
}
337336
return 0;
338-
339-
thermal_cooling_device_register_fail:
340-
emc2305_unset_tz(dev);
341-
return ret;
342-
}
343-
344-
static void emc2305_unset_tz(struct device *dev)
345-
{
346-
struct emc2305_data *data = dev_get_drvdata(dev);
347-
int i;
348-
349-
/* Unregister cooling device. */
350-
for (i = 0; i < EMC2305_PWM_MAX; i++)
351-
if (data->cdev_data[i].cdev)
352-
thermal_cooling_device_unregister(data->cdev_data[i].cdev);
353337
}
354338

355339
static umode_t
@@ -599,14 +583,6 @@ static int emc2305_probe(struct i2c_client *client)
599583
return 0;
600584
}
601585

602-
static void emc2305_remove(struct i2c_client *client)
603-
{
604-
struct device *dev = &client->dev;
605-
606-
if (IS_REACHABLE(CONFIG_THERMAL))
607-
emc2305_unset_tz(dev);
608-
}
609-
610586
static const struct of_device_id of_emc2305_match_table[] = {
611587
{ .compatible = "microchip,emc2305", },
612588
{},
@@ -619,7 +595,6 @@ static struct i2c_driver emc2305_driver = {
619595
.of_match_table = of_emc2305_match_table,
620596
},
621597
.probe = emc2305_probe,
622-
.remove = emc2305_remove,
623598
.id_table = emc2305_ids,
624599
};
625600

0 commit comments

Comments
 (0)