linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for-5.9] iio: adc: meson-saradc: Use the parent device to look up the calib data
@ 2020-08-15 18:13 Martin Blumenstingl
  2020-08-22 10:40 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Blumenstingl @ 2020-08-15 18:13 UTC (permalink / raw)
  To: jic23, lars, linux-iio, linux-amlogic
  Cc: knaack.h, linux-arm-kernel, linux-kernel, Martin Blumenstingl

On the older-gen 32-bit SoCs the meson-saradc driver is used to read the
SoC temperature. This requires reading calibration data from the eFuse.

Looking up the calibration data nvmem-cell requires the OF device_node
pointer to be available in the struct device which is passed to
devm_nvmem_cell_get(). This however got lost with commit 8cb631ccbb1952
("iio: Remove superfluous of_node assignments") from indio_dev->dev. As
devm_nvmem_cell_get() is called in the initialization phase the
device_node is not yet available because the NVMEM cell is looked up
before iio_device_register() is called (which would then set the
device_node automatically).
Use the parent device to look up the NVMEM cell instead to fix this
issue.

Fixes: 8cb631ccbb1952 ("iio: Remove superfluous of_node assignments")
Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
---
 drivers/iio/adc/meson_saradc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
index 93c2252c0b89..1a9189ba69ae 100644
--- a/drivers/iio/adc/meson_saradc.c
+++ b/drivers/iio/adc/meson_saradc.c
@@ -707,7 +707,7 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
 	size_t read_len;
 	int ret;
 
-	temperature_calib = devm_nvmem_cell_get(&indio_dev->dev,
+	temperature_calib = devm_nvmem_cell_get(indio_dev->dev.parent,
 						"temperature_calib");
 	if (IS_ERR(temperature_calib)) {
 		ret = PTR_ERR(temperature_calib);
-- 
2.28.0


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

* Re: [PATCH for-5.9] iio: adc: meson-saradc: Use the parent device to look up the calib data
  2020-08-15 18:13 [PATCH for-5.9] iio: adc: meson-saradc: Use the parent device to look up the calib data Martin Blumenstingl
@ 2020-08-22 10:40 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2020-08-22 10:40 UTC (permalink / raw)
  To: Martin Blumenstingl
  Cc: lars, linux-iio, linux-amlogic, knaack.h, linux-arm-kernel, linux-kernel

On Sat, 15 Aug 2020 20:13:55 +0200
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> On the older-gen 32-bit SoCs the meson-saradc driver is used to read the
> SoC temperature. This requires reading calibration data from the eFuse.
> 
> Looking up the calibration data nvmem-cell requires the OF device_node
> pointer to be available in the struct device which is passed to
> devm_nvmem_cell_get(). This however got lost with commit 8cb631ccbb1952
> ("iio: Remove superfluous of_node assignments") from indio_dev->dev. As
> devm_nvmem_cell_get() is called in the initialization phase the
> device_node is not yet available because the NVMEM cell is looked up
> before iio_device_register() is called (which would then set the
> device_node automatically).
> Use the parent device to look up the NVMEM cell instead to fix this
> issue.
> 
> Fixes: 8cb631ccbb1952 ("iio: Remove superfluous of_node assignments")
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Gah.  I hope we don't have too many more non obvious cases like
this hiding.

Applied to the fixes-togreg branch of iio.git

Thanks,

Jonathan

> ---
>  drivers/iio/adc/meson_saradc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 93c2252c0b89..1a9189ba69ae 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -707,7 +707,7 @@ static int meson_sar_adc_temp_sensor_init(struct iio_dev *indio_dev)
>  	size_t read_len;
>  	int ret;
>  
> -	temperature_calib = devm_nvmem_cell_get(&indio_dev->dev,
> +	temperature_calib = devm_nvmem_cell_get(indio_dev->dev.parent,
>  						"temperature_calib");
>  	if (IS_ERR(temperature_calib)) {
>  		ret = PTR_ERR(temperature_calib);


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

end of thread, other threads:[~2020-08-22 10:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-15 18:13 [PATCH for-5.9] iio: adc: meson-saradc: Use the parent device to look up the calib data Martin Blumenstingl
2020-08-22 10:40 ` Jonathan Cameron

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