Re: [RESEND PATCH v6 1/4] mfd: syscon: Add fwnode_to_regmap

2020-04-28 Thread Dilip Kota



On 4/28/2020 6:29 PM, Arnd Bergmann wrote:

On Tue, Apr 28, 2020 at 12:05 PM Lee Jones  wrote:

On Tue, 21 Apr 2020, Dilip Kota wrote:

But, i feel return error for ACPI or oother, looks better because
'device_node' has fwnode pointer. And provide description
in the header file, mentioning function is success for 'OF' and returns
error for the rest.

I don't think this patch adds much to be honest.

Better to just do:

 device_node_get_regmap(to_of_node(fwnode), false);

... from the call site I think.

Agreed, or just use the of_node pointer consistently in the driver that uses
it and avoid the use of the fwnode interface entirely when dealing with a
modern driver that does not need to support board files any more.

   Arnd
Ok, I will do it in the driver itself and remove the fwnode_to_regmap() 
definition.


Regards,
Dilip


Re: [RESEND PATCH v6 1/4] mfd: syscon: Add fwnode_to_regmap

2020-04-28 Thread Arnd Bergmann
On Tue, Apr 28, 2020 at 12:05 PM Lee Jones  wrote:
> On Tue, 21 Apr 2020, Dilip Kota wrote:
> >
> > But, i feel return error for ACPI or oother, looks better because
> > 'device_node' has fwnode pointer. And provide description
> > in the header file, mentioning function is success for 'OF' and returns
> > error for the rest.
>
> I don't think this patch adds much to be honest.
>
> Better to just do:
>
> device_node_get_regmap(to_of_node(fwnode), false);
>
> ... from the call site I think.

Agreed, or just use the of_node pointer consistently in the driver that uses
it and avoid the use of the fwnode interface entirely when dealing with a
modern driver that does not need to support board files any more.

  Arnd


Re: [RESEND PATCH v6 1/4] mfd: syscon: Add fwnode_to_regmap

2020-04-28 Thread Lee Jones
On Tue, 21 Apr 2020, Dilip Kota wrote:

> 
> On 4/17/2020 5:35 PM, Lee Jones wrote:
> > On Mon, 06 Apr 2020, Dilip Kota wrote:
> > 
> > > Traverse regmap handle entry from firmware node handle.
> > > 
> > > Signed-off-by: Dilip Kota 
> > > ---
> > > Changes on v5:
> > >No changes
> > > Changes on v5:
> > >No changes
> > > 
> > > Changes on v4:
> > >No changes
> > > 
> > >   drivers/mfd/syscon.c   | 8 
> > >   include/linux/mfd/syscon.h | 6 ++
> > >   2 files changed, 14 insertions(+)
> > > 
> > > diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> > > index 3a97816d0cba..e085c50816b9 100644
> > > --- a/drivers/mfd/syscon.c
> > > +++ b/drivers/mfd/syscon.c
> > > @@ -178,6 +178,14 @@ struct regmap *device_node_to_regmap(struct 
> > > device_node *np)
> > >   }
> > >   EXPORT_SYMBOL_GPL(device_node_to_regmap);
> > > +struct regmap *fwnode_to_regmap(struct fwnode_handle *fwnode)
> > > +{
> > > + struct device_node *np = to_of_node(fwnode);
> > You are assuming that the fwnode was Device Tree pointer.
> > 
> > The point of a fwnode is that it could be one of multiple types.
> > 
> > What if it was a pointer to an ACPI property?
> Yes, i missed to check in other perspective. Thanks for pointing it.
> While going through the System control driver to address the query, i
> noticed that System Control
> driver is talking with 'of' framework only. (No ACPI)
> 
> So, i think to add a defensive check and return error pointer if
> 'to_of_node' returns NULL
> As System control Driver cannot talk with ACPI, so fwnode_to_regmap() cannot
> talk and return error.
> 
> Or, the other option is removing the 'fwnode_to_regmap()' definition itself,
> to avoid confusion as fwnode can
> point to 'OF', 'ACPI'or 'swnode'.
> 
> But, i feel return error for ACPI or oother, looks better because
> 'device_node' has fwnode pointer. And provide description
> in the header file, mentioning function is success for 'OF' and returns
> error for the rest.

I don't think this patch adds much to be honest.

Better to just do:

device_node_get_regmap(to_of_node(fwnode), false);

... from the call site I think.

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog