diff mbox series

[v3,09/15] iio: adc: at91-sama5d2_adc: convert to device properties

Message ID 20220715122903.332535-10-nuno.sa@analog.com (mailing list archive)
State Handled Elsewhere
Headers show
Series make iio inkern interface firmware agnostic | expand

Commit Message

Nuno Sa July 15, 2022, 12:28 p.m. UTC
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>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
---
 drivers/iio/adc/at91-sama5d2_adc.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

Comments

Claudiu Beznea July 18, 2022, 5:21 a.m. UTC | #1
On 15.07.2022 15:28, Nuno Sá wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> 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>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.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 fe3131c9593c..df716584c117 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.37.1
>
Jonathan Cameron Aug. 6, 2022, 6:49 p.m. UTC | #2
On Mon, 18 Jul 2022 05:21:47 +0000
<Claudiu.Beznea@microchip.com> wrote:

> On 15.07.2022 15:28, Nuno Sá wrote:
> > EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> > 
> > 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>
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>  
> 
> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
> 

Hi Nuno / Claudiu

Lots of fuzz on this one because of Claudiu's series that I took whilst this was under review
I haven't really checked the result of forcing it in but please take a look at the
testing branch of iio.git for anything silly that happened.

Jonathan

> 
> > ---
> >  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 fe3131c9593c..df716584c117 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.37.1
> >   
>
Claudiu Beznea Aug. 18, 2022, 8:39 a.m. UTC | #3
On 06.08.2022 21:49, Jonathan Cameron wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> On Mon, 18 Jul 2022 05:21:47 +0000
> <Claudiu.Beznea@microchip.com> wrote:
> 
>> On 15.07.2022 15:28, Nuno Sá wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>>
>>> 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>
>>> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
>>
>> Reviewed-by: Claudiu Beznea <claudiu.beznea@microchip.com>
>>
> 
> Hi Nuno / Claudiu
> 
> Lots of fuzz on this one because of Claudiu's series that I took whilst this was under review
> I haven't really checked the result of forcing it in but please take a look at the
> testing branch of iio.git for anything silly that happened.

Looks good to me.

Thank you,
Claudiu Beznea

> 
> Jonathan
> 
>>
>>> ---
>>>  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 fe3131c9593c..df716584c117 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.37.1
>>>
>>
>
diff mbox series

Patch

diff --git a/drivers/iio/adc/at91-sama5d2_adc.c b/drivers/iio/adc/at91-sama5d2_adc.c
index fe3131c9593c..df716584c117 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");