Re: [RESUBMIT PATCH v7 7/9] regulator: sky81452: Modify Device Tree structure

From: Gyungoh Yoo
Date: Wed Nov 19 2014 - 02:40:20 EST


On Tue, Nov 18, 2014 at 11:20:56AM +0000, Mark Brown wrote:
> On Tue, Nov 18, 2014 at 05:04:51PM +0900, Gyungoh Yoo wrote:
> > On Mon, Nov 17, 2014 at 02:18:36PM +0000, Mark Brown wrote:
>
> > > Don't open code this, use regulators_node and of_match as previously
> > > advised.
>
> > I think I had a misunderstanding.
> > But I have no idea about regulators_node and of_match.
> > Could you let me know more about them?
>
> They are fields in regulator_desc, there are documentation and examples
> in current mainline - take a look at that and ask questions if it is
> unclear.

Okay. Thank you.
If of_match and regulators_node are assigned, don't I need to
call of_regulator_match()? Does regulator_register() call it internally?
So can I write code like below?

static const struct regulator_desc sky81452_reg = {
.name = "LOUT",
.of_match = of_match_ptr("lout"),
.regulators_node = of_match_ptr("regulator"),
.ops = &sky81452_reg_ops,
...
};

static int sky81452_reg_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
const struct regulator_init_data *init_data = dev_get_platdata(dev);
struct regulator_config config = { };
struct regulator_dev *rdev;

config.dev = dev->parent;
config.init_data = init_data;
config.of_node = dev->of_node;
config.regmap = dev_get_drvdata(dev->parent);

rdev = devm_regulator_register(dev, &sky81452_reg, &config);
if (IS_ERR(rdev)) {
dev_err(dev, "failed to register. err=%ld\n", PTR_ERR(rdev));
return PTR_ERR(rdev);
}

platform_set_drvdata(pdev, rdev);

return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/