drivers: thermal: Add find device function
Joshua Primero [Tue, 28 Aug 2012 17:00:39 +0000 (10:00 -0700)]
Added functionality to the linux thermal driver to find a
particular device.

Change-Id: I414ddcaa2607efb32a2a622676e3b9cd64758dc7
Signed-off-by: Joshua Primero <jprimero@nvidia.com>
Reviewed-on: http://git-master/r/130283
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/thermal/thermal_sys.c
include/linux/thermal.h

index 022bacb..b27f7a6 100644 (file)
@@ -1088,6 +1088,23 @@ leave:
 }
 EXPORT_SYMBOL(thermal_zone_device_update);
 
+struct thermal_zone_device *thermal_zone_device_find(void *data,
+       int (*match)(struct thermal_zone_device *, void *))
+{
+       struct thermal_zone_device *thz;
+
+       mutex_lock(&thermal_list_lock);
+       list_for_each_entry(thz, &thermal_tz_list, node)
+               if (match(thz, data)) {
+                       mutex_unlock(&thermal_list_lock);
+                       return thz;
+               }
+
+       mutex_unlock(&thermal_list_lock);
+       return NULL;
+}
+EXPORT_SYMBOL(thermal_zone_device_find);
+
 /**
  * thermal_zone_device_register - register a new thermal zone device
  * @type:      the thermal zone device type
index 796f1ff..c960452 100644 (file)
@@ -150,6 +150,8 @@ void thermal_zone_device_update(struct thermal_zone_device *);
 struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
                const struct thermal_cooling_device_ops *);
 void thermal_cooling_device_unregister(struct thermal_cooling_device *);
+struct thermal_zone_device *thermal_zone_device_find(void *data,
+       int (*match)(struct thermal_zone_device *, void *));
 
 #ifdef CONFIG_NET
 extern int thermal_generate_netlink_event(u32 orig, enum events event);