diff mbox series

[22/23] iio:adc:bcm_iproc: Drop of_match_ptr protection and switch to mod_devicetable.h

Message ID 20200628123654.32830-23-jic23@kernel.org (mailing list archive)
State New, archived
Headers show
Series iio:adc more of_match_ptr and similar removal | expand

Commit Message

Jonathan Cameron June 28, 2020, 12:36 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

Whilst it's unlikely that this driver will ever be instantiated from
ACPI PRP0001 there is little advantage in using the of_match_ptr
protection.  The switch of header is because we only use of_match_id
in here and that is defined in mod_devicetable.h not of.h.

Note the main reason for this patch is to avoid providing instances
of of_match_ptr being used in IIO that might get copied into new drivers.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
---
 drivers/iio/adc/bcm_iproc_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Andy Shevchenko June 30, 2020, 7:25 a.m. UTC | #1
On Sun, Jun 28, 2020 at 3:39 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> Whilst it's unlikely that this driver will ever be instantiated from
> ACPI PRP0001 there is little advantage in using the of_match_ptr
> protection.  The switch of header is because we only use of_match_id
> in here and that is defined in mod_devicetable.h not of.h.
>
> Note the main reason for this patch is to avoid providing instances
> of of_match_ptr being used in IIO that might get copied into new drivers.
>

Commit message is misleading. The change won't help with ACPI due to
syscon_regmap_lookup_by_phandle() call.

> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Cc: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
> ---
>  drivers/iio/adc/bcm_iproc_adc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> index 936da32faa9d..44e1e53ada72 100644
> --- a/drivers/iio/adc/bcm_iproc_adc.c
> +++ b/drivers/iio/adc/bcm_iproc_adc.c
> @@ -4,7 +4,7 @@
>   */
>
>  #include <linux/module.h>
> -#include <linux/of.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/io.h>
>  #include <linux/clk.h>
>  #include <linux/mfd/syscon.h>
> @@ -617,7 +617,7 @@ static struct platform_driver iproc_adc_driver = {
>         .remove = iproc_adc_remove,
>         .driver = {
>                 .name   = "iproc-static-adc",
> -               .of_match_table = of_match_ptr(iproc_adc_of_match),
> +               .of_match_table = iproc_adc_of_match,
>         },
>  };
>  module_platform_driver(iproc_adc_driver);
> --
> 2.27.0
>
Jonathan Cameron July 4, 2020, 3:59 p.m. UTC | #2
On Tue, 30 Jun 2020 10:25:24 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Sun, Jun 28, 2020 at 3:39 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> >
> > Whilst it's unlikely that this driver will ever be instantiated from
> > ACPI PRP0001 there is little advantage in using the of_match_ptr
> > protection.  The switch of header is because we only use of_match_id
> > in here and that is defined in mod_devicetable.h not of.h.
> >
> > Note the main reason for this patch is to avoid providing instances
> > of of_match_ptr being used in IIO that might get copied into new drivers.
> >  
> 
> Commit message is misleading. The change won't help with ACPI due to
> syscon_regmap_lookup_by_phandle() call.

I'd missed that.  I'll drop this one.

Thanks,

Jonathan

> 
> > Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > Cc: Raveendra Padasalagi <raveendra.padasalagi@broadcom.com>
> > ---
> >  drivers/iio/adc/bcm_iproc_adc.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
> > index 936da32faa9d..44e1e53ada72 100644
> > --- a/drivers/iio/adc/bcm_iproc_adc.c
> > +++ b/drivers/iio/adc/bcm_iproc_adc.c
> > @@ -4,7 +4,7 @@
> >   */
> >
> >  #include <linux/module.h>
> > -#include <linux/of.h>
> > +#include <linux/mod_devicetable.h>
> >  #include <linux/io.h>
> >  #include <linux/clk.h>
> >  #include <linux/mfd/syscon.h>
> > @@ -617,7 +617,7 @@ static struct platform_driver iproc_adc_driver = {
> >         .remove = iproc_adc_remove,
> >         .driver = {
> >                 .name   = "iproc-static-adc",
> > -               .of_match_table = of_match_ptr(iproc_adc_of_match),
> > +               .of_match_table = iproc_adc_of_match,
> >         },
> >  };
> >  module_platform_driver(iproc_adc_driver);
> > --
> > 2.27.0
> >  
> 
>
Andy Shevchenko July 4, 2020, 6:22 p.m. UTC | #3
On Sat, Jul 4, 2020 at 6:59 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Tue, 30 Jun 2020 10:25:24 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
>
> > On Sun, Jun 28, 2020 at 3:39 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > >
> > > From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> > >
> > > Whilst it's unlikely that this driver will ever be instantiated from
> > > ACPI PRP0001 there is little advantage in using the of_match_ptr
> > > protection.  The switch of header is because we only use of_match_id
> > > in here and that is defined in mod_devicetable.h not of.h.
> > >
> > > Note the main reason for this patch is to avoid providing instances
> > > of of_match_ptr being used in IIO that might get copied into new drivers.
> > >
> >
> > Commit message is misleading. The change won't help with ACPI due to
> > syscon_regmap_lookup_by_phandle() call.
>
> I'd missed that.  I'll drop this one.

Actually in this case, if it's not done yet, I prefer to see in
Kconfig something like

depends on OF || COMPILE_TEST

to explicitly show that "yes, you may compile it, but it requires OF
to function with usefulness".
diff mbox series

Patch

diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c
index 936da32faa9d..44e1e53ada72 100644
--- a/drivers/iio/adc/bcm_iproc_adc.c
+++ b/drivers/iio/adc/bcm_iproc_adc.c
@@ -4,7 +4,7 @@ 
  */
 
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/mod_devicetable.h>
 #include <linux/io.h>
 #include <linux/clk.h>
 #include <linux/mfd/syscon.h>
@@ -617,7 +617,7 @@  static struct platform_driver iproc_adc_driver = {
 	.remove	= iproc_adc_remove,
 	.driver	= {
 		.name	= "iproc-static-adc",
-		.of_match_table = of_match_ptr(iproc_adc_of_match),
+		.of_match_table = iproc_adc_of_match,
 	},
 };
 module_platform_driver(iproc_adc_driver);