Skip to content

Commit

Permalink
regulator: lp872x: fix NULL pointer access problem
Browse files Browse the repository at this point in the history
 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>
  • Loading branch information
Kim, Milo authored and Mark Brown committed Sep 5, 2012
1 parent 86b3fef commit 9d6da6f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/regulator/lp872x.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,9 @@ static int lp872x_regulator_enable_time(struct regulator_dev *rdev)
return val > MAX_DELAY ? 0 : val * time_step_us;
}

static void lp872x_set_dvs(struct lp872x *lp, int gpio)
static void lp872x_set_dvs(struct lp872x *lp, enum lp872x_dvs_sel dvs_sel,
int gpio)
{
enum lp872x_dvs_sel dvs_sel = lp->pdata->dvs->vsel;
enum lp872x_dvs_state state;

state = dvs_sel == SEL_V1 ? DVS_HIGH : DVS_LOW;
Expand Down Expand Up @@ -343,10 +343,10 @@ static int lp872x_buck_set_voltage_sel(struct regulator_dev *rdev,
struct lp872x *lp = rdev_get_drvdata(rdev);
enum lp872x_regulator_id buck = rdev_get_id(rdev);
u8 addr, mask = LP872X_VOUT_M;
struct lp872x_dvs *dvs = lp->pdata->dvs;
struct lp872x_dvs *dvs = lp->pdata ? lp->pdata->dvs : NULL;

if (dvs && gpio_is_valid(dvs->gpio))
lp872x_set_dvs(lp, dvs->gpio);
lp872x_set_dvs(lp, dvs->vsel, dvs->gpio);

addr = lp872x_select_buck_vout_addr(lp, buck);
if (!lp872x_is_valid_buck_addr(addr))
Expand Down

0 comments on commit 9d6da6f

Please sign in to comment.