]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
thermal: netlink: Pass thermal zone pointer to notify routines
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 3 Jan 2024 11:59:10 +0000 (12:59 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 9 Jan 2024 12:32:23 +0000 (13:32 +0100)
There are several rountines in the thermal netlink API that take a
thermal zone ID or a thermal zone type as their arguments, but from
their callers perspective it would be more convenient to pass a thermal
zone pointer to them and let them extract the necessary data from the
given thermal zone object by themselves.

Modify the code accordingly.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Lukasz Luba <lukasz.luba@arm.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
drivers/thermal/thermal_core.c
drivers/thermal/thermal_netlink.c
drivers/thermal/thermal_netlink.h

index a7e2008d34c9b2ad6df26df6aeba92e23edb641f..c0b012e075f3466a4acbb0e2679b4a684f02ccee 100644 (file)
@@ -211,7 +211,7 @@ exit:
        mutex_unlock(&tz->lock);
        mutex_unlock(&thermal_governor_lock);
 
-       thermal_notify_tz_gov_change(tz->id, policy);
+       thermal_notify_tz_gov_change(tz, policy);
 
        return ret;
 }
@@ -501,9 +501,9 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
        mutex_unlock(&tz->lock);
 
        if (mode == THERMAL_DEVICE_ENABLED)
-               thermal_notify_tz_enable(tz->id);
+               thermal_notify_tz_enable(tz);
        else
-               thermal_notify_tz_disable(tz->id);
+               thermal_notify_tz_disable(tz);
 
        return ret;
 }
@@ -1407,7 +1407,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
        if (atomic_cmpxchg(&tz->need_update, 1, 0))
                thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
 
-       thermal_notify_tz_create(tz->id, tz->type);
+       thermal_notify_tz_create(tz);
 
        return tz;
 
@@ -1466,15 +1466,12 @@ EXPORT_SYMBOL_GPL(thermal_zone_device);
  */
 void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 {
-       int tz_id;
        struct thermal_cooling_device *cdev;
        struct thermal_zone_device *pos = NULL;
 
        if (!tz)
                return;
 
-       tz_id = tz->id;
-
        mutex_lock(&thermal_list_lock);
        list_for_each_entry(pos, &thermal_tz_list, node)
                if (pos == tz)
@@ -1510,7 +1507,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
 
        put_device(&tz->device);
 
-       thermal_notify_tz_delete(tz_id);
+       thermal_notify_tz_delete(tz);
 
        wait_for_completion(&tz->removal);
        kfree(tz);
index 91992181e845cd930fca0952d37812abed55d081..46b0156a63191ea8eed5e71ec224b6cdafef4aff 100644 (file)
@@ -304,30 +304,30 @@ out_free_msg:
        return ret;
 }
 
-int thermal_notify_tz_create(int tz_id, const char *name)
+int thermal_notify_tz_create(const struct thermal_zone_device *tz)
 {
-       struct param p = { .tz_id = tz_id, .name = name };
+       struct param p = { .tz_id = tz->id, .name = tz->type };
 
        return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_CREATE, &p);
 }
 
-int thermal_notify_tz_delete(int tz_id)
+int thermal_notify_tz_delete(const struct thermal_zone_device *tz)
 {
-       struct param p = { .tz_id = tz_id };
+       struct param p = { .tz_id = tz->id };
 
        return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DELETE, &p);
 }
 
-int thermal_notify_tz_enable(int tz_id)
+int thermal_notify_tz_enable(const struct thermal_zone_device *tz)
 {
-       struct param p = { .tz_id = tz_id };
+       struct param p = { .tz_id = tz->id };
 
        return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_ENABLE, &p);
 }
 
-int thermal_notify_tz_disable(int tz_id)
+int thermal_notify_tz_disable(const struct thermal_zone_device *tz)
 {
-       struct param p = { .tz_id = tz_id };
+       struct param p = { .tz_id = tz->id };
 
        return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p);
 }
@@ -386,9 +386,10 @@ int thermal_notify_cdev_delete(int cdev_id)
        return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_DELETE, &p);
 }
 
-int thermal_notify_tz_gov_change(int tz_id, const char *name)
+int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
+                                const char *name)
 {
-       struct param p = { .tz_id = tz_id, .name = name };
+       struct param p = { .tz_id = tz->id, .name = name };
 
        return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_GOV_CHANGE, &p);
 }
index e780ce3f7db6ec0ba160157d8113891510b8068d..13ea2ad23d3ab1ed893b90721f6bb3455ba4a28b 100644 (file)
@@ -17,10 +17,10 @@ struct thermal_trip;
 #ifdef CONFIG_THERMAL_NETLINK
 int __init thermal_netlink_init(void);
 void __init thermal_netlink_exit(void);
-int thermal_notify_tz_create(int tz_id, const char *name);
-int thermal_notify_tz_delete(int tz_id);
-int thermal_notify_tz_enable(int tz_id);
-int thermal_notify_tz_disable(int tz_id);
+int thermal_notify_tz_create(const struct thermal_zone_device *tz);
+int thermal_notify_tz_delete(const struct thermal_zone_device *tz);
+int thermal_notify_tz_enable(const struct thermal_zone_device *tz);
+int thermal_notify_tz_disable(const struct thermal_zone_device *tz);
 int thermal_notify_tz_trip_down(const struct thermal_zone_device *tz,
                                const struct thermal_trip *trip);
 int thermal_notify_tz_trip_up(const struct thermal_zone_device *tz,
@@ -30,7 +30,8 @@ int thermal_notify_tz_trip_change(const struct thermal_zone_device *tz,
 int thermal_notify_cdev_state_update(int cdev_id, int state);
 int thermal_notify_cdev_add(int cdev_id, const char *name, int max_state);
 int thermal_notify_cdev_delete(int cdev_id);
-int thermal_notify_tz_gov_change(int tz_id, const char *name);
+int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
+                                const char *name);
 int thermal_genl_sampling_temp(int id, int temp);
 int thermal_genl_cpu_capability_event(int count,
                                      struct thermal_genl_cpu_caps *caps);
@@ -40,22 +41,22 @@ static inline int thermal_netlink_init(void)
        return 0;
 }
 
-static inline int thermal_notify_tz_create(int tz_id, const char *name)
+static inline int thermal_notify_tz_create(const struct thermal_zone_device *tz)
 {
        return 0;
 }
 
-static inline int thermal_notify_tz_delete(int tz_id)
+static inline int thermal_notify_tz_delete(const struct thermal_zone_device *tz)
 {
        return 0;
 }
 
-static inline int thermal_notify_tz_enable(int tz_id)
+static inline int thermal_notify_tz_enable(const struct thermal_zone_device *tz)
 {
        return 0;
 }
 
-static inline int thermal_notify_tz_disable(int tz_id)
+static inline int thermal_notify_tz_disable(const struct thermal_zone_device *tz)
 {
        return 0;
 }
@@ -94,7 +95,8 @@ static inline int thermal_notify_cdev_delete(int cdev_id)
        return 0;
 }
 
-static inline int thermal_notify_tz_gov_change(int tz_id, const char *name)
+static inline int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
+                                              const char *name)
 {
        return 0;
 }