Linux IIO development
 help / color / mirror / Atom feed
* [PATCH] iio:proximity:sx_common: Fix device property parsing on DT systems
@ 2022-03-31 21:04 Stephen Boyd
  2022-04-01 20:54 ` Gwendal Grignou
  0 siblings, 1 reply; 3+ messages in thread
From: Stephen Boyd @ 2022-03-31 21:04 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen
  Cc: linux-kernel, linux-iio, Gwendal Grignou

After commit 7a3605bef878 ("iio: sx9310: Support ACPI property") we
started using the 'indio_dev->dev' to extract device properties for
various register settings in sx9310_get_default_reg(). This broke DT
based systems because dev_fwnode() used in the device_property*() APIs
can't find an 'of_node'. That's because the 'indio_dev->dev.of_node'
pointer isn't set until iio_device_register() is called. Set the pointer
earlier, next to where the ACPI companion is set, so that the device
property APIs work on DT systems.

Cc: Gwendal Grignou <gwendal@chromium.org>
Fixes: 7a3605bef878 ("iio: sx9310: Support ACPI property")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/iio/proximity/sx_common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c
index a7c07316a0a9..8ad814d96b7e 100644
--- a/drivers/iio/proximity/sx_common.c
+++ b/drivers/iio/proximity/sx_common.c
@@ -521,6 +521,7 @@ int sx_common_probe(struct i2c_client *client,
 		return dev_err_probe(dev, ret, "error reading WHOAMI\n");
 
 	ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(dev));
+	indio_dev->dev.of_node = client->dev.of_node;
 	indio_dev->modes = INDIO_DIRECT_MODE;
 
 	indio_dev->channels =  data->chip_info->iio_channels;
-- 
https://chromeos.dev


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

* Re: [PATCH] iio:proximity:sx_common: Fix device property parsing on DT systems
  2022-03-31 21:04 [PATCH] iio:proximity:sx_common: Fix device property parsing on DT systems Stephen Boyd
@ 2022-04-01 20:54 ` Gwendal Grignou
  2022-04-02 15:26   ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Gwendal Grignou @ 2022-04-01 20:54 UTC (permalink / raw)
  To: Stephen Boyd
  Cc: Jonathan Cameron, Lars-Peter Clausen, linux-kernel, linux-iio

On Thu, Mar 31, 2022 at 2:04 PM Stephen Boyd <swboyd@chromium.org> wrote:
>
> After commit 7a3605bef878 ("iio: sx9310: Support ACPI property") we
> started using the 'indio_dev->dev' to extract device properties for
> various register settings in sx9310_get_default_reg(). This broke DT
> based systems because dev_fwnode() used in the device_property*() APIs
> can't find an 'of_node'. That's because the 'indio_dev->dev.of_node'
> pointer isn't set until iio_device_register() is called. Set the pointer
> earlier, next to where the ACPI companion is set, so that the device
> property APIs work on DT systems.
>
> Cc: Gwendal Grignou <gwendal@chromium.org>
> Fixes: 7a3605bef878 ("iio: sx9310: Support ACPI property")
> Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Gwendal Grignou <gwendal@chromium.org>
> ---
>  drivers/iio/proximity/sx_common.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c
> index a7c07316a0a9..8ad814d96b7e 100644
> --- a/drivers/iio/proximity/sx_common.c
> +++ b/drivers/iio/proximity/sx_common.c
> @@ -521,6 +521,7 @@ int sx_common_probe(struct i2c_client *client,
>                 return dev_err_probe(dev, ret, "error reading WHOAMI\n");
>
>         ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(dev));
> +       indio_dev->dev.of_node = client->dev.of_node;
>         indio_dev->modes = INDIO_DIRECT_MODE;
>
>         indio_dev->channels =  data->chip_info->iio_channels;
> --
> https://chromeos.dev
>

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

* Re: [PATCH] iio:proximity:sx_common: Fix device property parsing on DT systems
  2022-04-01 20:54 ` Gwendal Grignou
@ 2022-04-02 15:26   ` Jonathan Cameron
  0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2022-04-02 15:26 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: Stephen Boyd, Lars-Peter Clausen, linux-kernel, linux-iio

On Fri, 1 Apr 2022 13:54:51 -0700
Gwendal Grignou <gwendal@chromium.org> wrote:

> On Thu, Mar 31, 2022 at 2:04 PM Stephen Boyd <swboyd@chromium.org> wrote:
> >
> > After commit 7a3605bef878 ("iio: sx9310: Support ACPI property") we
> > started using the 'indio_dev->dev' to extract device properties for
> > various register settings in sx9310_get_default_reg(). This broke DT
> > based systems because dev_fwnode() used in the device_property*() APIs
> > can't find an 'of_node'. That's because the 'indio_dev->dev.of_node'
> > pointer isn't set until iio_device_register() is called. Set the pointer
> > earlier, next to where the ACPI companion is set, so that the device
> > property APIs work on DT systems.
> >
> > Cc: Gwendal Grignou <gwendal@chromium.org>
> > Fixes: 7a3605bef878 ("iio: sx9310: Support ACPI property")
> > Signed-off-by: Stephen Boyd <swboyd@chromium.org>  
> Reviewed-by: Gwendal Grignou <gwendal@chromium.org>

Applied to the fixes-togreg branch of iio.git though I'll not push
that out until rc1 is out in a few days time and I can rebase appropriately.

Thinking on the cause of this problem it seems like we should really be setting
the indio_dev->dev.of_node in iio_device_alloc() and then let a driver
override it if desired rather than this approach of fill it in if not set.
Such a change only affects a few drivers based on a dumb bit of grepping.
I'd treat such a change as a cleanup though, so having this fix in place
makes sense anyway. 

Jonathan

> > ---
> >  drivers/iio/proximity/sx_common.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/iio/proximity/sx_common.c b/drivers/iio/proximity/sx_common.c
> > index a7c07316a0a9..8ad814d96b7e 100644
> > --- a/drivers/iio/proximity/sx_common.c
> > +++ b/drivers/iio/proximity/sx_common.c
> > @@ -521,6 +521,7 @@ int sx_common_probe(struct i2c_client *client,
> >                 return dev_err_probe(dev, ret, "error reading WHOAMI\n");
> >
> >         ACPI_COMPANION_SET(&indio_dev->dev, ACPI_COMPANION(dev));
> > +       indio_dev->dev.of_node = client->dev.of_node;
> >         indio_dev->modes = INDIO_DIRECT_MODE;
> >
> >         indio_dev->channels =  data->chip_info->iio_channels;
> > --
> > https://chromeos.dev
> >  


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

end of thread, other threads:[~2022-04-02 15:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-31 21:04 [PATCH] iio:proximity:sx_common: Fix device property parsing on DT systems Stephen Boyd
2022-04-01 20:54 ` Gwendal Grignou
2022-04-02 15:26   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox