drivers: make tegra-throughput driver always post fps
[linux-2.6.git] / drivers / misc / nct1008.c
index 68be49a..61cbdca 100644 (file)
@@ -126,11 +126,11 @@ static int nct1008_write_reg(struct i2c_client *client, u8 reg, u16 value)
        }
 
        ret = i2c_smbus_write_byte_data(client, reg, value);
+       mutex_unlock(&data->mutex);
 
        if (ret < 0)
                dev_err(&client->dev, "%s: err %d\n", __func__, ret);
 
-       mutex_unlock(&data->mutex);
        return ret;
 }
 
@@ -145,11 +145,11 @@ static int nct1008_read_reg(struct i2c_client *client, u8 reg)
        }
 
        ret = i2c_smbus_read_byte_data(client, reg);
+       mutex_unlock(&data->mutex);
 
        if (ret < 0)
                dev_err(&client->dev, "%s: err %d\n", __func__, ret);
 
-       mutex_unlock(&data->mutex);
        return ret;
 }
 
@@ -499,8 +499,10 @@ static void nct1008_update(struct nct1008_data *data)
        for (count = 0; count < thz->trips; count++) {
                trip_state = &data->plat_data.trips[count];
                trip_temp = trip_state->trip_temp;
-               hysteresis_temp = trip_state->tripped ?
-                               trip_temp - trip_state->hysteresis : trip_temp;
+               hysteresis_temp = trip_temp - trip_state->hysteresis;
+               if ((trip_state->trip_type == THERMAL_TRIP_PASSIVE) &&
+                   !trip_state->tripped)
+                       hysteresis_temp = trip_temp;
 
                if ((trip_temp >= temp) && (trip_temp < high_temp)) {
                        high_temp = trip_temp;
@@ -591,7 +593,10 @@ static int nct1008_ext_get_trip_temp(struct thermal_zone_device *thz,
 
        *temp = trip_state->trip_temp;
 
-       if (thz->temperature >= trip_state->trip_temp) {
+       if (trip_state->trip_type != THERMAL_TRIP_PASSIVE)
+               return 0;
+
+       if (thz->temperature >= *temp) {
                trip_state->tripped = true;
        } else if (trip_state->tripped) {
                *temp -= trip_state->hysteresis;
@@ -1163,7 +1168,7 @@ static int __devinit nct1008_probe(struct i2c_client *client,
                                        mask,
                                        data,
                                        &nct_ext_ops,
-                                       NULL,
+                                       data->plat_data.tzp,
                                        data->plat_data.passive_delay,
                                        0);
        if (IS_ERR_OR_NULL(data->nct_ext)) {
@@ -1208,12 +1213,12 @@ static int __devexit nct1008_remove(struct i2c_client *client)
 static void nct1008_shutdown(struct i2c_client *client)
 {
        struct nct1008_data *data = i2c_get_clientdata(client);
-       mutex_lock(&data->mutex);
        if (client->irq)
                disable_irq(client->irq);
 
        cancel_work_sync(&data->work);
 
+       mutex_lock(&data->mutex);
        data->shutdown_complete = 1;
        mutex_unlock(&data->mutex);
 }