mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 17:47:41 +02:00
thermal/of: Pass cdev_id and introduce devm registration helper
Extend the OF cooling device registration to support an explicit cooling device identifier (cdev_id), preparing for upcoming DT bindings where cooling devices are identified by a tuple (device node, id) instead of relying on child nodes. Introduce a new helper: devm_thermal_of_cooling_device_register() which registers a cooling device using the device's of_node and an explicit cdev_id. This complements the existing devm_thermal_of_child_cooling_device_register() helper, which remains dedicated to the legacy child-node based bindings. Internally, factorize the devm registration logic into a common helper to avoid code duplication. Existing users are unaffected, as the child-based helper continues to pass a default cdev_id of 0, preserving current behavior. This change is a preparatory step for supporting indexed cooling devices in thermal OF bindings. Signed-off-by: Daniel Lezcano <daniel.lezcano@oss.qualcomm.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@kernel.org> Reviewed-by: Lukasz Luba <lukasz.luba@arm.com> Acked-by: Rafael J. Wysocki (Intel) <rafael@kernel.org> Link: https://patch.msgid.link/20260526140802.1059293-20-daniel.lezcano@oss.qualcomm.com
This commit is contained in:
parent
37324803f0
commit
3570cb58e3
|
|
@ -558,6 +558,51 @@ static void thermal_of_cooling_device_release(void *data)
|
|||
thermal_cooling_device_unregister(cdev);
|
||||
}
|
||||
|
||||
static struct thermal_cooling_device *
|
||||
__devm_thermal_of_cooling_device_register(struct device *dev, struct device_node *np,
|
||||
u32 cdev_id, const char *type, void *devdata,
|
||||
const struct thermal_cooling_device_ops *ops)
|
||||
{
|
||||
struct thermal_cooling_device *cdev;
|
||||
int ret;
|
||||
|
||||
cdev = thermal_of_cooling_device_register(np, cdev_id, type, devdata, ops);
|
||||
if (IS_ERR(cdev))
|
||||
return cdev;
|
||||
|
||||
ret = devm_add_action_or_reset(dev, thermal_of_cooling_device_release, cdev);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
return cdev;
|
||||
}
|
||||
|
||||
/**
|
||||
* devm_thermal_of_cooling_device_register() - register an OF thermal cooling device
|
||||
* @dev: a valid struct device pointer of a sensor device.
|
||||
* @cdev_id: a cooling device index in the cooling controller
|
||||
* @type: the thermal cooling device type.
|
||||
* @devdata: device private data.
|
||||
* @ops: standard thermal cooling devices callbacks.
|
||||
*
|
||||
* This function will register a cooling device with device tree node reference.
|
||||
* This interface function adds a new thermal cooling device (fan/processor/...)
|
||||
* to /sys/class/thermal/ folder as cooling_device[0-*]. It tries to bind itself
|
||||
* to all the thermal zone devices registered at the same time.
|
||||
*
|
||||
* Return: a pointer to the created struct thermal_cooling_device or an
|
||||
* ERR_PTR. Caller must check return value with IS_ERR*() helpers.
|
||||
*/
|
||||
struct thermal_cooling_device *
|
||||
devm_thermal_of_cooling_device_register(struct device *dev, u32 cdev_id,
|
||||
const char *type, void *devdata,
|
||||
const struct thermal_cooling_device_ops *ops)
|
||||
{
|
||||
return __devm_thermal_of_cooling_device_register(dev, dev->of_node, cdev_id,
|
||||
type, devdata, ops);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_thermal_of_cooling_device_register);
|
||||
|
||||
/**
|
||||
* devm_thermal_of_child_cooling_device_register() - register an OF thermal cooling
|
||||
* device
|
||||
|
|
@ -584,17 +629,6 @@ devm_thermal_of_child_cooling_device_register(struct device *dev,
|
|||
const char *type, void *devdata,
|
||||
const struct thermal_cooling_device_ops *ops)
|
||||
{
|
||||
struct thermal_cooling_device *cdev;
|
||||
int ret;
|
||||
|
||||
cdev = thermal_of_cooling_device_register(np, 0, type, devdata, ops);
|
||||
if (IS_ERR(cdev))
|
||||
return cdev;
|
||||
|
||||
ret = devm_add_action_or_reset(dev, thermal_of_cooling_device_release, cdev);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
return cdev;
|
||||
return __devm_thermal_of_cooling_device_register(dev, np, 0, type, devdata, ops);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(devm_thermal_of_child_cooling_device_register);
|
||||
|
|
|
|||
|
|
@ -206,6 +206,11 @@ thermal_of_cooling_device_register(struct device_node *np, u32 cdev_id,
|
|||
const char *type, void *data,
|
||||
const struct thermal_cooling_device_ops *ops);
|
||||
|
||||
struct thermal_cooling_device *
|
||||
devm_thermal_of_cooling_device_register(struct device *dev, u32 cdev_id,
|
||||
const char *type, void *devdata,
|
||||
const struct thermal_cooling_device_ops *ops);
|
||||
|
||||
struct thermal_cooling_device *
|
||||
devm_thermal_of_child_cooling_device_register(struct device *dev,
|
||||
struct device_node *np,
|
||||
|
|
@ -233,6 +238,14 @@ thermal_of_cooling_device_register(struct device_node *np, u32 cdev_id,
|
|||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
|
||||
static inline struct thermal_cooling_device *
|
||||
devm_thermal_of_cooling_device_register(struct device *dev, u32 cdev_id,
|
||||
const char *type, void *devdata,
|
||||
const struct thermal_cooling_device_ops *ops)
|
||||
{
|
||||
return ERR_PTR(-ENODEV);
|
||||
}
|
||||
|
||||
static inline struct thermal_cooling_device *
|
||||
devm_thermal_of_child_cooling_device_register(struct device *dev,
|
||||
struct device_node *np,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user