Re: [PATCH 3/7] PM / Domain: Add struct device to genpd

From: Ulf Hansson
Date: Thu Mar 22 2018 - 06:19:04 EST


On 22 March 2018 at 10:59, Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
> On 22-03-18, 10:30, Ulf Hansson wrote:
>> On 22 December 2017 at 08:26, Viresh Kumar <viresh.kumar@xxxxxxxxxx> wrote:
>> > The power-domain core would be using the OPP core going forward and the
>> > OPP core has the basic requirement of a device structure for its working.
>>
>> According to the OPP core also seems to require the ->dev.of_node to
>> be set. Actually, it seems like that part belongs in patch4 instead,
>> while starting to make use of the opp OF APIs. Could you please move
>> it?
>
> You meaning setting of the of_node to the next patch? I can do that if that;s
> what you want.

Yes, please.

>
>> > +static struct bus_type genpd_bus_type = {
>> > + .name = "genpd",
>> > +};
>>
>> This seems silly. Can't we just avoid having a bus type altogether,
>> thus no need to call bus_register() as well?
>
> I thought we need a bus where we want to add the device, haven't tried with that
> pointer being empty. Will try that and let you know.

Great!

>
>> > +
>> > /**
>> > * pm_genpd_init - Initialize a generic I/O PM domain object.
>> > * @genpd: PM domain object to initialize.
>> > @@ -1687,6 +1691,18 @@ int pm_genpd_init(struct generic_pm_domain *genpd,
>> > return ret;
>> > }
>> >
>> > + genpd->dev.bus = &genpd_bus_type;
>> > + device_initialize(&genpd->dev);
>> > + dev_set_name(&genpd->dev, "%s", genpd->name);
>> > +
>> > + ret = device_add(&genpd->dev);
>>
>> What's the point of adding the device? Can we skip this step, as I
>> guess the opp core is only using the device as cookie rather actual
>> using it? No?
>
> We also use it for the OPP debugfs stuff, so that would be required I believe.

Right, however, isn't that only using the dev_name(dev), which you
don't need to add the device to make use of.

Or maybe I missing something around this...

> We also use it for playing with clk/regulator stuff as well, though we may not
> use it in genpd case for now.
>
> --
> viresh

Kind regards
Uffe