Skip to content

Commit 9a99a99

Browse files
committed
thermal: core: Introduce thermal_zone_device_exec()
Introduce a new helper function, thermal_zone_device_exec(), that can be used by drivers to run a given callback routine under the zone lock. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent bc840ea commit 9a99a99

2 files changed

Lines changed: 23 additions & 0 deletions

File tree

drivers/thermal/thermal_core.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,25 @@ void thermal_zone_device_update(struct thermal_zone_device *tz,
497497
}
498498
EXPORT_SYMBOL_GPL(thermal_zone_device_update);
499499

500+
/**
501+
* thermal_zone_device_exec - Run a callback under the zone lock.
502+
* @tz: Thermal zone.
503+
* @cb: Callback to run.
504+
* @data: Data to pass to the callback.
505+
*/
506+
void thermal_zone_device_exec(struct thermal_zone_device *tz,
507+
void (*cb)(struct thermal_zone_device *,
508+
unsigned long),
509+
unsigned long data)
510+
{
511+
mutex_lock(&tz->lock);
512+
513+
cb(tz, data);
514+
515+
mutex_unlock(&tz->lock);
516+
}
517+
EXPORT_SYMBOL_GPL(thermal_zone_device_exec);
518+
500519
static void thermal_zone_device_check(struct work_struct *work)
501520
{
502521
struct thermal_zone_device *tz = container_of(work, struct

include/linux/thermal.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@ int thermal_zone_unbind_cooling_device(struct thermal_zone_device *, int,
323323
struct thermal_cooling_device *);
324324
void thermal_zone_device_update(struct thermal_zone_device *,
325325
enum thermal_notify_event);
326+
void thermal_zone_device_exec(struct thermal_zone_device *tz,
327+
void (*cb)(struct thermal_zone_device *,
328+
unsigned long),
329+
unsigned long data);
326330

327331
struct thermal_cooling_device *thermal_cooling_device_register(const char *,
328332
void *, const struct thermal_cooling_device_ops *);

0 commit comments

Comments
 (0)