Linux IIO development
 help / color / mirror / Atom feed
* [PATCH v1 1/1] iio: adc: twl4030-madc: Make use of device properties
@ 2024-02-28 20:59 Andy Shevchenko
  2024-03-03 13:50 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2024-02-28 20:59 UTC (permalink / raw)
  To: Andy Shevchenko, linux-iio, linux-kernel
  Cc: Jonathan Cameron, Lars-Peter Clausen

Convert the module to be property provider agnostic and allow
it to be used on non-OF platforms.

Include mod_devicetable.h explicitly to replace the dropped of.h
which included mod_devicetable.h indirectly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/twl4030-madc.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
index 4a247ca25a44..a7b6b81014de 100644
--- a/drivers/iio/adc/twl4030-madc.c
+++ b/drivers/iio/adc/twl4030-madc.c
@@ -19,10 +19,12 @@
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
+#include <linux/mod_devicetable.h>
+#include <linux/module.h>
 #include <linux/platform_device.h>
+#include <linux/property.h>
 #include <linux/slab.h>
 #include <linux/mfd/twl.h>
-#include <linux/module.h>
 #include <linux/stddef.h>
 #include <linux/mutex.h>
 #include <linux/bitops.h>
@@ -30,7 +32,6 @@
 #include <linux/types.h>
 #include <linux/gfp.h>
 #include <linux/err.h>
-#include <linux/of.h>
 #include <linux/regulator/consumer.h>
 
 #include <linux/iio/iio.h>
@@ -746,7 +747,6 @@ static int twl4030_madc_probe(struct platform_device *pdev)
 {
 	struct twl4030_madc_data *madc;
 	struct twl4030_madc_platform_data *pdata = dev_get_platdata(&pdev->dev);
-	struct device_node *np = pdev->dev.of_node;
 	int irq, ret;
 	u8 regval;
 	struct iio_dev *iio_dev = NULL;
@@ -779,7 +779,7 @@ static int twl4030_madc_probe(struct platform_device *pdev)
 	if (pdata)
 		madc->use_second_irq = (pdata->irq_line != 1);
 	else
-		madc->use_second_irq = of_property_read_bool(np,
+		madc->use_second_irq = device_property_read_bool(&pdev->dev,
 				       "ti,system-uses-second-madc-irq");
 
 	madc->imr = madc->use_second_irq ? TWL4030_MADC_IMR2 :
@@ -905,20 +905,18 @@ static void twl4030_madc_remove(struct platform_device *pdev)
 	regulator_disable(madc->usb3v1);
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id twl_madc_of_match[] = {
 	{ .compatible = "ti,twl4030-madc", },
-	{ },
+	{ }
 };
 MODULE_DEVICE_TABLE(of, twl_madc_of_match);
-#endif
 
 static struct platform_driver twl4030_madc_driver = {
 	.probe = twl4030_madc_probe,
 	.remove_new = twl4030_madc_remove,
 	.driver = {
 		   .name = "twl4030_madc",
-		   .of_match_table = of_match_ptr(twl_madc_of_match),
+		   .of_match_table = twl_madc_of_match,
 	},
 };
 
-- 
2.43.0.rc1.1.gbec44491f096


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

* Re: [PATCH v1 1/1] iio: adc: twl4030-madc: Make use of device properties
  2024-02-28 20:59 [PATCH v1 1/1] iio: adc: twl4030-madc: Make use of device properties Andy Shevchenko
@ 2024-03-03 13:50 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2024-03-03 13:50 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-iio, linux-kernel, Lars-Peter Clausen

On Wed, 28 Feb 2024 22:59:27 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> Convert the module to be property provider agnostic and allow
> it to be used on non-OF platforms.
> 
> Include mod_devicetable.h explicitly to replace the dropped of.h
> which included mod_devicetable.h indirectly.

It seems fairly implausible anyone will use this ancient device
with any other firmware, but as conversion is trivial and provides
one less place for people to copy of specific handling from
i tried applying it.

However it doesn't build...

drivers/iio/adc/twl4030-madc.c:754:24: error: ‘np’ undeclared (first use in this function); did you mean ‘up’?
  754 |         if (!pdata && !np) {
      |                        ^~
      |                        up


I guess !dev_fwnode(dev) instead?

Jonathan
 
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/iio/adc/twl4030-madc.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
> index 4a247ca25a44..a7b6b81014de 100644
> --- a/drivers/iio/adc/twl4030-madc.c
> +++ b/drivers/iio/adc/twl4030-madc.c
> @@ -19,10 +19,12 @@
>  #include <linux/interrupt.h>
>  #include <linux/kernel.h>
>  #include <linux/delay.h>
> +#include <linux/mod_devicetable.h>
> +#include <linux/module.h>
>  #include <linux/platform_device.h>
> +#include <linux/property.h>
>  #include <linux/slab.h>
>  #include <linux/mfd/twl.h>
> -#include <linux/module.h>
>  #include <linux/stddef.h>
>  #include <linux/mutex.h>
>  #include <linux/bitops.h>
> @@ -30,7 +32,6 @@
>  #include <linux/types.h>
>  #include <linux/gfp.h>
>  #include <linux/err.h>
> -#include <linux/of.h>
>  #include <linux/regulator/consumer.h>
>  
>  #include <linux/iio/iio.h>
> @@ -746,7 +747,6 @@ static int twl4030_madc_probe(struct platform_device *pdev)
>  {
>  	struct twl4030_madc_data *madc;
>  	struct twl4030_madc_platform_data *pdata = dev_get_platdata(&pdev->dev);
> -	struct device_node *np = pdev->dev.of_node;
>  	int irq, ret;
>  	u8 regval;
>  	struct iio_dev *iio_dev = NULL;
> @@ -779,7 +779,7 @@ static int twl4030_madc_probe(struct platform_device *pdev)
>  	if (pdata)
>  		madc->use_second_irq = (pdata->irq_line != 1);
>  	else
> -		madc->use_second_irq = of_property_read_bool(np,
> +		madc->use_second_irq = device_property_read_bool(&pdev->dev,
>  				       "ti,system-uses-second-madc-irq");
>  
>  	madc->imr = madc->use_second_irq ? TWL4030_MADC_IMR2 :
> @@ -905,20 +905,18 @@ static void twl4030_madc_remove(struct platform_device *pdev)
>  	regulator_disable(madc->usb3v1);
>  }
>  
> -#ifdef CONFIG_OF
>  static const struct of_device_id twl_madc_of_match[] = {
>  	{ .compatible = "ti,twl4030-madc", },
> -	{ },
> +	{ }
>  };
>  MODULE_DEVICE_TABLE(of, twl_madc_of_match);
> -#endif
>  
>  static struct platform_driver twl4030_madc_driver = {
>  	.probe = twl4030_madc_probe,
>  	.remove_new = twl4030_madc_remove,
>  	.driver = {
>  		   .name = "twl4030_madc",
> -		   .of_match_table = of_match_ptr(twl_madc_of_match),
> +		   .of_match_table = twl_madc_of_match,
>  	},
>  };
>  


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

end of thread, other threads:[~2024-03-03 13:50 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-28 20:59 [PATCH v1 1/1] iio: adc: twl4030-madc: Make use of device properties Andy Shevchenko
2024-03-03 13:50 ` Jonathan Cameron

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