thermal: reference thermal instances in thermal_cooling_device
Zhang Rui
reviewerRFC PATCH 10/12 thermal: reference thermal instances in thermal_cooling_device
reference thermal instances in thermal_cooling_device.
so that cooling device can know the cooling state requirement of all the thermal instances.
Signed-off-by Zhang Rui <[email protected]>
--- drivers/thermal/thermal_sys.c | 7 ++++++- include/linux/thermal.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-)
include/linux/thermal.h +1 -0
@@ -86,6 +86,7 @@ struct thermal_cooling_device {struct device device;void *devdata;const struct thermal_cooling_device_ops *ops; +struct list_head instances;struct list_head node; };
drivers/thermal/thermal_sys.c +6 -1
@@ -57,6 +57,7 @@ struct thermal_instance {char attr_name[THERMAL_NAME_LENGTH ];struct device_attribute attr;struct list_head tz_node;/* node in tz->instances */ +struct list_head cdev_node;/* node in cdev->instances */ };static DEFINE_IDR (thermal_tz_idr);
@@ -837,8 +838,10 @@ int thermal_zone_bind_cooling_device(str result = -EEXIST ;break ; } -if (!result) +if (!result) {list_add_tail (&dev->tz_node, &tz->instances); +list_add_tail (&dev->cdev_node, &cdev->instances); + }mutex_unlock (&tz->lock);if (!result)
@@ -874,6 +877,7 @@ int thermal_zone_unbind_cooling_device(slist_for_each_entry_safe (pos, next, &tz->instances, tz_node) {if (pos->tz == tz && pos->trip == trip && pos->cdev == cdev) {list_del (&pos->tz_node); +list_del (&pos->cdev_node);mutex_unlock (&tz->lock); goto unbind; }
@@ -943,6 +947,7 @@ thermal_cooling_device_register(char *ty }strcpy (cdev->type, type); +INIT_LIST_HEAD (&cdev->instances); cdev->ops = ops; cdev->device.class = &thermal_class; cdev->devdata = devdata;