Skip to content

Commit 2f52189

Browse files
committed
thermal: netlink: Pass thermal zone pointer to notify routines
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>
1 parent 4ae535f commit 2f52189

3 files changed

Lines changed: 28 additions & 28 deletions

File tree

drivers/thermal/thermal_core.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ int thermal_zone_device_set_policy(struct thermal_zone_device *tz,
211211
mutex_unlock(&tz->lock);
212212
mutex_unlock(&thermal_governor_lock);
213213

214-
thermal_notify_tz_gov_change(tz->id, policy);
214+
thermal_notify_tz_gov_change(tz, policy);
215215

216216
return ret;
217217
}
@@ -501,9 +501,9 @@ static int thermal_zone_device_set_mode(struct thermal_zone_device *tz,
501501
mutex_unlock(&tz->lock);
502502

503503
if (mode == THERMAL_DEVICE_ENABLED)
504-
thermal_notify_tz_enable(tz->id);
504+
thermal_notify_tz_enable(tz);
505505
else
506-
thermal_notify_tz_disable(tz->id);
506+
thermal_notify_tz_disable(tz);
507507

508508
return ret;
509509
}
@@ -1407,7 +1407,7 @@ thermal_zone_device_register_with_trips(const char *type, struct thermal_trip *t
14071407
if (atomic_cmpxchg(&tz->need_update, 1, 0))
14081408
thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
14091409

1410-
thermal_notify_tz_create(tz->id, tz->type);
1410+
thermal_notify_tz_create(tz);
14111411

14121412
return tz;
14131413

@@ -1466,15 +1466,12 @@ EXPORT_SYMBOL_GPL(thermal_zone_device);
14661466
*/
14671467
void thermal_zone_device_unregister(struct thermal_zone_device *tz)
14681468
{
1469-
int tz_id;
14701469
struct thermal_cooling_device *cdev;
14711470
struct thermal_zone_device *pos = NULL;
14721471

14731472
if (!tz)
14741473
return;
14751474

1476-
tz_id = tz->id;
1477-
14781475
mutex_lock(&thermal_list_lock);
14791476
list_for_each_entry(pos, &thermal_tz_list, node)
14801477
if (pos == tz)
@@ -1510,7 +1507,7 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz)
15101507

15111508
put_device(&tz->device);
15121509

1513-
thermal_notify_tz_delete(tz_id);
1510+
thermal_notify_tz_delete(tz);
15141511

15151512
wait_for_completion(&tz->removal);
15161513
kfree(tz);

drivers/thermal/thermal_netlink.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,30 +304,30 @@ static int thermal_genl_send_event(enum thermal_genl_event event,
304304
return ret;
305305
}
306306

307-
int thermal_notify_tz_create(int tz_id, const char *name)
307+
int thermal_notify_tz_create(const struct thermal_zone_device *tz)
308308
{
309-
struct param p = { .tz_id = tz_id, .name = name };
309+
struct param p = { .tz_id = tz->id, .name = tz->type };
310310

311311
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_CREATE, &p);
312312
}
313313

314-
int thermal_notify_tz_delete(int tz_id)
314+
int thermal_notify_tz_delete(const struct thermal_zone_device *tz)
315315
{
316-
struct param p = { .tz_id = tz_id };
316+
struct param p = { .tz_id = tz->id };
317317

318318
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DELETE, &p);
319319
}
320320

321-
int thermal_notify_tz_enable(int tz_id)
321+
int thermal_notify_tz_enable(const struct thermal_zone_device *tz)
322322
{
323-
struct param p = { .tz_id = tz_id };
323+
struct param p = { .tz_id = tz->id };
324324

325325
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_ENABLE, &p);
326326
}
327327

328-
int thermal_notify_tz_disable(int tz_id)
328+
int thermal_notify_tz_disable(const struct thermal_zone_device *tz)
329329
{
330-
struct param p = { .tz_id = tz_id };
330+
struct param p = { .tz_id = tz->id };
331331

332332
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_DISABLE, &p);
333333
}
@@ -386,9 +386,10 @@ int thermal_notify_cdev_delete(int cdev_id)
386386
return thermal_genl_send_event(THERMAL_GENL_EVENT_CDEV_DELETE, &p);
387387
}
388388

389-
int thermal_notify_tz_gov_change(int tz_id, const char *name)
389+
int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
390+
const char *name)
390391
{
391-
struct param p = { .tz_id = tz_id, .name = name };
392+
struct param p = { .tz_id = tz->id, .name = name };
392393

393394
return thermal_genl_send_event(THERMAL_GENL_EVENT_TZ_GOV_CHANGE, &p);
394395
}

drivers/thermal/thermal_netlink.h

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ struct thermal_trip;
1717
#ifdef CONFIG_THERMAL_NETLINK
1818
int __init thermal_netlink_init(void);
1919
void __init thermal_netlink_exit(void);
20-
int thermal_notify_tz_create(int tz_id, const char *name);
21-
int thermal_notify_tz_delete(int tz_id);
22-
int thermal_notify_tz_enable(int tz_id);
23-
int thermal_notify_tz_disable(int tz_id);
20+
int thermal_notify_tz_create(const struct thermal_zone_device *tz);
21+
int thermal_notify_tz_delete(const struct thermal_zone_device *tz);
22+
int thermal_notify_tz_enable(const struct thermal_zone_device *tz);
23+
int thermal_notify_tz_disable(const struct thermal_zone_device *tz);
2424
int thermal_notify_tz_trip_down(const struct thermal_zone_device *tz,
2525
const struct thermal_trip *trip);
2626
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,
3030
int thermal_notify_cdev_state_update(int cdev_id, int state);
3131
int thermal_notify_cdev_add(int cdev_id, const char *name, int max_state);
3232
int thermal_notify_cdev_delete(int cdev_id);
33-
int thermal_notify_tz_gov_change(int tz_id, const char *name);
33+
int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
34+
const char *name);
3435
int thermal_genl_sampling_temp(int id, int temp);
3536
int thermal_genl_cpu_capability_event(int count,
3637
struct thermal_genl_cpu_caps *caps);
@@ -40,22 +41,22 @@ static inline int thermal_netlink_init(void)
4041
return 0;
4142
}
4243

43-
static inline int thermal_notify_tz_create(int tz_id, const char *name)
44+
static inline int thermal_notify_tz_create(const struct thermal_zone_device *tz)
4445
{
4546
return 0;
4647
}
4748

48-
static inline int thermal_notify_tz_delete(int tz_id)
49+
static inline int thermal_notify_tz_delete(const struct thermal_zone_device *tz)
4950
{
5051
return 0;
5152
}
5253

53-
static inline int thermal_notify_tz_enable(int tz_id)
54+
static inline int thermal_notify_tz_enable(const struct thermal_zone_device *tz)
5455
{
5556
return 0;
5657
}
5758

58-
static inline int thermal_notify_tz_disable(int tz_id)
59+
static inline int thermal_notify_tz_disable(const struct thermal_zone_device *tz)
5960
{
6061
return 0;
6162
}
@@ -94,7 +95,8 @@ static inline int thermal_notify_cdev_delete(int cdev_id)
9495
return 0;
9596
}
9697

97-
static inline int thermal_notify_tz_gov_change(int tz_id, const char *name)
98+
static inline int thermal_notify_tz_gov_change(const struct thermal_zone_device *tz,
99+
const char *name)
98100
{
99101
return 0;
100102
}

0 commit comments

Comments
 (0)