Skip to contentSkip to conversation

regulator: core: fix rdev->regmap NULL pointer

PATCH In review AnilKumar Ch 2 participants 2 messages Sep 7, 2012 – Sep 8, 2012 Voltage and current regulator framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regulator: core: fix rdev->regmap NULL pointer

Fixes rdev->regmap NULL pointer if regmap for regulator device is NULL. If it is NULL then get regmap for regulator device from its parent (MFD).

---
 drivers/regulator/core.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/regulator/core.c +3 -1
index 4838531..7d85402 100644
@@ -3189,8 +3189,10 @@ regulator_register(const struct regulator_desc *regulator_desc,
 	rdev->desc = regulator_desc;
 	if (config->regmap)
 		rdev->regmap = config->regmap;
-	else
+	else if (dev_get_regmap(dev, NULL))
 		rdev->regmap = dev_get_regmap(dev, NULL);
+	else if (dev->parent)
+		rdev->regmap = dev_get_regmap(dev->parent, NULL);
 	INIT_LIST_HEAD(&rdev->consumer_list);
 	INIT_LIST_HEAD(&rdev->list);
 	BLOCKING_INIT_NOTIFIER_HEAD(&rdev->notifier);
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 5 lines · AnilKumar Ch

Fixes rdev->regmap NULL pointer if regmap for regulator device is NULL. If it is NULL then get regmap for regulator device from its parent (MFD).

Applied with a rewritten commit message - this is adding a new feature, not fixing a problem (devices can always explicitly specify a regmap, this is just adding a new default option). Thanks.