Merge tag 'hwmon-for-linus-v4.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging
Pull hwmon fix from Guenter Roeck: "Handle errors from thermal subsystem" * tag 'hwmon-for-linus-v4.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging: hwmon: Deal with errors from the thermal subsystem
This commit is contained in:
commit
beacbc68ac
@ -143,6 +143,7 @@ static int hwmon_thermal_add_sensor(struct device *dev,
|
|||||||
struct hwmon_device *hwdev, int index)
|
struct hwmon_device *hwdev, int index)
|
||||||
{
|
{
|
||||||
struct hwmon_thermal_data *tdata;
|
struct hwmon_thermal_data *tdata;
|
||||||
|
struct thermal_zone_device *tzd;
|
||||||
|
|
||||||
tdata = devm_kzalloc(dev, sizeof(*tdata), GFP_KERNEL);
|
tdata = devm_kzalloc(dev, sizeof(*tdata), GFP_KERNEL);
|
||||||
if (!tdata)
|
if (!tdata)
|
||||||
@ -151,8 +152,14 @@ static int hwmon_thermal_add_sensor(struct device *dev,
|
|||||||
tdata->hwdev = hwdev;
|
tdata->hwdev = hwdev;
|
||||||
tdata->index = index;
|
tdata->index = index;
|
||||||
|
|
||||||
devm_thermal_zone_of_sensor_register(&hwdev->dev, index, tdata,
|
tzd = devm_thermal_zone_of_sensor_register(&hwdev->dev, index, tdata,
|
||||||
&hwmon_thermal_ops);
|
&hwmon_thermal_ops);
|
||||||
|
/*
|
||||||
|
* If CONFIG_THERMAL_OF is disabled, this returns -ENODEV,
|
||||||
|
* so ignore that error but forward any other error.
|
||||||
|
*/
|
||||||
|
if (IS_ERR(tzd) && (PTR_ERR(tzd) != -ENODEV))
|
||||||
|
return PTR_ERR(tzd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -621,14 +628,20 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata,
|
|||||||
if (!chip->ops->is_visible(drvdata, hwmon_temp,
|
if (!chip->ops->is_visible(drvdata, hwmon_temp,
|
||||||
hwmon_temp_input, j))
|
hwmon_temp_input, j))
|
||||||
continue;
|
continue;
|
||||||
if (info[i]->config[j] & HWMON_T_INPUT)
|
if (info[i]->config[j] & HWMON_T_INPUT) {
|
||||||
hwmon_thermal_add_sensor(dev, hwdev, j);
|
err = hwmon_thermal_add_sensor(dev,
|
||||||
|
hwdev, j);
|
||||||
|
if (err)
|
||||||
|
goto free_device;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return hdev;
|
return hdev;
|
||||||
|
|
||||||
|
free_device:
|
||||||
|
device_unregister(hdev);
|
||||||
free_hwmon:
|
free_hwmon:
|
||||||
kfree(hwdev);
|
kfree(hwdev);
|
||||||
ida_remove:
|
ida_remove:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user