regulator: hi655x: Fix pass wrong pointer to config.driver_data
[ Upstream commit 61eb1b24f9e4f4e0725aa5f8164a932c933f3339 ]
Current code sets config.driver_data to a zero initialized regulator
which is obviously wrong. Fix it.
Fixes: 4618119b9b
("regulator: hi655x: enable regulator for hi655x PMIC")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Link: https://lore.kernel.org/r/20210620132715.60215-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
032fd28ed5
commit
a0876d9dc1
@ -72,7 +72,7 @@ enum hi655x_regulator_id {
|
|||||||
static int hi655x_is_enabled(struct regulator_dev *rdev)
|
static int hi655x_is_enabled(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
unsigned int value = 0;
|
unsigned int value = 0;
|
||||||
struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
|
const struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
|
||||||
|
|
||||||
regmap_read(rdev->regmap, regulator->status_reg, &value);
|
regmap_read(rdev->regmap, regulator->status_reg, &value);
|
||||||
return (value & rdev->desc->enable_mask);
|
return (value & rdev->desc->enable_mask);
|
||||||
@ -80,7 +80,7 @@ static int hi655x_is_enabled(struct regulator_dev *rdev)
|
|||||||
|
|
||||||
static int hi655x_disable(struct regulator_dev *rdev)
|
static int hi655x_disable(struct regulator_dev *rdev)
|
||||||
{
|
{
|
||||||
struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
|
const struct hi655x_regulator *regulator = rdev_get_drvdata(rdev);
|
||||||
|
|
||||||
return regmap_write(rdev->regmap, regulator->disable_reg,
|
return regmap_write(rdev->regmap, regulator->disable_reg,
|
||||||
rdev->desc->enable_mask);
|
rdev->desc->enable_mask);
|
||||||
@ -169,7 +169,6 @@ static const struct hi655x_regulator regulators[] = {
|
|||||||
static int hi655x_regulator_probe(struct platform_device *pdev)
|
static int hi655x_regulator_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
struct hi655x_regulator *regulator;
|
|
||||||
struct hi655x_pmic *pmic;
|
struct hi655x_pmic *pmic;
|
||||||
struct regulator_config config = { };
|
struct regulator_config config = { };
|
||||||
struct regulator_dev *rdev;
|
struct regulator_dev *rdev;
|
||||||
@ -180,22 +179,17 @@ static int hi655x_regulator_probe(struct platform_device *pdev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
regulator = devm_kzalloc(&pdev->dev, sizeof(*regulator), GFP_KERNEL);
|
|
||||||
if (!regulator)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
platform_set_drvdata(pdev, regulator);
|
|
||||||
|
|
||||||
config.dev = pdev->dev.parent;
|
config.dev = pdev->dev.parent;
|
||||||
config.regmap = pmic->regmap;
|
config.regmap = pmic->regmap;
|
||||||
config.driver_data = regulator;
|
|
||||||
for (i = 0; i < ARRAY_SIZE(regulators); i++) {
|
for (i = 0; i < ARRAY_SIZE(regulators); i++) {
|
||||||
|
config.driver_data = (void *) ®ulators[i];
|
||||||
|
|
||||||
rdev = devm_regulator_register(&pdev->dev,
|
rdev = devm_regulator_register(&pdev->dev,
|
||||||
®ulators[i].rdesc,
|
®ulators[i].rdesc,
|
||||||
&config);
|
&config);
|
||||||
if (IS_ERR(rdev)) {
|
if (IS_ERR(rdev)) {
|
||||||
dev_err(&pdev->dev, "failed to register regulator %s\n",
|
dev_err(&pdev->dev, "failed to register regulator %s\n",
|
||||||
regulator->rdesc.name);
|
regulators[i].rdesc.name);
|
||||||
return PTR_ERR(rdev);
|
return PTR_ERR(rdev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user