]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/thermal/thermal_core.c
Merge tag 'for-5.4/dm-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/device...
[linux.git] / drivers / thermal / thermal_core.c
index 6bab66e84eb58c6fc86d1528bf5ffdfa4a1dfc4b..d4481cc8958fec35b5e6ca6fc1b4c677b8ca86a1 100644 (file)
@@ -304,7 +304,7 @@ static void thermal_zone_device_set_polling(struct thermal_zone_device *tz,
                                 &tz->poll_queue,
                                 msecs_to_jiffies(delay));
        else
-               cancel_delayed_work(&tz->poll_queue);
+               cancel_delayed_work_sync(&tz->poll_queue);
 }
 
 static void monitor_thermal_zone(struct thermal_zone_device *tz)
@@ -985,7 +985,7 @@ __thermal_cooling_device_register(struct device_node *np,
        result = device_register(&cdev->device);
        if (result) {
                ida_simple_remove(&thermal_cdev_ida, cdev->id);
-               kfree(cdev);
+               put_device(&cdev->device);
                return ERR_PTR(result);
        }
 
@@ -1240,21 +1240,31 @@ thermal_zone_device_register(const char *type, int trips, int mask,
        struct thermal_zone_device *tz;
        enum thermal_trip_type trip_type;
        int trip_temp;
+       int id;
        int result;
        int count;
        struct thermal_governor *governor;
 
-       if (!type || strlen(type) == 0)
+       if (!type || strlen(type) == 0) {
+               pr_err("Error: No thermal zone type defined\n");
                return ERR_PTR(-EINVAL);
+       }
 
-       if (type && strlen(type) >= THERMAL_NAME_LENGTH)
+       if (type && strlen(type) >= THERMAL_NAME_LENGTH) {
+               pr_err("Error: Thermal zone name (%s) too long, should be under %d chars\n",
+                      type, THERMAL_NAME_LENGTH);
                return ERR_PTR(-EINVAL);
+       }
 
-       if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips)
+       if (trips > THERMAL_MAX_TRIPS || trips < 0 || mask >> trips) {
+               pr_err("Error: Incorrect number of thermal trips\n");
                return ERR_PTR(-EINVAL);
+       }
 
-       if (!ops)
+       if (!ops) {
+               pr_err("Error: Thermal zone device ops not defined\n");
                return ERR_PTR(-EINVAL);
+       }
 
        if (trips > 0 && (!ops->get_trip_type || !ops->get_trip_temp))
                return ERR_PTR(-EINVAL);
@@ -1266,11 +1276,13 @@ thermal_zone_device_register(const char *type, int trips, int mask,
        INIT_LIST_HEAD(&tz->thermal_instances);
        ida_init(&tz->ida);
        mutex_init(&tz->lock);
-       result = ida_simple_get(&thermal_tz_ida, 0, 0, GFP_KERNEL);
-       if (result < 0)
+       id = ida_simple_get(&thermal_tz_ida, 0, 0, GFP_KERNEL);
+       if (id < 0) {
+               result = id;
                goto free_tz;
+       }
 
-       tz->id = result;
+       tz->id = id;
        strlcpy(tz->type, type, sizeof(tz->type));
        tz->ops = ops;
        tz->tzp = tzp;
@@ -1292,7 +1304,7 @@ thermal_zone_device_register(const char *type, int trips, int mask,
        dev_set_name(&tz->device, "thermal_zone%d", tz->id);
        result = device_register(&tz->device);
        if (result)
-               goto remove_device_groups;
+               goto release_device;
 
        for (count = 0; count < trips; count++) {
                if (tz->ops->get_trip_type(tz, count, &trip_type))
@@ -1343,14 +1355,12 @@ thermal_zone_device_register(const char *type, int trips, int mask,
        return tz;
 
 unregister:
-       ida_simple_remove(&thermal_tz_ida, tz->id);
-       device_unregister(&tz->device);
-       return ERR_PTR(result);
-
-remove_device_groups:
-       thermal_zone_destroy_device_groups(tz);
+       device_del(&tz->device);
+release_device:
+       put_device(&tz->device);
+       tz = NULL;
 remove_id:
-       ida_simple_remove(&thermal_tz_ida, tz->id);
+       ida_simple_remove(&thermal_tz_ida, id);
 free_tz:
        kfree(tz);
        return ERR_PTR(result);