Currently, cooling devices have no parent device, potentially causing
issues with suspend ordering and making it impossible for consumers
(thermal zones and userspace appications) to associate a given cooling
device with its parent device.

Extend __thermal_cooling_device_register() to also accept a parent
device pointer. For now only devm_thermal_of_cooling_device_register()
uses this, as the other wrapper functions need to be extended first.

Signed-off-by: Armin Wolf <[email protected]>
---
 drivers/thermal/thermal_core.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 17ca5c082643..c8b720194b44 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -1040,6 +1040,7 @@ static void thermal_cooling_device_init_complete(struct 
thermal_cooling_device *
 
 /**
  * __thermal_cooling_device_register() - register a new thermal cooling device
+ * @parent:    parent device pointer.
  * @np:                a pointer to a device tree node.
  * @type:      the thermal cooling device type.
  * @devdata:   device private data.
@@ -1055,7 +1056,7 @@ static void thermal_cooling_device_init_complete(struct 
thermal_cooling_device *
  * ERR_PTR. Caller must check return value with IS_ERR*() helpers.
  */
 static struct thermal_cooling_device *
-__thermal_cooling_device_register(struct device_node *np,
+__thermal_cooling_device_register(struct device *parent, struct device_node 
*np,
                                  const char *type, void *devdata,
                                  const struct thermal_cooling_device_ops *ops)
 {
@@ -1092,6 +1093,7 @@ __thermal_cooling_device_register(struct device_node *np,
        cdev->ops = ops;
        cdev->updated = false;
        cdev->device.class = thermal_class;
+       cdev->device.parent = parent;
        cdev->devdata = devdata;
 
        ret = cdev->ops->get_max_state(cdev, &cdev->max_state);
@@ -1158,7 +1160,7 @@ struct thermal_cooling_device *
 thermal_cooling_device_register(const char *type, void *devdata,
                                const struct thermal_cooling_device_ops *ops)
 {
-       return __thermal_cooling_device_register(NULL, type, devdata, ops);
+       return __thermal_cooling_device_register(NULL, NULL, type, devdata, 
ops);
 }
 EXPORT_SYMBOL_GPL(thermal_cooling_device_register);
 
@@ -1182,7 +1184,7 @@ thermal_of_cooling_device_register(struct device_node *np,
                                   const char *type, void *devdata,
                                   const struct thermal_cooling_device_ops *ops)
 {
-       return __thermal_cooling_device_register(np, type, devdata, ops);
+       return __thermal_cooling_device_register(NULL, np, type, devdata, ops);
 }
 EXPORT_SYMBOL_GPL(thermal_of_cooling_device_register);
 
@@ -1222,7 +1224,7 @@ devm_thermal_of_cooling_device_register(struct device 
*dev,
        if (!ptr)
                return ERR_PTR(-ENOMEM);
 
-       tcd = __thermal_cooling_device_register(np, type, devdata, ops);
+       tcd = __thermal_cooling_device_register(dev, np, type, devdata, ops);
        if (IS_ERR(tcd)) {
                devres_free(ptr);
                return tcd;

-- 
2.39.5

Reply via email to