diff options
author | Sang-Hun Lee <sanlee@nvidia.com> | 2013-05-13 10:06:00 -0700 |
---|---|---|
committer | Mandar Padmawar <mpadmawar@nvidia.com> | 2013-05-23 23:09:09 -0700 |
commit | 06cb33e1a598426e67bf2ced08cd37f798995013 (patch) | |
tree | d9de84881e9b04bea32a7c2e77d533c6f4e2bd6b | |
parent | fbaa987c3143381c22c7846718764a6e6110c723 (diff) |
misc: nct1008: talk to nct1008 only when powered
Problem description:
- nct1008_suspend powers off nct1008
- nct1008_suspend does stop the workqueue and irq, but
if there is a kernel thread which would trigger
nct1008_read_reg or nct1008_write_reg, nct1008 would
still be accessed after it is powered off
Fix description:
- Rename the existing flag shutdown_complete to nct_disabled
- Update the value of nct_disabled when powering nct1008 on and off
Bug 1288427
Change-Id: Id885794eb39a71025ad9f5c3615156c19039d13f
Signed-off-by: Sang-Hun Lee <sanlee@nvidia.com>
Reviewed-on: http://git-master/r/228011
(cherry picked from commit 08eed1ddbacece2f1c8b4fba633c01c0f87ba2cd)
Reviewed-on: http://git-master/r/232275
Reviewed-by: Matt Wagner <mwagner@nvidia.com>
Tested-by: Matt Wagner <mwagner@nvidia.com>
GVS: Gerrit_Virtual_Submit
-rw-r--r-- | drivers/misc/nct1008.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/misc/nct1008.c b/drivers/misc/nct1008.c index 3808f4dce7f7..e6aa33d9a9ff 100644 --- a/drivers/misc/nct1008.c +++ b/drivers/misc/nct1008.c @@ -95,7 +95,7 @@ struct nct1008_data { long current_hi_limit; int conv_period_ms; long etemp; - int shutdown_complete; + int nct_disabled; int stop_workqueue; struct thermal_zone_device *nct_int; struct thermal_zone_device *nct_ext; @@ -120,7 +120,7 @@ static int nct1008_write_reg(struct i2c_client *client, u8 reg, u16 value) struct nct1008_data *data = i2c_get_clientdata(client); mutex_lock(&data->mutex); - if (data && data->shutdown_complete) { + if (data && data->nct_disabled) { mutex_unlock(&data->mutex); return -ENODEV; } @@ -139,7 +139,7 @@ static int nct1008_read_reg(struct i2c_client *client, u8 reg) int ret = 0; struct nct1008_data *data = i2c_get_clientdata(client); mutex_lock(&data->mutex); - if (data && data->shutdown_complete) { + if (data && data->nct_disabled) { mutex_unlock(&data->mutex); return -ENODEV; } @@ -894,6 +894,7 @@ static irqreturn_t nct1008_irq(int irq, void *dev_id) static void nct1008_power_control(struct nct1008_data *data, bool is_enable) { int ret; + mutex_lock(&data->mutex); if (!data->nct_reg) { data->nct_reg = regulator_get(&data->client->dev, "vdd"); if (IS_ERR_OR_NULL(data->nct_reg)) { @@ -906,6 +907,7 @@ static void nct1008_power_control(struct nct1008_data *data, bool is_enable) "getting the regulator handle for" " vdd\n", PTR_ERR(data->nct_reg)); data->nct_reg = NULL; + mutex_unlock(&data->mutex); return; } } @@ -925,6 +927,8 @@ static void nct1008_power_control(struct nct1008_data *data, bool is_enable) dev_info(&data->client->dev, "success in %s rail vdd_nct%s\n", (is_enable) ? "enabling" : "disabling", (data->chip == NCT72) ? "72" : "1008"); + data->nct_disabled = !is_enable; + mutex_unlock(&data->mutex); } static int nct1008_configure_sensor(struct nct1008_data *data) @@ -1232,7 +1236,7 @@ static void nct1008_shutdown(struct i2c_client *client) disable_irq(client->irq); mutex_lock(&data->mutex); - data->shutdown_complete = 1; + data->nct_disabled = 1; mutex_unlock(&data->mutex); } |