aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorKim, Milo <Milo.Kim@ti.com>2012-09-05 00:39:33 -0400
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-09-05 19:53:02 -0400
commit9d6da6fcc2831220a8754385ee54847e3ee6274f (patch)
treeef823e9e3267f972e13e78964c16b070f1e8016c /drivers
parent86b3fef0c7b5aba1c64ac1e02e68267aeaff44a6 (diff)
regulator: lp872x: fix NULL pointer access problem
The lp872x_set_dvs() is used for changing the DVS pin state. This function works only when the DVS platform data is defined. So don't assume that DVS data is always valid. In case the platform data is not defined, the DVS data is set to NULL for skipping the DVS pin control. DVS selection and GPIO pin number are used for the LP872x DVS pin control. For better readability, DVS selection argument is added in lp872x_set_dvs(). Signed-off-by: Milo(Woogyom) Kim <milo.kim@ti.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/regulator/lp872x.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/regulator/lp872x.c b/drivers/regulator/lp872x.c
index b16a941c1a62..86485e823f05 100644
--- a/drivers/regulator/lp872x.c
+++ b/drivers/regulator/lp872x.c
@@ -273,9 +273,9 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev)
273 return val > MAX_DELAY ? 0 : val * time_step_us; 273 return val > MAX_DELAY ? 0 : val * time_step_us;
274} 274}
275 275
276static void lp872x_set_dvs(struct lp872x *lp, int gpio) 276static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel,
277 int gpio)
277{ 278{
278 enum lp872x_dvs_sel dvs_sel = lp->pdata->dvs->vsel;
279 enum lp872x_dvs_state state; 279 enum lp872x_dvs_state state;
280 280
281 state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW; 281 state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW;
@@ -343,10 +343,10 @@ static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev,
343 struct lp872x *lp = rdev_get_drvdata(rdev); 343 struct lp872x *lp = rdev_get_drvdata(rdev);
344 enum lp872x_regulator_id buck = rdev_get_id(rdev); 344 enum lp872x_regulator_id buck = rdev_get_id(rdev);
345 u8 addr, mask = LP872X_VOUT_M; 345 u8 addr, mask = LP872X_VOUT_M;
346 struct lp872x_dvs *dvs = lp->pdata->dvs; 346 struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL;
347 347
348 if (dvs && gpio_is_valid(dvs->gpio)) 348 if (dvs && gpio_is_valid(dvs->gpio))
349 lp872x_set_dvs(lp, dvs->gpio); 349 lp872x_set_dvs(lp, dvs->vsel, dvs->gpio);
350 350
351 addr = lp872x_select_buck_vout_addr(lp, buck); 351 addr = lp872x_select_buck_vout_addr(lp, buck);
352 if (!lp872x_is_valid_buck_addr(addr)) 352 if (!lp872x_is_valid_buck_addr(addr))