Skip to content

Commit e5d2107

Browse files
committed
hwmon: Introduce hwmon_device_register_for_thermal
The thermal subsystem registers a hwmon driver without providing chip or sysfs group information. This is for legacy reasons and would be difficult to change. At the same time, we want to enforce that chip information is provided when registering a hwmon device using hwmon_device_register_with_info(). To enable this, introduce a special API for use only by the thermal subsystem. Acked-by: Rafael J . Wysocki <rafael@kernel.org> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
1 parent 59e746c commit e5d2107

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

drivers/hwmon/hwmon.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,31 @@ hwmon_device_register_with_info(struct device *dev, const char *name,
916916
}
917917
EXPORT_SYMBOL_GPL(hwmon_device_register_with_info);
918918

919+
/**
920+
* hwmon_device_register_for_thermal - register hwmon device for thermal subsystem
921+
* @dev: the parent device
922+
* @name: hwmon name attribute
923+
* @drvdata: driver data to attach to created device
924+
*
925+
* The use of this function is restricted. It is provided for legacy reasons
926+
* and must only be called from the thermal subsystem.
927+
*
928+
* hwmon_device_unregister() must be called when the device is no
929+
* longer needed.
930+
*
931+
* Returns the pointer to the new device.
932+
*/
933+
struct device *
934+
hwmon_device_register_for_thermal(struct device *dev, const char *name,
935+
void *drvdata)
936+
{
937+
if (!name || !dev)
938+
return ERR_PTR(-EINVAL);
939+
940+
return __hwmon_device_register(dev, name, drvdata, NULL, NULL);
941+
}
942+
EXPORT_SYMBOL_NS_GPL(hwmon_device_register_for_thermal, HWMON_THERMAL);
943+
919944
/**
920945
* hwmon_device_register - register w/ hwmon
921946
* @dev: the device to register

include/linux/hwmon.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ hwmon_device_register_with_info(struct device *dev,
450450
const struct hwmon_chip_info *info,
451451
const struct attribute_group **extra_groups);
452452
struct device *
453+
hwmon_device_register_for_thermal(struct device *dev, const char *name,
454+
void *drvdata);
455+
struct device *
453456
devm_hwmon_device_register_with_info(struct device *dev,
454457
const char *name, void *drvdata,
455458
const struct hwmon_chip_info *info,

0 commit comments

Comments
 (0)