All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/34] make iio inkern interface firmware agnostic
@ 2022-06-10  8:45 ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

The main goal of this patchset is to convert the iio inkern interface to
be firmware agnostic. Some previous discussion was done in here [1].
Though something odd happened while sending the patches and the RFC
actually never landed in the IIO list (hopefully now works):

As suggested by Andy, the series can be seen in three blocks:

1) "Fix" all drivers that were relying on iio.h for specific header
files (mainly of.h and mod_devicetable.h). After that we can drop
of.h from iio.h and just forward declare what we need.

2) Move "most" of the IIO in kernel interface to FW API. At this point,
there's still some OF dependent API in place so that users are not broken.

3) Move all users of the IIO in kernel interface to the FW API and with
that, make IIO firmware agnostic.

On 3), the qcom-spmi-adc-tm5.c driver was only converted to use the IIO
API while on the IIO drivers a full driver conversion was done. The
thermal one would be really non trivial as we would also need to touch the
subsystem. On the IIO drivers, the conversions were mostly peacefull
(apparently). Special care for the stm32-adc.c driver though as that one
was far from being straight :).

Lastly, this is only compile tested with allyesconfig for arm and arm64.
While I surely can come up with some dummy devices to make sure I can still
properly get IIO channels, having proper tested-by tags on platforms
relying on this interface would be very appreciated (and I suspect Jonathan
will require it).

[1]: https://lore.kernel.org/linux-iio/20220604141925.129f0ffe@jic23-huawei/T/#mfd5ccd793841569182e4f831f2c46089b665c346

Nuno Sá (34):
  iio: adc: ad7606: explicitly add proper header files
  iio: adc: ad7606_par: explicitly add proper header files
  iio: adc: berlin2-adc: explicitly add proper header files
  iio: adc: imx7d_adc: explicitly add proper header files
  iio: adc: imx8qxp-adc: explicitly add proper header files
  iio: adc: ingenic-adc: explicitly add proper header files
  iio: adc: mp2629_adc: explicitly add proper header files
  iio: adc: mt6360-adc: explicitly add proper header files
  iio: adc: npcm_adc: explicitly add proper header files
  iio: adc: rzg2l_adc: explicitly add proper header files
  iio: common: cros_ec_lid_angle: explicitly add proper header files
  iio: common: cros_ec_sensors: explicitly add proper header files
  iio: dac: stm32-dac: explicitly add proper header files
  iio: dac: vf610_dac: explicitly add proper header files
  iio: humidity: hts221_buffer: explicitly add proper header files
  iio: light: cros_ec_light_prox: explicitly add proper header files
  iio: pressure: cros_ec_baro: explicitly add proper header files
  iio: trigger: stm32-lptimer-trigger: explicitly add proper header
    files
  iio: core: drop of.h from iio.h
  iio: inkern: only relase the device node when done with it
  iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
  iio: inkern: only return error codes in iio_channel_get_*() APIs
  iio: inkern: split of_iio_channel_get_by_name()
  iio: inkern: move to fwnode properties
  thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
  iio: adc: ingenic-adc: convert to IIO fwnode interface
  iio: adc: ab8500-gpadc: convert to device properties
  iio: adc: at91-sama5d2_adc: convert to device properties
  iio: adc: qcom-pm8xxx-xoadc: convert to device properties
  iio: adc: qcom-spmi-vadc: convert to device properties
  iio: adc: qcom-spmi-adc5: convert to device properties
  iio: adc: stm32-adc: convert to device properties
  iio: inkern: remove OF dependencies
  iio: inkern: fix coding style warnings

 drivers/iio/adc/ab8500-gpadc.c                |  27 +-
 drivers/iio/adc/ad7606.c                      |   1 +
 drivers/iio/adc/ad7606_par.c                  |   1 +
 drivers/iio/adc/at91-sama5d2_adc.c            |  30 +--
 drivers/iio/adc/berlin2-adc.c                 |   2 +
 drivers/iio/adc/imx7d_adc.c                   |   1 +
 drivers/iio/adc/imx8qxp-adc.c                 |   1 +
 drivers/iio/adc/ingenic-adc.c                 |   9 +-
 drivers/iio/adc/mp2629_adc.c                  |   1 +
 drivers/iio/adc/mt6360-adc.c                  |   1 +
 drivers/iio/adc/npcm_adc.c                    |   1 +
 drivers/iio/adc/qcom-pm8xxx-xoadc.c           |  58 ++---
 drivers/iio/adc/qcom-spmi-adc5.c              |  63 +++--
 drivers/iio/adc/qcom-spmi-vadc.c              |  44 ++--
 drivers/iio/adc/rzg2l_adc.c                   |   1 +
 drivers/iio/adc/stm32-adc.c                   | 128 +++++-----
 .../cros_ec_sensors/cros_ec_lid_angle.c       |   1 +
 .../common/cros_ec_sensors/cros_ec_sensors.c  |   1 +
 drivers/iio/dac/stm32-dac.c                   |   2 +
 drivers/iio/dac/vf610_dac.c                   |   1 +
 drivers/iio/humidity/hts221_buffer.c          |   1 +
 drivers/iio/inkern.c                          | 241 +++++++++---------
 drivers/iio/light/cros_ec_light_prox.c        |   1 +
 drivers/iio/pressure/cros_ec_baro.c           |   1 +
 drivers/iio/trigger/stm32-lptimer-trigger.c   |   1 +
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |   3 +-
 include/linux/iio/consumer.h                  |  28 +-
 include/linux/iio/iio.h                       |   9 +-
 28 files changed, 347 insertions(+), 312 deletions(-)

-- 
2.36.1


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

* [PATCH 00/34] make iio inkern interface firmware agnostic
@ 2022-06-10  8:45 ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

The main goal of this patchset is to convert the iio inkern interface to
be firmware agnostic. Some previous discussion was done in here [1].
Though something odd happened while sending the patches and the RFC
actually never landed in the IIO list (hopefully now works):

As suggested by Andy, the series can be seen in three blocks:

1) "Fix" all drivers that were relying on iio.h for specific header
files (mainly of.h and mod_devicetable.h). After that we can drop
of.h from iio.h and just forward declare what we need.

2) Move "most" of the IIO in kernel interface to FW API. At this point,
there's still some OF dependent API in place so that users are not broken.

3) Move all users of the IIO in kernel interface to the FW API and with
that, make IIO firmware agnostic.

On 3), the qcom-spmi-adc-tm5.c driver was only converted to use the IIO
API while on the IIO drivers a full driver conversion was done. The
thermal one would be really non trivial as we would also need to touch the
subsystem. On the IIO drivers, the conversions were mostly peacefull
(apparently). Special care for the stm32-adc.c driver though as that one
was far from being straight :).

Lastly, this is only compile tested with allyesconfig for arm and arm64.
While I surely can come up with some dummy devices to make sure I can still
properly get IIO channels, having proper tested-by tags on platforms
relying on this interface would be very appreciated (and I suspect Jonathan
will require it).

[1]: https://lore.kernel.org/linux-iio/20220604141925.129f0ffe@jic23-huawei/T/#mfd5ccd793841569182e4f831f2c46089b665c346

Nuno Sá (34):
  iio: adc: ad7606: explicitly add proper header files
  iio: adc: ad7606_par: explicitly add proper header files
  iio: adc: berlin2-adc: explicitly add proper header files
  iio: adc: imx7d_adc: explicitly add proper header files
  iio: adc: imx8qxp-adc: explicitly add proper header files
  iio: adc: ingenic-adc: explicitly add proper header files
  iio: adc: mp2629_adc: explicitly add proper header files
  iio: adc: mt6360-adc: explicitly add proper header files
  iio: adc: npcm_adc: explicitly add proper header files
  iio: adc: rzg2l_adc: explicitly add proper header files
  iio: common: cros_ec_lid_angle: explicitly add proper header files
  iio: common: cros_ec_sensors: explicitly add proper header files
  iio: dac: stm32-dac: explicitly add proper header files
  iio: dac: vf610_dac: explicitly add proper header files
  iio: humidity: hts221_buffer: explicitly add proper header files
  iio: light: cros_ec_light_prox: explicitly add proper header files
  iio: pressure: cros_ec_baro: explicitly add proper header files
  iio: trigger: stm32-lptimer-trigger: explicitly add proper header
    files
  iio: core: drop of.h from iio.h
  iio: inkern: only relase the device node when done with it
  iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
  iio: inkern: only return error codes in iio_channel_get_*() APIs
  iio: inkern: split of_iio_channel_get_by_name()
  iio: inkern: move to fwnode properties
  thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
  iio: adc: ingenic-adc: convert to IIO fwnode interface
  iio: adc: ab8500-gpadc: convert to device properties
  iio: adc: at91-sama5d2_adc: convert to device properties
  iio: adc: qcom-pm8xxx-xoadc: convert to device properties
  iio: adc: qcom-spmi-vadc: convert to device properties
  iio: adc: qcom-spmi-adc5: convert to device properties
  iio: adc: stm32-adc: convert to device properties
  iio: inkern: remove OF dependencies
  iio: inkern: fix coding style warnings

 drivers/iio/adc/ab8500-gpadc.c                |  27 +-
 drivers/iio/adc/ad7606.c                      |   1 +
 drivers/iio/adc/ad7606_par.c                  |   1 +
 drivers/iio/adc/at91-sama5d2_adc.c            |  30 +--
 drivers/iio/adc/berlin2-adc.c                 |   2 +
 drivers/iio/adc/imx7d_adc.c                   |   1 +
 drivers/iio/adc/imx8qxp-adc.c                 |   1 +
 drivers/iio/adc/ingenic-adc.c                 |   9 +-
 drivers/iio/adc/mp2629_adc.c                  |   1 +
 drivers/iio/adc/mt6360-adc.c                  |   1 +
 drivers/iio/adc/npcm_adc.c                    |   1 +
 drivers/iio/adc/qcom-pm8xxx-xoadc.c           |  58 ++---
 drivers/iio/adc/qcom-spmi-adc5.c              |  63 +++--
 drivers/iio/adc/qcom-spmi-vadc.c              |  44 ++--
 drivers/iio/adc/rzg2l_adc.c                   |   1 +
 drivers/iio/adc/stm32-adc.c                   | 128 +++++-----
 .../cros_ec_sensors/cros_ec_lid_angle.c       |   1 +
 .../common/cros_ec_sensors/cros_ec_sensors.c  |   1 +
 drivers/iio/dac/stm32-dac.c                   |   2 +
 drivers/iio/dac/vf610_dac.c                   |   1 +
 drivers/iio/humidity/hts221_buffer.c          |   1 +
 drivers/iio/inkern.c                          | 241 +++++++++---------
 drivers/iio/light/cros_ec_light_prox.c        |   1 +
 drivers/iio/pressure/cros_ec_baro.c           |   1 +
 drivers/iio/trigger/stm32-lptimer-trigger.c   |   1 +
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |   3 +-
 include/linux/iio/consumer.h                  |  28 +-
 include/linux/iio/iio.h                       |   9 +-
 28 files changed, 347 insertions(+), 312 deletions(-)

-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 00/34] make iio inkern interface firmware agnostic
@ 2022-06-10  8:45 ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

The main goal of this patchset is to convert the iio inkern interface to
be firmware agnostic. Some previous discussion was done in here [1].
Though something odd happened while sending the patches and the RFC
actually never landed in the IIO list (hopefully now works):

As suggested by Andy, the series can be seen in three blocks:

1) "Fix" all drivers that were relying on iio.h for specific header
files (mainly of.h and mod_devicetable.h). After that we can drop
of.h from iio.h and just forward declare what we need.

2) Move "most" of the IIO in kernel interface to FW API. At this point,
there's still some OF dependent API in place so that users are not broken.

3) Move all users of the IIO in kernel interface to the FW API and with
that, make IIO firmware agnostic.

On 3), the qcom-spmi-adc-tm5.c driver was only converted to use the IIO
API while on the IIO drivers a full driver conversion was done. The
thermal one would be really non trivial as we would also need to touch the
subsystem. On the IIO drivers, the conversions were mostly peacefull
(apparently). Special care for the stm32-adc.c driver though as that one
was far from being straight :).

Lastly, this is only compile tested with allyesconfig for arm and arm64.
While I surely can come up with some dummy devices to make sure I can still
properly get IIO channels, having proper tested-by tags on platforms
relying on this interface would be very appreciated (and I suspect Jonathan
will require it).

[1]: https://lore.kernel.org/linux-iio/20220604141925.129f0ffe@jic23-huawei/T/#mfd5ccd793841569182e4f831f2c46089b665c346

Nuno Sá (34):
  iio: adc: ad7606: explicitly add proper header files
  iio: adc: ad7606_par: explicitly add proper header files
  iio: adc: berlin2-adc: explicitly add proper header files
  iio: adc: imx7d_adc: explicitly add proper header files
  iio: adc: imx8qxp-adc: explicitly add proper header files
  iio: adc: ingenic-adc: explicitly add proper header files
  iio: adc: mp2629_adc: explicitly add proper header files
  iio: adc: mt6360-adc: explicitly add proper header files
  iio: adc: npcm_adc: explicitly add proper header files
  iio: adc: rzg2l_adc: explicitly add proper header files
  iio: common: cros_ec_lid_angle: explicitly add proper header files
  iio: common: cros_ec_sensors: explicitly add proper header files
  iio: dac: stm32-dac: explicitly add proper header files
  iio: dac: vf610_dac: explicitly add proper header files
  iio: humidity: hts221_buffer: explicitly add proper header files
  iio: light: cros_ec_light_prox: explicitly add proper header files
  iio: pressure: cros_ec_baro: explicitly add proper header files
  iio: trigger: stm32-lptimer-trigger: explicitly add proper header
    files
  iio: core: drop of.h from iio.h
  iio: inkern: only relase the device node when done with it
  iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
  iio: inkern: only return error codes in iio_channel_get_*() APIs
  iio: inkern: split of_iio_channel_get_by_name()
  iio: inkern: move to fwnode properties
  thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
  iio: adc: ingenic-adc: convert to IIO fwnode interface
  iio: adc: ab8500-gpadc: convert to device properties
  iio: adc: at91-sama5d2_adc: convert to device properties
  iio: adc: qcom-pm8xxx-xoadc: convert to device properties
  iio: adc: qcom-spmi-vadc: convert to device properties
  iio: adc: qcom-spmi-adc5: convert to device properties
  iio: adc: stm32-adc: convert to device properties
  iio: inkern: remove OF dependencies
  iio: inkern: fix coding style warnings

 drivers/iio/adc/ab8500-gpadc.c                |  27 +-
 drivers/iio/adc/ad7606.c                      |   1 +
 drivers/iio/adc/ad7606_par.c                  |   1 +
 drivers/iio/adc/at91-sama5d2_adc.c            |  30 +--
 drivers/iio/adc/berlin2-adc.c                 |   2 +
 drivers/iio/adc/imx7d_adc.c                   |   1 +
 drivers/iio/adc/imx8qxp-adc.c                 |   1 +
 drivers/iio/adc/ingenic-adc.c                 |   9 +-
 drivers/iio/adc/mp2629_adc.c                  |   1 +
 drivers/iio/adc/mt6360-adc.c                  |   1 +
 drivers/iio/adc/npcm_adc.c                    |   1 +
 drivers/iio/adc/qcom-pm8xxx-xoadc.c           |  58 ++---
 drivers/iio/adc/qcom-spmi-adc5.c              |  63 +++--
 drivers/iio/adc/qcom-spmi-vadc.c              |  44 ++--
 drivers/iio/adc/rzg2l_adc.c                   |   1 +
 drivers/iio/adc/stm32-adc.c                   | 128 +++++-----
 .../cros_ec_sensors/cros_ec_lid_angle.c       |   1 +
 .../common/cros_ec_sensors/cros_ec_sensors.c  |   1 +
 drivers/iio/dac/stm32-dac.c                   |   2 +
 drivers/iio/dac/vf610_dac.c                   |   1 +
 drivers/iio/humidity/hts221_buffer.c          |   1 +
 drivers/iio/inkern.c                          | 241 +++++++++---------
 drivers/iio/light/cros_ec_light_prox.c        |   1 +
 drivers/iio/pressure/cros_ec_baro.c           |   1 +
 drivers/iio/trigger/stm32-lptimer-trigger.c   |   1 +
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |   3 +-
 include/linux/iio/consumer.h                  |  28 +-
 include/linux/iio/iio.h                       |   9 +-
 28 files changed, 347 insertions(+), 312 deletions(-)

-- 
2.36.1


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

* [PATCH 00/34] make iio inkern interface firmware agnostic
@ 2022-06-10  8:45 ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

The main goal of this patchset is to convert the iio inkern interface to
be firmware agnostic. Some previous discussion was done in here [1].
Though something odd happened while sending the patches and the RFC
actually never landed in the IIO list (hopefully now works):

As suggested by Andy, the series can be seen in three blocks:

1) "Fix" all drivers that were relying on iio.h for specific header
files (mainly of.h and mod_devicetable.h). After that we can drop
of.h from iio.h and just forward declare what we need.

2) Move "most" of the IIO in kernel interface to FW API. At this point,
there's still some OF dependent API in place so that users are not broken.

3) Move all users of the IIO in kernel interface to the FW API and with
that, make IIO firmware agnostic.

On 3), the qcom-spmi-adc-tm5.c driver was only converted to use the IIO
API while on the IIO drivers a full driver conversion was done. The
thermal one would be really non trivial as we would also need to touch the
subsystem. On the IIO drivers, the conversions were mostly peacefull
(apparently). Special care for the stm32-adc.c driver though as that one
was far from being straight :).

Lastly, this is only compile tested with allyesconfig for arm and arm64.
While I surely can come up with some dummy devices to make sure I can still
properly get IIO channels, having proper tested-by tags on platforms
relying on this interface would be very appreciated (and I suspect Jonathan
will require it).

[1]: https://lore.kernel.org/linux-iio/20220604141925.129f0ffe@jic23-huawei/T/#mfd5ccd793841569182e4f831f2c46089b665c346

Nuno Sá (34):
  iio: adc: ad7606: explicitly add proper header files
  iio: adc: ad7606_par: explicitly add proper header files
  iio: adc: berlin2-adc: explicitly add proper header files
  iio: adc: imx7d_adc: explicitly add proper header files
  iio: adc: imx8qxp-adc: explicitly add proper header files
  iio: adc: ingenic-adc: explicitly add proper header files
  iio: adc: mp2629_adc: explicitly add proper header files
  iio: adc: mt6360-adc: explicitly add proper header files
  iio: adc: npcm_adc: explicitly add proper header files
  iio: adc: rzg2l_adc: explicitly add proper header files
  iio: common: cros_ec_lid_angle: explicitly add proper header files
  iio: common: cros_ec_sensors: explicitly add proper header files
  iio: dac: stm32-dac: explicitly add proper header files
  iio: dac: vf610_dac: explicitly add proper header files
  iio: humidity: hts221_buffer: explicitly add proper header files
  iio: light: cros_ec_light_prox: explicitly add proper header files
  iio: pressure: cros_ec_baro: explicitly add proper header files
  iio: trigger: stm32-lptimer-trigger: explicitly add proper header
    files
  iio: core: drop of.h from iio.h
  iio: inkern: only relase the device node when done with it
  iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
  iio: inkern: only return error codes in iio_channel_get_*() APIs
  iio: inkern: split of_iio_channel_get_by_name()
  iio: inkern: move to fwnode properties
  thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
  iio: adc: ingenic-adc: convert to IIO fwnode interface
  iio: adc: ab8500-gpadc: convert to device properties
  iio: adc: at91-sama5d2_adc: convert to device properties
  iio: adc: qcom-pm8xxx-xoadc: convert to device properties
  iio: adc: qcom-spmi-vadc: convert to device properties
  iio: adc: qcom-spmi-adc5: convert to device properties
  iio: adc: stm32-adc: convert to device properties
  iio: inkern: remove OF dependencies
  iio: inkern: fix coding style warnings

 drivers/iio/adc/ab8500-gpadc.c                |  27 +-
 drivers/iio/adc/ad7606.c                      |   1 +
 drivers/iio/adc/ad7606_par.c                  |   1 +
 drivers/iio/adc/at91-sama5d2_adc.c            |  30 +--
 drivers/iio/adc/berlin2-adc.c                 |   2 +
 drivers/iio/adc/imx7d_adc.c                   |   1 +
 drivers/iio/adc/imx8qxp-adc.c                 |   1 +
 drivers/iio/adc/ingenic-adc.c                 |   9 +-
 drivers/iio/adc/mp2629_adc.c                  |   1 +
 drivers/iio/adc/mt6360-adc.c                  |   1 +
 drivers/iio/adc/npcm_adc.c                    |   1 +
 drivers/iio/adc/qcom-pm8xxx-xoadc.c           |  58 ++---
 drivers/iio/adc/qcom-spmi-adc5.c              |  63 +++--
 drivers/iio/adc/qcom-spmi-vadc.c              |  44 ++--
 drivers/iio/adc/rzg2l_adc.c                   |   1 +
 drivers/iio/adc/stm32-adc.c                   | 128 +++++-----
 .../cros_ec_sensors/cros_ec_lid_angle.c       |   1 +
 .../common/cros_ec_sensors/cros_ec_sensors.c  |   1 +
 drivers/iio/dac/stm32-dac.c                   |   2 +
 drivers/iio/dac/vf610_dac.c                   |   1 +
 drivers/iio/humidity/hts221_buffer.c          |   1 +
 drivers/iio/inkern.c                          | 241 +++++++++---------
 drivers/iio/light/cros_ec_light_prox.c        |   1 +
 drivers/iio/pressure/cros_ec_baro.c           |   1 +
 drivers/iio/trigger/stm32-lptimer-trigger.c   |   1 +
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |   3 +-
 include/linux/iio/consumer.h                  |  28 +-
 include/linux/iio/iio.h                       |   9 +-
 28 files changed, 347 insertions(+), 312 deletions(-)

-- 
2.36.1


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

* [PATCH 01/34] iio: adc: ad7606: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7606.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 3b193dc26438..ba24f99523e0 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
-- 
2.36.1


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

* [PATCH 01/34] iio: adc: ad7606: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7606.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 3b193dc26438..ba24f99523e0 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 01/34] iio: adc: ad7606: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7606.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 3b193dc26438..ba24f99523e0 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -12,6 +12,7 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/property.h>
 #include <linux/regulator/consumer.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
-- 
2.36.1


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

* [PATCH 02/34] iio: adc: ad7606_par: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7606_par.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
index 8888e56b5e90..b912b4df9b56 100644
--- a/drivers/iio/adc/ad7606_par.c
+++ b/drivers/iio/adc/ad7606_par.c
@@ -5,6 +5,7 @@
  * Copyright 2011 Analog Devices Inc.
  */
 
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
-- 
2.36.1


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

* [PATCH 02/34] iio: adc: ad7606_par: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7606_par.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
index 8888e56b5e90..b912b4df9b56 100644
--- a/drivers/iio/adc/ad7606_par.c
+++ b/drivers/iio/adc/ad7606_par.c
@@ -5,6 +5,7 @@
  * Copyright 2011 Analog Devices Inc.
  */
 
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 02/34] iio: adc: ad7606_par: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ad7606_par.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
index 8888e56b5e90..b912b4df9b56 100644
--- a/drivers/iio/adc/ad7606_par.c
+++ b/drivers/iio/adc/ad7606_par.c
@@ -5,6 +5,7 @@
  * Copyright 2011 Analog Devices Inc.
  */
 
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/types.h>
-- 
2.36.1


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

* [PATCH 03/34] iio: adc: berlin2-adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/berlin2-adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
index 03987d7e6b3d..3d2e8b4db61a 100644
--- a/drivers/iio/adc/berlin2-adc.c
+++ b/drivers/iio/adc/berlin2-adc.c
@@ -15,7 +15,9 @@
 #include <linux/iio/machine.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/mfd/syscon.h>
-- 
2.36.1


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

* [PATCH 03/34] iio: adc: berlin2-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/berlin2-adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
index 03987d7e6b3d..3d2e8b4db61a 100644
--- a/drivers/iio/adc/berlin2-adc.c
+++ b/drivers/iio/adc/berlin2-adc.c
@@ -15,7 +15,9 @@
 #include <linux/iio/machine.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/mfd/syscon.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 03/34] iio: adc: berlin2-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/berlin2-adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
index 03987d7e6b3d..3d2e8b4db61a 100644
--- a/drivers/iio/adc/berlin2-adc.c
+++ b/drivers/iio/adc/berlin2-adc.c
@@ -15,7 +15,9 @@
 #include <linux/iio/machine.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/mfd/syscon.h>
-- 
2.36.1


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

* [PATCH 04/34] iio: adc: imx7d_adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/imx7d_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 12f5b8e34c84..119217af2bde 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -11,6 +11,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-- 
2.36.1


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

* [PATCH 04/34] iio: adc: imx7d_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/imx7d_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 12f5b8e34c84..119217af2bde 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -11,6 +11,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 04/34] iio: adc: imx7d_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/imx7d_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
index 12f5b8e34c84..119217af2bde 100644
--- a/drivers/iio/adc/imx7d_adc.c
+++ b/drivers/iio/adc/imx7d_adc.c
@@ -11,6 +11,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-- 
2.36.1


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

* [PATCH 05/34] iio: adc: imx8qxp-adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/imx8qxp-adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
index 901dd8e1b32f..e8c9a69e10eb 100644
--- a/drivers/iio/adc/imx8qxp-adc.c
+++ b/drivers/iio/adc/imx8qxp-adc.c
@@ -19,6 +19,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-- 
2.36.1


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

* [PATCH 05/34] iio: adc: imx8qxp-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/imx8qxp-adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
index 901dd8e1b32f..e8c9a69e10eb 100644
--- a/drivers/iio/adc/imx8qxp-adc.c
+++ b/drivers/iio/adc/imx8qxp-adc.c
@@ -19,6 +19,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 05/34] iio: adc: imx8qxp-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/imx8qxp-adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
index 901dd8e1b32f..e8c9a69e10eb 100644
--- a/drivers/iio/adc/imx8qxp-adc.c
+++ b/drivers/iio/adc/imx8qxp-adc.c
@@ -19,6 +19,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-- 
2.36.1


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

* [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ingenic-adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index 2b3912c6ca6b..e731ba47add2 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -18,6 +18,8 @@
 #include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/of.h>
 
 #define JZ_ADC_REG_ENABLE		0x00
 #define JZ_ADC_REG_CFG			0x04
-- 
2.36.1


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

* [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ingenic-adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index 2b3912c6ca6b..e731ba47add2 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -18,6 +18,8 @@
 #include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/of.h>
 
 #define JZ_ADC_REG_ENABLE		0x00
 #define JZ_ADC_REG_CFG			0x04
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ingenic-adc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index 2b3912c6ca6b..e731ba47add2 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -18,6 +18,8 @@
 #include <linux/mod_devicetable.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/of.h>
 
 #define JZ_ADC_REG_ENABLE		0x00
 #define JZ_ADC_REG_CFG			0x04
-- 
2.36.1


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

* [PATCH 07/34] iio: adc: mp2629_adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/mp2629_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
index aca084f1e78a..30a31f185d08 100644
--- a/drivers/iio/adc/mp2629_adc.c
+++ b/drivers/iio/adc/mp2629_adc.c
@@ -11,6 +11,7 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/machine.h>
 #include <linux/mfd/mp2629.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
-- 
2.36.1


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

* [PATCH 07/34] iio: adc: mp2629_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/mp2629_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
index aca084f1e78a..30a31f185d08 100644
--- a/drivers/iio/adc/mp2629_adc.c
+++ b/drivers/iio/adc/mp2629_adc.c
@@ -11,6 +11,7 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/machine.h>
 #include <linux/mfd/mp2629.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 07/34] iio: adc: mp2629_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/mp2629_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
index aca084f1e78a..30a31f185d08 100644
--- a/drivers/iio/adc/mp2629_adc.c
+++ b/drivers/iio/adc/mp2629_adc.c
@@ -11,6 +11,7 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/machine.h>
 #include <linux/mfd/mp2629.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
-- 
2.36.1


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

* [PATCH 08/34] iio: adc: mt6360-adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/mt6360-adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
index 07c0e6768391..35260d9e4e47 100644
--- a/drivers/iio/adc/mt6360-adc.c
+++ b/drivers/iio/adc/mt6360-adc.c
@@ -5,6 +5,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/ktime.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
-- 
2.36.1


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

* [PATCH 08/34] iio: adc: mt6360-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/mt6360-adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
index 07c0e6768391..35260d9e4e47 100644
--- a/drivers/iio/adc/mt6360-adc.c
+++ b/drivers/iio/adc/mt6360-adc.c
@@ -5,6 +5,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/ktime.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 08/34] iio: adc: mt6360-adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/mt6360-adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
index 07c0e6768391..35260d9e4e47 100644
--- a/drivers/iio/adc/mt6360-adc.c
+++ b/drivers/iio/adc/mt6360-adc.c
@@ -5,6 +5,7 @@
 #include <linux/irq.h>
 #include <linux/kernel.h>
 #include <linux/ktime.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
-- 
2.36.1


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

* [PATCH 09/34] iio: adc: npcm_adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/npcm_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
index f7bc0bb7f112..a242e7993476 100644
--- a/drivers/iio/adc/npcm_adc.c
+++ b/drivers/iio/adc/npcm_adc.c
@@ -8,6 +8,7 @@
 #include <linux/iio/iio.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
-- 
2.36.1


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

* [PATCH 09/34] iio: adc: npcm_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/npcm_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
index f7bc0bb7f112..a242e7993476 100644
--- a/drivers/iio/adc/npcm_adc.c
+++ b/drivers/iio/adc/npcm_adc.c
@@ -8,6 +8,7 @@
 #include <linux/iio/iio.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 09/34] iio: adc: npcm_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/npcm_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
index f7bc0bb7f112..a242e7993476 100644
--- a/drivers/iio/adc/npcm_adc.c
+++ b/drivers/iio/adc/npcm_adc.c
@@ -8,6 +8,7 @@
 #include <linux/iio/iio.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
-- 
2.36.1


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

* [PATCH 10/34] iio: adc: rzg2l_adc: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/rzg2l_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
index bee5f9861acb..c9403ab520d8 100644
--- a/drivers/iio/adc/rzg2l_adc.c
+++ b/drivers/iio/adc/rzg2l_adc.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/reset.h>
 
 #define DRIVER_NAME		"rzg2l-adc"
-- 
2.36.1


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

* [PATCH 10/34] iio: adc: rzg2l_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/rzg2l_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
index bee5f9861acb..c9403ab520d8 100644
--- a/drivers/iio/adc/rzg2l_adc.c
+++ b/drivers/iio/adc/rzg2l_adc.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/reset.h>
 
 #define DRIVER_NAME		"rzg2l-adc"
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 10/34] iio: adc: rzg2l_adc: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/rzg2l_adc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
index bee5f9861acb..c9403ab520d8 100644
--- a/drivers/iio/adc/rzg2l_adc.c
+++ b/drivers/iio/adc/rzg2l_adc.c
@@ -18,6 +18,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
+#include <linux/property.h>
 #include <linux/reset.h>
 
 #define DRIVER_NAME		"rzg2l-adc"
-- 
2.36.1


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

* [PATCH 11/34] iio: common: cros_ec_lid_angle: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
index af801e203623..9f780fafaed9 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
@@ -20,6 +20,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_device.h>
-- 
2.36.1


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

* [PATCH 11/34] iio: common: cros_ec_lid_angle: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
index af801e203623..9f780fafaed9 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
@@ -20,6 +20,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_device.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 11/34] iio: common: cros_ec_lid_angle: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
index af801e203623..9f780fafaed9 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
@@ -20,6 +20,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_device.h>
-- 
2.36.1


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

* [PATCH 12/34] iio: common: cros_ec_sensors: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 376a5b30010a..61e07a7bb199 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -16,6 +16,7 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
-- 
2.36.1


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

* [PATCH 12/34] iio: common: cros_ec_sensors: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 376a5b30010a..61e07a7bb199 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -16,6 +16,7 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 12/34] iio: common: cros_ec_sensors: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
index 376a5b30010a..61e07a7bb199 100644
--- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
+++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
@@ -16,6 +16,7 @@
 #include <linux/iio/trigger_consumer.h>
 #include <linux/iio/triggered_buffer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
-- 
2.36.1


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

* [PATCH 13/34] iio: dac: stm32-dac: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/dac/stm32-dac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
index daa42bcbae83..0de1b09b92f7 100644
--- a/drivers/iio/dac/stm32-dac.c
+++ b/drivers/iio/dac/stm32-dac.c
@@ -12,6 +12,8 @@
 #include <linux/iio/iio.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 
-- 
2.36.1


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

* [PATCH 13/34] iio: dac: stm32-dac: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/dac/stm32-dac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
index daa42bcbae83..0de1b09b92f7 100644
--- a/drivers/iio/dac/stm32-dac.c
+++ b/drivers/iio/dac/stm32-dac.c
@@ -12,6 +12,8 @@
 #include <linux/iio/iio.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 13/34] iio: dac: stm32-dac: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/dac/stm32-dac.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
index daa42bcbae83..0de1b09b92f7 100644
--- a/drivers/iio/dac/stm32-dac.c
+++ b/drivers/iio/dac/stm32-dac.c
@@ -12,6 +12,8 @@
 #include <linux/iio/iio.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
 
-- 
2.36.1


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

* [PATCH 14/34] iio: dac: vf610_dac: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/dac/vf610_dac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
index 92429c0d2685..fc182250c622 100644
--- a/drivers/iio/dac/vf610_dac.c
+++ b/drivers/iio/dac/vf610_dac.c
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-- 
2.36.1


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

* [PATCH 14/34] iio: dac: vf610_dac: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/dac/vf610_dac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
index 92429c0d2685..fc182250c622 100644
--- a/drivers/iio/dac/vf610_dac.c
+++ b/drivers/iio/dac/vf610_dac.c
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 14/34] iio: dac: vf610_dac: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/dac/vf610_dac.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
index 92429c0d2685..fc182250c622 100644
--- a/drivers/iio/dac/vf610_dac.c
+++ b/drivers/iio/dac/vf610_dac.c
@@ -10,6 +10,7 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-- 
2.36.1


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

* [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/humidity/hts221_buffer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
index f29692b9d2db..9010e355754e 100644
--- a/drivers/iio/humidity/hts221_buffer.c
+++ b/drivers/iio/humidity/hts221_buffer.c
@@ -13,6 +13,7 @@
 #include <linux/irqreturn.h>
 #include <linux/regmap.h>
 #include <linux/bitfield.h>
+#include <linux/property.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/trigger.h>
-- 
2.36.1


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

* [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/humidity/hts221_buffer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
index f29692b9d2db..9010e355754e 100644
--- a/drivers/iio/humidity/hts221_buffer.c
+++ b/drivers/iio/humidity/hts221_buffer.c
@@ -13,6 +13,7 @@
 #include <linux/irqreturn.h>
 #include <linux/regmap.h>
 #include <linux/bitfield.h>
+#include <linux/property.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/trigger.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/humidity/hts221_buffer.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/humidity/hts221_buffer.c b/drivers/iio/humidity/hts221_buffer.c
index f29692b9d2db..9010e355754e 100644
--- a/drivers/iio/humidity/hts221_buffer.c
+++ b/drivers/iio/humidity/hts221_buffer.c
@@ -13,6 +13,7 @@
 #include <linux/irqreturn.h>
 #include <linux/regmap.h>
 #include <linux/bitfield.h>
+#include <linux/property.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/trigger.h>
-- 
2.36.1


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

* [PATCH 16/34] iio: light: cros_ec_light_prox: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/light/cros_ec_light_prox.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index a00a8b3b86cf..e345e0f71b74 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -14,6 +14,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 16/34] iio: light: cros_ec_light_prox: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/light/cros_ec_light_prox.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index a00a8b3b86cf..e345e0f71b74 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -14,6 +14,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
-- 
2.36.1


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

* [PATCH 16/34] iio: light: cros_ec_light_prox: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/light/cros_ec_light_prox.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
index a00a8b3b86cf..e345e0f71b74 100644
--- a/drivers/iio/light/cros_ec_light_prox.c
+++ b/drivers/iio/light/cros_ec_light_prox.c
@@ -14,6 +14,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_data/cros_ec_commands.h>
 #include <linux/platform_data/cros_ec_proto.h>
-- 
2.36.1


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

* [PATCH 17/34] iio: pressure: cros_ec_baro: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/pressure/cros_ec_baro.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index 1d9d34ae3c0a..25217279f350 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -14,6 +14,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/platform_data/cros_ec_commands.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 17/34] iio: pressure: cros_ec_baro: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/pressure/cros_ec_baro.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index 1d9d34ae3c0a..25217279f350 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -14,6 +14,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/platform_data/cros_ec_commands.h>
-- 
2.36.1


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

* [PATCH 17/34] iio: pressure: cros_ec_baro: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/pressure/cros_ec_baro.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index 1d9d34ae3c0a..25217279f350 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -14,6 +14,7 @@
 #include <linux/iio/triggered_buffer.h>
 #include <linux/iio/trigger_consumer.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/platform_data/cros_ec_commands.h>
-- 
2.36.1


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

* [PATCH 18/34] iio: trigger: stm32-lptimer-trigger: explicitly add proper header files
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/trigger/stm32-lptimer-trigger.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/trigger/stm32-lptimer-trigger.c b/drivers/iio/trigger/stm32-lptimer-trigger.c
index af46c10cea92..2e447a3f047d 100644
--- a/drivers/iio/trigger/stm32-lptimer-trigger.c
+++ b/drivers/iio/trigger/stm32-lptimer-trigger.c
@@ -11,6 +11,7 @@
 
 #include <linux/iio/timer/stm32-lptim-trigger.h>
 #include <linux/mfd/stm32-lptimer.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 18/34] iio: trigger: stm32-lptimer-trigger: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/trigger/stm32-lptimer-trigger.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/trigger/stm32-lptimer-trigger.c b/drivers/iio/trigger/stm32-lptimer-trigger.c
index af46c10cea92..2e447a3f047d 100644
--- a/drivers/iio/trigger/stm32-lptimer-trigger.c
+++ b/drivers/iio/trigger/stm32-lptimer-trigger.c
@@ -11,6 +11,7 @@
 
 #include <linux/iio/timer/stm32-lptim-trigger.h>
 #include <linux/mfd/stm32-lptimer.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-- 
2.36.1


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

* [PATCH 18/34] iio: trigger: stm32-lptimer-trigger: explicitly add proper header files
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Do not trust the fact that iio.h includes of.h which in turn includes
all the headers we are relying on.

The ultimate goal is to actually drop of.h from iio.h.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/trigger/stm32-lptimer-trigger.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/trigger/stm32-lptimer-trigger.c b/drivers/iio/trigger/stm32-lptimer-trigger.c
index af46c10cea92..2e447a3f047d 100644
--- a/drivers/iio/trigger/stm32-lptimer-trigger.c
+++ b/drivers/iio/trigger/stm32-lptimer-trigger.c
@@ -11,6 +11,7 @@
 
 #include <linux/iio/timer/stm32-lptim-trigger.h>
 #include <linux/mfd/stm32-lptimer.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-- 
2.36.1


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

* [PATCH 19/34] iio: core: drop of.h from iio.h
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

There is no reason to include OF as we only need to forward declare
'of_phandle_args'. Previously, some drivers were actually relying on
this for some headers (those were already fixed).

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 include/linux/iio/iio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 4e21a82b3756..d9b4a9ca9a0f 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -11,13 +11,14 @@
 #include <linux/cdev.h>
 #include <linux/slab.h>
 #include <linux/iio/types.h>
-#include <linux/of.h>
 /* IIO TODO LIST */
 /*
  * Provide means of adjusting timer accuracy.
  * Currently assumes nano seconds.
  */
 
+struct of_phandle_args;
+
 enum iio_shared_by {
 	IIO_SEPARATE,
 	IIO_SHARED_BY_TYPE,
-- 
2.36.1


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

* [PATCH 19/34] iio: core: drop of.h from iio.h
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

There is no reason to include OF as we only need to forward declare
'of_phandle_args'. Previously, some drivers were actually relying on
this for some headers (those were already fixed).

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 include/linux/iio/iio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 4e21a82b3756..d9b4a9ca9a0f 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -11,13 +11,14 @@
 #include <linux/cdev.h>
 #include <linux/slab.h>
 #include <linux/iio/types.h>
-#include <linux/of.h>
 /* IIO TODO LIST */
 /*
  * Provide means of adjusting timer accuracy.
  * Currently assumes nano seconds.
  */
 
+struct of_phandle_args;
+
 enum iio_shared_by {
 	IIO_SEPARATE,
 	IIO_SHARED_BY_TYPE,
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 19/34] iio: core: drop of.h from iio.h
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

There is no reason to include OF as we only need to forward declare
'of_phandle_args'. Previously, some drivers were actually relying on
this for some headers (those were already fixed).

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 include/linux/iio/iio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 4e21a82b3756..d9b4a9ca9a0f 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -11,13 +11,14 @@
 #include <linux/cdev.h>
 #include <linux/slab.h>
 #include <linux/iio/types.h>
-#include <linux/of.h>
 /* IIO TODO LIST */
 /*
  * Provide means of adjusting timer accuracy.
  * Currently assumes nano seconds.
  */
 
+struct of_phandle_args;
+
 enum iio_shared_by {
 	IIO_SEPARATE,
 	IIO_SHARED_BY_TYPE,
-- 
2.36.1


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

* [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

'of_node_put()' can potentially release the memory pointed to by
'iiospec.np' which would leave us with an invalid pointer (and we would
still pass it in 'of_xlate()'). As such, we can only release the node
after we are done with it.

Fixes: 17d82b47a215d ("iio: Add OF support")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index df74765d33dc..9d87057794fc 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -165,9 +165,10 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 
 	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
 			       iio_dev_node_match);
-	of_node_put(iiospec.np);
-	if (idev == NULL)
+	if (idev == NULL) {
+		of_node_put(iiospec.np);
 		return -EPROBE_DEFER;
+	}
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
@@ -175,6 +176,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
 	else
 		index = __of_iio_simple_xlate(indio_dev, &iiospec);
+	of_node_put(iiospec.np);
 	if (index < 0)
 		goto err_put;
 	channel->channel = &indio_dev->channels[index];
-- 
2.36.1


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

* [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

'of_node_put()' can potentially release the memory pointed to by
'iiospec.np' which would leave us with an invalid pointer (and we would
still pass it in 'of_xlate()'). As such, we can only release the node
after we are done with it.

Fixes: 17d82b47a215d ("iio: Add OF support")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index df74765d33dc..9d87057794fc 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -165,9 +165,10 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 
 	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
 			       iio_dev_node_match);
-	of_node_put(iiospec.np);
-	if (idev == NULL)
+	if (idev == NULL) {
+		of_node_put(iiospec.np);
 		return -EPROBE_DEFER;
+	}
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
@@ -175,6 +176,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
 	else
 		index = __of_iio_simple_xlate(indio_dev, &iiospec);
+	of_node_put(iiospec.np);
 	if (index < 0)
 		goto err_put;
 	channel->channel = &indio_dev->channels[index];
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

'of_node_put()' can potentially release the memory pointed to by
'iiospec.np' which would leave us with an invalid pointer (and we would
still pass it in 'of_xlate()'). As such, we can only release the node
after we are done with it.

Fixes: 17d82b47a215d ("iio: Add OF support")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index df74765d33dc..9d87057794fc 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -165,9 +165,10 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 
 	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
 			       iio_dev_node_match);
-	of_node_put(iiospec.np);
-	if (idev == NULL)
+	if (idev == NULL) {
+		of_node_put(iiospec.np);
 		return -EPROBE_DEFER;
+	}
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
@@ -175,6 +176,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
 	else
 		index = __of_iio_simple_xlate(indio_dev, &iiospec);
+	of_node_put(iiospec.np);
 	if (index < 0)
 		goto err_put;
 	channel->channel = &indio_dev->channels[index];
-- 
2.36.1


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

* [PATCH 21/34] iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

of_iio_channel_get_by_name() can either return NULL or an error pointer
so that only doing IS_ERR() is not enough. Fix it by checking the NULL
pointer case and return -ENODEV in that case. Note this is done like this
so that users of the function (which only check for error pointers) do
not need to be changed. This is not ideal since we are losing error codes
and as such, in a follow up change, things will be unified so that
of_iio_channel_get_by_name() only returns error codes.

Fixes: 6e39b145cef7 ("iio: provide of_iio_channel_get_by_name() and devm_ version it")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 9d87057794fc..87fd2a0d44f2 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -412,6 +412,8 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 	channel = of_iio_channel_get_by_name(np, channel_name);
 	if (IS_ERR(channel))
 		return channel;
+	if (!channel)
+		return ERR_PTR(-ENODEV);
 
 	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
 	if (ret)
-- 
2.36.1


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

* [PATCH 21/34] iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

of_iio_channel_get_by_name() can either return NULL or an error pointer
so that only doing IS_ERR() is not enough. Fix it by checking the NULL
pointer case and return -ENODEV in that case. Note this is done like this
so that users of the function (which only check for error pointers) do
not need to be changed. This is not ideal since we are losing error codes
and as such, in a follow up change, things will be unified so that
of_iio_channel_get_by_name() only returns error codes.

Fixes: 6e39b145cef7 ("iio: provide of_iio_channel_get_by_name() and devm_ version it")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 9d87057794fc..87fd2a0d44f2 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -412,6 +412,8 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 	channel = of_iio_channel_get_by_name(np, channel_name);
 	if (IS_ERR(channel))
 		return channel;
+	if (!channel)
+		return ERR_PTR(-ENODEV);
 
 	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
 	if (ret)
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 21/34] iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

of_iio_channel_get_by_name() can either return NULL or an error pointer
so that only doing IS_ERR() is not enough. Fix it by checking the NULL
pointer case and return -ENODEV in that case. Note this is done like this
so that users of the function (which only check for error pointers) do
not need to be changed. This is not ideal since we are losing error codes
and as such, in a follow up change, things will be unified so that
of_iio_channel_get_by_name() only returns error codes.

Fixes: 6e39b145cef7 ("iio: provide of_iio_channel_get_by_name() and devm_ version it")
Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 9d87057794fc..87fd2a0d44f2 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -412,6 +412,8 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 	channel = of_iio_channel_get_by_name(np, channel_name);
 	if (IS_ERR(channel))
 		return channel;
+	if (!channel)
+		return ERR_PTR(-ENODEV);
 
 	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
 	if (ret)
-- 
2.36.1


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

* [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
returning a mix of NULL and error pointers being NULL the way to
"notify" that we should do a "system" lookup for channels. This make
it very confusing and prone to errors as commit dbbccf7c20bf
("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
proves. On top of this, patterns like 'if (channel != NULL) return channel'
were being used where channel could actually be an error code which
makes the code hard to read.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 87fd2a0d44f2..31d9c122199a 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -214,7 +214,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 					       const char *name)
 {
-	struct iio_channel *chan = NULL;
+	struct iio_channel *chan;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
 	while (np) {
@@ -231,11 +231,11 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 							 name);
 		chan = of_iio_channel_get(np, index);
 		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
-			break;
-		else if (name && index >= 0) {
+			return chan;
+		if (name && index >= 0) {
 			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
 				np, name ? name : "", index);
-			return NULL;
+			return chan;
 		}
 
 		/*
@@ -245,10 +245,10 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		 */
 		np = np->parent;
 		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
+			return chan;
 	}
 
-	return chan;
+	return ERR_PTR(-ENODEV);
 }
 EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
 
@@ -267,8 +267,8 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 			break;
 	} while (++nummaps);
 
-	if (nummaps == 0)	/* no error, return NULL to search map table */
-		return NULL;
+	if (nummaps == 0)	/* return -ENODEV to search map table */
+		return ERR_PTR(-ENODEV);
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
@@ -295,7 +295,7 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 
 static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_OF */
@@ -362,7 +362,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	if (dev) {
 		channel = of_iio_channel_get_by_name(dev->of_node,
 						     channel_name);
-		if (channel != NULL)
+		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
 			return channel;
 	}
 
@@ -412,8 +412,6 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 	channel = of_iio_channel_get_by_name(np, channel_name);
 	if (IS_ERR(channel))
 		return channel;
-	if (!channel)
-		return ERR_PTR(-ENODEV);
 
 	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
 	if (ret)
@@ -436,7 +434,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 		return ERR_PTR(-EINVAL);
 
 	chans = of_iio_channel_get_all(dev);
-	if (chans)
+	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
 		return chans;
 
 	name = dev_name(dev);
-- 
2.36.1


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

* [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
returning a mix of NULL and error pointers being NULL the way to
"notify" that we should do a "system" lookup for channels. This make
it very confusing and prone to errors as commit dbbccf7c20bf
("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
proves. On top of this, patterns like 'if (channel != NULL) return channel'
were being used where channel could actually be an error code which
makes the code hard to read.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 87fd2a0d44f2..31d9c122199a 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -214,7 +214,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 					       const char *name)
 {
-	struct iio_channel *chan = NULL;
+	struct iio_channel *chan;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
 	while (np) {
@@ -231,11 +231,11 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 							 name);
 		chan = of_iio_channel_get(np, index);
 		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
-			break;
-		else if (name && index >= 0) {
+			return chan;
+		if (name && index >= 0) {
 			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
 				np, name ? name : "", index);
-			return NULL;
+			return chan;
 		}
 
 		/*
@@ -245,10 +245,10 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		 */
 		np = np->parent;
 		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
+			return chan;
 	}
 
-	return chan;
+	return ERR_PTR(-ENODEV);
 }
 EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
 
@@ -267,8 +267,8 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 			break;
 	} while (++nummaps);
 
-	if (nummaps == 0)	/* no error, return NULL to search map table */
-		return NULL;
+	if (nummaps == 0)	/* return -ENODEV to search map table */
+		return ERR_PTR(-ENODEV);
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
@@ -295,7 +295,7 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 
 static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_OF */
@@ -362,7 +362,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	if (dev) {
 		channel = of_iio_channel_get_by_name(dev->of_node,
 						     channel_name);
-		if (channel != NULL)
+		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
 			return channel;
 	}
 
@@ -412,8 +412,6 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 	channel = of_iio_channel_get_by_name(np, channel_name);
 	if (IS_ERR(channel))
 		return channel;
-	if (!channel)
-		return ERR_PTR(-ENODEV);
 
 	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
 	if (ret)
@@ -436,7 +434,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 		return ERR_PTR(-EINVAL);
 
 	chans = of_iio_channel_get_all(dev);
-	if (chans)
+	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
 		return chans;
 
 	name = dev_name(dev);
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
returning a mix of NULL and error pointers being NULL the way to
"notify" that we should do a "system" lookup for channels. This make
it very confusing and prone to errors as commit dbbccf7c20bf
("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
proves. On top of this, patterns like 'if (channel != NULL) return channel'
were being used where channel could actually be an error code which
makes the code hard to read.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 87fd2a0d44f2..31d9c122199a 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -214,7 +214,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 					       const char *name)
 {
-	struct iio_channel *chan = NULL;
+	struct iio_channel *chan;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
 	while (np) {
@@ -231,11 +231,11 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 							 name);
 		chan = of_iio_channel_get(np, index);
 		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
-			break;
-		else if (name && index >= 0) {
+			return chan;
+		if (name && index >= 0) {
 			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
 				np, name ? name : "", index);
-			return NULL;
+			return chan;
 		}
 
 		/*
@@ -245,10 +245,10 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 		 */
 		np = np->parent;
 		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return NULL;
+			return chan;
 	}
 
-	return chan;
+	return ERR_PTR(-ENODEV);
 }
 EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
 
@@ -267,8 +267,8 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 			break;
 	} while (++nummaps);
 
-	if (nummaps == 0)	/* no error, return NULL to search map table */
-		return NULL;
+	if (nummaps == 0)	/* return -ENODEV to search map table */
+		return ERR_PTR(-ENODEV);
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
@@ -295,7 +295,7 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 
 static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
 {
-	return NULL;
+	return ERR_PTR(-ENODEV);
 }
 
 #endif /* CONFIG_OF */
@@ -362,7 +362,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	if (dev) {
 		channel = of_iio_channel_get_by_name(dev->of_node,
 						     channel_name);
-		if (channel != NULL)
+		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
 			return channel;
 	}
 
@@ -412,8 +412,6 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 	channel = of_iio_channel_get_by_name(np, channel_name);
 	if (IS_ERR(channel))
 		return channel;
-	if (!channel)
-		return ERR_PTR(-ENODEV);
 
 	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
 	if (ret)
@@ -436,7 +434,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 		return ERR_PTR(-EINVAL);
 
 	chans = of_iio_channel_get_all(dev);
-	if (chans)
+	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
 		return chans;
 
 	name = dev_name(dev);
-- 
2.36.1


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

* [PATCH 23/34] iio: inkern: split of_iio_channel_get_by_name()
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

This change splits of_iio_channel_get_by_name() so that it decouples
looking for channels in the current node from looking in it's parents
nodes. This will be helpful when moving to fwnode properties where we
need to release the handles when looking for channels in parent's nodes.

No functional change intended...

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 69 ++++++++++++++++++++++++++++----------------
 1 file changed, 44 insertions(+), 25 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 31d9c122199a..dde47324b826 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -211,44 +211,63 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	return ERR_PTR(err);
 }
 
+struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
+						 const char *name,
+						 bool *parent_lookup)
+{
+	struct iio_channel *chan;
+	int index = 0;
+
+	/*
+	 * For named iio channels, first look up the name in the
+	 * "io-channel-names" property.  If it cannot be found, the
+	 * index will be an error code, and of_iio_channel_get()
+	 * will fail.
+	 */
+	if (name)
+		index = of_property_match_string(np, "io-channel-names", name);
+
+	chan = of_iio_channel_get(np, index);
+	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
+		*parent_lookup = false;
+	} else if (name && index >= 0) {
+		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
+		       np, name ? name : "", index);
+		*parent_lookup = false;
+	}
+
+	return chan;
+}
+
 struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 					       const char *name)
 {
 	struct iio_channel *chan;
+	bool parent_lookup = true;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
+	chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+	if (!parent_lookup)
+		return chan;
+
+	/*
+	 * No matching IIO channel found on this node.
+	 * If the parent node has a "io-channel-ranges" property,
+	 * then we can try one of its channels.
+	 */
+	np = np->parent;
 	while (np) {
-		int index = 0;
-
-		/*
-		 * For named iio channels, first look up the name in the
-		 * "io-channel-names" property.  If it cannot be found, the
-		 * index will be an error code, and of_iio_channel_get()
-		 * will fail.
-		 */
-		if (name)
-			index = of_property_match_string(np, "io-channel-names",
-							 name);
-		chan = of_iio_channel_get(np, index);
-		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
+		if (!of_get_property(np, "io-channel-ranges", NULL))
 			return chan;
-		if (name && index >= 0) {
-			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
-				np, name ? name : "", index);
+
+		chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+		if (!parent_lookup)
 			return chan;
-		}
 
-		/*
-		 * No matching IIO channel found on this node.
-		 * If the parent node has a "io-channel-ranges" property,
-		 * then we can try one of its channels.
-		 */
 		np = np->parent;
-		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return chan;
 	}
 
-	return ERR_PTR(-ENODEV);
+	return chan;
 }
 EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
 
-- 
2.36.1


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

* [PATCH 23/34] iio: inkern: split of_iio_channel_get_by_name()
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

This change splits of_iio_channel_get_by_name() so that it decouples
looking for channels in the current node from looking in it's parents
nodes. This will be helpful when moving to fwnode properties where we
need to release the handles when looking for channels in parent's nodes.

No functional change intended...

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 69 ++++++++++++++++++++++++++++----------------
 1 file changed, 44 insertions(+), 25 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 31d9c122199a..dde47324b826 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -211,44 +211,63 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	return ERR_PTR(err);
 }
 
+struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
+						 const char *name,
+						 bool *parent_lookup)
+{
+	struct iio_channel *chan;
+	int index = 0;
+
+	/*
+	 * For named iio channels, first look up the name in the
+	 * "io-channel-names" property.  If it cannot be found, the
+	 * index will be an error code, and of_iio_channel_get()
+	 * will fail.
+	 */
+	if (name)
+		index = of_property_match_string(np, "io-channel-names", name);
+
+	chan = of_iio_channel_get(np, index);
+	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
+		*parent_lookup = false;
+	} else if (name && index >= 0) {
+		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
+		       np, name ? name : "", index);
+		*parent_lookup = false;
+	}
+
+	return chan;
+}
+
 struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 					       const char *name)
 {
 	struct iio_channel *chan;
+	bool parent_lookup = true;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
+	chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+	if (!parent_lookup)
+		return chan;
+
+	/*
+	 * No matching IIO channel found on this node.
+	 * If the parent node has a "io-channel-ranges" property,
+	 * then we can try one of its channels.
+	 */
+	np = np->parent;
 	while (np) {
-		int index = 0;
-
-		/*
-		 * For named iio channels, first look up the name in the
-		 * "io-channel-names" property.  If it cannot be found, the
-		 * index will be an error code, and of_iio_channel_get()
-		 * will fail.
-		 */
-		if (name)
-			index = of_property_match_string(np, "io-channel-names",
-							 name);
-		chan = of_iio_channel_get(np, index);
-		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
+		if (!of_get_property(np, "io-channel-ranges", NULL))
 			return chan;
-		if (name && index >= 0) {
-			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
-				np, name ? name : "", index);
+
+		chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+		if (!parent_lookup)
 			return chan;
-		}
 
-		/*
-		 * No matching IIO channel found on this node.
-		 * If the parent node has a "io-channel-ranges" property,
-		 * then we can try one of its channels.
-		 */
 		np = np->parent;
-		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return chan;
 	}
 
-	return ERR_PTR(-ENODEV);
+	return chan;
 }
 EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
 
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 23/34] iio: inkern: split of_iio_channel_get_by_name()
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

This change splits of_iio_channel_get_by_name() so that it decouples
looking for channels in the current node from looking in it's parents
nodes. This will be helpful when moving to fwnode properties where we
need to release the handles when looking for channels in parent's nodes.

No functional change intended...

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 69 ++++++++++++++++++++++++++++----------------
 1 file changed, 44 insertions(+), 25 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 31d9c122199a..dde47324b826 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -211,44 +211,63 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	return ERR_PTR(err);
 }
 
+struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
+						 const char *name,
+						 bool *parent_lookup)
+{
+	struct iio_channel *chan;
+	int index = 0;
+
+	/*
+	 * For named iio channels, first look up the name in the
+	 * "io-channel-names" property.  If it cannot be found, the
+	 * index will be an error code, and of_iio_channel_get()
+	 * will fail.
+	 */
+	if (name)
+		index = of_property_match_string(np, "io-channel-names", name);
+
+	chan = of_iio_channel_get(np, index);
+	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
+		*parent_lookup = false;
+	} else if (name && index >= 0) {
+		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
+		       np, name ? name : "", index);
+		*parent_lookup = false;
+	}
+
+	return chan;
+}
+
 struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 					       const char *name)
 {
 	struct iio_channel *chan;
+	bool parent_lookup = true;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
+	chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+	if (!parent_lookup)
+		return chan;
+
+	/*
+	 * No matching IIO channel found on this node.
+	 * If the parent node has a "io-channel-ranges" property,
+	 * then we can try one of its channels.
+	 */
+	np = np->parent;
 	while (np) {
-		int index = 0;
-
-		/*
-		 * For named iio channels, first look up the name in the
-		 * "io-channel-names" property.  If it cannot be found, the
-		 * index will be an error code, and of_iio_channel_get()
-		 * will fail.
-		 */
-		if (name)
-			index = of_property_match_string(np, "io-channel-names",
-							 name);
-		chan = of_iio_channel_get(np, index);
-		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
+		if (!of_get_property(np, "io-channel-ranges", NULL))
 			return chan;
-		if (name && index >= 0) {
-			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
-				np, name ? name : "", index);
+
+		chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+		if (!parent_lookup)
 			return chan;
-		}
 
-		/*
-		 * No matching IIO channel found on this node.
-		 * If the parent node has a "io-channel-ranges" property,
-		 * then we can try one of its channels.
-		 */
 		np = np->parent;
-		if (np && !of_get_property(np, "io-channel-ranges", NULL))
-			return chan;
 	}
 
-	return ERR_PTR(-ENODEV);
+	return chan;
 }
 EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
 
-- 
2.36.1


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

* [PATCH 24/34] iio: inkern: move to fwnode properties
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

This moves the IIO in kernel interface to use fwnode properties and thus
be firmware agnostic.

Note that the interface is still not firmware agnostic. At this point we
have both OF and fwnode interfaces so that we don't break any user. On
top of this we also want to have a per driver conversion and that is the
main reason we have both of_xlate() and fwnode_xlate() support.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c         | 145 +++++++++++++++++++----------------
 include/linux/iio/consumer.h |  36 +++++----
 include/linux/iio/iio.h      |   5 ++
 3 files changed, 105 insertions(+), 81 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index dde47324b826..1d519b0cacea 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -5,6 +5,7 @@
  */
 #include <linux/err.h>
 #include <linux/export.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
@@ -117,15 +118,13 @@ static const struct iio_chan_spec
 	return chan;
 }
 
-#ifdef CONFIG_OF
-
 static int iio_dev_node_match(struct device *dev, const void *data)
 {
-	return dev->of_node == data && dev->type == &iio_device_type;
+	return device_match_fwnode(dev, data) && dev->type == &iio_device_type;
 }
 
 /**
- * __of_iio_simple_xlate - translate iiospec to the IIO channel index
+ * __fwnode_iio_simple_xlate - translate iiospec to the IIO channel index
  * @indio_dev:	pointer to the iio_dev structure
  * @iiospec:	IIO specifier as found in the device tree
  *
@@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device *dev, const void *data)
  * whether IIO index is less than num_channels (that is specified in the
  * iio_dev).
  */
-static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
+				     const struct fwnode_reference_args *iiospec)
 {
-	if (!iiospec->args_count)
+	if (!iiospec->nargs)
 		return 0;
 
 	if (iiospec->args[0] >= indio_dev->num_channels) {
-		dev_err(&indio_dev->dev, "invalid channel index %u\n",
+		dev_err(&indio_dev->dev, "invalid channel index %llu\n",
 			iiospec->args[0]);
 		return -EINVAL;
 	}
@@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
 	return iiospec->args[0];
 }
 
-static int __of_iio_channel_get(struct iio_channel *channel,
-				struct device_node *np, int index)
+/*
+ * Simple helper to copy fwnode_reference_args into of_phandle_args so we
+ * can pass it to of_xlate(). Ultimate goal is to drop this together with
+ * of_xlate().
+ */
+static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
+				const struct fwnode_reference_args *iiospec)
+{
+	struct of_phandle_args of_args;
+	unsigned int i;
+
+	of_args.args_count = iiospec->nargs;
+	of_args.np = to_of_node(iiospec->fwnode);
+
+	for (i = 0; i < MAX_PHANDLE_ARGS; i++)
+		of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
+
+	return indio_dev->info->of_xlate(indio_dev, &of_args);
+}
+
+static int __fwnode_iio_channel_get(struct iio_channel *channel,
+				    struct fwnode_handle *fwnode, int index)
 {
 	struct device *idev;
 	struct iio_dev *indio_dev;
 	int err;
-	struct of_phandle_args iiospec;
+	struct fwnode_reference_args iiospec;
 
-	err = of_parse_phandle_with_args(np, "io-channels",
-					 "#io-channel-cells",
-					 index, &iiospec);
+	err = fwnode_property_get_reference_args(fwnode, "io-channels",
+						 "#io-channel-cells", 0,
+						 index, &iiospec);
 	if (err)
 		return err;
 
-	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
+	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
 			       iio_dev_node_match);
 	if (idev == NULL) {
-		of_node_put(iiospec.np);
+		fwnode_handle_put(iiospec.fwnode);
 		return -EPROBE_DEFER;
 	}
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
 	if (indio_dev->info->of_xlate)
-		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
+		index = __fwnode_to_of_xlate(indio_dev, &iiospec);
+	else if (indio_dev->info->fwnode_xlate)
+		index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
 	else
-		index = __of_iio_simple_xlate(indio_dev, &iiospec);
-	of_node_put(iiospec.np);
+		index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
+	fwnode_handle_put(iiospec.fwnode);
 	if (index < 0)
 		goto err_put;
 	channel->channel = &indio_dev->channels[index];
@@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 	return index;
 }
 
-static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
+static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
+						  int index)
 {
 	struct iio_channel *channel;
 	int err;
@@ -200,7 +222,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	if (channel == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	err = __of_iio_channel_get(channel, np, index);
+	err = __fwnode_iio_channel_get(channel, fwnode, index);
 	if (err)
 		goto err_free_channel;
 
@@ -211,9 +233,9 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	return ERR_PTR(err);
 }
 
-struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
-						 const char *name,
-						 bool *parent_lookup)
+struct iio_channel *
+__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode, const char *name,
+				 bool *parent_lookup)
 {
 	struct iio_channel *chan;
 	int index = 0;
@@ -221,32 +243,34 @@ struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
 	/*
 	 * For named iio channels, first look up the name in the
 	 * "io-channel-names" property.  If it cannot be found, the
-	 * index will be an error code, and of_iio_channel_get()
+	 * index will be an error code, and fwnode_iio_channel_get()
 	 * will fail.
 	 */
 	if (name)
-		index = of_property_match_string(np, "io-channel-names", name);
+		index = fwnode_property_match_string(fwnode, "io-channel-names",
+						     name);
 
-	chan = of_iio_channel_get(np, index);
+	chan = fwnode_iio_channel_get(fwnode, index);
 	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
 		*parent_lookup = false;
 	} else if (name && index >= 0) {
-		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
-		       np, name ? name : "", index);
+		pr_err("ERROR: could not get IIO channel %pfw:%s(%i)\n",
+		       fwnode, name ? name : "", index);
 		*parent_lookup = false;
 	}
 
 	return chan;
 }
 
-struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
-					       const char *name)
+struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
+						   const char *name)
 {
 	struct iio_channel *chan;
+	struct fwnode_handle *parent;
 	bool parent_lookup = true;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
-	chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+	chan = __fwnode_iio_channel_get_by_name(fwnode, name, &parent_lookup);
 	if (!parent_lookup)
 		return chan;
 
@@ -255,33 +279,34 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 	 * If the parent node has a "io-channel-ranges" property,
 	 * then we can try one of its channels.
 	 */
-	np = np->parent;
-	while (np) {
-		if (!of_get_property(np, "io-channel-ranges", NULL))
+	fwnode_for_each_parent_node(fwnode, parent) {
+		if (!fwnode_property_present(parent, "io-channel-ranges")) {
+			fwnode_handle_put(parent);
 			return chan;
+		}
 
-		chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
-		if (!parent_lookup)
+		chan = __fwnode_iio_channel_get_by_name(parent, name, &parent_lookup);
+		if (!parent_lookup) {
+			fwnode_handle_put(parent);
 			return chan;
-
-		np = np->parent;
+		}
 	}
 
 	return chan;
 }
-EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
+EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);
 
-static struct iio_channel *of_iio_channel_get_all(struct device *dev)
+static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
 {
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	struct iio_channel *chans;
 	int i, mapind, nummaps = 0;
 	int ret;
 
 	do {
-		ret = of_parse_phandle_with_args(dev->of_node,
-						 "io-channels",
-						 "#io-channel-cells",
-						 nummaps, NULL);
+		ret = fwnode_property_get_reference_args(fwnode, "io-channels",
+							 "#io-channel-cells", 0,
+							 nummaps, NULL);
 		if (ret < 0)
 			break;
 	} while (++nummaps);
@@ -294,10 +319,9 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 	if (chans == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	/* Search for OF matches */
+	/* Search for FW matches */
 	for (mapind = 0; mapind < nummaps; mapind++) {
-		ret = __of_iio_channel_get(&chans[mapind], dev->of_node,
-					   mapind);
+		ret = __fwnode_iio_channel_get(&chans[mapind], fwnode, mapind);
 		if (ret)
 			goto error_free_chans;
 	}
@@ -310,15 +334,6 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 	return ERR_PTR(ret);
 }
 
-#else /* CONFIG_OF */
-
-static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
-{
-	return ERR_PTR(-ENODEV);
-}
-
-#endif /* CONFIG_OF */
-
 static struct iio_channel *iio_channel_get_sys(const char *name,
 					       const char *channel_name)
 {
@@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	struct iio_channel *channel;
 
 	if (dev) {
-		channel = of_iio_channel_get_by_name(dev->of_node,
-						     channel_name);
+		channel = fwnode_iio_channel_get_by_name(dev_fwnode(dev),
+							 channel_name);
 		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
 			return channel;
 	}
@@ -421,14 +436,14 @@ struct iio_channel *devm_iio_channel_get(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_iio_channel_get);
 
-struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
-						    struct device_node *np,
-						    const char *channel_name)
+struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
+							struct fwnode_handle *fwnode,
+							const char *channel_name)
 {
 	struct iio_channel *channel;
 	int ret;
 
-	channel = of_iio_channel_get_by_name(np, channel_name);
+	channel = fwnode_iio_channel_get_by_name(fwnode, channel_name);
 	if (IS_ERR(channel))
 		return channel;
 
@@ -438,7 +453,7 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 
 	return channel;
 }
-EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
+EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
 
 struct iio_channel *iio_channel_get_all(struct device *dev)
 {
@@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 	if (dev == NULL)
 		return ERR_PTR(-EINVAL);
 
-	chans = of_iio_channel_get_all(dev);
+	chans = fwnode_iio_channel_get_all(dev);
 	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
 		return chans;
 
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 5fa5957586cf..a96a714b5fdc 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -9,11 +9,13 @@
 
 #include <linux/types.h>
 #include <linux/iio/types.h>
+#include <linux/of.h>
 
 struct iio_dev;
 struct iio_chan_spec;
 struct device;
 struct device_node;
+struct fwnode_handle;
 
 /**
  * struct iio_channel - everything needed for a consumer to use a channel
@@ -99,26 +101,20 @@ void iio_channel_release_all(struct iio_channel *chan);
 struct iio_channel *devm_iio_channel_get_all(struct device *dev);
 
 /**
- * of_iio_channel_get_by_name() - get description of all that is needed to access channel.
- * @np:			Pointer to consumer device tree node
+ * fwnode_iio_channel_get_by_name() - get description of all that is needed to access channel.
+ * @fwnode:		Pointer to consumer Firmware node
  * @consumer_channel:	Unique name to identify the channel on the consumer
  *			side. This typically describes the channels use within
  *			the consumer. E.g. 'battery_voltage'
  */
-#ifdef CONFIG_OF
-struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, const char *name);
-#else
-static inline struct iio_channel *
-of_iio_channel_get_by_name(struct device_node *np, const char *name)
-{
-	return NULL;
-}
-#endif
+struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
+						   const char *name);
 
 /**
- * devm_of_iio_channel_get_by_name() - Resource managed version of of_iio_channel_get_by_name().
+ * devm_fwnode_iio_channel_get_by_name() - Resource managed version of
+ *					   fwnode_iio_channel_get_by_name().
  * @dev:		Pointer to consumer device.
- * @np:			Pointer to consumer device tree node
+ * @fwnode:		Pointer to consumer Firmware node
  * @consumer_channel:	Unique name to identify the channel on the consumer
  *			side. This typically describes the channels use within
  *			the consumer. E.g. 'battery_voltage'
@@ -129,9 +125,17 @@ of_iio_channel_get_by_name(struct device_node *np, const char *name)
  * The allocated iio channel is automatically released when the device is
  * unbound.
  */
-struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
-						    struct device_node *np,
-						    const char *consumer_channel);
+struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
+							struct fwnode_handle *fwnode,
+							const char *consumer_channel);
+
+static inline struct iio_channel
+*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
+				 const char *consumer_channel)
+{
+	return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
+						   consumer_channel);
+}
 
 struct iio_cb_buffer;
 /**
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index d9b4a9ca9a0f..494abb63406e 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -18,6 +18,7 @@
  */
 
 struct of_phandle_args;
+struct fwnode_reference_args;
 
 enum iio_shared_by {
 	IIO_SEPARATE,
@@ -429,6 +430,8 @@ struct iio_trigger; /* forward declaration */
  *			provide a custom of_xlate function that reads the
  *			*args* and returns the appropriate index in registered
  *			IIO channels array.
+ * @fwnode_xlate:	fwnode based function pointer to obtain channel specifier index.
+ *			Functionally the same as @of_xlate.
  * @hwfifo_set_watermark: function pointer to set the current hardware
  *			fifo watermark level; see hwfifo_* entries in
  *			Documentation/ABI/testing/sysfs-bus-iio for details on
@@ -510,6 +513,8 @@ struct iio_info {
 				  unsigned *readval);
 	int (*of_xlate)(struct iio_dev *indio_dev,
 			const struct of_phandle_args *iiospec);
+	int (*fwnode_xlate)(struct iio_dev *indio_dev,
+			    const struct fwnode_reference_args *iiospec);
 	int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
 	int (*hwfifo_flush_to_buffer)(struct iio_dev *indio_dev,
 				      unsigned count);
-- 
2.36.1


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

* [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

This moves the IIO in kernel interface to use fwnode properties and thus
be firmware agnostic.

Note that the interface is still not firmware agnostic. At this point we
have both OF and fwnode interfaces so that we don't break any user. On
top of this we also want to have a per driver conversion and that is the
main reason we have both of_xlate() and fwnode_xlate() support.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c         | 145 +++++++++++++++++++----------------
 include/linux/iio/consumer.h |  36 +++++----
 include/linux/iio/iio.h      |   5 ++
 3 files changed, 105 insertions(+), 81 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index dde47324b826..1d519b0cacea 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -5,6 +5,7 @@
  */
 #include <linux/err.h>
 #include <linux/export.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
@@ -117,15 +118,13 @@ static const struct iio_chan_spec
 	return chan;
 }
 
-#ifdef CONFIG_OF
-
 static int iio_dev_node_match(struct device *dev, const void *data)
 {
-	return dev->of_node == data && dev->type == &iio_device_type;
+	return device_match_fwnode(dev, data) && dev->type == &iio_device_type;
 }
 
 /**
- * __of_iio_simple_xlate - translate iiospec to the IIO channel index
+ * __fwnode_iio_simple_xlate - translate iiospec to the IIO channel index
  * @indio_dev:	pointer to the iio_dev structure
  * @iiospec:	IIO specifier as found in the device tree
  *
@@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device *dev, const void *data)
  * whether IIO index is less than num_channels (that is specified in the
  * iio_dev).
  */
-static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
+				     const struct fwnode_reference_args *iiospec)
 {
-	if (!iiospec->args_count)
+	if (!iiospec->nargs)
 		return 0;
 
 	if (iiospec->args[0] >= indio_dev->num_channels) {
-		dev_err(&indio_dev->dev, "invalid channel index %u\n",
+		dev_err(&indio_dev->dev, "invalid channel index %llu\n",
 			iiospec->args[0]);
 		return -EINVAL;
 	}
@@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
 	return iiospec->args[0];
 }
 
-static int __of_iio_channel_get(struct iio_channel *channel,
-				struct device_node *np, int index)
+/*
+ * Simple helper to copy fwnode_reference_args into of_phandle_args so we
+ * can pass it to of_xlate(). Ultimate goal is to drop this together with
+ * of_xlate().
+ */
+static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
+				const struct fwnode_reference_args *iiospec)
+{
+	struct of_phandle_args of_args;
+	unsigned int i;
+
+	of_args.args_count = iiospec->nargs;
+	of_args.np = to_of_node(iiospec->fwnode);
+
+	for (i = 0; i < MAX_PHANDLE_ARGS; i++)
+		of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
+
+	return indio_dev->info->of_xlate(indio_dev, &of_args);
+}
+
+static int __fwnode_iio_channel_get(struct iio_channel *channel,
+				    struct fwnode_handle *fwnode, int index)
 {
 	struct device *idev;
 	struct iio_dev *indio_dev;
 	int err;
-	struct of_phandle_args iiospec;
+	struct fwnode_reference_args iiospec;
 
-	err = of_parse_phandle_with_args(np, "io-channels",
-					 "#io-channel-cells",
-					 index, &iiospec);
+	err = fwnode_property_get_reference_args(fwnode, "io-channels",
+						 "#io-channel-cells", 0,
+						 index, &iiospec);
 	if (err)
 		return err;
 
-	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
+	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
 			       iio_dev_node_match);
 	if (idev == NULL) {
-		of_node_put(iiospec.np);
+		fwnode_handle_put(iiospec.fwnode);
 		return -EPROBE_DEFER;
 	}
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
 	if (indio_dev->info->of_xlate)
-		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
+		index = __fwnode_to_of_xlate(indio_dev, &iiospec);
+	else if (indio_dev->info->fwnode_xlate)
+		index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
 	else
-		index = __of_iio_simple_xlate(indio_dev, &iiospec);
-	of_node_put(iiospec.np);
+		index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
+	fwnode_handle_put(iiospec.fwnode);
 	if (index < 0)
 		goto err_put;
 	channel->channel = &indio_dev->channels[index];
@@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 	return index;
 }
 
-static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
+static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
+						  int index)
 {
 	struct iio_channel *channel;
 	int err;
@@ -200,7 +222,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	if (channel == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	err = __of_iio_channel_get(channel, np, index);
+	err = __fwnode_iio_channel_get(channel, fwnode, index);
 	if (err)
 		goto err_free_channel;
 
@@ -211,9 +233,9 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	return ERR_PTR(err);
 }
 
-struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
-						 const char *name,
-						 bool *parent_lookup)
+struct iio_channel *
+__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode, const char *name,
+				 bool *parent_lookup)
 {
 	struct iio_channel *chan;
 	int index = 0;
@@ -221,32 +243,34 @@ struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
 	/*
 	 * For named iio channels, first look up the name in the
 	 * "io-channel-names" property.  If it cannot be found, the
-	 * index will be an error code, and of_iio_channel_get()
+	 * index will be an error code, and fwnode_iio_channel_get()
 	 * will fail.
 	 */
 	if (name)
-		index = of_property_match_string(np, "io-channel-names", name);
+		index = fwnode_property_match_string(fwnode, "io-channel-names",
+						     name);
 
-	chan = of_iio_channel_get(np, index);
+	chan = fwnode_iio_channel_get(fwnode, index);
 	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
 		*parent_lookup = false;
 	} else if (name && index >= 0) {
-		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
-		       np, name ? name : "", index);
+		pr_err("ERROR: could not get IIO channel %pfw:%s(%i)\n",
+		       fwnode, name ? name : "", index);
 		*parent_lookup = false;
 	}
 
 	return chan;
 }
 
-struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
-					       const char *name)
+struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
+						   const char *name)
 {
 	struct iio_channel *chan;
+	struct fwnode_handle *parent;
 	bool parent_lookup = true;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
-	chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+	chan = __fwnode_iio_channel_get_by_name(fwnode, name, &parent_lookup);
 	if (!parent_lookup)
 		return chan;
 
@@ -255,33 +279,34 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 	 * If the parent node has a "io-channel-ranges" property,
 	 * then we can try one of its channels.
 	 */
-	np = np->parent;
-	while (np) {
-		if (!of_get_property(np, "io-channel-ranges", NULL))
+	fwnode_for_each_parent_node(fwnode, parent) {
+		if (!fwnode_property_present(parent, "io-channel-ranges")) {
+			fwnode_handle_put(parent);
 			return chan;
+		}
 
-		chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
-		if (!parent_lookup)
+		chan = __fwnode_iio_channel_get_by_name(parent, name, &parent_lookup);
+		if (!parent_lookup) {
+			fwnode_handle_put(parent);
 			return chan;
-
-		np = np->parent;
+		}
 	}
 
 	return chan;
 }
-EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
+EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);
 
-static struct iio_channel *of_iio_channel_get_all(struct device *dev)
+static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
 {
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	struct iio_channel *chans;
 	int i, mapind, nummaps = 0;
 	int ret;
 
 	do {
-		ret = of_parse_phandle_with_args(dev->of_node,
-						 "io-channels",
-						 "#io-channel-cells",
-						 nummaps, NULL);
+		ret = fwnode_property_get_reference_args(fwnode, "io-channels",
+							 "#io-channel-cells", 0,
+							 nummaps, NULL);
 		if (ret < 0)
 			break;
 	} while (++nummaps);
@@ -294,10 +319,9 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 	if (chans == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	/* Search for OF matches */
+	/* Search for FW matches */
 	for (mapind = 0; mapind < nummaps; mapind++) {
-		ret = __of_iio_channel_get(&chans[mapind], dev->of_node,
-					   mapind);
+		ret = __fwnode_iio_channel_get(&chans[mapind], fwnode, mapind);
 		if (ret)
 			goto error_free_chans;
 	}
@@ -310,15 +334,6 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 	return ERR_PTR(ret);
 }
 
-#else /* CONFIG_OF */
-
-static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
-{
-	return ERR_PTR(-ENODEV);
-}
-
-#endif /* CONFIG_OF */
-
 static struct iio_channel *iio_channel_get_sys(const char *name,
 					       const char *channel_name)
 {
@@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	struct iio_channel *channel;
 
 	if (dev) {
-		channel = of_iio_channel_get_by_name(dev->of_node,
-						     channel_name);
+		channel = fwnode_iio_channel_get_by_name(dev_fwnode(dev),
+							 channel_name);
 		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
 			return channel;
 	}
@@ -421,14 +436,14 @@ struct iio_channel *devm_iio_channel_get(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_iio_channel_get);
 
-struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
-						    struct device_node *np,
-						    const char *channel_name)
+struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
+							struct fwnode_handle *fwnode,
+							const char *channel_name)
 {
 	struct iio_channel *channel;
 	int ret;
 
-	channel = of_iio_channel_get_by_name(np, channel_name);
+	channel = fwnode_iio_channel_get_by_name(fwnode, channel_name);
 	if (IS_ERR(channel))
 		return channel;
 
@@ -438,7 +453,7 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 
 	return channel;
 }
-EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
+EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
 
 struct iio_channel *iio_channel_get_all(struct device *dev)
 {
@@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 	if (dev == NULL)
 		return ERR_PTR(-EINVAL);
 
-	chans = of_iio_channel_get_all(dev);
+	chans = fwnode_iio_channel_get_all(dev);
 	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
 		return chans;
 
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 5fa5957586cf..a96a714b5fdc 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -9,11 +9,13 @@
 
 #include <linux/types.h>
 #include <linux/iio/types.h>
+#include <linux/of.h>
 
 struct iio_dev;
 struct iio_chan_spec;
 struct device;
 struct device_node;
+struct fwnode_handle;
 
 /**
  * struct iio_channel - everything needed for a consumer to use a channel
@@ -99,26 +101,20 @@ void iio_channel_release_all(struct iio_channel *chan);
 struct iio_channel *devm_iio_channel_get_all(struct device *dev);
 
 /**
- * of_iio_channel_get_by_name() - get description of all that is needed to access channel.
- * @np:			Pointer to consumer device tree node
+ * fwnode_iio_channel_get_by_name() - get description of all that is needed to access channel.
+ * @fwnode:		Pointer to consumer Firmware node
  * @consumer_channel:	Unique name to identify the channel on the consumer
  *			side. This typically describes the channels use within
  *			the consumer. E.g. 'battery_voltage'
  */
-#ifdef CONFIG_OF
-struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, const char *name);
-#else
-static inline struct iio_channel *
-of_iio_channel_get_by_name(struct device_node *np, const char *name)
-{
-	return NULL;
-}
-#endif
+struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
+						   const char *name);
 
 /**
- * devm_of_iio_channel_get_by_name() - Resource managed version of of_iio_channel_get_by_name().
+ * devm_fwnode_iio_channel_get_by_name() - Resource managed version of
+ *					   fwnode_iio_channel_get_by_name().
  * @dev:		Pointer to consumer device.
- * @np:			Pointer to consumer device tree node
+ * @fwnode:		Pointer to consumer Firmware node
  * @consumer_channel:	Unique name to identify the channel on the consumer
  *			side. This typically describes the channels use within
  *			the consumer. E.g. 'battery_voltage'
@@ -129,9 +125,17 @@ of_iio_channel_get_by_name(struct device_node *np, const char *name)
  * The allocated iio channel is automatically released when the device is
  * unbound.
  */
-struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
-						    struct device_node *np,
-						    const char *consumer_channel);
+struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
+							struct fwnode_handle *fwnode,
+							const char *consumer_channel);
+
+static inline struct iio_channel
+*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
+				 const char *consumer_channel)
+{
+	return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
+						   consumer_channel);
+}
 
 struct iio_cb_buffer;
 /**
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index d9b4a9ca9a0f..494abb63406e 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -18,6 +18,7 @@
  */
 
 struct of_phandle_args;
+struct fwnode_reference_args;
 
 enum iio_shared_by {
 	IIO_SEPARATE,
@@ -429,6 +430,8 @@ struct iio_trigger; /* forward declaration */
  *			provide a custom of_xlate function that reads the
  *			*args* and returns the appropriate index in registered
  *			IIO channels array.
+ * @fwnode_xlate:	fwnode based function pointer to obtain channel specifier index.
+ *			Functionally the same as @of_xlate.
  * @hwfifo_set_watermark: function pointer to set the current hardware
  *			fifo watermark level; see hwfifo_* entries in
  *			Documentation/ABI/testing/sysfs-bus-iio for details on
@@ -510,6 +513,8 @@ struct iio_info {
 				  unsigned *readval);
 	int (*of_xlate)(struct iio_dev *indio_dev,
 			const struct of_phandle_args *iiospec);
+	int (*fwnode_xlate)(struct iio_dev *indio_dev,
+			    const struct fwnode_reference_args *iiospec);
 	int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
 	int (*hwfifo_flush_to_buffer)(struct iio_dev *indio_dev,
 				      unsigned count);
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

This moves the IIO in kernel interface to use fwnode properties and thus
be firmware agnostic.

Note that the interface is still not firmware agnostic. At this point we
have both OF and fwnode interfaces so that we don't break any user. On
top of this we also want to have a per driver conversion and that is the
main reason we have both of_xlate() and fwnode_xlate() support.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c         | 145 +++++++++++++++++++----------------
 include/linux/iio/consumer.h |  36 +++++----
 include/linux/iio/iio.h      |   5 ++
 3 files changed, 105 insertions(+), 81 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index dde47324b826..1d519b0cacea 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -5,6 +5,7 @@
  */
 #include <linux/err.h>
 #include <linux/export.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
@@ -117,15 +118,13 @@ static const struct iio_chan_spec
 	return chan;
 }
 
-#ifdef CONFIG_OF
-
 static int iio_dev_node_match(struct device *dev, const void *data)
 {
-	return dev->of_node == data && dev->type == &iio_device_type;
+	return device_match_fwnode(dev, data) && dev->type == &iio_device_type;
 }
 
 /**
- * __of_iio_simple_xlate - translate iiospec to the IIO channel index
+ * __fwnode_iio_simple_xlate - translate iiospec to the IIO channel index
  * @indio_dev:	pointer to the iio_dev structure
  * @iiospec:	IIO specifier as found in the device tree
  *
@@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device *dev, const void *data)
  * whether IIO index is less than num_channels (that is specified in the
  * iio_dev).
  */
-static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
+				     const struct fwnode_reference_args *iiospec)
 {
-	if (!iiospec->args_count)
+	if (!iiospec->nargs)
 		return 0;
 
 	if (iiospec->args[0] >= indio_dev->num_channels) {
-		dev_err(&indio_dev->dev, "invalid channel index %u\n",
+		dev_err(&indio_dev->dev, "invalid channel index %llu\n",
 			iiospec->args[0]);
 		return -EINVAL;
 	}
@@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
 	return iiospec->args[0];
 }
 
-static int __of_iio_channel_get(struct iio_channel *channel,
-				struct device_node *np, int index)
+/*
+ * Simple helper to copy fwnode_reference_args into of_phandle_args so we
+ * can pass it to of_xlate(). Ultimate goal is to drop this together with
+ * of_xlate().
+ */
+static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
+				const struct fwnode_reference_args *iiospec)
+{
+	struct of_phandle_args of_args;
+	unsigned int i;
+
+	of_args.args_count = iiospec->nargs;
+	of_args.np = to_of_node(iiospec->fwnode);
+
+	for (i = 0; i < MAX_PHANDLE_ARGS; i++)
+		of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
+
+	return indio_dev->info->of_xlate(indio_dev, &of_args);
+}
+
+static int __fwnode_iio_channel_get(struct iio_channel *channel,
+				    struct fwnode_handle *fwnode, int index)
 {
 	struct device *idev;
 	struct iio_dev *indio_dev;
 	int err;
-	struct of_phandle_args iiospec;
+	struct fwnode_reference_args iiospec;
 
-	err = of_parse_phandle_with_args(np, "io-channels",
-					 "#io-channel-cells",
-					 index, &iiospec);
+	err = fwnode_property_get_reference_args(fwnode, "io-channels",
+						 "#io-channel-cells", 0,
+						 index, &iiospec);
 	if (err)
 		return err;
 
-	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
+	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
 			       iio_dev_node_match);
 	if (idev == NULL) {
-		of_node_put(iiospec.np);
+		fwnode_handle_put(iiospec.fwnode);
 		return -EPROBE_DEFER;
 	}
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
 	if (indio_dev->info->of_xlate)
-		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
+		index = __fwnode_to_of_xlate(indio_dev, &iiospec);
+	else if (indio_dev->info->fwnode_xlate)
+		index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
 	else
-		index = __of_iio_simple_xlate(indio_dev, &iiospec);
-	of_node_put(iiospec.np);
+		index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
+	fwnode_handle_put(iiospec.fwnode);
 	if (index < 0)
 		goto err_put;
 	channel->channel = &indio_dev->channels[index];
@@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct iio_channel *channel,
 	return index;
 }
 
-static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
+static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
+						  int index)
 {
 	struct iio_channel *channel;
 	int err;
@@ -200,7 +222,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	if (channel == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	err = __of_iio_channel_get(channel, np, index);
+	err = __fwnode_iio_channel_get(channel, fwnode, index);
 	if (err)
 		goto err_free_channel;
 
@@ -211,9 +233,9 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
 	return ERR_PTR(err);
 }
 
-struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
-						 const char *name,
-						 bool *parent_lookup)
+struct iio_channel *
+__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode, const char *name,
+				 bool *parent_lookup)
 {
 	struct iio_channel *chan;
 	int index = 0;
@@ -221,32 +243,34 @@ struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
 	/*
 	 * For named iio channels, first look up the name in the
 	 * "io-channel-names" property.  If it cannot be found, the
-	 * index will be an error code, and of_iio_channel_get()
+	 * index will be an error code, and fwnode_iio_channel_get()
 	 * will fail.
 	 */
 	if (name)
-		index = of_property_match_string(np, "io-channel-names", name);
+		index = fwnode_property_match_string(fwnode, "io-channel-names",
+						     name);
 
-	chan = of_iio_channel_get(np, index);
+	chan = fwnode_iio_channel_get(fwnode, index);
 	if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
 		*parent_lookup = false;
 	} else if (name && index >= 0) {
-		pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
-		       np, name ? name : "", index);
+		pr_err("ERROR: could not get IIO channel %pfw:%s(%i)\n",
+		       fwnode, name ? name : "", index);
 		*parent_lookup = false;
 	}
 
 	return chan;
 }
 
-struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
-					       const char *name)
+struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
+						   const char *name)
 {
 	struct iio_channel *chan;
+	struct fwnode_handle *parent;
 	bool parent_lookup = true;
 
 	/* Walk up the tree of devices looking for a matching iio channel */
-	chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
+	chan = __fwnode_iio_channel_get_by_name(fwnode, name, &parent_lookup);
 	if (!parent_lookup)
 		return chan;
 
@@ -255,33 +279,34 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
 	 * If the parent node has a "io-channel-ranges" property,
 	 * then we can try one of its channels.
 	 */
-	np = np->parent;
-	while (np) {
-		if (!of_get_property(np, "io-channel-ranges", NULL))
+	fwnode_for_each_parent_node(fwnode, parent) {
+		if (!fwnode_property_present(parent, "io-channel-ranges")) {
+			fwnode_handle_put(parent);
 			return chan;
+		}
 
-		chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
-		if (!parent_lookup)
+		chan = __fwnode_iio_channel_get_by_name(parent, name, &parent_lookup);
+		if (!parent_lookup) {
+			fwnode_handle_put(parent);
 			return chan;
-
-		np = np->parent;
+		}
 	}
 
 	return chan;
 }
-EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
+EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);
 
-static struct iio_channel *of_iio_channel_get_all(struct device *dev)
+static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
 {
+	struct fwnode_handle *fwnode = dev_fwnode(dev);
 	struct iio_channel *chans;
 	int i, mapind, nummaps = 0;
 	int ret;
 
 	do {
-		ret = of_parse_phandle_with_args(dev->of_node,
-						 "io-channels",
-						 "#io-channel-cells",
-						 nummaps, NULL);
+		ret = fwnode_property_get_reference_args(fwnode, "io-channels",
+							 "#io-channel-cells", 0,
+							 nummaps, NULL);
 		if (ret < 0)
 			break;
 	} while (++nummaps);
@@ -294,10 +319,9 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 	if (chans == NULL)
 		return ERR_PTR(-ENOMEM);
 
-	/* Search for OF matches */
+	/* Search for FW matches */
 	for (mapind = 0; mapind < nummaps; mapind++) {
-		ret = __of_iio_channel_get(&chans[mapind], dev->of_node,
-					   mapind);
+		ret = __fwnode_iio_channel_get(&chans[mapind], fwnode, mapind);
 		if (ret)
 			goto error_free_chans;
 	}
@@ -310,15 +334,6 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
 	return ERR_PTR(ret);
 }
 
-#else /* CONFIG_OF */
-
-static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
-{
-	return ERR_PTR(-ENODEV);
-}
-
-#endif /* CONFIG_OF */
-
 static struct iio_channel *iio_channel_get_sys(const char *name,
 					       const char *channel_name)
 {
@@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct device *dev,
 	struct iio_channel *channel;
 
 	if (dev) {
-		channel = of_iio_channel_get_by_name(dev->of_node,
-						     channel_name);
+		channel = fwnode_iio_channel_get_by_name(dev_fwnode(dev),
+							 channel_name);
 		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
 			return channel;
 	}
@@ -421,14 +436,14 @@ struct iio_channel *devm_iio_channel_get(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(devm_iio_channel_get);
 
-struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
-						    struct device_node *np,
-						    const char *channel_name)
+struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
+							struct fwnode_handle *fwnode,
+							const char *channel_name)
 {
 	struct iio_channel *channel;
 	int ret;
 
-	channel = of_iio_channel_get_by_name(np, channel_name);
+	channel = fwnode_iio_channel_get_by_name(fwnode, channel_name);
 	if (IS_ERR(channel))
 		return channel;
 
@@ -438,7 +453,7 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
 
 	return channel;
 }
-EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
+EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
 
 struct iio_channel *iio_channel_get_all(struct device *dev)
 {
@@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 	if (dev == NULL)
 		return ERR_PTR(-EINVAL);
 
-	chans = of_iio_channel_get_all(dev);
+	chans = fwnode_iio_channel_get_all(dev);
 	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
 		return chans;
 
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index 5fa5957586cf..a96a714b5fdc 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -9,11 +9,13 @@
 
 #include <linux/types.h>
 #include <linux/iio/types.h>
+#include <linux/of.h>
 
 struct iio_dev;
 struct iio_chan_spec;
 struct device;
 struct device_node;
+struct fwnode_handle;
 
 /**
  * struct iio_channel - everything needed for a consumer to use a channel
@@ -99,26 +101,20 @@ void iio_channel_release_all(struct iio_channel *chan);
 struct iio_channel *devm_iio_channel_get_all(struct device *dev);
 
 /**
- * of_iio_channel_get_by_name() - get description of all that is needed to access channel.
- * @np:			Pointer to consumer device tree node
+ * fwnode_iio_channel_get_by_name() - get description of all that is needed to access channel.
+ * @fwnode:		Pointer to consumer Firmware node
  * @consumer_channel:	Unique name to identify the channel on the consumer
  *			side. This typically describes the channels use within
  *			the consumer. E.g. 'battery_voltage'
  */
-#ifdef CONFIG_OF
-struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, const char *name);
-#else
-static inline struct iio_channel *
-of_iio_channel_get_by_name(struct device_node *np, const char *name)
-{
-	return NULL;
-}
-#endif
+struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
+						   const char *name);
 
 /**
- * devm_of_iio_channel_get_by_name() - Resource managed version of of_iio_channel_get_by_name().
+ * devm_fwnode_iio_channel_get_by_name() - Resource managed version of
+ *					   fwnode_iio_channel_get_by_name().
  * @dev:		Pointer to consumer device.
- * @np:			Pointer to consumer device tree node
+ * @fwnode:		Pointer to consumer Firmware node
  * @consumer_channel:	Unique name to identify the channel on the consumer
  *			side. This typically describes the channels use within
  *			the consumer. E.g. 'battery_voltage'
@@ -129,9 +125,17 @@ of_iio_channel_get_by_name(struct device_node *np, const char *name)
  * The allocated iio channel is automatically released when the device is
  * unbound.
  */
-struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
-						    struct device_node *np,
-						    const char *consumer_channel);
+struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
+							struct fwnode_handle *fwnode,
+							const char *consumer_channel);
+
+static inline struct iio_channel
+*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
+				 const char *consumer_channel)
+{
+	return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
+						   consumer_channel);
+}
 
 struct iio_cb_buffer;
 /**
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index d9b4a9ca9a0f..494abb63406e 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -18,6 +18,7 @@
  */
 
 struct of_phandle_args;
+struct fwnode_reference_args;
 
 enum iio_shared_by {
 	IIO_SEPARATE,
@@ -429,6 +430,8 @@ struct iio_trigger; /* forward declaration */
  *			provide a custom of_xlate function that reads the
  *			*args* and returns the appropriate index in registered
  *			IIO channels array.
+ * @fwnode_xlate:	fwnode based function pointer to obtain channel specifier index.
+ *			Functionally the same as @of_xlate.
  * @hwfifo_set_watermark: function pointer to set the current hardware
  *			fifo watermark level; see hwfifo_* entries in
  *			Documentation/ABI/testing/sysfs-bus-iio for details on
@@ -510,6 +513,8 @@ struct iio_info {
 				  unsigned *readval);
 	int (*of_xlate)(struct iio_dev *indio_dev,
 			const struct of_phandle_args *iiospec);
+	int (*fwnode_xlate)(struct iio_dev *indio_dev,
+			    const struct fwnode_reference_args *iiospec);
 	int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
 	int (*hwfifo_flush_to_buffer)(struct iio_dev *indio_dev,
 				      unsigned count);
-- 
2.36.1


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

* [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make usage of the new firmware agnostic API
'devm_of_iio_channel_get_by_name()' to get the IIO channel.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
index d9c9c975f931..0b8543c627f0 100644
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
@@ -825,7 +825,8 @@ static int adc_tm5_get_dt_channel_data(struct adc_tm5_chip *adc_tm,
 	}
 	channel->adc_channel = args.args[0];
 
-	channel->iio = devm_of_iio_channel_get_by_name(adc_tm->dev, node, NULL);
+	channel->iio = devm_fwnode_iio_channel_get_by_name(adc_tm->dev,
+							   of_fwnode_handle(node), NULL);
 	if (IS_ERR(channel->iio)) {
 		ret = PTR_ERR(channel->iio);
 		if (ret != -EPROBE_DEFER)
-- 
2.36.1


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

* [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make usage of the new firmware agnostic API
'devm_of_iio_channel_get_by_name()' to get the IIO channel.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
index d9c9c975f931..0b8543c627f0 100644
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
@@ -825,7 +825,8 @@ static int adc_tm5_get_dt_channel_data(struct adc_tm5_chip *adc_tm,
 	}
 	channel->adc_channel = args.args[0];
 
-	channel->iio = devm_of_iio_channel_get_by_name(adc_tm->dev, node, NULL);
+	channel->iio = devm_fwnode_iio_channel_get_by_name(adc_tm->dev,
+							   of_fwnode_handle(node), NULL);
 	if (IS_ERR(channel->iio)) {
 		ret = PTR_ERR(channel->iio);
 		if (ret != -EPROBE_DEFER)
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Make usage of the new firmware agnostic API
'devm_of_iio_channel_get_by_name()' to get the IIO channel.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/thermal/qcom/qcom-spmi-adc-tm5.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
index d9c9c975f931..0b8543c627f0 100644
--- a/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
+++ b/drivers/thermal/qcom/qcom-spmi-adc-tm5.c
@@ -825,7 +825,8 @@ static int adc_tm5_get_dt_channel_data(struct adc_tm5_chip *adc_tm,
 	}
 	channel->adc_channel = args.args[0];
 
-	channel->iio = devm_of_iio_channel_get_by_name(adc_tm->dev, node, NULL);
+	channel->iio = devm_fwnode_iio_channel_get_by_name(adc_tm->dev,
+							   of_fwnode_handle(node), NULL);
 	if (IS_ERR(channel->iio)) {
 		ret = PTR_ERR(channel->iio);
 		if (ret != -EPROBE_DEFER)
-- 
2.36.1


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

* [PATCH 26/34] iio: adc: ingenic-adc: convert to IIO fwnode interface
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Move from 'of_xlate()' to 'fwnode_xlate()'. The end goal is to completely
drop OF from the IIO inkernel interface.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ingenic-adc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index e731ba47add2..dcc6bc29dca0 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -19,7 +19,6 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-#include <linux/of.h>
 
 #define JZ_ADC_REG_ENABLE		0x00
 #define JZ_ADC_REG_CFG			0x04
@@ -719,12 +718,12 @@ static int ingenic_adc_read_raw(struct iio_dev *iio_dev,
 	}
 }
 
-static int ingenic_adc_of_xlate(struct iio_dev *iio_dev,
-				const struct of_phandle_args *iiospec)
+static int ingenic_adc_fwnode_xlate(struct iio_dev *iio_dev,
+				    const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
-	if (!iiospec->args_count)
+	if (!iiospec->nargs)
 		return -EINVAL;
 
 	for (i = 0; i < iio_dev->num_channels; ++i)
@@ -743,7 +742,7 @@ static const struct iio_info ingenic_adc_info = {
 	.write_raw = ingenic_adc_write_raw,
 	.read_raw = ingenic_adc_read_raw,
 	.read_avail = ingenic_adc_read_avail,
-	.of_xlate = ingenic_adc_of_xlate,
+	.fwnode_xlate = ingenic_adc_fwnode_xlate,
 };
 
 static int ingenic_adc_buffer_enable(struct iio_dev *iio_dev)
-- 
2.36.1


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

* [PATCH 26/34] iio: adc: ingenic-adc: convert to IIO fwnode interface
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Move from 'of_xlate()' to 'fwnode_xlate()'. The end goal is to completely
drop OF from the IIO inkernel interface.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ingenic-adc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index e731ba47add2..dcc6bc29dca0 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -19,7 +19,6 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-#include <linux/of.h>
 
 #define JZ_ADC_REG_ENABLE		0x00
 #define JZ_ADC_REG_CFG			0x04
@@ -719,12 +718,12 @@ static int ingenic_adc_read_raw(struct iio_dev *iio_dev,
 	}
 }
 
-static int ingenic_adc_of_xlate(struct iio_dev *iio_dev,
-				const struct of_phandle_args *iiospec)
+static int ingenic_adc_fwnode_xlate(struct iio_dev *iio_dev,
+				    const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
-	if (!iiospec->args_count)
+	if (!iiospec->nargs)
 		return -EINVAL;
 
 	for (i = 0; i < iio_dev->num_channels; ++i)
@@ -743,7 +742,7 @@ static const struct iio_info ingenic_adc_info = {
 	.write_raw = ingenic_adc_write_raw,
 	.read_raw = ingenic_adc_read_raw,
 	.read_avail = ingenic_adc_read_avail,
-	.of_xlate = ingenic_adc_of_xlate,
+	.fwnode_xlate = ingenic_adc_fwnode_xlate,
 };
 
 static int ingenic_adc_buffer_enable(struct iio_dev *iio_dev)
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 26/34] iio: adc: ingenic-adc: convert to IIO fwnode interface
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Move from 'of_xlate()' to 'fwnode_xlate()'. The end goal is to completely
drop OF from the IIO inkernel interface.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ingenic-adc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/iio/adc/ingenic-adc.c b/drivers/iio/adc/ingenic-adc.c
index e731ba47add2..dcc6bc29dca0 100644
--- a/drivers/iio/adc/ingenic-adc.c
+++ b/drivers/iio/adc/ingenic-adc.c
@@ -19,7 +19,6 @@
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 #include <linux/property.h>
-#include <linux/of.h>
 
 #define JZ_ADC_REG_ENABLE		0x00
 #define JZ_ADC_REG_CFG			0x04
@@ -719,12 +718,12 @@ static int ingenic_adc_read_raw(struct iio_dev *iio_dev,
 	}
 }
 
-static int ingenic_adc_of_xlate(struct iio_dev *iio_dev,
-				const struct of_phandle_args *iiospec)
+static int ingenic_adc_fwnode_xlate(struct iio_dev *iio_dev,
+				    const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
-	if (!iiospec->args_count)
+	if (!iiospec->nargs)
 		return -EINVAL;
 
 	for (i = 0; i < iio_dev->num_channels; ++i)
@@ -743,7 +742,7 @@ static const struct iio_info ingenic_adc_info = {
 	.write_raw = ingenic_adc_write_raw,
 	.read_raw = ingenic_adc_read_raw,
 	.read_avail = ingenic_adc_read_avail,
-	.of_xlate = ingenic_adc_of_xlate,
+	.fwnode_xlate = ingenic_adc_fwnode_xlate,
 };
 
 static int ingenic_adc_buffer_enable(struct iio_dev *iio_dev)
-- 
2.36.1


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

* [PATCH 27/34] iio: adc: ab8500-gpadc: convert to device properties
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ab8500-gpadc.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c
index 930ce96e6ff5..4fa2126a354b 100644
--- a/drivers/iio/adc/ab8500-gpadc.c
+++ b/drivers/iio/adc/ab8500-gpadc.c
@@ -925,8 +925,8 @@ static int ab8500_gpadc_read_raw(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
-static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev,
-				 const struct of_phandle_args *iiospec)
+static int ab8500_gpadc_fwnode_xlate(struct iio_dev *indio_dev,
+				     const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
@@ -938,7 +938,7 @@ static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev,
 }
 
 static const struct iio_info ab8500_gpadc_info = {
-	.of_xlate = ab8500_gpadc_of_xlate,
+	.fwnode_xlate = ab8500_gpadc_fwnode_xlate,
 	.read_raw = ab8500_gpadc_read_raw,
 };
 
@@ -968,7 +968,7 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
 /**
  * ab8500_gpadc_parse_channel() - process devicetree channel configuration
  * @dev: pointer to containing device
- * @np: device tree node for the channel to configure
+ * @fwnode: fw node for the channel to configure
  * @ch: channel info to fill in
  * @iio_chan: IIO channel specification to fill in
  *
@@ -976,15 +976,15 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
  * and define usage for things like AUX GPADC inputs more precisely.
  */
 static int ab8500_gpadc_parse_channel(struct device *dev,
-				      struct device_node *np,
+				      struct fwnode_handle *fwnode,
 				      struct ab8500_gpadc_chan_info *ch,
 				      struct iio_chan_spec *iio_chan)
 {
-	const char *name = np->name;
+	const char *name = fwnode_get_name(fwnode);
 	u32 chan;
 	int ret;
 
-	ret = of_property_read_u32(np, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -1021,22 +1021,20 @@ static int ab8500_gpadc_parse_channel(struct device *dev,
 /**
  * ab8500_gpadc_parse_channels() - Parse the GPADC channels from DT
  * @gpadc: the GPADC to configure the channels for
- * @np: device tree node containing the channel configurations
  * @chans: the IIO channels we parsed
  * @nchans: the number of IIO channels we parsed
  */
 static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
-				       struct device_node *np,
 				       struct iio_chan_spec **chans_parsed,
 				       unsigned int *nchans_parsed)
 {
-	struct device_node *child;
+	struct fwnode_handle *child;
 	struct ab8500_gpadc_chan_info *ch;
 	struct iio_chan_spec *iio_chans;
 	unsigned int nchans;
 	int i;
 
-	nchans = of_get_available_child_count(np);
+	nchans = device_get_child_node_count(gpadc->dev);
 	if (!nchans) {
 		dev_err(gpadc->dev, "no channel children\n");
 		return -ENODEV;
@@ -1054,7 +1052,7 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_available_child_of_node(np, child) {
+	device_for_each_child_node(gpadc->dev, child) {
 		struct iio_chan_spec *iio_chan;
 		int ret;
 
@@ -1064,7 +1062,7 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
 		ret = ab8500_gpadc_parse_channel(gpadc->dev, child, ch,
 						 iio_chan);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 		i++;
@@ -1081,7 +1079,6 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)
 	struct ab8500_gpadc *gpadc;
 	struct iio_dev *indio_dev;
 	struct device *dev = &pdev->dev;
-	struct device_node *np = pdev->dev.of_node;
 	struct iio_chan_spec *iio_chans;
 	unsigned int n_iio_chans;
 	int ret;
@@ -1096,7 +1093,7 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)
 	gpadc->dev = dev;
 	gpadc->ab8500 = dev_get_drvdata(dev->parent);
 
-	ret = ab8500_gpadc_parse_channels(gpadc, np, &iio_chans, &n_iio_chans);
+	ret = ab8500_gpadc_parse_channels(gpadc, &iio_chans, &n_iio_chans);
 	if (ret)
 		return ret;
 
-- 
2.36.1


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

* [PATCH 27/34] iio: adc: ab8500-gpadc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ab8500-gpadc.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c
index 930ce96e6ff5..4fa2126a354b 100644
--- a/drivers/iio/adc/ab8500-gpadc.c
+++ b/drivers/iio/adc/ab8500-gpadc.c
@@ -925,8 +925,8 @@ static int ab8500_gpadc_read_raw(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
-static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev,
-				 const struct of_phandle_args *iiospec)
+static int ab8500_gpadc_fwnode_xlate(struct iio_dev *indio_dev,
+				     const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
@@ -938,7 +938,7 @@ static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev,
 }
 
 static const struct iio_info ab8500_gpadc_info = {
-	.of_xlate = ab8500_gpadc_of_xlate,
+	.fwnode_xlate = ab8500_gpadc_fwnode_xlate,
 	.read_raw = ab8500_gpadc_read_raw,
 };
 
@@ -968,7 +968,7 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
 /**
  * ab8500_gpadc_parse_channel() - process devicetree channel configuration
  * @dev: pointer to containing device
- * @np: device tree node for the channel to configure
+ * @fwnode: fw node for the channel to configure
  * @ch: channel info to fill in
  * @iio_chan: IIO channel specification to fill in
  *
@@ -976,15 +976,15 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
  * and define usage for things like AUX GPADC inputs more precisely.
  */
 static int ab8500_gpadc_parse_channel(struct device *dev,
-				      struct device_node *np,
+				      struct fwnode_handle *fwnode,
 				      struct ab8500_gpadc_chan_info *ch,
 				      struct iio_chan_spec *iio_chan)
 {
-	const char *name = np->name;
+	const char *name = fwnode_get_name(fwnode);
 	u32 chan;
 	int ret;
 
-	ret = of_property_read_u32(np, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -1021,22 +1021,20 @@ static int ab8500_gpadc_parse_channel(struct device *dev,
 /**
  * ab8500_gpadc_parse_channels() - Parse the GPADC channels from DT
  * @gpadc: the GPADC to configure the channels for
- * @np: device tree node containing the channel configurations
  * @chans: the IIO channels we parsed
  * @nchans: the number of IIO channels we parsed
  */
 static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
-				       struct device_node *np,
 				       struct iio_chan_spec **chans_parsed,
 				       unsigned int *nchans_parsed)
 {
-	struct device_node *child;
+	struct fwnode_handle *child;
 	struct ab8500_gpadc_chan_info *ch;
 	struct iio_chan_spec *iio_chans;
 	unsigned int nchans;
 	int i;
 
-	nchans = of_get_available_child_count(np);
+	nchans = device_get_child_node_count(gpadc->dev);
 	if (!nchans) {
 		dev_err(gpadc->dev, "no channel children\n");
 		return -ENODEV;
@@ -1054,7 +1052,7 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_available_child_of_node(np, child) {
+	device_for_each_child_node(gpadc->dev, child) {
 		struct iio_chan_spec *iio_chan;
 		int ret;
 
@@ -1064,7 +1062,7 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
 		ret = ab8500_gpadc_parse_channel(gpadc->dev, child, ch,
 						 iio_chan);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 		i++;
@@ -1081,7 +1079,6 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)
 	struct ab8500_gpadc *gpadc;
 	struct iio_dev *indio_dev;
 	struct device *dev = &pdev->dev;
-	struct device_node *np = pdev->dev.of_node;
 	struct iio_chan_spec *iio_chans;
 	unsigned int n_iio_chans;
 	int ret;
@@ -1096,7 +1093,7 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)
 	gpadc->dev = dev;
 	gpadc->ab8500 = dev_get_drvdata(dev->parent);
 
-	ret = ab8500_gpadc_parse_channels(gpadc, np, &iio_chans, &n_iio_chans);
+	ret = ab8500_gpadc_parse_channels(gpadc, &iio_chans, &n_iio_chans);
 	if (ret)
 		return ret;
 
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 27/34] iio: adc: ab8500-gpadc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/ab8500-gpadc.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/ab8500-gpadc.c b/drivers/iio/adc/ab8500-gpadc.c
index 930ce96e6ff5..4fa2126a354b 100644
--- a/drivers/iio/adc/ab8500-gpadc.c
+++ b/drivers/iio/adc/ab8500-gpadc.c
@@ -925,8 +925,8 @@ static int ab8500_gpadc_read_raw(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
-static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev,
-				 const struct of_phandle_args *iiospec)
+static int ab8500_gpadc_fwnode_xlate(struct iio_dev *indio_dev,
+				     const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
@@ -938,7 +938,7 @@ static int ab8500_gpadc_of_xlate(struct iio_dev *indio_dev,
 }
 
 static const struct iio_info ab8500_gpadc_info = {
-	.of_xlate = ab8500_gpadc_of_xlate,
+	.fwnode_xlate = ab8500_gpadc_fwnode_xlate,
 	.read_raw = ab8500_gpadc_read_raw,
 };
 
@@ -968,7 +968,7 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
 /**
  * ab8500_gpadc_parse_channel() - process devicetree channel configuration
  * @dev: pointer to containing device
- * @np: device tree node for the channel to configure
+ * @fwnode: fw node for the channel to configure
  * @ch: channel info to fill in
  * @iio_chan: IIO channel specification to fill in
  *
@@ -976,15 +976,15 @@ static int ab8500_gpadc_runtime_resume(struct device *dev)
  * and define usage for things like AUX GPADC inputs more precisely.
  */
 static int ab8500_gpadc_parse_channel(struct device *dev,
-				      struct device_node *np,
+				      struct fwnode_handle *fwnode,
 				      struct ab8500_gpadc_chan_info *ch,
 				      struct iio_chan_spec *iio_chan)
 {
-	const char *name = np->name;
+	const char *name = fwnode_get_name(fwnode);
 	u32 chan;
 	int ret;
 
-	ret = of_property_read_u32(np, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -1021,22 +1021,20 @@ static int ab8500_gpadc_parse_channel(struct device *dev,
 /**
  * ab8500_gpadc_parse_channels() - Parse the GPADC channels from DT
  * @gpadc: the GPADC to configure the channels for
- * @np: device tree node containing the channel configurations
  * @chans: the IIO channels we parsed
  * @nchans: the number of IIO channels we parsed
  */
 static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
-				       struct device_node *np,
 				       struct iio_chan_spec **chans_parsed,
 				       unsigned int *nchans_parsed)
 {
-	struct device_node *child;
+	struct fwnode_handle *child;
 	struct ab8500_gpadc_chan_info *ch;
 	struct iio_chan_spec *iio_chans;
 	unsigned int nchans;
 	int i;
 
-	nchans = of_get_available_child_count(np);
+	nchans = device_get_child_node_count(gpadc->dev);
 	if (!nchans) {
 		dev_err(gpadc->dev, "no channel children\n");
 		return -ENODEV;
@@ -1054,7 +1052,7 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_available_child_of_node(np, child) {
+	device_for_each_child_node(gpadc->dev, child) {
 		struct iio_chan_spec *iio_chan;
 		int ret;
 
@@ -1064,7 +1062,7 @@ static int ab8500_gpadc_parse_channels(struct ab8500_gpadc *gpadc,
 		ret = ab8500_gpadc_parse_channel(gpadc->dev, child, ch,
 						 iio_chan);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 		i++;
@@ -1081,7 +1079,6 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)
 	struct ab8500_gpadc *gpadc;
 	struct iio_dev *indio_dev;
 	struct device *dev = &pdev->dev;
-	struct device_node *np = pdev->dev.of_node;
 	struct iio_chan_spec *iio_chans;
 	unsigned int n_iio_chans;
 	int ret;
@@ -1096,7 +1093,7 @@ static int ab8500_gpadc_probe(struct platform_device *pdev)
 	gpadc->dev = dev;
 	gpadc->ab8500 = dev_get_drvdata(dev->parent);
 
-	ret = ab8500_gpadc_parse_channels(gpadc, np, &iio_chans, &n_iio_chans);
+	ret = ab8500_gpadc_parse_channels(gpadc, &iio_chans, &n_iio_chans);
 	if (ret)
 		return ret;
 
-- 
2.36.1


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

* [PATCH 28/34] iio: adc: at91-sama5d2_adc: convert to device properties
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/at91-sama5d2_adc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index b764823ce57e..f5a1df19e5b6 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -16,8 +16,9 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/iio/iio.h>
@@ -650,8 +651,8 @@ at91_adc_chan_get(struct iio_dev *indio_dev, int chan)
 	return indio_dev->channels + index;
 }
 
-static inline int at91_adc_of_xlate(struct iio_dev *indio_dev,
-				    const struct of_phandle_args *iiospec)
+static inline int at91_adc_fwnode_xlate(struct iio_dev *indio_dev,
+					const struct fwnode_reference_args *iiospec)
 {
 	return at91_adc_chan_xlate(indio_dev, iiospec->args[0]);
 }
@@ -1876,7 +1877,7 @@ static const struct iio_info at91_adc_info = {
 	.read_raw = &at91_adc_read_raw,
 	.write_raw = &at91_adc_write_raw,
 	.update_scan_mode = &at91_adc_update_scan_mode,
-	.of_xlate = &at91_adc_of_xlate,
+	.fwnode_xlate = &at91_adc_fwnode_xlate,
 	.hwfifo_set_watermark = &at91_adc_set_watermark,
 };
 
@@ -1920,6 +1921,7 @@ static int at91_adc_buffer_and_trigger_init(struct device *dev,
 
 static int at91_adc_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct at91_adc_state *st;
 	struct resource	*res;
@@ -1933,7 +1935,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	st = iio_priv(indio_dev);
 	st->indio_dev = indio_dev;
 
-	st->soc_info.platform = of_device_get_match_data(&pdev->dev);
+	st->soc_info.platform = device_get_match_data(dev);
 
 	indio_dev->name = dev_name(&pdev->dev);
 	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
@@ -1950,34 +1952,32 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	st->oversampling_ratio = AT91_OSR_1SAMPLES;
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,min-sample-rate-hz",
-				   &st->soc_info.min_sample_rate);
+	ret = device_property_read_u32(dev, "atmel,min-sample-rate-hz",
+				       &st->soc_info.min_sample_rate);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,min-sample-rate-hz\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,max-sample-rate-hz",
-				   &st->soc_info.max_sample_rate);
+	ret = device_property_read_u32(dev, "atmel,max-sample-rate-hz",
+				       &st->soc_info.max_sample_rate);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,max-sample-rate-hz\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node, "atmel,startup-time-ms",
-				   &st->soc_info.startup_time);
+	ret = device_property_read_u32(dev, "atmel,startup-time-ms",
+				       &st->soc_info.startup_time);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,startup-time-ms\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,trigger-edge-type", &edge_type);
+	ret = device_property_read_u32(dev, "atmel,trigger-edge-type",
+				       &edge_type);
 	if (ret) {
 		dev_dbg(&pdev->dev,
 			"atmel,trigger-edge-type not specified, only software trigger available\n");
-- 
2.36.1


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

* [PATCH 28/34] iio: adc: at91-sama5d2_adc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/at91-sama5d2_adc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index b764823ce57e..f5a1df19e5b6 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -16,8 +16,9 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/iio/iio.h>
@@ -650,8 +651,8 @@ at91_adc_chan_get(struct iio_dev *indio_dev, int chan)
 	return indio_dev->channels + index;
 }
 
-static inline int at91_adc_of_xlate(struct iio_dev *indio_dev,
-				    const struct of_phandle_args *iiospec)
+static inline int at91_adc_fwnode_xlate(struct iio_dev *indio_dev,
+					const struct fwnode_reference_args *iiospec)
 {
 	return at91_adc_chan_xlate(indio_dev, iiospec->args[0]);
 }
@@ -1876,7 +1877,7 @@ static const struct iio_info at91_adc_info = {
 	.read_raw = &at91_adc_read_raw,
 	.write_raw = &at91_adc_write_raw,
 	.update_scan_mode = &at91_adc_update_scan_mode,
-	.of_xlate = &at91_adc_of_xlate,
+	.fwnode_xlate = &at91_adc_fwnode_xlate,
 	.hwfifo_set_watermark = &at91_adc_set_watermark,
 };
 
@@ -1920,6 +1921,7 @@ static int at91_adc_buffer_and_trigger_init(struct device *dev,
 
 static int at91_adc_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct at91_adc_state *st;
 	struct resource	*res;
@@ -1933,7 +1935,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	st = iio_priv(indio_dev);
 	st->indio_dev = indio_dev;
 
-	st->soc_info.platform = of_device_get_match_data(&pdev->dev);
+	st->soc_info.platform = device_get_match_data(dev);
 
 	indio_dev->name = dev_name(&pdev->dev);
 	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
@@ -1950,34 +1952,32 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	st->oversampling_ratio = AT91_OSR_1SAMPLES;
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,min-sample-rate-hz",
-				   &st->soc_info.min_sample_rate);
+	ret = device_property_read_u32(dev, "atmel,min-sample-rate-hz",
+				       &st->soc_info.min_sample_rate);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,min-sample-rate-hz\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,max-sample-rate-hz",
-				   &st->soc_info.max_sample_rate);
+	ret = device_property_read_u32(dev, "atmel,max-sample-rate-hz",
+				       &st->soc_info.max_sample_rate);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,max-sample-rate-hz\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node, "atmel,startup-time-ms",
-				   &st->soc_info.startup_time);
+	ret = device_property_read_u32(dev, "atmel,startup-time-ms",
+				       &st->soc_info.startup_time);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,startup-time-ms\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,trigger-edge-type", &edge_type);
+	ret = device_property_read_u32(dev, "atmel,trigger-edge-type",
+				       &edge_type);
 	if (ret) {
 		dev_dbg(&pdev->dev,
 			"atmel,trigger-edge-type not specified, only software trigger available\n");
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 28/34] iio: adc: at91-sama5d2_adc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/at91-sama5d2_adc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index b764823ce57e..f5a1df19e5b6 100644
--- a/drivers/iio/adc/at91-sama5d2_adc.c
+++ b/drivers/iio/adc/at91-sama5d2_adc.c
@@ -16,8 +16,9 @@
 #include <linux/interrupt.h>
 #include <linux/io.h>
 #include <linux/module.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/sched.h>
 #include <linux/wait.h>
 #include <linux/iio/iio.h>
@@ -650,8 +651,8 @@ at91_adc_chan_get(struct iio_dev *indio_dev, int chan)
 	return indio_dev->channels + index;
 }
 
-static inline int at91_adc_of_xlate(struct iio_dev *indio_dev,
-				    const struct of_phandle_args *iiospec)
+static inline int at91_adc_fwnode_xlate(struct iio_dev *indio_dev,
+					const struct fwnode_reference_args *iiospec)
 {
 	return at91_adc_chan_xlate(indio_dev, iiospec->args[0]);
 }
@@ -1876,7 +1877,7 @@ static const struct iio_info at91_adc_info = {
 	.read_raw = &at91_adc_read_raw,
 	.write_raw = &at91_adc_write_raw,
 	.update_scan_mode = &at91_adc_update_scan_mode,
-	.of_xlate = &at91_adc_of_xlate,
+	.fwnode_xlate = &at91_adc_fwnode_xlate,
 	.hwfifo_set_watermark = &at91_adc_set_watermark,
 };
 
@@ -1920,6 +1921,7 @@ static int at91_adc_buffer_and_trigger_init(struct device *dev,
 
 static int at91_adc_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct at91_adc_state *st;
 	struct resource	*res;
@@ -1933,7 +1935,7 @@ static int at91_adc_probe(struct platform_device *pdev)
 	st = iio_priv(indio_dev);
 	st->indio_dev = indio_dev;
 
-	st->soc_info.platform = of_device_get_match_data(&pdev->dev);
+	st->soc_info.platform = device_get_match_data(dev);
 
 	indio_dev->name = dev_name(&pdev->dev);
 	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_BUFFER_SOFTWARE;
@@ -1950,34 +1952,32 @@ static int at91_adc_probe(struct platform_device *pdev)
 
 	st->oversampling_ratio = AT91_OSR_1SAMPLES;
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,min-sample-rate-hz",
-				   &st->soc_info.min_sample_rate);
+	ret = device_property_read_u32(dev, "atmel,min-sample-rate-hz",
+				       &st->soc_info.min_sample_rate);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,min-sample-rate-hz\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,max-sample-rate-hz",
-				   &st->soc_info.max_sample_rate);
+	ret = device_property_read_u32(dev, "atmel,max-sample-rate-hz",
+				       &st->soc_info.max_sample_rate);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,max-sample-rate-hz\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node, "atmel,startup-time-ms",
-				   &st->soc_info.startup_time);
+	ret = device_property_read_u32(dev, "atmel,startup-time-ms",
+				       &st->soc_info.startup_time);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"invalid or missing value for atmel,startup-time-ms\n");
 		return ret;
 	}
 
-	ret = of_property_read_u32(pdev->dev.of_node,
-				   "atmel,trigger-edge-type", &edge_type);
+	ret = device_property_read_u32(dev, "atmel,trigger-edge-type",
+				       &edge_type);
 	if (ret) {
 		dev_dbg(&pdev->dev,
 			"atmel,trigger-edge-type not specified, only software trigger available\n");
-- 
2.36.1


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

* [PATCH 29/34] iio: adc: qcom-pm8xxx-xoadc: convert to device properties
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-pm8xxx-xoadc.c | 58 ++++++++++++++---------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
index 5e9e56821075..eb424496ee1d 100644
--- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
@@ -14,9 +14,9 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -694,8 +694,8 @@ static int pm8xxx_read_raw(struct iio_dev *indio_dev,
 	}
 }
 
-static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
-			   const struct of_phandle_args *iiospec)
+static int pm8xxx_fwnode_xlate(struct iio_dev *indio_dev,
+			       const struct fwnode_reference_args *iiospec)
 {
 	struct pm8xxx_xoadc *adc = iio_priv(indio_dev);
 	u8 pre_scale_mux;
@@ -706,10 +706,10 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
 	 * First cell is prescaler or premux, second cell is analog
 	 * mux.
 	 */
-	if (iiospec->args_count != 2) {
-		dev_err(&indio_dev->dev, "wrong number of arguments for %pOFn need 2 got %d\n",
-			iiospec->np,
-			iiospec->args_count);
+	if (iiospec->nargs != 2) {
+		dev_err(&indio_dev->dev, "wrong number of arguments for %pfwP need 2 got %d\n",
+			iiospec->fwnode,
+			iiospec->nargs);
 		return -EINVAL;
 	}
 	pre_scale_mux = (u8)iiospec->args[0];
@@ -727,34 +727,34 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
 }
 
 static const struct iio_info pm8xxx_xoadc_info = {
-	.of_xlate = pm8xxx_of_xlate,
+	.fwnode_xlate = pm8xxx_fwnode_xlate,
 	.read_raw = pm8xxx_read_raw,
 };
 
 static int pm8xxx_xoadc_parse_channel(struct device *dev,
-				      struct device_node *np,
+				      struct fwnode_handle *fwnode,
 				      const struct xoadc_channel *hw_channels,
 				      struct iio_chan_spec *iio_chan,
 				      struct pm8xxx_chan_info *ch)
 {
-	const char *name = np->name;
+	const char *name = fwnode_get_name(fwnode);
 	const struct xoadc_channel *hwchan;
-	u32 pre_scale_mux, amux_channel;
+	u32 pre_scale_mux, amux_channel, reg[2];
 	u32 rsv, dec;
 	int ret;
 	int chid;
 
-	ret = of_property_read_u32_index(np, "reg", 0, &pre_scale_mux);
+	ret = fwnode_property_read_u32_array(fwnode, "reg", reg,
+					     ARRAY_SIZE(reg));
 	if (ret) {
-		dev_err(dev, "invalid pre scale/mux number %s\n", name);
-		return ret;
-	}
-	ret = of_property_read_u32_index(np, "reg", 1, &amux_channel);
-	if (ret) {
-		dev_err(dev, "invalid amux channel number %s\n", name);
+		dev_err(dev, "invalid pre scale/mux or amux channel number %s\n",
+			name);
 		return ret;
 	}
 
+	pre_scale_mux = reg[0];
+	amux_channel = reg[1];
+
 	/* Find the right channel setting */
 	chid = 0;
 	hwchan = &hw_channels[0];
@@ -778,7 +778,7 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	/* Everyone seems to use default ("type 2") decimation */
 	ch->decimation = VADC_DEF_DECIMATION;
 
-	if (!of_property_read_u32(np, "qcom,ratiometric", &rsv)) {
+	if (!fwnode_property_read_u32(fwnode, "qcom,ratiometric", &rsv)) {
 		ch->calibration = VADC_CALIB_RATIOMETRIC;
 		if (rsv > XOADC_RSV_MAX) {
 			dev_err(dev, "%s too large RSV value %d\n", name, rsv);
@@ -791,7 +791,7 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	}
 
 	/* Optional decimation, if omitted we use the default */
-	ret = of_property_read_u32(np, "qcom,decimation", &dec);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &dec);
 	if (!ret) {
 		ret = qcom_vadc_decimation_from_dt(dec);
 		if (ret < 0) {
@@ -820,15 +820,14 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	return 0;
 }
 
-static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc,
-				       struct device_node *np)
+static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc)
 {
-	struct device_node *child;
+	struct fwnode_handle *child;
 	struct pm8xxx_chan_info *ch;
 	int ret;
 	int i;
 
-	adc->nchans = of_get_available_child_count(np);
+	adc->nchans = device_get_child_node_count(adc->dev);
 	if (!adc->nchans) {
 		dev_err(adc->dev, "no channel children\n");
 		return -ENODEV;
@@ -846,14 +845,14 @@ static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_available_child_of_node(np, child) {
+	device_for_each_child_node(adc->dev, child) {
 		ch = &adc->chans[i];
 		ret = pm8xxx_xoadc_parse_channel(adc->dev, child,
 						 adc->variant->channels,
 						 &adc->iio_chans[i],
 						 ch);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 		i++;
@@ -884,12 +883,11 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)
 	const struct xoadc_variant *variant;
 	struct pm8xxx_xoadc *adc;
 	struct iio_dev *indio_dev;
-	struct device_node *np = pdev->dev.of_node;
 	struct regmap *map;
 	struct device *dev = &pdev->dev;
 	int ret;
 
-	variant = of_device_get_match_data(dev);
+	variant = device_get_match_data(dev);
 	if (!variant)
 		return -ENODEV;
 
@@ -904,7 +902,7 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)
 	init_completion(&adc->complete);
 	mutex_init(&adc->lock);
 
-	ret = pm8xxx_xoadc_parse_channels(adc, np);
+	ret = pm8xxx_xoadc_parse_channels(adc);
 	if (ret)
 		return ret;
 
-- 
2.36.1


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

* [PATCH 29/34] iio: adc: qcom-pm8xxx-xoadc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-pm8xxx-xoadc.c | 58 ++++++++++++++---------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
index 5e9e56821075..eb424496ee1d 100644
--- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
@@ -14,9 +14,9 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -694,8 +694,8 @@ static int pm8xxx_read_raw(struct iio_dev *indio_dev,
 	}
 }
 
-static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
-			   const struct of_phandle_args *iiospec)
+static int pm8xxx_fwnode_xlate(struct iio_dev *indio_dev,
+			       const struct fwnode_reference_args *iiospec)
 {
 	struct pm8xxx_xoadc *adc = iio_priv(indio_dev);
 	u8 pre_scale_mux;
@@ -706,10 +706,10 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
 	 * First cell is prescaler or premux, second cell is analog
 	 * mux.
 	 */
-	if (iiospec->args_count != 2) {
-		dev_err(&indio_dev->dev, "wrong number of arguments for %pOFn need 2 got %d\n",
-			iiospec->np,
-			iiospec->args_count);
+	if (iiospec->nargs != 2) {
+		dev_err(&indio_dev->dev, "wrong number of arguments for %pfwP need 2 got %d\n",
+			iiospec->fwnode,
+			iiospec->nargs);
 		return -EINVAL;
 	}
 	pre_scale_mux = (u8)iiospec->args[0];
@@ -727,34 +727,34 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
 }
 
 static const struct iio_info pm8xxx_xoadc_info = {
-	.of_xlate = pm8xxx_of_xlate,
+	.fwnode_xlate = pm8xxx_fwnode_xlate,
 	.read_raw = pm8xxx_read_raw,
 };
 
 static int pm8xxx_xoadc_parse_channel(struct device *dev,
-				      struct device_node *np,
+				      struct fwnode_handle *fwnode,
 				      const struct xoadc_channel *hw_channels,
 				      struct iio_chan_spec *iio_chan,
 				      struct pm8xxx_chan_info *ch)
 {
-	const char *name = np->name;
+	const char *name = fwnode_get_name(fwnode);
 	const struct xoadc_channel *hwchan;
-	u32 pre_scale_mux, amux_channel;
+	u32 pre_scale_mux, amux_channel, reg[2];
 	u32 rsv, dec;
 	int ret;
 	int chid;
 
-	ret = of_property_read_u32_index(np, "reg", 0, &pre_scale_mux);
+	ret = fwnode_property_read_u32_array(fwnode, "reg", reg,
+					     ARRAY_SIZE(reg));
 	if (ret) {
-		dev_err(dev, "invalid pre scale/mux number %s\n", name);
-		return ret;
-	}
-	ret = of_property_read_u32_index(np, "reg", 1, &amux_channel);
-	if (ret) {
-		dev_err(dev, "invalid amux channel number %s\n", name);
+		dev_err(dev, "invalid pre scale/mux or amux channel number %s\n",
+			name);
 		return ret;
 	}
 
+	pre_scale_mux = reg[0];
+	amux_channel = reg[1];
+
 	/* Find the right channel setting */
 	chid = 0;
 	hwchan = &hw_channels[0];
@@ -778,7 +778,7 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	/* Everyone seems to use default ("type 2") decimation */
 	ch->decimation = VADC_DEF_DECIMATION;
 
-	if (!of_property_read_u32(np, "qcom,ratiometric", &rsv)) {
+	if (!fwnode_property_read_u32(fwnode, "qcom,ratiometric", &rsv)) {
 		ch->calibration = VADC_CALIB_RATIOMETRIC;
 		if (rsv > XOADC_RSV_MAX) {
 			dev_err(dev, "%s too large RSV value %d\n", name, rsv);
@@ -791,7 +791,7 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	}
 
 	/* Optional decimation, if omitted we use the default */
-	ret = of_property_read_u32(np, "qcom,decimation", &dec);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &dec);
 	if (!ret) {
 		ret = qcom_vadc_decimation_from_dt(dec);
 		if (ret < 0) {
@@ -820,15 +820,14 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	return 0;
 }
 
-static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc,
-				       struct device_node *np)
+static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc)
 {
-	struct device_node *child;
+	struct fwnode_handle *child;
 	struct pm8xxx_chan_info *ch;
 	int ret;
 	int i;
 
-	adc->nchans = of_get_available_child_count(np);
+	adc->nchans = device_get_child_node_count(adc->dev);
 	if (!adc->nchans) {
 		dev_err(adc->dev, "no channel children\n");
 		return -ENODEV;
@@ -846,14 +845,14 @@ static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_available_child_of_node(np, child) {
+	device_for_each_child_node(adc->dev, child) {
 		ch = &adc->chans[i];
 		ret = pm8xxx_xoadc_parse_channel(adc->dev, child,
 						 adc->variant->channels,
 						 &adc->iio_chans[i],
 						 ch);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 		i++;
@@ -884,12 +883,11 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)
 	const struct xoadc_variant *variant;
 	struct pm8xxx_xoadc *adc;
 	struct iio_dev *indio_dev;
-	struct device_node *np = pdev->dev.of_node;
 	struct regmap *map;
 	struct device *dev = &pdev->dev;
 	int ret;
 
-	variant = of_device_get_match_data(dev);
+	variant = device_get_match_data(dev);
 	if (!variant)
 		return -ENODEV;
 
@@ -904,7 +902,7 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)
 	init_completion(&adc->complete);
 	mutex_init(&adc->lock);
 
-	ret = pm8xxx_xoadc_parse_channels(adc, np);
+	ret = pm8xxx_xoadc_parse_channels(adc);
 	if (ret)
 		return ret;
 
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 29/34] iio: adc: qcom-pm8xxx-xoadc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-pm8xxx-xoadc.c | 58 ++++++++++++++---------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/drivers/iio/adc/qcom-pm8xxx-xoadc.c b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
index 5e9e56821075..eb424496ee1d 100644
--- a/drivers/iio/adc/qcom-pm8xxx-xoadc.c
+++ b/drivers/iio/adc/qcom-pm8xxx-xoadc.c
@@ -14,9 +14,9 @@
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -694,8 +694,8 @@ static int pm8xxx_read_raw(struct iio_dev *indio_dev,
 	}
 }
 
-static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
-			   const struct of_phandle_args *iiospec)
+static int pm8xxx_fwnode_xlate(struct iio_dev *indio_dev,
+			       const struct fwnode_reference_args *iiospec)
 {
 	struct pm8xxx_xoadc *adc = iio_priv(indio_dev);
 	u8 pre_scale_mux;
@@ -706,10 +706,10 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
 	 * First cell is prescaler or premux, second cell is analog
 	 * mux.
 	 */
-	if (iiospec->args_count != 2) {
-		dev_err(&indio_dev->dev, "wrong number of arguments for %pOFn need 2 got %d\n",
-			iiospec->np,
-			iiospec->args_count);
+	if (iiospec->nargs != 2) {
+		dev_err(&indio_dev->dev, "wrong number of arguments for %pfwP need 2 got %d\n",
+			iiospec->fwnode,
+			iiospec->nargs);
 		return -EINVAL;
 	}
 	pre_scale_mux = (u8)iiospec->args[0];
@@ -727,34 +727,34 @@ static int pm8xxx_of_xlate(struct iio_dev *indio_dev,
 }
 
 static const struct iio_info pm8xxx_xoadc_info = {
-	.of_xlate = pm8xxx_of_xlate,
+	.fwnode_xlate = pm8xxx_fwnode_xlate,
 	.read_raw = pm8xxx_read_raw,
 };
 
 static int pm8xxx_xoadc_parse_channel(struct device *dev,
-				      struct device_node *np,
+				      struct fwnode_handle *fwnode,
 				      const struct xoadc_channel *hw_channels,
 				      struct iio_chan_spec *iio_chan,
 				      struct pm8xxx_chan_info *ch)
 {
-	const char *name = np->name;
+	const char *name = fwnode_get_name(fwnode);
 	const struct xoadc_channel *hwchan;
-	u32 pre_scale_mux, amux_channel;
+	u32 pre_scale_mux, amux_channel, reg[2];
 	u32 rsv, dec;
 	int ret;
 	int chid;
 
-	ret = of_property_read_u32_index(np, "reg", 0, &pre_scale_mux);
+	ret = fwnode_property_read_u32_array(fwnode, "reg", reg,
+					     ARRAY_SIZE(reg));
 	if (ret) {
-		dev_err(dev, "invalid pre scale/mux number %s\n", name);
-		return ret;
-	}
-	ret = of_property_read_u32_index(np, "reg", 1, &amux_channel);
-	if (ret) {
-		dev_err(dev, "invalid amux channel number %s\n", name);
+		dev_err(dev, "invalid pre scale/mux or amux channel number %s\n",
+			name);
 		return ret;
 	}
 
+	pre_scale_mux = reg[0];
+	amux_channel = reg[1];
+
 	/* Find the right channel setting */
 	chid = 0;
 	hwchan = &hw_channels[0];
@@ -778,7 +778,7 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	/* Everyone seems to use default ("type 2") decimation */
 	ch->decimation = VADC_DEF_DECIMATION;
 
-	if (!of_property_read_u32(np, "qcom,ratiometric", &rsv)) {
+	if (!fwnode_property_read_u32(fwnode, "qcom,ratiometric", &rsv)) {
 		ch->calibration = VADC_CALIB_RATIOMETRIC;
 		if (rsv > XOADC_RSV_MAX) {
 			dev_err(dev, "%s too large RSV value %d\n", name, rsv);
@@ -791,7 +791,7 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	}
 
 	/* Optional decimation, if omitted we use the default */
-	ret = of_property_read_u32(np, "qcom,decimation", &dec);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &dec);
 	if (!ret) {
 		ret = qcom_vadc_decimation_from_dt(dec);
 		if (ret < 0) {
@@ -820,15 +820,14 @@ static int pm8xxx_xoadc_parse_channel(struct device *dev,
 	return 0;
 }
 
-static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc,
-				       struct device_node *np)
+static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc)
 {
-	struct device_node *child;
+	struct fwnode_handle *child;
 	struct pm8xxx_chan_info *ch;
 	int ret;
 	int i;
 
-	adc->nchans = of_get_available_child_count(np);
+	adc->nchans = device_get_child_node_count(adc->dev);
 	if (!adc->nchans) {
 		dev_err(adc->dev, "no channel children\n");
 		return -ENODEV;
@@ -846,14 +845,14 @@ static int pm8xxx_xoadc_parse_channels(struct pm8xxx_xoadc *adc,
 		return -ENOMEM;
 
 	i = 0;
-	for_each_available_child_of_node(np, child) {
+	device_for_each_child_node(adc->dev, child) {
 		ch = &adc->chans[i];
 		ret = pm8xxx_xoadc_parse_channel(adc->dev, child,
 						 adc->variant->channels,
 						 &adc->iio_chans[i],
 						 ch);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 		i++;
@@ -884,12 +883,11 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)
 	const struct xoadc_variant *variant;
 	struct pm8xxx_xoadc *adc;
 	struct iio_dev *indio_dev;
-	struct device_node *np = pdev->dev.of_node;
 	struct regmap *map;
 	struct device *dev = &pdev->dev;
 	int ret;
 
-	variant = of_device_get_match_data(dev);
+	variant = device_get_match_data(dev);
 	if (!variant)
 		return -ENODEV;
 
@@ -904,7 +902,7 @@ static int pm8xxx_xoadc_probe(struct platform_device *pdev)
 	init_completion(&adc->complete);
 	mutex_init(&adc->lock);
 
-	ret = pm8xxx_xoadc_parse_channels(adc, np);
+	ret = pm8xxx_xoadc_parse_channels(adc);
 	if (ret)
 		return ret;
 
-- 
2.36.1


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

* [PATCH 30/34] iio: adc: qcom-spmi-vadc: convert to device properties
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-spmi-vadc.c | 44 ++++++++++++++++----------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
index 34202ba52469..bcff0f62b70e 100644
--- a/drivers/iio/adc/qcom-spmi-vadc.c
+++ b/drivers/iio/adc/qcom-spmi-vadc.c
@@ -13,8 +13,9 @@
 #include <linux/kernel.h>
 #include <linux/math64.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/log2.h>
@@ -481,8 +482,8 @@ static int vadc_read_raw(struct iio_dev *indio_dev,
 	return ret;
 }
 
-static int vadc_of_xlate(struct iio_dev *indio_dev,
-			 const struct of_phandle_args *iiospec)
+static int vadc_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct vadc_priv *vadc = iio_priv(indio_dev);
 	unsigned int i;
@@ -496,7 +497,7 @@ static int vadc_of_xlate(struct iio_dev *indio_dev,
 
 static const struct iio_info vadc_info = {
 	.read_raw = vadc_read_raw,
-	.of_xlate = vadc_of_xlate,
+	.fwnode_xlate = vadc_fwnode_xlate,
 };
 
 struct vadc_channels {
@@ -647,15 +648,15 @@ static const struct vadc_channels vadc_chans[] = {
 	VADC_CHAN_NO_SCALE(LR_MUX3_BUF_PU1_PU2_XO_THERM, 0)
 };
 
-static int vadc_get_dt_channel_data(struct device *dev,
+static int vadc_get_fw_channel_data(struct device *dev,
 				    struct vadc_channel_prop *prop,
-				    struct device_node *node)
+				    struct fwnode_handle *fwnode)
 {
-	const char *name = node->name;
+	const char *name = fwnode_get_name(fwnode);
 	u32 chan, value, varr[2];
 	int ret;
 
-	ret = of_property_read_u32(node, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -669,7 +670,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 	/* the channel has DT description */
 	prop->channel = chan;
 
-	ret = of_property_read_u32(node, "qcom,decimation", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value);
 	if (!ret) {
 		ret = qcom_vadc_decimation_from_dt(value);
 		if (ret < 0) {
@@ -682,7 +683,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->decimation = VADC_DEF_DECIMATION;
 	}
 
-	ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
+	ret = fwnode_property_read_u32_array(fwnode, "qcom,pre-scaling", varr, 2);
 	if (!ret) {
 		ret = vadc_prescaling_from_dt(varr[0], varr[1]);
 		if (ret < 0) {
@@ -695,7 +696,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->prescale = vadc_chans[prop->channel].prescale_index;
 	}
 
-	ret = of_property_read_u32(node, "qcom,hw-settle-time", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,hw-settle-time", &value);
 	if (!ret) {
 		ret = vadc_hw_settle_time_from_dt(value);
 		if (ret < 0) {
@@ -708,7 +709,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->hw_settle_time = VADC_DEF_HW_SETTLE_TIME;
 	}
 
-	ret = of_property_read_u32(node, "qcom,avg-samples", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,avg-samples", &value);
 	if (!ret) {
 		ret = vadc_avg_samples_from_dt(value);
 		if (ret < 0) {
@@ -721,7 +722,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->avg_samples = VADC_DEF_AVG_SAMPLES;
 	}
 
-	if (of_property_read_bool(node, "qcom,ratiometric"))
+	if (fwnode_property_read_bool(fwnode, "qcom,ratiometric"))
 		prop->calibration = VADC_CALIB_RATIOMETRIC;
 	else
 		prop->calibration = VADC_CALIB_ABSOLUTE;
@@ -731,16 +732,16 @@ static int vadc_get_dt_channel_data(struct device *dev,
 	return 0;
 }
 
-static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
+static int vadc_get_fw_data(struct vadc_priv *vadc)
 {
 	const struct vadc_channels *vadc_chan;
 	struct iio_chan_spec *iio_chan;
 	struct vadc_channel_prop prop;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	unsigned int index = 0;
 	int ret;
 
-	vadc->nchannels = of_get_available_child_count(node);
+	vadc->nchannels = device_get_child_node_count(vadc->dev);
 	if (!vadc->nchannels)
 		return -EINVAL;
 
@@ -756,10 +757,10 @@ static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
 
 	iio_chan = vadc->iio_chans;
 
-	for_each_available_child_of_node(node, child) {
-		ret = vadc_get_dt_channel_data(vadc->dev, &prop, child);
+	device_for_each_child_node(vadc->dev, child) {
+		ret = vadc_get_fw_channel_data(vadc->dev, &prop, child);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 
@@ -848,7 +849,6 @@ static int vadc_check_revision(struct vadc_priv *vadc)
 
 static int vadc_probe(struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct vadc_priv *vadc;
@@ -860,7 +860,7 @@ static int vadc_probe(struct platform_device *pdev)
 	if (!regmap)
 		return -ENODEV;
 
-	ret = of_property_read_u32(node, "reg", &reg);
+	ret = device_property_read_u32(dev, "reg", &reg);
 	if (ret < 0)
 		return ret;
 
@@ -880,7 +880,7 @@ static int vadc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = vadc_get_dt_data(vadc, node);
+	ret = vadc_get_fw_data(vadc);
 	if (ret)
 		return ret;
 
-- 
2.36.1


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

* [PATCH 30/34] iio: adc: qcom-spmi-vadc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-spmi-vadc.c | 44 ++++++++++++++++----------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
index 34202ba52469..bcff0f62b70e 100644
--- a/drivers/iio/adc/qcom-spmi-vadc.c
+++ b/drivers/iio/adc/qcom-spmi-vadc.c
@@ -13,8 +13,9 @@
 #include <linux/kernel.h>
 #include <linux/math64.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/log2.h>
@@ -481,8 +482,8 @@ static int vadc_read_raw(struct iio_dev *indio_dev,
 	return ret;
 }
 
-static int vadc_of_xlate(struct iio_dev *indio_dev,
-			 const struct of_phandle_args *iiospec)
+static int vadc_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct vadc_priv *vadc = iio_priv(indio_dev);
 	unsigned int i;
@@ -496,7 +497,7 @@ static int vadc_of_xlate(struct iio_dev *indio_dev,
 
 static const struct iio_info vadc_info = {
 	.read_raw = vadc_read_raw,
-	.of_xlate = vadc_of_xlate,
+	.fwnode_xlate = vadc_fwnode_xlate,
 };
 
 struct vadc_channels {
@@ -647,15 +648,15 @@ static const struct vadc_channels vadc_chans[] = {
 	VADC_CHAN_NO_SCALE(LR_MUX3_BUF_PU1_PU2_XO_THERM, 0)
 };
 
-static int vadc_get_dt_channel_data(struct device *dev,
+static int vadc_get_fw_channel_data(struct device *dev,
 				    struct vadc_channel_prop *prop,
-				    struct device_node *node)
+				    struct fwnode_handle *fwnode)
 {
-	const char *name = node->name;
+	const char *name = fwnode_get_name(fwnode);
 	u32 chan, value, varr[2];
 	int ret;
 
-	ret = of_property_read_u32(node, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -669,7 +670,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 	/* the channel has DT description */
 	prop->channel = chan;
 
-	ret = of_property_read_u32(node, "qcom,decimation", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value);
 	if (!ret) {
 		ret = qcom_vadc_decimation_from_dt(value);
 		if (ret < 0) {
@@ -682,7 +683,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->decimation = VADC_DEF_DECIMATION;
 	}
 
-	ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
+	ret = fwnode_property_read_u32_array(fwnode, "qcom,pre-scaling", varr, 2);
 	if (!ret) {
 		ret = vadc_prescaling_from_dt(varr[0], varr[1]);
 		if (ret < 0) {
@@ -695,7 +696,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->prescale = vadc_chans[prop->channel].prescale_index;
 	}
 
-	ret = of_property_read_u32(node, "qcom,hw-settle-time", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,hw-settle-time", &value);
 	if (!ret) {
 		ret = vadc_hw_settle_time_from_dt(value);
 		if (ret < 0) {
@@ -708,7 +709,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->hw_settle_time = VADC_DEF_HW_SETTLE_TIME;
 	}
 
-	ret = of_property_read_u32(node, "qcom,avg-samples", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,avg-samples", &value);
 	if (!ret) {
 		ret = vadc_avg_samples_from_dt(value);
 		if (ret < 0) {
@@ -721,7 +722,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->avg_samples = VADC_DEF_AVG_SAMPLES;
 	}
 
-	if (of_property_read_bool(node, "qcom,ratiometric"))
+	if (fwnode_property_read_bool(fwnode, "qcom,ratiometric"))
 		prop->calibration = VADC_CALIB_RATIOMETRIC;
 	else
 		prop->calibration = VADC_CALIB_ABSOLUTE;
@@ -731,16 +732,16 @@ static int vadc_get_dt_channel_data(struct device *dev,
 	return 0;
 }
 
-static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
+static int vadc_get_fw_data(struct vadc_priv *vadc)
 {
 	const struct vadc_channels *vadc_chan;
 	struct iio_chan_spec *iio_chan;
 	struct vadc_channel_prop prop;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	unsigned int index = 0;
 	int ret;
 
-	vadc->nchannels = of_get_available_child_count(node);
+	vadc->nchannels = device_get_child_node_count(vadc->dev);
 	if (!vadc->nchannels)
 		return -EINVAL;
 
@@ -756,10 +757,10 @@ static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
 
 	iio_chan = vadc->iio_chans;
 
-	for_each_available_child_of_node(node, child) {
-		ret = vadc_get_dt_channel_data(vadc->dev, &prop, child);
+	device_for_each_child_node(vadc->dev, child) {
+		ret = vadc_get_fw_channel_data(vadc->dev, &prop, child);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 
@@ -848,7 +849,6 @@ static int vadc_check_revision(struct vadc_priv *vadc)
 
 static int vadc_probe(struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct vadc_priv *vadc;
@@ -860,7 +860,7 @@ static int vadc_probe(struct platform_device *pdev)
 	if (!regmap)
 		return -ENODEV;
 
-	ret = of_property_read_u32(node, "reg", &reg);
+	ret = device_property_read_u32(dev, "reg", &reg);
 	if (ret < 0)
 		return ret;
 
@@ -880,7 +880,7 @@ static int vadc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = vadc_get_dt_data(vadc, node);
+	ret = vadc_get_fw_data(vadc);
 	if (ret)
 		return ret;
 
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 30/34] iio: adc: qcom-spmi-vadc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-spmi-vadc.c | 44 ++++++++++++++++----------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c
index 34202ba52469..bcff0f62b70e 100644
--- a/drivers/iio/adc/qcom-spmi-vadc.c
+++ b/drivers/iio/adc/qcom-spmi-vadc.c
@@ -13,8 +13,9 @@
 #include <linux/kernel.h>
 #include <linux/math64.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 #include <linux/log2.h>
@@ -481,8 +482,8 @@ static int vadc_read_raw(struct iio_dev *indio_dev,
 	return ret;
 }
 
-static int vadc_of_xlate(struct iio_dev *indio_dev,
-			 const struct of_phandle_args *iiospec)
+static int vadc_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct vadc_priv *vadc = iio_priv(indio_dev);
 	unsigned int i;
@@ -496,7 +497,7 @@ static int vadc_of_xlate(struct iio_dev *indio_dev,
 
 static const struct iio_info vadc_info = {
 	.read_raw = vadc_read_raw,
-	.of_xlate = vadc_of_xlate,
+	.fwnode_xlate = vadc_fwnode_xlate,
 };
 
 struct vadc_channels {
@@ -647,15 +648,15 @@ static const struct vadc_channels vadc_chans[] = {
 	VADC_CHAN_NO_SCALE(LR_MUX3_BUF_PU1_PU2_XO_THERM, 0)
 };
 
-static int vadc_get_dt_channel_data(struct device *dev,
+static int vadc_get_fw_channel_data(struct device *dev,
 				    struct vadc_channel_prop *prop,
-				    struct device_node *node)
+				    struct fwnode_handle *fwnode)
 {
-	const char *name = node->name;
+	const char *name = fwnode_get_name(fwnode);
 	u32 chan, value, varr[2];
 	int ret;
 
-	ret = of_property_read_u32(node, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -669,7 +670,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 	/* the channel has DT description */
 	prop->channel = chan;
 
-	ret = of_property_read_u32(node, "qcom,decimation", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value);
 	if (!ret) {
 		ret = qcom_vadc_decimation_from_dt(value);
 		if (ret < 0) {
@@ -682,7 +683,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->decimation = VADC_DEF_DECIMATION;
 	}
 
-	ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
+	ret = fwnode_property_read_u32_array(fwnode, "qcom,pre-scaling", varr, 2);
 	if (!ret) {
 		ret = vadc_prescaling_from_dt(varr[0], varr[1]);
 		if (ret < 0) {
@@ -695,7 +696,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->prescale = vadc_chans[prop->channel].prescale_index;
 	}
 
-	ret = of_property_read_u32(node, "qcom,hw-settle-time", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,hw-settle-time", &value);
 	if (!ret) {
 		ret = vadc_hw_settle_time_from_dt(value);
 		if (ret < 0) {
@@ -708,7 +709,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->hw_settle_time = VADC_DEF_HW_SETTLE_TIME;
 	}
 
-	ret = of_property_read_u32(node, "qcom,avg-samples", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,avg-samples", &value);
 	if (!ret) {
 		ret = vadc_avg_samples_from_dt(value);
 		if (ret < 0) {
@@ -721,7 +722,7 @@ static int vadc_get_dt_channel_data(struct device *dev,
 		prop->avg_samples = VADC_DEF_AVG_SAMPLES;
 	}
 
-	if (of_property_read_bool(node, "qcom,ratiometric"))
+	if (fwnode_property_read_bool(fwnode, "qcom,ratiometric"))
 		prop->calibration = VADC_CALIB_RATIOMETRIC;
 	else
 		prop->calibration = VADC_CALIB_ABSOLUTE;
@@ -731,16 +732,16 @@ static int vadc_get_dt_channel_data(struct device *dev,
 	return 0;
 }
 
-static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
+static int vadc_get_fw_data(struct vadc_priv *vadc)
 {
 	const struct vadc_channels *vadc_chan;
 	struct iio_chan_spec *iio_chan;
 	struct vadc_channel_prop prop;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	unsigned int index = 0;
 	int ret;
 
-	vadc->nchannels = of_get_available_child_count(node);
+	vadc->nchannels = device_get_child_node_count(vadc->dev);
 	if (!vadc->nchannels)
 		return -EINVAL;
 
@@ -756,10 +757,10 @@ static int vadc_get_dt_data(struct vadc_priv *vadc, struct device_node *node)
 
 	iio_chan = vadc->iio_chans;
 
-	for_each_available_child_of_node(node, child) {
-		ret = vadc_get_dt_channel_data(vadc->dev, &prop, child);
+	device_for_each_child_node(vadc->dev, child) {
+		ret = vadc_get_fw_channel_data(vadc->dev, &prop, child);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 
@@ -848,7 +849,6 @@ static int vadc_check_revision(struct vadc_priv *vadc)
 
 static int vadc_probe(struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct vadc_priv *vadc;
@@ -860,7 +860,7 @@ static int vadc_probe(struct platform_device *pdev)
 	if (!regmap)
 		return -ENODEV;
 
-	ret = of_property_read_u32(node, "reg", &reg);
+	ret = device_property_read_u32(dev, "reg", &reg);
 	if (ret < 0)
 		return ret;
 
@@ -880,7 +880,7 @@ static int vadc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = vadc_get_dt_data(vadc, node);
+	ret = vadc_get_fw_data(vadc);
 	if (ret)
 		return ret;
 
-- 
2.36.1


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

* [PATCH 31/34] iio: adc: qcom-spmi-adc5: convert to device properties
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-spmi-adc5.c | 63 +++++++++++++++-----------------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
index 87438d1e5c0b..a23f9293d6c1 100644
--- a/drivers/iio/adc/qcom-spmi-adc5.c
+++ b/drivers/iio/adc/qcom-spmi-adc5.c
@@ -14,9 +14,9 @@
 #include <linux/log2.h>
 #include <linux/math64.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
@@ -403,8 +403,8 @@ static irqreturn_t adc5_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int adc5_of_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int adc5_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct adc5_chip *adc = iio_priv(indio_dev);
 	int i;
@@ -416,8 +416,8 @@ static int adc5_of_xlate(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
-static int adc7_of_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int adc7_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct adc5_chip *adc = iio_priv(indio_dev);
 	int i, v_channel;
@@ -481,12 +481,12 @@ static int adc7_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_info adc5_info = {
 	.read_raw = adc5_read_raw,
-	.of_xlate = adc5_of_xlate,
+	.fwnode_xlate = adc5_fwnode_xlate,
 };
 
 static const struct iio_info adc7_info = {
 	.read_raw = adc7_read_raw,
-	.of_xlate = adc7_of_xlate,
+	.fwnode_xlate = adc7_fwnode_xlate,
 };
 
 struct adc5_channels {
@@ -611,18 +611,18 @@ static const struct adc5_channels adc5_chans_rev2[ADC5_MAX_CHANNEL] = {
 					SCALE_HW_CALIB_THERM_100K_PULLUP)
 };
 
-static int adc5_get_dt_channel_data(struct adc5_chip *adc,
+static int adc5_get_fw_channel_data(struct adc5_chip *adc,
 				    struct adc5_channel_prop *prop,
-				    struct device_node *node,
+				    struct fwnode_handle *fwnode,
 				    const struct adc5_data *data)
 {
-	const char *name = node->name, *channel_name;
+	const char *name = fwnode_get_name(fwnode), *channel_name;
 	u32 chan, value, varr[2];
 	u32 sid = 0;
 	int ret;
 	struct device *dev = adc->dev;
 
-	ret = of_property_read_u32(node, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -647,15 +647,13 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 	prop->channel = chan;
 	prop->sid = sid;
 
-	channel_name = of_get_property(node,
-				"label", NULL) ? : node->name;
-	if (!channel_name) {
-		dev_err(dev, "Invalid channel name\n");
-		return -EINVAL;
-	}
+	ret = fwnode_property_read_string(fwnode, "label", &channel_name);
+	if (ret)
+		channel_name = name;
+
 	prop->datasheet_name = channel_name;
 
-	ret = of_property_read_u32(node, "qcom,decimation", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value);
 	if (!ret) {
 		ret = qcom_adc5_decimation_from_dt(value, data->decimation);
 		if (ret < 0) {
@@ -668,7 +666,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->decimation = ADC5_DECIMATION_DEFAULT;
 	}
 
-	ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
+	ret = fwnode_property_read_u32_array(fwnode, "qcom,pre-scaling", varr, 2);
 	if (!ret) {
 		ret = qcom_adc5_prescaling_from_dt(varr[0], varr[1]);
 		if (ret < 0) {
@@ -682,7 +680,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 			adc->data->adc_chans[prop->channel].prescale_index;
 	}
 
-	ret = of_property_read_u32(node, "qcom,hw-settle-time", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,hw-settle-time", &value);
 	if (!ret) {
 		u8 dig_version[2];
 
@@ -713,7 +711,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->hw_settle_time = VADC_DEF_HW_SETTLE_TIME;
 	}
 
-	ret = of_property_read_u32(node, "qcom,avg-samples", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,avg-samples", &value);
 	if (!ret) {
 		ret = qcom_adc5_avg_samples_from_dt(value);
 		if (ret < 0) {
@@ -726,7 +724,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->avg_samples = VADC_DEF_AVG_SAMPLES;
 	}
 
-	if (of_property_read_bool(node, "qcom,ratiometric"))
+	if (fwnode_property_read_bool(fwnode, "qcom,ratiometric"))
 		prop->cal_method = ADC5_RATIOMETRIC_CAL;
 	else
 		prop->cal_method = ADC5_ABSOLUTE_CAL;
@@ -801,16 +799,16 @@ static const struct of_device_id adc5_match_table[] = {
 };
 MODULE_DEVICE_TABLE(of, adc5_match_table);
 
-static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
+static int adc5_get_fw_data(struct adc5_chip *adc)
 {
 	const struct adc5_channels *adc_chan;
 	struct iio_chan_spec *iio_chan;
 	struct adc5_channel_prop prop, *chan_props;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	unsigned int index = 0;
 	int ret;
 
-	adc->nchannels = of_get_available_child_count(node);
+	adc->nchannels = device_get_child_node_count(adc->dev);
 	if (!adc->nchannels)
 		return -EINVAL;
 
@@ -826,14 +824,14 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
 
 	chan_props = adc->chan_props;
 	iio_chan = adc->iio_chans;
-	adc->data = of_device_get_match_data(adc->dev);
+	adc->data = device_get_match_data(adc->dev);
 	if (!adc->data)
 		adc->data = &adc5_data_pmic;
 
-	for_each_available_child_of_node(node, child) {
-		ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data);
+	device_for_each_child_node(adc->dev, child) {
+		ret = adc5_get_fw_channel_data(adc, &prop, child, adc->data);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 
@@ -858,7 +856,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
 
 static int adc5_probe(struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct adc5_chip *adc;
@@ -870,7 +867,7 @@ static int adc5_probe(struct platform_device *pdev)
 	if (!regmap)
 		return -ENODEV;
 
-	ret = of_property_read_u32(node, "reg", &reg);
+	ret = device_property_read_u32(dev, "reg", &reg);
 	if (ret < 0)
 		return ret;
 
@@ -886,7 +883,7 @@ static int adc5_probe(struct platform_device *pdev)
 	init_completion(&adc->complete);
 	mutex_init(&adc->lock);
 
-	ret = adc5_get_dt_data(adc, node);
+	ret = adc5_get_fw_data(adc);
 	if (ret) {
 		dev_err(dev, "adc get dt data failed\n");
 		return ret;
-- 
2.36.1


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

* [PATCH 31/34] iio: adc: qcom-spmi-adc5: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-spmi-adc5.c | 63 +++++++++++++++-----------------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
index 87438d1e5c0b..a23f9293d6c1 100644
--- a/drivers/iio/adc/qcom-spmi-adc5.c
+++ b/drivers/iio/adc/qcom-spmi-adc5.c
@@ -14,9 +14,9 @@
 #include <linux/log2.h>
 #include <linux/math64.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
@@ -403,8 +403,8 @@ static irqreturn_t adc5_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int adc5_of_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int adc5_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct adc5_chip *adc = iio_priv(indio_dev);
 	int i;
@@ -416,8 +416,8 @@ static int adc5_of_xlate(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
-static int adc7_of_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int adc7_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct adc5_chip *adc = iio_priv(indio_dev);
 	int i, v_channel;
@@ -481,12 +481,12 @@ static int adc7_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_info adc5_info = {
 	.read_raw = adc5_read_raw,
-	.of_xlate = adc5_of_xlate,
+	.fwnode_xlate = adc5_fwnode_xlate,
 };
 
 static const struct iio_info adc7_info = {
 	.read_raw = adc7_read_raw,
-	.of_xlate = adc7_of_xlate,
+	.fwnode_xlate = adc7_fwnode_xlate,
 };
 
 struct adc5_channels {
@@ -611,18 +611,18 @@ static const struct adc5_channels adc5_chans_rev2[ADC5_MAX_CHANNEL] = {
 					SCALE_HW_CALIB_THERM_100K_PULLUP)
 };
 
-static int adc5_get_dt_channel_data(struct adc5_chip *adc,
+static int adc5_get_fw_channel_data(struct adc5_chip *adc,
 				    struct adc5_channel_prop *prop,
-				    struct device_node *node,
+				    struct fwnode_handle *fwnode,
 				    const struct adc5_data *data)
 {
-	const char *name = node->name, *channel_name;
+	const char *name = fwnode_get_name(fwnode), *channel_name;
 	u32 chan, value, varr[2];
 	u32 sid = 0;
 	int ret;
 	struct device *dev = adc->dev;
 
-	ret = of_property_read_u32(node, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -647,15 +647,13 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 	prop->channel = chan;
 	prop->sid = sid;
 
-	channel_name = of_get_property(node,
-				"label", NULL) ? : node->name;
-	if (!channel_name) {
-		dev_err(dev, "Invalid channel name\n");
-		return -EINVAL;
-	}
+	ret = fwnode_property_read_string(fwnode, "label", &channel_name);
+	if (ret)
+		channel_name = name;
+
 	prop->datasheet_name = channel_name;
 
-	ret = of_property_read_u32(node, "qcom,decimation", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value);
 	if (!ret) {
 		ret = qcom_adc5_decimation_from_dt(value, data->decimation);
 		if (ret < 0) {
@@ -668,7 +666,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->decimation = ADC5_DECIMATION_DEFAULT;
 	}
 
-	ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
+	ret = fwnode_property_read_u32_array(fwnode, "qcom,pre-scaling", varr, 2);
 	if (!ret) {
 		ret = qcom_adc5_prescaling_from_dt(varr[0], varr[1]);
 		if (ret < 0) {
@@ -682,7 +680,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 			adc->data->adc_chans[prop->channel].prescale_index;
 	}
 
-	ret = of_property_read_u32(node, "qcom,hw-settle-time", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,hw-settle-time", &value);
 	if (!ret) {
 		u8 dig_version[2];
 
@@ -713,7 +711,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->hw_settle_time = VADC_DEF_HW_SETTLE_TIME;
 	}
 
-	ret = of_property_read_u32(node, "qcom,avg-samples", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,avg-samples", &value);
 	if (!ret) {
 		ret = qcom_adc5_avg_samples_from_dt(value);
 		if (ret < 0) {
@@ -726,7 +724,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->avg_samples = VADC_DEF_AVG_SAMPLES;
 	}
 
-	if (of_property_read_bool(node, "qcom,ratiometric"))
+	if (fwnode_property_read_bool(fwnode, "qcom,ratiometric"))
 		prop->cal_method = ADC5_RATIOMETRIC_CAL;
 	else
 		prop->cal_method = ADC5_ABSOLUTE_CAL;
@@ -801,16 +799,16 @@ static const struct of_device_id adc5_match_table[] = {
 };
 MODULE_DEVICE_TABLE(of, adc5_match_table);
 
-static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
+static int adc5_get_fw_data(struct adc5_chip *adc)
 {
 	const struct adc5_channels *adc_chan;
 	struct iio_chan_spec *iio_chan;
 	struct adc5_channel_prop prop, *chan_props;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	unsigned int index = 0;
 	int ret;
 
-	adc->nchannels = of_get_available_child_count(node);
+	adc->nchannels = device_get_child_node_count(adc->dev);
 	if (!adc->nchannels)
 		return -EINVAL;
 
@@ -826,14 +824,14 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
 
 	chan_props = adc->chan_props;
 	iio_chan = adc->iio_chans;
-	adc->data = of_device_get_match_data(adc->dev);
+	adc->data = device_get_match_data(adc->dev);
 	if (!adc->data)
 		adc->data = &adc5_data_pmic;
 
-	for_each_available_child_of_node(node, child) {
-		ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data);
+	device_for_each_child_node(adc->dev, child) {
+		ret = adc5_get_fw_channel_data(adc, &prop, child, adc->data);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 
@@ -858,7 +856,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
 
 static int adc5_probe(struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct adc5_chip *adc;
@@ -870,7 +867,7 @@ static int adc5_probe(struct platform_device *pdev)
 	if (!regmap)
 		return -ENODEV;
 
-	ret = of_property_read_u32(node, "reg", &reg);
+	ret = device_property_read_u32(dev, "reg", &reg);
 	if (ret < 0)
 		return ret;
 
@@ -886,7 +883,7 @@ static int adc5_probe(struct platform_device *pdev)
 	init_completion(&adc->complete);
 	mutex_init(&adc->lock);
 
-	ret = adc5_get_dt_data(adc, node);
+	ret = adc5_get_fw_data(adc);
 	if (ret) {
 		dev_err(dev, "adc get dt data failed\n");
 		return ret;
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 31/34] iio: adc: qcom-spmi-adc5: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/qcom-spmi-adc5.c | 63 +++++++++++++++-----------------
 1 file changed, 30 insertions(+), 33 deletions(-)

diff --git a/drivers/iio/adc/qcom-spmi-adc5.c b/drivers/iio/adc/qcom-spmi-adc5.c
index 87438d1e5c0b..a23f9293d6c1 100644
--- a/drivers/iio/adc/qcom-spmi-adc5.c
+++ b/drivers/iio/adc/qcom-spmi-adc5.c
@@ -14,9 +14,9 @@
 #include <linux/log2.h>
 #include <linux/math64.h>
 #include <linux/module.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
 
@@ -403,8 +403,8 @@ static irqreturn_t adc5_isr(int irq, void *dev_id)
 	return IRQ_HANDLED;
 }
 
-static int adc5_of_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int adc5_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct adc5_chip *adc = iio_priv(indio_dev);
 	int i;
@@ -416,8 +416,8 @@ static int adc5_of_xlate(struct iio_dev *indio_dev,
 	return -EINVAL;
 }
 
-static int adc7_of_xlate(struct iio_dev *indio_dev,
-				const struct of_phandle_args *iiospec)
+static int adc7_fwnode_xlate(struct iio_dev *indio_dev,
+			     const struct fwnode_reference_args *iiospec)
 {
 	struct adc5_chip *adc = iio_priv(indio_dev);
 	int i, v_channel;
@@ -481,12 +481,12 @@ static int adc7_read_raw(struct iio_dev *indio_dev,
 
 static const struct iio_info adc5_info = {
 	.read_raw = adc5_read_raw,
-	.of_xlate = adc5_of_xlate,
+	.fwnode_xlate = adc5_fwnode_xlate,
 };
 
 static const struct iio_info adc7_info = {
 	.read_raw = adc7_read_raw,
-	.of_xlate = adc7_of_xlate,
+	.fwnode_xlate = adc7_fwnode_xlate,
 };
 
 struct adc5_channels {
@@ -611,18 +611,18 @@ static const struct adc5_channels adc5_chans_rev2[ADC5_MAX_CHANNEL] = {
 					SCALE_HW_CALIB_THERM_100K_PULLUP)
 };
 
-static int adc5_get_dt_channel_data(struct adc5_chip *adc,
+static int adc5_get_fw_channel_data(struct adc5_chip *adc,
 				    struct adc5_channel_prop *prop,
-				    struct device_node *node,
+				    struct fwnode_handle *fwnode,
 				    const struct adc5_data *data)
 {
-	const char *name = node->name, *channel_name;
+	const char *name = fwnode_get_name(fwnode), *channel_name;
 	u32 chan, value, varr[2];
 	u32 sid = 0;
 	int ret;
 	struct device *dev = adc->dev;
 
-	ret = of_property_read_u32(node, "reg", &chan);
+	ret = fwnode_property_read_u32(fwnode, "reg", &chan);
 	if (ret) {
 		dev_err(dev, "invalid channel number %s\n", name);
 		return ret;
@@ -647,15 +647,13 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 	prop->channel = chan;
 	prop->sid = sid;
 
-	channel_name = of_get_property(node,
-				"label", NULL) ? : node->name;
-	if (!channel_name) {
-		dev_err(dev, "Invalid channel name\n");
-		return -EINVAL;
-	}
+	ret = fwnode_property_read_string(fwnode, "label", &channel_name);
+	if (ret)
+		channel_name = name;
+
 	prop->datasheet_name = channel_name;
 
-	ret = of_property_read_u32(node, "qcom,decimation", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,decimation", &value);
 	if (!ret) {
 		ret = qcom_adc5_decimation_from_dt(value, data->decimation);
 		if (ret < 0) {
@@ -668,7 +666,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->decimation = ADC5_DECIMATION_DEFAULT;
 	}
 
-	ret = of_property_read_u32_array(node, "qcom,pre-scaling", varr, 2);
+	ret = fwnode_property_read_u32_array(fwnode, "qcom,pre-scaling", varr, 2);
 	if (!ret) {
 		ret = qcom_adc5_prescaling_from_dt(varr[0], varr[1]);
 		if (ret < 0) {
@@ -682,7 +680,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 			adc->data->adc_chans[prop->channel].prescale_index;
 	}
 
-	ret = of_property_read_u32(node, "qcom,hw-settle-time", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,hw-settle-time", &value);
 	if (!ret) {
 		u8 dig_version[2];
 
@@ -713,7 +711,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->hw_settle_time = VADC_DEF_HW_SETTLE_TIME;
 	}
 
-	ret = of_property_read_u32(node, "qcom,avg-samples", &value);
+	ret = fwnode_property_read_u32(fwnode, "qcom,avg-samples", &value);
 	if (!ret) {
 		ret = qcom_adc5_avg_samples_from_dt(value);
 		if (ret < 0) {
@@ -726,7 +724,7 @@ static int adc5_get_dt_channel_data(struct adc5_chip *adc,
 		prop->avg_samples = VADC_DEF_AVG_SAMPLES;
 	}
 
-	if (of_property_read_bool(node, "qcom,ratiometric"))
+	if (fwnode_property_read_bool(fwnode, "qcom,ratiometric"))
 		prop->cal_method = ADC5_RATIOMETRIC_CAL;
 	else
 		prop->cal_method = ADC5_ABSOLUTE_CAL;
@@ -801,16 +799,16 @@ static const struct of_device_id adc5_match_table[] = {
 };
 MODULE_DEVICE_TABLE(of, adc5_match_table);
 
-static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
+static int adc5_get_fw_data(struct adc5_chip *adc)
 {
 	const struct adc5_channels *adc_chan;
 	struct iio_chan_spec *iio_chan;
 	struct adc5_channel_prop prop, *chan_props;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	unsigned int index = 0;
 	int ret;
 
-	adc->nchannels = of_get_available_child_count(node);
+	adc->nchannels = device_get_child_node_count(adc->dev);
 	if (!adc->nchannels)
 		return -EINVAL;
 
@@ -826,14 +824,14 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
 
 	chan_props = adc->chan_props;
 	iio_chan = adc->iio_chans;
-	adc->data = of_device_get_match_data(adc->dev);
+	adc->data = device_get_match_data(adc->dev);
 	if (!adc->data)
 		adc->data = &adc5_data_pmic;
 
-	for_each_available_child_of_node(node, child) {
-		ret = adc5_get_dt_channel_data(adc, &prop, child, adc->data);
+	device_for_each_child_node(adc->dev, child) {
+		ret = adc5_get_fw_channel_data(adc, &prop, child, adc->data);
 		if (ret) {
-			of_node_put(child);
+			fwnode_handle_put(child);
 			return ret;
 		}
 
@@ -858,7 +856,6 @@ static int adc5_get_dt_data(struct adc5_chip *adc, struct device_node *node)
 
 static int adc5_probe(struct platform_device *pdev)
 {
-	struct device_node *node = pdev->dev.of_node;
 	struct device *dev = &pdev->dev;
 	struct iio_dev *indio_dev;
 	struct adc5_chip *adc;
@@ -870,7 +867,7 @@ static int adc5_probe(struct platform_device *pdev)
 	if (!regmap)
 		return -ENODEV;
 
-	ret = of_property_read_u32(node, "reg", &reg);
+	ret = device_property_read_u32(dev, "reg", &reg);
 	if (ret < 0)
 		return ret;
 
@@ -886,7 +883,7 @@ static int adc5_probe(struct platform_device *pdev)
 	init_completion(&adc->complete);
 	mutex_init(&adc->lock);
 
-	ret = adc5_get_dt_data(adc, node);
+	ret = adc5_get_fw_data(adc);
 	if (ret) {
 		dev_err(dev, "adc get dt data failed\n");
 		return ret;
-- 
2.36.1


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

* [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
 1 file changed, 70 insertions(+), 58 deletions(-)

diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index a68ecbda6480..87acef31ace1 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -21,11 +21,11 @@
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/nvmem-consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/property.h>
 
 #include "stm32-adc-core.h"
 
@@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
 	return ret;
 }
 
-static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
-			      const struct of_phandle_args *iiospec)
+static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
+				  const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
@@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
 	.hwfifo_set_watermark = stm32_adc_set_watermark,
 	.update_scan_mode = stm32_adc_update_scan_mode,
 	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
-	.of_xlate = stm32_adc_of_xlate,
+	.fwnode_xlate = stm32_adc_fwnode_xlate,
 };
 
 static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
@@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
 	{},
 };
 
-static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
+static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
 {
-	struct device_node *node = indio_dev->dev.of_node;
+	struct device *dev = &indio_dev->dev;
 	struct stm32_adc *adc = iio_priv(indio_dev);
 	unsigned int i;
 	u32 res;
 
-	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
+	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
 		res = adc->cfg->adc_info->resolutions[0];
 
 	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
@@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
 
 static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
 {
-	struct device_node *node = indio_dev->dev.of_node;
+	struct device *dev = &indio_dev->dev;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	int num_channels = 0, ret;
 
-	ret = of_property_count_u32_elems(node, "st,adc-channels");
+	ret = device_property_count_u32(dev, "st,adc-channels");
 	if (ret > adc_info->max_channels) {
 		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
 		return -EINVAL;
@@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
 		num_channels += ret;
 	}
 
-	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
-					      sizeof(struct stm32_adc_diff_channel));
-	if (ret > adc_info->max_channels) {
+	ret = device_property_count_u32(dev, "st,adc-diff-channels");
+	if ((ret / 2) > adc_info->max_channels) {
 		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
 		return -EINVAL;
-	} else if (ret > 0) {
-		adc->num_diff = ret;
-		num_channels += ret;
+	} else if ((ret / 2) > 0) {
+		adc->num_diff = ret / 2;
+		num_channels += ret / 2;
 	}
 
 	/* Optional sample time is provided either for each, or all channels */
-	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
+	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
 	if (ret > 1 && ret != num_channels) {
 		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
 		return -EINVAL;
@@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
 
 static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
 				      struct stm32_adc *adc,
-				      struct iio_chan_spec *channels)
+				      struct iio_chan_spec *channels,
+				      int nchans)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
+	struct device *dev = &indio_dev->dev;
 	u32 num_diff = adc->num_diff;
 	int size = num_diff * sizeof(*diff) / sizeof(u32);
-	int scan_index = 0, val, ret, i;
-	struct property *prop;
-	const __be32 *cur;
-	u32 smp = 0;
+	int scan_index = 0, ret, i;
+	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
 
 	if (num_diff) {
-		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
-						 (u32 *)diff, size);
+		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
+						     (u32 *)diff, size);
 		if (ret) {
 			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
 			return ret;
@@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
 		}
 	}
 
-	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
-		if (val >= adc_info->max_channels) {
-			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
+	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
+					     nchans);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < nchans; i++) {
+		if (chans[i] >= adc_info->max_channels) {
+			dev_err(&indio_dev->dev, "Invalid channel %d\n",
+				chans[i]);
 			return -EINVAL;
 		}
 
 		/* Channel can't be configured both as single-ended & diff */
 		for (i = 0; i < num_diff; i++) {
-			if (val == diff[i].vinp) {
-				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
+			if (chans[i] == diff[i].vinp) {
+				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
 				return -EINVAL;
 			}
 		}
-		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
-					0, scan_index, false);
+		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
+					chans[i], 0, scan_index, false);
 		scan_index++;
 	}
 
+	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
+	if (nsmps) {
+		if (nsmps >= nchans)
+			nsmps = nchans;
+
+		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
+						     smps, nsmps);
+		if (ret)
+			return ret;
+	}
+
 	for (i = 0; i < scan_index; i++) {
 		/*
-		 * Using of_property_read_u32_index(), smp value will only be
-		 * modified if valid u32 value can be decoded. This allows to
-		 * get either no value, 1 shared value for all indexes, or one
-		 * value per channel.
+		 * This check is used with the above logic so that smp value
+		 * will only be modified if valid u32 value can be decoded. This
+		 * allows to get either no value, 1 shared value for all indexes,
+		 * or one value per channel. The point is to have the same
+		 * behavior as 'of_property_read_u32_index()'.
 		 */
-		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
+		if (i < nsmps)
+			smp = smps[i];
 
 		/* Prepare sampling time settings */
 		stm32_adc_smpr_init(adc, channels[i].channel, smp);
@@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 				       struct stm32_adc *adc,
 				       struct iio_chan_spec *channels)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	const char *name;
 	int val, scan_index = 0, ret;
 	bool differential;
 	u32 vin[2];
 
-	for_each_available_child_of_node(node, child) {
-		ret = of_property_read_u32(child, "reg", &val);
+	device_for_each_child_node(&indio_dev->dev, child) {
+		ret = fwnode_property_read_u32(child, "reg", &val);
 		if (ret) {
 			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
 			goto err;
 		}
 
-		ret = of_property_read_string(child, "label", &name);
+		ret = fwnode_property_read_string(child, "label", &name);
 		/* label is optional */
 		if (!ret) {
 			if (strlen(name) >= STM32_ADC_CH_SZ) {
@@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 		}
 
 		differential = false;
-		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
+		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
 		/* diff-channels is optional */
 		if (!ret) {
 			differential = true;
@@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
 					vin[1], scan_index, differential);
 
-		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
+		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
 		/* st,min-sample-time-ns is optional */
 		if (!ret) {
 			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
@@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 	return scan_index;
 
 err:
-	of_node_put(child);
+	fwnode_handle_put(child);
 
 	return ret;
 }
 
-static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
+static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	struct stm32_adc *adc = iio_priv(indio_dev);
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	struct iio_chan_spec *channels;
@@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
 	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
 		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
 
-	num_channels = of_get_available_child_count(node);
+	num_channels = device_get_child_node_count(&indio_dev->dev);
 	/* If no channels have been found, fallback to channels legacy properties. */
 	if (!num_channels) {
 		legacy = true;
@@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
 		return -ENOMEM;
 
 	if (legacy)
-		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
+		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
+						 num_channels);
 	else
 		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
 	if (ret < 0)
@@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	bool timestamping = false;
 	int ret;
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
 	if (!indio_dev)
 		return -ENOMEM;
@@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	adc->common = dev_get_drvdata(pdev->dev.parent);
 	spin_lock_init(&adc->lock);
 	init_completion(&adc->completion);
-	adc->cfg = (const struct stm32_adc_cfg *)
-		of_match_device(dev->driver->of_match_table, dev)->data;
+	adc->cfg = device_get_match_data(dev);
 
 	indio_dev->name = dev_name(&pdev->dev);
-	indio_dev->dev.of_node = pdev->dev.of_node;
+	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
 	indio_dev->info = &stm32_adc_iio_info;
 	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
 
 	platform_set_drvdata(pdev, indio_dev);
 
-	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
+	ret = device_property_read_u32(dev, "reg", &adc->offset);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "missing reg property\n");
 		return -EINVAL;
@@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
 		}
 	}
 
-	ret = stm32_adc_of_get_resolution(indio_dev);
+	ret = stm32_adc_fw_get_resolution(indio_dev);
 	if (ret < 0)
 		return ret;
 
@@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
 		timestamping = true;
 	}
 
-	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
+	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
 	if (ret < 0)
 		goto err_dma_disable;
 
-- 
2.36.1


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

* [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
 1 file changed, 70 insertions(+), 58 deletions(-)

diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index a68ecbda6480..87acef31ace1 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -21,11 +21,11 @@
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/nvmem-consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/property.h>
 
 #include "stm32-adc-core.h"
 
@@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
 	return ret;
 }
 
-static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
-			      const struct of_phandle_args *iiospec)
+static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
+				  const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
@@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
 	.hwfifo_set_watermark = stm32_adc_set_watermark,
 	.update_scan_mode = stm32_adc_update_scan_mode,
 	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
-	.of_xlate = stm32_adc_of_xlate,
+	.fwnode_xlate = stm32_adc_fwnode_xlate,
 };
 
 static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
@@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
 	{},
 };
 
-static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
+static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
 {
-	struct device_node *node = indio_dev->dev.of_node;
+	struct device *dev = &indio_dev->dev;
 	struct stm32_adc *adc = iio_priv(indio_dev);
 	unsigned int i;
 	u32 res;
 
-	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
+	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
 		res = adc->cfg->adc_info->resolutions[0];
 
 	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
@@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
 
 static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
 {
-	struct device_node *node = indio_dev->dev.of_node;
+	struct device *dev = &indio_dev->dev;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	int num_channels = 0, ret;
 
-	ret = of_property_count_u32_elems(node, "st,adc-channels");
+	ret = device_property_count_u32(dev, "st,adc-channels");
 	if (ret > adc_info->max_channels) {
 		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
 		return -EINVAL;
@@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
 		num_channels += ret;
 	}
 
-	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
-					      sizeof(struct stm32_adc_diff_channel));
-	if (ret > adc_info->max_channels) {
+	ret = device_property_count_u32(dev, "st,adc-diff-channels");
+	if ((ret / 2) > adc_info->max_channels) {
 		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
 		return -EINVAL;
-	} else if (ret > 0) {
-		adc->num_diff = ret;
-		num_channels += ret;
+	} else if ((ret / 2) > 0) {
+		adc->num_diff = ret / 2;
+		num_channels += ret / 2;
 	}
 
 	/* Optional sample time is provided either for each, or all channels */
-	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
+	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
 	if (ret > 1 && ret != num_channels) {
 		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
 		return -EINVAL;
@@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
 
 static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
 				      struct stm32_adc *adc,
-				      struct iio_chan_spec *channels)
+				      struct iio_chan_spec *channels,
+				      int nchans)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
+	struct device *dev = &indio_dev->dev;
 	u32 num_diff = adc->num_diff;
 	int size = num_diff * sizeof(*diff) / sizeof(u32);
-	int scan_index = 0, val, ret, i;
-	struct property *prop;
-	const __be32 *cur;
-	u32 smp = 0;
+	int scan_index = 0, ret, i;
+	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
 
 	if (num_diff) {
-		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
-						 (u32 *)diff, size);
+		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
+						     (u32 *)diff, size);
 		if (ret) {
 			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
 			return ret;
@@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
 		}
 	}
 
-	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
-		if (val >= adc_info->max_channels) {
-			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
+	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
+					     nchans);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < nchans; i++) {
+		if (chans[i] >= adc_info->max_channels) {
+			dev_err(&indio_dev->dev, "Invalid channel %d\n",
+				chans[i]);
 			return -EINVAL;
 		}
 
 		/* Channel can't be configured both as single-ended & diff */
 		for (i = 0; i < num_diff; i++) {
-			if (val == diff[i].vinp) {
-				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
+			if (chans[i] == diff[i].vinp) {
+				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
 				return -EINVAL;
 			}
 		}
-		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
-					0, scan_index, false);
+		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
+					chans[i], 0, scan_index, false);
 		scan_index++;
 	}
 
+	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
+	if (nsmps) {
+		if (nsmps >= nchans)
+			nsmps = nchans;
+
+		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
+						     smps, nsmps);
+		if (ret)
+			return ret;
+	}
+
 	for (i = 0; i < scan_index; i++) {
 		/*
-		 * Using of_property_read_u32_index(), smp value will only be
-		 * modified if valid u32 value can be decoded. This allows to
-		 * get either no value, 1 shared value for all indexes, or one
-		 * value per channel.
+		 * This check is used with the above logic so that smp value
+		 * will only be modified if valid u32 value can be decoded. This
+		 * allows to get either no value, 1 shared value for all indexes,
+		 * or one value per channel. The point is to have the same
+		 * behavior as 'of_property_read_u32_index()'.
 		 */
-		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
+		if (i < nsmps)
+			smp = smps[i];
 
 		/* Prepare sampling time settings */
 		stm32_adc_smpr_init(adc, channels[i].channel, smp);
@@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 				       struct stm32_adc *adc,
 				       struct iio_chan_spec *channels)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	const char *name;
 	int val, scan_index = 0, ret;
 	bool differential;
 	u32 vin[2];
 
-	for_each_available_child_of_node(node, child) {
-		ret = of_property_read_u32(child, "reg", &val);
+	device_for_each_child_node(&indio_dev->dev, child) {
+		ret = fwnode_property_read_u32(child, "reg", &val);
 		if (ret) {
 			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
 			goto err;
 		}
 
-		ret = of_property_read_string(child, "label", &name);
+		ret = fwnode_property_read_string(child, "label", &name);
 		/* label is optional */
 		if (!ret) {
 			if (strlen(name) >= STM32_ADC_CH_SZ) {
@@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 		}
 
 		differential = false;
-		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
+		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
 		/* diff-channels is optional */
 		if (!ret) {
 			differential = true;
@@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
 					vin[1], scan_index, differential);
 
-		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
+		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
 		/* st,min-sample-time-ns is optional */
 		if (!ret) {
 			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
@@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 	return scan_index;
 
 err:
-	of_node_put(child);
+	fwnode_handle_put(child);
 
 	return ret;
 }
 
-static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
+static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	struct stm32_adc *adc = iio_priv(indio_dev);
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	struct iio_chan_spec *channels;
@@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
 	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
 		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
 
-	num_channels = of_get_available_child_count(node);
+	num_channels = device_get_child_node_count(&indio_dev->dev);
 	/* If no channels have been found, fallback to channels legacy properties. */
 	if (!num_channels) {
 		legacy = true;
@@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
 		return -ENOMEM;
 
 	if (legacy)
-		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
+		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
+						 num_channels);
 	else
 		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
 	if (ret < 0)
@@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	bool timestamping = false;
 	int ret;
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
 	if (!indio_dev)
 		return -ENOMEM;
@@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	adc->common = dev_get_drvdata(pdev->dev.parent);
 	spin_lock_init(&adc->lock);
 	init_completion(&adc->completion);
-	adc->cfg = (const struct stm32_adc_cfg *)
-		of_match_device(dev->driver->of_match_table, dev)->data;
+	adc->cfg = device_get_match_data(dev);
 
 	indio_dev->name = dev_name(&pdev->dev);
-	indio_dev->dev.of_node = pdev->dev.of_node;
+	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
 	indio_dev->info = &stm32_adc_iio_info;
 	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
 
 	platform_set_drvdata(pdev, indio_dev);
 
-	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
+	ret = device_property_read_u32(dev, "reg", &adc->offset);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "missing reg property\n");
 		return -EINVAL;
@@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
 		}
 	}
 
-	ret = stm32_adc_of_get_resolution(indio_dev);
+	ret = stm32_adc_fw_get_resolution(indio_dev);
 	if (ret < 0)
 		return ret;
 
@@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
 		timestamping = true;
 	}
 
-	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
+	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
 	if (ret < 0)
 		goto err_dma_disable;
 
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier

Make the conversion to firmware agnostic device properties. As part of
the conversion the IIO inkern interface 'of_xlate()' is also converted to
'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
dependencies from IIO.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
 1 file changed, 70 insertions(+), 58 deletions(-)

diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
index a68ecbda6480..87acef31ace1 100644
--- a/drivers/iio/adc/stm32-adc.c
+++ b/drivers/iio/adc/stm32-adc.c
@@ -21,11 +21,11 @@
 #include <linux/io.h>
 #include <linux/iopoll.h>
 #include <linux/module.h>
+#include <linux/mod_devicetable.h>
 #include <linux/nvmem-consumer.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/property.h>
 
 #include "stm32-adc-core.h"
 
@@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
 	return ret;
 }
 
-static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
-			      const struct of_phandle_args *iiospec)
+static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
+				  const struct fwnode_reference_args *iiospec)
 {
 	int i;
 
@@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
 	.hwfifo_set_watermark = stm32_adc_set_watermark,
 	.update_scan_mode = stm32_adc_update_scan_mode,
 	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
-	.of_xlate = stm32_adc_of_xlate,
+	.fwnode_xlate = stm32_adc_fwnode_xlate,
 };
 
 static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
@@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
 	{},
 };
 
-static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
+static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
 {
-	struct device_node *node = indio_dev->dev.of_node;
+	struct device *dev = &indio_dev->dev;
 	struct stm32_adc *adc = iio_priv(indio_dev);
 	unsigned int i;
 	u32 res;
 
-	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
+	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
 		res = adc->cfg->adc_info->resolutions[0];
 
 	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
@@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
 
 static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
 {
-	struct device_node *node = indio_dev->dev.of_node;
+	struct device *dev = &indio_dev->dev;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	int num_channels = 0, ret;
 
-	ret = of_property_count_u32_elems(node, "st,adc-channels");
+	ret = device_property_count_u32(dev, "st,adc-channels");
 	if (ret > adc_info->max_channels) {
 		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
 		return -EINVAL;
@@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
 		num_channels += ret;
 	}
 
-	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
-					      sizeof(struct stm32_adc_diff_channel));
-	if (ret > adc_info->max_channels) {
+	ret = device_property_count_u32(dev, "st,adc-diff-channels");
+	if ((ret / 2) > adc_info->max_channels) {
 		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
 		return -EINVAL;
-	} else if (ret > 0) {
-		adc->num_diff = ret;
-		num_channels += ret;
+	} else if ((ret / 2) > 0) {
+		adc->num_diff = ret / 2;
+		num_channels += ret / 2;
 	}
 
 	/* Optional sample time is provided either for each, or all channels */
-	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
+	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
 	if (ret > 1 && ret != num_channels) {
 		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
 		return -EINVAL;
@@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
 
 static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
 				      struct stm32_adc *adc,
-				      struct iio_chan_spec *channels)
+				      struct iio_chan_spec *channels,
+				      int nchans)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
+	struct device *dev = &indio_dev->dev;
 	u32 num_diff = adc->num_diff;
 	int size = num_diff * sizeof(*diff) / sizeof(u32);
-	int scan_index = 0, val, ret, i;
-	struct property *prop;
-	const __be32 *cur;
-	u32 smp = 0;
+	int scan_index = 0, ret, i;
+	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
 
 	if (num_diff) {
-		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
-						 (u32 *)diff, size);
+		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
+						     (u32 *)diff, size);
 		if (ret) {
 			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
 			return ret;
@@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
 		}
 	}
 
-	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
-		if (val >= adc_info->max_channels) {
-			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
+	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
+					     nchans);
+	if (ret)
+		return ret;
+
+	for (i = 0; i < nchans; i++) {
+		if (chans[i] >= adc_info->max_channels) {
+			dev_err(&indio_dev->dev, "Invalid channel %d\n",
+				chans[i]);
 			return -EINVAL;
 		}
 
 		/* Channel can't be configured both as single-ended & diff */
 		for (i = 0; i < num_diff; i++) {
-			if (val == diff[i].vinp) {
-				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
+			if (chans[i] == diff[i].vinp) {
+				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
 				return -EINVAL;
 			}
 		}
-		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
-					0, scan_index, false);
+		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
+					chans[i], 0, scan_index, false);
 		scan_index++;
 	}
 
+	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
+	if (nsmps) {
+		if (nsmps >= nchans)
+			nsmps = nchans;
+
+		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
+						     smps, nsmps);
+		if (ret)
+			return ret;
+	}
+
 	for (i = 0; i < scan_index; i++) {
 		/*
-		 * Using of_property_read_u32_index(), smp value will only be
-		 * modified if valid u32 value can be decoded. This allows to
-		 * get either no value, 1 shared value for all indexes, or one
-		 * value per channel.
+		 * This check is used with the above logic so that smp value
+		 * will only be modified if valid u32 value can be decoded. This
+		 * allows to get either no value, 1 shared value for all indexes,
+		 * or one value per channel. The point is to have the same
+		 * behavior as 'of_property_read_u32_index()'.
 		 */
-		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
+		if (i < nsmps)
+			smp = smps[i];
 
 		/* Prepare sampling time settings */
 		stm32_adc_smpr_init(adc, channels[i].channel, smp);
@@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 				       struct stm32_adc *adc,
 				       struct iio_chan_spec *channels)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
-	struct device_node *child;
+	struct fwnode_handle *child;
 	const char *name;
 	int val, scan_index = 0, ret;
 	bool differential;
 	u32 vin[2];
 
-	for_each_available_child_of_node(node, child) {
-		ret = of_property_read_u32(child, "reg", &val);
+	device_for_each_child_node(&indio_dev->dev, child) {
+		ret = fwnode_property_read_u32(child, "reg", &val);
 		if (ret) {
 			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
 			goto err;
 		}
 
-		ret = of_property_read_string(child, "label", &name);
+		ret = fwnode_property_read_string(child, "label", &name);
 		/* label is optional */
 		if (!ret) {
 			if (strlen(name) >= STM32_ADC_CH_SZ) {
@@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 		}
 
 		differential = false;
-		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
+		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
 		/* diff-channels is optional */
 		if (!ret) {
 			differential = true;
@@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
 					vin[1], scan_index, differential);
 
-		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
+		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
 		/* st,min-sample-time-ns is optional */
 		if (!ret) {
 			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
@@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
 	return scan_index;
 
 err:
-	of_node_put(child);
+	fwnode_handle_put(child);
 
 	return ret;
 }
 
-static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
+static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
 {
-	struct device_node *node = indio_dev->dev.of_node;
 	struct stm32_adc *adc = iio_priv(indio_dev);
 	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
 	struct iio_chan_spec *channels;
@@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
 	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
 		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
 
-	num_channels = of_get_available_child_count(node);
+	num_channels = device_get_child_node_count(&indio_dev->dev);
 	/* If no channels have been found, fallback to channels legacy properties. */
 	if (!num_channels) {
 		legacy = true;
@@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
 		return -ENOMEM;
 
 	if (legacy)
-		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
+		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
+						 num_channels);
 	else
 		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
 	if (ret < 0)
@@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	bool timestamping = false;
 	int ret;
 
-	if (!pdev->dev.of_node)
-		return -ENODEV;
-
 	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
 	if (!indio_dev)
 		return -ENOMEM;
@@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
 	adc->common = dev_get_drvdata(pdev->dev.parent);
 	spin_lock_init(&adc->lock);
 	init_completion(&adc->completion);
-	adc->cfg = (const struct stm32_adc_cfg *)
-		of_match_device(dev->driver->of_match_table, dev)->data;
+	adc->cfg = device_get_match_data(dev);
 
 	indio_dev->name = dev_name(&pdev->dev);
-	indio_dev->dev.of_node = pdev->dev.of_node;
+	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
 	indio_dev->info = &stm32_adc_iio_info;
 	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
 
 	platform_set_drvdata(pdev, indio_dev);
 
-	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
+	ret = device_property_read_u32(dev, "reg", &adc->offset);
 	if (ret != 0) {
 		dev_err(&pdev->dev, "missing reg property\n");
 		return -EINVAL;
@@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
 		}
 	}
 
-	ret = stm32_adc_of_get_resolution(indio_dev);
+	ret = stm32_adc_fw_get_resolution(indio_dev);
 	if (ret < 0)
 		return ret;
 
@@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
 		timestamping = true;
 	}
 
-	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
+	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
 	if (ret < 0)
 		goto err_dma_disable;
 
-- 
2.36.1


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

* [PATCH 33/34] iio: inkern: remove OF dependencies
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Since all users of the OF dependendent API are now converted to use the
firmware agnostic alternative, we can drop OF dependencies from the IIO
in kernel interface.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c         | 25 +------------------------
 include/linux/iio/consumer.h | 10 ----------
 include/linux/iio/iio.h      |  3 ---
 3 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 1d519b0cacea..7eb536560ded 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -8,7 +8,6 @@
 #include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/iio-opaque.h>
@@ -148,26 +147,6 @@ static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
 	return iiospec->args[0];
 }
 
-/*
- * Simple helper to copy fwnode_reference_args into of_phandle_args so we
- * can pass it to of_xlate(). Ultimate goal is to drop this together with
- * of_xlate().
- */
-static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
-				const struct fwnode_reference_args *iiospec)
-{
-	struct of_phandle_args of_args;
-	unsigned int i;
-
-	of_args.args_count = iiospec->nargs;
-	of_args.np = to_of_node(iiospec->fwnode);
-
-	for (i = 0; i < MAX_PHANDLE_ARGS; i++)
-		of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
-
-	return indio_dev->info->of_xlate(indio_dev, &of_args);
-}
-
 static int __fwnode_iio_channel_get(struct iio_channel *channel,
 				    struct fwnode_handle *fwnode, int index)
 {
@@ -191,9 +170,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
-	if (indio_dev->info->of_xlate)
-		index = __fwnode_to_of_xlate(indio_dev, &iiospec);
-	else if (indio_dev->info->fwnode_xlate)
+	if (indio_dev->info->fwnode_xlate)
 		index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
 	else
 		index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index a96a714b5fdc..6802596b017c 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -9,12 +9,10 @@
 
 #include <linux/types.h>
 #include <linux/iio/types.h>
-#include <linux/of.h>
 
 struct iio_dev;
 struct iio_chan_spec;
 struct device;
-struct device_node;
 struct fwnode_handle;
 
 /**
@@ -129,14 +127,6 @@ struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
 							struct fwnode_handle *fwnode,
 							const char *consumer_channel);
 
-static inline struct iio_channel
-*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
-				 const char *consumer_channel)
-{
-	return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
-						   consumer_channel);
-}
-
 struct iio_cb_buffer;
 /**
  * iio_channel_get_all_cb() - register callback for triggered capture
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 494abb63406e..7093be1531c1 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -17,7 +17,6 @@
  * Currently assumes nano seconds.
  */
 
-struct of_phandle_args;
 struct fwnode_reference_args;
 
 enum iio_shared_by {
@@ -511,8 +510,6 @@ struct iio_info {
 	int (*debugfs_reg_access)(struct iio_dev *indio_dev,
 				  unsigned reg, unsigned writeval,
 				  unsigned *readval);
-	int (*of_xlate)(struct iio_dev *indio_dev,
-			const struct of_phandle_args *iiospec);
 	int (*fwnode_xlate)(struct iio_dev *indio_dev,
 			    const struct fwnode_reference_args *iiospec);
 	int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
-- 
2.36.1


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

* [PATCH 33/34] iio: inkern: remove OF dependencies
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Since all users of the OF dependendent API are now converted to use the
firmware agnostic alternative, we can drop OF dependencies from the IIO
in kernel interface.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c         | 25 +------------------------
 include/linux/iio/consumer.h | 10 ----------
 include/linux/iio/iio.h      |  3 ---
 3 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 1d519b0cacea..7eb536560ded 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -8,7 +8,6 @@
 #include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/iio-opaque.h>
@@ -148,26 +147,6 @@ static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
 	return iiospec->args[0];
 }
 
-/*
- * Simple helper to copy fwnode_reference_args into of_phandle_args so we
- * can pass it to of_xlate(). Ultimate goal is to drop this together with
- * of_xlate().
- */
-static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
-				const struct fwnode_reference_args *iiospec)
-{
-	struct of_phandle_args of_args;
-	unsigned int i;
-
-	of_args.args_count = iiospec->nargs;
-	of_args.np = to_of_node(iiospec->fwnode);
-
-	for (i = 0; i < MAX_PHANDLE_ARGS; i++)
-		of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
-
-	return indio_dev->info->of_xlate(indio_dev, &of_args);
-}
-
 static int __fwnode_iio_channel_get(struct iio_channel *channel,
 				    struct fwnode_handle *fwnode, int index)
 {
@@ -191,9 +170,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
-	if (indio_dev->info->of_xlate)
-		index = __fwnode_to_of_xlate(indio_dev, &iiospec);
-	else if (indio_dev->info->fwnode_xlate)
+	if (indio_dev->info->fwnode_xlate)
 		index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
 	else
 		index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index a96a714b5fdc..6802596b017c 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -9,12 +9,10 @@
 
 #include <linux/types.h>
 #include <linux/iio/types.h>
-#include <linux/of.h>
 
 struct iio_dev;
 struct iio_chan_spec;
 struct device;
-struct device_node;
 struct fwnode_handle;
 
 /**
@@ -129,14 +127,6 @@ struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
 							struct fwnode_handle *fwnode,
 							const char *consumer_channel);
 
-static inline struct iio_channel
-*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
-				 const char *consumer_channel)
-{
-	return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
-						   consumer_channel);
-}
-
 struct iio_cb_buffer;
 /**
  * iio_channel_get_all_cb() - register callback for triggered capture
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 494abb63406e..7093be1531c1 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -17,7 +17,6 @@
  * Currently assumes nano seconds.
  */
 
-struct of_phandle_args;
 struct fwnode_reference_args;
 
 enum iio_shared_by {
@@ -511,8 +510,6 @@ struct iio_info {
 	int (*debugfs_reg_access)(struct iio_dev *indio_dev,
 				  unsigned reg, unsigned writeval,
 				  unsigned *readval);
-	int (*of_xlate)(struct iio_dev *indio_dev,
-			const struct of_phandle_args *iiospec);
 	int (*fwnode_xlate)(struct iio_dev *indio_dev,
 			    const struct fwnode_reference_args *iiospec);
 	int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 33/34] iio: inkern: remove OF dependencies
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Since all users of the OF dependendent API are now converted to use the
firmware agnostic alternative, we can drop OF dependencies from the IIO
in kernel interface.

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c         | 25 +------------------------
 include/linux/iio/consumer.h | 10 ----------
 include/linux/iio/iio.h      |  3 ---
 3 files changed, 1 insertion(+), 37 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 1d519b0cacea..7eb536560ded 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -8,7 +8,6 @@
 #include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/mutex.h>
-#include <linux/of.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/iio-opaque.h>
@@ -148,26 +147,6 @@ static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
 	return iiospec->args[0];
 }
 
-/*
- * Simple helper to copy fwnode_reference_args into of_phandle_args so we
- * can pass it to of_xlate(). Ultimate goal is to drop this together with
- * of_xlate().
- */
-static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
-				const struct fwnode_reference_args *iiospec)
-{
-	struct of_phandle_args of_args;
-	unsigned int i;
-
-	of_args.args_count = iiospec->nargs;
-	of_args.np = to_of_node(iiospec->fwnode);
-
-	for (i = 0; i < MAX_PHANDLE_ARGS; i++)
-		of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
-
-	return indio_dev->info->of_xlate(indio_dev, &of_args);
-}
-
 static int __fwnode_iio_channel_get(struct iio_channel *channel,
 				    struct fwnode_handle *fwnode, int index)
 {
@@ -191,9 +170,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
 
 	indio_dev = dev_to_iio_dev(idev);
 	channel->indio_dev = indio_dev;
-	if (indio_dev->info->of_xlate)
-		index = __fwnode_to_of_xlate(indio_dev, &iiospec);
-	else if (indio_dev->info->fwnode_xlate)
+	if (indio_dev->info->fwnode_xlate)
 		index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
 	else
 		index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
index a96a714b5fdc..6802596b017c 100644
--- a/include/linux/iio/consumer.h
+++ b/include/linux/iio/consumer.h
@@ -9,12 +9,10 @@
 
 #include <linux/types.h>
 #include <linux/iio/types.h>
-#include <linux/of.h>
 
 struct iio_dev;
 struct iio_chan_spec;
 struct device;
-struct device_node;
 struct fwnode_handle;
 
 /**
@@ -129,14 +127,6 @@ struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
 							struct fwnode_handle *fwnode,
 							const char *consumer_channel);
 
-static inline struct iio_channel
-*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
-				 const char *consumer_channel)
-{
-	return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
-						   consumer_channel);
-}
-
 struct iio_cb_buffer;
 /**
  * iio_channel_get_all_cb() - register callback for triggered capture
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 494abb63406e..7093be1531c1 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -17,7 +17,6 @@
  * Currently assumes nano seconds.
  */
 
-struct of_phandle_args;
 struct fwnode_reference_args;
 
 enum iio_shared_by {
@@ -511,8 +510,6 @@ struct iio_info {
 	int (*debugfs_reg_access)(struct iio_dev *indio_dev,
 				  unsigned reg, unsigned writeval,
 				  unsigned *readval);
-	int (*of_xlate)(struct iio_dev *indio_dev,
-			const struct of_phandle_args *iiospec);
 	int (*fwnode_xlate)(struct iio_dev *indio_dev,
 			    const struct fwnode_reference_args *iiospec);
 	int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
-- 
2.36.1


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

* [PATCH 34/34] iio: inkern: fix coding style warnings
  2022-06-10  8:45 ` Nuno Sá
  (?)
@ 2022-06-10  8:45   ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Just cosmetics. No functional change intended...

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 64 ++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 7eb536560ded..526519cefcb9 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
 	int i = 0, ret = 0;
 	struct iio_map_internal *mapi;
 
-	if (maps == NULL)
+	if (!maps)
 		return 0;
 
 	mutex_lock(&iio_map_list_lock);
-	while (maps[i].consumer_dev_name != NULL) {
+	while (!maps[i].consumer_dev_name) {
 		mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
-		if (mapi == NULL) {
+		if (!mapi) {
 			ret = -ENOMEM;
 			goto error_ret;
 		}
@@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
 }
 EXPORT_SYMBOL_GPL(iio_map_array_register);
 
-
 /*
  * Remove all map entries associated with the given iio device
  */
@@ -163,7 +162,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
 
 	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
 			       iio_dev_node_match);
-	if (idev == NULL) {
+	if (!idev) {
 		fwnode_handle_put(iiospec.fwnode);
 		return -EPROBE_DEFER;
 	}
@@ -196,7 +195,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
 		return ERR_PTR(-EINVAL);
 
 	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-	if (channel == NULL)
+	if (!channel)
 		return ERR_PTR(-ENOMEM);
 
 	err = __fwnode_iio_channel_get(channel, fwnode, index);
@@ -293,7 +292,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
-	if (chans == NULL)
+	if (!chans)
 		return ERR_PTR(-ENOMEM);
 
 	/* Search for FW matches */
@@ -318,7 +317,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 	struct iio_channel *channel;
 	int err;
 
-	if (name == NULL && channel_name == NULL)
+	if (!name && !channel_name)
 		return ERR_PTR(-ENODEV);
 
 	/* first find matching entry the channel map */
@@ -333,11 +332,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 		break;
 	}
 	mutex_unlock(&iio_map_list_lock);
-	if (c == NULL)
+	if (!c)
 		return ERR_PTR(-ENODEV);
 
 	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-	if (channel == NULL) {
+	if (!channel) {
 		err = -ENOMEM;
 		goto error_no_mem;
 	}
@@ -349,7 +348,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 			iio_chan_spec_from_name(channel->indio_dev,
 						c->map->adc_channel_label);
 
-		if (channel->channel == NULL) {
+		if (!channel->channel) {
 			err = -EINVAL;
 			goto error_no_chan;
 		}
@@ -441,7 +440,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 	int mapind = 0;
 	int i, ret;
 
-	if (dev == NULL)
+	if (!dev)
 		return ERR_PTR(-EINVAL);
 
 	chans = fwnode_iio_channel_get_all(dev);
@@ -465,7 +464,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
-	if (chans == NULL) {
+	if (!chans) {
 		ret = -ENOMEM;
 		goto error_ret;
 	}
@@ -479,7 +478,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 		chans[mapind].channel =
 			iio_chan_spec_from_name(chans[mapind].indio_dev,
 						c->map->adc_channel_label);
-		if (chans[mapind].channel == NULL) {
+		if (!chans[mapind].channel) {
 			ret = -EINVAL;
 			goto error_free_chans;
 		}
@@ -541,14 +540,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev)
 EXPORT_SYMBOL_GPL(devm_iio_channel_get_all);
 
 static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
-	enum iio_chan_info_enum info)
+			    enum iio_chan_info_enum info)
 {
 	int unused;
 	int vals[INDIO_MAX_RAW_ELEMENTS];
 	int ret;
 	int val_len = 2;
 
-	if (val2 == NULL)
+	if (!val2)
 		val2 = &unused;
 
 	if (!iio_channel_has_info(chan->channel, info))
@@ -560,9 +559,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
 					vals, &val_len, info);
 		*val = vals[0];
 		*val2 = vals[1];
-	} else
+	} else {
 		ret = chan->indio_dev->info->read_raw(chan->indio_dev,
 					chan->channel, val, val2, info);
+	}
 
 	return ret;
 }
@@ -573,7 +573,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val)
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -592,7 +592,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -606,7 +606,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
 EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
 
 static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
-	int raw, int *processed, unsigned int scale)
+						 int raw, int *processed,
+						 unsigned int scale)
 {
 	int scale_type, scale_val, scale_val2;
 	int offset_type, offset_val, offset_val2;
@@ -639,7 +640,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
 	}
 
 	scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
-					IIO_CHAN_INFO_SCALE);
+				      IIO_CHAN_INFO_SCALE);
 	if (scale_type < 0) {
 		/*
 		 * If no channel scaling is available apply consumer scale to
@@ -684,19 +685,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
 }
 
 int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
-	int *processed, unsigned int scale)
+				 int *processed, unsigned int scale)
 {
 	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
 
 	ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed,
-							scale);
+						    scale);
 err_unlock:
 	mutex_unlock(&iio_dev_opaque->info_exist_lock);
 
@@ -711,7 +712,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -737,7 +738,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -815,7 +816,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan,
 	int type;
 
 	ret = iio_read_avail_channel_attribute(chan, vals, &type, length,
-					 IIO_CHAN_INFO_RAW);
+					       IIO_CHAN_INFO_RAW);
 
 	if (ret >= 0 && type != IIO_VAL_INT)
 		/* raw values are assumed to be IIO_VAL_INT */
@@ -899,7 +900,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
 	/* Need to verify underlying driver has not gone away */
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -926,7 +927,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -960,9 +961,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
 }
 EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
 
-static const struct iio_chan_spec_ext_info *iio_lookup_ext_info(
-						const struct iio_channel *chan,
-						const char *attr)
+static const struct iio_chan_spec_ext_info *
+iio_lookup_ext_info(const struct iio_channel *chan, const char *attr)
 {
 	const struct iio_chan_spec_ext_info *ext_info;
 
-- 
2.36.1


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

* [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Cai Huoqing, Benjamin Fair, Jishnu Prakash, Linus Walleij,
	Lars-Peter Clausen, Alexandre Torgue, Amit Kucheria, Andy Gross,
	Michael Hennerich, Haibo Chen, Benson Leung, Rafael J. Wysocki,
	Alexandre Belloni, Christophe Branchereau, Patrick Venture,
	Arnd Bergmann, Nancy Yuen, Sascha Hauer, Daniel Lezcano,
	Gwendal Grignou, Saravanan Sekar, Tali Perry, Maxime Coquelin,
	Paul Cercueil, Thara Gopinath, Avi Fishman, Lorenzo Bianconi,
	Claudiu Beznea, Pengutronix Kernel Team, Andy Shevchenko,
	Fabrice Gasnier, Matthias Brugger, Tomer Maimon, Bjorn Andersson,
	Nicolas Ferre, Jonathan Cameron, Zhang Rui, Shawn Guo,
	Guenter Roeck, Fabio Estevam, Olivier Moysan, Eugen Hristev,
	Miquel Raynal

Just cosmetics. No functional change intended...

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 64 ++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 7eb536560ded..526519cefcb9 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
 	int i = 0, ret = 0;
 	struct iio_map_internal *mapi;
 
-	if (maps == NULL)
+	if (!maps)
 		return 0;
 
 	mutex_lock(&iio_map_list_lock);
-	while (maps[i].consumer_dev_name != NULL) {
+	while (!maps[i].consumer_dev_name) {
 		mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
-		if (mapi == NULL) {
+		if (!mapi) {
 			ret = -ENOMEM;
 			goto error_ret;
 		}
@@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
 }
 EXPORT_SYMBOL_GPL(iio_map_array_register);
 
-
 /*
  * Remove all map entries associated with the given iio device
  */
@@ -163,7 +162,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
 
 	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
 			       iio_dev_node_match);
-	if (idev == NULL) {
+	if (!idev) {
 		fwnode_handle_put(iiospec.fwnode);
 		return -EPROBE_DEFER;
 	}
@@ -196,7 +195,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
 		return ERR_PTR(-EINVAL);
 
 	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-	if (channel == NULL)
+	if (!channel)
 		return ERR_PTR(-ENOMEM);
 
 	err = __fwnode_iio_channel_get(channel, fwnode, index);
@@ -293,7 +292,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
-	if (chans == NULL)
+	if (!chans)
 		return ERR_PTR(-ENOMEM);
 
 	/* Search for FW matches */
@@ -318,7 +317,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 	struct iio_channel *channel;
 	int err;
 
-	if (name == NULL && channel_name == NULL)
+	if (!name && !channel_name)
 		return ERR_PTR(-ENODEV);
 
 	/* first find matching entry the channel map */
@@ -333,11 +332,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 		break;
 	}
 	mutex_unlock(&iio_map_list_lock);
-	if (c == NULL)
+	if (!c)
 		return ERR_PTR(-ENODEV);
 
 	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-	if (channel == NULL) {
+	if (!channel) {
 		err = -ENOMEM;
 		goto error_no_mem;
 	}
@@ -349,7 +348,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 			iio_chan_spec_from_name(channel->indio_dev,
 						c->map->adc_channel_label);
 
-		if (channel->channel == NULL) {
+		if (!channel->channel) {
 			err = -EINVAL;
 			goto error_no_chan;
 		}
@@ -441,7 +440,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 	int mapind = 0;
 	int i, ret;
 
-	if (dev == NULL)
+	if (!dev)
 		return ERR_PTR(-EINVAL);
 
 	chans = fwnode_iio_channel_get_all(dev);
@@ -465,7 +464,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
-	if (chans == NULL) {
+	if (!chans) {
 		ret = -ENOMEM;
 		goto error_ret;
 	}
@@ -479,7 +478,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 		chans[mapind].channel =
 			iio_chan_spec_from_name(chans[mapind].indio_dev,
 						c->map->adc_channel_label);
-		if (chans[mapind].channel == NULL) {
+		if (!chans[mapind].channel) {
 			ret = -EINVAL;
 			goto error_free_chans;
 		}
@@ -541,14 +540,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev)
 EXPORT_SYMBOL_GPL(devm_iio_channel_get_all);
 
 static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
-	enum iio_chan_info_enum info)
+			    enum iio_chan_info_enum info)
 {
 	int unused;
 	int vals[INDIO_MAX_RAW_ELEMENTS];
 	int ret;
 	int val_len = 2;
 
-	if (val2 == NULL)
+	if (!val2)
 		val2 = &unused;
 
 	if (!iio_channel_has_info(chan->channel, info))
@@ -560,9 +559,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
 					vals, &val_len, info);
 		*val = vals[0];
 		*val2 = vals[1];
-	} else
+	} else {
 		ret = chan->indio_dev->info->read_raw(chan->indio_dev,
 					chan->channel, val, val2, info);
+	}
 
 	return ret;
 }
@@ -573,7 +573,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val)
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -592,7 +592,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -606,7 +606,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
 EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
 
 static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
-	int raw, int *processed, unsigned int scale)
+						 int raw, int *processed,
+						 unsigned int scale)
 {
 	int scale_type, scale_val, scale_val2;
 	int offset_type, offset_val, offset_val2;
@@ -639,7 +640,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
 	}
 
 	scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
-					IIO_CHAN_INFO_SCALE);
+				      IIO_CHAN_INFO_SCALE);
 	if (scale_type < 0) {
 		/*
 		 * If no channel scaling is available apply consumer scale to
@@ -684,19 +685,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
 }
 
 int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
-	int *processed, unsigned int scale)
+				 int *processed, unsigned int scale)
 {
 	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
 
 	ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed,
-							scale);
+						    scale);
 err_unlock:
 	mutex_unlock(&iio_dev_opaque->info_exist_lock);
 
@@ -711,7 +712,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -737,7 +738,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -815,7 +816,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan,
 	int type;
 
 	ret = iio_read_avail_channel_attribute(chan, vals, &type, length,
-					 IIO_CHAN_INFO_RAW);
+					       IIO_CHAN_INFO_RAW);
 
 	if (ret >= 0 && type != IIO_VAL_INT)
 		/* raw values are assumed to be IIO_VAL_INT */
@@ -899,7 +900,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
 	/* Need to verify underlying driver has not gone away */
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -926,7 +927,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -960,9 +961,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
 }
 EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
 
-static const struct iio_chan_spec_ext_info *iio_lookup_ext_info(
-						const struct iio_channel *chan,
-						const char *attr)
+static const struct iio_chan_spec_ext_info *
+iio_lookup_ext_info(const struct iio_channel *chan, const char *attr)
 {
 	const struct iio_chan_spec_ext_info *ext_info;
 
-- 
2.36.1


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-10  8:45   ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10  8:45 UTC (permalink / raw)
  To: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, Lars-Peter Clausen, Benjamin Fair,
	Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, Sascha Hauer,
	Fabrice Gasnier, Cai Huoqing, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture, Nicolas Ferre,
	Thara Gopinath, Arnd Bergmann, Maxime Coquelin, Eugen Hristev,
	Shawn Guo, Claudiu Beznea, Jonathan Cameron

Just cosmetics. No functional change intended...

Signed-off-by: Nuno Sá <nuno.sa@analog.com>
---
 drivers/iio/inkern.c | 64 ++++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 7eb536560ded..526519cefcb9 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
 	int i = 0, ret = 0;
 	struct iio_map_internal *mapi;
 
-	if (maps == NULL)
+	if (!maps)
 		return 0;
 
 	mutex_lock(&iio_map_list_lock);
-	while (maps[i].consumer_dev_name != NULL) {
+	while (!maps[i].consumer_dev_name) {
 		mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
-		if (mapi == NULL) {
+		if (!mapi) {
 			ret = -ENOMEM;
 			goto error_ret;
 		}
@@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
 }
 EXPORT_SYMBOL_GPL(iio_map_array_register);
 
-
 /*
  * Remove all map entries associated with the given iio device
  */
@@ -163,7 +162,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
 
 	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
 			       iio_dev_node_match);
-	if (idev == NULL) {
+	if (!idev) {
 		fwnode_handle_put(iiospec.fwnode);
 		return -EPROBE_DEFER;
 	}
@@ -196,7 +195,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
 		return ERR_PTR(-EINVAL);
 
 	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-	if (channel == NULL)
+	if (!channel)
 		return ERR_PTR(-ENOMEM);
 
 	err = __fwnode_iio_channel_get(channel, fwnode, index);
@@ -293,7 +292,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
-	if (chans == NULL)
+	if (!chans)
 		return ERR_PTR(-ENOMEM);
 
 	/* Search for FW matches */
@@ -318,7 +317,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 	struct iio_channel *channel;
 	int err;
 
-	if (name == NULL && channel_name == NULL)
+	if (!name && !channel_name)
 		return ERR_PTR(-ENODEV);
 
 	/* first find matching entry the channel map */
@@ -333,11 +332,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 		break;
 	}
 	mutex_unlock(&iio_map_list_lock);
-	if (c == NULL)
+	if (!c)
 		return ERR_PTR(-ENODEV);
 
 	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
-	if (channel == NULL) {
+	if (!channel) {
 		err = -ENOMEM;
 		goto error_no_mem;
 	}
@@ -349,7 +348,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
 			iio_chan_spec_from_name(channel->indio_dev,
 						c->map->adc_channel_label);
 
-		if (channel->channel == NULL) {
+		if (!channel->channel) {
 			err = -EINVAL;
 			goto error_no_chan;
 		}
@@ -441,7 +440,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 	int mapind = 0;
 	int i, ret;
 
-	if (dev == NULL)
+	if (!dev)
 		return ERR_PTR(-EINVAL);
 
 	chans = fwnode_iio_channel_get_all(dev);
@@ -465,7 +464,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 
 	/* NULL terminated array to save passing size */
 	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
-	if (chans == NULL) {
+	if (!chans) {
 		ret = -ENOMEM;
 		goto error_ret;
 	}
@@ -479,7 +478,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
 		chans[mapind].channel =
 			iio_chan_spec_from_name(chans[mapind].indio_dev,
 						c->map->adc_channel_label);
-		if (chans[mapind].channel == NULL) {
+		if (!chans[mapind].channel) {
 			ret = -EINVAL;
 			goto error_free_chans;
 		}
@@ -541,14 +540,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev)
 EXPORT_SYMBOL_GPL(devm_iio_channel_get_all);
 
 static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
-	enum iio_chan_info_enum info)
+			    enum iio_chan_info_enum info)
 {
 	int unused;
 	int vals[INDIO_MAX_RAW_ELEMENTS];
 	int ret;
 	int val_len = 2;
 
-	if (val2 == NULL)
+	if (!val2)
 		val2 = &unused;
 
 	if (!iio_channel_has_info(chan->channel, info))
@@ -560,9 +559,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
 					vals, &val_len, info);
 		*val = vals[0];
 		*val2 = vals[1];
-	} else
+	} else {
 		ret = chan->indio_dev->info->read_raw(chan->indio_dev,
 					chan->channel, val, val2, info);
+	}
 
 	return ret;
 }
@@ -573,7 +573,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val)
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -592,7 +592,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -606,7 +606,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
 EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
 
 static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
-	int raw, int *processed, unsigned int scale)
+						 int raw, int *processed,
+						 unsigned int scale)
 {
 	int scale_type, scale_val, scale_val2;
 	int offset_type, offset_val, offset_val2;
@@ -639,7 +640,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
 	}
 
 	scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
-					IIO_CHAN_INFO_SCALE);
+				      IIO_CHAN_INFO_SCALE);
 	if (scale_type < 0) {
 		/*
 		 * If no channel scaling is available apply consumer scale to
@@ -684,19 +685,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
 }
 
 int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
-	int *processed, unsigned int scale)
+				 int *processed, unsigned int scale)
 {
 	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
 
 	ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed,
-							scale);
+						    scale);
 err_unlock:
 	mutex_unlock(&iio_dev_opaque->info_exist_lock);
 
@@ -711,7 +712,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -737,7 +738,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -815,7 +816,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan,
 	int type;
 
 	ret = iio_read_avail_channel_attribute(chan, vals, &type, length,
-					 IIO_CHAN_INFO_RAW);
+					       IIO_CHAN_INFO_RAW);
 
 	if (ret >= 0 && type != IIO_VAL_INT)
 		/* raw values are assumed to be IIO_VAL_INT */
@@ -899,7 +900,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
 	/* Need to verify underlying driver has not gone away */
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -926,7 +927,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
 	int ret;
 
 	mutex_lock(&iio_dev_opaque->info_exist_lock);
-	if (chan->indio_dev->info == NULL) {
+	if (!chan->indio_dev->info) {
 		ret = -ENODEV;
 		goto err_unlock;
 	}
@@ -960,9 +961,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
 }
 EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
 
-static const struct iio_chan_spec_ext_info *iio_lookup_ext_info(
-						const struct iio_channel *chan,
-						const char *attr)
+static const struct iio_chan_spec_ext_info *
+iio_lookup_ext_info(const struct iio_channel *chan, const char *attr)
 {
 	const struct iio_chan_spec_ext_info *ext_info;
 
-- 
2.36.1


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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 14:45     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:45 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
>
> The ultimate goal is to actually drop of.h from iio.h.

...

>  #include <linux/mod_devicetable.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/of.h>

Ordering (from the context I don't see it's messed up already)

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
@ 2022-06-10 14:45     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:45 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
>
> The ultimate goal is to actually drop of.h from iio.h.

...

>  #include <linux/mod_devicetable.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
> +#include <linux/of.h>

Ordering (from the context I don't see it's messed up already)

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 14:47     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:47 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:47 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
>
> The ultimate goal is to actually drop of.h from iio.h.

...

>  #include <linux/irqreturn.h>
>  #include <linux/regmap.h>
>  #include <linux/bitfield.h>
> +#include <linux/property.h>

Yes, I see, but you can make life easier if you try to squeeze to the
most sorted part. I do not see full context, but here I would put it
before regmap.h.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
@ 2022-06-10 14:47     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:47 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:47 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
>
> The ultimate goal is to actually drop of.h from iio.h.

...

>  #include <linux/irqreturn.h>
>  #include <linux/regmap.h>
>  #include <linux/bitfield.h>
> +#include <linux/property.h>

Yes, I see, but you can make life easier if you try to squeeze to the
most sorted part. I do not see full context, but here I would put it
before regmap.h.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 00/34] make iio inkern interface firmware agnostic
  2022-06-10  8:45 ` Nuno Sá
@ 2022-06-10 14:48   ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:48 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:45 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> The main goal of this patchset is to convert the iio inkern interface to
> be firmware agnostic. Some previous discussion was done in here [1].
> Though something odd happened while sending the patches and the RFC
> actually never landed in the IIO list (hopefully now works):
>
> As suggested by Andy, the series can be seen in three blocks:
>
> 1) "Fix" all drivers that were relying on iio.h for specific header
> files (mainly of.h and mod_devicetable.h). After that we can drop
> of.h from iio.h and just forward declare what we need.
>
> 2) Move "most" of the IIO in kernel interface to FW API. At this point,
> there's still some OF dependent API in place so that users are not broken.
>
> 3) Move all users of the IIO in kernel interface to the FW API and with
> that, make IIO firmware agnostic.
>
> On 3), the qcom-spmi-adc-tm5.c driver was only converted to use the IIO
> API while on the IIO drivers a full driver conversion was done. The
> thermal one would be really non trivial as we would also need to touch the
> subsystem. On the IIO drivers, the conversions were mostly peacefull
> (apparently). Special care for the stm32-adc.c driver though as that one
> was far from being straight :).
>
> Lastly, this is only compile tested with allyesconfig for arm and arm64.
> While I surely can come up with some dummy devices to make sure I can still
> properly get IIO channels, having proper tested-by tags on platforms
> relying on this interface would be very appreciated (and I suspect Jonathan
> will require it).

For non-commented patches 1-19:
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

You may add it for the commented patches in the 1-19 range in case you
are going to address my comments.

> [1]: https://lore.kernel.org/linux-iio/20220604141925.129f0ffe@jic23-huawei/T/#mfd5ccd793841569182e4f831f2c46089b665c346
>
> Nuno Sá (34):
>   iio: adc: ad7606: explicitly add proper header files
>   iio: adc: ad7606_par: explicitly add proper header files
>   iio: adc: berlin2-adc: explicitly add proper header files
>   iio: adc: imx7d_adc: explicitly add proper header files
>   iio: adc: imx8qxp-adc: explicitly add proper header files
>   iio: adc: ingenic-adc: explicitly add proper header files
>   iio: adc: mp2629_adc: explicitly add proper header files
>   iio: adc: mt6360-adc: explicitly add proper header files
>   iio: adc: npcm_adc: explicitly add proper header files
>   iio: adc: rzg2l_adc: explicitly add proper header files
>   iio: common: cros_ec_lid_angle: explicitly add proper header files
>   iio: common: cros_ec_sensors: explicitly add proper header files
>   iio: dac: stm32-dac: explicitly add proper header files
>   iio: dac: vf610_dac: explicitly add proper header files
>   iio: humidity: hts221_buffer: explicitly add proper header files
>   iio: light: cros_ec_light_prox: explicitly add proper header files
>   iio: pressure: cros_ec_baro: explicitly add proper header files
>   iio: trigger: stm32-lptimer-trigger: explicitly add proper header
>     files
>   iio: core: drop of.h from iio.h
>   iio: inkern: only relase the device node when done with it
>   iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
>   iio: inkern: only return error codes in iio_channel_get_*() APIs
>   iio: inkern: split of_iio_channel_get_by_name()
>   iio: inkern: move to fwnode properties
>   thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
>   iio: adc: ingenic-adc: convert to IIO fwnode interface
>   iio: adc: ab8500-gpadc: convert to device properties
>   iio: adc: at91-sama5d2_adc: convert to device properties
>   iio: adc: qcom-pm8xxx-xoadc: convert to device properties
>   iio: adc: qcom-spmi-vadc: convert to device properties
>   iio: adc: qcom-spmi-adc5: convert to device properties
>   iio: adc: stm32-adc: convert to device properties
>   iio: inkern: remove OF dependencies
>   iio: inkern: fix coding style warnings
>
>  drivers/iio/adc/ab8500-gpadc.c                |  27 +-
>  drivers/iio/adc/ad7606.c                      |   1 +
>  drivers/iio/adc/ad7606_par.c                  |   1 +
>  drivers/iio/adc/at91-sama5d2_adc.c            |  30 +--
>  drivers/iio/adc/berlin2-adc.c                 |   2 +
>  drivers/iio/adc/imx7d_adc.c                   |   1 +
>  drivers/iio/adc/imx8qxp-adc.c                 |   1 +
>  drivers/iio/adc/ingenic-adc.c                 |   9 +-
>  drivers/iio/adc/mp2629_adc.c                  |   1 +
>  drivers/iio/adc/mt6360-adc.c                  |   1 +
>  drivers/iio/adc/npcm_adc.c                    |   1 +
>  drivers/iio/adc/qcom-pm8xxx-xoadc.c           |  58 ++---
>  drivers/iio/adc/qcom-spmi-adc5.c              |  63 +++--
>  drivers/iio/adc/qcom-spmi-vadc.c              |  44 ++--
>  drivers/iio/adc/rzg2l_adc.c                   |   1 +
>  drivers/iio/adc/stm32-adc.c                   | 128 +++++-----
>  .../cros_ec_sensors/cros_ec_lid_angle.c       |   1 +
>  .../common/cros_ec_sensors/cros_ec_sensors.c  |   1 +
>  drivers/iio/dac/stm32-dac.c                   |   2 +
>  drivers/iio/dac/vf610_dac.c                   |   1 +
>  drivers/iio/humidity/hts221_buffer.c          |   1 +
>  drivers/iio/inkern.c                          | 241 +++++++++---------
>  drivers/iio/light/cros_ec_light_prox.c        |   1 +
>  drivers/iio/pressure/cros_ec_baro.c           |   1 +
>  drivers/iio/trigger/stm32-lptimer-trigger.c   |   1 +
>  drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |   3 +-
>  include/linux/iio/consumer.h                  |  28 +-
>  include/linux/iio/iio.h                       |   9 +-
>  28 files changed, 347 insertions(+), 312 deletions(-)
>
> --
> 2.36.1
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 00/34] make iio inkern interface firmware agnostic
@ 2022-06-10 14:48   ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:48 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:45 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> The main goal of this patchset is to convert the iio inkern interface to
> be firmware agnostic. Some previous discussion was done in here [1].
> Though something odd happened while sending the patches and the RFC
> actually never landed in the IIO list (hopefully now works):
>
> As suggested by Andy, the series can be seen in three blocks:
>
> 1) "Fix" all drivers that were relying on iio.h for specific header
> files (mainly of.h and mod_devicetable.h). After that we can drop
> of.h from iio.h and just forward declare what we need.
>
> 2) Move "most" of the IIO in kernel interface to FW API. At this point,
> there's still some OF dependent API in place so that users are not broken.
>
> 3) Move all users of the IIO in kernel interface to the FW API and with
> that, make IIO firmware agnostic.
>
> On 3), the qcom-spmi-adc-tm5.c driver was only converted to use the IIO
> API while on the IIO drivers a full driver conversion was done. The
> thermal one would be really non trivial as we would also need to touch the
> subsystem. On the IIO drivers, the conversions were mostly peacefull
> (apparently). Special care for the stm32-adc.c driver though as that one
> was far from being straight :).
>
> Lastly, this is only compile tested with allyesconfig for arm and arm64.
> While I surely can come up with some dummy devices to make sure I can still
> properly get IIO channels, having proper tested-by tags on platforms
> relying on this interface would be very appreciated (and I suspect Jonathan
> will require it).

For non-commented patches 1-19:
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

You may add it for the commented patches in the 1-19 range in case you
are going to address my comments.

> [1]: https://lore.kernel.org/linux-iio/20220604141925.129f0ffe@jic23-huawei/T/#mfd5ccd793841569182e4f831f2c46089b665c346
>
> Nuno Sá (34):
>   iio: adc: ad7606: explicitly add proper header files
>   iio: adc: ad7606_par: explicitly add proper header files
>   iio: adc: berlin2-adc: explicitly add proper header files
>   iio: adc: imx7d_adc: explicitly add proper header files
>   iio: adc: imx8qxp-adc: explicitly add proper header files
>   iio: adc: ingenic-adc: explicitly add proper header files
>   iio: adc: mp2629_adc: explicitly add proper header files
>   iio: adc: mt6360-adc: explicitly add proper header files
>   iio: adc: npcm_adc: explicitly add proper header files
>   iio: adc: rzg2l_adc: explicitly add proper header files
>   iio: common: cros_ec_lid_angle: explicitly add proper header files
>   iio: common: cros_ec_sensors: explicitly add proper header files
>   iio: dac: stm32-dac: explicitly add proper header files
>   iio: dac: vf610_dac: explicitly add proper header files
>   iio: humidity: hts221_buffer: explicitly add proper header files
>   iio: light: cros_ec_light_prox: explicitly add proper header files
>   iio: pressure: cros_ec_baro: explicitly add proper header files
>   iio: trigger: stm32-lptimer-trigger: explicitly add proper header
>     files
>   iio: core: drop of.h from iio.h
>   iio: inkern: only relase the device node when done with it
>   iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
>   iio: inkern: only return error codes in iio_channel_get_*() APIs
>   iio: inkern: split of_iio_channel_get_by_name()
>   iio: inkern: move to fwnode properties
>   thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
>   iio: adc: ingenic-adc: convert to IIO fwnode interface
>   iio: adc: ab8500-gpadc: convert to device properties
>   iio: adc: at91-sama5d2_adc: convert to device properties
>   iio: adc: qcom-pm8xxx-xoadc: convert to device properties
>   iio: adc: qcom-spmi-vadc: convert to device properties
>   iio: adc: qcom-spmi-adc5: convert to device properties
>   iio: adc: stm32-adc: convert to device properties
>   iio: inkern: remove OF dependencies
>   iio: inkern: fix coding style warnings
>
>  drivers/iio/adc/ab8500-gpadc.c                |  27 +-
>  drivers/iio/adc/ad7606.c                      |   1 +
>  drivers/iio/adc/ad7606_par.c                  |   1 +
>  drivers/iio/adc/at91-sama5d2_adc.c            |  30 +--
>  drivers/iio/adc/berlin2-adc.c                 |   2 +
>  drivers/iio/adc/imx7d_adc.c                   |   1 +
>  drivers/iio/adc/imx8qxp-adc.c                 |   1 +
>  drivers/iio/adc/ingenic-adc.c                 |   9 +-
>  drivers/iio/adc/mp2629_adc.c                  |   1 +
>  drivers/iio/adc/mt6360-adc.c                  |   1 +
>  drivers/iio/adc/npcm_adc.c                    |   1 +
>  drivers/iio/adc/qcom-pm8xxx-xoadc.c           |  58 ++---
>  drivers/iio/adc/qcom-spmi-adc5.c              |  63 +++--
>  drivers/iio/adc/qcom-spmi-vadc.c              |  44 ++--
>  drivers/iio/adc/rzg2l_adc.c                   |   1 +
>  drivers/iio/adc/stm32-adc.c                   | 128 +++++-----
>  .../cros_ec_sensors/cros_ec_lid_angle.c       |   1 +
>  .../common/cros_ec_sensors/cros_ec_sensors.c  |   1 +
>  drivers/iio/dac/stm32-dac.c                   |   2 +
>  drivers/iio/dac/vf610_dac.c                   |   1 +
>  drivers/iio/humidity/hts221_buffer.c          |   1 +
>  drivers/iio/inkern.c                          | 241 +++++++++---------
>  drivers/iio/light/cros_ec_light_prox.c        |   1 +
>  drivers/iio/pressure/cros_ec_baro.c           |   1 +
>  drivers/iio/trigger/stm32-lptimer-trigger.c   |   1 +
>  drivers/thermal/qcom/qcom-spmi-adc-tm5.c      |   3 +-
>  include/linux/iio/consumer.h                  |  28 +-
>  include/linux/iio/iio.h                       |   9 +-
>  28 files changed, 347 insertions(+), 312 deletions(-)
>
> --
> 2.36.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 14:56     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:56 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> 'of_node_put()' can potentially release the memory pointed to by
> 'iiospec.np' which would leave us with an invalid pointer (and we would
> still pass it in 'of_xlate()'). As such, we can only release the node
> after we are done with it.

The question you should answer in the commit message is the following:
"Can an OF node, attached to a struct device, be gone before the
device itself?" If it so, then patch is good, otherwise there is no
point in this patch in the first place.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-10 14:56     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:56 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> 'of_node_put()' can potentially release the memory pointed to by
> 'iiospec.np' which would leave us with an invalid pointer (and we would
> still pass it in 'of_xlate()'). As such, we can only release the node
> after we are done with it.

The question you should answer in the commit message is the following:
"Can an OF node, attached to a struct device, be gone before the
device itself?" If it so, then patch is good, otherwise there is no
point in this patch in the first place.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 21/34] iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 14:56     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:56 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> of_iio_channel_get_by_name() can either return NULL or an error pointer
> so that only doing IS_ERR() is not enough. Fix it by checking the NULL
> pointer case and return -ENODEV in that case. Note this is done like this
> so that users of the function (which only check for error pointers) do
> not need to be changed. This is not ideal since we are losing error codes
> and as such, in a follow up change, things will be unified so that
> of_iio_channel_get_by_name() only returns error codes.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Fixes: 6e39b145cef7 ("iio: provide of_iio_channel_get_by_name() and devm_ version it")
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 9d87057794fc..87fd2a0d44f2 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -412,6 +412,8 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
>         channel = of_iio_channel_get_by_name(np, channel_name);
>         if (IS_ERR(channel))
>                 return channel;
> +       if (!channel)
> +               return ERR_PTR(-ENODEV);
>
>         ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
>         if (ret)
> --
> 2.36.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 21/34] iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
@ 2022-06-10 14:56     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 14:56 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> of_iio_channel_get_by_name() can either return NULL or an error pointer
> so that only doing IS_ERR() is not enough. Fix it by checking the NULL
> pointer case and return -ENODEV in that case. Note this is done like this
> so that users of the function (which only check for error pointers) do
> not need to be changed. This is not ideal since we are losing error codes
> and as such, in a follow up change, things will be unified so that
> of_iio_channel_get_by_name() only returns error codes.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Fixes: 6e39b145cef7 ("iio: provide of_iio_channel_get_by_name() and devm_ version it")
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 9d87057794fc..87fd2a0d44f2 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -412,6 +412,8 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
>         channel = of_iio_channel_get_by_name(np, channel_name);
>         if (IS_ERR(channel))
>                 return channel;
> +       if (!channel)
> +               return ERR_PTR(-ENODEV);
>
>         ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
>         if (ret)
> --
> 2.36.1
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 15:05     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:05 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
> returning a mix of NULL and error pointers being NULL the way to
> "notify" that we should do a "system" lookup for channels. This make
> it very confusing and prone to errors as commit dbbccf7c20bf
> ("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
> proves. On top of this, patterns like 'if (channel != NULL) return channel'
> were being used where channel could actually be an error code which
> makes the code hard to read.

...

>                 np = np->parent;
>                 if (np && !of_get_property(np, "io-channel-ranges", NULL))
> -                       return NULL;
> +                       return chan;

Shouldn't it return a dedicated error code and not some arbitrary one?
It may be I missed something and chan has a correct error code in this
case...

...

> +       if (nummaps == 0)       /* return -ENODEV to search map table */

Comment is superfluous, the next line is self-explaining.

> +               return ERR_PTR(-ENODEV);

...

> -               if (channel != NULL)
> +               if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)

Btw, in the GPIO library we have a macro or inliner (don't remember)
that represents such a conditional.
Perhaps make it (if it's a macro) global, or introduce an inline in IIO?

Okay, it's here:
https://elixir.bootlin.com/linux/v5.19-rc1/source/drivers/gpio/gpiolib.h#L179

It's similar, but not the same, so just play with an idea to introduce
something in this file, maybe it's worth doing this, maybe not.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-10 15:05     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:05 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
> returning a mix of NULL and error pointers being NULL the way to
> "notify" that we should do a "system" lookup for channels. This make
> it very confusing and prone to errors as commit dbbccf7c20bf
> ("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
> proves. On top of this, patterns like 'if (channel != NULL) return channel'
> were being used where channel could actually be an error code which
> makes the code hard to read.

...

>                 np = np->parent;
>                 if (np && !of_get_property(np, "io-channel-ranges", NULL))
> -                       return NULL;
> +                       return chan;

Shouldn't it return a dedicated error code and not some arbitrary one?
It may be I missed something and chan has a correct error code in this
case...

...

> +       if (nummaps == 0)       /* return -ENODEV to search map table */

Comment is superfluous, the next line is self-explaining.

> +               return ERR_PTR(-ENODEV);

...

> -               if (channel != NULL)
> +               if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)

Btw, in the GPIO library we have a macro or inliner (don't remember)
that represents such a conditional.
Perhaps make it (if it's a macro) global, or introduce an inline in IIO?

Okay, it's here:
https://elixir.bootlin.com/linux/v5.19-rc1/source/drivers/gpio/gpiolib.h#L179

It's similar, but not the same, so just play with an idea to introduce
something in this file, maybe it's worth doing this, maybe not.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 23/34] iio: inkern: split of_iio_channel_get_by_name()
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 15:07     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:07 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> This change splits of_iio_channel_get_by_name() so that it decouples
> looking for channels in the current node from looking in it's parents
> nodes. This will be helpful when moving to fwnode properties where we
> need to release the handles when looking for channels in parent's nodes.
>
> No functional change intended...

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 69 ++++++++++++++++++++++++++++----------------
>  1 file changed, 44 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 31d9c122199a..dde47324b826 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -211,44 +211,63 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>         return ERR_PTR(err);
>  }
>
> +struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
> +                                                const char *name,
> +                                                bool *parent_lookup)
> +{
> +       struct iio_channel *chan;
> +       int index = 0;
> +
> +       /*
> +        * For named iio channels, first look up the name in the
> +        * "io-channel-names" property.  If it cannot be found, the
> +        * index will be an error code, and of_iio_channel_get()
> +        * will fail.
> +        */
> +       if (name)
> +               index = of_property_match_string(np, "io-channel-names", name);
> +
> +       chan = of_iio_channel_get(np, index);
> +       if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
> +               *parent_lookup = false;
> +       } else if (name && index >= 0) {
> +               pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
> +                      np, name ? name : "", index);
> +               *parent_lookup = false;
> +       }
> +
> +       return chan;
> +}
> +
>  struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>                                                const char *name)
>  {
>         struct iio_channel *chan;
> +       bool parent_lookup = true;
>
>         /* Walk up the tree of devices looking for a matching iio channel */
> +       chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> +       if (!parent_lookup)
> +               return chan;
> +
> +       /*
> +        * No matching IIO channel found on this node.
> +        * If the parent node has a "io-channel-ranges" property,
> +        * then we can try one of its channels.
> +        */
> +       np = np->parent;
>         while (np) {
> -               int index = 0;
> -
> -               /*
> -                * For named iio channels, first look up the name in the
> -                * "io-channel-names" property.  If it cannot be found, the
> -                * index will be an error code, and of_iio_channel_get()
> -                * will fail.
> -                */
> -               if (name)
> -                       index = of_property_match_string(np, "io-channel-names",
> -                                                        name);
> -               chan = of_iio_channel_get(np, index);
> -               if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
> +               if (!of_get_property(np, "io-channel-ranges", NULL))
>                         return chan;
> -               if (name && index >= 0) {
> -                       pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
> -                               np, name ? name : "", index);
> +
> +               chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> +               if (!parent_lookup)
>                         return chan;
> -               }
>
> -               /*
> -                * No matching IIO channel found on this node.
> -                * If the parent node has a "io-channel-ranges" property,
> -                * then we can try one of its channels.
> -                */
>                 np = np->parent;
> -               if (np && !of_get_property(np, "io-channel-ranges", NULL))
> -                       return chan;
>         }
>
> -       return ERR_PTR(-ENODEV);
> +       return chan;
>  }
>  EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
>
> --
> 2.36.1
>


-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 23/34] iio: inkern: split of_iio_channel_get_by_name()
@ 2022-06-10 15:07     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:07 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> This change splits of_iio_channel_get_by_name() so that it decouples
> looking for channels in the current node from looking in it's parents
> nodes. This will be helpful when moving to fwnode properties where we
> need to release the handles when looking for channels in parent's nodes.
>
> No functional change intended...

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 69 ++++++++++++++++++++++++++++----------------
>  1 file changed, 44 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 31d9c122199a..dde47324b826 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -211,44 +211,63 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>         return ERR_PTR(err);
>  }
>
> +struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
> +                                                const char *name,
> +                                                bool *parent_lookup)
> +{
> +       struct iio_channel *chan;
> +       int index = 0;
> +
> +       /*
> +        * For named iio channels, first look up the name in the
> +        * "io-channel-names" property.  If it cannot be found, the
> +        * index will be an error code, and of_iio_channel_get()
> +        * will fail.
> +        */
> +       if (name)
> +               index = of_property_match_string(np, "io-channel-names", name);
> +
> +       chan = of_iio_channel_get(np, index);
> +       if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
> +               *parent_lookup = false;
> +       } else if (name && index >= 0) {
> +               pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
> +                      np, name ? name : "", index);
> +               *parent_lookup = false;
> +       }
> +
> +       return chan;
> +}
> +
>  struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>                                                const char *name)
>  {
>         struct iio_channel *chan;
> +       bool parent_lookup = true;
>
>         /* Walk up the tree of devices looking for a matching iio channel */
> +       chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> +       if (!parent_lookup)
> +               return chan;
> +
> +       /*
> +        * No matching IIO channel found on this node.
> +        * If the parent node has a "io-channel-ranges" property,
> +        * then we can try one of its channels.
> +        */
> +       np = np->parent;
>         while (np) {
> -               int index = 0;
> -
> -               /*
> -                * For named iio channels, first look up the name in the
> -                * "io-channel-names" property.  If it cannot be found, the
> -                * index will be an error code, and of_iio_channel_get()
> -                * will fail.
> -                */
> -               if (name)
> -                       index = of_property_match_string(np, "io-channel-names",
> -                                                        name);
> -               chan = of_iio_channel_get(np, index);
> -               if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
> +               if (!of_get_property(np, "io-channel-ranges", NULL))
>                         return chan;
> -               if (name && index >= 0) {
> -                       pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
> -                               np, name ? name : "", index);
> +
> +               chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> +               if (!parent_lookup)
>                         return chan;
> -               }
>
> -               /*
> -                * No matching IIO channel found on this node.
> -                * If the parent node has a "io-channel-ranges" property,
> -                * then we can try one of its channels.
> -                */
>                 np = np->parent;
> -               if (np && !of_get_property(np, "io-channel-ranges", NULL))
> -                       return chan;
>         }
>
> -       return ERR_PTR(-ENODEV);
> +       return chan;
>  }
>  EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
>
> --
> 2.36.1
>


-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 15:19     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:19 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> This moves the IIO in kernel interface to use fwnode properties and thus
> be firmware agnostic.
>
> Note that the interface is still not firmware agnostic. At this point we
> have both OF and fwnode interfaces so that we don't break any user. On
> top of this we also want to have a per driver conversion and that is the
> main reason we have both of_xlate() and fwnode_xlate() support.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Thanks!

A few nit-picks below, though.

> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c         | 145 +++++++++++++++++++----------------
>  include/linux/iio/consumer.h |  36 +++++----
>  include/linux/iio/iio.h      |   5 ++
>  3 files changed, 105 insertions(+), 81 deletions(-)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index dde47324b826..1d519b0cacea 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -5,6 +5,7 @@
>   */
>  #include <linux/err.h>
>  #include <linux/export.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>  #include <linux/mutex.h>
>  #include <linux/of.h>
> @@ -117,15 +118,13 @@ static const struct iio_chan_spec
>         return chan;
>  }
>
> -#ifdef CONFIG_OF
> -
>  static int iio_dev_node_match(struct device *dev, const void *data)
>  {
> -       return dev->of_node == data && dev->type == &iio_device_type;
> +       return device_match_fwnode(dev, data) && dev->type == &iio_device_type;
>  }
>
>  /**
> - * __of_iio_simple_xlate - translate iiospec to the IIO channel index
> + * __fwnode_iio_simple_xlate - translate iiospec to the IIO channel index
>   * @indio_dev: pointer to the iio_dev structure
>   * @iiospec:   IIO specifier as found in the device tree
>   *
> @@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device *dev, const void *data)
>   * whether IIO index is less than num_channels (that is specified in the
>   * iio_dev).
>   */
> -static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
> -                               const struct of_phandle_args *iiospec)
> +static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
> +                                    const struct fwnode_reference_args *iiospec)
>  {
> -       if (!iiospec->args_count)
> +       if (!iiospec->nargs)
>                 return 0;
>
>         if (iiospec->args[0] >= indio_dev->num_channels) {
> -               dev_err(&indio_dev->dev, "invalid channel index %u\n",
> +               dev_err(&indio_dev->dev, "invalid channel index %llu\n",
>                         iiospec->args[0]);
>                 return -EINVAL;
>         }
> @@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
>         return iiospec->args[0];
>  }
>
> -static int __of_iio_channel_get(struct iio_channel *channel,
> -                               struct device_node *np, int index)
> +/*
> + * Simple helper to copy fwnode_reference_args into of_phandle_args so we
> + * can pass it to of_xlate(). Ultimate goal is to drop this together with
> + * of_xlate().
> + */
> +static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
> +                               const struct fwnode_reference_args *iiospec)
> +{
> +       struct of_phandle_args of_args;
> +       unsigned int i;
> +
> +       of_args.args_count = iiospec->nargs;
> +       of_args.np = to_of_node(iiospec->fwnode);
> +
> +       for (i = 0; i < MAX_PHANDLE_ARGS; i++)
> +               of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
> +
> +       return indio_dev->info->of_xlate(indio_dev, &of_args);
> +}

Ah, now I realized that it's a bit more complicated than just to_of_node() :-)

> +static int __fwnode_iio_channel_get(struct iio_channel *channel,
> +                                   struct fwnode_handle *fwnode, int index)
>  {
>         struct device *idev;
>         struct iio_dev *indio_dev;
>         int err;
> -       struct of_phandle_args iiospec;
> +       struct fwnode_reference_args iiospec;

At the same point you can move it up in the block to make a long line first.

> -       err = of_parse_phandle_with_args(np, "io-channels",
> -                                        "#io-channel-cells",
> -                                        index, &iiospec);
> +       err = fwnode_property_get_reference_args(fwnode, "io-channels",
> +                                                "#io-channel-cells", 0,
> +                                                index, &iiospec);
>         if (err)
>                 return err;
>
> -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
>                                iio_dev_node_match);

Wondering if this
https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
can be utilized (yes, I noticed iio_device_type above).

>         if (idev == NULL) {
> -               of_node_put(iiospec.np);
> +               fwnode_handle_put(iiospec.fwnode);
>                 return -EPROBE_DEFER;
>         }
>
>         indio_dev = dev_to_iio_dev(idev);
>         channel->indio_dev = indio_dev;
>         if (indio_dev->info->of_xlate)
> -               index = indio_dev->info->of_xlate(indio_dev, &iiospec);
> +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> +       else if (indio_dev->info->fwnode_xlate)
> +               index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
>         else
> -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> -       of_node_put(iiospec.np);
> +               index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
> +       fwnode_handle_put(iiospec.fwnode);
>         if (index < 0)
>                 goto err_put;
>         channel->channel = &indio_dev->channels[index];
> @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct iio_channel *channel,
>         return index;
>  }
>
> -static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
> +static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
> +                                                 int index)
>  {
>         struct iio_channel *channel;
>         int err;
> @@ -200,7 +222,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>         if (channel == NULL)
>                 return ERR_PTR(-ENOMEM);
>
> -       err = __of_iio_channel_get(channel, np, index);
> +       err = __fwnode_iio_channel_get(channel, fwnode, index);
>         if (err)
>                 goto err_free_channel;
>
> @@ -211,9 +233,9 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>         return ERR_PTR(err);
>  }
>
> -struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
> -                                                const char *name,
> -                                                bool *parent_lookup)
> +struct iio_channel *
> +__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode, const char *name,
> +                                bool *parent_lookup)
>  {
>         struct iio_channel *chan;
>         int index = 0;
> @@ -221,32 +243,34 @@ struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
>         /*
>          * For named iio channels, first look up the name in the
>          * "io-channel-names" property.  If it cannot be found, the
> -        * index will be an error code, and of_iio_channel_get()
> +        * index will be an error code, and fwnode_iio_channel_get()
>          * will fail.
>          */
>         if (name)
> -               index = of_property_match_string(np, "io-channel-names", name);
> +               index = fwnode_property_match_string(fwnode, "io-channel-names",
> +                                                    name);
>
> -       chan = of_iio_channel_get(np, index);
> +       chan = fwnode_iio_channel_get(fwnode, index);
>         if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
>                 *parent_lookup = false;
>         } else if (name && index >= 0) {
> -               pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
> -                      np, name ? name : "", index);
> +               pr_err("ERROR: could not get IIO channel %pfw:%s(%i)\n",
> +                      fwnode, name ? name : "", index);

Since you are touching this line can you switch to name ?: "" and
possibly move some parameters to the above line?

>                 *parent_lookup = false;
>         }
>
>         return chan;
>  }
>
> -struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
> -                                              const char *name)
> +struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
> +                                                  const char *name)
>  {
>         struct iio_channel *chan;
> +       struct fwnode_handle *parent;
>         bool parent_lookup = true;
>
>         /* Walk up the tree of devices looking for a matching iio channel */
> -       chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> +       chan = __fwnode_iio_channel_get_by_name(fwnode, name, &parent_lookup);
>         if (!parent_lookup)
>                 return chan;
>
> @@ -255,33 +279,34 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>          * If the parent node has a "io-channel-ranges" property,
>          * then we can try one of its channels.
>          */
> -       np = np->parent;
> -       while (np) {
> -               if (!of_get_property(np, "io-channel-ranges", NULL))
> +       fwnode_for_each_parent_node(fwnode, parent) {
> +               if (!fwnode_property_present(parent, "io-channel-ranges")) {
> +                       fwnode_handle_put(parent);
>                         return chan;

break; ?

(Yes, I understand pros and cons of each variant, up to you)

> +               }
>
> -               chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> -               if (!parent_lookup)
> +               chan = __fwnode_iio_channel_get_by_name(parent, name, &parent_lookup);
> +               if (!parent_lookup) {
> +                       fwnode_handle_put(parent);
>                         return chan;

Ditto.

> -               np = np->parent;
> +               }
>         }
>
>         return chan;
>  }
> -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);

Wondering if we may move this to the IIO namespace.

> -static struct iio_channel *of_iio_channel_get_all(struct device *dev)
> +static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
>  {
> +       struct fwnode_handle *fwnode = dev_fwnode(dev);
>         struct iio_channel *chans;
>         int i, mapind, nummaps = 0;
>         int ret;
>
>         do {
> -               ret = of_parse_phandle_with_args(dev->of_node,
> -                                                "io-channels",
> -                                                "#io-channel-cells",
> -                                                nummaps, NULL);
> +               ret = fwnode_property_get_reference_args(fwnode, "io-channels",
> +                                                        "#io-channel-cells", 0,
> +                                                        nummaps, NULL);
>                 if (ret < 0)
>                         break;
>         } while (++nummaps);
> @@ -294,10 +319,9 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>         if (chans == NULL)
>                 return ERR_PTR(-ENOMEM);
>
> -       /* Search for OF matches */
> +       /* Search for FW matches */
>         for (mapind = 0; mapind < nummaps; mapind++) {
> -               ret = __of_iio_channel_get(&chans[mapind], dev->of_node,
> -                                          mapind);
> +               ret = __fwnode_iio_channel_get(&chans[mapind], fwnode, mapind);
>                 if (ret)
>                         goto error_free_chans;
>         }
> @@ -310,15 +334,6 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>         return ERR_PTR(ret);
>  }
>
> -#else /* CONFIG_OF */
> -
> -static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
> -{
> -       return ERR_PTR(-ENODEV);
> -}
> -
> -#endif /* CONFIG_OF */
> -
>  static struct iio_channel *iio_channel_get_sys(const char *name,
>                                                const char *channel_name)
>  {
> @@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct device *dev,
>         struct iio_channel *channel;
>
>         if (dev) {
> -               channel = of_iio_channel_get_by_name(dev->of_node,
> -                                                    channel_name);
> +               channel = fwnode_iio_channel_get_by_name(dev_fwnode(dev),
> +                                                        channel_name);
>                 if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
>                         return channel;
>         }
> @@ -421,14 +436,14 @@ struct iio_channel *devm_iio_channel_get(struct device *dev,
>  }
>  EXPORT_SYMBOL_GPL(devm_iio_channel_get);
>
> -struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
> -                                                   struct device_node *np,
> -                                                   const char *channel_name)
> +struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
> +                                                       struct fwnode_handle *fwnode,
> +                                                       const char *channel_name)
>  {
>         struct iio_channel *channel;
>         int ret;
>
> -       channel = of_iio_channel_get_by_name(np, channel_name);
> +       channel = fwnode_iio_channel_get_by_name(fwnode, channel_name);
>         if (IS_ERR(channel))
>                 return channel;
>
> @@ -438,7 +453,7 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
>
>         return channel;
>  }
> -EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
> +EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
>
>  struct iio_channel *iio_channel_get_all(struct device *dev)
>  {
> @@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>         if (dev == NULL)
>                 return ERR_PTR(-EINVAL);
>
> -       chans = of_iio_channel_get_all(dev);
> +       chans = fwnode_iio_channel_get_all(dev);
>         if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
>                 return chans;
>
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index 5fa5957586cf..a96a714b5fdc 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -9,11 +9,13 @@
>
>  #include <linux/types.h>
>  #include <linux/iio/types.h>

> +#include <linux/of.h>

Ordering. IIO has special meaning here, that's why it's last.

>  struct iio_dev;
>  struct iio_chan_spec;
>  struct device;
>  struct device_node;
> +struct fwnode_handle;
>
>  /**
>   * struct iio_channel - everything needed for a consumer to use a channel
> @@ -99,26 +101,20 @@ void iio_channel_release_all(struct iio_channel *chan);
>  struct iio_channel *devm_iio_channel_get_all(struct device *dev);
>
>  /**
> - * of_iio_channel_get_by_name() - get description of all that is needed to access channel.
> - * @np:                        Pointer to consumer device tree node
> + * fwnode_iio_channel_get_by_name() - get description of all that is needed to access channel.
> + * @fwnode:            Pointer to consumer Firmware node
>   * @consumer_channel:  Unique name to identify the channel on the consumer
>   *                     side. This typically describes the channels use within
>   *                     the consumer. E.g. 'battery_voltage'
>   */
> -#ifdef CONFIG_OF
> -struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, const char *name);
> -#else
> -static inline struct iio_channel *
> -of_iio_channel_get_by_name(struct device_node *np, const char *name)
> -{
> -       return NULL;
> -}
> -#endif
> +struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
> +                                                  const char *name);
>
>  /**
> - * devm_of_iio_channel_get_by_name() - Resource managed version of of_iio_channel_get_by_name().
> + * devm_fwnode_iio_channel_get_by_name() - Resource managed version of
> + *                                        fwnode_iio_channel_get_by_name().
>   * @dev:               Pointer to consumer device.
> - * @np:                        Pointer to consumer device tree node
> + * @fwnode:            Pointer to consumer Firmware node
>   * @consumer_channel:  Unique name to identify the channel on the consumer
>   *                     side. This typically describes the channels use within
>   *                     the consumer. E.g. 'battery_voltage'
> @@ -129,9 +125,17 @@ of_iio_channel_get_by_name(struct device_node *np, const char *name)
>   * The allocated iio channel is automatically released when the device is
>   * unbound.
>   */
> -struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
> -                                                   struct device_node *np,
> -                                                   const char *consumer_channel);
> +struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
> +                                                       struct fwnode_handle *fwnode,
> +                                                       const char *consumer_channel);
> +
> +static inline struct iio_channel
> +*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
> +                                const char *consumer_channel)
> +{
> +       return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
> +                                                  consumer_channel);
> +}
>
>  struct iio_cb_buffer;
>  /**
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index d9b4a9ca9a0f..494abb63406e 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -18,6 +18,7 @@
>   */
>
>  struct of_phandle_args;
> +struct fwnode_reference_args;
>
>  enum iio_shared_by {
>         IIO_SEPARATE,
> @@ -429,6 +430,8 @@ struct iio_trigger; /* forward declaration */
>   *                     provide a custom of_xlate function that reads the
>   *                     *args* and returns the appropriate index in registered
>   *                     IIO channels array.
> + * @fwnode_xlate:      fwnode based function pointer to obtain channel specifier index.
> + *                     Functionally the same as @of_xlate.
>   * @hwfifo_set_watermark: function pointer to set the current hardware
>   *                     fifo watermark level; see hwfifo_* entries in
>   *                     Documentation/ABI/testing/sysfs-bus-iio for details on
> @@ -510,6 +513,8 @@ struct iio_info {
>                                   unsigned *readval);
>         int (*of_xlate)(struct iio_dev *indio_dev,
>                         const struct of_phandle_args *iiospec);
> +       int (*fwnode_xlate)(struct iio_dev *indio_dev,
> +                           const struct fwnode_reference_args *iiospec);
>         int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
>         int (*hwfifo_flush_to_buffer)(struct iio_dev *indio_dev,
>                                       unsigned count);

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-10 15:19     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:19 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> This moves the IIO in kernel interface to use fwnode properties and thus
> be firmware agnostic.
>
> Note that the interface is still not firmware agnostic. At this point we
> have both OF and fwnode interfaces so that we don't break any user. On
> top of this we also want to have a per driver conversion and that is the
> main reason we have both of_xlate() and fwnode_xlate() support.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Thanks!

A few nit-picks below, though.

> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c         | 145 +++++++++++++++++++----------------
>  include/linux/iio/consumer.h |  36 +++++----
>  include/linux/iio/iio.h      |   5 ++
>  3 files changed, 105 insertions(+), 81 deletions(-)
>
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index dde47324b826..1d519b0cacea 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -5,6 +5,7 @@
>   */
>  #include <linux/err.h>
>  #include <linux/export.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>  #include <linux/mutex.h>
>  #include <linux/of.h>
> @@ -117,15 +118,13 @@ static const struct iio_chan_spec
>         return chan;
>  }
>
> -#ifdef CONFIG_OF
> -
>  static int iio_dev_node_match(struct device *dev, const void *data)
>  {
> -       return dev->of_node == data && dev->type == &iio_device_type;
> +       return device_match_fwnode(dev, data) && dev->type == &iio_device_type;
>  }
>
>  /**
> - * __of_iio_simple_xlate - translate iiospec to the IIO channel index
> + * __fwnode_iio_simple_xlate - translate iiospec to the IIO channel index
>   * @indio_dev: pointer to the iio_dev structure
>   * @iiospec:   IIO specifier as found in the device tree
>   *
> @@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device *dev, const void *data)
>   * whether IIO index is less than num_channels (that is specified in the
>   * iio_dev).
>   */
> -static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
> -                               const struct of_phandle_args *iiospec)
> +static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
> +                                    const struct fwnode_reference_args *iiospec)
>  {
> -       if (!iiospec->args_count)
> +       if (!iiospec->nargs)
>                 return 0;
>
>         if (iiospec->args[0] >= indio_dev->num_channels) {
> -               dev_err(&indio_dev->dev, "invalid channel index %u\n",
> +               dev_err(&indio_dev->dev, "invalid channel index %llu\n",
>                         iiospec->args[0]);
>                 return -EINVAL;
>         }
> @@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
>         return iiospec->args[0];
>  }
>
> -static int __of_iio_channel_get(struct iio_channel *channel,
> -                               struct device_node *np, int index)
> +/*
> + * Simple helper to copy fwnode_reference_args into of_phandle_args so we
> + * can pass it to of_xlate(). Ultimate goal is to drop this together with
> + * of_xlate().
> + */
> +static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
> +                               const struct fwnode_reference_args *iiospec)
> +{
> +       struct of_phandle_args of_args;
> +       unsigned int i;
> +
> +       of_args.args_count = iiospec->nargs;
> +       of_args.np = to_of_node(iiospec->fwnode);
> +
> +       for (i = 0; i < MAX_PHANDLE_ARGS; i++)
> +               of_args.args[i] = i < iiospec->nargs ? iiospec->args[i] : 0;
> +
> +       return indio_dev->info->of_xlate(indio_dev, &of_args);
> +}

Ah, now I realized that it's a bit more complicated than just to_of_node() :-)

> +static int __fwnode_iio_channel_get(struct iio_channel *channel,
> +                                   struct fwnode_handle *fwnode, int index)
>  {
>         struct device *idev;
>         struct iio_dev *indio_dev;
>         int err;
> -       struct of_phandle_args iiospec;
> +       struct fwnode_reference_args iiospec;

At the same point you can move it up in the block to make a long line first.

> -       err = of_parse_phandle_with_args(np, "io-channels",
> -                                        "#io-channel-cells",
> -                                        index, &iiospec);
> +       err = fwnode_property_get_reference_args(fwnode, "io-channels",
> +                                                "#io-channel-cells", 0,
> +                                                index, &iiospec);
>         if (err)
>                 return err;
>
> -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
>                                iio_dev_node_match);

Wondering if this
https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
can be utilized (yes, I noticed iio_device_type above).

>         if (idev == NULL) {
> -               of_node_put(iiospec.np);
> +               fwnode_handle_put(iiospec.fwnode);
>                 return -EPROBE_DEFER;
>         }
>
>         indio_dev = dev_to_iio_dev(idev);
>         channel->indio_dev = indio_dev;
>         if (indio_dev->info->of_xlate)
> -               index = indio_dev->info->of_xlate(indio_dev, &iiospec);
> +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> +       else if (indio_dev->info->fwnode_xlate)
> +               index = indio_dev->info->fwnode_xlate(indio_dev, &iiospec);
>         else
> -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> -       of_node_put(iiospec.np);
> +               index = __fwnode_iio_simple_xlate(indio_dev, &iiospec);
> +       fwnode_handle_put(iiospec.fwnode);
>         if (index < 0)
>                 goto err_put;
>         channel->channel = &indio_dev->channels[index];
> @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct iio_channel *channel,
>         return index;
>  }
>
> -static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
> +static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
> +                                                 int index)
>  {
>         struct iio_channel *channel;
>         int err;
> @@ -200,7 +222,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>         if (channel == NULL)
>                 return ERR_PTR(-ENOMEM);
>
> -       err = __of_iio_channel_get(channel, np, index);
> +       err = __fwnode_iio_channel_get(channel, fwnode, index);
>         if (err)
>                 goto err_free_channel;
>
> @@ -211,9 +233,9 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>         return ERR_PTR(err);
>  }
>
> -struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
> -                                                const char *name,
> -                                                bool *parent_lookup)
> +struct iio_channel *
> +__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode, const char *name,
> +                                bool *parent_lookup)
>  {
>         struct iio_channel *chan;
>         int index = 0;
> @@ -221,32 +243,34 @@ struct iio_channel *__of_iio_channel_get_by_name(struct device_node *np,
>         /*
>          * For named iio channels, first look up the name in the
>          * "io-channel-names" property.  If it cannot be found, the
> -        * index will be an error code, and of_iio_channel_get()
> +        * index will be an error code, and fwnode_iio_channel_get()
>          * will fail.
>          */
>         if (name)
> -               index = of_property_match_string(np, "io-channel-names", name);
> +               index = fwnode_property_match_string(fwnode, "io-channel-names",
> +                                                    name);
>
> -       chan = of_iio_channel_get(np, index);
> +       chan = fwnode_iio_channel_get(fwnode, index);
>         if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
>                 *parent_lookup = false;
>         } else if (name && index >= 0) {
> -               pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
> -                      np, name ? name : "", index);
> +               pr_err("ERROR: could not get IIO channel %pfw:%s(%i)\n",
> +                      fwnode, name ? name : "", index);

Since you are touching this line can you switch to name ?: "" and
possibly move some parameters to the above line?

>                 *parent_lookup = false;
>         }
>
>         return chan;
>  }
>
> -struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
> -                                              const char *name)
> +struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
> +                                                  const char *name)
>  {
>         struct iio_channel *chan;
> +       struct fwnode_handle *parent;
>         bool parent_lookup = true;
>
>         /* Walk up the tree of devices looking for a matching iio channel */
> -       chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> +       chan = __fwnode_iio_channel_get_by_name(fwnode, name, &parent_lookup);
>         if (!parent_lookup)
>                 return chan;
>
> @@ -255,33 +279,34 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>          * If the parent node has a "io-channel-ranges" property,
>          * then we can try one of its channels.
>          */
> -       np = np->parent;
> -       while (np) {
> -               if (!of_get_property(np, "io-channel-ranges", NULL))
> +       fwnode_for_each_parent_node(fwnode, parent) {
> +               if (!fwnode_property_present(parent, "io-channel-ranges")) {
> +                       fwnode_handle_put(parent);
>                         return chan;

break; ?

(Yes, I understand pros and cons of each variant, up to you)

> +               }
>
> -               chan = __of_iio_channel_get_by_name(np, name, &parent_lookup);
> -               if (!parent_lookup)
> +               chan = __fwnode_iio_channel_get_by_name(parent, name, &parent_lookup);
> +               if (!parent_lookup) {
> +                       fwnode_handle_put(parent);
>                         return chan;

Ditto.

> -               np = np->parent;
> +               }
>         }
>
>         return chan;
>  }
> -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);

Wondering if we may move this to the IIO namespace.

> -static struct iio_channel *of_iio_channel_get_all(struct device *dev)
> +static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
>  {
> +       struct fwnode_handle *fwnode = dev_fwnode(dev);
>         struct iio_channel *chans;
>         int i, mapind, nummaps = 0;
>         int ret;
>
>         do {
> -               ret = of_parse_phandle_with_args(dev->of_node,
> -                                                "io-channels",
> -                                                "#io-channel-cells",
> -                                                nummaps, NULL);
> +               ret = fwnode_property_get_reference_args(fwnode, "io-channels",
> +                                                        "#io-channel-cells", 0,
> +                                                        nummaps, NULL);
>                 if (ret < 0)
>                         break;
>         } while (++nummaps);
> @@ -294,10 +319,9 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>         if (chans == NULL)
>                 return ERR_PTR(-ENOMEM);
>
> -       /* Search for OF matches */
> +       /* Search for FW matches */
>         for (mapind = 0; mapind < nummaps; mapind++) {
> -               ret = __of_iio_channel_get(&chans[mapind], dev->of_node,
> -                                          mapind);
> +               ret = __fwnode_iio_channel_get(&chans[mapind], fwnode, mapind);
>                 if (ret)
>                         goto error_free_chans;
>         }
> @@ -310,15 +334,6 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>         return ERR_PTR(ret);
>  }
>
> -#else /* CONFIG_OF */
> -
> -static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
> -{
> -       return ERR_PTR(-ENODEV);
> -}
> -
> -#endif /* CONFIG_OF */
> -
>  static struct iio_channel *iio_channel_get_sys(const char *name,
>                                                const char *channel_name)
>  {
> @@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct device *dev,
>         struct iio_channel *channel;
>
>         if (dev) {
> -               channel = of_iio_channel_get_by_name(dev->of_node,
> -                                                    channel_name);
> +               channel = fwnode_iio_channel_get_by_name(dev_fwnode(dev),
> +                                                        channel_name);
>                 if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
>                         return channel;
>         }
> @@ -421,14 +436,14 @@ struct iio_channel *devm_iio_channel_get(struct device *dev,
>  }
>  EXPORT_SYMBOL_GPL(devm_iio_channel_get);
>
> -struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
> -                                                   struct device_node *np,
> -                                                   const char *channel_name)
> +struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
> +                                                       struct fwnode_handle *fwnode,
> +                                                       const char *channel_name)
>  {
>         struct iio_channel *channel;
>         int ret;
>
> -       channel = of_iio_channel_get_by_name(np, channel_name);
> +       channel = fwnode_iio_channel_get_by_name(fwnode, channel_name);
>         if (IS_ERR(channel))
>                 return channel;
>
> @@ -438,7 +453,7 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
>
>         return channel;
>  }
> -EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
> +EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
>
>  struct iio_channel *iio_channel_get_all(struct device *dev)
>  {
> @@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>         if (dev == NULL)
>                 return ERR_PTR(-EINVAL);
>
> -       chans = of_iio_channel_get_all(dev);
> +       chans = fwnode_iio_channel_get_all(dev);
>         if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
>                 return chans;
>
> diff --git a/include/linux/iio/consumer.h b/include/linux/iio/consumer.h
> index 5fa5957586cf..a96a714b5fdc 100644
> --- a/include/linux/iio/consumer.h
> +++ b/include/linux/iio/consumer.h
> @@ -9,11 +9,13 @@
>
>  #include <linux/types.h>
>  #include <linux/iio/types.h>

> +#include <linux/of.h>

Ordering. IIO has special meaning here, that's why it's last.

>  struct iio_dev;
>  struct iio_chan_spec;
>  struct device;
>  struct device_node;
> +struct fwnode_handle;
>
>  /**
>   * struct iio_channel - everything needed for a consumer to use a channel
> @@ -99,26 +101,20 @@ void iio_channel_release_all(struct iio_channel *chan);
>  struct iio_channel *devm_iio_channel_get_all(struct device *dev);
>
>  /**
> - * of_iio_channel_get_by_name() - get description of all that is needed to access channel.
> - * @np:                        Pointer to consumer device tree node
> + * fwnode_iio_channel_get_by_name() - get description of all that is needed to access channel.
> + * @fwnode:            Pointer to consumer Firmware node
>   * @consumer_channel:  Unique name to identify the channel on the consumer
>   *                     side. This typically describes the channels use within
>   *                     the consumer. E.g. 'battery_voltage'
>   */
> -#ifdef CONFIG_OF
> -struct iio_channel *of_iio_channel_get_by_name(struct device_node *np, const char *name);
> -#else
> -static inline struct iio_channel *
> -of_iio_channel_get_by_name(struct device_node *np, const char *name)
> -{
> -       return NULL;
> -}
> -#endif
> +struct iio_channel *fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
> +                                                  const char *name);
>
>  /**
> - * devm_of_iio_channel_get_by_name() - Resource managed version of of_iio_channel_get_by_name().
> + * devm_fwnode_iio_channel_get_by_name() - Resource managed version of
> + *                                        fwnode_iio_channel_get_by_name().
>   * @dev:               Pointer to consumer device.
> - * @np:                        Pointer to consumer device tree node
> + * @fwnode:            Pointer to consumer Firmware node
>   * @consumer_channel:  Unique name to identify the channel on the consumer
>   *                     side. This typically describes the channels use within
>   *                     the consumer. E.g. 'battery_voltage'
> @@ -129,9 +125,17 @@ of_iio_channel_get_by_name(struct device_node *np, const char *name)
>   * The allocated iio channel is automatically released when the device is
>   * unbound.
>   */
> -struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
> -                                                   struct device_node *np,
> -                                                   const char *consumer_channel);
> +struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct device *dev,
> +                                                       struct fwnode_handle *fwnode,
> +                                                       const char *consumer_channel);
> +
> +static inline struct iio_channel
> +*devm_of_iio_channel_get_by_name(struct device *dev, struct device_node *np,
> +                                const char *consumer_channel)
> +{
> +       return devm_fwnode_iio_channel_get_by_name(dev, of_fwnode_handle(np),
> +                                                  consumer_channel);
> +}
>
>  struct iio_cb_buffer;
>  /**
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index d9b4a9ca9a0f..494abb63406e 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -18,6 +18,7 @@
>   */
>
>  struct of_phandle_args;
> +struct fwnode_reference_args;
>
>  enum iio_shared_by {
>         IIO_SEPARATE,
> @@ -429,6 +430,8 @@ struct iio_trigger; /* forward declaration */
>   *                     provide a custom of_xlate function that reads the
>   *                     *args* and returns the appropriate index in registered
>   *                     IIO channels array.
> + * @fwnode_xlate:      fwnode based function pointer to obtain channel specifier index.
> + *                     Functionally the same as @of_xlate.
>   * @hwfifo_set_watermark: function pointer to set the current hardware
>   *                     fifo watermark level; see hwfifo_* entries in
>   *                     Documentation/ABI/testing/sysfs-bus-iio for details on
> @@ -510,6 +513,8 @@ struct iio_info {
>                                   unsigned *readval);
>         int (*of_xlate)(struct iio_dev *indio_dev,
>                         const struct of_phandle_args *iiospec);
> +       int (*fwnode_xlate)(struct iio_dev *indio_dev,
> +                           const struct fwnode_reference_args *iiospec);
>         int (*hwfifo_set_watermark)(struct iio_dev *indio_dev, unsigned val);
>         int (*hwfifo_flush_to_buffer)(struct iio_dev *indio_dev,
>                                       unsigned count);

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-10 15:20     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:20 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> Make usage of the new firmware agnostic API
> 'devm_of_iio_channel_get_by_name()' to get the IIO channel.

_of_ ?!

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
@ 2022-06-10 15:20     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:20 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
>
> Make usage of the new firmware agnostic API
> 'devm_of_iio_channel_get_by_name()' to get the IIO channel.

_of_ ?!

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 00/34] make iio inkern interface firmware agnostic
  2022-06-10 14:48   ` Andy Shevchenko
@ 2022-06-10 15:28     ` Andy Shevchenko
  -1 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:28 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 4:48 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Fri, Jun 10, 2022 at 10:45 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Ditto for patches 26-34.

-- 
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH 00/34] make iio inkern interface firmware agnostic
@ 2022-06-10 15:28     ` Andy Shevchenko
  0 siblings, 0 replies; 246+ messages in thread
From: Andy Shevchenko @ 2022-06-10 15:28 UTC (permalink / raw)
  To: Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 4:48 PM Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Fri, Jun 10, 2022 at 10:45 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Ditto for patches 26-34.

-- 
With Best Regards,
Andy Shevchenko

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-10 15:53     ` Joe Simmons-Talbott
  -1 siblings, 0 replies; 246+ messages in thread
From: Joe Simmons-Talbott @ 2022-06-10 15:53 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> Just cosmetics. No functional change intended...
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 64 ++++++++++++++++++++++----------------------
>  1 file changed, 32 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 7eb536560ded..526519cefcb9 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
>  	int i = 0, ret = 0;
>  	struct iio_map_internal *mapi;
>  
> -	if (maps == NULL)
> +	if (!maps)
>  		return 0;
>  
>  	mutex_lock(&iio_map_list_lock);
> -	while (maps[i].consumer_dev_name != NULL) {
> +	while (!maps[i].consumer_dev_name) {

Shouldn't this be?:
while (maps[i].consumer_dev_name) {

Thanks,
Joe
>  		mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
> -		if (mapi == NULL) {
> +		if (!mapi) {
>  			ret = -ENOMEM;
>  			goto error_ret;
>  		}
> @@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
>  }
>  EXPORT_SYMBOL_GPL(iio_map_array_register);
>  
> -
>  /*
>   * Remove all map entries associated with the given iio device
>   */
> @@ -163,7 +162,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
>  
>  	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
>  			       iio_dev_node_match);
> -	if (idev == NULL) {
> +	if (!idev) {
>  		fwnode_handle_put(iiospec.fwnode);
>  		return -EPROBE_DEFER;
>  	}
> @@ -196,7 +195,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
>  		return ERR_PTR(-EINVAL);
>  
>  	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
> -	if (channel == NULL)
> +	if (!channel)
>  		return ERR_PTR(-ENOMEM);
>  
>  	err = __fwnode_iio_channel_get(channel, fwnode, index);
> @@ -293,7 +292,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> -	if (chans == NULL)
> +	if (!chans)
>  		return ERR_PTR(-ENOMEM);
>  
>  	/* Search for FW matches */
> @@ -318,7 +317,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  	struct iio_channel *channel;
>  	int err;
>  
> -	if (name == NULL && channel_name == NULL)
> +	if (!name && !channel_name)
>  		return ERR_PTR(-ENODEV);
>  
>  	/* first find matching entry the channel map */
> @@ -333,11 +332,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  		break;
>  	}
>  	mutex_unlock(&iio_map_list_lock);
> -	if (c == NULL)
> +	if (!c)
>  		return ERR_PTR(-ENODEV);
>  
>  	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
> -	if (channel == NULL) {
> +	if (!channel) {
>  		err = -ENOMEM;
>  		goto error_no_mem;
>  	}
> @@ -349,7 +348,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  			iio_chan_spec_from_name(channel->indio_dev,
>  						c->map->adc_channel_label);
>  
> -		if (channel->channel == NULL) {
> +		if (!channel->channel) {
>  			err = -EINVAL;
>  			goto error_no_chan;
>  		}
> @@ -441,7 +440,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  	int mapind = 0;
>  	int i, ret;
>  
> -	if (dev == NULL)
> +	if (!dev)
>  		return ERR_PTR(-EINVAL);
>  
>  	chans = fwnode_iio_channel_get_all(dev);
> @@ -465,7 +464,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> -	if (chans == NULL) {
> +	if (!chans) {
>  		ret = -ENOMEM;
>  		goto error_ret;
>  	}
> @@ -479,7 +478,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  		chans[mapind].channel =
>  			iio_chan_spec_from_name(chans[mapind].indio_dev,
>  						c->map->adc_channel_label);
> -		if (chans[mapind].channel == NULL) {
> +		if (!chans[mapind].channel) {
>  			ret = -EINVAL;
>  			goto error_free_chans;
>  		}
> @@ -541,14 +540,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev)
>  EXPORT_SYMBOL_GPL(devm_iio_channel_get_all);
>  
>  static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
> -	enum iio_chan_info_enum info)
> +			    enum iio_chan_info_enum info)
>  {
>  	int unused;
>  	int vals[INDIO_MAX_RAW_ELEMENTS];
>  	int ret;
>  	int val_len = 2;
>  
> -	if (val2 == NULL)
> +	if (!val2)
>  		val2 = &unused;
>  
>  	if (!iio_channel_has_info(chan->channel, info))
> @@ -560,9 +559,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
>  					vals, &val_len, info);
>  		*val = vals[0];
>  		*val2 = vals[1];
> -	} else
> +	} else {
>  		ret = chan->indio_dev->info->read_raw(chan->indio_dev,
>  					chan->channel, val, val2, info);
> +	}
>  
>  	return ret;
>  }
> @@ -573,7 +573,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val)
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -592,7 +592,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -606,7 +606,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
>  EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
>  
>  static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
> -	int raw, int *processed, unsigned int scale)
> +						 int raw, int *processed,
> +						 unsigned int scale)
>  {
>  	int scale_type, scale_val, scale_val2;
>  	int offset_type, offset_val, offset_val2;
> @@ -639,7 +640,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
>  	}
>  
>  	scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
> -					IIO_CHAN_INFO_SCALE);
> +				      IIO_CHAN_INFO_SCALE);
>  	if (scale_type < 0) {
>  		/*
>  		 * If no channel scaling is available apply consumer scale to
> @@ -684,19 +685,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
>  }
>  
>  int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
> -	int *processed, unsigned int scale)
> +				 int *processed, unsigned int scale)
>  {
>  	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
>  
>  	ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed,
> -							scale);
> +						    scale);
>  err_unlock:
>  	mutex_unlock(&iio_dev_opaque->info_exist_lock);
>  
> @@ -711,7 +712,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -737,7 +738,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -815,7 +816,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan,
>  	int type;
>  
>  	ret = iio_read_avail_channel_attribute(chan, vals, &type, length,
> -					 IIO_CHAN_INFO_RAW);
> +					       IIO_CHAN_INFO_RAW);
>  
>  	if (ret >= 0 && type != IIO_VAL_INT)
>  		/* raw values are assumed to be IIO_VAL_INT */
> @@ -899,7 +900,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
>  	/* Need to verify underlying driver has not gone away */
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -926,7 +927,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -960,9 +961,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
>  }
>  EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
>  
> -static const struct iio_chan_spec_ext_info *iio_lookup_ext_info(
> -						const struct iio_channel *chan,
> -						const char *attr)
> +static const struct iio_chan_spec_ext_info *
> +iio_lookup_ext_info(const struct iio_channel *chan, const char *attr)
>  {
>  	const struct iio_chan_spec_ext_info *ext_info;
>  
> -- 
> 2.36.1
> 

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-10 15:53     ` Joe Simmons-Talbott
  0 siblings, 0 replies; 246+ messages in thread
From: Joe Simmons-Talbott @ 2022-06-10 15:53 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> Just cosmetics. No functional change intended...
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 64 ++++++++++++++++++++++----------------------
>  1 file changed, 32 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 7eb536560ded..526519cefcb9 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
>  	int i = 0, ret = 0;
>  	struct iio_map_internal *mapi;
>  
> -	if (maps == NULL)
> +	if (!maps)
>  		return 0;
>  
>  	mutex_lock(&iio_map_list_lock);
> -	while (maps[i].consumer_dev_name != NULL) {
> +	while (!maps[i].consumer_dev_name) {

Shouldn't this be?:
while (maps[i].consumer_dev_name) {

Thanks,
Joe
>  		mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
> -		if (mapi == NULL) {
> +		if (!mapi) {
>  			ret = -ENOMEM;
>  			goto error_ret;
>  		}
> @@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
>  }
>  EXPORT_SYMBOL_GPL(iio_map_array_register);
>  
> -
>  /*
>   * Remove all map entries associated with the given iio device
>   */
> @@ -163,7 +162,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
>  
>  	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
>  			       iio_dev_node_match);
> -	if (idev == NULL) {
> +	if (!idev) {
>  		fwnode_handle_put(iiospec.fwnode);
>  		return -EPROBE_DEFER;
>  	}
> @@ -196,7 +195,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
>  		return ERR_PTR(-EINVAL);
>  
>  	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
> -	if (channel == NULL)
> +	if (!channel)
>  		return ERR_PTR(-ENOMEM);
>  
>  	err = __fwnode_iio_channel_get(channel, fwnode, index);
> @@ -293,7 +292,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> -	if (chans == NULL)
> +	if (!chans)
>  		return ERR_PTR(-ENOMEM);
>  
>  	/* Search for FW matches */
> @@ -318,7 +317,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  	struct iio_channel *channel;
>  	int err;
>  
> -	if (name == NULL && channel_name == NULL)
> +	if (!name && !channel_name)
>  		return ERR_PTR(-ENODEV);
>  
>  	/* first find matching entry the channel map */
> @@ -333,11 +332,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  		break;
>  	}
>  	mutex_unlock(&iio_map_list_lock);
> -	if (c == NULL)
> +	if (!c)
>  		return ERR_PTR(-ENODEV);
>  
>  	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
> -	if (channel == NULL) {
> +	if (!channel) {
>  		err = -ENOMEM;
>  		goto error_no_mem;
>  	}
> @@ -349,7 +348,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  			iio_chan_spec_from_name(channel->indio_dev,
>  						c->map->adc_channel_label);
>  
> -		if (channel->channel == NULL) {
> +		if (!channel->channel) {
>  			err = -EINVAL;
>  			goto error_no_chan;
>  		}
> @@ -441,7 +440,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  	int mapind = 0;
>  	int i, ret;
>  
> -	if (dev == NULL)
> +	if (!dev)
>  		return ERR_PTR(-EINVAL);
>  
>  	chans = fwnode_iio_channel_get_all(dev);
> @@ -465,7 +464,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> -	if (chans == NULL) {
> +	if (!chans) {
>  		ret = -ENOMEM;
>  		goto error_ret;
>  	}
> @@ -479,7 +478,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  		chans[mapind].channel =
>  			iio_chan_spec_from_name(chans[mapind].indio_dev,
>  						c->map->adc_channel_label);
> -		if (chans[mapind].channel == NULL) {
> +		if (!chans[mapind].channel) {
>  			ret = -EINVAL;
>  			goto error_free_chans;
>  		}
> @@ -541,14 +540,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev)
>  EXPORT_SYMBOL_GPL(devm_iio_channel_get_all);
>  
>  static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
> -	enum iio_chan_info_enum info)
> +			    enum iio_chan_info_enum info)
>  {
>  	int unused;
>  	int vals[INDIO_MAX_RAW_ELEMENTS];
>  	int ret;
>  	int val_len = 2;
>  
> -	if (val2 == NULL)
> +	if (!val2)
>  		val2 = &unused;
>  
>  	if (!iio_channel_has_info(chan->channel, info))
> @@ -560,9 +559,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
>  					vals, &val_len, info);
>  		*val = vals[0];
>  		*val2 = vals[1];
> -	} else
> +	} else {
>  		ret = chan->indio_dev->info->read_raw(chan->indio_dev,
>  					chan->channel, val, val2, info);
> +	}
>  
>  	return ret;
>  }
> @@ -573,7 +573,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val)
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -592,7 +592,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -606,7 +606,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
>  EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
>  
>  static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
> -	int raw, int *processed, unsigned int scale)
> +						 int raw, int *processed,
> +						 unsigned int scale)
>  {
>  	int scale_type, scale_val, scale_val2;
>  	int offset_type, offset_val, offset_val2;
> @@ -639,7 +640,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
>  	}
>  
>  	scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
> -					IIO_CHAN_INFO_SCALE);
> +				      IIO_CHAN_INFO_SCALE);
>  	if (scale_type < 0) {
>  		/*
>  		 * If no channel scaling is available apply consumer scale to
> @@ -684,19 +685,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
>  }
>  
>  int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
> -	int *processed, unsigned int scale)
> +				 int *processed, unsigned int scale)
>  {
>  	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
>  
>  	ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed,
> -							scale);
> +						    scale);
>  err_unlock:
>  	mutex_unlock(&iio_dev_opaque->info_exist_lock);
>  
> @@ -711,7 +712,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -737,7 +738,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -815,7 +816,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan,
>  	int type;
>  
>  	ret = iio_read_avail_channel_attribute(chan, vals, &type, length,
> -					 IIO_CHAN_INFO_RAW);
> +					       IIO_CHAN_INFO_RAW);
>  
>  	if (ret >= 0 && type != IIO_VAL_INT)
>  		/* raw values are assumed to be IIO_VAL_INT */
> @@ -899,7 +900,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
>  	/* Need to verify underlying driver has not gone away */
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -926,7 +927,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -960,9 +961,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
>  }
>  EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
>  
> -static const struct iio_chan_spec_ext_info *iio_lookup_ext_info(
> -						const struct iio_channel *chan,
> -						const char *attr)
> +static const struct iio_chan_spec_ext_info *
> +iio_lookup_ext_info(const struct iio_channel *chan, const char *attr)
>  {
>  	const struct iio_chan_spec_ext_info *ext_info;
>  
> -- 
> 2.36.1
> 

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-10 15:53     ` Joe Simmons-Talbott
  0 siblings, 0 replies; 246+ messages in thread
From: Joe Simmons-Talbott @ 2022-06-10 15:53 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>, Jonathan Cameron <jic23@kernel.org>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> Just cosmetics. No functional change intended...
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 64 ++++++++++++++++++++++----------------------
>  1 file changed, 32 insertions(+), 32 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 7eb536560ded..526519cefcb9 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
>  	int i = 0, ret = 0;
>  	struct iio_map_internal *mapi;
>  
> -	if (maps == NULL)
> +	if (!maps)
>  		return 0;
>  
>  	mutex_lock(&iio_map_list_lock);
> -	while (maps[i].consumer_dev_name != NULL) {
> +	while (!maps[i].consumer_dev_name) {

Shouldn't this be?:
while (maps[i].consumer_dev_name) {

Thanks,
Joe
>  		mapi = kzalloc(sizeof(*mapi), GFP_KERNEL);
> -		if (mapi == NULL) {
> +		if (!mapi) {
>  			ret = -ENOMEM;
>  			goto error_ret;
>  		}
> @@ -69,7 +69,6 @@ int iio_map_array_register(struct iio_dev *indio_dev, struct iio_map *maps)
>  }
>  EXPORT_SYMBOL_GPL(iio_map_array_register);
>  
> -
>  /*
>   * Remove all map entries associated with the given iio device
>   */
> @@ -163,7 +162,7 @@ static int __fwnode_iio_channel_get(struct iio_channel *channel,
>  
>  	idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
>  			       iio_dev_node_match);
> -	if (idev == NULL) {
> +	if (!idev) {
>  		fwnode_handle_put(iiospec.fwnode);
>  		return -EPROBE_DEFER;
>  	}
> @@ -196,7 +195,7 @@ static struct iio_channel *fwnode_iio_channel_get(struct fwnode_handle *fwnode,
>  		return ERR_PTR(-EINVAL);
>  
>  	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
> -	if (channel == NULL)
> +	if (!channel)
>  		return ERR_PTR(-ENOMEM);
>  
>  	err = __fwnode_iio_channel_get(channel, fwnode, index);
> @@ -293,7 +292,7 @@ static struct iio_channel *fwnode_iio_channel_get_all(struct device *dev)
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> -	if (chans == NULL)
> +	if (!chans)
>  		return ERR_PTR(-ENOMEM);
>  
>  	/* Search for FW matches */
> @@ -318,7 +317,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  	struct iio_channel *channel;
>  	int err;
>  
> -	if (name == NULL && channel_name == NULL)
> +	if (!name && !channel_name)
>  		return ERR_PTR(-ENODEV);
>  
>  	/* first find matching entry the channel map */
> @@ -333,11 +332,11 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  		break;
>  	}
>  	mutex_unlock(&iio_map_list_lock);
> -	if (c == NULL)
> +	if (!c)
>  		return ERR_PTR(-ENODEV);
>  
>  	channel = kzalloc(sizeof(*channel), GFP_KERNEL);
> -	if (channel == NULL) {
> +	if (!channel) {
>  		err = -ENOMEM;
>  		goto error_no_mem;
>  	}
> @@ -349,7 +348,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
>  			iio_chan_spec_from_name(channel->indio_dev,
>  						c->map->adc_channel_label);
>  
> -		if (channel->channel == NULL) {
> +		if (!channel->channel) {
>  			err = -EINVAL;
>  			goto error_no_chan;
>  		}
> @@ -441,7 +440,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  	int mapind = 0;
>  	int i, ret;
>  
> -	if (dev == NULL)
> +	if (!dev)
>  		return ERR_PTR(-EINVAL);
>  
>  	chans = fwnode_iio_channel_get_all(dev);
> @@ -465,7 +464,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> -	if (chans == NULL) {
> +	if (!chans) {
>  		ret = -ENOMEM;
>  		goto error_ret;
>  	}
> @@ -479,7 +478,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  		chans[mapind].channel =
>  			iio_chan_spec_from_name(chans[mapind].indio_dev,
>  						c->map->adc_channel_label);
> -		if (chans[mapind].channel == NULL) {
> +		if (!chans[mapind].channel) {
>  			ret = -EINVAL;
>  			goto error_free_chans;
>  		}
> @@ -541,14 +540,14 @@ struct iio_channel *devm_iio_channel_get_all(struct device *dev)
>  EXPORT_SYMBOL_GPL(devm_iio_channel_get_all);
>  
>  static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
> -	enum iio_chan_info_enum info)
> +			    enum iio_chan_info_enum info)
>  {
>  	int unused;
>  	int vals[INDIO_MAX_RAW_ELEMENTS];
>  	int ret;
>  	int val_len = 2;
>  
> -	if (val2 == NULL)
> +	if (!val2)
>  		val2 = &unused;
>  
>  	if (!iio_channel_has_info(chan->channel, info))
> @@ -560,9 +559,10 @@ static int iio_channel_read(struct iio_channel *chan, int *val, int *val2,
>  					vals, &val_len, info);
>  		*val = vals[0];
>  		*val2 = vals[1];
> -	} else
> +	} else {
>  		ret = chan->indio_dev->info->read_raw(chan->indio_dev,
>  					chan->channel, val, val2, info);
> +	}
>  
>  	return ret;
>  }
> @@ -573,7 +573,7 @@ int iio_read_channel_raw(struct iio_channel *chan, int *val)
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -592,7 +592,7 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -606,7 +606,8 @@ int iio_read_channel_average_raw(struct iio_channel *chan, int *val)
>  EXPORT_SYMBOL_GPL(iio_read_channel_average_raw);
>  
>  static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
> -	int raw, int *processed, unsigned int scale)
> +						 int raw, int *processed,
> +						 unsigned int scale)
>  {
>  	int scale_type, scale_val, scale_val2;
>  	int offset_type, offset_val, offset_val2;
> @@ -639,7 +640,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
>  	}
>  
>  	scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
> -					IIO_CHAN_INFO_SCALE);
> +				      IIO_CHAN_INFO_SCALE);
>  	if (scale_type < 0) {
>  		/*
>  		 * If no channel scaling is available apply consumer scale to
> @@ -684,19 +685,19 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
>  }
>  
>  int iio_convert_raw_to_processed(struct iio_channel *chan, int raw,
> -	int *processed, unsigned int scale)
> +				 int *processed, unsigned int scale)
>  {
>  	struct iio_dev_opaque *iio_dev_opaque = to_iio_dev_opaque(chan->indio_dev);
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
>  
>  	ret = iio_convert_raw_to_processed_unlocked(chan, raw, processed,
> -							scale);
> +						    scale);
>  err_unlock:
>  	mutex_unlock(&iio_dev_opaque->info_exist_lock);
>  
> @@ -711,7 +712,7 @@ int iio_read_channel_attribute(struct iio_channel *chan, int *val, int *val2,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -737,7 +738,7 @@ int iio_read_channel_processed_scale(struct iio_channel *chan, int *val,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -815,7 +816,7 @@ int iio_read_avail_channel_raw(struct iio_channel *chan,
>  	int type;
>  
>  	ret = iio_read_avail_channel_attribute(chan, vals, &type, length,
> -					 IIO_CHAN_INFO_RAW);
> +					       IIO_CHAN_INFO_RAW);
>  
>  	if (ret >= 0 && type != IIO_VAL_INT)
>  		/* raw values are assumed to be IIO_VAL_INT */
> @@ -899,7 +900,7 @@ int iio_get_channel_type(struct iio_channel *chan, enum iio_chan_type *type)
>  	/* Need to verify underlying driver has not gone away */
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -926,7 +927,7 @@ int iio_write_channel_attribute(struct iio_channel *chan, int val, int val2,
>  	int ret;
>  
>  	mutex_lock(&iio_dev_opaque->info_exist_lock);
> -	if (chan->indio_dev->info == NULL) {
> +	if (!chan->indio_dev->info) {
>  		ret = -ENODEV;
>  		goto err_unlock;
>  	}
> @@ -960,9 +961,8 @@ unsigned int iio_get_channel_ext_info_count(struct iio_channel *chan)
>  }
>  EXPORT_SYMBOL_GPL(iio_get_channel_ext_info_count);
>  
> -static const struct iio_chan_spec_ext_info *iio_lookup_ext_info(
> -						const struct iio_channel *chan,
> -						const char *attr)
> +static const struct iio_chan_spec_ext_info *
> +iio_lookup_ext_info(const struct iio_channel *chan, const char *attr)
>  {
>  	const struct iio_chan_spec_ext_info *ext_info;
>  
> -- 
> 2.36.1
> 

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

* Re: [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
  2022-06-10 15:20     ` Andy Shevchenko
  (?)
@ 2022-06-10 19:42       ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:42 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 17:20 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > Make usage of the new firmware agnostic API
> > 'devm_of_iio_channel_get_by_name()' to get the IIO channel.
> 
> _of_ ?!
> 

Clearly not :)... Will fix it on v2

- Nuno Sá


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

* Re: [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
@ 2022-06-10 19:42       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:42 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 17:20 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > Make usage of the new firmware agnostic API
> > 'devm_of_iio_channel_get_by_name()' to get the IIO channel.
> 
> _of_ ?!
> 

Clearly not :)... Will fix it on v2

- Nuno Sá


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API
@ 2022-06-10 19:42       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:42 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, OpenBMC Maillist,
	Jishnu Prakash, Haibo Chen, Andy Gross, dl-linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier,
	moderated list:ARM/Mediatek SoC support, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm Mailing List,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	open list:BROADCOM NVRAM DRIVER, Thara Gopinath, Linux-Renesas,
	Arnd Bergmann, Maxime Coquelin, Cai Huoqing, Shawn Guo,
	Claudiu Beznea, Jonathan Cameron

On Fri, 2022-06-10 at 17:20 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > Make usage of the new firmware agnostic API
> > 'devm_of_iio_channel_get_by_name()' to get the IIO channel.
> 
> _of_ ?!
> 

Clearly not :)... Will fix it on v2

- Nuno Sá


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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
  2022-06-10 15:05     ` Andy Shevchenko
  (?)
@ 2022-06-10 19:48       ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:48 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 17:05 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > were
> > returning a mix of NULL and error pointers being NULL the way to
> > "notify" that we should do a "system" lookup for channels. This
> > make
> > it very confusing and prone to errors as commit dbbccf7c20bf
> > ("iio: inkern: fix return value in
> > devm_of_iio_channel_get_by_name()")
> > proves. On top of this, patterns like 'if (channel != NULL) return
> > channel'
> > were being used where channel could actually be an error code which
> > makes the code hard to read.
> 
> ...
> 
> >                 np = np->parent;
> >                 if (np && !of_get_property(np, "io-channel-ranges",
> > NULL))
> > -                       return NULL;
> > +                       return chan;
> 
> Shouldn't it return a dedicated error code and not some arbitrary
> one?
> It may be I missed something and chan has a correct error code in
> this
> case...
> 

Since in this case we won't look for channels in the parent device, I'm
just honoring the code returned by 'of_iio_channel_get()'.

> ...
> 
> > +       if (nummaps == 0)       /* return -ENODEV to search map
> > table */
> 
> Comment is superfluous, the next line is self-explaining.
> 

Well, I agree. I just kept as it was on the original code. Can hapilly
remove it if no one objects against it.

> > +               return ERR_PTR(-ENODEV);
> 
> ...
> 
> > -               if (channel != NULL)
> > +               if (!IS_ERR(channel) || PTR_ERR(channel) == -
> > EPROBE_DEFER)
> 
> Btw, in the GPIO library we have a macro or inliner (don't remember)
> that represents such a conditional.
> Perhaps make it (if it's a macro) global, or introduce an inline in
> IIO?
> 
> Okay, it's here:
> https://elixir.bootlin.com/linux/v5.19-rc1/source/drivers/gpio/gpiolib.h#L179
> 
> It's similar, but not the same, so just play with an idea to
> introduce
> something in this file, maybe it's worth doing this, maybe not.
> 

I would also argue that could be something done after this series gets
applied...

- Nuno Sá


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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-10 19:48       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:48 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 17:05 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > were
> > returning a mix of NULL and error pointers being NULL the way to
> > "notify" that we should do a "system" lookup for channels. This
> > make
> > it very confusing and prone to errors as commit dbbccf7c20bf
> > ("iio: inkern: fix return value in
> > devm_of_iio_channel_get_by_name()")
> > proves. On top of this, patterns like 'if (channel != NULL) return
> > channel'
> > were being used where channel could actually be an error code which
> > makes the code hard to read.
> 
> ...
> 
> >                 np = np->parent;
> >                 if (np && !of_get_property(np, "io-channel-ranges",
> > NULL))
> > -                       return NULL;
> > +                       return chan;
> 
> Shouldn't it return a dedicated error code and not some arbitrary
> one?
> It may be I missed something and chan has a correct error code in
> this
> case...
> 

Since in this case we won't look for channels in the parent device, I'm
just honoring the code returned by 'of_iio_channel_get()'.

> ...
> 
> > +       if (nummaps == 0)       /* return -ENODEV to search map
> > table */
> 
> Comment is superfluous, the next line is self-explaining.
> 

Well, I agree. I just kept as it was on the original code. Can hapilly
remove it if no one objects against it.

> > +               return ERR_PTR(-ENODEV);
> 
> ...
> 
> > -               if (channel != NULL)
> > +               if (!IS_ERR(channel) || PTR_ERR(channel) == -
> > EPROBE_DEFER)
> 
> Btw, in the GPIO library we have a macro or inliner (don't remember)
> that represents such a conditional.
> Perhaps make it (if it's a macro) global, or introduce an inline in
> IIO?
> 
> Okay, it's here:
> https://elixir.bootlin.com/linux/v5.19-rc1/source/drivers/gpio/gpiolib.h#L179
> 
> It's similar, but not the same, so just play with an idea to
> introduce
> something in this file, maybe it's worth doing this, maybe not.
> 

I would also argue that could be something done after this series gets
applied...

- Nuno Sá


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-10 19:48       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:48 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, OpenBMC Maillist,
	Jishnu Prakash, Haibo Chen, Andy Gross, dl-linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier,
	moderated list:ARM/Mediatek SoC support, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm Mailing List,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	open list:BROADCOM NVRAM DRIVER, Thara Gopinath, Linux-Renesas,
	Arnd Bergmann, Maxime Coquelin, Cai Huoqing, Shawn Guo,
	Claudiu Beznea, Jonathan Cameron

On Fri, 2022-06-10 at 17:05 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > were
> > returning a mix of NULL and error pointers being NULL the way to
> > "notify" that we should do a "system" lookup for channels. This
> > make
> > it very confusing and prone to errors as commit dbbccf7c20bf
> > ("iio: inkern: fix return value in
> > devm_of_iio_channel_get_by_name()")
> > proves. On top of this, patterns like 'if (channel != NULL) return
> > channel'
> > were being used where channel could actually be an error code which
> > makes the code hard to read.
> 
> ...
> 
> >                 np = np->parent;
> >                 if (np && !of_get_property(np, "io-channel-ranges",
> > NULL))
> > -                       return NULL;
> > +                       return chan;
> 
> Shouldn't it return a dedicated error code and not some arbitrary
> one?
> It may be I missed something and chan has a correct error code in
> this
> case...
> 

Since in this case we won't look for channels in the parent device, I'm
just honoring the code returned by 'of_iio_channel_get()'.

> ...
> 
> > +       if (nummaps == 0)       /* return -ENODEV to search map
> > table */
> 
> Comment is superfluous, the next line is self-explaining.
> 

Well, I agree. I just kept as it was on the original code. Can hapilly
remove it if no one objects against it.

> > +               return ERR_PTR(-ENODEV);
> 
> ...
> 
> > -               if (channel != NULL)
> > +               if (!IS_ERR(channel) || PTR_ERR(channel) == -
> > EPROBE_DEFER)
> 
> Btw, in the GPIO library we have a macro or inliner (don't remember)
> that represents such a conditional.
> Perhaps make it (if it's a macro) global, or introduce an inline in
> IIO?
> 
> Okay, it's here:
> https://elixir.bootlin.com/linux/v5.19-rc1/source/drivers/gpio/gpiolib.h#L179
> 
> It's similar, but not the same, so just play with an idea to
> introduce
> something in this file, maybe it's worth doing this, maybe not.
> 

I would also argue that could be something done after this series gets
applied...

- Nuno Sá


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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
  2022-06-10 14:45     ` Andy Shevchenko
  (?)
@ 2022-06-10 19:49       ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:49 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 16:45 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > Do not trust the fact that iio.h includes of.h which in turn
> > includes
> > all the headers we are relying on.
> > 
> > The ultimate goal is to actually drop of.h from iio.h.
> 
> ...
> 
> >  #include <linux/mod_devicetable.h>
> >  #include <linux/mutex.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/property.h>
> > +#include <linux/of.h>
> 
> Ordering (from the context I don't see it's messed up already)
> 

Will double check on v2...

- Nuno Sá

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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
@ 2022-06-10 19:49       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:49 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 16:45 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > Do not trust the fact that iio.h includes of.h which in turn
> > includes
> > all the headers we are relying on.
> > 
> > The ultimate goal is to actually drop of.h from iio.h.
> 
> ...
> 
> >  #include <linux/mod_devicetable.h>
> >  #include <linux/mutex.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/property.h>
> > +#include <linux/of.h>
> 
> Ordering (from the context I don't see it's messed up already)
> 

Will double check on v2...

- Nuno Sá

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
@ 2022-06-10 19:49       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:49 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, OpenBMC Maillist,
	Jishnu Prakash, Haibo Chen, Andy Gross, dl-linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier,
	moderated list:ARM/Mediatek SoC support, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm Mailing List,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	open list:BROADCOM NVRAM DRIVER, Thara Gopinath, Linux-Renesas,
	Arnd Bergmann, Maxime Coquelin, Cai Huoqing, Shawn Guo,
	Claudiu Beznea, Jonathan Cameron

On Fri, 2022-06-10 at 16:45 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > Do not trust the fact that iio.h includes of.h which in turn
> > includes
> > all the headers we are relying on.
> > 
> > The ultimate goal is to actually drop of.h from iio.h.
> 
> ...
> 
> >  #include <linux/mod_devicetable.h>
> >  #include <linux/mutex.h>
> >  #include <linux/platform_device.h>
> > +#include <linux/property.h>
> > +#include <linux/of.h>
> 
> Ordering (from the context I don't see it's messed up already)
> 

Will double check on v2...

- Nuno Sá

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
  2022-06-10 15:53     ` Joe Simmons-Talbott
  (?)
@ 2022-06-10 19:51       ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:51 UTC (permalink / raw)
  To: Joe Simmons-Talbott, Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > Just cosmetics. No functional change intended...
> > 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c | 64 ++++++++++++++++++++++------------------
> > ----
> >  1 file changed, 32 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index 7eb536560ded..526519cefcb9 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > *indio_dev, struct iio_map *maps)
> >         int i = 0, ret = 0;
> >         struct iio_map_internal *mapi;
> >  
> > -       if (maps == NULL)
> > +       if (!maps)
> >                 return 0;
> >  
> >         mutex_lock(&iio_map_list_lock);
> > -       while (maps[i].consumer_dev_name != NULL) {
> > +       while (!maps[i].consumer_dev_name) {
> 
> Shouldn't this be?:
> while (maps[i].consumer_dev_name) {
> 

Ups... Nice catch! I was probably in bot mode already.

- Nuno Sá


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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-10 19:51       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:51 UTC (permalink / raw)
  To: Joe Simmons-Talbott, Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > Just cosmetics. No functional change intended...
> > 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c | 64 ++++++++++++++++++++++------------------
> > ----
> >  1 file changed, 32 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index 7eb536560ded..526519cefcb9 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > *indio_dev, struct iio_map *maps)
> >         int i = 0, ret = 0;
> >         struct iio_map_internal *mapi;
> >  
> > -       if (maps == NULL)
> > +       if (!maps)
> >                 return 0;
> >  
> >         mutex_lock(&iio_map_list_lock);
> > -       while (maps[i].consumer_dev_name != NULL) {
> > +       while (!maps[i].consumer_dev_name) {
> 
> Shouldn't this be?:
> while (maps[i].consumer_dev_name) {
> 

Ups... Nice catch! I was probably in bot mode already.

- Nuno Sá


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-10 19:51       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 19:51 UTC (permalink / raw)
  To: Joe Simmons-Talbott, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>, Jonathan Cameron <jic23@kernel.org>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > Just cosmetics. No functional change intended...
> > 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c | 64 ++++++++++++++++++++++------------------
> > ----
> >  1 file changed, 32 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index 7eb536560ded..526519cefcb9 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > *indio_dev, struct iio_map *maps)
> >         int i = 0, ret = 0;
> >         struct iio_map_internal *mapi;
> >  
> > -       if (maps == NULL)
> > +       if (!maps)
> >                 return 0;
> >  
> >         mutex_lock(&iio_map_list_lock);
> > -       while (maps[i].consumer_dev_name != NULL) {
> > +       while (!maps[i].consumer_dev_name) {
> 
> Shouldn't this be?:
> while (maps[i].consumer_dev_name) {
> 

Ups... Nice catch! I was probably in bot mode already.

- Nuno Sá


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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
  2022-06-10 15:19     ` Andy Shevchenko
  (?)
@ 2022-06-10 20:01       ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 20:01 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > This moves the IIO in kernel interface to use fwnode properties and
> > thus
> > be firmware agnostic.
> > 
> > Note that the interface is still not firmware agnostic. At this
> > point we
> > have both OF and fwnode interfaces so that we don't break any user.
> > On
> > top of this we also want to have a per driver conversion and that
> > is the
> > main reason we have both of_xlate() and fwnode_xlate() support.
> 
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Thanks!
> 
> A few nit-picks below, though.
> 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c         | 145 +++++++++++++++++++------------
> > ----
> >  include/linux/iio/consumer.h |  36 +++++----
> >  include/linux/iio/iio.h      |   5 ++
> >  3 files changed, 105 insertions(+), 81 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index dde47324b826..1d519b0cacea 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -5,6 +5,7 @@
> >   */
> >  #include <linux/err.h>
> >  #include <linux/export.h>
> > +#include <linux/property.h>
> >  #include <linux/slab.h>
> >  #include <linux/mutex.h>
> >  #include <linux/of.h>
> > @@ -117,15 +118,13 @@ static const struct iio_chan_spec
> >         return chan;
> >  }
> > 
> > -#ifdef CONFIG_OF
> > -
> >  static int iio_dev_node_match(struct device *dev, const void
> > *data)
> >  {
> > -       return dev->of_node == data && dev->type ==
> > &iio_device_type;
> > +       return device_match_fwnode(dev, data) && dev->type ==
> > &iio_device_type;
> >  }
> > 
> >  /**
> > - * __of_iio_simple_xlate - translate iiospec to the IIO channel
> > index
> > + * __fwnode_iio_simple_xlate - translate iiospec to the IIO
> > channel index
> >   * @indio_dev: pointer to the iio_dev structure
> >   * @iiospec:   IIO specifier as found in the device tree
> >   *
> > @@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device
> > *dev, const void *data)
> >   * whether IIO index is less than num_channels (that is specified
> > in the
> >   * iio_dev).
> >   */
> > -static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
> > -                               const struct of_phandle_args
> > *iiospec)
> > +static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
> > +                                    const struct
> > fwnode_reference_args *iiospec)
> >  {
> > -       if (!iiospec->args_count)
> > +       if (!iiospec->nargs)
> >                 return 0;
> > 
> >         if (iiospec->args[0] >= indio_dev->num_channels) {
> > -               dev_err(&indio_dev->dev, "invalid channel index
> > %u\n",
> > +               dev_err(&indio_dev->dev, "invalid channel index
> > %llu\n",
> >                         iiospec->args[0]);
> >                 return -EINVAL;
> >         }
> > @@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct
> > iio_dev *indio_dev,
> >         return iiospec->args[0];
> >  }
> > 
> > -static int __of_iio_channel_get(struct iio_channel *channel,
> > -                               struct device_node *np, int index)
> > +/*
> > + * Simple helper to copy fwnode_reference_args into
> > of_phandle_args so we
> > + * can pass it to of_xlate(). Ultimate goal is to drop this
> > together with
> > + * of_xlate().
> > + */
> > +static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
> > +                               const struct fwnode_reference_args
> > *iiospec)
> > +{
> > +       struct of_phandle_args of_args;
> > +       unsigned int i;
> > +
> > +       of_args.args_count = iiospec->nargs;
> > +       of_args.np = to_of_node(iiospec->fwnode);
> > +
> > +       for (i = 0; i < MAX_PHANDLE_ARGS; i++)
> > +               of_args.args[i] = i < iiospec->nargs ? iiospec-
> > >args[i] : 0;
> > +
> > +       return indio_dev->info->of_xlate(indio_dev, &of_args);
> > +}
> 
> Ah, now I realized that it's a bit more complicated than just
> to_of_node() :-)
> 

Yeah, of_fwnode_get_reference_args() was helpfull. But I based myself
too much on it. On a second look, I guess ARRAY_SIZE(of_args.args)
would be better than MAX_PHANDLE_ARGS.

> > +static int __fwnode_iio_channel_get(struct iio_channel *channel,
> > +                                   struct fwnode_handle *fwnode,
> > int index)
> >  {
> >         struct device *idev;
> >         struct iio_dev *indio_dev;
> >         int err;
> > -       struct of_phandle_args iiospec;
> > +       struct fwnode_reference_args iiospec;
> 
> At the same point you can move it up in the block to make a long line
> first.

Can do that...

> 
> > -       err = of_parse_phandle_with_args(np, "io-channels",
> > -                                        "#io-channel-cells",
> > -                                        index, &iiospec);
> > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > channels",
> > +                                                "#io-channel-
> > cells", 0,
> > +                                                index, &iiospec);
> >         if (err)
> >                 return err;
> > 
> > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> >                                iio_dev_node_match);
> 
> Wondering if this
> https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> can be utilized (yes, I noticed iio_device_type above).

Hmm, at first glance I would say we can use it. AFAICT, we are already
grabbing a node which contains "#io-channel-cells" which is very
indicative that is an IIO device. I also find it very unlikely to have
two IIO devices with the same fwnode (I guess it would be an issue even
in the old code) and even more unlikely two devices of diferent types
with the same fwnode?

Anyways, I guess Jonathan can help in here...


> 
> >         if (idev == NULL) {
> > -               of_node_put(iiospec.np);
> > +               fwnode_handle_put(iiospec.fwnode);
> >                 return -EPROBE_DEFER;
> >         }
> > 
> >         indio_dev = dev_to_iio_dev(idev);
> >         channel->indio_dev = indio_dev;
> >         if (indio_dev->info->of_xlate)
> > -               index = indio_dev->info->of_xlate(indio_dev,
> > &iiospec);
> > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > +       else if (indio_dev->info->fwnode_xlate)
> > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > &iiospec);
> >         else
> > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > -       of_node_put(iiospec.np);
> > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > &iiospec);
> > +       fwnode_handle_put(iiospec.fwnode);
> >         if (index < 0)
> >                 goto err_put;
> >         channel->channel = &indio_dev->channels[index];
> > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > iio_channel *channel,
> >         return index;
> >  }
> > 
> > -static struct iio_channel *of_iio_channel_get(struct device_node
> > *np, int index)
> > +static struct iio_channel *fwnode_iio_channel_get(struct
> > fwnode_handle *fwnode,
> > +                                                 int index)
> >  {
> >         struct iio_channel *channel;
> >         int err;
> > @@ -200,7 +222,7 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >         if (channel == NULL)
> >                 return ERR_PTR(-ENOMEM);
> > 
> > -       err = __of_iio_channel_get(channel, np, index);
> > +       err = __fwnode_iio_channel_get(channel, fwnode, index);
> >         if (err)
> >                 goto err_free_channel;
> > 
> > @@ -211,9 +233,9 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >         return ERR_PTR(err);
> >  }
> > 
> > -struct iio_channel *__of_iio_channel_get_by_name(struct
> > device_node *np,
> > -                                                const char *name,
> > -                                                bool
> > *parent_lookup)
> > +struct iio_channel *
> > +__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
> > const char *name,
> > +                                bool *parent_lookup)
> >  {
> >         struct iio_channel *chan;
> >         int index = 0;
> > @@ -221,32 +243,34 @@ struct iio_channel
> > *__of_iio_channel_get_by_name(struct device_node *np,
> >         /*
> >          * For named iio channels, first look up the name in the
> >          * "io-channel-names" property.  If it cannot be found, the
> > -        * index will be an error code, and of_iio_channel_get()
> > +        * index will be an error code, and
> > fwnode_iio_channel_get()
> >          * will fail.
> >          */
> >         if (name)
> > -               index = of_property_match_string(np, "io-channel-
> > names", name);
> > +               index = fwnode_property_match_string(fwnode, "io-
> > channel-names",
> > +                                                    name);
> > 
> > -       chan = of_iio_channel_get(np, index);
> > +       chan = fwnode_iio_channel_get(fwnode, index);
> >         if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
> >                 *parent_lookup = false;
> >         } else if (name && index >= 0) {
> > -               pr_err("ERROR: could not get IIO channel
> > %pOF:%s(%i)\n",
> > -                      np, name ? name : "", index);
> > +               pr_err("ERROR: could not get IIO channel
> > %pfw:%s(%i)\n",
> > +                      fwnode, name ? name : "", index);
> 
> Since you are touching this line can you switch to name ?: "" and
> possibly move some parameters to the above line?

If it does not cross the 80limit col, sure. 
> 
> >                 *parent_lookup = false;
> >         }
> > 
> >         return chan;
> >  }
> > 
> > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > *np,
> > -                                              const char *name)
> > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > fwnode_handle *fwnode,
> > +                                                  const char
> > *name)
> >  {
> >         struct iio_channel *chan;
> > +       struct fwnode_handle *parent;
> >         bool parent_lookup = true;
> > 
> >         /* Walk up the tree of devices looking for a matching iio
> > channel */
> > -       chan = __of_iio_channel_get_by_name(np, name,
> > &parent_lookup);
> > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > &parent_lookup);
> >         if (!parent_lookup)
> >                 return chan;
> > 
> > @@ -255,33 +279,34 @@ struct iio_channel
> > *of_iio_channel_get_by_name(struct device_node *np,
> >          * If the parent node has a "io-channel-ranges" property,
> >          * then we can try one of its channels.
> >          */
> > -       np = np->parent;
> > -       while (np) {
> > -               if (!of_get_property(np, "io-channel-ranges",
> > NULL))
> > +       fwnode_for_each_parent_node(fwnode, parent) {
> > +               if (!fwnode_property_present(parent, "io-channel-
> > ranges")) {
> > +                       fwnode_handle_put(parent);
> >                         return chan;
> 
> break; ?

The return in place was a request from Jonathan in the RFC...

> 
> (Yes, I understand pros and cons of each variant, up to you)
> 
> > +               }
> > 
> > -               chan = __of_iio_channel_get_by_name(np, name,
> > &parent_lookup);
> > -               if (!parent_lookup)
> > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > name, &parent_lookup);
> > +               if (!parent_lookup) {
> > +                       fwnode_handle_put(parent);
> >                         return chan;
> 
> Ditto.
> 
> > -               np = np->parent;
> > +               }
> >         }
> > 
> >         return chan;
> >  }
> > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);
> 
> Wondering if we may move this to the IIO namespace.

I guess it makes sense but surely on a different patch...

> 
> > -static struct iio_channel *of_iio_channel_get_all(struct device
> > *dev)
> > +static struct iio_channel *fwnode_iio_channel_get_all(struct
> > device *dev)
> >  {
> > +       struct fwnode_handle *fwnode = dev_fwnode(dev);
> >         struct iio_channel *chans;
> >         int i, mapind, nummaps = 0;
> >         int ret;
> > 
> >         do {
> > -               ret = of_parse_phandle_with_args(dev->of_node,
> > -                                                "io-channels",
> > -                                                "#io-channel-
> > cells",
> > -                                                nummaps, NULL);
> > +               ret = fwnode_property_get_reference_args(fwnode,
> > "io-channels",
> > +                                                        "#io-
> > channel-cells", 0,
> > +                                                        nummaps,
> > NULL);
> >                 if (ret < 0)
> >                         break;
> >         } while (++nummaps);
> > @@ -294,10 +319,9 @@ static struct iio_channel
> > *of_iio_channel_get_all(struct device *dev)
> >         if (chans == NULL)
> >                 return ERR_PTR(-ENOMEM);
> > 
> > -       /* Search for OF matches */
> > +       /* Search for FW matches */
> >         for (mapind = 0; mapind < nummaps; mapind++) {
> > -               ret = __of_iio_channel_get(&chans[mapind], dev-
> > >of_node,
> > -                                          mapind);
> > +               ret = __fwnode_iio_channel_get(&chans[mapind],
> > fwnode, mapind);
> >                 if (ret)
> >                         goto error_free_chans;
> >         }
> > @@ -310,15 +334,6 @@ static struct iio_channel
> > *of_iio_channel_get_all(struct device *dev)
> >         return ERR_PTR(ret);
> >  }
> > 
> > -#else /* CONFIG_OF */
> > -
> > -static inline struct iio_channel *of_iio_channel_get_all(struct
> > device *dev)
> > -{
> > -       return ERR_PTR(-ENODEV);
> > -}
> > -
> > -#endif /* CONFIG_OF */
> > -
> >  static struct iio_channel *iio_channel_get_sys(const char *name,
> >                                                const char
> > *channel_name)
> >  {
> > @@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct
> > device *dev,
> >         struct iio_channel *channel;
> > 
> >         if (dev) {
> > -               channel = of_iio_channel_get_by_name(dev->of_node,
> > -                                                    channel_name);
> > +               channel =
> > fwnode_iio_channel_get_by_name(dev_fwnode(dev),
> > +                                                       
> > channel_name);
> >                 if (!IS_ERR(channel) || PTR_ERR(channel) == -
> > EPROBE_DEFER)
> >                         return channel;
> >         }
> > @@ -421,14 +436,14 @@ struct iio_channel
> > *devm_iio_channel_get(struct device *dev,
> >  }
> >  EXPORT_SYMBOL_GPL(devm_iio_channel_get);
> > 
> > -struct iio_channel *devm_of_iio_channel_get_by_name(struct device
> > *dev,
> > -                                                   struct
> > device_node *np,
> > -                                                   const char
> > *channel_name)
> > +struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct
> > device *dev,
> > +                                                       struct
> > fwnode_handle *fwnode,
> > +                                                       const char
> > *channel_name)
> >  {
> >         struct iio_channel *channel;
> >         int ret;
> > 
> > -       channel = of_iio_channel_get_by_name(np, channel_name);
> > +       channel = fwnode_iio_channel_get_by_name(fwnode,
> > channel_name);
> >         if (IS_ERR(channel))
> >                 return channel;
> > 
> > @@ -438,7 +453,7 @@ struct iio_channel
> > *devm_of_iio_channel_get_by_name(struct device *dev,
> > 
> >         return channel;
> >  }
> > -EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
> > +EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
> > 
> >  struct iio_channel *iio_channel_get_all(struct device *dev)
> >  {
> > @@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct
> > device *dev)
> >         if (dev == NULL)
> >                 return ERR_PTR(-EINVAL);
> > 
> > -       chans = of_iio_channel_get_all(dev);
> > +       chans = fwnode_iio_channel_get_all(dev);
> >         if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
> >                 return chans;
> > 
> > diff --git a/include/linux/iio/consumer.h
> > b/include/linux/iio/consumer.h
> > index 5fa5957586cf..a96a714b5fdc 100644
> > --- a/include/linux/iio/consumer.h
> > +++ b/include/linux/iio/consumer.h
> > @@ -9,11 +9,13 @@
> > 
> >  #include <linux/types.h>
> >  #include <linux/iio/types.h>
> 
> > +#include <linux/of.h>
> 
> Ordering. IIO has special meaning here, that's why it's last.

ok...

- Nuno Sá



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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-10 20:01       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 20:01 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > This moves the IIO in kernel interface to use fwnode properties and
> > thus
> > be firmware agnostic.
> > 
> > Note that the interface is still not firmware agnostic. At this
> > point we
> > have both OF and fwnode interfaces so that we don't break any user.
> > On
> > top of this we also want to have a per driver conversion and that
> > is the
> > main reason we have both of_xlate() and fwnode_xlate() support.
> 
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Thanks!
> 
> A few nit-picks below, though.
> 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c         | 145 +++++++++++++++++++------------
> > ----
> >  include/linux/iio/consumer.h |  36 +++++----
> >  include/linux/iio/iio.h      |   5 ++
> >  3 files changed, 105 insertions(+), 81 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index dde47324b826..1d519b0cacea 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -5,6 +5,7 @@
> >   */
> >  #include <linux/err.h>
> >  #include <linux/export.h>
> > +#include <linux/property.h>
> >  #include <linux/slab.h>
> >  #include <linux/mutex.h>
> >  #include <linux/of.h>
> > @@ -117,15 +118,13 @@ static const struct iio_chan_spec
> >         return chan;
> >  }
> > 
> > -#ifdef CONFIG_OF
> > -
> >  static int iio_dev_node_match(struct device *dev, const void
> > *data)
> >  {
> > -       return dev->of_node == data && dev->type ==
> > &iio_device_type;
> > +       return device_match_fwnode(dev, data) && dev->type ==
> > &iio_device_type;
> >  }
> > 
> >  /**
> > - * __of_iio_simple_xlate - translate iiospec to the IIO channel
> > index
> > + * __fwnode_iio_simple_xlate - translate iiospec to the IIO
> > channel index
> >   * @indio_dev: pointer to the iio_dev structure
> >   * @iiospec:   IIO specifier as found in the device tree
> >   *
> > @@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device
> > *dev, const void *data)
> >   * whether IIO index is less than num_channels (that is specified
> > in the
> >   * iio_dev).
> >   */
> > -static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
> > -                               const struct of_phandle_args
> > *iiospec)
> > +static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
> > +                                    const struct
> > fwnode_reference_args *iiospec)
> >  {
> > -       if (!iiospec->args_count)
> > +       if (!iiospec->nargs)
> >                 return 0;
> > 
> >         if (iiospec->args[0] >= indio_dev->num_channels) {
> > -               dev_err(&indio_dev->dev, "invalid channel index
> > %u\n",
> > +               dev_err(&indio_dev->dev, "invalid channel index
> > %llu\n",
> >                         iiospec->args[0]);
> >                 return -EINVAL;
> >         }
> > @@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct
> > iio_dev *indio_dev,
> >         return iiospec->args[0];
> >  }
> > 
> > -static int __of_iio_channel_get(struct iio_channel *channel,
> > -                               struct device_node *np, int index)
> > +/*
> > + * Simple helper to copy fwnode_reference_args into
> > of_phandle_args so we
> > + * can pass it to of_xlate(). Ultimate goal is to drop this
> > together with
> > + * of_xlate().
> > + */
> > +static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
> > +                               const struct fwnode_reference_args
> > *iiospec)
> > +{
> > +       struct of_phandle_args of_args;
> > +       unsigned int i;
> > +
> > +       of_args.args_count = iiospec->nargs;
> > +       of_args.np = to_of_node(iiospec->fwnode);
> > +
> > +       for (i = 0; i < MAX_PHANDLE_ARGS; i++)
> > +               of_args.args[i] = i < iiospec->nargs ? iiospec-
> > >args[i] : 0;
> > +
> > +       return indio_dev->info->of_xlate(indio_dev, &of_args);
> > +}
> 
> Ah, now I realized that it's a bit more complicated than just
> to_of_node() :-)
> 

Yeah, of_fwnode_get_reference_args() was helpfull. But I based myself
too much on it. On a second look, I guess ARRAY_SIZE(of_args.args)
would be better than MAX_PHANDLE_ARGS.

> > +static int __fwnode_iio_channel_get(struct iio_channel *channel,
> > +                                   struct fwnode_handle *fwnode,
> > int index)
> >  {
> >         struct device *idev;
> >         struct iio_dev *indio_dev;
> >         int err;
> > -       struct of_phandle_args iiospec;
> > +       struct fwnode_reference_args iiospec;
> 
> At the same point you can move it up in the block to make a long line
> first.

Can do that...

> 
> > -       err = of_parse_phandle_with_args(np, "io-channels",
> > -                                        "#io-channel-cells",
> > -                                        index, &iiospec);
> > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > channels",
> > +                                                "#io-channel-
> > cells", 0,
> > +                                                index, &iiospec);
> >         if (err)
> >                 return err;
> > 
> > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> >                                iio_dev_node_match);
> 
> Wondering if this
> https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> can be utilized (yes, I noticed iio_device_type above).

Hmm, at first glance I would say we can use it. AFAICT, we are already
grabbing a node which contains "#io-channel-cells" which is very
indicative that is an IIO device. I also find it very unlikely to have
two IIO devices with the same fwnode (I guess it would be an issue even
in the old code) and even more unlikely two devices of diferent types
with the same fwnode?

Anyways, I guess Jonathan can help in here...


> 
> >         if (idev == NULL) {
> > -               of_node_put(iiospec.np);
> > +               fwnode_handle_put(iiospec.fwnode);
> >                 return -EPROBE_DEFER;
> >         }
> > 
> >         indio_dev = dev_to_iio_dev(idev);
> >         channel->indio_dev = indio_dev;
> >         if (indio_dev->info->of_xlate)
> > -               index = indio_dev->info->of_xlate(indio_dev,
> > &iiospec);
> > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > +       else if (indio_dev->info->fwnode_xlate)
> > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > &iiospec);
> >         else
> > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > -       of_node_put(iiospec.np);
> > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > &iiospec);
> > +       fwnode_handle_put(iiospec.fwnode);
> >         if (index < 0)
> >                 goto err_put;
> >         channel->channel = &indio_dev->channels[index];
> > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > iio_channel *channel,
> >         return index;
> >  }
> > 
> > -static struct iio_channel *of_iio_channel_get(struct device_node
> > *np, int index)
> > +static struct iio_channel *fwnode_iio_channel_get(struct
> > fwnode_handle *fwnode,
> > +                                                 int index)
> >  {
> >         struct iio_channel *channel;
> >         int err;
> > @@ -200,7 +222,7 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >         if (channel == NULL)
> >                 return ERR_PTR(-ENOMEM);
> > 
> > -       err = __of_iio_channel_get(channel, np, index);
> > +       err = __fwnode_iio_channel_get(channel, fwnode, index);
> >         if (err)
> >                 goto err_free_channel;
> > 
> > @@ -211,9 +233,9 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >         return ERR_PTR(err);
> >  }
> > 
> > -struct iio_channel *__of_iio_channel_get_by_name(struct
> > device_node *np,
> > -                                                const char *name,
> > -                                                bool
> > *parent_lookup)
> > +struct iio_channel *
> > +__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
> > const char *name,
> > +                                bool *parent_lookup)
> >  {
> >         struct iio_channel *chan;
> >         int index = 0;
> > @@ -221,32 +243,34 @@ struct iio_channel
> > *__of_iio_channel_get_by_name(struct device_node *np,
> >         /*
> >          * For named iio channels, first look up the name in the
> >          * "io-channel-names" property.  If it cannot be found, the
> > -        * index will be an error code, and of_iio_channel_get()
> > +        * index will be an error code, and
> > fwnode_iio_channel_get()
> >          * will fail.
> >          */
> >         if (name)
> > -               index = of_property_match_string(np, "io-channel-
> > names", name);
> > +               index = fwnode_property_match_string(fwnode, "io-
> > channel-names",
> > +                                                    name);
> > 
> > -       chan = of_iio_channel_get(np, index);
> > +       chan = fwnode_iio_channel_get(fwnode, index);
> >         if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
> >                 *parent_lookup = false;
> >         } else if (name && index >= 0) {
> > -               pr_err("ERROR: could not get IIO channel
> > %pOF:%s(%i)\n",
> > -                      np, name ? name : "", index);
> > +               pr_err("ERROR: could not get IIO channel
> > %pfw:%s(%i)\n",
> > +                      fwnode, name ? name : "", index);
> 
> Since you are touching this line can you switch to name ?: "" and
> possibly move some parameters to the above line?

If it does not cross the 80limit col, sure. 
> 
> >                 *parent_lookup = false;
> >         }
> > 
> >         return chan;
> >  }
> > 
> > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > *np,
> > -                                              const char *name)
> > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > fwnode_handle *fwnode,
> > +                                                  const char
> > *name)
> >  {
> >         struct iio_channel *chan;
> > +       struct fwnode_handle *parent;
> >         bool parent_lookup = true;
> > 
> >         /* Walk up the tree of devices looking for a matching iio
> > channel */
> > -       chan = __of_iio_channel_get_by_name(np, name,
> > &parent_lookup);
> > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > &parent_lookup);
> >         if (!parent_lookup)
> >                 return chan;
> > 
> > @@ -255,33 +279,34 @@ struct iio_channel
> > *of_iio_channel_get_by_name(struct device_node *np,
> >          * If the parent node has a "io-channel-ranges" property,
> >          * then we can try one of its channels.
> >          */
> > -       np = np->parent;
> > -       while (np) {
> > -               if (!of_get_property(np, "io-channel-ranges",
> > NULL))
> > +       fwnode_for_each_parent_node(fwnode, parent) {
> > +               if (!fwnode_property_present(parent, "io-channel-
> > ranges")) {
> > +                       fwnode_handle_put(parent);
> >                         return chan;
> 
> break; ?

The return in place was a request from Jonathan in the RFC...

> 
> (Yes, I understand pros and cons of each variant, up to you)
> 
> > +               }
> > 
> > -               chan = __of_iio_channel_get_by_name(np, name,
> > &parent_lookup);
> > -               if (!parent_lookup)
> > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > name, &parent_lookup);
> > +               if (!parent_lookup) {
> > +                       fwnode_handle_put(parent);
> >                         return chan;
> 
> Ditto.
> 
> > -               np = np->parent;
> > +               }
> >         }
> > 
> >         return chan;
> >  }
> > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);
> 
> Wondering if we may move this to the IIO namespace.

I guess it makes sense but surely on a different patch...

> 
> > -static struct iio_channel *of_iio_channel_get_all(struct device
> > *dev)
> > +static struct iio_channel *fwnode_iio_channel_get_all(struct
> > device *dev)
> >  {
> > +       struct fwnode_handle *fwnode = dev_fwnode(dev);
> >         struct iio_channel *chans;
> >         int i, mapind, nummaps = 0;
> >         int ret;
> > 
> >         do {
> > -               ret = of_parse_phandle_with_args(dev->of_node,
> > -                                                "io-channels",
> > -                                                "#io-channel-
> > cells",
> > -                                                nummaps, NULL);
> > +               ret = fwnode_property_get_reference_args(fwnode,
> > "io-channels",
> > +                                                        "#io-
> > channel-cells", 0,
> > +                                                        nummaps,
> > NULL);
> >                 if (ret < 0)
> >                         break;
> >         } while (++nummaps);
> > @@ -294,10 +319,9 @@ static struct iio_channel
> > *of_iio_channel_get_all(struct device *dev)
> >         if (chans == NULL)
> >                 return ERR_PTR(-ENOMEM);
> > 
> > -       /* Search for OF matches */
> > +       /* Search for FW matches */
> >         for (mapind = 0; mapind < nummaps; mapind++) {
> > -               ret = __of_iio_channel_get(&chans[mapind], dev-
> > >of_node,
> > -                                          mapind);
> > +               ret = __fwnode_iio_channel_get(&chans[mapind],
> > fwnode, mapind);
> >                 if (ret)
> >                         goto error_free_chans;
> >         }
> > @@ -310,15 +334,6 @@ static struct iio_channel
> > *of_iio_channel_get_all(struct device *dev)
> >         return ERR_PTR(ret);
> >  }
> > 
> > -#else /* CONFIG_OF */
> > -
> > -static inline struct iio_channel *of_iio_channel_get_all(struct
> > device *dev)
> > -{
> > -       return ERR_PTR(-ENODEV);
> > -}
> > -
> > -#endif /* CONFIG_OF */
> > -
> >  static struct iio_channel *iio_channel_get_sys(const char *name,
> >                                                const char
> > *channel_name)
> >  {
> > @@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct
> > device *dev,
> >         struct iio_channel *channel;
> > 
> >         if (dev) {
> > -               channel = of_iio_channel_get_by_name(dev->of_node,
> > -                                                    channel_name);
> > +               channel =
> > fwnode_iio_channel_get_by_name(dev_fwnode(dev),
> > +                                                       
> > channel_name);
> >                 if (!IS_ERR(channel) || PTR_ERR(channel) == -
> > EPROBE_DEFER)
> >                         return channel;
> >         }
> > @@ -421,14 +436,14 @@ struct iio_channel
> > *devm_iio_channel_get(struct device *dev,
> >  }
> >  EXPORT_SYMBOL_GPL(devm_iio_channel_get);
> > 
> > -struct iio_channel *devm_of_iio_channel_get_by_name(struct device
> > *dev,
> > -                                                   struct
> > device_node *np,
> > -                                                   const char
> > *channel_name)
> > +struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct
> > device *dev,
> > +                                                       struct
> > fwnode_handle *fwnode,
> > +                                                       const char
> > *channel_name)
> >  {
> >         struct iio_channel *channel;
> >         int ret;
> > 
> > -       channel = of_iio_channel_get_by_name(np, channel_name);
> > +       channel = fwnode_iio_channel_get_by_name(fwnode,
> > channel_name);
> >         if (IS_ERR(channel))
> >                 return channel;
> > 
> > @@ -438,7 +453,7 @@ struct iio_channel
> > *devm_of_iio_channel_get_by_name(struct device *dev,
> > 
> >         return channel;
> >  }
> > -EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
> > +EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
> > 
> >  struct iio_channel *iio_channel_get_all(struct device *dev)
> >  {
> > @@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct
> > device *dev)
> >         if (dev == NULL)
> >                 return ERR_PTR(-EINVAL);
> > 
> > -       chans = of_iio_channel_get_all(dev);
> > +       chans = fwnode_iio_channel_get_all(dev);
> >         if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
> >                 return chans;
> > 
> > diff --git a/include/linux/iio/consumer.h
> > b/include/linux/iio/consumer.h
> > index 5fa5957586cf..a96a714b5fdc 100644
> > --- a/include/linux/iio/consumer.h
> > +++ b/include/linux/iio/consumer.h
> > @@ -9,11 +9,13 @@
> > 
> >  #include <linux/types.h>
> >  #include <linux/iio/types.h>
> 
> > +#include <linux/of.h>
> 
> Ordering. IIO has special meaning here, that's why it's last.

ok...

- Nuno Sá



_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-10 20:01       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 20:01 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, OpenBMC Maillist,
	Jishnu Prakash, Haibo Chen, Andy Gross, dl-linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier,
	moderated list:ARM/Mediatek SoC support, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm Mailing List,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	open list:BROADCOM NVRAM DRIVER, Thara Gopinath, Linux-Renesas,
	Arnd Bergmann, Maxime Coquelin, Cai Huoqing, Shawn Guo,
	Claudiu Beznea, Jonathan Cameron

On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > This moves the IIO in kernel interface to use fwnode properties and
> > thus
> > be firmware agnostic.
> > 
> > Note that the interface is still not firmware agnostic. At this
> > point we
> > have both OF and fwnode interfaces so that we don't break any user.
> > On
> > top of this we also want to have a per driver conversion and that
> > is the
> > main reason we have both of_xlate() and fwnode_xlate() support.
> 
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Thanks!
> 
> A few nit-picks below, though.
> 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c         | 145 +++++++++++++++++++------------
> > ----
> >  include/linux/iio/consumer.h |  36 +++++----
> >  include/linux/iio/iio.h      |   5 ++
> >  3 files changed, 105 insertions(+), 81 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index dde47324b826..1d519b0cacea 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -5,6 +5,7 @@
> >   */
> >  #include <linux/err.h>
> >  #include <linux/export.h>
> > +#include <linux/property.h>
> >  #include <linux/slab.h>
> >  #include <linux/mutex.h>
> >  #include <linux/of.h>
> > @@ -117,15 +118,13 @@ static const struct iio_chan_spec
> >         return chan;
> >  }
> > 
> > -#ifdef CONFIG_OF
> > -
> >  static int iio_dev_node_match(struct device *dev, const void
> > *data)
> >  {
> > -       return dev->of_node == data && dev->type ==
> > &iio_device_type;
> > +       return device_match_fwnode(dev, data) && dev->type ==
> > &iio_device_type;
> >  }
> > 
> >  /**
> > - * __of_iio_simple_xlate - translate iiospec to the IIO channel
> > index
> > + * __fwnode_iio_simple_xlate - translate iiospec to the IIO
> > channel index
> >   * @indio_dev: pointer to the iio_dev structure
> >   * @iiospec:   IIO specifier as found in the device tree
> >   *
> > @@ -134,14 +133,14 @@ static int iio_dev_node_match(struct device
> > *dev, const void *data)
> >   * whether IIO index is less than num_channels (that is specified
> > in the
> >   * iio_dev).
> >   */
> > -static int __of_iio_simple_xlate(struct iio_dev *indio_dev,
> > -                               const struct of_phandle_args
> > *iiospec)
> > +static int __fwnode_iio_simple_xlate(struct iio_dev *indio_dev,
> > +                                    const struct
> > fwnode_reference_args *iiospec)
> >  {
> > -       if (!iiospec->args_count)
> > +       if (!iiospec->nargs)
> >                 return 0;
> > 
> >         if (iiospec->args[0] >= indio_dev->num_channels) {
> > -               dev_err(&indio_dev->dev, "invalid channel index
> > %u\n",
> > +               dev_err(&indio_dev->dev, "invalid channel index
> > %llu\n",
> >                         iiospec->args[0]);
> >                 return -EINVAL;
> >         }
> > @@ -149,34 +148,56 @@ static int __of_iio_simple_xlate(struct
> > iio_dev *indio_dev,
> >         return iiospec->args[0];
> >  }
> > 
> > -static int __of_iio_channel_get(struct iio_channel *channel,
> > -                               struct device_node *np, int index)
> > +/*
> > + * Simple helper to copy fwnode_reference_args into
> > of_phandle_args so we
> > + * can pass it to of_xlate(). Ultimate goal is to drop this
> > together with
> > + * of_xlate().
> > + */
> > +static int __fwnode_to_of_xlate(struct iio_dev *indio_dev,
> > +                               const struct fwnode_reference_args
> > *iiospec)
> > +{
> > +       struct of_phandle_args of_args;
> > +       unsigned int i;
> > +
> > +       of_args.args_count = iiospec->nargs;
> > +       of_args.np = to_of_node(iiospec->fwnode);
> > +
> > +       for (i = 0; i < MAX_PHANDLE_ARGS; i++)
> > +               of_args.args[i] = i < iiospec->nargs ? iiospec-
> > >args[i] : 0;
> > +
> > +       return indio_dev->info->of_xlate(indio_dev, &of_args);
> > +}
> 
> Ah, now I realized that it's a bit more complicated than just
> to_of_node() :-)
> 

Yeah, of_fwnode_get_reference_args() was helpfull. But I based myself
too much on it. On a second look, I guess ARRAY_SIZE(of_args.args)
would be better than MAX_PHANDLE_ARGS.

> > +static int __fwnode_iio_channel_get(struct iio_channel *channel,
> > +                                   struct fwnode_handle *fwnode,
> > int index)
> >  {
> >         struct device *idev;
> >         struct iio_dev *indio_dev;
> >         int err;
> > -       struct of_phandle_args iiospec;
> > +       struct fwnode_reference_args iiospec;
> 
> At the same point you can move it up in the block to make a long line
> first.

Can do that...

> 
> > -       err = of_parse_phandle_with_args(np, "io-channels",
> > -                                        "#io-channel-cells",
> > -                                        index, &iiospec);
> > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > channels",
> > +                                                "#io-channel-
> > cells", 0,
> > +                                                index, &iiospec);
> >         if (err)
> >                 return err;
> > 
> > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> >                                iio_dev_node_match);
> 
> Wondering if this
> https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> can be utilized (yes, I noticed iio_device_type above).

Hmm, at first glance I would say we can use it. AFAICT, we are already
grabbing a node which contains "#io-channel-cells" which is very
indicative that is an IIO device. I also find it very unlikely to have
two IIO devices with the same fwnode (I guess it would be an issue even
in the old code) and even more unlikely two devices of diferent types
with the same fwnode?

Anyways, I guess Jonathan can help in here...


> 
> >         if (idev == NULL) {
> > -               of_node_put(iiospec.np);
> > +               fwnode_handle_put(iiospec.fwnode);
> >                 return -EPROBE_DEFER;
> >         }
> > 
> >         indio_dev = dev_to_iio_dev(idev);
> >         channel->indio_dev = indio_dev;
> >         if (indio_dev->info->of_xlate)
> > -               index = indio_dev->info->of_xlate(indio_dev,
> > &iiospec);
> > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > +       else if (indio_dev->info->fwnode_xlate)
> > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > &iiospec);
> >         else
> > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > -       of_node_put(iiospec.np);
> > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > &iiospec);
> > +       fwnode_handle_put(iiospec.fwnode);
> >         if (index < 0)
> >                 goto err_put;
> >         channel->channel = &indio_dev->channels[index];
> > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > iio_channel *channel,
> >         return index;
> >  }
> > 
> > -static struct iio_channel *of_iio_channel_get(struct device_node
> > *np, int index)
> > +static struct iio_channel *fwnode_iio_channel_get(struct
> > fwnode_handle *fwnode,
> > +                                                 int index)
> >  {
> >         struct iio_channel *channel;
> >         int err;
> > @@ -200,7 +222,7 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >         if (channel == NULL)
> >                 return ERR_PTR(-ENOMEM);
> > 
> > -       err = __of_iio_channel_get(channel, np, index);
> > +       err = __fwnode_iio_channel_get(channel, fwnode, index);
> >         if (err)
> >                 goto err_free_channel;
> > 
> > @@ -211,9 +233,9 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >         return ERR_PTR(err);
> >  }
> > 
> > -struct iio_channel *__of_iio_channel_get_by_name(struct
> > device_node *np,
> > -                                                const char *name,
> > -                                                bool
> > *parent_lookup)
> > +struct iio_channel *
> > +__fwnode_iio_channel_get_by_name(struct fwnode_handle *fwnode,
> > const char *name,
> > +                                bool *parent_lookup)
> >  {
> >         struct iio_channel *chan;
> >         int index = 0;
> > @@ -221,32 +243,34 @@ struct iio_channel
> > *__of_iio_channel_get_by_name(struct device_node *np,
> >         /*
> >          * For named iio channels, first look up the name in the
> >          * "io-channel-names" property.  If it cannot be found, the
> > -        * index will be an error code, and of_iio_channel_get()
> > +        * index will be an error code, and
> > fwnode_iio_channel_get()
> >          * will fail.
> >          */
> >         if (name)
> > -               index = of_property_match_string(np, "io-channel-
> > names", name);
> > +               index = fwnode_property_match_string(fwnode, "io-
> > channel-names",
> > +                                                    name);
> > 
> > -       chan = of_iio_channel_get(np, index);
> > +       chan = fwnode_iio_channel_get(fwnode, index);
> >         if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER) {
> >                 *parent_lookup = false;
> >         } else if (name && index >= 0) {
> > -               pr_err("ERROR: could not get IIO channel
> > %pOF:%s(%i)\n",
> > -                      np, name ? name : "", index);
> > +               pr_err("ERROR: could not get IIO channel
> > %pfw:%s(%i)\n",
> > +                      fwnode, name ? name : "", index);
> 
> Since you are touching this line can you switch to name ?: "" and
> possibly move some parameters to the above line?

If it does not cross the 80limit col, sure. 
> 
> >                 *parent_lookup = false;
> >         }
> > 
> >         return chan;
> >  }
> > 
> > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > *np,
> > -                                              const char *name)
> > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > fwnode_handle *fwnode,
> > +                                                  const char
> > *name)
> >  {
> >         struct iio_channel *chan;
> > +       struct fwnode_handle *parent;
> >         bool parent_lookup = true;
> > 
> >         /* Walk up the tree of devices looking for a matching iio
> > channel */
> > -       chan = __of_iio_channel_get_by_name(np, name,
> > &parent_lookup);
> > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > &parent_lookup);
> >         if (!parent_lookup)
> >                 return chan;
> > 
> > @@ -255,33 +279,34 @@ struct iio_channel
> > *of_iio_channel_get_by_name(struct device_node *np,
> >          * If the parent node has a "io-channel-ranges" property,
> >          * then we can try one of its channels.
> >          */
> > -       np = np->parent;
> > -       while (np) {
> > -               if (!of_get_property(np, "io-channel-ranges",
> > NULL))
> > +       fwnode_for_each_parent_node(fwnode, parent) {
> > +               if (!fwnode_property_present(parent, "io-channel-
> > ranges")) {
> > +                       fwnode_handle_put(parent);
> >                         return chan;
> 
> break; ?

The return in place was a request from Jonathan in the RFC...

> 
> (Yes, I understand pros and cons of each variant, up to you)
> 
> > +               }
> > 
> > -               chan = __of_iio_channel_get_by_name(np, name,
> > &parent_lookup);
> > -               if (!parent_lookup)
> > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > name, &parent_lookup);
> > +               if (!parent_lookup) {
> > +                       fwnode_handle_put(parent);
> >                         return chan;
> 
> Ditto.
> 
> > -               np = np->parent;
> > +               }
> >         }
> > 
> >         return chan;
> >  }
> > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);
> 
> Wondering if we may move this to the IIO namespace.

I guess it makes sense but surely on a different patch...

> 
> > -static struct iio_channel *of_iio_channel_get_all(struct device
> > *dev)
> > +static struct iio_channel *fwnode_iio_channel_get_all(struct
> > device *dev)
> >  {
> > +       struct fwnode_handle *fwnode = dev_fwnode(dev);
> >         struct iio_channel *chans;
> >         int i, mapind, nummaps = 0;
> >         int ret;
> > 
> >         do {
> > -               ret = of_parse_phandle_with_args(dev->of_node,
> > -                                                "io-channels",
> > -                                                "#io-channel-
> > cells",
> > -                                                nummaps, NULL);
> > +               ret = fwnode_property_get_reference_args(fwnode,
> > "io-channels",
> > +                                                        "#io-
> > channel-cells", 0,
> > +                                                        nummaps,
> > NULL);
> >                 if (ret < 0)
> >                         break;
> >         } while (++nummaps);
> > @@ -294,10 +319,9 @@ static struct iio_channel
> > *of_iio_channel_get_all(struct device *dev)
> >         if (chans == NULL)
> >                 return ERR_PTR(-ENOMEM);
> > 
> > -       /* Search for OF matches */
> > +       /* Search for FW matches */
> >         for (mapind = 0; mapind < nummaps; mapind++) {
> > -               ret = __of_iio_channel_get(&chans[mapind], dev-
> > >of_node,
> > -                                          mapind);
> > +               ret = __fwnode_iio_channel_get(&chans[mapind],
> > fwnode, mapind);
> >                 if (ret)
> >                         goto error_free_chans;
> >         }
> > @@ -310,15 +334,6 @@ static struct iio_channel
> > *of_iio_channel_get_all(struct device *dev)
> >         return ERR_PTR(ret);
> >  }
> > 
> > -#else /* CONFIG_OF */
> > -
> > -static inline struct iio_channel *of_iio_channel_get_all(struct
> > device *dev)
> > -{
> > -       return ERR_PTR(-ENODEV);
> > -}
> > -
> > -#endif /* CONFIG_OF */
> > -
> >  static struct iio_channel *iio_channel_get_sys(const char *name,
> >                                                const char
> > *channel_name)
> >  {
> > @@ -379,8 +394,8 @@ struct iio_channel *iio_channel_get(struct
> > device *dev,
> >         struct iio_channel *channel;
> > 
> >         if (dev) {
> > -               channel = of_iio_channel_get_by_name(dev->of_node,
> > -                                                    channel_name);
> > +               channel =
> > fwnode_iio_channel_get_by_name(dev_fwnode(dev),
> > +                                                       
> > channel_name);
> >                 if (!IS_ERR(channel) || PTR_ERR(channel) == -
> > EPROBE_DEFER)
> >                         return channel;
> >         }
> > @@ -421,14 +436,14 @@ struct iio_channel
> > *devm_iio_channel_get(struct device *dev,
> >  }
> >  EXPORT_SYMBOL_GPL(devm_iio_channel_get);
> > 
> > -struct iio_channel *devm_of_iio_channel_get_by_name(struct device
> > *dev,
> > -                                                   struct
> > device_node *np,
> > -                                                   const char
> > *channel_name)
> > +struct iio_channel *devm_fwnode_iio_channel_get_by_name(struct
> > device *dev,
> > +                                                       struct
> > fwnode_handle *fwnode,
> > +                                                       const char
> > *channel_name)
> >  {
> >         struct iio_channel *channel;
> >         int ret;
> > 
> > -       channel = of_iio_channel_get_by_name(np, channel_name);
> > +       channel = fwnode_iio_channel_get_by_name(fwnode,
> > channel_name);
> >         if (IS_ERR(channel))
> >                 return channel;
> > 
> > @@ -438,7 +453,7 @@ struct iio_channel
> > *devm_of_iio_channel_get_by_name(struct device *dev,
> > 
> >         return channel;
> >  }
> > -EXPORT_SYMBOL_GPL(devm_of_iio_channel_get_by_name);
> > +EXPORT_SYMBOL_GPL(devm_fwnode_iio_channel_get_by_name);
> > 
> >  struct iio_channel *iio_channel_get_all(struct device *dev)
> >  {
> > @@ -452,7 +467,7 @@ struct iio_channel *iio_channel_get_all(struct
> > device *dev)
> >         if (dev == NULL)
> >                 return ERR_PTR(-EINVAL);
> > 
> > -       chans = of_iio_channel_get_all(dev);
> > +       chans = fwnode_iio_channel_get_all(dev);
> >         if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)
> >                 return chans;
> > 
> > diff --git a/include/linux/iio/consumer.h
> > b/include/linux/iio/consumer.h
> > index 5fa5957586cf..a96a714b5fdc 100644
> > --- a/include/linux/iio/consumer.h
> > +++ b/include/linux/iio/consumer.h
> > @@ -9,11 +9,13 @@
> > 
> >  #include <linux/types.h>
> >  #include <linux/iio/types.h>
> 
> > +#include <linux/of.h>
> 
> Ordering. IIO has special meaning here, that's why it's last.

ok...

- Nuno Sá



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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-10 14:56     ` Andy Shevchenko
  (?)
@ 2022-06-10 20:08       ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 20:08 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > 'of_node_put()' can potentially release the memory pointed to by
> > 'iiospec.np' which would leave us with an invalid pointer (and we
> > would
> > still pass it in 'of_xlate()'). As such, we can only release the
> > node
> > after we are done with it.
> 
> The question you should answer in the commit message is the
> following:
> "Can an OF node, attached to a struct device, be gone before the
> device itself?" If it so, then patch is good, otherwise there is no
> point in this patch in the first place.
> 

Yeah, I might be wrong but from a quick look... yes, I think the node
can be gone before the device. Take a look on the spi or i2c of_notify
handling and you can see that the nodes are get/put on the add/remove
notifcation. Meaning that the node lifespan is not really attached to
the device lifespan. If it was, I would expect to see of_node_put() on
the device release() function...

Again, I might be wrong and I admit I was not sure about including this
patch because it's a very unlikely scenario even though I think, in
theory, a possible one.

- Nuno Sá


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-10 20:08       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 20:08 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Jonathan Cameron,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > 'of_node_put()' can potentially release the memory pointed to by
> > 'iiospec.np' which would leave us with an invalid pointer (and we
> > would
> > still pass it in 'of_xlate()'). As such, we can only release the
> > node
> > after we are done with it.
> 
> The question you should answer in the commit message is the
> following:
> "Can an OF node, attached to a struct device, be gone before the
> device itself?" If it so, then patch is good, otherwise there is no
> point in this patch in the first place.
> 

Yeah, I might be wrong but from a quick look... yes, I think the node
can be gone before the device. Take a look on the spi or i2c of_notify
handling and you can see that the nodes are get/put on the add/remove
notifcation. Meaning that the node lifespan is not really attached to
the device lifespan. If it was, I would expect to see of_node_put() on
the device release() function...

Again, I might be wrong and I admit I was not sure about including this
patch because it's a very unlikely scenario even though I think, in
theory, a possible one.

- Nuno Sá


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-10 20:08       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-10 20:08 UTC (permalink / raw)
  To: Andy Shevchenko, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, OpenBMC Maillist,
	Jishnu Prakash, Haibo Chen, Andy Gross, dl-linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier,
	moderated list:ARM/Mediatek SoC support, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm Mailing List,
	Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	open list:BROADCOM NVRAM DRIVER, Thara Gopinath, Linux-Renesas,
	Arnd Bergmann, Maxime Coquelin, Cai Huoqing, Shawn Guo,
	Claudiu Beznea, Jonathan Cameron

On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:
> > 
> > 'of_node_put()' can potentially release the memory pointed to by
> > 'iiospec.np' which would leave us with an invalid pointer (and we
> > would
> > still pass it in 'of_xlate()'). As such, we can only release the
> > node
> > after we are done with it.
> 
> The question you should answer in the commit message is the
> following:
> "Can an OF node, attached to a struct device, be gone before the
> device itself?" If it so, then patch is good, otherwise there is no
> point in this patch in the first place.
> 

Yeah, I might be wrong but from a quick look... yes, I think the node
can be gone before the device. Take a look on the spi or i2c of_notify
handling and you can see that the nodes are get/put on the add/remove
notifcation. Meaning that the node lifespan is not really attached to
the device lifespan. If it was, I would expect to see of_node_put() on
the device release() function...

Again, I might be wrong and I admit I was not sure about including this
patch because it's a very unlikely scenario even though I think, in
theory, a possible one.

- Nuno Sá


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

* Re: [PATCH 01/34] iio: adc: ad7606: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 13:59     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 13:59 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:12 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Hi Nuno,

Not sure how far I'll get through the series, but to try and
reduce the noise / traffic for any future versions I'm going to
pick up as many of these precursor patches as possible.

Applied to the togreg branch of iio.git (which just got rebased
on v5.19-rc1) and pushed out as testing for 0-day to take a quick
look and see if we missed anything.

Thanks,

Jonathan


> ---
>  drivers/iio/adc/ad7606.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 3b193dc26438..ba24f99523e0 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -12,6 +12,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>


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

* Re: [PATCH 01/34] iio: adc: ad7606: explicitly add proper header files
@ 2022-06-11 13:59     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 13:59 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:12 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Hi Nuno,

Not sure how far I'll get through the series, but to try and
reduce the noise / traffic for any future versions I'm going to
pick up as many of these precursor patches as possible.

Applied to the togreg branch of iio.git (which just got rebased
on v5.19-rc1) and pushed out as testing for 0-day to take a quick
look and see if we missed anything.

Thanks,

Jonathan


> ---
>  drivers/iio/adc/ad7606.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 3b193dc26438..ba24f99523e0 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -12,6 +12,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 01/34] iio: adc: ad7606: explicitly add proper header files
@ 2022-06-11 13:59     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 13:59 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:12 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Hi Nuno,

Not sure how far I'll get through the series, but to try and
reduce the noise / traffic for any future versions I'm going to
pick up as many of these precursor patches as possible.

Applied to the togreg branch of iio.git (which just got rebased
on v5.19-rc1) and pushed out as testing for 0-day to take a quick
look and see if we missed anything.

Thanks,

Jonathan


> ---
>  drivers/iio/adc/ad7606.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 3b193dc26438..ba24f99523e0 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -12,6 +12,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/property.h>
>  #include <linux/regulator/consumer.h>
>  #include <linux/sched.h>
>  #include <linux/slab.h>


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

* Re: [PATCH 02/34] iio: adc: ad7606_par: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:00     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:00 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:13 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/adc/ad7606_par.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
> index 8888e56b5e90..b912b4df9b56 100644
> --- a/drivers/iio/adc/ad7606_par.c
> +++ b/drivers/iio/adc/ad7606_par.c
> @@ -5,6 +5,7 @@
>   * Copyright 2011 Analog Devices Inc.
>   */
>  
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/types.h>


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

* Re: [PATCH 02/34] iio: adc: ad7606_par: explicitly add proper header files
@ 2022-06-11 14:00     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:00 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:13 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/adc/ad7606_par.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
> index 8888e56b5e90..b912b4df9b56 100644
> --- a/drivers/iio/adc/ad7606_par.c
> +++ b/drivers/iio/adc/ad7606_par.c
> @@ -5,6 +5,7 @@
>   * Copyright 2011 Analog Devices Inc.
>   */
>  
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/types.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 02/34] iio: adc: ad7606_par: explicitly add proper header files
@ 2022-06-11 14:00     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:00 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:13 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/adc/ad7606_par.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/ad7606_par.c b/drivers/iio/adc/ad7606_par.c
> index 8888e56b5e90..b912b4df9b56 100644
> --- a/drivers/iio/adc/ad7606_par.c
> +++ b/drivers/iio/adc/ad7606_par.c
> @@ -5,6 +5,7 @@
>   * Copyright 2011 Analog Devices Inc.
>   */
>  
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/types.h>


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

* Re: [PATCH 03/34] iio: adc: berlin2-adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:02     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:02 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:14 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

Thanks,

> ---
>  drivers/iio/adc/berlin2-adc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
> index 03987d7e6b3d..3d2e8b4db61a 100644
> --- a/drivers/iio/adc/berlin2-adc.c
> +++ b/drivers/iio/adc/berlin2-adc.c
> @@ -15,7 +15,9 @@
>  #include <linux/iio/machine.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/mfd/syscon.h>


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

* Re: [PATCH 03/34] iio: adc: berlin2-adc: explicitly add proper header files
@ 2022-06-11 14:02     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:02 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:14 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

Thanks,

> ---
>  drivers/iio/adc/berlin2-adc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
> index 03987d7e6b3d..3d2e8b4db61a 100644
> --- a/drivers/iio/adc/berlin2-adc.c
> +++ b/drivers/iio/adc/berlin2-adc.c
> @@ -15,7 +15,9 @@
>  #include <linux/iio/machine.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/mfd/syscon.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 03/34] iio: adc: berlin2-adc: explicitly add proper header files
@ 2022-06-11 14:02     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:02 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:14 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

Thanks,

> ---
>  drivers/iio/adc/berlin2-adc.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
> index 03987d7e6b3d..3d2e8b4db61a 100644
> --- a/drivers/iio/adc/berlin2-adc.c
> +++ b/drivers/iio/adc/berlin2-adc.c
> @@ -15,7 +15,9 @@
>  #include <linux/iio/machine.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/slab.h>
>  #include <linux/mfd/syscon.h>


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

* Re: [PATCH 04/34] iio: adc: imx7d_adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:04     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:04 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:15 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.
> ---
>  drivers/iio/adc/imx7d_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
> index 12f5b8e34c84..119217af2bde 100644
> --- a/drivers/iio/adc/imx7d_adc.c
> +++ b/drivers/iio/adc/imx7d_adc.c
> @@ -11,6 +11,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>


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

* Re: [PATCH 04/34] iio: adc: imx7d_adc: explicitly add proper header files
@ 2022-06-11 14:04     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:04 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:15 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.
> ---
>  drivers/iio/adc/imx7d_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
> index 12f5b8e34c84..119217af2bde 100644
> --- a/drivers/iio/adc/imx7d_adc.c
> +++ b/drivers/iio/adc/imx7d_adc.c
> @@ -11,6 +11,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 04/34] iio: adc: imx7d_adc: explicitly add proper header files
@ 2022-06-11 14:04     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:04 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:15 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.
> ---
>  drivers/iio/adc/imx7d_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/imx7d_adc.c b/drivers/iio/adc/imx7d_adc.c
> index 12f5b8e34c84..119217af2bde 100644
> --- a/drivers/iio/adc/imx7d_adc.c
> +++ b/drivers/iio/adc/imx7d_adc.c
> @@ -11,6 +11,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>


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

* Re: [PATCH 05/34] iio: adc: imx8qxp-adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:05     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:05 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:16 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/imx8qxp-adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
> index 901dd8e1b32f..e8c9a69e10eb 100644
> --- a/drivers/iio/adc/imx8qxp-adc.c
> +++ b/drivers/iio/adc/imx8qxp-adc.c
> @@ -19,6 +19,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>


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

* Re: [PATCH 05/34] iio: adc: imx8qxp-adc: explicitly add proper header files
@ 2022-06-11 14:05     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:05 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:16 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/imx8qxp-adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
> index 901dd8e1b32f..e8c9a69e10eb 100644
> --- a/drivers/iio/adc/imx8qxp-adc.c
> +++ b/drivers/iio/adc/imx8qxp-adc.c
> @@ -19,6 +19,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 05/34] iio: adc: imx8qxp-adc: explicitly add proper header files
@ 2022-06-11 14:05     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:05 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:16 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/imx8qxp-adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/imx8qxp-adc.c b/drivers/iio/adc/imx8qxp-adc.c
> index 901dd8e1b32f..e8c9a69e10eb 100644
> --- a/drivers/iio/adc/imx8qxp-adc.c
> +++ b/drivers/iio/adc/imx8qxp-adc.c
> @@ -19,6 +19,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>


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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
  2022-06-10 19:49       ` Nuno Sá
  (?)
@ 2022-06-11 14:07         ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:07 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 21:49:22 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 16:45 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > Do not trust the fact that iio.h includes of.h which in turn
> > > includes
> > > all the headers we are relying on.
> > > 
> > > The ultimate goal is to actually drop of.h from iio.h.  
> > 
> > ...
> >   
> > >  #include <linux/mod_devicetable.h>
> > >  #include <linux/mutex.h>
> > >  #include <linux/platform_device.h>
> > > +#include <linux/property.h>
> > > +#include <linux/of.h>  
> > 
> > Ordering (from the context I don't see it's messed up already)
> >   
> 
> Will double check on v2...

Fixed up whilst applying...

> 
> - Nuno Sá


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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
@ 2022-06-11 14:07         ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:07 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 21:49:22 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 16:45 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > Do not trust the fact that iio.h includes of.h which in turn
> > > includes
> > > all the headers we are relying on.
> > > 
> > > The ultimate goal is to actually drop of.h from iio.h.  
> > 
> > ...
> >   
> > >  #include <linux/mod_devicetable.h>
> > >  #include <linux/mutex.h>
> > >  #include <linux/platform_device.h>
> > > +#include <linux/property.h>
> > > +#include <linux/of.h>  
> > 
> > Ordering (from the context I don't see it's messed up already)
> >   
> 
> Will double check on v2...

Fixed up whilst applying...

> 
> - Nuno Sá


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 06/34] iio: adc: ingenic-adc: explicitly add proper header files
@ 2022-06-11 14:07         ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:07 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	OpenBMC Maillist, Jishnu Prakash, Haibo Chen, Andy Shevchenko,
	Andy Gross, dl-linux-imx, Olivier Moysan, Zhang Rui

On Fri, 10 Jun 2022 21:49:22 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 16:45 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:46 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > Do not trust the fact that iio.h includes of.h which in turn
> > > includes
> > > all the headers we are relying on.
> > > 
> > > The ultimate goal is to actually drop of.h from iio.h.  
> > 
> > ...
> >   
> > >  #include <linux/mod_devicetable.h>
> > >  #include <linux/mutex.h>
> > >  #include <linux/platform_device.h>
> > > +#include <linux/property.h>
> > > +#include <linux/of.h>  
> > 
> > Ordering (from the context I don't see it's messed up already)
> >   
> 
> Will double check on v2...

Fixed up whilst applying...

> 
> - Nuno Sá


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

* Re: [PATCH 07/34] iio: adc: mp2629_adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:08     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:08 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:18 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/mp2629_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
> index aca084f1e78a..30a31f185d08 100644
> --- a/drivers/iio/adc/mp2629_adc.c
> +++ b/drivers/iio/adc/mp2629_adc.c
> @@ -11,6 +11,7 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/machine.h>
>  #include <linux/mfd/mp2629.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>


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

* Re: [PATCH 07/34] iio: adc: mp2629_adc: explicitly add proper header files
@ 2022-06-11 14:08     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:08 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:18 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/mp2629_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
> index aca084f1e78a..30a31f185d08 100644
> --- a/drivers/iio/adc/mp2629_adc.c
> +++ b/drivers/iio/adc/mp2629_adc.c
> @@ -11,6 +11,7 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/machine.h>
>  #include <linux/mfd/mp2629.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 07/34] iio: adc: mp2629_adc: explicitly add proper header files
@ 2022-06-11 14:08     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:08 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:18 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/mp2629_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mp2629_adc.c b/drivers/iio/adc/mp2629_adc.c
> index aca084f1e78a..30a31f185d08 100644
> --- a/drivers/iio/adc/mp2629_adc.c
> +++ b/drivers/iio/adc/mp2629_adc.c
> @@ -11,6 +11,7 @@
>  #include <linux/iio/iio.h>
>  #include <linux/iio/machine.h>
>  #include <linux/mfd/mp2629.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>


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

* Re: [PATCH 08/34] iio: adc: mt6360-adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:09     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:09 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:19 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/mt6360-adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
> index 07c0e6768391..35260d9e4e47 100644
> --- a/drivers/iio/adc/mt6360-adc.c
> +++ b/drivers/iio/adc/mt6360-adc.c
> @@ -5,6 +5,7 @@
>  #include <linux/irq.h>
>  #include <linux/kernel.h>
>  #include <linux/ktime.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>


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

* Re: [PATCH 08/34] iio: adc: mt6360-adc: explicitly add proper header files
@ 2022-06-11 14:09     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:09 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:19 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/mt6360-adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
> index 07c0e6768391..35260d9e4e47 100644
> --- a/drivers/iio/adc/mt6360-adc.c
> +++ b/drivers/iio/adc/mt6360-adc.c
> @@ -5,6 +5,7 @@
>  #include <linux/irq.h>
>  #include <linux/kernel.h>
>  #include <linux/ktime.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 08/34] iio: adc: mt6360-adc: explicitly add proper header files
@ 2022-06-11 14:09     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:09 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:19 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/adc/mt6360-adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/mt6360-adc.c b/drivers/iio/adc/mt6360-adc.c
> index 07c0e6768391..35260d9e4e47 100644
> --- a/drivers/iio/adc/mt6360-adc.c
> +++ b/drivers/iio/adc/mt6360-adc.c
> @@ -5,6 +5,7 @@
>  #include <linux/irq.h>
>  #include <linux/kernel.h>
>  #include <linux/ktime.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>


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

* Re: [PATCH 09/34] iio: adc: npcm_adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:12     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:12 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:20 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Applied. It's funny, but I'd always assumed module.h included
mod_devicetable.h (though tried never to rely on it).  Turns
out nope, it doesn't :)

Jonathan

> ---
>  drivers/iio/adc/npcm_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
> index f7bc0bb7f112..a242e7993476 100644
> --- a/drivers/iio/adc/npcm_adc.c
> +++ b/drivers/iio/adc/npcm_adc.c
> @@ -8,6 +8,7 @@
>  #include <linux/iio/iio.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regmap.h>


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

* Re: [PATCH 09/34] iio: adc: npcm_adc: explicitly add proper header files
@ 2022-06-11 14:12     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:12 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:20 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Applied. It's funny, but I'd always assumed module.h included
mod_devicetable.h (though tried never to rely on it).  Turns
out nope, it doesn't :)

Jonathan

> ---
>  drivers/iio/adc/npcm_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
> index f7bc0bb7f112..a242e7993476 100644
> --- a/drivers/iio/adc/npcm_adc.c
> +++ b/drivers/iio/adc/npcm_adc.c
> @@ -8,6 +8,7 @@
>  #include <linux/iio/iio.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regmap.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 09/34] iio: adc: npcm_adc: explicitly add proper header files
@ 2022-06-11 14:12     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:12 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:20 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Applied. It's funny, but I'd always assumed module.h included
mod_devicetable.h (though tried never to rely on it).  Turns
out nope, it doesn't :)

Jonathan

> ---
>  drivers/iio/adc/npcm_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/npcm_adc.c b/drivers/iio/adc/npcm_adc.c
> index f7bc0bb7f112..a242e7993476 100644
> --- a/drivers/iio/adc/npcm_adc.c
> +++ b/drivers/iio/adc/npcm_adc.c
> @@ -8,6 +8,7 @@
>  #include <linux/iio/iio.h>
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regmap.h>


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

* Re: [PATCH 10/34] iio: adc: rzg2l_adc: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:13     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:13 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:21 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.
> ---
>  drivers/iio/adc/rzg2l_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
> index bee5f9861acb..c9403ab520d8 100644
> --- a/drivers/iio/adc/rzg2l_adc.c
> +++ b/drivers/iio/adc/rzg2l_adc.c
> @@ -18,6 +18,7 @@
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>  #include <linux/reset.h>
>  
>  #define DRIVER_NAME		"rzg2l-adc"


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

* Re: [PATCH 10/34] iio: adc: rzg2l_adc: explicitly add proper header files
@ 2022-06-11 14:13     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:13 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:21 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.
> ---
>  drivers/iio/adc/rzg2l_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
> index bee5f9861acb..c9403ab520d8 100644
> --- a/drivers/iio/adc/rzg2l_adc.c
> +++ b/drivers/iio/adc/rzg2l_adc.c
> @@ -18,6 +18,7 @@
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>  #include <linux/reset.h>
>  
>  #define DRIVER_NAME		"rzg2l-adc"


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 10/34] iio: adc: rzg2l_adc: explicitly add proper header files
@ 2022-06-11 14:13     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:13 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:21 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.
> ---
>  drivers/iio/adc/rzg2l_adc.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/adc/rzg2l_adc.c b/drivers/iio/adc/rzg2l_adc.c
> index bee5f9861acb..c9403ab520d8 100644
> --- a/drivers/iio/adc/rzg2l_adc.c
> +++ b/drivers/iio/adc/rzg2l_adc.c
> @@ -18,6 +18,7 @@
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/property.h>
>  #include <linux/reset.h>
>  
>  #define DRIVER_NAME		"rzg2l-adc"


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

* Re: [PATCH 11/34] iio: common: cros_ec_lid_angle: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:14     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:14 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:22 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> index af801e203623..9f780fafaed9 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> @@ -20,6 +20,7 @@
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_device.h>


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

* Re: [PATCH 11/34] iio: common: cros_ec_lid_angle: explicitly add proper header files
@ 2022-06-11 14:14     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:14 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:22 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> index af801e203623..9f780fafaed9 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> @@ -20,6 +20,7 @@
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_device.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 11/34] iio: common: cros_ec_lid_angle: explicitly add proper header files
@ 2022-06-11 14:14     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:14 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:22 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> index af801e203623..9f780fafaed9 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_lid_angle.c
> @@ -20,6 +20,7 @@
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_device.h>


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

* Re: [PATCH 12/34] iio: common: cros_ec_sensors: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:16     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:16 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:23 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> index 376a5b30010a..61e07a7bb199 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> @@ -16,6 +16,7 @@
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>


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

* Re: [PATCH 12/34] iio: common: cros_ec_sensors: explicitly add proper header files
@ 2022-06-11 14:16     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:16 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:23 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> index 376a5b30010a..61e07a7bb199 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> @@ -16,6 +16,7 @@
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 12/34] iio: common: cros_ec_sensors: explicitly add proper header files
@ 2022-06-11 14:16     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:16 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:23 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> index 376a5b30010a..61e07a7bb199 100644
> --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors.c
> @@ -16,6 +16,7 @@
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>


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

* Re: [PATCH 13/34] iio: dac: stm32-dac: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:17     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:17 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:24 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/dac/stm32-dac.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
> index daa42bcbae83..0de1b09b92f7 100644
> --- a/drivers/iio/dac/stm32-dac.c
> +++ b/drivers/iio/dac/stm32-dac.c
> @@ -12,6 +12,8 @@
>  #include <linux/iio/iio.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
>  


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

* Re: [PATCH 13/34] iio: dac: stm32-dac: explicitly add proper header files
@ 2022-06-11 14:17     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:17 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:24 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/dac/stm32-dac.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
> index daa42bcbae83..0de1b09b92f7 100644
> --- a/drivers/iio/dac/stm32-dac.c
> +++ b/drivers/iio/dac/stm32-dac.c
> @@ -12,6 +12,8 @@
>  #include <linux/iio/iio.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
>  


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 13/34] iio: dac: stm32-dac: explicitly add proper header files
@ 2022-06-11 14:17     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:17 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:24 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

> ---
>  drivers/iio/dac/stm32-dac.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/iio/dac/stm32-dac.c b/drivers/iio/dac/stm32-dac.c
> index daa42bcbae83..0de1b09b92f7 100644
> --- a/drivers/iio/dac/stm32-dac.c
> +++ b/drivers/iio/dac/stm32-dac.c
> @@ -12,6 +12,8 @@
>  #include <linux/iio/iio.h>
>  #include <linux/kernel.h>
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/of.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
>  


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

* Re: [PATCH 14/34] iio: dac: vf610_dac: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:19     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:19 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:25 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/dac/vf610_dac.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
> index 92429c0d2685..fc182250c622 100644
> --- a/drivers/iio/dac/vf610_dac.c
> +++ b/drivers/iio/dac/vf610_dac.c
> @@ -10,6 +10,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>


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

* Re: [PATCH 14/34] iio: dac: vf610_dac: explicitly add proper header files
@ 2022-06-11 14:19     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:19 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:25 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/dac/vf610_dac.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
> index 92429c0d2685..fc182250c622 100644
> --- a/drivers/iio/dac/vf610_dac.c
> +++ b/drivers/iio/dac/vf610_dac.c
> @@ -10,6 +10,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 14/34] iio: dac: vf610_dac: explicitly add proper header files
@ 2022-06-11 14:19     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:19 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:25 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied.

> ---
>  drivers/iio/dac/vf610_dac.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/dac/vf610_dac.c b/drivers/iio/dac/vf610_dac.c
> index 92429c0d2685..fc182250c622 100644
> --- a/drivers/iio/dac/vf610_dac.c
> +++ b/drivers/iio/dac/vf610_dac.c
> @@ -10,6 +10,7 @@
>  #include <linux/interrupt.h>
>  #include <linux/io.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include <linux/regulator/consumer.h>


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

* Re: [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
  2022-06-10 14:47     ` Andy Shevchenko
  (?)
@ 2022-06-11 14:22       ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 16:47:16 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 10, 2022 at 10:47 AM Nuno Sá <nuno.sa@analog.com> wrote:
> >
> > Do not trust the fact that iio.h includes of.h which in turn includes
> > all the headers we are relying on.
> >
> > The ultimate goal is to actually drop of.h from iio.h.  
> 
> ...
> 
> >  #include <linux/irqreturn.h>
> >  #include <linux/regmap.h>
> >  #include <linux/bitfield.h>
> > +#include <linux/property.h>  
> 
> Yes, I see, but you can make life easier if you try to squeeze to the
> most sorted part. I do not see full context, but here I would put it
> before regmap.h.
> 
With full context it's clear the list is way off sorted, but meh
putting it above regmap probably reduces the follow up diff a tiny
bit and I doubt Nuno feels strongly about this so I went with
what Andy suggested as a tweak whilst applying.

Applied

Thanks,

Jonathan


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

* Re: [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
@ 2022-06-11 14:22       ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 16:47:16 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 10, 2022 at 10:47 AM Nuno Sá <nuno.sa@analog.com> wrote:
> >
> > Do not trust the fact that iio.h includes of.h which in turn includes
> > all the headers we are relying on.
> >
> > The ultimate goal is to actually drop of.h from iio.h.  
> 
> ...
> 
> >  #include <linux/irqreturn.h>
> >  #include <linux/regmap.h>
> >  #include <linux/bitfield.h>
> > +#include <linux/property.h>  
> 
> Yes, I see, but you can make life easier if you try to squeeze to the
> most sorted part. I do not see full context, but here I would put it
> before regmap.h.
> 
With full context it's clear the list is way off sorted, but meh
putting it above regmap probably reduces the follow up diff a tiny
bit and I doubt Nuno feels strongly about this so I went with
what Andy suggested as a tweak whilst applying.

Applied

Thanks,

Jonathan


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 15/34] iio: humidity: hts221_buffer: explicitly add proper header files
@ 2022-06-11 14:22       ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:22 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	OpenBMC Maillist, Jishnu Prakash, Haibo Chen, Andy Gross,
	dl-linux-imx, Olivier Moysan, Zhang Rui, Christophe Branchereau

On Fri, 10 Jun 2022 16:47:16 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 10, 2022 at 10:47 AM Nuno Sá <nuno.sa@analog.com> wrote:
> >
> > Do not trust the fact that iio.h includes of.h which in turn includes
> > all the headers we are relying on.
> >
> > The ultimate goal is to actually drop of.h from iio.h.  
> 
> ...
> 
> >  #include <linux/irqreturn.h>
> >  #include <linux/regmap.h>
> >  #include <linux/bitfield.h>
> > +#include <linux/property.h>  
> 
> Yes, I see, but you can make life easier if you try to squeeze to the
> most sorted part. I do not see full context, but here I would put it
> before regmap.h.
> 
With full context it's clear the list is way off sorted, but meh
putting it above regmap probably reduces the follow up diff a tiny
bit and I doubt Nuno feels strongly about this so I went with
what Andy suggested as a tweak whilst applying.

Applied

Thanks,

Jonathan


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

* Re: [PATCH 16/34] iio: light: cros_ec_light_prox: explicitly add proper header files
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:23     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:23 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:27 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

Thanks,

J

> ---
>  drivers/iio/light/cros_ec_light_prox.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
> index a00a8b3b86cf..e345e0f71b74 100644
> --- a/drivers/iio/light/cros_ec_light_prox.c
> +++ b/drivers/iio/light/cros_ec_light_prox.c
> @@ -14,6 +14,7 @@
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>


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

* Re: [PATCH 16/34] iio: light: cros_ec_light_prox: explicitly add proper header files
@ 2022-06-11 14:23     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:23 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:27 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

Thanks,

J

> ---
>  drivers/iio/light/cros_ec_light_prox.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
> index a00a8b3b86cf..e345e0f71b74 100644
> --- a/drivers/iio/light/cros_ec_light_prox.c
> +++ b/drivers/iio/light/cros_ec_light_prox.c
> @@ -14,6 +14,7 @@
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 16/34] iio: light: cros_ec_light_prox: explicitly add proper header files
@ 2022-06-11 14:23     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:23 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:27 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Do not trust the fact that iio.h includes of.h which in turn includes
> all the headers we are relying on.
> 
> The ultimate goal is to actually drop of.h from iio.h.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
Applied

Thanks,

J

> ---
>  drivers/iio/light/cros_ec_light_prox.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/light/cros_ec_light_prox.c b/drivers/iio/light/cros_ec_light_prox.c
> index a00a8b3b86cf..e345e0f71b74 100644
> --- a/drivers/iio/light/cros_ec_light_prox.c
> +++ b/drivers/iio/light/cros_ec_light_prox.c
> @@ -14,6 +14,7 @@
>  #include <linux/iio/triggered_buffer.h>
>  #include <linux/iio/trigger_consumer.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_data/cros_ec_commands.h>
>  #include <linux/platform_data/cros_ec_proto.h>


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

* Re: [PATCH 19/34] iio: core: drop of.h from iio.h
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 14:30     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:30 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> There is no reason to include OF as we only need to forward declare
> 'of_phandle_args'. Previously, some drivers were actually relying on
> this for some headers (those were already fixed).
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
This one deserves a 'woot' :)

I would have guessed we were much further off being able to do this
than the 18 patches earlier in this series. Good work from Andy
and yourself to get to the point where this was possible.

Applied to the togreg branch of iio.git and pushed out as testing for
0-day to take a look.  I'm probably going to review the remainder, but
leave on list a bit longer as they are more complex/controversial than
this includes cleanup.

Thanks,

Jonathan

> ---
>  include/linux/iio/iio.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 4e21a82b3756..d9b4a9ca9a0f 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -11,13 +11,14 @@
>  #include <linux/cdev.h>
>  #include <linux/slab.h>
>  #include <linux/iio/types.h>
> -#include <linux/of.h>
>  /* IIO TODO LIST */
>  /*
>   * Provide means of adjusting timer accuracy.
>   * Currently assumes nano seconds.
>   */
>  
> +struct of_phandle_args;
> +
>  enum iio_shared_by {
>  	IIO_SEPARATE,
>  	IIO_SHARED_BY_TYPE,


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

* Re: [PATCH 19/34] iio: core: drop of.h from iio.h
@ 2022-06-11 14:30     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:30 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> There is no reason to include OF as we only need to forward declare
> 'of_phandle_args'. Previously, some drivers were actually relying on
> this for some headers (those were already fixed).
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
This one deserves a 'woot' :)

I would have guessed we were much further off being able to do this
than the 18 patches earlier in this series. Good work from Andy
and yourself to get to the point where this was possible.

Applied to the togreg branch of iio.git and pushed out as testing for
0-day to take a look.  I'm probably going to review the remainder, but
leave on list a bit longer as they are more complex/controversial than
this includes cleanup.

Thanks,

Jonathan

> ---
>  include/linux/iio/iio.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 4e21a82b3756..d9b4a9ca9a0f 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -11,13 +11,14 @@
>  #include <linux/cdev.h>
>  #include <linux/slab.h>
>  #include <linux/iio/types.h>
> -#include <linux/of.h>
>  /* IIO TODO LIST */
>  /*
>   * Provide means of adjusting timer accuracy.
>   * Currently assumes nano seconds.
>   */
>  
> +struct of_phandle_args;
> +
>  enum iio_shared_by {
>  	IIO_SEPARATE,
>  	IIO_SHARED_BY_TYPE,


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 19/34] iio: core: drop of.h from iio.h
@ 2022-06-11 14:30     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:30 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> There is no reason to include OF as we only need to forward declare
> 'of_phandle_args'. Previously, some drivers were actually relying on
> this for some headers (those were already fixed).
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
This one deserves a 'woot' :)

I would have guessed we were much further off being able to do this
than the 18 patches earlier in this series. Good work from Andy
and yourself to get to the point where this was possible.

Applied to the togreg branch of iio.git and pushed out as testing for
0-day to take a look.  I'm probably going to review the remainder, but
leave on list a bit longer as they are more complex/controversial than
this includes cleanup.

Thanks,

Jonathan

> ---
>  include/linux/iio/iio.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index 4e21a82b3756..d9b4a9ca9a0f 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -11,13 +11,14 @@
>  #include <linux/cdev.h>
>  #include <linux/slab.h>
>  #include <linux/iio/types.h>
> -#include <linux/of.h>
>  /* IIO TODO LIST */
>  /*
>   * Provide means of adjusting timer accuracy.
>   * Currently assumes nano seconds.
>   */
>  
> +struct of_phandle_args;
> +
>  enum iio_shared_by {
>  	IIO_SEPARATE,
>  	IIO_SHARED_BY_TYPE,


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-10 20:08       ` Nuno Sá
  (?)
@ 2022-06-11 14:59         ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:59 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal, Mark Brown


+Cc Mark Brown for a query on ordering in device tree based SPI setup.

On Fri, 10 Jun 2022 22:08:41 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > 'of_node_put()' can potentially release the memory pointed to by
> > > 'iiospec.np' which would leave us with an invalid pointer (and we
> > > would
> > > still pass it in 'of_xlate()'). As such, we can only release the
> > > node
> > > after we are done with it.  
> > 
> > The question you should answer in the commit message is the
> > following:
> > "Can an OF node, attached to a struct device, be gone before the
> > device itself?" If it so, then patch is good, otherwise there is no
> > point in this patch in the first place.
> >   
> 
> Yeah, I might be wrong but from a quick look... yes, I think the node
> can be gone before the device. Take a look on the spi or i2c of_notify
> handling and you can see that the nodes are get/put on the add/remove
> notifcation. Meaning that the node lifespan is not really attached to
> the device lifespan. If it was, I would expect to see of_node_put() on
> the device release() function...

I had a look at spi_of_notify() and indeed via spi_unregister_device()
the node is put just before device_del() so I agree that at first glance
it seems like there may be a race there against the useage here.
Mark (+CC) out of interest why are the node gets before the device_add()
in spi_add_device() called from of_register_spi_device() but the matching
node puts before the device_del() in spi_unregister_device()?
Seems like inconsistent ordering...

Which is not to say we shouldn't fix the IIO usage as this patch does!

> 
> Again, I might be wrong and I admit I was not sure about including this
> patch because it's a very unlikely scenario even though I think, in
> theory, a possible one.

The patch is currently valid even if it's not a 'real' bug.
Given we are doing a put on that device_node, it makes sense for that
to occur after the local use has finished - we shouldn't be relying on
what happens to be the case for lifetimes today.

Now, I did wonder if any drivers actually use it in their xlate callbacks.
One does for an error print, so this is potentially real (if very unlikely!)

This isn't a 'fix' I'd expect to rush in, or necessarily backport to stable
but I think it's a valid fix.

Perhaps add a little more detail to the patch description for v2.

Thanks,

Jonathan


> 
> - Nuno Sá
> 


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-11 14:59         ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:59 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal, Mark Brown


+Cc Mark Brown for a query on ordering in device tree based SPI setup.

On Fri, 10 Jun 2022 22:08:41 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > 'of_node_put()' can potentially release the memory pointed to by
> > > 'iiospec.np' which would leave us with an invalid pointer (and we
> > > would
> > > still pass it in 'of_xlate()'). As such, we can only release the
> > > node
> > > after we are done with it.  
> > 
> > The question you should answer in the commit message is the
> > following:
> > "Can an OF node, attached to a struct device, be gone before the
> > device itself?" If it so, then patch is good, otherwise there is no
> > point in this patch in the first place.
> >   
> 
> Yeah, I might be wrong but from a quick look... yes, I think the node
> can be gone before the device. Take a look on the spi or i2c of_notify
> handling and you can see that the nodes are get/put on the add/remove
> notifcation. Meaning that the node lifespan is not really attached to
> the device lifespan. If it was, I would expect to see of_node_put() on
> the device release() function...

I had a look at spi_of_notify() and indeed via spi_unregister_device()
the node is put just before device_del() so I agree that at first glance
it seems like there may be a race there against the useage here.
Mark (+CC) out of interest why are the node gets before the device_add()
in spi_add_device() called from of_register_spi_device() but the matching
node puts before the device_del() in spi_unregister_device()?
Seems like inconsistent ordering...

Which is not to say we shouldn't fix the IIO usage as this patch does!

> 
> Again, I might be wrong and I admit I was not sure about including this
> patch because it's a very unlikely scenario even though I think, in
> theory, a possible one.

The patch is currently valid even if it's not a 'real' bug.
Given we are doing a put on that device_node, it makes sense for that
to occur after the local use has finished - we shouldn't be relying on
what happens to be the case for lifetimes today.

Now, I did wonder if any drivers actually use it in their xlate callbacks.
One does for an error print, so this is potentially real (if very unlikely!)

This isn't a 'fix' I'd expect to rush in, or necessarily backport to stable
but I think it's a valid fix.

Perhaps add a little more detail to the patch description for v2.

Thanks,

Jonathan


> 
> - Nuno Sá
> 


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-11 14:59         ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 14:59 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	OpenBMC Maillist, Jishnu Prakash, Haibo Chen, Andy Shevchenko,
	Andy Gross, dl-linux-imx, Olivier Moysan, Zhang Rui


+Cc Mark Brown for a query on ordering in device tree based SPI setup.

On Fri, 10 Jun 2022 22:08:41 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > 'of_node_put()' can potentially release the memory pointed to by
> > > 'iiospec.np' which would leave us with an invalid pointer (and we
> > > would
> > > still pass it in 'of_xlate()'). As such, we can only release the
> > > node
> > > after we are done with it.  
> > 
> > The question you should answer in the commit message is the
> > following:
> > "Can an OF node, attached to a struct device, be gone before the
> > device itself?" If it so, then patch is good, otherwise there is no
> > point in this patch in the first place.
> >   
> 
> Yeah, I might be wrong but from a quick look... yes, I think the node
> can be gone before the device. Take a look on the spi or i2c of_notify
> handling and you can see that the nodes are get/put on the add/remove
> notifcation. Meaning that the node lifespan is not really attached to
> the device lifespan. If it was, I would expect to see of_node_put() on
> the device release() function...

I had a look at spi_of_notify() and indeed via spi_unregister_device()
the node is put just before device_del() so I agree that at first glance
it seems like there may be a race there against the useage here.
Mark (+CC) out of interest why are the node gets before the device_add()
in spi_add_device() called from of_register_spi_device() but the matching
node puts before the device_del() in spi_unregister_device()?
Seems like inconsistent ordering...

Which is not to say we shouldn't fix the IIO usage as this patch does!

> 
> Again, I might be wrong and I admit I was not sure about including this
> patch because it's a very unlikely scenario even though I think, in
> theory, a possible one.

The patch is currently valid even if it's not a 'real' bug.
Given we are doing a put on that device_node, it makes sense for that
to occur after the local use has finished - we shouldn't be relying on
what happens to be the case for lifetimes today.

Now, I did wonder if any drivers actually use it in their xlate callbacks.
One does for an error print, so this is potentially real (if very unlikely!)

This isn't a 'fix' I'd expect to rush in, or necessarily backport to stable
but I think it's a valid fix.

Perhaps add a little more detail to the patch description for v2.

Thanks,

Jonathan


> 
> - Nuno Sá
> 


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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 15:17     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:17 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:33 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
> returning a mix of NULL and error pointers being NULL the way to

pointers with NULL being the way to...

> "notify" that we should do a "system" lookup for channels. This make
> it very confusing and prone to errors as commit dbbccf7c20bf
> ("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
> proves. On top of this, patterns like 'if (channel != NULL) return channel'
> were being used where channel could actually be an error code which
> makes the code hard to read.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 87fd2a0d44f2..31d9c122199a 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -214,7 +214,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>  struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  					       const char *name)
>  {
> -	struct iio_channel *chan = NULL;
> +	struct iio_channel *chan;
>  
>  	/* Walk up the tree of devices looking for a matching iio channel */
>  	while (np) {
> @@ -231,11 +231,11 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  							 name);
>  		chan = of_iio_channel_get(np, index);
>  		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
> -			break;

This original behaviour is 'interesting'. If we get a error like -ENOMEM
we should return it rather than carry on.  Do we have enough knowledge
of possible errors here to be more explicit on when we keep looking up
the tree?  I think we can get -ENOENT from of_parse_phandle_with_args()

That raises an interesting question on whether -ENODEV is the right response
for the previously NULL case or is -ENOENT more consistent with other
of_ functions?  No device could be thought of as being the case that needs
to defer (in hope it turns up later) whereas no entry means it will never
succeed.

> -		else if (name && index >= 0) {
> +			return chan;
> +		if (name && index >= 0) {
>  			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
>  				np, name ? name : "", index);
> -			return NULL;
> +			return chan;
>  		}
>  
>  		/*
> @@ -245,10 +245,10 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  		 */
>  		np = np->parent;
>  		if (np && !of_get_property(np, "io-channel-ranges", NULL))
> -			return NULL;
> +			return chan;
>  	}
>  
> -	return chan;
> +	return ERR_PTR(-ENODEV);
>  }
>  EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
>  
> @@ -267,8 +267,8 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  			break;
>  	} while (++nummaps);
>  
> -	if (nummaps == 0)	/* no error, return NULL to search map table */
> -		return NULL;
> +	if (nummaps == 0)	/* return -ENODEV to search map table */
> +		return ERR_PTR(-ENODEV);
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> @@ -295,7 +295,7 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  
>  static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  {
> -	return NULL;
> +	return ERR_PTR(-ENODEV);
>  }
>  
>  #endif /* CONFIG_OF */
> @@ -362,7 +362,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
>  	if (dev) {
>  		channel = of_iio_channel_get_by_name(dev->of_node,
>  						     channel_name);
> -		if (channel != NULL)
> +		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
>  			return channel;
>  	}
>  
> @@ -412,8 +412,6 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
>  	channel = of_iio_channel_get_by_name(np, channel_name);
>  	if (IS_ERR(channel))
>  		return channel;
> -	if (!channel)
> -		return ERR_PTR(-ENODEV);
>  
>  	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
>  	if (ret)
> @@ -436,7 +434,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  		return ERR_PTR(-EINVAL);
>  
>  	chans = of_iio_channel_get_all(dev);
> -	if (chans)
> +	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)

Hmm. We only want to carry on if the error is -ENODEV.  Anything else
should be reported up the stack.

That might be the only error left, but I think we should be explicit.

>  		return chans;
>  
>  	name = dev_name(dev);


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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-11 15:17     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:17 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:33 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
> returning a mix of NULL and error pointers being NULL the way to

pointers with NULL being the way to...

> "notify" that we should do a "system" lookup for channels. This make
> it very confusing and prone to errors as commit dbbccf7c20bf
> ("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
> proves. On top of this, patterns like 'if (channel != NULL) return channel'
> were being used where channel could actually be an error code which
> makes the code hard to read.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 87fd2a0d44f2..31d9c122199a 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -214,7 +214,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>  struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  					       const char *name)
>  {
> -	struct iio_channel *chan = NULL;
> +	struct iio_channel *chan;
>  
>  	/* Walk up the tree of devices looking for a matching iio channel */
>  	while (np) {
> @@ -231,11 +231,11 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  							 name);
>  		chan = of_iio_channel_get(np, index);
>  		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
> -			break;

This original behaviour is 'interesting'. If we get a error like -ENOMEM
we should return it rather than carry on.  Do we have enough knowledge
of possible errors here to be more explicit on when we keep looking up
the tree?  I think we can get -ENOENT from of_parse_phandle_with_args()

That raises an interesting question on whether -ENODEV is the right response
for the previously NULL case or is -ENOENT more consistent with other
of_ functions?  No device could be thought of as being the case that needs
to defer (in hope it turns up later) whereas no entry means it will never
succeed.

> -		else if (name && index >= 0) {
> +			return chan;
> +		if (name && index >= 0) {
>  			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
>  				np, name ? name : "", index);
> -			return NULL;
> +			return chan;
>  		}
>  
>  		/*
> @@ -245,10 +245,10 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  		 */
>  		np = np->parent;
>  		if (np && !of_get_property(np, "io-channel-ranges", NULL))
> -			return NULL;
> +			return chan;
>  	}
>  
> -	return chan;
> +	return ERR_PTR(-ENODEV);
>  }
>  EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
>  
> @@ -267,8 +267,8 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  			break;
>  	} while (++nummaps);
>  
> -	if (nummaps == 0)	/* no error, return NULL to search map table */
> -		return NULL;
> +	if (nummaps == 0)	/* return -ENODEV to search map table */
> +		return ERR_PTR(-ENODEV);
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> @@ -295,7 +295,7 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  
>  static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  {
> -	return NULL;
> +	return ERR_PTR(-ENODEV);
>  }
>  
>  #endif /* CONFIG_OF */
> @@ -362,7 +362,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
>  	if (dev) {
>  		channel = of_iio_channel_get_by_name(dev->of_node,
>  						     channel_name);
> -		if (channel != NULL)
> +		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
>  			return channel;
>  	}
>  
> @@ -412,8 +412,6 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
>  	channel = of_iio_channel_get_by_name(np, channel_name);
>  	if (IS_ERR(channel))
>  		return channel;
> -	if (!channel)
> -		return ERR_PTR(-ENODEV);
>  
>  	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
>  	if (ret)
> @@ -436,7 +434,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  		return ERR_PTR(-EINVAL);
>  
>  	chans = of_iio_channel_get_all(dev);
> -	if (chans)
> +	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)

Hmm. We only want to carry on if the error is -ENODEV.  Anything else
should be reported up the stack.

That might be the only error left, but I think we should be explicit.

>  		return chans;
>  
>  	name = dev_name(dev);


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-11 15:17     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:17 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

On Fri, 10 Jun 2022 10:45:33 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all() were
> returning a mix of NULL and error pointers being NULL the way to

pointers with NULL being the way to...

> "notify" that we should do a "system" lookup for channels. This make
> it very confusing and prone to errors as commit dbbccf7c20bf
> ("iio: inkern: fix return value in devm_of_iio_channel_get_by_name()")
> proves. On top of this, patterns like 'if (channel != NULL) return channel'
> were being used where channel could actually be an error code which
> makes the code hard to read.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 24 +++++++++++-------------
>  1 file changed, 11 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 87fd2a0d44f2..31d9c122199a 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -214,7 +214,7 @@ static struct iio_channel *of_iio_channel_get(struct device_node *np, int index)
>  struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  					       const char *name)
>  {
> -	struct iio_channel *chan = NULL;
> +	struct iio_channel *chan;
>  
>  	/* Walk up the tree of devices looking for a matching iio channel */
>  	while (np) {
> @@ -231,11 +231,11 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  							 name);
>  		chan = of_iio_channel_get(np, index);
>  		if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
> -			break;

This original behaviour is 'interesting'. If we get a error like -ENOMEM
we should return it rather than carry on.  Do we have enough knowledge
of possible errors here to be more explicit on when we keep looking up
the tree?  I think we can get -ENOENT from of_parse_phandle_with_args()

That raises an interesting question on whether -ENODEV is the right response
for the previously NULL case or is -ENOENT more consistent with other
of_ functions?  No device could be thought of as being the case that needs
to defer (in hope it turns up later) whereas no entry means it will never
succeed.

> -		else if (name && index >= 0) {
> +			return chan;
> +		if (name && index >= 0) {
>  			pr_err("ERROR: could not get IIO channel %pOF:%s(%i)\n",
>  				np, name ? name : "", index);
> -			return NULL;
> +			return chan;
>  		}
>  
>  		/*
> @@ -245,10 +245,10 @@ struct iio_channel *of_iio_channel_get_by_name(struct device_node *np,
>  		 */
>  		np = np->parent;
>  		if (np && !of_get_property(np, "io-channel-ranges", NULL))
> -			return NULL;
> +			return chan;
>  	}
>  
> -	return chan;
> +	return ERR_PTR(-ENODEV);
>  }
>  EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
>  
> @@ -267,8 +267,8 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  			break;
>  	} while (++nummaps);
>  
> -	if (nummaps == 0)	/* no error, return NULL to search map table */
> -		return NULL;
> +	if (nummaps == 0)	/* return -ENODEV to search map table */
> +		return ERR_PTR(-ENODEV);
>  
>  	/* NULL terminated array to save passing size */
>  	chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
> @@ -295,7 +295,7 @@ static struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  
>  static inline struct iio_channel *of_iio_channel_get_all(struct device *dev)
>  {
> -	return NULL;
> +	return ERR_PTR(-ENODEV);
>  }
>  
>  #endif /* CONFIG_OF */
> @@ -362,7 +362,7 @@ struct iio_channel *iio_channel_get(struct device *dev,
>  	if (dev) {
>  		channel = of_iio_channel_get_by_name(dev->of_node,
>  						     channel_name);
> -		if (channel != NULL)
> +		if (!IS_ERR(channel) || PTR_ERR(channel) == -EPROBE_DEFER)
>  			return channel;
>  	}
>  
> @@ -412,8 +412,6 @@ struct iio_channel *devm_of_iio_channel_get_by_name(struct device *dev,
>  	channel = of_iio_channel_get_by_name(np, channel_name);
>  	if (IS_ERR(channel))
>  		return channel;
> -	if (!channel)
> -		return ERR_PTR(-ENODEV);
>  
>  	ret = devm_add_action_or_reset(dev, devm_iio_channel_free, channel);
>  	if (ret)
> @@ -436,7 +434,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
>  		return ERR_PTR(-EINVAL);
>  
>  	chans = of_iio_channel_get_all(dev);
> -	if (chans)
> +	if (!IS_ERR(chans) || PTR_ERR(chans) == -EPROBE_DEFER)

Hmm. We only want to carry on if the error is -ENODEV.  Anything else
should be reported up the stack.

That might be the only error left, but I think we should be explicit.

>  		return chans;
>  
>  	name = dev_name(dev);


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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
  2022-06-10 20:01       ` Nuno Sá
  (?)
@ 2022-06-11 15:30         ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 22:01:09 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > This moves the IIO in kernel interface to use fwnode properties and
> > > thus
> > > be firmware agnostic.
> > > 
> > > Note that the interface is still not firmware agnostic. At this
> > > point we
> > > have both OF and fwnode interfaces so that we don't break any user.
> > > On
> > > top of this we also want to have a per driver conversion and that
> > > is the
> > > main reason we have both of_xlate() and fwnode_xlate() support.  
> > 
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Thanks!
> > 
> > A few nit-picks below, though.
> >   
...

> 
> >   
> > > -       err = of_parse_phandle_with_args(np, "io-channels",
> > > -                                        "#io-channel-cells",
> > > -                                        index, &iiospec);
> > > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > > channels",
> > > +                                                "#io-channel-
> > > cells", 0,
> > > +                                                index, &iiospec);
> > >         if (err)
> > >                 return err;
> > > 
> > > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> > >                                iio_dev_node_match);  
> > 
> > Wondering if this
> > https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> > can be utilized (yes, I noticed iio_device_type above).  
> 
> Hmm, at first glance I would say we can use it. AFAICT, we are already
> grabbing a node which contains "#io-channel-cells" which is very
> indicative that is an IIO device. I also find it very unlikely to have
> two IIO devices with the same fwnode (I guess it would be an issue even
> in the old code) and even more unlikely two devices of diferent types
> with the same fwnode?

If we are talking struct iio_dev instances, then there are quite a few cases
where there are multiple with the same fwnode.  We had to do that pre
multiple buffers being introduced so it's fairly common, though not in
ADCs which is probably why we haven't seen breakage here. Not sure how
broken things already are as a result or if any of those devices (most
IMUs) provide #io-channel-cells etc.  I'd put that breakage down as
one to look into if anyone every hits it or one of us is bored enough
to poke at it.  (superficially I think we'd have to check all matches
for an xlate success).

Also, possible (I'm not totally sure) that we have other subdevices using
the same firmware node, such as triggers.  I can't immediately think
of why they would need it, but I'd rather we were at least partly protected
against that.

> 
> Anyways, I guess Jonathan can help in here...
> 
> 
> >   
> > >         if (idev == NULL) {
> > > -               of_node_put(iiospec.np);
> > > +               fwnode_handle_put(iiospec.fwnode);
> > >                 return -EPROBE_DEFER;
> > >         }
> > > 
> > >         indio_dev = dev_to_iio_dev(idev);
> > >         channel->indio_dev = indio_dev;
> > >         if (indio_dev->info->of_xlate)
> > > -               index = indio_dev->info->of_xlate(indio_dev,
> > > &iiospec);
> > > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > > +       else if (indio_dev->info->fwnode_xlate)
> > > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > > &iiospec);
> > >         else
> > > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > > -       of_node_put(iiospec.np);
> > > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > > &iiospec);
> > > +       fwnode_handle_put(iiospec.fwnode);
> > >         if (index < 0)
> > >                 goto err_put;
> > >         channel->channel = &indio_dev->channels[index];
> > > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > > iio_channel *channel,
> > >         return index;
> > >  }

> >   
> > >                 *parent_lookup = false;
> > >         }
> > > 
> > >         return chan;
> > >  }
> > > 
> > > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > > *np,
> > > -                                              const char *name)
> > > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > > fwnode_handle *fwnode,
> > > +                                                  const char
> > > *name)
> > >  {
> > >         struct iio_channel *chan;
> > > +       struct fwnode_handle *parent;
> > >         bool parent_lookup = true;
> > > 
> > >         /* Walk up the tree of devices looking for a matching iio
> > > channel */
> > > -       chan = __of_iio_channel_get_by_name(np, name,
> > > &parent_lookup);
> > > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > > &parent_lookup);
> > >         if (!parent_lookup)
> > >                 return chan;
> > > 
> > > @@ -255,33 +279,34 @@ struct iio_channel
> > > *of_iio_channel_get_by_name(struct device_node *np,
> > >          * If the parent node has a "io-channel-ranges" property,
> > >          * then we can try one of its channels.
> > >          */
> > > -       np = np->parent;
> > > -       while (np) {
> > > -               if (!of_get_property(np, "io-channel-ranges",
> > > NULL))
> > > +       fwnode_for_each_parent_node(fwnode, parent) {
> > > +               if (!fwnode_property_present(parent, "io-channel-
> > > ranges")) {
> > > +                       fwnode_handle_put(parent);
> > >                         return chan;  
> > 
> > break; ?  
> 
> The return in place was a request from Jonathan in the RFC...

:)  I prefer not having to scroll down when we can get out quickly.

> 
> > 
> > (Yes, I understand pros and cons of each variant, up to you)
> >   
> > > +               }
> > > 
> > > -               chan = __of_iio_channel_get_by_name(np, name,
> > > &parent_lookup);
> > > -               if (!parent_lookup)
> > > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > > name, &parent_lookup);
> > > +               if (!parent_lookup) {
> > > +                       fwnode_handle_put(parent);
> > >                         return chan;  
> > 
> > Ditto.
> >   
> > > -               np = np->parent;
> > > +               }
> > >         }
> > > 
> > >         return chan;
> > >  }
> > > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);  
> > 
> > Wondering if we may move this to the IIO namespace.  
> 
> I guess it makes sense but surely on a different patch...

Yup - moving to a IIO namespace is a work in progress (got snarled
up by the PM related macros needed for some of the sub namespaces
which is now sorted)  Let's do it after this.



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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-11 15:30         ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 22:01:09 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > This moves the IIO in kernel interface to use fwnode properties and
> > > thus
> > > be firmware agnostic.
> > > 
> > > Note that the interface is still not firmware agnostic. At this
> > > point we
> > > have both OF and fwnode interfaces so that we don't break any user.
> > > On
> > > top of this we also want to have a per driver conversion and that
> > > is the
> > > main reason we have both of_xlate() and fwnode_xlate() support.  
> > 
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Thanks!
> > 
> > A few nit-picks below, though.
> >   
...

> 
> >   
> > > -       err = of_parse_phandle_with_args(np, "io-channels",
> > > -                                        "#io-channel-cells",
> > > -                                        index, &iiospec);
> > > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > > channels",
> > > +                                                "#io-channel-
> > > cells", 0,
> > > +                                                index, &iiospec);
> > >         if (err)
> > >                 return err;
> > > 
> > > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> > >                                iio_dev_node_match);  
> > 
> > Wondering if this
> > https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> > can be utilized (yes, I noticed iio_device_type above).  
> 
> Hmm, at first glance I would say we can use it. AFAICT, we are already
> grabbing a node which contains "#io-channel-cells" which is very
> indicative that is an IIO device. I also find it very unlikely to have
> two IIO devices with the same fwnode (I guess it would be an issue even
> in the old code) and even more unlikely two devices of diferent types
> with the same fwnode?

If we are talking struct iio_dev instances, then there are quite a few cases
where there are multiple with the same fwnode.  We had to do that pre
multiple buffers being introduced so it's fairly common, though not in
ADCs which is probably why we haven't seen breakage here. Not sure how
broken things already are as a result or if any of those devices (most
IMUs) provide #io-channel-cells etc.  I'd put that breakage down as
one to look into if anyone every hits it or one of us is bored enough
to poke at it.  (superficially I think we'd have to check all matches
for an xlate success).

Also, possible (I'm not totally sure) that we have other subdevices using
the same firmware node, such as triggers.  I can't immediately think
of why they would need it, but I'd rather we were at least partly protected
against that.

> 
> Anyways, I guess Jonathan can help in here...
> 
> 
> >   
> > >         if (idev == NULL) {
> > > -               of_node_put(iiospec.np);
> > > +               fwnode_handle_put(iiospec.fwnode);
> > >                 return -EPROBE_DEFER;
> > >         }
> > > 
> > >         indio_dev = dev_to_iio_dev(idev);
> > >         channel->indio_dev = indio_dev;
> > >         if (indio_dev->info->of_xlate)
> > > -               index = indio_dev->info->of_xlate(indio_dev,
> > > &iiospec);
> > > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > > +       else if (indio_dev->info->fwnode_xlate)
> > > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > > &iiospec);
> > >         else
> > > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > > -       of_node_put(iiospec.np);
> > > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > > &iiospec);
> > > +       fwnode_handle_put(iiospec.fwnode);
> > >         if (index < 0)
> > >                 goto err_put;
> > >         channel->channel = &indio_dev->channels[index];
> > > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > > iio_channel *channel,
> > >         return index;
> > >  }

> >   
> > >                 *parent_lookup = false;
> > >         }
> > > 
> > >         return chan;
> > >  }
> > > 
> > > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > > *np,
> > > -                                              const char *name)
> > > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > > fwnode_handle *fwnode,
> > > +                                                  const char
> > > *name)
> > >  {
> > >         struct iio_channel *chan;
> > > +       struct fwnode_handle *parent;
> > >         bool parent_lookup = true;
> > > 
> > >         /* Walk up the tree of devices looking for a matching iio
> > > channel */
> > > -       chan = __of_iio_channel_get_by_name(np, name,
> > > &parent_lookup);
> > > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > > &parent_lookup);
> > >         if (!parent_lookup)
> > >                 return chan;
> > > 
> > > @@ -255,33 +279,34 @@ struct iio_channel
> > > *of_iio_channel_get_by_name(struct device_node *np,
> > >          * If the parent node has a "io-channel-ranges" property,
> > >          * then we can try one of its channels.
> > >          */
> > > -       np = np->parent;
> > > -       while (np) {
> > > -               if (!of_get_property(np, "io-channel-ranges",
> > > NULL))
> > > +       fwnode_for_each_parent_node(fwnode, parent) {
> > > +               if (!fwnode_property_present(parent, "io-channel-
> > > ranges")) {
> > > +                       fwnode_handle_put(parent);
> > >                         return chan;  
> > 
> > break; ?  
> 
> The return in place was a request from Jonathan in the RFC...

:)  I prefer not having to scroll down when we can get out quickly.

> 
> > 
> > (Yes, I understand pros and cons of each variant, up to you)
> >   
> > > +               }
> > > 
> > > -               chan = __of_iio_channel_get_by_name(np, name,
> > > &parent_lookup);
> > > -               if (!parent_lookup)
> > > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > > name, &parent_lookup);
> > > +               if (!parent_lookup) {
> > > +                       fwnode_handle_put(parent);
> > >                         return chan;  
> > 
> > Ditto.
> >   
> > > -               np = np->parent;
> > > +               }
> > >         }
> > > 
> > >         return chan;
> > >  }
> > > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);  
> > 
> > Wondering if we may move this to the IIO namespace.  
> 
> I guess it makes sense but surely on a different patch...

Yup - moving to a IIO namespace is a work in progress (got snarled
up by the PM related macros needed for some of the sub namespaces
which is now sorted)  Let's do it after this.



_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-11 15:30         ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	OpenBMC Maillist, Jishnu Prakash, Haibo Chen, Andy Shevchenko,
	Andy Gross, dl-linux-imx, Olivier Moysan, Zhang Rui

On Fri, 10 Jun 2022 22:01:09 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:
> > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> > > 
> > > This moves the IIO in kernel interface to use fwnode properties and
> > > thus
> > > be firmware agnostic.
> > > 
> > > Note that the interface is still not firmware agnostic. At this
> > > point we
> > > have both OF and fwnode interfaces so that we don't break any user.
> > > On
> > > top of this we also want to have a per driver conversion and that
> > > is the
> > > main reason we have both of_xlate() and fwnode_xlate() support.  
> > 
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Thanks!
> > 
> > A few nit-picks below, though.
> >   
...

> 
> >   
> > > -       err = of_parse_phandle_with_args(np, "io-channels",
> > > -                                        "#io-channel-cells",
> > > -                                        index, &iiospec);
> > > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > > channels",
> > > +                                                "#io-channel-
> > > cells", 0,
> > > +                                                index, &iiospec);
> > >         if (err)
> > >                 return err;
> > > 
> > > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> > >                                iio_dev_node_match);  
> > 
> > Wondering if this
> > https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> > can be utilized (yes, I noticed iio_device_type above).  
> 
> Hmm, at first glance I would say we can use it. AFAICT, we are already
> grabbing a node which contains "#io-channel-cells" which is very
> indicative that is an IIO device. I also find it very unlikely to have
> two IIO devices with the same fwnode (I guess it would be an issue even
> in the old code) and even more unlikely two devices of diferent types
> with the same fwnode?

If we are talking struct iio_dev instances, then there are quite a few cases
where there are multiple with the same fwnode.  We had to do that pre
multiple buffers being introduced so it's fairly common, though not in
ADCs which is probably why we haven't seen breakage here. Not sure how
broken things already are as a result or if any of those devices (most
IMUs) provide #io-channel-cells etc.  I'd put that breakage down as
one to look into if anyone every hits it or one of us is bored enough
to poke at it.  (superficially I think we'd have to check all matches
for an xlate success).

Also, possible (I'm not totally sure) that we have other subdevices using
the same firmware node, such as triggers.  I can't immediately think
of why they would need it, but I'd rather we were at least partly protected
against that.

> 
> Anyways, I guess Jonathan can help in here...
> 
> 
> >   
> > >         if (idev == NULL) {
> > > -               of_node_put(iiospec.np);
> > > +               fwnode_handle_put(iiospec.fwnode);
> > >                 return -EPROBE_DEFER;
> > >         }
> > > 
> > >         indio_dev = dev_to_iio_dev(idev);
> > >         channel->indio_dev = indio_dev;
> > >         if (indio_dev->info->of_xlate)
> > > -               index = indio_dev->info->of_xlate(indio_dev,
> > > &iiospec);
> > > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > > +       else if (indio_dev->info->fwnode_xlate)
> > > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > > &iiospec);
> > >         else
> > > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > > -       of_node_put(iiospec.np);
> > > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > > &iiospec);
> > > +       fwnode_handle_put(iiospec.fwnode);
> > >         if (index < 0)
> > >                 goto err_put;
> > >         channel->channel = &indio_dev->channels[index];
> > > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > > iio_channel *channel,
> > >         return index;
> > >  }

> >   
> > >                 *parent_lookup = false;
> > >         }
> > > 
> > >         return chan;
> > >  }
> > > 
> > > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > > *np,
> > > -                                              const char *name)
> > > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > > fwnode_handle *fwnode,
> > > +                                                  const char
> > > *name)
> > >  {
> > >         struct iio_channel *chan;
> > > +       struct fwnode_handle *parent;
> > >         bool parent_lookup = true;
> > > 
> > >         /* Walk up the tree of devices looking for a matching iio
> > > channel */
> > > -       chan = __of_iio_channel_get_by_name(np, name,
> > > &parent_lookup);
> > > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > > &parent_lookup);
> > >         if (!parent_lookup)
> > >                 return chan;
> > > 
> > > @@ -255,33 +279,34 @@ struct iio_channel
> > > *of_iio_channel_get_by_name(struct device_node *np,
> > >          * If the parent node has a "io-channel-ranges" property,
> > >          * then we can try one of its channels.
> > >          */
> > > -       np = np->parent;
> > > -       while (np) {
> > > -               if (!of_get_property(np, "io-channel-ranges",
> > > NULL))
> > > +       fwnode_for_each_parent_node(fwnode, parent) {
> > > +               if (!fwnode_property_present(parent, "io-channel-
> > > ranges")) {
> > > +                       fwnode_handle_put(parent);
> > >                         return chan;  
> > 
> > break; ?  
> 
> The return in place was a request from Jonathan in the RFC...

:)  I prefer not having to scroll down when we can get out quickly.

> 
> > 
> > (Yes, I understand pros and cons of each variant, up to you)
> >   
> > > +               }
> > > 
> > > -               chan = __of_iio_channel_get_by_name(np, name,
> > > &parent_lookup);
> > > -               if (!parent_lookup)
> > > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > > name, &parent_lookup);
> > > +               if (!parent_lookup) {
> > > +                       fwnode_handle_put(parent);
> > >                         return chan;  
> > 
> > Ditto.
> >   
> > > -               np = np->parent;
> > > +               }
> > >         }
> > > 
> > >         return chan;
> > >  }
> > > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);  
> > 
> > Wondering if we may move this to the IIO namespace.  
> 
> I guess it makes sense but surely on a different patch...

Yup - moving to a IIO namespace is a work in progress (got snarled
up by the PM related macros needed for some of the sub namespaces
which is now sorted)  Let's do it after this.



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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
  2022-06-11 15:30         ` Jonathan Cameron
@ 2022-06-11 15:32           ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:32 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar

On Sat, 11 Jun 2022 16:30:57 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Fri, 10 Jun 2022 22:01:09 +0200
> Nuno Sá <noname.nuno@gmail.com> wrote:
> 
> > On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:  
> > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:    
> > > > 
> > > > This moves the IIO in kernel interface to use fwnode properties and
> > > > thus
> > > > be firmware agnostic.
> > > > 
> > > > Note that the interface is still not firmware agnostic. At this
> > > > point we
> > > > have both OF and fwnode interfaces so that we don't break any user.
> > > > On
> > > > top of this we also want to have a per driver conversion and that
> > > > is the
> > > > main reason we have both of_xlate() and fwnode_xlate() support.    
> > > 
> > > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > > Thanks!
> > > 
> > > A few nit-picks below, though.
> > >     
> ...
> 
> >   
> > >     
> > > > -       err = of_parse_phandle_with_args(np, "io-channels",
> > > > -                                        "#io-channel-cells",
> > > > -                                        index, &iiospec);
> > > > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > > > channels",
> > > > +                                                "#io-channel-
> > > > cells", 0,
> > > > +                                                index, &iiospec);
> > > >         if (err)
> > > >                 return err;
> > > > 
> > > > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > > > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> > > >                                iio_dev_node_match);    
> > > 
> > > Wondering if this
> > > https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> > > can be utilized (yes, I noticed iio_device_type above).    
> > 
> > Hmm, at first glance I would say we can use it. AFAICT, we are already
> > grabbing a node which contains "#io-channel-cells" which is very
> > indicative that is an IIO device. I also find it very unlikely to have
> > two IIO devices with the same fwnode (I guess it would be an issue even
> > in the old code) and even more unlikely two devices of diferent types
> > with the same fwnode?  
> 
> If we are talking struct iio_dev instances, then there are quite a few cases
> where there are multiple with the same fwnode.  We had to do that pre
> multiple buffers being introduced so it's fairly common, though not in
> ADCs which is probably why we haven't seen breakage here. Not sure how
> broken things already are as a result or if any of those devices (most
> IMUs) provide #io-channel-cells etc.  I'd put that breakage down as
> one to look into if anyone every hits it or one of us is bored enough
> to poke at it.  (superficially I think we'd have to check all matches
> for an xlate success).

Having said that adding a warning comment here, so we remember this is
a potential issue would be great.

> 
> Also, possible (I'm not totally sure) that we have other subdevices using
> the same firmware node, such as triggers.  I can't immediately think
> of why they would need it, but I'd rather we were at least partly protected
> against that.
> 
> > 
> > Anyways, I guess Jonathan can help in here...
> > 
> >   
> > >     
> > > >         if (idev == NULL) {
> > > > -               of_node_put(iiospec.np);
> > > > +               fwnode_handle_put(iiospec.fwnode);
> > > >                 return -EPROBE_DEFER;
> > > >         }
> > > > 
> > > >         indio_dev = dev_to_iio_dev(idev);
> > > >         channel->indio_dev = indio_dev;
> > > >         if (indio_dev->info->of_xlate)
> > > > -               index = indio_dev->info->of_xlate(indio_dev,
> > > > &iiospec);
> > > > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > > > +       else if (indio_dev->info->fwnode_xlate)
> > > > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > > > &iiospec);
> > > >         else
> > > > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > > > -       of_node_put(iiospec.np);
> > > > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > > > &iiospec);
> > > > +       fwnode_handle_put(iiospec.fwnode);
> > > >         if (index < 0)
> > > >                 goto err_put;
> > > >         channel->channel = &indio_dev->channels[index];
> > > > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > > > iio_channel *channel,
> > > >         return index;
> > > >  }  
> 
> > >     
> > > >                 *parent_lookup = false;
> > > >         }
> > > > 
> > > >         return chan;
> > > >  }
> > > > 
> > > > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > > > *np,
> > > > -                                              const char *name)
> > > > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > > > fwnode_handle *fwnode,
> > > > +                                                  const char
> > > > *name)
> > > >  {
> > > >         struct iio_channel *chan;
> > > > +       struct fwnode_handle *parent;
> > > >         bool parent_lookup = true;
> > > > 
> > > >         /* Walk up the tree of devices looking for a matching iio
> > > > channel */
> > > > -       chan = __of_iio_channel_get_by_name(np, name,
> > > > &parent_lookup);
> > > > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > > > &parent_lookup);
> > > >         if (!parent_lookup)
> > > >                 return chan;
> > > > 
> > > > @@ -255,33 +279,34 @@ struct iio_channel
> > > > *of_iio_channel_get_by_name(struct device_node *np,
> > > >          * If the parent node has a "io-channel-ranges" property,
> > > >          * then we can try one of its channels.
> > > >          */
> > > > -       np = np->parent;
> > > > -       while (np) {
> > > > -               if (!of_get_property(np, "io-channel-ranges",
> > > > NULL))
> > > > +       fwnode_for_each_parent_node(fwnode, parent) {
> > > > +               if (!fwnode_property_present(parent, "io-channel-
> > > > ranges")) {
> > > > +                       fwnode_handle_put(parent);
> > > >                         return chan;    
> > > 
> > > break; ?    
> > 
> > The return in place was a request from Jonathan in the RFC...  
> 
> :)  I prefer not having to scroll down when we can get out quickly.
> 
> >   
> > > 
> > > (Yes, I understand pros and cons of each variant, up to you)
> > >     
> > > > +               }
> > > > 
> > > > -               chan = __of_iio_channel_get_by_name(np, name,
> > > > &parent_lookup);
> > > > -               if (!parent_lookup)
> > > > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > > > name, &parent_lookup);
> > > > +               if (!parent_lookup) {
> > > > +                       fwnode_handle_put(parent);
> > > >                         return chan;    
> > > 
> > > Ditto.
> > >     
> > > > -               np = np->parent;
> > > > +               }
> > > >         }
> > > > 
> > > >         return chan;
> > > >  }
> > > > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > > > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);    
> > > 
> > > Wondering if we may move this to the IIO namespace.    
> > 
> > I guess it makes sense but surely on a different patch...  
> 
> Yup - moving to a IIO namespace is a work in progress (got snarled
> up by the PM related macros needed for some of the sub namespaces
> which is now sorted)  Let's do it after this.
> 
> 


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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
@ 2022-06-11 15:32           ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:32 UTC (permalink / raw)
  To: Nuno Sá
  Cc: chrome-platform, Lad Prabhakar, open list:BROADCOM NVRAM DRIVER,
	Nuno Sá,
	Linux-Renesas, Andy Shevchenko, dl-linux-imx, moderated,
	list:ARM/Mediatek, SoC, support,
	          <linux-mediatek@lists.infradead.org>,
	 linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-msm  <linux-arm-msm@vger.kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	 OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	Cai Huoqing  <cai.huoqing@linux.dev>,
	Benjamin Fair <benjaminfair@google.com>,
	Jishnu  Prakash <quic_jprakash@quicinc.com>,
	Linus Walleij  <linus.walleij@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Alexandre  Torgue <alexandre.torgue@foss.st.com>,
	Amit Kucheria <amitk@kernel.org>,
	 Andy Gross <agross@kernel.org>,
	Michael Hennerich  <Michael.Hennerich@analog.com>,
	Haibo Chen <haibo.chen@nxp.com>,
	Benson  Leung <bleung@chromium.org>, ,
	linux-arm Mailing List
	<linux-arm-kernel@lists.infradead.org>

On Sat, 11 Jun 2022 16:30:57 +0100
Jonathan Cameron <jic23@kernel.org> wrote:

> On Fri, 10 Jun 2022 22:01:09 +0200
> Nuno Sá <noname.nuno@gmail.com> wrote:
> 
> > On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:  
> > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:    
> > > > 
> > > > This moves the IIO in kernel interface to use fwnode properties and
> > > > thus
> > > > be firmware agnostic.
> > > > 
> > > > Note that the interface is still not firmware agnostic. At this
> > > > point we
> > > > have both OF and fwnode interfaces so that we don't break any user.
> > > > On
> > > > top of this we also want to have a per driver conversion and that
> > > > is the
> > > > main reason we have both of_xlate() and fwnode_xlate() support.    
> > > 
> > > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > > Thanks!
> > > 
> > > A few nit-picks below, though.
> > >     
> ...
> 
> >   
> > >     
> > > > -       err = of_parse_phandle_with_args(np, "io-channels",
> > > > -                                        "#io-channel-cells",
> > > > -                                        index, &iiospec);
> > > > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > > > channels",
> > > > +                                                "#io-channel-
> > > > cells", 0,
> > > > +                                                index, &iiospec);
> > > >         if (err)
> > > >                 return err;
> > > > 
> > > > -       idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
> > > > +       idev = bus_find_device(&iio_bus_type, NULL, iiospec.fwnode,
> > > >                                iio_dev_node_match);    
> > > 
> > > Wondering if this
> > > https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> > > can be utilized (yes, I noticed iio_device_type above).    
> > 
> > Hmm, at first glance I would say we can use it. AFAICT, we are already
> > grabbing a node which contains "#io-channel-cells" which is very
> > indicative that is an IIO device. I also find it very unlikely to have
> > two IIO devices with the same fwnode (I guess it would be an issue even
> > in the old code) and even more unlikely two devices of diferent types
> > with the same fwnode?  
> 
> If we are talking struct iio_dev instances, then there are quite a few cases
> where there are multiple with the same fwnode.  We had to do that pre
> multiple buffers being introduced so it's fairly common, though not in
> ADCs which is probably why we haven't seen breakage here. Not sure how
> broken things already are as a result or if any of those devices (most
> IMUs) provide #io-channel-cells etc.  I'd put that breakage down as
> one to look into if anyone every hits it or one of us is bored enough
> to poke at it.  (superficially I think we'd have to check all matches
> for an xlate success).

Having said that adding a warning comment here, so we remember this is
a potential issue would be great.

> 
> Also, possible (I'm not totally sure) that we have other subdevices using
> the same firmware node, such as triggers.  I can't immediately think
> of why they would need it, but I'd rather we were at least partly protected
> against that.
> 
> > 
> > Anyways, I guess Jonathan can help in here...
> > 
> >   
> > >     
> > > >         if (idev == NULL) {
> > > > -               of_node_put(iiospec.np);
> > > > +               fwnode_handle_put(iiospec.fwnode);
> > > >                 return -EPROBE_DEFER;
> > > >         }
> > > > 
> > > >         indio_dev = dev_to_iio_dev(idev);
> > > >         channel->indio_dev = indio_dev;
> > > >         if (indio_dev->info->of_xlate)
> > > > -               index = indio_dev->info->of_xlate(indio_dev,
> > > > &iiospec);
> > > > +               index = __fwnode_to_of_xlate(indio_dev, &iiospec);
> > > > +       else if (indio_dev->info->fwnode_xlate)
> > > > +               index = indio_dev->info->fwnode_xlate(indio_dev,
> > > > &iiospec);
> > > >         else
> > > > -               index = __of_iio_simple_xlate(indio_dev, &iiospec);
> > > > -       of_node_put(iiospec.np);
> > > > +               index = __fwnode_iio_simple_xlate(indio_dev,
> > > > &iiospec);
> > > > +       fwnode_handle_put(iiospec.fwnode);
> > > >         if (index < 0)
> > > >                 goto err_put;
> > > >         channel->channel = &indio_dev->channels[index];
> > > > @@ -188,7 +209,8 @@ static int __of_iio_channel_get(struct
> > > > iio_channel *channel,
> > > >         return index;
> > > >  }  
> 
> > >     
> > > >                 *parent_lookup = false;
> > > >         }
> > > > 
> > > >         return chan;
> > > >  }
> > > > 
> > > > -struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > > > *np,
> > > > -                                              const char *name)
> > > > +struct iio_channel *fwnode_iio_channel_get_by_name(struct
> > > > fwnode_handle *fwnode,
> > > > +                                                  const char
> > > > *name)
> > > >  {
> > > >         struct iio_channel *chan;
> > > > +       struct fwnode_handle *parent;
> > > >         bool parent_lookup = true;
> > > > 
> > > >         /* Walk up the tree of devices looking for a matching iio
> > > > channel */
> > > > -       chan = __of_iio_channel_get_by_name(np, name,
> > > > &parent_lookup);
> > > > +       chan = __fwnode_iio_channel_get_by_name(fwnode, name,
> > > > &parent_lookup);
> > > >         if (!parent_lookup)
> > > >                 return chan;
> > > > 
> > > > @@ -255,33 +279,34 @@ struct iio_channel
> > > > *of_iio_channel_get_by_name(struct device_node *np,
> > > >          * If the parent node has a "io-channel-ranges" property,
> > > >          * then we can try one of its channels.
> > > >          */
> > > > -       np = np->parent;
> > > > -       while (np) {
> > > > -               if (!of_get_property(np, "io-channel-ranges",
> > > > NULL))
> > > > +       fwnode_for_each_parent_node(fwnode, parent) {
> > > > +               if (!fwnode_property_present(parent, "io-channel-
> > > > ranges")) {
> > > > +                       fwnode_handle_put(parent);
> > > >                         return chan;    
> > > 
> > > break; ?    
> > 
> > The return in place was a request from Jonathan in the RFC...  
> 
> :)  I prefer not having to scroll down when we can get out quickly.
> 
> >   
> > > 
> > > (Yes, I understand pros and cons of each variant, up to you)
> > >     
> > > > +               }
> > > > 
> > > > -               chan = __of_iio_channel_get_by_name(np, name,
> > > > &parent_lookup);
> > > > -               if (!parent_lookup)
> > > > +               chan = __fwnode_iio_channel_get_by_name(parent,
> > > > name, &parent_lookup);
> > > > +               if (!parent_lookup) {
> > > > +                       fwnode_handle_put(parent);
> > > >                         return chan;    
> > > 
> > > Ditto.
> > >     
> > > > -               np = np->parent;
> > > > +               }
> > > >         }
> > > > 
> > > >         return chan;
> > > >  }
> > > > -EXPORT_SYMBOL_GPL(of_iio_channel_get_by_name);
> > > > +EXPORT_SYMBOL_GPL(fwnode_iio_channel_get_by_name);    
> > > 
> > > Wondering if we may move this to the IIO namespace.    
> > 
> > I guess it makes sense but surely on a different patch...  
> 
> Yup - moving to a IIO namespace is a work in progress (got snarled
> up by the PM related macros needed for some of the sub namespaces
> which is now sorted)  Let's do it after this.
> 
> 


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

* Re: [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
  2022-06-10  8:45   ` Nuno Sá
  (?)
@ 2022-06-11 15:47     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:47 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:43 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

One trivial comment inline. 

In general this particular refactor is complex, so I either want
eyes of those familiar with the driver and / or testing or we may want
to reduce the scope to just the fwnode_xlate() and leave the more
complex conversions for when we can get that testing done.

Let's see if we get the necessary review on this more complex patch.
I just don't want us to get stalled by trying to do too much at once!

Jonathan


> ---
>  drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
>  1 file changed, 70 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> index a68ecbda6480..87acef31ace1 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -21,11 +21,11 @@
>  #include <linux/io.h>
>  #include <linux/iopoll.h>
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/nvmem-consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> -#include <linux/of.h>
> -#include <linux/of_device.h>
> +#include <linux/property.h>
>  
>  #include "stm32-adc-core.h"
>  
> @@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
>  	return ret;
>  }
>  
> -static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
> -			      const struct of_phandle_args *iiospec)
> +static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
> +				  const struct fwnode_reference_args *iiospec)
>  {
>  	int i;
>  
> @@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
>  	.hwfifo_set_watermark = stm32_adc_set_watermark,
>  	.update_scan_mode = stm32_adc_update_scan_mode,
>  	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
> -	.of_xlate = stm32_adc_of_xlate,
> +	.fwnode_xlate = stm32_adc_fwnode_xlate,
>  };
>  
>  static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
> @@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
>  	{},
>  };
>  
> -static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
> +static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
> +	struct device *dev = &indio_dev->dev;
>  	struct stm32_adc *adc = iio_priv(indio_dev);
>  	unsigned int i;
>  	u32 res;
>  
> -	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
> +	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
>  		res = adc->cfg->adc_info->resolutions[0];
>  
>  	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
> @@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
>  
>  static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
> +	struct device *dev = &indio_dev->dev;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	int num_channels = 0, ret;
>  
> -	ret = of_property_count_u32_elems(node, "st,adc-channels");
> +	ret = device_property_count_u32(dev, "st,adc-channels");
>  	if (ret > adc_info->max_channels) {
>  		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
>  		return -EINVAL;
> @@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>  		num_channels += ret;
>  	}
>  
> -	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
> -					      sizeof(struct stm32_adc_diff_channel));
> -	if (ret > adc_info->max_channels) {
> +	ret = device_property_count_u32(dev, "st,adc-diff-channels");
> +	if ((ret / 2) > adc_info->max_channels) {
hmm. The magic '2' that is introduced here kind of looses some of the meaning
that existed for the *_count_elems_of_size()

Perhaps introduce a define or a comment on why it is 2?

>  		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
>  		return -EINVAL;
> -	} else if (ret > 0) {
> -		adc->num_diff = ret;
> -		num_channels += ret;
> +	} else if ((ret / 2) > 0) {
> +		adc->num_diff = ret / 2;
> +		num_channels += ret / 2;
>  	}
>  
>  	/* Optional sample time is provided either for each, or all channels */
> -	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
> +	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
>  	if (ret > 1 && ret != num_channels) {
>  		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
>  		return -EINVAL;
> @@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>  
>  static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>  				      struct stm32_adc *adc,
> -				      struct iio_chan_spec *channels)
> +				      struct iio_chan_spec *channels,
> +				      int nchans)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
> +	struct device *dev = &indio_dev->dev;
>  	u32 num_diff = adc->num_diff;
>  	int size = num_diff * sizeof(*diff) / sizeof(u32);
> -	int scan_index = 0, val, ret, i;
> -	struct property *prop;
> -	const __be32 *cur;
> -	u32 smp = 0;
> +	int scan_index = 0, ret, i;
> +	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
>  
>  	if (num_diff) {
> -		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
> -						 (u32 *)diff, size);
> +		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
> +						     (u32 *)diff, size);
>  		if (ret) {
>  			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
>  			return ret;
> @@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>  		}
>  	}
>  
> -	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
> -		if (val >= adc_info->max_channels) {
> -			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
> +	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
> +					     nchans);
> +	if (ret)
> +		return ret;
> +
> +	for (i = 0; i < nchans; i++) {
> +		if (chans[i] >= adc_info->max_channels) {
> +			dev_err(&indio_dev->dev, "Invalid channel %d\n",
> +				chans[i]);
>  			return -EINVAL;
>  		}
>  
>  		/* Channel can't be configured both as single-ended & diff */
>  		for (i = 0; i < num_diff; i++) {
> -			if (val == diff[i].vinp) {
> -				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
> +			if (chans[i] == diff[i].vinp) {
> +				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
>  				return -EINVAL;
>  			}
>  		}
> -		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
> -					0, scan_index, false);
> +		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
> +					chans[i], 0, scan_index, false);
>  		scan_index++;
>  	}
>  
> +	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
> +	if (nsmps) {
> +		if (nsmps >= nchans)
> +			nsmps = nchans;
> +
> +		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
> +						     smps, nsmps);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	for (i = 0; i < scan_index; i++) {
>  		/*
> -		 * Using of_property_read_u32_index(), smp value will only be
> -		 * modified if valid u32 value can be decoded. This allows to
> -		 * get either no value, 1 shared value for all indexes, or one
> -		 * value per channel.
> +		 * This check is used with the above logic so that smp value
> +		 * will only be modified if valid u32 value can be decoded. This
> +		 * allows to get either no value, 1 shared value for all indexes,
> +		 * or one value per channel. The point is to have the same
> +		 * behavior as 'of_property_read_u32_index()'.
>  		 */
> -		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
> +		if (i < nsmps)
> +			smp = smps[i];
>  
>  		/* Prepare sampling time settings */
>  		stm32_adc_smpr_init(adc, channels[i].channel, smp);
> @@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  				       struct stm32_adc *adc,
>  				       struct iio_chan_spec *channels)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
> -	struct device_node *child;
> +	struct fwnode_handle *child;
>  	const char *name;
>  	int val, scan_index = 0, ret;
>  	bool differential;
>  	u32 vin[2];
>  
> -	for_each_available_child_of_node(node, child) {
> -		ret = of_property_read_u32(child, "reg", &val);
> +	device_for_each_child_node(&indio_dev->dev, child) {
> +		ret = fwnode_property_read_u32(child, "reg", &val);
>  		if (ret) {
>  			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
>  			goto err;
>  		}
>  
> -		ret = of_property_read_string(child, "label", &name);
> +		ret = fwnode_property_read_string(child, "label", &name);
>  		/* label is optional */
>  		if (!ret) {
>  			if (strlen(name) >= STM32_ADC_CH_SZ) {
> @@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  		}
>  
>  		differential = false;
> -		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
> +		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
>  		/* diff-channels is optional */
>  		if (!ret) {
>  			differential = true;
> @@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
>  					vin[1], scan_index, differential);
>  
> -		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
> +		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
>  		/* st,min-sample-time-ns is optional */
>  		if (!ret) {
>  			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
> @@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  	return scan_index;
>  
>  err:
> -	of_node_put(child);
> +	fwnode_handle_put(child);
>  
>  	return ret;
>  }
>  
> -static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
> +static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	struct stm32_adc *adc = iio_priv(indio_dev);
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	struct iio_chan_spec *channels;
> @@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>  	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
>  		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
>  
> -	num_channels = of_get_available_child_count(node);
> +	num_channels = device_get_child_node_count(&indio_dev->dev);
>  	/* If no channels have been found, fallback to channels legacy properties. */
>  	if (!num_channels) {
>  		legacy = true;
> @@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>  		return -ENOMEM;
>  
>  	if (legacy)
> -		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
> +		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
> +						 num_channels);
>  	else
>  		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
>  	if (ret < 0)
> @@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  	bool timestamping = false;
>  	int ret;
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
>  	if (!indio_dev)
>  		return -ENOMEM;
> @@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  	adc->common = dev_get_drvdata(pdev->dev.parent);
>  	spin_lock_init(&adc->lock);
>  	init_completion(&adc->completion);
> -	adc->cfg = (const struct stm32_adc_cfg *)
> -		of_match_device(dev->driver->of_match_table, dev)->data;
> +	adc->cfg = device_get_match_data(dev);
>  
>  	indio_dev->name = dev_name(&pdev->dev);
> -	indio_dev->dev.of_node = pdev->dev.of_node;
> +	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
>  	indio_dev->info = &stm32_adc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
>  
>  	platform_set_drvdata(pdev, indio_dev);
>  
> -	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
> +	ret = device_property_read_u32(dev, "reg", &adc->offset);
>  	if (ret != 0) {
>  		dev_err(&pdev->dev, "missing reg property\n");
>  		return -EINVAL;
> @@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	ret = stm32_adc_of_get_resolution(indio_dev);
> +	ret = stm32_adc_fw_get_resolution(indio_dev);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  		timestamping = true;
>  	}
>  
> -	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
> +	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
>  	if (ret < 0)
>  		goto err_dma_disable;
>  


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

* Re: [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
@ 2022-06-11 15:47     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:47 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:43 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

One trivial comment inline. 

In general this particular refactor is complex, so I either want
eyes of those familiar with the driver and / or testing or we may want
to reduce the scope to just the fwnode_xlate() and leave the more
complex conversions for when we can get that testing done.

Let's see if we get the necessary review on this more complex patch.
I just don't want us to get stalled by trying to do too much at once!

Jonathan


> ---
>  drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
>  1 file changed, 70 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> index a68ecbda6480..87acef31ace1 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -21,11 +21,11 @@
>  #include <linux/io.h>
>  #include <linux/iopoll.h>
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/nvmem-consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> -#include <linux/of.h>
> -#include <linux/of_device.h>
> +#include <linux/property.h>
>  
>  #include "stm32-adc-core.h"
>  
> @@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
>  	return ret;
>  }
>  
> -static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
> -			      const struct of_phandle_args *iiospec)
> +static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
> +				  const struct fwnode_reference_args *iiospec)
>  {
>  	int i;
>  
> @@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
>  	.hwfifo_set_watermark = stm32_adc_set_watermark,
>  	.update_scan_mode = stm32_adc_update_scan_mode,
>  	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
> -	.of_xlate = stm32_adc_of_xlate,
> +	.fwnode_xlate = stm32_adc_fwnode_xlate,
>  };
>  
>  static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
> @@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
>  	{},
>  };
>  
> -static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
> +static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
> +	struct device *dev = &indio_dev->dev;
>  	struct stm32_adc *adc = iio_priv(indio_dev);
>  	unsigned int i;
>  	u32 res;
>  
> -	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
> +	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
>  		res = adc->cfg->adc_info->resolutions[0];
>  
>  	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
> @@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
>  
>  static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
> +	struct device *dev = &indio_dev->dev;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	int num_channels = 0, ret;
>  
> -	ret = of_property_count_u32_elems(node, "st,adc-channels");
> +	ret = device_property_count_u32(dev, "st,adc-channels");
>  	if (ret > adc_info->max_channels) {
>  		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
>  		return -EINVAL;
> @@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>  		num_channels += ret;
>  	}
>  
> -	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
> -					      sizeof(struct stm32_adc_diff_channel));
> -	if (ret > adc_info->max_channels) {
> +	ret = device_property_count_u32(dev, "st,adc-diff-channels");
> +	if ((ret / 2) > adc_info->max_channels) {
hmm. The magic '2' that is introduced here kind of looses some of the meaning
that existed for the *_count_elems_of_size()

Perhaps introduce a define or a comment on why it is 2?

>  		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
>  		return -EINVAL;
> -	} else if (ret > 0) {
> -		adc->num_diff = ret;
> -		num_channels += ret;
> +	} else if ((ret / 2) > 0) {
> +		adc->num_diff = ret / 2;
> +		num_channels += ret / 2;
>  	}
>  
>  	/* Optional sample time is provided either for each, or all channels */
> -	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
> +	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
>  	if (ret > 1 && ret != num_channels) {
>  		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
>  		return -EINVAL;
> @@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>  
>  static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>  				      struct stm32_adc *adc,
> -				      struct iio_chan_spec *channels)
> +				      struct iio_chan_spec *channels,
> +				      int nchans)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
> +	struct device *dev = &indio_dev->dev;
>  	u32 num_diff = adc->num_diff;
>  	int size = num_diff * sizeof(*diff) / sizeof(u32);
> -	int scan_index = 0, val, ret, i;
> -	struct property *prop;
> -	const __be32 *cur;
> -	u32 smp = 0;
> +	int scan_index = 0, ret, i;
> +	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
>  
>  	if (num_diff) {
> -		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
> -						 (u32 *)diff, size);
> +		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
> +						     (u32 *)diff, size);
>  		if (ret) {
>  			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
>  			return ret;
> @@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>  		}
>  	}
>  
> -	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
> -		if (val >= adc_info->max_channels) {
> -			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
> +	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
> +					     nchans);
> +	if (ret)
> +		return ret;
> +
> +	for (i = 0; i < nchans; i++) {
> +		if (chans[i] >= adc_info->max_channels) {
> +			dev_err(&indio_dev->dev, "Invalid channel %d\n",
> +				chans[i]);
>  			return -EINVAL;
>  		}
>  
>  		/* Channel can't be configured both as single-ended & diff */
>  		for (i = 0; i < num_diff; i++) {
> -			if (val == diff[i].vinp) {
> -				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
> +			if (chans[i] == diff[i].vinp) {
> +				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
>  				return -EINVAL;
>  			}
>  		}
> -		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
> -					0, scan_index, false);
> +		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
> +					chans[i], 0, scan_index, false);
>  		scan_index++;
>  	}
>  
> +	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
> +	if (nsmps) {
> +		if (nsmps >= nchans)
> +			nsmps = nchans;
> +
> +		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
> +						     smps, nsmps);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	for (i = 0; i < scan_index; i++) {
>  		/*
> -		 * Using of_property_read_u32_index(), smp value will only be
> -		 * modified if valid u32 value can be decoded. This allows to
> -		 * get either no value, 1 shared value for all indexes, or one
> -		 * value per channel.
> +		 * This check is used with the above logic so that smp value
> +		 * will only be modified if valid u32 value can be decoded. This
> +		 * allows to get either no value, 1 shared value for all indexes,
> +		 * or one value per channel. The point is to have the same
> +		 * behavior as 'of_property_read_u32_index()'.
>  		 */
> -		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
> +		if (i < nsmps)
> +			smp = smps[i];
>  
>  		/* Prepare sampling time settings */
>  		stm32_adc_smpr_init(adc, channels[i].channel, smp);
> @@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  				       struct stm32_adc *adc,
>  				       struct iio_chan_spec *channels)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
> -	struct device_node *child;
> +	struct fwnode_handle *child;
>  	const char *name;
>  	int val, scan_index = 0, ret;
>  	bool differential;
>  	u32 vin[2];
>  
> -	for_each_available_child_of_node(node, child) {
> -		ret = of_property_read_u32(child, "reg", &val);
> +	device_for_each_child_node(&indio_dev->dev, child) {
> +		ret = fwnode_property_read_u32(child, "reg", &val);
>  		if (ret) {
>  			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
>  			goto err;
>  		}
>  
> -		ret = of_property_read_string(child, "label", &name);
> +		ret = fwnode_property_read_string(child, "label", &name);
>  		/* label is optional */
>  		if (!ret) {
>  			if (strlen(name) >= STM32_ADC_CH_SZ) {
> @@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  		}
>  
>  		differential = false;
> -		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
> +		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
>  		/* diff-channels is optional */
>  		if (!ret) {
>  			differential = true;
> @@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
>  					vin[1], scan_index, differential);
>  
> -		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
> +		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
>  		/* st,min-sample-time-ns is optional */
>  		if (!ret) {
>  			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
> @@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  	return scan_index;
>  
>  err:
> -	of_node_put(child);
> +	fwnode_handle_put(child);
>  
>  	return ret;
>  }
>  
> -static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
> +static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	struct stm32_adc *adc = iio_priv(indio_dev);
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	struct iio_chan_spec *channels;
> @@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>  	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
>  		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
>  
> -	num_channels = of_get_available_child_count(node);
> +	num_channels = device_get_child_node_count(&indio_dev->dev);
>  	/* If no channels have been found, fallback to channels legacy properties. */
>  	if (!num_channels) {
>  		legacy = true;
> @@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>  		return -ENOMEM;
>  
>  	if (legacy)
> -		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
> +		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
> +						 num_channels);
>  	else
>  		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
>  	if (ret < 0)
> @@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  	bool timestamping = false;
>  	int ret;
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
>  	if (!indio_dev)
>  		return -ENOMEM;
> @@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  	adc->common = dev_get_drvdata(pdev->dev.parent);
>  	spin_lock_init(&adc->lock);
>  	init_completion(&adc->completion);
> -	adc->cfg = (const struct stm32_adc_cfg *)
> -		of_match_device(dev->driver->of_match_table, dev)->data;
> +	adc->cfg = device_get_match_data(dev);
>  
>  	indio_dev->name = dev_name(&pdev->dev);
> -	indio_dev->dev.of_node = pdev->dev.of_node;
> +	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
>  	indio_dev->info = &stm32_adc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
>  
>  	platform_set_drvdata(pdev, indio_dev);
>  
> -	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
> +	ret = device_property_read_u32(dev, "reg", &adc->offset);
>  	if (ret != 0) {
>  		dev_err(&pdev->dev, "missing reg property\n");
>  		return -EINVAL;
> @@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	ret = stm32_adc_of_get_resolution(indio_dev);
> +	ret = stm32_adc_fw_get_resolution(indio_dev);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  		timestamping = true;
>  	}
>  
> -	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
> +	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
>  	if (ret < 0)
>  		goto err_dma_disable;
>  


_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
@ 2022-06-11 15:47     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:47 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:43 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
> 
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

One trivial comment inline. 

In general this particular refactor is complex, so I either want
eyes of those familiar with the driver and / or testing or we may want
to reduce the scope to just the fwnode_xlate() and leave the more
complex conversions for when we can get that testing done.

Let's see if we get the necessary review on this more complex patch.
I just don't want us to get stalled by trying to do too much at once!

Jonathan


> ---
>  drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
>  1 file changed, 70 insertions(+), 58 deletions(-)
> 
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> index a68ecbda6480..87acef31ace1 100644
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
> @@ -21,11 +21,11 @@
>  #include <linux/io.h>
>  #include <linux/iopoll.h>
>  #include <linux/module.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/nvmem-consumer.h>
>  #include <linux/platform_device.h>
>  #include <linux/pm_runtime.h>
> -#include <linux/of.h>
> -#include <linux/of_device.h>
> +#include <linux/property.h>
>  
>  #include "stm32-adc-core.h"
>  
> @@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
>  	return ret;
>  }
>  
> -static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
> -			      const struct of_phandle_args *iiospec)
> +static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
> +				  const struct fwnode_reference_args *iiospec)
>  {
>  	int i;
>  
> @@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
>  	.hwfifo_set_watermark = stm32_adc_set_watermark,
>  	.update_scan_mode = stm32_adc_update_scan_mode,
>  	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
> -	.of_xlate = stm32_adc_of_xlate,
> +	.fwnode_xlate = stm32_adc_fwnode_xlate,
>  };
>  
>  static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
> @@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
>  	{},
>  };
>  
> -static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
> +static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
> +	struct device *dev = &indio_dev->dev;
>  	struct stm32_adc *adc = iio_priv(indio_dev);
>  	unsigned int i;
>  	u32 res;
>  
> -	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
> +	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
>  		res = adc->cfg->adc_info->resolutions[0];
>  
>  	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
> @@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
>  
>  static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
> +	struct device *dev = &indio_dev->dev;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	int num_channels = 0, ret;
>  
> -	ret = of_property_count_u32_elems(node, "st,adc-channels");
> +	ret = device_property_count_u32(dev, "st,adc-channels");
>  	if (ret > adc_info->max_channels) {
>  		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
>  		return -EINVAL;
> @@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>  		num_channels += ret;
>  	}
>  
> -	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
> -					      sizeof(struct stm32_adc_diff_channel));
> -	if (ret > adc_info->max_channels) {
> +	ret = device_property_count_u32(dev, "st,adc-diff-channels");
> +	if ((ret / 2) > adc_info->max_channels) {
hmm. The magic '2' that is introduced here kind of looses some of the meaning
that existed for the *_count_elems_of_size()

Perhaps introduce a define or a comment on why it is 2?

>  		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
>  		return -EINVAL;
> -	} else if (ret > 0) {
> -		adc->num_diff = ret;
> -		num_channels += ret;
> +	} else if ((ret / 2) > 0) {
> +		adc->num_diff = ret / 2;
> +		num_channels += ret / 2;
>  	}
>  
>  	/* Optional sample time is provided either for each, or all channels */
> -	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
> +	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
>  	if (ret > 1 && ret != num_channels) {
>  		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
>  		return -EINVAL;
> @@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>  
>  static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>  				      struct stm32_adc *adc,
> -				      struct iio_chan_spec *channels)
> +				      struct iio_chan_spec *channels,
> +				      int nchans)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
> +	struct device *dev = &indio_dev->dev;
>  	u32 num_diff = adc->num_diff;
>  	int size = num_diff * sizeof(*diff) / sizeof(u32);
> -	int scan_index = 0, val, ret, i;
> -	struct property *prop;
> -	const __be32 *cur;
> -	u32 smp = 0;
> +	int scan_index = 0, ret, i;
> +	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
>  
>  	if (num_diff) {
> -		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
> -						 (u32 *)diff, size);
> +		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
> +						     (u32 *)diff, size);
>  		if (ret) {
>  			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
>  			return ret;
> @@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>  		}
>  	}
>  
> -	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
> -		if (val >= adc_info->max_channels) {
> -			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
> +	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
> +					     nchans);
> +	if (ret)
> +		return ret;
> +
> +	for (i = 0; i < nchans; i++) {
> +		if (chans[i] >= adc_info->max_channels) {
> +			dev_err(&indio_dev->dev, "Invalid channel %d\n",
> +				chans[i]);
>  			return -EINVAL;
>  		}
>  
>  		/* Channel can't be configured both as single-ended & diff */
>  		for (i = 0; i < num_diff; i++) {
> -			if (val == diff[i].vinp) {
> -				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
> +			if (chans[i] == diff[i].vinp) {
> +				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
>  				return -EINVAL;
>  			}
>  		}
> -		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
> -					0, scan_index, false);
> +		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
> +					chans[i], 0, scan_index, false);
>  		scan_index++;
>  	}
>  
> +	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
> +	if (nsmps) {
> +		if (nsmps >= nchans)
> +			nsmps = nchans;
> +
> +		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
> +						     smps, nsmps);
> +		if (ret)
> +			return ret;
> +	}
> +
>  	for (i = 0; i < scan_index; i++) {
>  		/*
> -		 * Using of_property_read_u32_index(), smp value will only be
> -		 * modified if valid u32 value can be decoded. This allows to
> -		 * get either no value, 1 shared value for all indexes, or one
> -		 * value per channel.
> +		 * This check is used with the above logic so that smp value
> +		 * will only be modified if valid u32 value can be decoded. This
> +		 * allows to get either no value, 1 shared value for all indexes,
> +		 * or one value per channel. The point is to have the same
> +		 * behavior as 'of_property_read_u32_index()'.
>  		 */
> -		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
> +		if (i < nsmps)
> +			smp = smps[i];
>  
>  		/* Prepare sampling time settings */
>  		stm32_adc_smpr_init(adc, channels[i].channel, smp);
> @@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  				       struct stm32_adc *adc,
>  				       struct iio_chan_spec *channels)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
> -	struct device_node *child;
> +	struct fwnode_handle *child;
>  	const char *name;
>  	int val, scan_index = 0, ret;
>  	bool differential;
>  	u32 vin[2];
>  
> -	for_each_available_child_of_node(node, child) {
> -		ret = of_property_read_u32(child, "reg", &val);
> +	device_for_each_child_node(&indio_dev->dev, child) {
> +		ret = fwnode_property_read_u32(child, "reg", &val);
>  		if (ret) {
>  			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
>  			goto err;
>  		}
>  
> -		ret = of_property_read_string(child, "label", &name);
> +		ret = fwnode_property_read_string(child, "label", &name);
>  		/* label is optional */
>  		if (!ret) {
>  			if (strlen(name) >= STM32_ADC_CH_SZ) {
> @@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  		}
>  
>  		differential = false;
> -		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
> +		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
>  		/* diff-channels is optional */
>  		if (!ret) {
>  			differential = true;
> @@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
>  					vin[1], scan_index, differential);
>  
> -		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
> +		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
>  		/* st,min-sample-time-ns is optional */
>  		if (!ret) {
>  			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
> @@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>  	return scan_index;
>  
>  err:
> -	of_node_put(child);
> +	fwnode_handle_put(child);
>  
>  	return ret;
>  }
>  
> -static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
> +static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
>  {
> -	struct device_node *node = indio_dev->dev.of_node;
>  	struct stm32_adc *adc = iio_priv(indio_dev);
>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>  	struct iio_chan_spec *channels;
> @@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>  	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
>  		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
>  
> -	num_channels = of_get_available_child_count(node);
> +	num_channels = device_get_child_node_count(&indio_dev->dev);
>  	/* If no channels have been found, fallback to channels legacy properties. */
>  	if (!num_channels) {
>  		legacy = true;
> @@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>  		return -ENOMEM;
>  
>  	if (legacy)
> -		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
> +		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
> +						 num_channels);
>  	else
>  		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
>  	if (ret < 0)
> @@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  	bool timestamping = false;
>  	int ret;
>  
> -	if (!pdev->dev.of_node)
> -		return -ENODEV;
> -
>  	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
>  	if (!indio_dev)
>  		return -ENOMEM;
> @@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  	adc->common = dev_get_drvdata(pdev->dev.parent);
>  	spin_lock_init(&adc->lock);
>  	init_completion(&adc->completion);
> -	adc->cfg = (const struct stm32_adc_cfg *)
> -		of_match_device(dev->driver->of_match_table, dev)->data;
> +	adc->cfg = device_get_match_data(dev);
>  
>  	indio_dev->name = dev_name(&pdev->dev);
> -	indio_dev->dev.of_node = pdev->dev.of_node;
> +	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
>  	indio_dev->info = &stm32_adc_iio_info;
>  	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
>  
>  	platform_set_drvdata(pdev, indio_dev);
>  
> -	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
> +	ret = device_property_read_u32(dev, "reg", &adc->offset);
>  	if (ret != 0) {
>  		dev_err(&pdev->dev, "missing reg property\n");
>  		return -EINVAL;
> @@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> -	ret = stm32_adc_of_get_resolution(indio_dev);
> +	ret = stm32_adc_fw_get_resolution(indio_dev);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>  		timestamping = true;
>  	}
>  
> -	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
> +	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
>  	if (ret < 0)
>  		goto err_dma_disable;
>  


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

* Re: [PATCH 00/34] make iio inkern interface firmware agnostic
  2022-06-10 15:28     ` Andy Shevchenko
@ 2022-06-11 15:50       ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:50 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar

On Fri, 10 Jun 2022 17:28:24 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 10, 2022 at 4:48 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Fri, Jun 10, 2022 at 10:45 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> 
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>  
> 
> Ditto for patches 26-34.
> 

I'm fine with all the patches I haven't commented on, but some
of the generic fwnode conversions are complex as such things go, so
more eyes on them and the core changes would be great.

Thanks,

Jonathan



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

* Re: [PATCH 00/34] make iio inkern interface firmware agnostic
@ 2022-06-11 15:50       ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-11 15:50 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: chrome-platform, Lad Prabhakar, open list:BROADCOM NVRAM DRIVER,
	Nuno Sá,
	Linux-Renesas, dl-linux-imx, moderated, list:ARM/Mediatek, SoC,
	support,          <linux-mediatek@lists.infradead.org>,
	 linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-msm  <linux-arm-msm@vger.kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	 OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	Cai Huoqing  <cai.huoqing@linux.dev>,
	Benjamin Fair <benjaminfair@google.com>,
	Jishnu  Prakash <quic_jprakash@quicinc.com>,
	Linus Walleij  <linus.walleij@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Alexandre  Torgue <alexandre.torgue@foss.st.com>,
	Amit Kucheria <amitk@kernel.org>,
	 Andy Gross <agross@kernel.org>,
	Michael Hennerich  <Michael.Hennerich@analog.com>,
	Haibo Chen <haibo.chen@nxp.com>,
	Benson  Leung <bleung@chromium.org>, ,
	linux-arm Mailing List
	<linux-arm-kernel@lists.infradead.org>

On Fri, 10 Jun 2022 17:28:24 +0200
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Fri, Jun 10, 2022 at 4:48 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Fri, Jun 10, 2022 at 10:45 AM Nuno Sá <nuno.sa@analog.com> wrote:  
> 
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>  
> 
> Ditto for patches 26-34.
> 

I'm fine with all the patches I haven't commented on, but some
of the generic fwnode conversions are complex as such things go, so
more eyes on them and the core changes would be great.

Thanks,

Jonathan



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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
  2022-06-10 19:51       ` Nuno Sá
  (?)
@ 2022-06-12 17:39         ` Geert Uytterhoeven
  -1 siblings, 0 replies; 246+ messages in thread
From: Geert Uytterhoeven @ 2022-06-12 17:39 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Joe Simmons-Talbott, Nuno Sá,
	NXP Linux Team, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	Linux ARM, chrome-platform, Lad Prabhakar, linux-mediatek,
	linux-stm32, linux-arm-msm, linux-iio, openbmc, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

Hi Nuno,

On Fri, Jun 10, 2022 at 9:52 PM Nuno Sá <noname.nuno@gmail.com> wrote:
> On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> > On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > > Just cosmetics. No functional change intended...
> > >
> > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>

> > > --- a/drivers/iio/inkern.c
> > > +++ b/drivers/iio/inkern.c
> > > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > > *indio_dev, struct iio_map *maps)
> > >         int i = 0, ret = 0;
> > >         struct iio_map_internal *mapi;
> > >
> > > -       if (maps == NULL)
> > > +       if (!maps)
> > >                 return 0;
> > >
> > >         mutex_lock(&iio_map_list_lock);
> > > -       while (maps[i].consumer_dev_name != NULL) {
> > > +       while (!maps[i].consumer_dev_name) {
> >
> > Shouldn't this be?:
> > while (maps[i].consumer_dev_name) {
>
> Ups... Nice catch! I was probably in bot mode already.

When making a change with no functional change intended, it is always
a good idea to compare the generated assembler before/after.  I.e.

    make drivers/iio/inkern.s
    mv drivers/iio/inkern.s drivers/iio/inkern.s.orig
    [make your change]
    make drivers/iio/inkern.s
    diff -u drivers/iio/inkern.s{.orig,}

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-12 17:39         ` Geert Uytterhoeven
  0 siblings, 0 replies; 246+ messages in thread
From: Geert Uytterhoeven @ 2022-06-12 17:39 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Joe Simmons-Talbott, Nuno Sá,
	NXP Linux Team, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	Linux ARM, chrome-platform, Lad Prabhakar, linux-mediatek,
	linux-stm32, linux-arm-msm, linux-iio, openbmc, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

Hi Nuno,

On Fri, Jun 10, 2022 at 9:52 PM Nuno Sá <noname.nuno@gmail.com> wrote:
> On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> > On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > > Just cosmetics. No functional change intended...
> > >
> > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>

> > > --- a/drivers/iio/inkern.c
> > > +++ b/drivers/iio/inkern.c
> > > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > > *indio_dev, struct iio_map *maps)
> > >         int i = 0, ret = 0;
> > >         struct iio_map_internal *mapi;
> > >
> > > -       if (maps == NULL)
> > > +       if (!maps)
> > >                 return 0;
> > >
> > >         mutex_lock(&iio_map_list_lock);
> > > -       while (maps[i].consumer_dev_name != NULL) {
> > > +       while (!maps[i].consumer_dev_name) {
> >
> > Shouldn't this be?:
> > while (maps[i].consumer_dev_name) {
>
> Ups... Nice catch! I was probably in bot mode already.

When making a change with no functional change intended, it is always
a good idea to compare the generated assembler before/after.  I.e.

    make drivers/iio/inkern.s
    mv drivers/iio/inkern.s drivers/iio/inkern.s.orig
    [make your change]
    make drivers/iio/inkern.s
    diff -u drivers/iio/inkern.s{.orig,}

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-12 17:39         ` Geert Uytterhoeven
  0 siblings, 0 replies; 246+ messages in thread
From: Geert Uytterhoeven @ 2022-06-12 17:39 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	openbmc, Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	NXP Linux Team, Olivier Moysan, Zhang Rui,
	Christophe Brancherea u, Bjorn Andersson, Tali Perry,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Joe Simmons-Talbott, Benson Leung, Pengutronix Kernel Team,
	Linux ARM, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	open list:BROADCOM NVRAM DRIVER, Thara Gopinath

, Arnd Bergmann <arnd@arndb.de>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Cai Huoqing <cai.huoqing@linux.dev>, Shawn Guo <shawnguo@kernel.org>, Claudiu Beznea <claudiu.beznea@microchip.com>, Jonathan Cameron <jic23@kernel.org>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

Hi Nuno,

On Fri, Jun 10, 2022 at 9:52 PM Nuno Sá <noname.nuno@gmail.com> wrote:
> On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> > On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > > Just cosmetics. No functional change intended...
> > >
> > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>

> > > --- a/drivers/iio/inkern.c
> > > +++ b/drivers/iio/inkern.c
> > > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > > *indio_dev, struct iio_map *maps)
> > >         int i = 0, ret = 0;
> > >         struct iio_map_internal *mapi;
> > >
> > > -       if (maps == NULL)
> > > +       if (!maps)
> > >                 return 0;
> > >
> > >         mutex_lock(&iio_map_list_lock);
> > > -       while (maps[i].consumer_dev_name != NULL) {
> > > +       while (!maps[i].consumer_dev_name) {
> >
> > Shouldn't this be?:
> > while (maps[i].consumer_dev_name) {
>
> Ups... Nice catch! I was probably in bot mode already.

When making a change with no functional change intended, it is always
a good idea to compare the generated assembler before/after.  I.e.

    make drivers/iio/inkern.s
    mv drivers/iio/inkern.s drivers/iio/inkern.s.orig
    [make your change]
    make drivers/iio/inkern.s
    diff -u drivers/iio/inkern.s{.orig,}

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
  2022-06-11 15:17     ` Jonathan Cameron
  (?)
@ 2022-06-13  7:06       ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:06 UTC (permalink / raw)
  To: Jonathan Cameron, Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Sat, 2022-06-11 at 16:17 +0100, Jonathan Cameron wrote:
> On Fri, 10 Jun 2022 10:45:33 +0200
> Nuno Sá <nuno.sa@analog.com> wrote:
> 
> > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > were
> > returning a mix of NULL and error pointers being NULL the way to
> 
> pointers with NULL being the way to...
> 
> > "notify" that we should do a "system" lookup for channels. This
> > make
> > it very confusing and prone to errors as commit dbbccf7c20bf
> > ("iio: inkern: fix return value in
> > devm_of_iio_channel_get_by_name()")
> > proves. On top of this, patterns like 'if (channel != NULL) return
> > channel'
> > were being used where channel could actually be an error code which
> > makes the code hard to read.
> > 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c | 24 +++++++++++-------------
> >  1 file changed, 11 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index 87fd2a0d44f2..31d9c122199a 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -214,7 +214,7 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >  struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > *np,
> >                                                const char *name)
> >  {
> > -       struct iio_channel *chan = NULL;
> > +       struct iio_channel *chan;
> >  
> >         /* Walk up the tree of devices looking for a matching iio
> > channel */
> >         while (np) {
> > @@ -231,11 +231,11 @@ struct iio_channel
> > *of_iio_channel_get_by_name(struct device_node *np,
> >                                                          name);
> >                 chan = of_iio_channel_get(np, index);
> >                 if (!IS_ERR(chan) || PTR_ERR(chan) == -
> > EPROBE_DEFER)
> > -                       break;
> 
> This original behaviour is 'interesting'. If we get a error like -
> ENOMEM
> we should return it rather than carry on.  Do we have enough
> knowledge
> of possible errors here to be more explicit on when we keep looking
> up
> the tree?  I think we can get -ENOENT from
> of_parse_phandle_with_args()
> 
> That raises an interesting question on whether -ENODEV is the right
> response
> for the previously NULL case or is -ENOENT more consistent with other
> of_ functions?  No device could be thought of as being the case that
> needs
> to defer (in hope it turns up later) whereas no entry means it will
> never
> succeed.

From what I could see, of_parse_phandle_with_args() either returns 
-EINVAL or -ENOENT. We also have the internal of_iio_channel_get()
which can return -ENOMEM. So I guess we should only continue looking if
we get -ENOENT?

To be clear, do you still prefer to explicitly return -ENODEV in the
previous NULL cases or should we honor the return code from 
of_parse_phandle_with_args() and just return chans (and thus ENOENT)?

- Nuno Sá

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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-13  7:06       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:06 UTC (permalink / raw)
  To: Jonathan Cameron, Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Sat, 2022-06-11 at 16:17 +0100, Jonathan Cameron wrote:
> On Fri, 10 Jun 2022 10:45:33 +0200
> Nuno Sá <nuno.sa@analog.com> wrote:
> 
> > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > were
> > returning a mix of NULL and error pointers being NULL the way to
> 
> pointers with NULL being the way to...
> 
> > "notify" that we should do a "system" lookup for channels. This
> > make
> > it very confusing and prone to errors as commit dbbccf7c20bf
> > ("iio: inkern: fix return value in
> > devm_of_iio_channel_get_by_name()")
> > proves. On top of this, patterns like 'if (channel != NULL) return
> > channel'
> > were being used where channel could actually be an error code which
> > makes the code hard to read.
> > 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c | 24 +++++++++++-------------
> >  1 file changed, 11 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index 87fd2a0d44f2..31d9c122199a 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -214,7 +214,7 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >  struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > *np,
> >                                                const char *name)
> >  {
> > -       struct iio_channel *chan = NULL;
> > +       struct iio_channel *chan;
> >  
> >         /* Walk up the tree of devices looking for a matching iio
> > channel */
> >         while (np) {
> > @@ -231,11 +231,11 @@ struct iio_channel
> > *of_iio_channel_get_by_name(struct device_node *np,
> >                                                          name);
> >                 chan = of_iio_channel_get(np, index);
> >                 if (!IS_ERR(chan) || PTR_ERR(chan) == -
> > EPROBE_DEFER)
> > -                       break;
> 
> This original behaviour is 'interesting'. If we get a error like -
> ENOMEM
> we should return it rather than carry on.  Do we have enough
> knowledge
> of possible errors here to be more explicit on when we keep looking
> up
> the tree?  I think we can get -ENOENT from
> of_parse_phandle_with_args()
> 
> That raises an interesting question on whether -ENODEV is the right
> response
> for the previously NULL case or is -ENOENT more consistent with other
> of_ functions?  No device could be thought of as being the case that
> needs
> to defer (in hope it turns up later) whereas no entry means it will
> never
> succeed.

From what I could see, of_parse_phandle_with_args() either returns 
-EINVAL or -ENOENT. We also have the internal of_iio_channel_get()
which can return -ENOMEM. So I guess we should only continue looking if
we get -ENOENT?

To be clear, do you still prefer to explicitly return -ENODEV in the
previous NULL cases or should we honor the return code from 
of_parse_phandle_with_args() and just return chans (and thus ENOENT)?

- Nuno Sá

_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-13  7:06       ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:06 UTC (permalink / raw)
  To: Jonathan Cameron, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Sat, 2022-06-11 at 16:17 +0100, Jonathan Cameron wrote:
> On Fri, 10 Jun 2022 10:45:33 +0200
> Nuno Sá <nuno.sa@analog.com> wrote:
> 
> > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > were
> > returning a mix of NULL and error pointers being NULL the way to
> 
> pointers with NULL being the way to...
> 
> > "notify" that we should do a "system" lookup for channels. This
> > make
> > it very confusing and prone to errors as commit dbbccf7c20bf
> > ("iio: inkern: fix return value in
> > devm_of_iio_channel_get_by_name()")
> > proves. On top of this, patterns like 'if (channel != NULL) return
> > channel'
> > were being used where channel could actually be an error code which
> > makes the code hard to read.
> > 
> > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > ---
> >  drivers/iio/inkern.c | 24 +++++++++++-------------
> >  1 file changed, 11 insertions(+), 13 deletions(-)
> > 
> > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > index 87fd2a0d44f2..31d9c122199a 100644
> > --- a/drivers/iio/inkern.c
> > +++ b/drivers/iio/inkern.c
> > @@ -214,7 +214,7 @@ static struct iio_channel
> > *of_iio_channel_get(struct device_node *np, int index)
> >  struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > *np,
> >                                                const char *name)
> >  {
> > -       struct iio_channel *chan = NULL;
> > +       struct iio_channel *chan;
> >  
> >         /* Walk up the tree of devices looking for a matching iio
> > channel */
> >         while (np) {
> > @@ -231,11 +231,11 @@ struct iio_channel
> > *of_iio_channel_get_by_name(struct device_node *np,
> >                                                          name);
> >                 chan = of_iio_channel_get(np, index);
> >                 if (!IS_ERR(chan) || PTR_ERR(chan) == -
> > EPROBE_DEFER)
> > -                       break;
> 
> This original behaviour is 'interesting'. If we get a error like -
> ENOMEM
> we should return it rather than carry on.  Do we have enough
> knowledge
> of possible errors here to be more explicit on when we keep looking
> up
> the tree?  I think we can get -ENOENT from
> of_parse_phandle_with_args()
> 
> That raises an interesting question on whether -ENODEV is the right
> response
> for the previously NULL case or is -ENOENT more consistent with other
> of_ functions?  No device could be thought of as being the case that
> needs
> to defer (in hope it turns up later) whereas no entry means it will
> never
> succeed.

From what I could see, of_parse_phandle_with_args() either returns 
-EINVAL or -ENOENT. We also have the internal of_iio_channel_get()
which can return -ENOMEM. So I guess we should only continue looking if
we get -ENOENT?

To be clear, do you still prefer to explicitly return -ENODEV in the
previous NULL cases or should we honor the return code from 
of_parse_phandle_with_args() and just return chans (and thus ENOENT)?

- Nuno Sá

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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
  2022-06-11 15:32           ` Jonathan Cameron
  (?)
@ 2022-06-13  7:13           ` Nuno Sá
  2022-06-18 14:09             ` Jonathan Cameron
  -1 siblings, 1 reply; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:13 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar

On Sat, 2022-06-11 at 16:32 +0100, Jonathan Cameron wrote:
> On Sat, 11 Jun 2022 16:30:57 +0100
> Jonathan Cameron <jic23@kernel.org> wrote:
> 
> > On Fri, 10 Jun 2022 22:01:09 +0200
> > Nuno Sá <noname.nuno@gmail.com> wrote:
> > 
> > > On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:  
> > > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > > wrote:    
> > > > > 
> > > > > This moves the IIO in kernel interface to use fwnode
> > > > > properties and
> > > > > thus
> > > > > be firmware agnostic.
> > > > > 
> > > > > Note that the interface is still not firmware agnostic. At
> > > > > this
> > > > > point we
> > > > > have both OF and fwnode interfaces so that we don't break any
> > > > > user.
> > > > > On
> > > > > top of this we also want to have a per driver conversion and
> > > > > that
> > > > > is the
> > > > > main reason we have both of_xlate() and fwnode_xlate()
> > > > > support.    
> > > > 
> > > > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > > > Thanks!
> > > > 
> > > > A few nit-picks below, though.
> > > >     
> > ...
> > 
> > >   
> > > >     
> > > > > -       err = of_parse_phandle_with_args(np, "io-channels",
> > > > > -                                        "#io-channel-cells",
> > > > > -                                        index, &iiospec);
> > > > > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > > > > channels",
> > > > > +                                                "#io-
> > > > > channel-
> > > > > cells", 0,
> > > > > +                                                index,
> > > > > &iiospec);
> > > > >         if (err)
> > > > >                 return err;
> > > > > 
> > > > > -       idev = bus_find_device(&iio_bus_type, NULL,
> > > > > iiospec.np,
> > > > > +       idev = bus_find_device(&iio_bus_type, NULL,
> > > > > iiospec.fwnode,
> > > > >                                iio_dev_node_match);    
> > > > 
> > > > Wondering if this
> > > > https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> > > > can be utilized (yes, I noticed iio_device_type above).    
> > > 
> > > Hmm, at first glance I would say we can use it. AFAICT, we are
> > > already
> > > grabbing a node which contains "#io-channel-cells" which is very
> > > indicative that is an IIO device. I also find it very unlikely to
> > > have
> > > two IIO devices with the same fwnode (I guess it would be an
> > > issue even
> > > in the old code) and even more unlikely two devices of diferent
> > > types
> > > with the same fwnode?  
> > 
> > If we are talking struct iio_dev instances, then there are quite a
> > few cases
> > where there are multiple with the same fwnode.  We had to do that
> > pre
> > multiple buffers being introduced so it's fairly common, though not
> > in
> > ADCs which is probably why we haven't seen breakage here. Not sure
> > how
> > broken things already are as a result or if any of those devices
> > (most
> > IMUs) provide #io-channel-cells etc.  I'd put that breakage down as
> > one to look into if anyone every hits it or one of us is bored
> > enough
> > to poke at it.  (superficially I think we'd have to check all
> > matches
> > for an xlate success).
> 
> Having said that adding a warning comment here, so we remember this
> is
> a potential issue would be great.
> 

can add the warning... And AFAIU, we can go with Andy suggestion right?

- Nuno Sá


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-11 14:59         ` Jonathan Cameron
  (?)
@ 2022-06-13  7:20           ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:20 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal, Mark Brown

On Sat, 2022-06-11 at 15:59 +0100, Jonathan Cameron wrote:
> 
> +Cc Mark Brown for a query on ordering in device tree based SPI
> setup.
> 
> On Fri, 10 Jun 2022 22:08:41 +0200
> Nuno Sá <noname.nuno@gmail.com> wrote:
> 
> > On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > wrote:  
> > > > 
> > > > 'of_node_put()' can potentially release the memory pointed to
> > > > by
> > > > 'iiospec.np' which would leave us with an invalid pointer (and
> > > > we
> > > > would
> > > > still pass it in 'of_xlate()'). As such, we can only release
> > > > the
> > > > node
> > > > after we are done with it.  
> > > 
> > > The question you should answer in the commit message is the
> > > following:
> > > "Can an OF node, attached to a struct device, be gone before the
> > > device itself?" If it so, then patch is good, otherwise there is
> > > no
> > > point in this patch in the first place.
> > >   
> > 
> > Yeah, I might be wrong but from a quick look... yes, I think the
> > node
> > can be gone before the device. Take a look on the spi or i2c
> > of_notify
> > handling and you can see that the nodes are get/put on the
> > add/remove
> > notifcation. Meaning that the node lifespan is not really attached
> > to
> > the device lifespan. If it was, I would expect to see of_node_put()
> > on
> > the device release() function...
> 
> I had a look at spi_of_notify() and indeed via
> spi_unregister_device()
> the node is put just before device_del() so I agree that at first
> glance
> it seems like there may be a race there against the useage here.
> Mark (+CC) out of interest why are the node gets before the
> device_add()
> in spi_add_device() called from of_register_spi_device() but the
> matching
> node puts before the device_del() in spi_unregister_device()?
> Seems like inconsistent ordering...
> 
> Which is not to say we shouldn't fix the IIO usage as this patch
> does!
> 

Just to add something that came to my attention. In the IIO case, it
does not even matter if the parent device has the OF node lifetime
"linked" to it (as it actually happens for platform devices). The
reason is that iio_dev only has a weak reference to it's parent and (I
think) the parent can actually go away while the iio_dev is still
around (eg: someone has an open fd to the iio_dev cdev).

> > 
> > Again, I might be wrong and I admit I was not sure about including
> > this
> > patch because it's a very unlikely scenario even though I think, in
> > theory, a possible one.
> 
> The patch is currently valid even if it's not a 'real' bug.
> Given we are doing a put on that device_node, it makes sense for that
> to occur after the local use has finished - we shouldn't be relying
> on
> what happens to be the case for lifetimes today.
> 
> Now, I did wonder if any drivers actually use it in their xlate
> callbacks.
> One does for an error print, so this is potentially real (if very
> unlikely!)
> 
> This isn't a 'fix' I'd expect to rush in, or necessarily backport to
> stable
> but I think it's a valid fix.
> 

Should I drop the fixes tag?

- Nuno Sá





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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-13  7:20           ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:20 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	moderated list:ARM/Mediatek SoC support, linux-stm32,
	linux-arm-msm, linux-iio, OpenBMC Maillist, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Fabrice Gasnier, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal, Mark Brown

On Sat, 2022-06-11 at 15:59 +0100, Jonathan Cameron wrote:
> 
> +Cc Mark Brown for a query on ordering in device tree based SPI
> setup.
> 
> On Fri, 10 Jun 2022 22:08:41 +0200
> Nuno Sá <noname.nuno@gmail.com> wrote:
> 
> > On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > wrote:  
> > > > 
> > > > 'of_node_put()' can potentially release the memory pointed to
> > > > by
> > > > 'iiospec.np' which would leave us with an invalid pointer (and
> > > > we
> > > > would
> > > > still pass it in 'of_xlate()'). As such, we can only release
> > > > the
> > > > node
> > > > after we are done with it.  
> > > 
> > > The question you should answer in the commit message is the
> > > following:
> > > "Can an OF node, attached to a struct device, be gone before the
> > > device itself?" If it so, then patch is good, otherwise there is
> > > no
> > > point in this patch in the first place.
> > >   
> > 
> > Yeah, I might be wrong but from a quick look... yes, I think the
> > node
> > can be gone before the device. Take a look on the spi or i2c
> > of_notify
> > handling and you can see that the nodes are get/put on the
> > add/remove
> > notifcation. Meaning that the node lifespan is not really attached
> > to
> > the device lifespan. If it was, I would expect to see of_node_put()
> > on
> > the device release() function...
> 
> I had a look at spi_of_notify() and indeed via
> spi_unregister_device()
> the node is put just before device_del() so I agree that at first
> glance
> it seems like there may be a race there against the useage here.
> Mark (+CC) out of interest why are the node gets before the
> device_add()
> in spi_add_device() called from of_register_spi_device() but the
> matching
> node puts before the device_del() in spi_unregister_device()?
> Seems like inconsistent ordering...
> 
> Which is not to say we shouldn't fix the IIO usage as this patch
> does!
> 

Just to add something that came to my attention. In the IIO case, it
does not even matter if the parent device has the OF node lifetime
"linked" to it (as it actually happens for platform devices). The
reason is that iio_dev only has a weak reference to it's parent and (I
think) the parent can actually go away while the iio_dev is still
around (eg: someone has an open fd to the iio_dev cdev).

> > 
> > Again, I might be wrong and I admit I was not sure about including
> > this
> > patch because it's a very unlikely scenario even though I think, in
> > theory, a possible one.
> 
> The patch is currently valid even if it's not a 'real' bug.
> Given we are doing a put on that device_node, it makes sense for that
> to occur after the local use has finished - we shouldn't be relying
> on
> what happens to be the case for lifetimes today.
> 
> Now, I did wonder if any drivers actually use it in their xlate
> callbacks.
> One does for an error print, so this is potentially real (if very
> unlikely!)
> 
> This isn't a 'fix' I'd expect to rush in, or necessarily backport to
> stable
> but I think it's a valid fix.
> 

Should I drop the fixes tag?

- Nuno Sá





_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-13  7:20           ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:20 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	OpenBMC Maillist, Jishnu Prakash, Haibo Chen, Andy Shevchenko,
	Andy Gross, dl-linux-imx, Olivier Moysan, Zhang Rui

On Sat, 2022-06-11 at 15:59 +0100, Jonathan Cameron wrote:
> 
> +Cc Mark Brown for a query on ordering in device tree based SPI
> setup.
> 
> On Fri, 10 Jun 2022 22:08:41 +0200
> Nuno Sá <noname.nuno@gmail.com> wrote:
> 
> > On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:
> > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > wrote:  
> > > > 
> > > > 'of_node_put()' can potentially release the memory pointed to
> > > > by
> > > > 'iiospec.np' which would leave us with an invalid pointer (and
> > > > we
> > > > would
> > > > still pass it in 'of_xlate()'). As such, we can only release
> > > > the
> > > > node
> > > > after we are done with it.  
> > > 
> > > The question you should answer in the commit message is the
> > > following:
> > > "Can an OF node, attached to a struct device, be gone before the
> > > device itself?" If it so, then patch is good, otherwise there is
> > > no
> > > point in this patch in the first place.
> > >   
> > 
> > Yeah, I might be wrong but from a quick look... yes, I think the
> > node
> > can be gone before the device. Take a look on the spi or i2c
> > of_notify
> > handling and you can see that the nodes are get/put on the
> > add/remove
> > notifcation. Meaning that the node lifespan is not really attached
> > to
> > the device lifespan. If it was, I would expect to see of_node_put()
> > on
> > the device release() function...
> 
> I had a look at spi_of_notify() and indeed via
> spi_unregister_device()
> the node is put just before device_del() so I agree that at first
> glance
> it seems like there may be a race there against the useage here.
> Mark (+CC) out of interest why are the node gets before the
> device_add()
> in spi_add_device() called from of_register_spi_device() but the
> matching
> node puts before the device_del() in spi_unregister_device()?
> Seems like inconsistent ordering...
> 
> Which is not to say we shouldn't fix the IIO usage as this patch
> does!
> 

Just to add something that came to my attention. In the IIO case, it
does not even matter if the parent device has the OF node lifetime
"linked" to it (as it actually happens for platform devices). The
reason is that iio_dev only has a weak reference to it's parent and (I
think) the parent can actually go away while the iio_dev is still
around (eg: someone has an open fd to the iio_dev cdev).

> > 
> > Again, I might be wrong and I admit I was not sure about including
> > this
> > patch because it's a very unlikely scenario even though I think, in
> > theory, a possible one.
> 
> The patch is currently valid even if it's not a 'real' bug.
> Given we are doing a put on that device_node, it makes sense for that
> to occur after the local use has finished - we shouldn't be relying
> on
> what happens to be the case for lifetimes today.
> 
> Now, I did wonder if any drivers actually use it in their xlate
> callbacks.
> One does for an error print, so this is potentially real (if very
> unlikely!)
> 
> This isn't a 'fix' I'd expect to rush in, or necessarily backport to
> stable
> but I think it's a valid fix.
> 

Should I drop the fixes tag?

- Nuno Sá





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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
  2022-06-12 17:39         ` Geert Uytterhoeven
  (?)
@ 2022-06-13  7:23           ` Nuno Sá
  -1 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:23 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joe Simmons-Talbott, Nuno Sá,
	NXP Linux Team, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	Linux ARM, chrome-platform, Lad Prabhakar, linux-mediatek,
	linux-stm32, linux-arm-msm, linux-iio, openbmc, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Sun, 2022-06-12 at 19:39 +0200, Geert Uytterhoeven wrote:
> Hi Nuno,
> 
> On Fri, Jun 10, 2022 at 9:52 PM Nuno Sá <noname.nuno@gmail.com>
> wrote:
> > On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> > > On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > > > Just cosmetics. No functional change intended...
> > > > 
> > > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> 
> > > > --- a/drivers/iio/inkern.c
> > > > +++ b/drivers/iio/inkern.c
> > > > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > > > *indio_dev, struct iio_map *maps)
> > > >         int i = 0, ret = 0;
> > > >         struct iio_map_internal *mapi;
> > > > 
> > > > -       if (maps == NULL)
> > > > +       if (!maps)
> > > >                 return 0;
> > > > 
> > > >         mutex_lock(&iio_map_list_lock);
> > > > -       while (maps[i].consumer_dev_name != NULL) {
> > > > +       while (!maps[i].consumer_dev_name) {
> > > 
> > > Shouldn't this be?:
> > > while (maps[i].consumer_dev_name) {
> > 
> > Ups... Nice catch! I was probably in bot mode already.
> 
> When making a change with no functional change intended, it is always
> a good idea to compare the generated assembler before/after.  I.e.
> 
>     make drivers/iio/inkern.s
>     mv drivers/iio/inkern.s drivers/iio/inkern.s.orig
>     [make your change]
>     make drivers/iio/inkern.s
>     diff -u drivers/iio/inkern.s{.orig,}
> 

Ah thx... That's indeed a good idea!

- Nuno Sá





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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-13  7:23           ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:23 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Joe Simmons-Talbott, Nuno Sá,
	NXP Linux Team, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	Linux ARM, chrome-platform, Lad Prabhakar, linux-mediatek,
	linux-stm32, linux-arm-msm, linux-iio, openbmc, Cai Huoqing,
	Benjamin Fair, Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Sun, 2022-06-12 at 19:39 +0200, Geert Uytterhoeven wrote:
> Hi Nuno,
> 
> On Fri, Jun 10, 2022 at 9:52 PM Nuno Sá <noname.nuno@gmail.com>
> wrote:
> > On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> > > On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > > > Just cosmetics. No functional change intended...
> > > > 
> > > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> 
> > > > --- a/drivers/iio/inkern.c
> > > > +++ b/drivers/iio/inkern.c
> > > > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > > > *indio_dev, struct iio_map *maps)
> > > >         int i = 0, ret = 0;
> > > >         struct iio_map_internal *mapi;
> > > > 
> > > > -       if (maps == NULL)
> > > > +       if (!maps)
> > > >                 return 0;
> > > > 
> > > >         mutex_lock(&iio_map_list_lock);
> > > > -       while (maps[i].consumer_dev_name != NULL) {
> > > > +       while (!maps[i].consumer_dev_name) {
> > > 
> > > Shouldn't this be?:
> > > while (maps[i].consumer_dev_name) {
> > 
> > Ups... Nice catch! I was probably in bot mode already.
> 
> When making a change with no functional change intended, it is always
> a good idea to compare the generated assembler before/after.  I.e.
> 
>     make drivers/iio/inkern.s
>     mv drivers/iio/inkern.s drivers/iio/inkern.s.orig
>     [make your change]
>     make drivers/iio/inkern.s
>     diff -u drivers/iio/inkern.s{.orig,}
> 

Ah thx... That's indeed a good idea!

- Nuno Sá





_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

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

* Re: [PATCH 34/34] iio: inkern: fix coding style warnings
@ 2022-06-13  7:23           ` Nuno Sá
  0 siblings, 0 replies; 246+ messages in thread
From: Nuno Sá @ 2022-06-13  7:23 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	openbmc, Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	NXP Linux Team, Olivier Moysan, Zhang Rui,
	Christophe Brancher eau, Bjorn Andersson, Tali Perry,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Joe Simmons-Talbott, Benson Leung, Pengutronix Kernel Team,
	Linux ARM, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	open list:BROADCOM NVRAM DRIVER, Thara Gopinath, Linux-Renesas

g>, Arnd Bergmann <arnd@arndb.de>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Cai Huoqing <cai.huoqing@linux.dev>, Shawn Guo <shawnguo@kernel.org>, Claudiu Beznea <claudiu.beznea@microchip.com>, Jonathan Cameron <jic23@kernel.org>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Sun, 2022-06-12 at 19:39 +0200, Geert Uytterhoeven wrote:
> Hi Nuno,
> 
> On Fri, Jun 10, 2022 at 9:52 PM Nuno Sá <noname.nuno@gmail.com>
> wrote:
> > On Fri, 2022-06-10 at 11:53 -0400, Joe Simmons-Talbott wrote:
> > > On Fri, Jun 10, 2022 at 10:45:45AM +0200, Nuno Sá wrote:
> > > > Just cosmetics. No functional change intended...
> > > > 
> > > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> 
> > > > --- a/drivers/iio/inkern.c
> > > > +++ b/drivers/iio/inkern.c
> > > > @@ -45,13 +45,13 @@ int iio_map_array_register(struct iio_dev
> > > > *indio_dev, struct iio_map *maps)
> > > >         int i = 0, ret = 0;
> > > >         struct iio_map_internal *mapi;
> > > > 
> > > > -       if (maps == NULL)
> > > > +       if (!maps)
> > > >                 return 0;
> > > > 
> > > >         mutex_lock(&iio_map_list_lock);
> > > > -       while (maps[i].consumer_dev_name != NULL) {
> > > > +       while (!maps[i].consumer_dev_name) {
> > > 
> > > Shouldn't this be?:
> > > while (maps[i].consumer_dev_name) {
> > 
> > Ups... Nice catch! I was probably in bot mode already.
> 
> When making a change with no functional change intended, it is always
> a good idea to compare the generated assembler before/after.  I.e.
> 
>     make drivers/iio/inkern.s
>     mv drivers/iio/inkern.s drivers/iio/inkern.s.orig
>     [make your change]
>     make drivers/iio/inkern.s
>     diff -u drivers/iio/inkern.s{.orig,}
> 

Ah thx... That's indeed a good idea!

- Nuno Sá





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

* Re: [PATCH 27/34] iio: adc: ab8500-gpadc: convert to device properties
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-15 14:26     ` Linus Walleij
  -1 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-15 14:26 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Lars-Peter Clausen, Alexandre Torgue,
	Amit Kucheria, Andy Gross, Michael Hennerich, Haibo Chen,
	Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 27/34] iio: adc: ab8500-gpadc: convert to device properties
@ 2022-06-15 14:26     ` Linus Walleij
  0 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-15 14:26 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Amit Kucheria, Alexandre Torgue,
	Tali Perry, Paul Cercueil, Miquel Raynal, Guenter Roeck,
	Fabio Estevam, linux-stm32, chrome-platform, Lars-Peter Clausen,
	Benjamin Fair, openbmc, Jishnu Prakash, Haibo Chen,
	Andy Shevchenko, Andy Gross, linux-imx, Olivier Moysan,
	Zhang Rui, Christophe Branchereau, Saravanan Sekar,
	Mi chael Hennerich, linux-arm-msm, Sascha Hauer, Nicolas Ferre,
	Lad Prabhakar, Fabrice Gasnier, linux-mediatek, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm-kernel, Lorenzo Bianconi,
	Avi Fishman, Patrick Venture, linux-mips, Thara Gopinath,
	linux-renesas-soc, Arnd Bergmann, Maxime Coquelin, Cai Huoqing,
	Shawn Guo, Claudiu Beznea

On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 29/34] iio: adc: qcom-pm8xxx-xoadc: convert to device properties
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-15 14:27     ` Linus Walleij
  -1 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-15 14:27 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Lars-Peter Clausen, Alexandre Torgue,
	Amit Kucheria, Andy Gross, Michael Hennerich, Haibo Chen,
	Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:49 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 29/34] iio: adc: qcom-pm8xxx-xoadc: convert to device properties
@ 2022-06-15 14:27     ` Linus Walleij
  0 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-15 14:27 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Amit Kucheria, Alexandre Torgue,
	Tali Perry, Paul Cercueil, Miquel Raynal, Guenter Roeck,
	Fabio Estevam, linux-stm32, chrome-platform, Lars-Peter Clausen,
	Benjamin Fair, openbmc, Jishnu Prakash, Haibo Chen,
	Andy Shevchenko, Andy Gross, linux-imx, Olivier Moysan,
	Zhang Rui, Christophe Branchereau, Saravanan Sekar,
	Mi chael Hennerich, linux-arm-msm, Sascha Hauer, Nicolas Ferre,
	Lad Prabhakar, Fabrice Gasnier, linux-mediatek, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm-kernel, Lorenzo Bianconi,
	Avi Fishman, Patrick Venture, linux-mips, Thara Gopinath,
	linux-renesas-soc, Arnd Bergmann, Maxime Coquelin, Cai Huoqing,
	Shawn Guo, Claudiu Beznea

On Fri, Jun 10, 2022 at 10:49 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 30/34] iio: adc: qcom-spmi-vadc: convert to device properties
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-16 13:15     ` Linus Walleij
  -1 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-16 13:15 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Lars-Peter Clausen, Alexandre Torgue,
	Amit Kucheria, Andy Gross, Michael Hennerich, Haibo Chen,
	Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:49 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 30/34] iio: adc: qcom-spmi-vadc: convert to device properties
@ 2022-06-16 13:15     ` Linus Walleij
  0 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-16 13:15 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Amit Kucheria, Alexandre Torgue,
	Tali Perry, Paul Cercueil, Miquel Raynal, Guenter Roeck,
	Fabio Estevam, linux-stm32, chrome-platform, Lars-Peter Clausen,
	Benjamin Fair, openbmc, Jishnu Prakash, Haibo Chen,
	Andy Shevchenko, Andy Gross, linux-imx, Olivier Moysan,
	Zhang Rui, Christophe Branchereau, Saravanan Sekar,
	Mi chael Hennerich, linux-arm-msm, Sascha Hauer, Nicolas Ferre,
	Lad Prabhakar, Fabrice Gasnier, linux-mediatek, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm-kernel, Lorenzo Bianconi,
	Avi Fishman, Patrick Venture, linux-mips, Thara Gopinath,
	linux-renesas-soc, Arnd Bergmann, Maxime Coquelin, Cai Huoqing,
	Shawn Guo, Claudiu Beznea

On Fri, Jun 10, 2022 at 10:49 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 31/34] iio: adc: qcom-spmi-adc5: convert to device properties
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-16 13:16     ` Linus Walleij
  -1 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-16 13:16 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Lars-Peter Clausen, Alexandre Torgue,
	Amit Kucheria, Andy Gross, Michael Hennerich, Haibo Chen,
	Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Jonathan Cameron, Zhang Rui, Shawn Guo, Guenter Roeck,
	Fabio Estevam, Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, Jun 10, 2022 at 10:49 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 31/34] iio: adc: qcom-spmi-adc5: convert to device properties
@ 2022-06-16 13:16     ` Linus Walleij
  0 siblings, 0 replies; 246+ messages in thread
From: Linus Walleij @ 2022-06-16 13:16 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Amit Kucheria, Alexandre Torgue,
	Tali Perry, Paul Cercueil, Miquel Raynal, Guenter Roeck,
	Fabio Estevam, linux-stm32, chrome-platform, Lars-Peter Clausen,
	Benjamin Fair, openbmc, Jishnu Prakash, Haibo Chen,
	Andy Shevchenko, Andy Gross, linux-imx, Olivier Moysan,
	Zhang Rui, Christophe Branchereau, Saravanan Sekar,
	Mi chael Hennerich, linux-arm-msm, Sascha Hauer, Nicolas Ferre,
	Lad Prabhakar, Fabrice Gasnier, linux-mediatek, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm-kernel, Lorenzo Bianconi,
	Avi Fishman, Patrick Venture, linux-mips, Thara Gopinath,
	linux-renesas-soc, Arnd Bergmann, Maxime Coquelin, Cai Huoqing,
	Shawn Guo, Claudiu Beznea

On Fri, Jun 10, 2022 at 10:49 AM Nuno Sá <nuno.sa@analog.com> wrote:

> Make the conversion to firmware agnostic device properties. As part of
> the conversion the IIO inkern interface 'of_xlate()' is also converted to
> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
> dependencies from IIO.
>
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij

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

* Re: [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
  2022-06-11 15:47     ` Jonathan Cameron
@ 2022-06-17 15:58       ` Fabrice Gasnier
  -1 siblings, 0 replies; 246+ messages in thread
From: Fabrice Gasnier @ 2022-06-17 15:58 UTC (permalink / raw)
  To: Jonathan Cameron, Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Matthias Brugger,
	Tomer Maimon, Bjorn Andersson, Nicolas Ferre, Zhang Rui,
	Shawn Guo, Guenter Roeck, Fabio Estevam, Olivier Moysan,
	Eugen Hristev, Miquel Raynal

On 6/11/22 17:47, Jonathan Cameron wrote:
> On Fri, 10 Jun 2022 10:45:43 +0200
> Nuno Sá <nuno.sa@analog.com> wrote:
> 
>> Make the conversion to firmware agnostic device properties. As part of
>> the conversion the IIO inkern interface 'of_xlate()' is also converted to
>> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
>> dependencies from IIO.
>>
>> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> 
> One trivial comment inline. 
> 
> In general this particular refactor is complex, so I either want
> eyes of those familiar with the driver and / or testing or we may want
> to reduce the scope to just the fwnode_xlate() and leave the more
> complex conversions for when we can get that testing done.
> 
> Let's see if we get the necessary review on this more complex patch.
> I just don't want us to get stalled by trying to do too much at once!
> 
> Jonathan
> 
> 
>> ---
>>  drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
>>  1 file changed, 70 insertions(+), 58 deletions(-)
>>
>> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
>> index a68ecbda6480..87acef31ace1 100644
>> --- a/drivers/iio/adc/stm32-adc.c
>> +++ b/drivers/iio/adc/stm32-adc.c
>> @@ -21,11 +21,11 @@
>>  #include <linux/io.h>
>>  #include <linux/iopoll.h>
>>  #include <linux/module.h>
>> +#include <linux/mod_devicetable.h>
>>  #include <linux/nvmem-consumer.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/pm_runtime.h>
>> -#include <linux/of.h>
>> -#include <linux/of_device.h>
>> +#include <linux/property.h>
>>  
>>  #include "stm32-adc-core.h"
>>  
>> @@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
>>  	return ret;
>>  }
>>  
>> -static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
>> -			      const struct of_phandle_args *iiospec)
>> +static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
>> +				  const struct fwnode_reference_args *iiospec)
>>  {
>>  	int i;
>>  
>> @@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
>>  	.hwfifo_set_watermark = stm32_adc_set_watermark,
>>  	.update_scan_mode = stm32_adc_update_scan_mode,
>>  	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
>> -	.of_xlate = stm32_adc_of_xlate,
>> +	.fwnode_xlate = stm32_adc_fwnode_xlate,
>>  };
>>  
>>  static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
>> @@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
>>  	{},
>>  };
>>  
>> -static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
>> +static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>> +	struct device *dev = &indio_dev->dev;
>>  	struct stm32_adc *adc = iio_priv(indio_dev);
>>  	unsigned int i;
>>  	u32 res;
>>  
>> -	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
>> +	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
>>  		res = adc->cfg->adc_info->resolutions[0];
>>  
>>  	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
>> @@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
>>  
>>  static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>> +	struct device *dev = &indio_dev->dev;
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>>  	int num_channels = 0, ret;
>>  
>> -	ret = of_property_count_u32_elems(node, "st,adc-channels");
>> +	ret = device_property_count_u32(dev, "st,adc-channels");
>>  	if (ret > adc_info->max_channels) {
>>  		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
>>  		return -EINVAL;
>> @@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>>  		num_channels += ret;
>>  	}
>>  
>> -	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
>> -					      sizeof(struct stm32_adc_diff_channel));
>> -	if (ret > adc_info->max_channels) {
>> +	ret = device_property_count_u32(dev, "st,adc-diff-channels");
>> +	if ((ret / 2) > adc_info->max_channels) {
> hmm. The magic '2' that is introduced here kind of looses some of the meaning
> that existed for the *_count_elems_of_size()
> 
> Perhaps introduce a define or a comment on why it is 2?

Hi Nuno,

Thanks for your patch, please find some remarks below.

First, I agree with Jonathan here. (Just suggesting) Would it be
possible to keep a reference to the target struct to ease long term
maintenance ? I'm thinking of:
sizeof(struct stm32_adc_diff_channel) / sizeof(u32).
Or possibly a better approach...

> 
>>  		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
>>  		return -EINVAL;
>> -	} else if (ret > 0) {
>> -		adc->num_diff = ret;
>> -		num_channels += ret;
>> +	} else if ((ret / 2) > 0) {
>> +		adc->num_diff = ret / 2;
>> +		num_channels += ret / 2;
>>  	}
>>  
>>  	/* Optional sample time is provided either for each, or all channels */
>> -	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
>> +	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
>>  	if (ret > 1 && ret != num_channels) {
>>  		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
>>  		return -EINVAL;
>> @@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>>  
>>  static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>>  				      struct stm32_adc *adc,
>> -				      struct iio_chan_spec *channels)
>> +				      struct iio_chan_spec *channels,
>> +				      int nchans)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>>  	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
>> +	struct device *dev = &indio_dev->dev;
>>  	u32 num_diff = adc->num_diff;
>>  	int size = num_diff * sizeof(*diff) / sizeof(u32);
>> -	int scan_index = 0, val, ret, i;
>> -	struct property *prop;
>> -	const __be32 *cur;
>> -	u32 smp = 0;
>> +	int scan_index = 0, ret, i;
>> +	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
>>  
>>  	if (num_diff) {
>> -		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
>> -						 (u32 *)diff, size);
>> +		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
>> +						     (u32 *)diff, size);
>>  		if (ret) {
>>  			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
>>  			return ret;
>> @@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>>  		}
>>  	}
>>  
>> -	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
>> -		if (val >= adc_info->max_channels) {
>> -			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
>> +	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
>> +					     nchans);
>> +	if (ret)
>> +		return ret;
>> +
>> +	for (i = 0; i < nchans; i++) {

Shouldn't use 'i' variable as is.

I tested at my end. There's a bug around here, as the same variable 'i'
is used already in next for loop. It creates an endless loop, that ends
up in incrementing scan_index indefinitely until some oops occurs.

I fixed that locally for quick testing by using another variable.

Isn't there a helper to achive this (e.g. like of_property_for_each_u32) ?

>> +		if (chans[i] >= adc_info->max_channels) {
>> +			dev_err(&indio_dev->dev, "Invalid channel %d\n",
>> +				chans[i]);
>>  			return -EINVAL;
>>  		}
>>  
>>  		/* Channel can't be configured both as single-ended & diff */
>>  		for (i = 0; i < num_diff; i++) {
>> -			if (val == diff[i].vinp) {
>> -				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
>> +			if (chans[i] == diff[i].vinp) {
>> +				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
>>  				return -EINVAL;
>>  			}
>>  		}
>> -		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
>> -					0, scan_index, false);
>> +		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
>> +					chans[i], 0, scan_index, false);
>>  		scan_index++;
>>  	}
>>  
>> +	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
>> +	if (nsmps) {
>> +		if (nsmps >= nchans)

nit: if (nsmps > nchans)

>> +			nsmps = nchans;

There's a bit of redundancy in checking nsmps,
"st,min-sample-time-nsecs" is already sanitized in
stm32_adc_get_legacy_chan_count():

/* Optional sample time is provided either for each, or all channels */
ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
if (ret > 1 && ret != num_channels) {
	dev_err(...

So just sharing my thoughts here:
- Maybe this could be dropped ?
  (Thinking loudly) The earliest this gets sanitized, the less un-needed
initialisations happen before failing?
- Or the earlier check could be moved here ?

I've no strong opinion.

>> +
>> +		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
>> +						     smps, nsmps);
>> +		if (ret)
>> +			return ret;
>> +	}
>> +
>>  	for (i = 0; i < scan_index; i++) {
>>  		/*
>> -		 * Using of_property_read_u32_index(), smp value will only be
>> -		 * modified if valid u32 value can be decoded. This allows to
>> -		 * get either no value, 1 shared value for all indexes, or one
>> -		 * value per channel.
>> +		 * This check is used with the above logic so that smp value
>> +		 * will only be modified if valid u32 value can be decoded. This
>> +		 * allows to get either no value, 1 shared value for all indexes,
>> +		 * or one value per channel. The point is to have the same
>> +		 * behavior as 'of_property_read_u32_index()'.
>>  		 */
>> -		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
>> +		if (i < nsmps)
>> +			smp = smps[i];

Minor remark, I'm wondering if using a switch (nsmps) {.. case} or
similar would help to improve understandabilty / readability ?

Best Regards,
Fabrice

>>  
>>  		/* Prepare sampling time settings */
>>  		stm32_adc_smpr_init(adc, channels[i].channel, smp);
>> @@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  				       struct stm32_adc *adc,
>>  				       struct iio_chan_spec *channels)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>> -	struct device_node *child;
>> +	struct fwnode_handle *child;
>>  	const char *name;
>>  	int val, scan_index = 0, ret;
>>  	bool differential;
>>  	u32 vin[2];
>>  
>> -	for_each_available_child_of_node(node, child) {
>> -		ret = of_property_read_u32(child, "reg", &val);
>> +	device_for_each_child_node(&indio_dev->dev, child) {
>> +		ret = fwnode_property_read_u32(child, "reg", &val);
>>  		if (ret) {
>>  			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
>>  			goto err;
>>  		}
>>  
>> -		ret = of_property_read_string(child, "label", &name);
>> +		ret = fwnode_property_read_string(child, "label", &name);
>>  		/* label is optional */
>>  		if (!ret) {
>>  			if (strlen(name) >= STM32_ADC_CH_SZ) {
>> @@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  		}
>>  
>>  		differential = false;
>> -		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
>> +		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
>>  		/* diff-channels is optional */
>>  		if (!ret) {
>>  			differential = true;
>> @@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
>>  					vin[1], scan_index, differential);
>>  
>> -		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
>> +		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
>>  		/* st,min-sample-time-ns is optional */
>>  		if (!ret) {
>>  			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
>> @@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  	return scan_index;
>>  
>>  err:
>> -	of_node_put(child);
>> +	fwnode_handle_put(child);
>>  
>>  	return ret;
>>  }
>>  
>> -static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>> +static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>>  	struct stm32_adc *adc = iio_priv(indio_dev);
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>>  	struct iio_chan_spec *channels;
>> @@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>>  	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
>>  		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
>>  
>> -	num_channels = of_get_available_child_count(node);
>> +	num_channels = device_get_child_node_count(&indio_dev->dev);
>>  	/* If no channels have been found, fallback to channels legacy properties. */
>>  	if (!num_channels) {
>>  		legacy = true;
>> @@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>>  		return -ENOMEM;
>>  
>>  	if (legacy)
>> -		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
>> +		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
>> +						 num_channels);
>>  	else
>>  		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
>>  	if (ret < 0)
>> @@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  	bool timestamping = false;
>>  	int ret;
>>  
>> -	if (!pdev->dev.of_node)
>> -		return -ENODEV;
>> -
>>  	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
>>  	if (!indio_dev)
>>  		return -ENOMEM;
>> @@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  	adc->common = dev_get_drvdata(pdev->dev.parent);
>>  	spin_lock_init(&adc->lock);
>>  	init_completion(&adc->completion);
>> -	adc->cfg = (const struct stm32_adc_cfg *)
>> -		of_match_device(dev->driver->of_match_table, dev)->data;
>> +	adc->cfg = device_get_match_data(dev);
>>  
>>  	indio_dev->name = dev_name(&pdev->dev);
>> -	indio_dev->dev.of_node = pdev->dev.of_node;
>> +	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
>>  	indio_dev->info = &stm32_adc_iio_info;
>>  	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
>>  
>>  	platform_set_drvdata(pdev, indio_dev);
>>  
>> -	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
>> +	ret = device_property_read_u32(dev, "reg", &adc->offset);
>>  	if (ret != 0) {
>>  		dev_err(&pdev->dev, "missing reg property\n");
>>  		return -EINVAL;
>> @@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  		}
>>  	}
>>  
>> -	ret = stm32_adc_of_get_resolution(indio_dev);
>> +	ret = stm32_adc_fw_get_resolution(indio_dev);
>>  	if (ret < 0)
>>  		return ret;
>>  
>> @@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  		timestamping = true;
>>  	}
>>  
>> -	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
>> +	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
>>  	if (ret < 0)
>>  		goto err_dma_disable;
>>  
> 

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

* Re: [PATCH 32/34] iio: adc: stm32-adc: convert to device properties
@ 2022-06-17 15:58       ` Fabrice Gasnier
  0 siblings, 0 replies; 246+ messages in thread
From: Fabrice Gasnier @ 2022-06-17 15:58 UTC (permalink / raw)
  To: Jonathan Cameron, Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, linux-mediatek, Eugen Hristev,
	Matthias Brugger, Gwendal Grignou, Bjorn Andersson, Benson Leung,
	Pengutronix Kernel Team, linux-arm-kernel, Lorenzo Bianconi,
	Avi Fishman, Patrick Venture, linux-mips, Thara Gopinath,
	linux-renesas-soc, Arnd Bergmann, Maxime Coquelin, Cai Huoqing,
	Shawn Guo, Claudiu Beznea

On 6/11/22 17:47, Jonathan Cameron wrote:
> On Fri, 10 Jun 2022 10:45:43 +0200
> Nuno Sá <nuno.sa@analog.com> wrote:
> 
>> Make the conversion to firmware agnostic device properties. As part of
>> the conversion the IIO inkern interface 'of_xlate()' is also converted to
>> 'fwnode_xlate()'. The goal is to completely drop 'of_xlate' and hence OF
>> dependencies from IIO.
>>
>> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> 
> One trivial comment inline. 
> 
> In general this particular refactor is complex, so I either want
> eyes of those familiar with the driver and / or testing or we may want
> to reduce the scope to just the fwnode_xlate() and leave the more
> complex conversions for when we can get that testing done.
> 
> Let's see if we get the necessary review on this more complex patch.
> I just don't want us to get stalled by trying to do too much at once!
> 
> Jonathan
> 
> 
>> ---
>>  drivers/iio/adc/stm32-adc.c | 128 ++++++++++++++++++++----------------
>>  1 file changed, 70 insertions(+), 58 deletions(-)
>>
>> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
>> index a68ecbda6480..87acef31ace1 100644
>> --- a/drivers/iio/adc/stm32-adc.c
>> +++ b/drivers/iio/adc/stm32-adc.c
>> @@ -21,11 +21,11 @@
>>  #include <linux/io.h>
>>  #include <linux/iopoll.h>
>>  #include <linux/module.h>
>> +#include <linux/mod_devicetable.h>
>>  #include <linux/nvmem-consumer.h>
>>  #include <linux/platform_device.h>
>>  #include <linux/pm_runtime.h>
>> -#include <linux/of.h>
>> -#include <linux/of_device.h>
>> +#include <linux/property.h>
>>  
>>  #include "stm32-adc-core.h"
>>  
>> @@ -1524,8 +1524,8 @@ static int stm32_adc_update_scan_mode(struct iio_dev *indio_dev,
>>  	return ret;
>>  }
>>  
>> -static int stm32_adc_of_xlate(struct iio_dev *indio_dev,
>> -			      const struct of_phandle_args *iiospec)
>> +static int stm32_adc_fwnode_xlate(struct iio_dev *indio_dev,
>> +				  const struct fwnode_reference_args *iiospec)
>>  {
>>  	int i;
>>  
>> @@ -1579,7 +1579,7 @@ static const struct iio_info stm32_adc_iio_info = {
>>  	.hwfifo_set_watermark = stm32_adc_set_watermark,
>>  	.update_scan_mode = stm32_adc_update_scan_mode,
>>  	.debugfs_reg_access = stm32_adc_debugfs_reg_access,
>> -	.of_xlate = stm32_adc_of_xlate,
>> +	.fwnode_xlate = stm32_adc_fwnode_xlate,
>>  };
>>  
>>  static unsigned int stm32_adc_dma_residue(struct stm32_adc *adc)
>> @@ -1776,14 +1776,14 @@ static const struct iio_chan_spec_ext_info stm32_adc_ext_info[] = {
>>  	{},
>>  };
>>  
>> -static int stm32_adc_of_get_resolution(struct iio_dev *indio_dev)
>> +static int stm32_adc_fw_get_resolution(struct iio_dev *indio_dev)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>> +	struct device *dev = &indio_dev->dev;
>>  	struct stm32_adc *adc = iio_priv(indio_dev);
>>  	unsigned int i;
>>  	u32 res;
>>  
>> -	if (of_property_read_u32(node, "assigned-resolution-bits", &res))
>> +	if (device_property_read_u32(dev, "assigned-resolution-bits", &res))
>>  		res = adc->cfg->adc_info->resolutions[0];
>>  
>>  	for (i = 0; i < adc->cfg->adc_info->num_res; i++)
>> @@ -1867,11 +1867,11 @@ static void stm32_adc_chan_init_one(struct iio_dev *indio_dev,
>>  
>>  static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm32_adc *adc)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>> +	struct device *dev = &indio_dev->dev;
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>>  	int num_channels = 0, ret;
>>  
>> -	ret = of_property_count_u32_elems(node, "st,adc-channels");
>> +	ret = device_property_count_u32(dev, "st,adc-channels");
>>  	if (ret > adc_info->max_channels) {
>>  		dev_err(&indio_dev->dev, "Bad st,adc-channels?\n");
>>  		return -EINVAL;
>> @@ -1879,18 +1879,17 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>>  		num_channels += ret;
>>  	}
>>  
>> -	ret = of_property_count_elems_of_size(node, "st,adc-diff-channels",
>> -					      sizeof(struct stm32_adc_diff_channel));
>> -	if (ret > adc_info->max_channels) {
>> +	ret = device_property_count_u32(dev, "st,adc-diff-channels");
>> +	if ((ret / 2) > adc_info->max_channels) {
> hmm. The magic '2' that is introduced here kind of looses some of the meaning
> that existed for the *_count_elems_of_size()
> 
> Perhaps introduce a define or a comment on why it is 2?

Hi Nuno,

Thanks for your patch, please find some remarks below.

First, I agree with Jonathan here. (Just suggesting) Would it be
possible to keep a reference to the target struct to ease long term
maintenance ? I'm thinking of:
sizeof(struct stm32_adc_diff_channel) / sizeof(u32).
Or possibly a better approach...

> 
>>  		dev_err(&indio_dev->dev, "Bad st,adc-diff-channels?\n");
>>  		return -EINVAL;
>> -	} else if (ret > 0) {
>> -		adc->num_diff = ret;
>> -		num_channels += ret;
>> +	} else if ((ret / 2) > 0) {
>> +		adc->num_diff = ret / 2;
>> +		num_channels += ret / 2;
>>  	}
>>  
>>  	/* Optional sample time is provided either for each, or all channels */
>> -	ret = of_property_count_u32_elems(node, "st,min-sample-time-nsecs");
>> +	ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
>>  	if (ret > 1 && ret != num_channels) {
>>  		dev_err(&indio_dev->dev, "Invalid st,min-sample-time-nsecs\n");
>>  		return -EINVAL;
>> @@ -1901,21 +1900,20 @@ static int stm32_adc_get_legacy_chan_count(struct iio_dev *indio_dev, struct stm
>>  
>>  static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>>  				      struct stm32_adc *adc,
>> -				      struct iio_chan_spec *channels)
>> +				      struct iio_chan_spec *channels,
>> +				      int nchans)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>>  	struct stm32_adc_diff_channel diff[STM32_ADC_CH_MAX];
>> +	struct device *dev = &indio_dev->dev;
>>  	u32 num_diff = adc->num_diff;
>>  	int size = num_diff * sizeof(*diff) / sizeof(u32);
>> -	int scan_index = 0, val, ret, i;
>> -	struct property *prop;
>> -	const __be32 *cur;
>> -	u32 smp = 0;
>> +	int scan_index = 0, ret, i;
>> +	u32 smp = 0, nsmps, smps[STM32_ADC_CH_MAX], chans[STM32_ADC_CH_MAX];
>>  
>>  	if (num_diff) {
>> -		ret = of_property_read_u32_array(node, "st,adc-diff-channels",
>> -						 (u32 *)diff, size);
>> +		ret = device_property_read_u32_array(dev, "st,adc-diff-channels",
>> +						     (u32 *)diff, size);
>>  		if (ret) {
>>  			dev_err(&indio_dev->dev, "Failed to get diff channels %d\n", ret);
>>  			return ret;
>> @@ -1936,32 +1934,51 @@ static int stm32_adc_legacy_chan_init(struct iio_dev *indio_dev,
>>  		}
>>  	}
>>  
>> -	of_property_for_each_u32(node, "st,adc-channels", prop, cur, val) {
>> -		if (val >= adc_info->max_channels) {
>> -			dev_err(&indio_dev->dev, "Invalid channel %d\n", val);
>> +	ret = device_property_read_u32_array(dev, "st,adc-channels", chans,
>> +					     nchans);
>> +	if (ret)
>> +		return ret;
>> +
>> +	for (i = 0; i < nchans; i++) {

Shouldn't use 'i' variable as is.

I tested at my end. There's a bug around here, as the same variable 'i'
is used already in next for loop. It creates an endless loop, that ends
up in incrementing scan_index indefinitely until some oops occurs.

I fixed that locally for quick testing by using another variable.

Isn't there a helper to achive this (e.g. like of_property_for_each_u32) ?

>> +		if (chans[i] >= adc_info->max_channels) {
>> +			dev_err(&indio_dev->dev, "Invalid channel %d\n",
>> +				chans[i]);
>>  			return -EINVAL;
>>  		}
>>  
>>  		/* Channel can't be configured both as single-ended & diff */
>>  		for (i = 0; i < num_diff; i++) {
>> -			if (val == diff[i].vinp) {
>> -				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	val);
>> +			if (chans[i] == diff[i].vinp) {
>> +				dev_err(&indio_dev->dev, "channel %d misconfigured\n",	chans[i]);
>>  				return -EINVAL;
>>  			}
>>  		}
>> -		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
>> -					0, scan_index, false);
>> +		stm32_adc_chan_init_one(indio_dev, &channels[scan_index],
>> +					chans[i], 0, scan_index, false);
>>  		scan_index++;
>>  	}
>>  
>> +	nsmps = device_property_count_u32(dev, "st,min-sample-time-nsecs");
>> +	if (nsmps) {
>> +		if (nsmps >= nchans)

nit: if (nsmps > nchans)

>> +			nsmps = nchans;

There's a bit of redundancy in checking nsmps,
"st,min-sample-time-nsecs" is already sanitized in
stm32_adc_get_legacy_chan_count():

/* Optional sample time is provided either for each, or all channels */
ret = device_property_count_u32(dev, "st,min-sample-time-nsecs");
if (ret > 1 && ret != num_channels) {
	dev_err(...

So just sharing my thoughts here:
- Maybe this could be dropped ?
  (Thinking loudly) The earliest this gets sanitized, the less un-needed
initialisations happen before failing?
- Or the earlier check could be moved here ?

I've no strong opinion.

>> +
>> +		ret = device_property_read_u32_array(dev, "st,min-sample-time-nsecs",
>> +						     smps, nsmps);
>> +		if (ret)
>> +			return ret;
>> +	}
>> +
>>  	for (i = 0; i < scan_index; i++) {
>>  		/*
>> -		 * Using of_property_read_u32_index(), smp value will only be
>> -		 * modified if valid u32 value can be decoded. This allows to
>> -		 * get either no value, 1 shared value for all indexes, or one
>> -		 * value per channel.
>> +		 * This check is used with the above logic so that smp value
>> +		 * will only be modified if valid u32 value can be decoded. This
>> +		 * allows to get either no value, 1 shared value for all indexes,
>> +		 * or one value per channel. The point is to have the same
>> +		 * behavior as 'of_property_read_u32_index()'.
>>  		 */
>> -		of_property_read_u32_index(node, "st,min-sample-time-nsecs", i, &smp);
>> +		if (i < nsmps)
>> +			smp = smps[i];

Minor remark, I'm wondering if using a switch (nsmps) {.. case} or
similar would help to improve understandabilty / readability ?

Best Regards,
Fabrice

>>  
>>  		/* Prepare sampling time settings */
>>  		stm32_adc_smpr_init(adc, channels[i].channel, smp);
>> @@ -2004,22 +2021,21 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  				       struct stm32_adc *adc,
>>  				       struct iio_chan_spec *channels)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>> -	struct device_node *child;
>> +	struct fwnode_handle *child;
>>  	const char *name;
>>  	int val, scan_index = 0, ret;
>>  	bool differential;
>>  	u32 vin[2];
>>  
>> -	for_each_available_child_of_node(node, child) {
>> -		ret = of_property_read_u32(child, "reg", &val);
>> +	device_for_each_child_node(&indio_dev->dev, child) {
>> +		ret = fwnode_property_read_u32(child, "reg", &val);
>>  		if (ret) {
>>  			dev_err(&indio_dev->dev, "Missing channel index %d\n", ret);
>>  			goto err;
>>  		}
>>  
>> -		ret = of_property_read_string(child, "label", &name);
>> +		ret = fwnode_property_read_string(child, "label", &name);
>>  		/* label is optional */
>>  		if (!ret) {
>>  			if (strlen(name) >= STM32_ADC_CH_SZ) {
>> @@ -2044,7 +2060,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  		}
>>  
>>  		differential = false;
>> -		ret = of_property_read_u32_array(child, "diff-channels", vin, 2);
>> +		ret = fwnode_property_read_u32_array(child, "diff-channels", vin, 2);
>>  		/* diff-channels is optional */
>>  		if (!ret) {
>>  			differential = true;
>> @@ -2061,7 +2077,7 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  		stm32_adc_chan_init_one(indio_dev, &channels[scan_index], val,
>>  					vin[1], scan_index, differential);
>>  
>> -		ret = of_property_read_u32(child, "st,min-sample-time-ns", &val);
>> +		ret = fwnode_property_read_u32(child, "st,min-sample-time-ns", &val);
>>  		/* st,min-sample-time-ns is optional */
>>  		if (!ret) {
>>  			stm32_adc_smpr_init(adc, channels[scan_index].channel, val);
>> @@ -2079,14 +2095,13 @@ static int stm32_adc_generic_chan_init(struct iio_dev *indio_dev,
>>  	return scan_index;
>>  
>>  err:
>> -	of_node_put(child);
>> +	fwnode_handle_put(child);
>>  
>>  	return ret;
>>  }
>>  
>> -static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>> +static int stm32_adc_chan_fw_init(struct iio_dev *indio_dev, bool timestamping)
>>  {
>> -	struct device_node *node = indio_dev->dev.of_node;
>>  	struct stm32_adc *adc = iio_priv(indio_dev);
>>  	const struct stm32_adc_info *adc_info = adc->cfg->adc_info;
>>  	struct iio_chan_spec *channels;
>> @@ -2096,7 +2111,7 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>>  	for (i = 0; i < STM32_ADC_INT_CH_NB; i++)
>>  		adc->int_ch[i] = STM32_ADC_INT_CH_NONE;
>>  
>> -	num_channels = of_get_available_child_count(node);
>> +	num_channels = device_get_child_node_count(&indio_dev->dev);
>>  	/* If no channels have been found, fallback to channels legacy properties. */
>>  	if (!num_channels) {
>>  		legacy = true;
>> @@ -2127,7 +2142,8 @@ static int stm32_adc_chan_of_init(struct iio_dev *indio_dev, bool timestamping)
>>  		return -ENOMEM;
>>  
>>  	if (legacy)
>> -		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels);
>> +		ret = stm32_adc_legacy_chan_init(indio_dev, adc, channels,
>> +						 num_channels);
>>  	else
>>  		ret = stm32_adc_generic_chan_init(indio_dev, adc, channels);
>>  	if (ret < 0)
>> @@ -2209,9 +2225,6 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  	bool timestamping = false;
>>  	int ret;
>>  
>> -	if (!pdev->dev.of_node)
>> -		return -ENODEV;
>> -
>>  	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc));
>>  	if (!indio_dev)
>>  		return -ENOMEM;
>> @@ -2220,17 +2233,16 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  	adc->common = dev_get_drvdata(pdev->dev.parent);
>>  	spin_lock_init(&adc->lock);
>>  	init_completion(&adc->completion);
>> -	adc->cfg = (const struct stm32_adc_cfg *)
>> -		of_match_device(dev->driver->of_match_table, dev)->data;
>> +	adc->cfg = device_get_match_data(dev);
>>  
>>  	indio_dev->name = dev_name(&pdev->dev);
>> -	indio_dev->dev.of_node = pdev->dev.of_node;
>> +	device_set_node(&indio_dev->dev, dev_fwnode(&pdev->dev));
>>  	indio_dev->info = &stm32_adc_iio_info;
>>  	indio_dev->modes = INDIO_DIRECT_MODE | INDIO_HARDWARE_TRIGGERED;
>>  
>>  	platform_set_drvdata(pdev, indio_dev);
>>  
>> -	ret = of_property_read_u32(pdev->dev.of_node, "reg", &adc->offset);
>> +	ret = device_property_read_u32(dev, "reg", &adc->offset);
>>  	if (ret != 0) {
>>  		dev_err(&pdev->dev, "missing reg property\n");
>>  		return -EINVAL;
>> @@ -2259,7 +2271,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  		}
>>  	}
>>  
>> -	ret = stm32_adc_of_get_resolution(indio_dev);
>> +	ret = stm32_adc_fw_get_resolution(indio_dev);
>>  	if (ret < 0)
>>  		return ret;
>>  
>> @@ -2276,7 +2288,7 @@ static int stm32_adc_probe(struct platform_device *pdev)
>>  		timestamping = true;
>>  	}
>>  
>> -	ret = stm32_adc_chan_of_init(indio_dev, timestamping);
>> +	ret = stm32_adc_chan_fw_init(indio_dev, timestamping);
>>  	if (ret < 0)
>>  		goto err_dma_disable;
>>  
> 

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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-13  7:20           ` Nuno Sá
@ 2022-06-18 14:03             ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 14:03 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar

On Mon, 13 Jun 2022 09:20:26 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2022-06-11 at 15:59 +0100, Jonathan Cameron wrote:
> > 
> > +Cc Mark Brown for a query on ordering in device tree based SPI
> > setup.
> > 
> > On Fri, 10 Jun 2022 22:08:41 +0200
> > Nuno Sá <noname.nuno@gmail.com> wrote:
> >   
> > > On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:  
> > > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > > wrote:    
> > > > > 
> > > > > 'of_node_put()' can potentially release the memory pointed to
> > > > > by
> > > > > 'iiospec.np' which would leave us with an invalid pointer (and
> > > > > we
> > > > > would
> > > > > still pass it in 'of_xlate()'). As such, we can only release
> > > > > the
> > > > > node
> > > > > after we are done with it.    
> > > > 
> > > > The question you should answer in the commit message is the
> > > > following:
> > > > "Can an OF node, attached to a struct device, be gone before the
> > > > device itself?" If it so, then patch is good, otherwise there is
> > > > no
> > > > point in this patch in the first place.
> > > >     
> > > 
> > > Yeah, I might be wrong but from a quick look... yes, I think the
> > > node
> > > can be gone before the device. Take a look on the spi or i2c
> > > of_notify
> > > handling and you can see that the nodes are get/put on the
> > > add/remove
> > > notifcation. Meaning that the node lifespan is not really attached
> > > to
> > > the device lifespan. If it was, I would expect to see of_node_put()
> > > on
> > > the device release() function...  
> > 
> > I had a look at spi_of_notify() and indeed via
> > spi_unregister_device()
> > the node is put just before device_del() so I agree that at first
> > glance
> > it seems like there may be a race there against the useage here.
> > Mark (+CC) out of interest why are the node gets before the
> > device_add()
> > in spi_add_device() called from of_register_spi_device() but the
> > matching
> > node puts before the device_del() in spi_unregister_device()?
> > Seems like inconsistent ordering...
> > 
> > Which is not to say we shouldn't fix the IIO usage as this patch
> > does!
> >   
> 
> Just to add something that came to my attention. In the IIO case, it
> does not even matter if the parent device has the OF node lifetime
> "linked" to it (as it actually happens for platform devices). The
> reason is that iio_dev only has a weak reference to it's parent and (I
> think) the parent can actually go away while the iio_dev is still
> around (eg: someone has an open fd to the iio_dev cdev).

I chased through this as well and agree. The device_del()
hiding in cdev_device_del() will drop the parent reference on the parent.

I'm not sure it actually maters much though given almost all of_node
useage is not tied up with the anything that might be using the iio_dev
after the iio_device_unregister() call.

Maybe there is a race condition somewhere...

> 
> > > 
> > > Again, I might be wrong and I admit I was not sure about including
> > > this
> > > patch because it's a very unlikely scenario even though I think, in
> > > theory, a possible one.  
> > 
> > The patch is currently valid even if it's not a 'real' bug.
> > Given we are doing a put on that device_node, it makes sense for that
> > to occur after the local use has finished - we shouldn't be relying
> > on
> > what happens to be the case for lifetimes today.
> > 
> > Now, I did wonder if any drivers actually use it in their xlate
> > callbacks.
> > One does for an error print, so this is potentially real (if very
> > unlikely!)
> > 
> > This isn't a 'fix' I'd expect to rush in, or necessarily backport to
> > stable
> > but I think it's a valid fix.
> >   
> 
> Should I drop the fixes tag?
> 
Keep the tag. It's a fix, just a low priority one.

Jonathan

> - Nuno Sá
> 
> 
> 
> 


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-18 14:03             ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 14:03 UTC (permalink / raw)
  To: Nuno Sá
  Cc: chrome-platform, Lad Prabhakar, open list:BROADCOM NVRAM DRIVER,
	Nuno Sá,
	Linux-Renesas, Andy Shevchenko, dl-linux-imx, moderated,
	list:ARM/Mediatek, SoC, support,
	          <linux-mediatek@lists.infradead.org>,
	 linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-msm  <linux-arm-msm@vger.kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	 OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	Cai Huoqing  <cai.huoqing@linux.dev>,
	Benjamin Fair <benjaminfair@google.com>,
	Jishnu  Prakash <quic_jprakash@quicinc.com>,
	Linus Walleij  <linus.walleij@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Alexandre  Torgue <alexandre.torgue@foss.st.com>,
	Amit Kucheria <amitk@kernel.org>,
	 Andy Gross <agross@kernel.org>,
	Michael Hennerich  <Michael.Hennerich@analog.com>,
	Haibo Chen <haibo.chen@nxp.com>,
	Benson  Leung <bleung@chromium.org>, ,
	linux-arm Mailing List
	<linux-arm-kernel@lists.infradead.org>

On Mon, 13 Jun 2022 09:20:26 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2022-06-11 at 15:59 +0100, Jonathan Cameron wrote:
> > 
> > +Cc Mark Brown for a query on ordering in device tree based SPI
> > setup.
> > 
> > On Fri, 10 Jun 2022 22:08:41 +0200
> > Nuno Sá <noname.nuno@gmail.com> wrote:
> >   
> > > On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:  
> > > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > > wrote:    
> > > > > 
> > > > > 'of_node_put()' can potentially release the memory pointed to
> > > > > by
> > > > > 'iiospec.np' which would leave us with an invalid pointer (and
> > > > > we
> > > > > would
> > > > > still pass it in 'of_xlate()'). As such, we can only release
> > > > > the
> > > > > node
> > > > > after we are done with it.    
> > > > 
> > > > The question you should answer in the commit message is the
> > > > following:
> > > > "Can an OF node, attached to a struct device, be gone before the
> > > > device itself?" If it so, then patch is good, otherwise there is
> > > > no
> > > > point in this patch in the first place.
> > > >     
> > > 
> > > Yeah, I might be wrong but from a quick look... yes, I think the
> > > node
> > > can be gone before the device. Take a look on the spi or i2c
> > > of_notify
> > > handling and you can see that the nodes are get/put on the
> > > add/remove
> > > notifcation. Meaning that the node lifespan is not really attached
> > > to
> > > the device lifespan. If it was, I would expect to see of_node_put()
> > > on
> > > the device release() function...  
> > 
> > I had a look at spi_of_notify() and indeed via
> > spi_unregister_device()
> > the node is put just before device_del() so I agree that at first
> > glance
> > it seems like there may be a race there against the useage here.
> > Mark (+CC) out of interest why are the node gets before the
> > device_add()
> > in spi_add_device() called from of_register_spi_device() but the
> > matching
> > node puts before the device_del() in spi_unregister_device()?
> > Seems like inconsistent ordering...
> > 
> > Which is not to say we shouldn't fix the IIO usage as this patch
> > does!
> >   
> 
> Just to add something that came to my attention. In the IIO case, it
> does not even matter if the parent device has the OF node lifetime
> "linked" to it (as it actually happens for platform devices). The
> reason is that iio_dev only has a weak reference to it's parent and (I
> think) the parent can actually go away while the iio_dev is still
> around (eg: someone has an open fd to the iio_dev cdev).

I chased through this as well and agree. The device_del()
hiding in cdev_device_del() will drop the parent reference on the parent.

I'm not sure it actually maters much though given almost all of_node
useage is not tied up with the anything that might be using the iio_dev
after the iio_device_unregister() call.

Maybe there is a race condition somewhere...

> 
> > > 
> > > Again, I might be wrong and I admit I was not sure about including
> > > this
> > > patch because it's a very unlikely scenario even though I think, in
> > > theory, a possible one.  
> > 
> > The patch is currently valid even if it's not a 'real' bug.
> > Given we are doing a put on that device_node, it makes sense for that
> > to occur after the local use has finished - we shouldn't be relying
> > on
> > what happens to be the case for lifetimes today.
> > 
> > Now, I did wonder if any drivers actually use it in their xlate
> > callbacks.
> > One does for an error print, so this is potentially real (if very
> > unlikely!)
> > 
> > This isn't a 'fix' I'd expect to rush in, or necessarily backport to
> > stable
> > but I think it's a valid fix.
> >   
> 
> Should I drop the fixes tag?
> 
Keep the tag. It's a fix, just a low priority one.

Jonathan

> - Nuno Sá
> 
> 
> 
> 


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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
  2022-06-13  7:06       ` Nuno Sá
@ 2022-06-18 14:06         ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 14:06 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Nuno Sá,
	linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Mon, 13 Jun 2022 09:06:49 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2022-06-11 at 16:17 +0100, Jonathan Cameron wrote:
> > On Fri, 10 Jun 2022 10:45:33 +0200
> > Nuno Sá <nuno.sa@analog.com> wrote:
> >   
> > > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > > were
> > > returning a mix of NULL and error pointers being NULL the way to  
> > 
> > pointers with NULL being the way to...
> >   
> > > "notify" that we should do a "system" lookup for channels. This
> > > make
> > > it very confusing and prone to errors as commit dbbccf7c20bf
> > > ("iio: inkern: fix return value in
> > > devm_of_iio_channel_get_by_name()")
> > > proves. On top of this, patterns like 'if (channel != NULL) return
> > > channel'
> > > were being used where channel could actually be an error code which
> > > makes the code hard to read.
> > > 
> > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > > ---
> > >  drivers/iio/inkern.c | 24 +++++++++++-------------
> > >  1 file changed, 11 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > > index 87fd2a0d44f2..31d9c122199a 100644
> > > --- a/drivers/iio/inkern.c
> > > +++ b/drivers/iio/inkern.c
> > > @@ -214,7 +214,7 @@ static struct iio_channel
> > > *of_iio_channel_get(struct device_node *np, int index)
> > >  struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > > *np,
> > >                                                const char *name)
> > >  {
> > > -       struct iio_channel *chan = NULL;
> > > +       struct iio_channel *chan;
> > >  
> > >         /* Walk up the tree of devices looking for a matching iio
> > > channel */
> > >         while (np) {
> > > @@ -231,11 +231,11 @@ struct iio_channel
> > > *of_iio_channel_get_by_name(struct device_node *np,
> > >                                                          name);
> > >                 chan = of_iio_channel_get(np, index);
> > >                 if (!IS_ERR(chan) || PTR_ERR(chan) == -
> > > EPROBE_DEFER)
> > > -                       break;  
> > 
> > This original behaviour is 'interesting'. If we get a error like -
> > ENOMEM
> > we should return it rather than carry on.  Do we have enough
> > knowledge
> > of possible errors here to be more explicit on when we keep looking
> > up
> > the tree?  I think we can get -ENOENT from
> > of_parse_phandle_with_args()
> > 
> > That raises an interesting question on whether -ENODEV is the right
> > response
> > for the previously NULL case or is -ENOENT more consistent with other
> > of_ functions?  No device could be thought of as being the case that
> > needs
> > to defer (in hope it turns up later) whereas no entry means it will
> > never
> > succeed.  
> 
> From what I could see, of_parse_phandle_with_args() either returns 
> -EINVAL or -ENOENT. We also have the internal of_iio_channel_get()
> which can return -ENOMEM. So I guess we should only continue looking if
> we get -ENOENT?
> 
> To be clear, do you still prefer to explicitly return -ENODEV in the
> previous NULL cases or should we honor the return code from 
> of_parse_phandle_with_args() and just return chans (and thus ENOENT)?
You've looked at this more than me, so whilst I think -ENOENT is probably
slightly more consistent I'll go with whatever you conclude is the
best option.  Maybe add a small amount of description on what you chose
and why to the relevant patch descriptions.

Thanks,

Jonathan


> 
> - Nuno Sá


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

* Re: [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs
@ 2022-06-18 14:06         ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 14:06 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Nuno Sá,
	Paul Cercueil, Miquel Raynal, Guenter Roeck, Fabio Estevam,
	linux-stm32, chrome-platform, Lars-Peter Clausen, Benjamin Fair,
	openbmc, Jishnu Prakash, Haibo Chen, Andy Shevchenko, Andy Gross,
	linux-imx, Olivier Moysan, Zhang Rui, Christophe Branchereau

g>, Claudiu Beznea <claudiu.beznea@microchip.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Mon, 13 Jun 2022 09:06:49 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2022-06-11 at 16:17 +0100, Jonathan Cameron wrote:
> > On Fri, 10 Jun 2022 10:45:33 +0200
> > Nuno Sá <nuno.sa@analog.com> wrote:
> >   
> > > APIs like of_iio_channel_get_by_name() and of_iio_channel_get_all()
> > > were
> > > returning a mix of NULL and error pointers being NULL the way to  
> > 
> > pointers with NULL being the way to...
> >   
> > > "notify" that we should do a "system" lookup for channels. This
> > > make
> > > it very confusing and prone to errors as commit dbbccf7c20bf
> > > ("iio: inkern: fix return value in
> > > devm_of_iio_channel_get_by_name()")
> > > proves. On top of this, patterns like 'if (channel != NULL) return
> > > channel'
> > > were being used where channel could actually be an error code which
> > > makes the code hard to read.
> > > 
> > > Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> > > ---
> > >  drivers/iio/inkern.c | 24 +++++++++++-------------
> > >  1 file changed, 11 insertions(+), 13 deletions(-)
> > > 
> > > diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> > > index 87fd2a0d44f2..31d9c122199a 100644
> > > --- a/drivers/iio/inkern.c
> > > +++ b/drivers/iio/inkern.c
> > > @@ -214,7 +214,7 @@ static struct iio_channel
> > > *of_iio_channel_get(struct device_node *np, int index)
> > >  struct iio_channel *of_iio_channel_get_by_name(struct device_node
> > > *np,
> > >                                                const char *name)
> > >  {
> > > -       struct iio_channel *chan = NULL;
> > > +       struct iio_channel *chan;
> > >  
> > >         /* Walk up the tree of devices looking for a matching iio
> > > channel */
> > >         while (np) {
> > > @@ -231,11 +231,11 @@ struct iio_channel
> > > *of_iio_channel_get_by_name(struct device_node *np,
> > >                                                          name);
> > >                 chan = of_iio_channel_get(np, index);
> > >                 if (!IS_ERR(chan) || PTR_ERR(chan) == -
> > > EPROBE_DEFER)
> > > -                       break;  
> > 
> > This original behaviour is 'interesting'. If we get a error like -
> > ENOMEM
> > we should return it rather than carry on.  Do we have enough
> > knowledge
> > of possible errors here to be more explicit on when we keep looking
> > up
> > the tree?  I think we can get -ENOENT from
> > of_parse_phandle_with_args()
> > 
> > That raises an interesting question on whether -ENODEV is the right
> > response
> > for the previously NULL case or is -ENOENT more consistent with other
> > of_ functions?  No device could be thought of as being the case that
> > needs
> > to defer (in hope it turns up later) whereas no entry means it will
> > never
> > succeed.  
> 
> From what I could see, of_parse_phandle_with_args() either returns 
> -EINVAL or -ENOENT. We also have the internal of_iio_channel_get()
> which can return -ENOMEM. So I guess we should only continue looking if
> we get -ENOENT?
> 
> To be clear, do you still prefer to explicitly return -ENODEV in the
> previous NULL cases or should we honor the return code from 
> of_parse_phandle_with_args() and just return chans (and thus ENOENT)?
You've looked at this more than me, so whilst I think -ENOENT is probably
slightly more consistent I'll go with whatever you conclude is the
best option.  Maybe add a small amount of description on what you chose
and why to the relevant patch descriptions.

Thanks,

Jonathan


> 
> - Nuno Sá


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

* Re: [PATCH 24/34] iio: inkern: move to fwnode properties
  2022-06-13  7:13           ` Nuno Sá
@ 2022-06-18 14:09             ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 14:09 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar,
	ARM/Mediatek "SoC support

On Mon, 13 Jun 2022 09:13:00 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2022-06-11 at 16:32 +0100, Jonathan Cameron wrote:
> > On Sat, 11 Jun 2022 16:30:57 +0100
> > Jonathan Cameron <jic23@kernel.org> wrote:
> >   
> > > On Fri, 10 Jun 2022 22:01:09 +0200
> > > Nuno Sá <noname.nuno@gmail.com> wrote:
> > >   
> > > > On Fri, 2022-06-10 at 17:19 +0200, Andy Shevchenko wrote:    
> > > > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > > > wrote:      
> > > > > > 
> > > > > > This moves the IIO in kernel interface to use fwnode
> > > > > > properties and
> > > > > > thus
> > > > > > be firmware agnostic.
> > > > > > 
> > > > > > Note that the interface is still not firmware agnostic. At
> > > > > > this
> > > > > > point we
> > > > > > have both OF and fwnode interfaces so that we don't break any
> > > > > > user.
> > > > > > On
> > > > > > top of this we also want to have a per driver conversion and
> > > > > > that
> > > > > > is the
> > > > > > main reason we have both of_xlate() and fwnode_xlate()
> > > > > > support.      
> > > > > 
> > > > > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > > > > Thanks!
> > > > > 
> > > > > A few nit-picks below, though.
> > > > >       
> > > ...
> > >   
> > > >     
> > > > >       
> > > > > > -       err = of_parse_phandle_with_args(np, "io-channels",
> > > > > > -                                        "#io-channel-cells",
> > > > > > -                                        index, &iiospec);
> > > > > > +       err = fwnode_property_get_reference_args(fwnode, "io-
> > > > > > channels",
> > > > > > +                                                "#io-
> > > > > > channel-
> > > > > > cells", 0,
> > > > > > +                                                index,
> > > > > > &iiospec);
> > > > > >         if (err)
> > > > > >                 return err;
> > > > > > 
> > > > > > -       idev = bus_find_device(&iio_bus_type, NULL,
> > > > > > iiospec.np,
> > > > > > +       idev = bus_find_device(&iio_bus_type, NULL,
> > > > > > iiospec.fwnode,
> > > > > >                                iio_dev_node_match);      
> > > > > 
> > > > > Wondering if this
> > > > > https://elixir.bootlin.com/linux/v5.19-rc1/C/ident/bus_find_device_by_fwnode
> > > > > can be utilized (yes, I noticed iio_device_type above).      
> > > > 
> > > > Hmm, at first glance I would say we can use it. AFAICT, we are
> > > > already
> > > > grabbing a node which contains "#io-channel-cells" which is very
> > > > indicative that is an IIO device. I also find it very unlikely to
> > > > have
> > > > two IIO devices with the same fwnode (I guess it would be an
> > > > issue even
> > > > in the old code) and even more unlikely two devices of diferent
> > > > types
> > > > with the same fwnode?    
> > > 
> > > If we are talking struct iio_dev instances, then there are quite a
> > > few cases
> > > where there are multiple with the same fwnode.  We had to do that
> > > pre
> > > multiple buffers being introduced so it's fairly common, though not
> > > in
> > > ADCs which is probably why we haven't seen breakage here. Not sure
> > > how
> > > broken things already are as a result or if any of those devices
> > > (most
> > > IMUs) provide #io-channel-cells etc.  I'd put that breakage down as
> > > one to look into if anyone every hits it or one of us is bored
> > > enough
> > > to poke at it.  (superficially I think we'd have to check all
> > > matches
> > > for an xlate success).  
> > 
> > Having said that adding a warning comment here, so we remember this
> > is
> > a potential issue would be great.
> >   
> 
> can add the warning... And AFAIU, we can go with Andy suggestion right?

Yes, I think so...   Might chance my mind when I see the code though :)

Jonathan



> 
> - Nuno Sá
> 


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-13  7:20           ` Nuno Sá
@ 2022-06-18 14:13             ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 14:13 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Andy Shevchenko, Nuno Sá,
	dl-linux-imx, Linux-Renesas, open list:BROADCOM NVRAM DRIVER,
	linux-arm Mailing List, chrome-platform, Lad Prabhakar

On Mon, 13 Jun 2022 09:20:26 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2022-06-11 at 15:59 +0100, Jonathan Cameron wrote:
> > 
> > +Cc Mark Brown for a query on ordering in device tree based SPI
> > setup.
> > 
> > On Fri, 10 Jun 2022 22:08:41 +0200
> > Nuno Sá <noname.nuno@gmail.com> wrote:
> >   
> > > On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:  
> > > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > > wrote:    
> > > > > 
> > > > > 'of_node_put()' can potentially release the memory pointed to
> > > > > by
> > > > > 'iiospec.np' which would leave us with an invalid pointer (and
> > > > > we
> > > > > would
> > > > > still pass it in 'of_xlate()'). As such, we can only release
> > > > > the
> > > > > node
> > > > > after we are done with it.    
> > > > 
> > > > The question you should answer in the commit message is the
> > > > following:
> > > > "Can an OF node, attached to a struct device, be gone before the
> > > > device itself?" If it so, then patch is good, otherwise there is
> > > > no
> > > > point in this patch in the first place.
> > > >     
> > > 
> > > Yeah, I might be wrong but from a quick look... yes, I think the
> > > node
> > > can be gone before the device. Take a look on the spi or i2c
> > > of_notify
> > > handling and you can see that the nodes are get/put on the
> > > add/remove
> > > notifcation. Meaning that the node lifespan is not really attached
> > > to
> > > the device lifespan. If it was, I would expect to see of_node_put()
> > > on
> > > the device release() function...  
> > 
> > I had a look at spi_of_notify() and indeed via
> > spi_unregister_device()
> > the node is put just before device_del() so I agree that at first
> > glance
> > it seems like there may be a race there against the useage here.
> > Mark (+CC) out of interest why are the node gets before the
> > device_add()
> > in spi_add_device() called from of_register_spi_device() but the
> > matching
> > node puts before the device_del() in spi_unregister_device()?
> > Seems like inconsistent ordering...
> > 
> > Which is not to say we shouldn't fix the IIO usage as this patch
> > does!
> >   
> 
> Just to add something that came to my attention. In the IIO case, it
> does not even matter if the parent device has the OF node lifetime
> "linked" to it (as it actually happens for platform devices). The
> reason is that iio_dev only has a weak reference to it's parent and (I
> think) the parent can actually go away while the iio_dev is still
> around (eg: someone has an open fd to the iio_dev cdev).
> 
> > > 
> > > Again, I might be wrong and I admit I was not sure about including
> > > this
> > > patch because it's a very unlikely scenario even though I think, in
> > > theory, a possible one.  
> > 
> > The patch is currently valid even if it's not a 'real' bug.
> > Given we are doing a put on that device_node, it makes sense for that
> > to occur after the local use has finished - we shouldn't be relying
> > on
> > what happens to be the case for lifetimes today.
> > 
> > Now, I did wonder if any drivers actually use it in their xlate
> > callbacks.
> > One does for an error print, so this is potentially real (if very
> > unlikely!)
> > 
> > This isn't a 'fix' I'd expect to rush in, or necessarily backport to
> > stable
> > but I think it's a valid fix.
> >   
> 
> Should I drop the fixes tag?
> 
Nope,  Tag still relevant and may be useful to someone down the
line!

Jonathan

> - Nuno Sá
> 
> 
> 
> 


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-18 14:13             ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 14:13 UTC (permalink / raw)
  To: Nuno Sá
  Cc: chrome-platform, Lad Prabhakar, open list:BROADCOM NVRAM DRIVER,
	Nuno Sá,
	Linux-Renesas, Andy Shevchenko, dl-linux-imx, moderated,
	list:ARM/Mediatek, SoC, support,
	          <linux-mediatek@lists.infradead.org>,
	 linux-stm32@st-md-mailman.stormreply.com,
	linux-arm-msm  <linux-arm-msm@vger.kernel.org>,
	linux-iio <linux-iio@vger.kernel.org>,
	 OpenBMC Maillist <openbmc@lists.ozlabs.org>,
	Cai Huoqing  <cai.huoqing@linux.dev>,
	Benjamin Fair <benjaminfair@google.com>,
	Jishnu  Prakash <quic_jprakash@quicinc.com>,
	Linus Walleij  <linus.walleij@linaro.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Alexandre  Torgue <alexandre.torgue@foss.st.com>,
	Amit Kucheria <amitk@kernel.org>,
	 Andy Gross <agross@kernel.org>,
	Michael Hennerich  <Michael.Hennerich@analog.com>,
	Haibo Chen <haibo.chen@nxp.com>,
	Benson  Leung <bleung@chromium.org>, ,
	linux-arm Mailing List
	<linux-arm-kernel@lists.infradead.org>

On Mon, 13 Jun 2022 09:20:26 +0200
Nuno Sá <noname.nuno@gmail.com> wrote:

> On Sat, 2022-06-11 at 15:59 +0100, Jonathan Cameron wrote:
> > 
> > +Cc Mark Brown for a query on ordering in device tree based SPI
> > setup.
> > 
> > On Fri, 10 Jun 2022 22:08:41 +0200
> > Nuno Sá <noname.nuno@gmail.com> wrote:
> >   
> > > On Fri, 2022-06-10 at 16:56 +0200, Andy Shevchenko wrote:  
> > > > On Fri, Jun 10, 2022 at 10:48 AM Nuno Sá <nuno.sa@analog.com>
> > > > wrote:    
> > > > > 
> > > > > 'of_node_put()' can potentially release the memory pointed to
> > > > > by
> > > > > 'iiospec.np' which would leave us with an invalid pointer (and
> > > > > we
> > > > > would
> > > > > still pass it in 'of_xlate()'). As such, we can only release
> > > > > the
> > > > > node
> > > > > after we are done with it.    
> > > > 
> > > > The question you should answer in the commit message is the
> > > > following:
> > > > "Can an OF node, attached to a struct device, be gone before the
> > > > device itself?" If it so, then patch is good, otherwise there is
> > > > no
> > > > point in this patch in the first place.
> > > >     
> > > 
> > > Yeah, I might be wrong but from a quick look... yes, I think the
> > > node
> > > can be gone before the device. Take a look on the spi or i2c
> > > of_notify
> > > handling and you can see that the nodes are get/put on the
> > > add/remove
> > > notifcation. Meaning that the node lifespan is not really attached
> > > to
> > > the device lifespan. If it was, I would expect to see of_node_put()
> > > on
> > > the device release() function...  
> > 
> > I had a look at spi_of_notify() and indeed via
> > spi_unregister_device()
> > the node is put just before device_del() so I agree that at first
> > glance
> > it seems like there may be a race there against the useage here.
> > Mark (+CC) out of interest why are the node gets before the
> > device_add()
> > in spi_add_device() called from of_register_spi_device() but the
> > matching
> > node puts before the device_del() in spi_unregister_device()?
> > Seems like inconsistent ordering...
> > 
> > Which is not to say we shouldn't fix the IIO usage as this patch
> > does!
> >   
> 
> Just to add something that came to my attention. In the IIO case, it
> does not even matter if the parent device has the OF node lifetime
> "linked" to it (as it actually happens for platform devices). The
> reason is that iio_dev only has a weak reference to it's parent and (I
> think) the parent can actually go away while the iio_dev is still
> around (eg: someone has an open fd to the iio_dev cdev).
> 
> > > 
> > > Again, I might be wrong and I admit I was not sure about including
> > > this
> > > patch because it's a very unlikely scenario even though I think, in
> > > theory, a possible one.  
> > 
> > The patch is currently valid even if it's not a 'real' bug.
> > Given we are doing a put on that device_node, it makes sense for that
> > to occur after the local use has finished - we shouldn't be relying
> > on
> > what happens to be the case for lifetimes today.
> > 
> > Now, I did wonder if any drivers actually use it in their xlate
> > callbacks.
> > One does for an error print, so this is potentially real (if very
> > unlikely!)
> > 
> > This isn't a 'fix' I'd expect to rush in, or necessarily backport to
> > stable
> > but I think it's a valid fix.
> >   
> 
> Should I drop the fixes tag?
> 
Nope,  Tag still relevant and may be useful to someone down the
line!

Jonathan

> - Nuno Sá
> 
> 
> 
> 


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
  2022-06-10  8:45   ` Nuno Sá
@ 2022-06-18 17:30     ` Jonathan Cameron
  -1 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 17:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: linux-imx, linux-renesas-soc, linux-mips, linux-arm-kernel,
	chrome-platform, Lad Prabhakar, linux-mediatek, linux-stm32,
	linux-arm-msm, linux-iio, openbmc, Cai Huoqing, Benjamin Fair,
	Jishnu Prakash, Linus Walleij, Lars-Peter Clausen,
	Alexandre Torgue, Amit Kucheria, Andy Gross, Michael Hennerich,
	Haibo Chen, Benson Leung, Rafael J. Wysocki, Alexandre Belloni,
	Christophe Branchereau, Patrick Venture, Arnd Bergmann,
	Nancy Yuen, Sascha Hauer, Daniel Lezcano, Gwendal Grignou,
	Saravanan Sekar, Tali Perry, Maxime Coquelin, Paul Cercueil,
	Thara Gopinath, Avi Fishman, Lorenzo Bianconi, Claudiu Beznea,
	Pengutronix Kernel Team, Andy Shevchenko, Fabrice Gasnier,
	Matthias Brugger, Tomer Maimon, Bjorn Andersson, Nicolas Ferre,
	Zhang Rui, Shawn Guo, Guenter Roeck, Fabio Estevam,
	Olivier Moysan, Eugen Hristev, Miquel Raynal

On Fri, 10 Jun 2022 10:45:31 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

Typo in patch title (just noticed whilst scrolling past)

release


> 'of_node_put()' can potentially release the memory pointed to by
> 'iiospec.np' which would leave us with an invalid pointer (and we would
> still pass it in 'of_xlate()'). As such, we can only release the node
> after we are done with it.
> 
> Fixes: 17d82b47a215d ("iio: Add OF support")
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index df74765d33dc..9d87057794fc 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -165,9 +165,10 @@ static int __of_iio_channel_get(struct iio_channel *channel,
>  
>  	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
>  			       iio_dev_node_match);
> -	of_node_put(iiospec.np);
> -	if (idev == NULL)
> +	if (idev == NULL) {
> +		of_node_put(iiospec.np);
>  		return -EPROBE_DEFER;
> +	}
>  
>  	indio_dev = dev_to_iio_dev(idev);
>  	channel->indio_dev = indio_dev;
> @@ -175,6 +176,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
>  		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
>  	else
>  		index = __of_iio_simple_xlate(indio_dev, &iiospec);
> +	of_node_put(iiospec.np);
>  	if (index < 0)
>  		goto err_put;
>  	channel->channel = &indio_dev->channels[index];


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

* Re: [PATCH 20/34] iio: inkern: only relase the device node when done with it
@ 2022-06-18 17:30     ` Jonathan Cameron
  0 siblings, 0 replies; 246+ messages in thread
From: Jonathan Cameron @ 2022-06-18 17:30 UTC (permalink / raw)
  To: Nuno Sá
  Cc: Alexandre Belloni, Daniel Lezcano, Tomer Maimon,
	Rafael J. Wysocki, linux-iio, Linus Walleij, Amit Kucheria,
	Alexandre Torgue, Tali Perry, Paul Cercueil, Miquel Raynal,
	Guenter Roeck, Fabio Estevam, linux-stm32, chrome-platform,
	Lars-Peter Clausen, Benjamin Fair, openbmc, Jishnu Prakash,
	Haibo Chen, Andy Shevchenko, Andy Gross, linux-imx,
	Olivier Moysan, Zhang Rui, Christophe Branchereau,
	Saravanan Sekar, Michael Hennerich, linux-arm-msm, Sascha Hauer,
	Nicolas Ferre, Lad Prabhakar, Fabrice Gasnier, linux-mediatek,
	Eugen Hristev, Matthias Brugger, Gwendal Grignou,
	Bjorn Andersson, Benson Leung, Pengutronix Kernel Team,
	linux-arm-kernel, Lorenzo Bianconi, Avi Fishman, Patrick Venture,
	linux-mips, Thara Gopinath, linux-renesas-soc, Arnd Bergmann,
	Maxime Coquelin, Cai Huoqing, Shawn Guo, Claudiu Beznea

.com>
Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org
Sender: "openbmc" <openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org>

On Fri, 10 Jun 2022 10:45:31 +0200
Nuno Sá <nuno.sa@analog.com> wrote:

Typo in patch title (just noticed whilst scrolling past)

release


> 'of_node_put()' can potentially release the memory pointed to by
> 'iiospec.np' which would leave us with an invalid pointer (and we would
> still pass it in 'of_xlate()'). As such, we can only release the node
> after we are done with it.
> 
> Fixes: 17d82b47a215d ("iio: Add OF support")
> Signed-off-by: Nuno Sá <nuno.sa@analog.com>
> ---
>  drivers/iio/inkern.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index df74765d33dc..9d87057794fc 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -165,9 +165,10 @@ static int __of_iio_channel_get(struct iio_channel *channel,
>  
>  	idev = bus_find_device(&iio_bus_type, NULL, iiospec.np,
>  			       iio_dev_node_match);
> -	of_node_put(iiospec.np);
> -	if (idev == NULL)
> +	if (idev == NULL) {
> +		of_node_put(iiospec.np);
>  		return -EPROBE_DEFER;
> +	}
>  
>  	indio_dev = dev_to_iio_dev(idev);
>  	channel->indio_dev = indio_dev;
> @@ -175,6 +176,7 @@ static int __of_iio_channel_get(struct iio_channel *channel,
>  		index = indio_dev->info->of_xlate(indio_dev, &iiospec);
>  	else
>  		index = __of_iio_simple_xlate(indio_dev, &iiospec);
> +	of_node_put(iiospec.np);
>  	if (index < 0)
>  		goto err_put;
>  	channel->channel = &indio_dev->channels[index];


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

end of thread, other threads:[~2022-06-20  8:09 UTC | newest]

Thread overview: 246+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-10  8:45 [PATCH 00/34] make iio inkern interface firmware agnostic Nuno Sá
2022-06-10  8:45 ` Nuno Sá
2022-06-10  8:45 ` Nuno Sá
2022-06-10  8:45 ` Nuno Sá
2022-06-10  8:45 ` [PATCH 01/34] iio: adc: ad7606: explicitly add proper header files Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 13:59   ` Jonathan Cameron
2022-06-11 13:59     ` Jonathan Cameron
2022-06-11 13:59     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 02/34] iio: adc: ad7606_par: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:00   ` Jonathan Cameron
2022-06-11 14:00     ` Jonathan Cameron
2022-06-11 14:00     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 03/34] iio: adc: berlin2-adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:02   ` Jonathan Cameron
2022-06-11 14:02     ` Jonathan Cameron
2022-06-11 14:02     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 04/34] iio: adc: imx7d_adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:04   ` Jonathan Cameron
2022-06-11 14:04     ` Jonathan Cameron
2022-06-11 14:04     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 05/34] iio: adc: imx8qxp-adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:05   ` Jonathan Cameron
2022-06-11 14:05     ` Jonathan Cameron
2022-06-11 14:05     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 06/34] iio: adc: ingenic-adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 14:45   ` Andy Shevchenko
2022-06-10 14:45     ` Andy Shevchenko
2022-06-10 19:49     ` Nuno Sá
2022-06-10 19:49       ` Nuno Sá
2022-06-10 19:49       ` Nuno Sá
2022-06-11 14:07       ` Jonathan Cameron
2022-06-11 14:07         ` Jonathan Cameron
2022-06-11 14:07         ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 07/34] iio: adc: mp2629_adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:08   ` Jonathan Cameron
2022-06-11 14:08     ` Jonathan Cameron
2022-06-11 14:08     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 08/34] iio: adc: mt6360-adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:09   ` Jonathan Cameron
2022-06-11 14:09     ` Jonathan Cameron
2022-06-11 14:09     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 09/34] iio: adc: npcm_adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:12   ` Jonathan Cameron
2022-06-11 14:12     ` Jonathan Cameron
2022-06-11 14:12     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 10/34] iio: adc: rzg2l_adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:13   ` Jonathan Cameron
2022-06-11 14:13     ` Jonathan Cameron
2022-06-11 14:13     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 11/34] iio: common: cros_ec_lid_angle: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:14   ` Jonathan Cameron
2022-06-11 14:14     ` Jonathan Cameron
2022-06-11 14:14     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 12/34] iio: common: cros_ec_sensors: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:16   ` Jonathan Cameron
2022-06-11 14:16     ` Jonathan Cameron
2022-06-11 14:16     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 13/34] iio: dac: stm32-dac: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:17   ` Jonathan Cameron
2022-06-11 14:17     ` Jonathan Cameron
2022-06-11 14:17     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 14/34] iio: dac: vf610_dac: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:19   ` Jonathan Cameron
2022-06-11 14:19     ` Jonathan Cameron
2022-06-11 14:19     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 15/34] iio: humidity: hts221_buffer: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 14:47   ` Andy Shevchenko
2022-06-10 14:47     ` Andy Shevchenko
2022-06-11 14:22     ` Jonathan Cameron
2022-06-11 14:22       ` Jonathan Cameron
2022-06-11 14:22       ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 16/34] iio: light: cros_ec_light_prox: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:23   ` Jonathan Cameron
2022-06-11 14:23     ` Jonathan Cameron
2022-06-11 14:23     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 17/34] iio: pressure: cros_ec_baro: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45 ` [PATCH 18/34] iio: trigger: stm32-lptimer-trigger: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45 ` [PATCH 19/34] iio: core: drop of.h from iio.h Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 14:30   ` Jonathan Cameron
2022-06-11 14:30     ` Jonathan Cameron
2022-06-11 14:30     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 20/34] iio: inkern: only relase the device node when done with it Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 14:56   ` Andy Shevchenko
2022-06-10 14:56     ` Andy Shevchenko
2022-06-10 20:08     ` Nuno Sá
2022-06-10 20:08       ` Nuno Sá
2022-06-10 20:08       ` Nuno Sá
2022-06-11 14:59       ` Jonathan Cameron
2022-06-11 14:59         ` Jonathan Cameron
2022-06-11 14:59         ` Jonathan Cameron
2022-06-13  7:20         ` Nuno Sá
2022-06-13  7:20           ` Nuno Sá
2022-06-13  7:20           ` Nuno Sá
2022-06-18 14:03           ` Jonathan Cameron
2022-06-18 14:03             ` Jonathan Cameron
2022-06-18 14:13           ` Jonathan Cameron
2022-06-18 14:13             ` Jonathan Cameron
2022-06-18 17:30   ` Jonathan Cameron
2022-06-18 17:30     ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 21/34] iio: inkern: fix return value in devm_of_iio_channel_get_by_name() Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 14:56   ` Andy Shevchenko
2022-06-10 14:56     ` Andy Shevchenko
2022-06-10  8:45 ` [PATCH 22/34] iio: inkern: only return error codes in iio_channel_get_*() APIs Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 15:05   ` Andy Shevchenko
2022-06-10 15:05     ` Andy Shevchenko
2022-06-10 19:48     ` Nuno Sá
2022-06-10 19:48       ` Nuno Sá
2022-06-10 19:48       ` Nuno Sá
2022-06-11 15:17   ` Jonathan Cameron
2022-06-11 15:17     ` Jonathan Cameron
2022-06-11 15:17     ` Jonathan Cameron
2022-06-13  7:06     ` Nuno Sá
2022-06-13  7:06       ` Nuno Sá
2022-06-13  7:06       ` Nuno Sá
2022-06-18 14:06       ` Jonathan Cameron
2022-06-18 14:06         ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 23/34] iio: inkern: split of_iio_channel_get_by_name() Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 15:07   ` Andy Shevchenko
2022-06-10 15:07     ` Andy Shevchenko
2022-06-10  8:45 ` [PATCH 24/34] iio: inkern: move to fwnode properties Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 15:19   ` Andy Shevchenko
2022-06-10 15:19     ` Andy Shevchenko
2022-06-10 20:01     ` Nuno Sá
2022-06-10 20:01       ` Nuno Sá
2022-06-10 20:01       ` Nuno Sá
2022-06-11 15:30       ` Jonathan Cameron
2022-06-11 15:30         ` Jonathan Cameron
2022-06-11 15:30         ` Jonathan Cameron
2022-06-11 15:32         ` Jonathan Cameron
2022-06-11 15:32           ` Jonathan Cameron
2022-06-13  7:13           ` Nuno Sá
2022-06-18 14:09             ` Jonathan Cameron
2022-06-10  8:45 ` [PATCH 25/34] thermal: qcom: qcom-spmi-adc-tm5: convert to IIO fwnode API Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 15:20   ` Andy Shevchenko
2022-06-10 15:20     ` Andy Shevchenko
2022-06-10 19:42     ` Nuno Sá
2022-06-10 19:42       ` Nuno Sá
2022-06-10 19:42       ` Nuno Sá
2022-06-10  8:45 ` [PATCH 26/34] iio: adc: ingenic-adc: convert to IIO fwnode interface Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45 ` [PATCH 27/34] iio: adc: ab8500-gpadc: convert to device properties Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-15 14:26   ` Linus Walleij
2022-06-15 14:26     ` Linus Walleij
2022-06-10  8:45 ` [PATCH 28/34] iio: adc: at91-sama5d2_adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45 ` [PATCH 29/34] iio: adc: qcom-pm8xxx-xoadc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-15 14:27   ` Linus Walleij
2022-06-15 14:27     ` Linus Walleij
2022-06-10  8:45 ` [PATCH 30/34] iio: adc: qcom-spmi-vadc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-16 13:15   ` Linus Walleij
2022-06-16 13:15     ` Linus Walleij
2022-06-10  8:45 ` [PATCH 31/34] iio: adc: qcom-spmi-adc5: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-16 13:16   ` Linus Walleij
2022-06-16 13:16     ` Linus Walleij
2022-06-10  8:45 ` [PATCH 32/34] iio: adc: stm32-adc: " Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-11 15:47   ` Jonathan Cameron
2022-06-11 15:47     ` Jonathan Cameron
2022-06-11 15:47     ` Jonathan Cameron
2022-06-17 15:58     ` Fabrice Gasnier
2022-06-17 15:58       ` Fabrice Gasnier
2022-06-10  8:45 ` [PATCH 33/34] iio: inkern: remove OF dependencies Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45 ` [PATCH 34/34] iio: inkern: fix coding style warnings Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10  8:45   ` Nuno Sá
2022-06-10 15:53   ` Joe Simmons-Talbott
2022-06-10 15:53     ` Joe Simmons-Talbott
2022-06-10 15:53     ` Joe Simmons-Talbott
2022-06-10 19:51     ` Nuno Sá
2022-06-10 19:51       ` Nuno Sá
2022-06-10 19:51       ` Nuno Sá
2022-06-12 17:39       ` Geert Uytterhoeven
2022-06-12 17:39         ` Geert Uytterhoeven
2022-06-12 17:39         ` Geert Uytterhoeven
2022-06-13  7:23         ` Nuno Sá
2022-06-13  7:23           ` Nuno Sá
2022-06-13  7:23           ` Nuno Sá
2022-06-10 14:48 ` [PATCH 00/34] make iio inkern interface firmware agnostic Andy Shevchenko
2022-06-10 14:48   ` Andy Shevchenko
2022-06-10 15:28   ` Andy Shevchenko
2022-06-10 15:28     ` Andy Shevchenko
2022-06-11 15:50     ` Jonathan Cameron
2022-06-11 15:50       ` Jonathan Cameron

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.