regulator: core: Try using the parent device for the default regmap
authorAnilKumar Ch <anilkumar@ti.com>
Fri, 7 Sep 2012 15:15:05 +0000 (20:45 +0530)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Sat, 8 Sep 2012 00:54:15 +0000 (08:54 +0800)
If the device doesn't have a regmap specified by the driver and we can't
find one on the device itself try its parent, providing a useful defualt
for many MFDs.

[Rewrite commit message -- broonie]

Signed-off-by: AnilKumar Ch <anilkumar@ti.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/regulator/core.c

index ed376d9f525daf88360e763924db31598db9a0e8..03fad8153476c2425cb2b2c181f61c4c812a23c0 100644 (file)
@@ -3202,8 +3202,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);