From: Shengfei xu Date: Tue, 2 Feb 2016 00:44:50 +0000 (+0800) Subject: Revert "regulator: rk818: remove the repeated operations." X-Git-Tag: firefly_0821_release~3432 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=1231831b6bae9158f73382710e09e091286b2eb6;hp=ac8723b701378d2f2755544e4c0eda05964c6e3c;p=firefly-linux-kernel-4.4.55.git Revert "regulator: rk818: remove the repeated operations." This reverts commit 5d24f688220debafd3de916e9e02c8d7c0472589. Change-Id: I0a98e803958b3f56b8fd2a0099f402fab9a83ad4 Signed-off-by: Shengfei xu --- diff --git a/drivers/regulator/rk818-regulator.c b/drivers/regulator/rk818-regulator.c index 30496c6f157d..6fe92365498a 100644 --- a/drivers/regulator/rk818-regulator.c +++ b/drivers/regulator/rk818-regulator.c @@ -395,16 +395,43 @@ static struct of_regulator_match rk818_reg_matches[] = { [RK818_ID_SWITCH] = { .name = "SWITCH_REG" }, }; +static int rk818_regulator_dt_parse_pdata(struct device *dev, + struct device *client_dev, + struct regmap *map) +{ + struct device_node *np; + int ret; + + np = of_get_child_by_name(client_dev->of_node, "regulators"); + if (!np) + return -ENXIO; + + ret = of_regulator_match(dev, np, rk818_reg_matches, + RK818_NUM_REGULATORS); + + of_node_put(np); + return ret; +} + static int rk818_regulator_probe(struct platform_device *pdev) { struct rk808 *rk818 = dev_get_drvdata(pdev->dev.parent); struct i2c_client *client = rk818->i2c; struct regulator_config config = {}; struct regulator_dev *rk818_rdev; - int i; + int ret, i; + + ret = rk818_regulator_dt_parse_pdata(&pdev->dev, &client->dev, + rk818->regmap); + if (ret < 0) + return ret; /* Instantiate the regulators */ for (i = 0; i < RK818_NUM_REGULATORS; i++) { + if (!rk818_reg_matches[i].init_data || + !rk818_reg_matches[i].of_node) + continue; + config.dev = &client->dev; config.regmap = rk818->regmap; config.of_node = rk818_reg_matches[i].of_node;