mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-30 08:02:30 +00:00
regulator: hi6421: Fix getting wrong drvdata
[ Upstream commit1c73daee4b
] Since config.dev = pdev->dev.parent in current code, so dev_get_drvdata(rdev->dev.parent) call in hi6421_regulator_enable returns the drvdata of the mfd device rather than the regulator. Fix it. This was broken while converting to use simplified DT parsing because the config.dev changed from pdev->dev to pdev->dev.parent for parsing the parent's of_node. Fixes:29dc269a85
("regulator: hi6421: Convert to use simplified DT parsing") Signed-off-by: Axel Lin <axel.lin@ingics.com> Link: https://lore.kernel.org/r/20210630095959.2411543-1-axel.lin@ingics.com Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
b25be6bf64
commit
08cdda8d89
1 changed files with 13 additions and 9 deletions
|
@ -366,9 +366,8 @@ static struct hi6421_regulator_info
|
||||||
|
|
||||||
static int hi6421_regulator_enable(struct regulator_dev *rdev)
|
static int hi6421_regulator_enable(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
struct hi6421_regulator_pdata *pdata;
|
struct hi6421_regulator_pdata *pdata = rdev_get_drvdata(rdev);
|
||||||
|
|
||||||
pdata = dev_get_drvdata(rdev->dev.parent);
|
|
||||||
/* hi6421 spec requires regulator enablement must be serialized:
|
/* hi6421 spec requires regulator enablement must be serialized:
|
||||||
* - Because when BUCK, LDO switching from off to on, it will have
|
* - Because when BUCK, LDO switching from off to on, it will have
|
||||||
* a huge instantaneous current; so you can not turn on two or
|
* a huge instantaneous current; so you can not turn on two or
|
||||||
|
@ -385,9 +384,10 @@ static int hi6421_regulator_enable(struct regulator_dev *rdev)
|
||||||
|
|
||||||
static unsigned int hi6421_regulator_ldo_get_mode(struct regulator_dev *rdev)
|
static unsigned int hi6421_regulator_ldo_get_mode(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
struct hi6421_regulator_info *info = rdev_get_drvdata(rdev);
|
struct hi6421_regulator_info *info;
|
||||||
unsigned int reg_val;
|
unsigned int reg_val;
|
||||||
|
|
||||||
|
info = container_of(rdev->desc, struct hi6421_regulator_info, desc);
|
||||||
regmap_read(rdev->regmap, rdev->desc->enable_reg, ®_val);
|
regmap_read(rdev->regmap, rdev->desc->enable_reg, ®_val);
|
||||||
if (reg_val & info->mode_mask)
|
if (reg_val & info->mode_mask)
|
||||||
return REGULATOR_MODE_IDLE;
|
return REGULATOR_MODE_IDLE;
|
||||||
|
@ -397,9 +397,10 @@ static unsigned int hi6421_regulator_ldo_get_mode(struct regulator_dev *rdev)
|
||||||
|
|
||||||
static unsigned int hi6421_regulator_buck_get_mode(struct regulator_dev *rdev)
|
static unsigned int hi6421_regulator_buck_get_mode(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
struct hi6421_regulator_info *info = rdev_get_drvdata(rdev);
|
struct hi6421_regulator_info *info;
|
||||||
unsigned int reg_val;
|
unsigned int reg_val;
|
||||||
|
|
||||||
|
info = container_of(rdev->desc, struct hi6421_regulator_info, desc);
|
||||||
regmap_read(rdev->regmap, rdev->desc->enable_reg, ®_val);
|
regmap_read(rdev->regmap, rdev->desc->enable_reg, ®_val);
|
||||||
if (reg_val & info->mode_mask)
|
if (reg_val & info->mode_mask)
|
||||||
return REGULATOR_MODE_STANDBY;
|
return REGULATOR_MODE_STANDBY;
|
||||||
|
@ -410,9 +411,10 @@ static unsigned int hi6421_regulator_buck_get_mode(struct regulator_dev *rdev)
|
||||||
static int hi6421_regulator_ldo_set_mode(struct regulator_dev *rdev,
|
static int hi6421_regulator_ldo_set_mode(struct regulator_dev *rdev,
|
||||||
unsigned int mode)
|
unsigned int mode)
|
||||||
{
|
{
|
||||||
struct hi6421_regulator_info *info = rdev_get_drvdata(rdev);
|
struct hi6421_regulator_info *info;
|
||||||
unsigned int new_mode;
|
unsigned int new_mode;
|
||||||
|
|
||||||
|
info = container_of(rdev->desc, struct hi6421_regulator_info, desc);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case REGULATOR_MODE_NORMAL:
|
case REGULATOR_MODE_NORMAL:
|
||||||
new_mode = 0;
|
new_mode = 0;
|
||||||
|
@ -434,9 +436,10 @@ static int hi6421_regulator_ldo_set_mode(struct regulator_dev *rdev,
|
||||||
static int hi6421_regulator_buck_set_mode(struct regulator_dev *rdev,
|
static int hi6421_regulator_buck_set_mode(struct regulator_dev *rdev,
|
||||||
unsigned int mode)
|
unsigned int mode)
|
||||||
{
|
{
|
||||||
struct hi6421_regulator_info *info = rdev_get_drvdata(rdev);
|
struct hi6421_regulator_info *info;
|
||||||
unsigned int new_mode;
|
unsigned int new_mode;
|
||||||
|
|
||||||
|
info = container_of(rdev->desc, struct hi6421_regulator_info, desc);
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case REGULATOR_MODE_NORMAL:
|
case REGULATOR_MODE_NORMAL:
|
||||||
new_mode = 0;
|
new_mode = 0;
|
||||||
|
@ -459,7 +462,9 @@ static unsigned int
|
||||||
hi6421_regulator_ldo_get_optimum_mode(struct regulator_dev *rdev,
|
hi6421_regulator_ldo_get_optimum_mode(struct regulator_dev *rdev,
|
||||||
int input_uV, int output_uV, int load_uA)
|
int input_uV, int output_uV, int load_uA)
|
||||||
{
|
{
|
||||||
struct hi6421_regulator_info *info = rdev_get_drvdata(rdev);
|
struct hi6421_regulator_info *info;
|
||||||
|
|
||||||
|
info = container_of(rdev->desc, struct hi6421_regulator_info, desc);
|
||||||
|
|
||||||
if (load_uA > info->eco_microamp)
|
if (load_uA > info->eco_microamp)
|
||||||
return REGULATOR_MODE_NORMAL;
|
return REGULATOR_MODE_NORMAL;
|
||||||
|
@ -543,14 +548,13 @@ static int hi6421_regulator_probe(struct platform_device *pdev)
|
||||||
if (!pdata)
|
if (!pdata)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
mutex_init(&pdata->lock);
|
mutex_init(&pdata->lock);
|
||||||
platform_set_drvdata(pdev, pdata);
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(hi6421_regulator_info); i++) {
|
for (i = 0; i < ARRAY_SIZE(hi6421_regulator_info); i++) {
|
||||||
/* assign per-regulator data */
|
/* assign per-regulator data */
|
||||||
info = &hi6421_regulator_info[i];
|
info = &hi6421_regulator_info[i];
|
||||||
|
|
||||||
config.dev = pdev->dev.parent;
|
config.dev = pdev->dev.parent;
|
||||||
config.driver_data = info;
|
config.driver_data = pdata;
|
||||||
config.regmap = pmic->regmap;
|
config.regmap = pmic->regmap;
|
||||||
|
|
||||||
rdev = devm_regulator_register(&pdev->dev, &info->desc,
|
rdev = devm_regulator_register(&pdev->dev, &info->desc,
|
||||||
|
|
Loading…
Reference in a new issue