hwmon: (ntc_thermistor) Use devm_iio_channel_get
Use devm_iio_channel_get() instead of iio_channel_get to simplify error handling and device removal. Signed-off-by: Guenter Roeck <linux@roeck-us.net>
This commit is contained in:
parent
cc00decf0e
commit
6402085676
|
@ -331,7 +331,7 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
|
||||||
chan = iio_channel_get(&pdev->dev, NULL);
|
chan = devm_iio_channel_get(&pdev->dev, NULL);
|
||||||
if (IS_ERR(chan))
|
if (IS_ERR(chan))
|
||||||
return ERR_CAST(chan);
|
return ERR_CAST(chan);
|
||||||
|
|
||||||
|
@ -359,11 +359,6 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
|
||||||
|
|
||||||
return pdata;
|
return pdata;
|
||||||
}
|
}
|
||||||
static void ntc_iio_channel_release(struct ntc_thermistor_platform_data *pdata)
|
|
||||||
{
|
|
||||||
if (pdata->chan)
|
|
||||||
iio_channel_release(pdata->chan);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
static struct ntc_thermistor_platform_data *
|
static struct ntc_thermistor_platform_data *
|
||||||
ntc_thermistor_parse_dt(struct platform_device *pdev)
|
ntc_thermistor_parse_dt(struct platform_device *pdev)
|
||||||
|
@ -373,8 +368,6 @@ ntc_thermistor_parse_dt(struct platform_device *pdev)
|
||||||
|
|
||||||
#define ntc_match NULL
|
#define ntc_match NULL
|
||||||
|
|
||||||
static void ntc_iio_channel_release(struct ntc_thermistor_platform_data *pdata)
|
|
||||||
{ }
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline u64 div64_u64_safe(u64 dividend, u64 divisor)
|
static inline u64 div64_u64_safe(u64 dividend, u64 divisor)
|
||||||
|
@ -685,18 +678,15 @@ static int ntc_thermistor_probe(struct platform_device *pdev)
|
||||||
return 0;
|
return 0;
|
||||||
err_after_sysfs:
|
err_after_sysfs:
|
||||||
sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
|
sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
|
||||||
ntc_iio_channel_release(pdata);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ntc_thermistor_remove(struct platform_device *pdev)
|
static int ntc_thermistor_remove(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct ntc_data *data = platform_get_drvdata(pdev);
|
struct ntc_data *data = platform_get_drvdata(pdev);
|
||||||
struct ntc_thermistor_platform_data *pdata = data->pdata;
|
|
||||||
|
|
||||||
hwmon_device_unregister(data->hwmon_dev);
|
hwmon_device_unregister(data->hwmon_dev);
|
||||||
sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
|
sysfs_remove_group(&data->dev->kobj, &ntc_attr_group);
|
||||||
ntc_iio_channel_release(pdata);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue