linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node
@ 2022-04-13 18:02 Andy Shevchenko
  2022-04-13 18:07 ` Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-04-13 18:02 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio, linux-kernel
  Cc: Jonathan Cameron, Lars-Peter Clausen, Andy Shevchenko

Switch the IIO core to use firmware node handle instead of OF node.
This will allow to get label from firmware on non-OF systems.

Note, this doesn't change of_iio_*() APIs for now.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/industrialio-core.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 2f48e9a97274..ffbe76806e07 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -1893,20 +1893,22 @@ static const struct iio_buffer_setup_ops noop_ring_setup_ops;
 int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
 {
 	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
-	const char *label;
+	struct fwnode_handle *fwnode;
 	int ret;
 
 	if (!indio_dev->info)
 		return -EINVAL;
 
 	iio_dev_opaque->driver_module = this_mod;
-	/* If the calling driver did not initialize of_node, do it here */
-	if (!indio_dev->dev.of_node && indio_dev->dev.parent)
-		indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
 
-	label = of_get_property(indio_dev->dev.of_node, "label", NULL);
-	if (label)
-		indio_dev->label = label;
+	/* If the calling driver did not initialize firmware node, do it here */
+	if (dev_fwnode(&indio_dev->dev))
+		fwnode = dev_fwnode(&indio_dev->dev);
+	else
+		fwnode = dev_fwnode(indio_dev->dev.parent);
+	device_set_node(&indio_dev->dev, fwnode);
+
+	fwnode_property_read_string(fwnode, "label", &indio_dev->label);
 
 	ret = iio_check_unique_scan_index(indio_dev);
 	if (ret < 0)
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node
  2022-04-13 18:02 [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node Andy Shevchenko
@ 2022-04-13 18:07 ` Andy Shevchenko
  2022-04-14  7:17 ` Nuno Sá
  2022-04-16 11:17 ` Jonathan Cameron
  2 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-04-13 18:07 UTC (permalink / raw)
  To: Jonathan Cameron, linux-iio, linux-kernel
  Cc: Jonathan Cameron, Lars-Peter Clausen

On Wed, Apr 13, 2022 at 09:02:02PM +0300, Andy Shevchenko wrote:

...

> +	/* If the calling driver did not initialize firmware node, do it here */
> +	if (dev_fwnode(&indio_dev->dev))
> +		fwnode = dev_fwnode(&indio_dev->dev);
> +	else
> +		fwnode = dev_fwnode(indio_dev->dev.parent);

Can be also done as

	fwnode = dev_fwnode(&indio_dev->dev) ?: dev_fwnode(indio_dev->dev.parent);

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node
  2022-04-13 18:02 [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node Andy Shevchenko
  2022-04-13 18:07 ` Andy Shevchenko
@ 2022-04-14  7:17 ` Nuno Sá
  2022-04-14 12:53   ` Andy Shevchenko
  2022-04-16 11:17 ` Jonathan Cameron
  2 siblings, 1 reply; 5+ messages in thread
From: Nuno Sá @ 2022-04-14  7:17 UTC (permalink / raw)
  To: Andy Shevchenko, Jonathan Cameron, linux-iio, linux-kernel
  Cc: Jonathan Cameron, Lars-Peter Clausen

On Wed, 2022-04-13 at 21:02 +0300, Andy Shevchenko wrote:
> Switch the IIO core to use firmware node handle instead of OF node.
> This will allow to get label from firmware on non-OF systems.
> 
> Note, this doesn't change of_iio_*() APIs for now.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/iio/industrialio-core.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-core.c
> b/drivers/iio/industrialio-core.c
> index 2f48e9a97274..ffbe76806e07 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1893,20 +1893,22 @@ static const struct iio_buffer_setup_ops
> noop_ring_setup_ops;
>  int __iio_device_register(struct iio_dev *indio_dev, struct module
> *this_mod)
>  {
>         struct iio_dev_opaque *iio_dev_opaque =
> to_iio_dev_opaque(indio_dev);
> -       const char *label;
> +       struct fwnode_handle *fwnode;
>         int ret;
>  
>         if (!indio_dev->info)
>                 return -EINVAL;
>  
>         iio_dev_opaque->driver_module = this_mod;
> -       /* If the calling driver did not initialize of_node, do it
> here */
> -       if (!indio_dev->dev.of_node && indio_dev->dev.parent)
> -               indio_dev->dev.of_node = indio_dev->dev.parent-
> >of_node;
>  
> -       label = of_get_property(indio_dev->dev.of_node, "label",
> NULL);
> -       if (label)
> -               indio_dev->label = label;
> +       /* If the calling driver did not initialize firmware node, do
> it here */
> +       if (dev_fwnode(&indio_dev->dev))
> +               fwnode = dev_fwnode(&indio_dev->dev);
> +       else
> +               fwnode = dev_fwnode(indio_dev->dev.parent);
> +       device_set_node(&indio_dev->dev, fwnode);
> +
> +       fwnode_property_read_string(fwnode, "label", &indio_dev-
> >label);
>  
>         ret = iio_check_unique_scan_index(indio_dev);
>         if (ret < 0)

Hi Andy,

So I was actually planning to send the same patch today or in the next
few days. I do also have the conversion of inkern.c so I guess we can
move in 3 different ways:

1. If you are planning or already have some work with it, I'm more than
fine in just forgetting my patches and let you do it (you are cleaning
all the drivers already)

2. I can send the patch (without this one) already for reviewing... It
won't apply because I think there will be some conflicts with some of
the drivers you changed already. Fun fact, remove of.h from iio.h and
you see some drivers relying on it for property.h and mod_devicetable.h

3. Just wait for your latest patches to be merged and send mine next
week.

Up to you :)

- Nuno Sá



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node
  2022-04-14  7:17 ` Nuno Sá
@ 2022-04-14 12:53   ` Andy Shevchenko
  0 siblings, 0 replies; 5+ messages in thread
From: Andy Shevchenko @ 2022-04-14 12:53 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Jonathan Cameron, linux-iio, linux-kernel, Jonathan Cameron,
	Lars-Peter Clausen

On Thu, Apr 14, 2022 at 09:17:22AM +0200, Nuno Sá wrote:
> On Wed, 2022-04-13 at 21:02 +0300, Andy Shevchenko wrote:
> > Switch the IIO core to use firmware node handle instead of OF node.
> > This will allow to get label from firmware on non-OF systems.
> > 
> > Note, this doesn't change of_iio_*() APIs for now.

> So I was actually planning to send the same patch today or in the next
> few days. I do also have the conversion of inkern.c so I guess we can
> move in 3 different ways:
> 
> 1. If you are planning or already have some work with it, I'm more than
> fine in just forgetting my patches and let you do it (you are cleaning
> all the drivers already)
> 
> 2. I can send the patch (without this one) already for reviewing... It
> won't apply because I think there will be some conflicts with some of
> the drivers you changed already. Fun fact, remove of.h from iio.h and
> you see some drivers relying on it for property.h and mod_devicetable.h
> 
> 3. Just wait for your latest patches to be merged and send mine next
> week.
> 
> Up to you :)

Thanks for letting me know. I think the best course of actions now is
to settle down with what I have sent and you then rebase your stuff and
sent out for review. I will help with reviewing and I'm glad to hear
that you are step ahead of me. I wasn't planning to chase the inkern.c
in the future (at least nearest future).

That said, it seems like fits the #3 from the above list you provided.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node
  2022-04-13 18:02 [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node Andy Shevchenko
  2022-04-13 18:07 ` Andy Shevchenko
  2022-04-14  7:17 ` Nuno Sá
@ 2022-04-16 11:17 ` Jonathan Cameron
  2 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2022-04-16 11:17 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jonathan Cameron, linux-iio, linux-kernel, Lars-Peter Clausen

On Wed, 13 Apr 2022 21:02:02 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Switch the IIO core to use firmware node handle instead of OF node.
> This will allow to get label from firmware on non-OF systems.
> 
> Note, this doesn't change of_iio_*() APIs for now.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Applied to the togreg branch of iio.git and pushed out as testing for
0-day to poke at this and see if we missed anything.

Thanks,

Jonathan

> ---
>  drivers/iio/industrialio-core.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 2f48e9a97274..ffbe76806e07 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -1893,20 +1893,22 @@ static const struct iio_buffer_setup_ops noop_ring_setup_ops;
>  int __iio_device_register(struct iio_dev *indio_dev, struct module *this_mod)
>  {
>  	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(indio_dev);
> -	const char *label;
> +	struct fwnode_handle *fwnode;
>  	int ret;
>  
>  	if (!indio_dev->info)
>  		return -EINVAL;
>  
>  	iio_dev_opaque->driver_module = this_mod;
> -	/* If the calling driver did not initialize of_node, do it here */
> -	if (!indio_dev->dev.of_node && indio_dev->dev.parent)
> -		indio_dev->dev.of_node = indio_dev->dev.parent->of_node;
>  
> -	label = of_get_property(indio_dev->dev.of_node, "label", NULL);
> -	if (label)
> -		indio_dev->label = label;
> +	/* If the calling driver did not initialize firmware node, do it here */
> +	if (dev_fwnode(&indio_dev->dev))
> +		fwnode = dev_fwnode(&indio_dev->dev);
> +	else
> +		fwnode = dev_fwnode(indio_dev->dev.parent);
> +	device_set_node(&indio_dev->dev, fwnode);
> +
> +	fwnode_property_read_string(fwnode, "label", &indio_dev->label);
>  
>  	ret = iio_check_unique_scan_index(indio_dev);
>  	if (ret < 0)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-04-16 11:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-13 18:02 [PATCH v1 1/1] iio: core: Convert to use firmware node handle instead of OF node Andy Shevchenko
2022-04-13 18:07 ` Andy Shevchenko
2022-04-14  7:17 ` Nuno Sá
2022-04-14 12:53   ` Andy Shevchenko
2022-04-16 11:17 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).