Commit e086a9cd authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman

staging: regulator: hi6421v600-regulator: better handle modes

Instead of implementing a custom set of properties, set
valid_modes_mask based on having or not a mask for enabling
the eco_mode.

This makes the code clearer, and remove some uneeded props
from DT.
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/0f4ac5a4167bbca428c8507b6992acd8b3ebabd1.1597647359.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent db27f829
......@@ -338,7 +338,6 @@ static int hisi_regulator_probe_ldo(struct platform_device *pdev,
struct regulator_config config = { };
struct regulation_constraints *constraint;
const char *supplyname = NULL;
unsigned int temp_modes;
int ret = 0;
initdata = of_get_regulator_init_data(dev, np, NULL);
......@@ -347,25 +346,6 @@ static int hisi_regulator_probe_ldo(struct platform_device *pdev,
return -EINVAL;
}
/* hisi regulator supports two modes */
constraint = &initdata->constraints;
ret = of_property_read_u32_array(np, "valid-modes-mask",
&constraint->valid_modes_mask, 1);
if (ret) {
dev_err(dev, "no valid modes mask\n");
ret = -ENODEV;
return ret;
}
ret = of_property_read_u32_array(np, "valid-idle-mask",
&temp_modes, 1);
if (ret) {
dev_err(dev, "no valid idle mask\n");
ret = -ENODEV;
return ret;
}
constraint->valid_ops_mask |= temp_modes;
sreg = kzalloc(sizeof(*sreg), GFP_KERNEL);
if (!sreg)
return -ENOMEM;
......@@ -387,6 +367,15 @@ static int hisi_regulator_probe_ldo(struct platform_device *pdev,
if (ret)
goto hisi_probe_end;
/* hisi regulator supports two modes */
constraint = &initdata->constraints;
constraint->valid_modes_mask = REGULATOR_MODE_NORMAL;
if (sreg->eco_mode_mask) {
constraint->valid_modes_mask |= REGULATOR_MODE_IDLE;
constraint->valid_ops_mask |= REGULATOR_CHANGE_MODE;
}
config.dev = &pdev->dev;
config.init_data = initdata;
config.driver_data = sreg;
......@@ -401,8 +390,7 @@ static int hisi_regulator_probe_ldo(struct platform_device *pdev,
goto hisi_probe_end;
}
dev_dbg(dev, "%s:valid_modes_mask: 0x%x, valid_ops_mask: 0x%x\n",
rdesc->name,
dev_dbg(dev, "valid_modes_mask: 0x%x, valid_ops_mask: 0x%x\n",
constraint->valid_modes_mask, constraint->valid_ops_mask);
dev_set_drvdata(dev, rdev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment