@@ -994,6 +994,19 @@ __thermal_cooling_device_register(struct device_node *np,
list_add(&cdev->node, &thermal_cdev_list);
mutex_unlock(&thermal_list_lock);
+ /* Call into cdev late initialization if defined */
+ if (cdev->ops->late_init) {
+ result = cdev->ops->late_init(cdev);
+ if (result) {
+ ida_simple_remove(&thermal_cdev_ida, cdev->id);
+ put_device(&cdev->device);
+ mutex_lock(&thermal_list_lock);
+ list_del(&cdev->node);
+ mutex_unlock(&thermal_list_lock);
+ return ERR_PTR(result);
+ }
+ }
+
/* Update binding information for 'this' new cdev */
bind_cdev(cdev);
@@ -125,6 +125,7 @@ struct thermal_cooling_device_ops {
struct thermal_zone_device *, unsigned long, u32 *);
int (*power2state)(struct thermal_cooling_device *,
struct thermal_zone_device *, u32, unsigned long *);
+ int (*late_init)(struct thermal_cooling_device *);
};
struct thermal_cooling_device {
Add a hook in thermal_cooling_device_ops to be called after the cooling device has been initialized and registered but before binding it to a thermal zone. In this patch series it is used to hook up a power domain to the device pointer of cooling device. It can be used for any other relevant late initializations of a cooling device as well. Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org> --- drivers/thermal/thermal_core.c | 13 +++++++++++++ include/linux/thermal.h | 1 + 2 files changed, 14 insertions(+) -- 2.1.4