drivers: misc: nct: bind via cdev type
Joshua Primero [Mon, 19 Nov 2012 23:40:56 +0000 (15:40 -0800)]
Bind thermal cooling devices via type name instead of creating
cooling devices.

Change-Id: I8a116608570b428703e25fbde6e62265a5fedc69
Signed-off-by: Joshua Primero <jprimero@nvidia.com>
Reviewed-on: http://git-master/r/165186
Tested-by: Jinyoung Park <jinyoungp@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Aleksandr Frid <afrid@nvidia.com>
Reviewed-by: Diwakar Tundlam <dtundlam@nvidia.com>

drivers/misc/nct1008.c
include/linux/nct1008.h

index d6e2483..e714e06 100644 (file)
@@ -94,8 +94,6 @@ struct nct1008_data {
        int conv_period_ms;
        long etemp;
 
-       struct thermal_cooling_device *passive_cdev;
-       struct thermal_cooling_device *active_cdev;
        struct thermal_zone_device *nct_int;
        struct thermal_zone_device *nct_ext;
 };
@@ -849,16 +847,20 @@ static int nct1008_ext_bind(struct thermal_zone_device *thz,
        int i;
        struct nct1008_data *data = thz->devdata;
 
-       if (cdev == data->passive_cdev)
-               return thermal_zone_bind_cooling_device(thz, 0, cdev,
-                                                       THERMAL_NO_LIMIT,
-                                                       THERMAL_NO_LIMIT);
+       if (!strcmp(cdev->type, data->plat_data.passive.type)) {
+               thermal_zone_bind_cooling_device(thz, 0, cdev,
+                                                THERMAL_NO_LIMIT,
+                                                THERMAL_NO_LIMIT);
+               nct1008_update(data);
+       }
 
-       if (cdev == data->active_cdev)
+       if (!strcmp(cdev->type, data->plat_data.active.type)) {
                for (i = 0; i < data->plat_data.active.states[i].trip_temp; i++)
                        thermal_zone_bind_cooling_device(thz, i+1, cdev,
                                        data->plat_data.active.states[i].state,
                                        data->plat_data.active.states[i].state);
+               nct1008_update(data);
+       }
 
        return 0;
 }
@@ -869,10 +871,10 @@ static int nct1008_ext_unbind(struct thermal_zone_device *thz,
        int i;
        struct nct1008_data *data = thz->devdata;
 
-       if (cdev == data->passive_cdev)
-               return thermal_zone_unbind_cooling_device(thz, 0, cdev);
+       if (!strcmp(cdev->type, data->plat_data.passive.type))
+               thermal_zone_unbind_cooling_device(thz, 0, cdev);
 
-       if (cdev == data->active_cdev)
+       if (!strcmp(cdev->type, data->plat_data.active.type))
                for (i = 0; i < data->plat_data.active.states[i].trip_temp; i++)
                        thermal_zone_unbind_cooling_device(thz, i+1, cdev);
 
@@ -1059,15 +1061,12 @@ static int __devinit nct1008_probe(struct i2c_client *client,
                err = 0; /* without debugfs we may continue */
 
 #ifdef CONFIG_THERMAL
-       if (data->plat_data.passive.create_cdev) {
-               data->passive_cdev = data->plat_data.passive.create_cdev(
-                                       data->plat_data.passive.cdev_data);
+       if (data->plat_data.passive.enable) {
                mask |= (1 << num_trips);
                num_trips++;
        }
 
-       if (data->plat_data.active.create_cdev) {
-               data->active_cdev = data->plat_data.active.create_cdev(NULL);
+       if (data->plat_data.active.enable) {
                for (i = 0; data->plat_data.active.states[i].trip_temp; i++) {
                        mask |= (1 << num_trips);
                        num_trips++;
index 68b35f1..388f68d 100644 (file)
@@ -40,11 +40,10 @@ struct active_temp_state {
 #define MAX_ACTIVE_TEMP_STATE 16
 
 struct nct1008_cdev {
-       struct thermal_cooling_device *(*create_cdev)(void *);
-       void *cdev_data;
+       bool enable;
+       char *type;
        long trip_temp;
        long hysteresis;
-       enum thermal_trip_type type;
        int tc1;
        int tc2;
        int passive_delay;