summaryrefslogtreecommitdiff
path: root/drivers/i2c
diff options
context:
space:
mode:
authorJihoon Bang <jbang@nvidia.com>2011-09-30 17:22:55 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:49:22 -0800
commit612fc1125ef1d98b2f7bf115b097daf96d63ec48 (patch)
tree8cf2766015a7aade7502a7c2265da61fcbf57f16 /drivers/i2c
parent5335cb5026165e4d3adefaae58c3ef7ebb8aa038 (diff)
i2c: fix crash when there is no regulator
Calling regulator_disable causes system to crash when there is no regualtor. It calls regulator_disable only when regulators exist. Bug 871860 Reviewed-on: http://git-master/r/55603 (cherry picked from commit 042e786e9766c891b44b8e00aa05f4c42b724440) Reviewed-on: http://git-master/r/56237 (cherry picked from commit 9607d33bfcb84f764935ea911b93e716018ab818) Change-Id: I06cfaeedcbdf276c3a17a759d410c7b46de8e9b1 Reviewed-on: http://git-master/r/57416 Reviewed-by: Jihoon Bang <jbang@nvidia.com> Tested-by: Jihoon Bang <jbang@nvidia.com> Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com> Rebase-Id: Rb146536a30b5e0c1f06a1622e77248aa539617a8
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/muxes/pca954x.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
index 90fd47b54df5..dd14ae38d3ee 100644
--- a/drivers/i2c/muxes/pca954x.c
+++ b/drivers/i2c/muxes/pca954x.c
@@ -274,8 +274,7 @@ static int pca954x_probe(struct i2c_client *client,
if (ret) {
dev_err(&client->dev, "%s: failed to enable vcc_i2c\n",
__func__);
- regulator_disable(data->vcc_reg);
- goto exit_regulator_put;
+ goto exit_vcc_regulator_disable;
}
}
@@ -291,9 +290,7 @@ static int pca954x_probe(struct i2c_client *client,
*/
if (i2c_smbus_write_byte(client, 0) < 0) {
dev_warn(&client->dev, "probe failed\n");
- regulator_disable(data->vcc_reg);
- regulator_disable(data->i2c_reg);
- goto exit_regulator_put;
+ goto exit_regulator_disable;
}
/* Decrease ref count for pca954x vcc */
@@ -343,9 +340,15 @@ static int pca954x_probe(struct i2c_client *client,
virt_reg_failed:
for (num--; num >= 0; num--)
i2c_del_mux_adapter(data->virt_adaps[num]);
+exit_regulator_disable:
+ if (data->i2c_reg)
+ regulator_disable(data->i2c_reg);
+exit_vcc_regulator_disable:
+ if (data->vcc_reg)
+ regulator_disable(data->vcc_reg);
exit_regulator_put:
- regulator_put(data->vcc_reg);
regulator_put(data->i2c_reg);
+ regulator_put(data->vcc_reg);
exit_free:
kfree(data);
err: