summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorJihoon Bang <jbang@nvidia.com>2011-09-30 17:22:55 -0700
committerVarun Colbert <vcolbert@nvidia.com>2011-10-13 12:58:51 -0700
commit8aad17d3e8cce86dc5d0a4330302b75d62cde68d (patch)
tree4ee0aa044e0cc200f99b7fc86e8a67d4f795152c /drivers
parente8d056675c755d399b893b9dc126168178116ffd (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>
Diffstat (limited to 'drivers')
-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: