diff mbox series

[v1,5/8] iio: accel: bma220: Drop ACPI_PTR() and accompanying ifdeffery

Message ID 20200831090813.78841-5-andriy.shevchenko@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [v1,1/8] iio: accel: bma220: Fix returned codes from bma220_init(), bma220_deinit() | expand

Commit Message

Andy Shevchenko Aug. 31, 2020, 9:08 a.m. UTC
The driver is quite likely used only on ACPI based platforms and
rarely build with CONFIG_ACPI=n. Even though, the few dozens of bytes
is better than ugly ifdeffery and inclusion of heavy header.

As a result, replace acpi.h with mod_devicetable.h.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/accel/bma220_spi.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Jonathan Cameron Aug. 31, 2020, 9:19 a.m. UTC | #1
On Mon, 31 Aug 2020 12:08:10 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> The driver is quite likely used only on ACPI based platforms and
> rarely build with CONFIG_ACPI=n. Even though, the few dozens of bytes
> is better than ugly ifdeffery and inclusion of heavy header.

Given this part is readily available on maker type break out boards
I doubt it is mostly ACPI.  Rest of the comment is fine though.

Jonathan


> 
> As a result, replace acpi.h with mod_devicetable.h.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/iio/accel/bma220_spi.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
> index e55c5f5dd6b4..105c1dece890 100644
> --- a/drivers/iio/accel/bma220_spi.c
> +++ b/drivers/iio/accel/bma220_spi.c
> @@ -5,8 +5,8 @@
>   * Copyright (c) 2016, Intel Corporation.
>   */
>  
> -#include <linux/acpi.h>
>  #include <linux/kernel.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/iio/buffer.h>
>  #include <linux/iio/iio.h>
> @@ -310,20 +310,18 @@ static const struct spi_device_id bma220_spi_id[] = {
>  	{}
>  };
>  
> -#ifdef CONFIG_ACPI
>  static const struct acpi_device_id bma220_acpi_id[] = {
>  	{"BMA0220", 0},
>  	{}
>  };
>  
>  MODULE_DEVICE_TABLE(spi, bma220_spi_id);
> -#endif
>  
>  static struct spi_driver bma220_driver = {
>  	.driver = {
>  		.name = "bma220_spi",
>  		.pm = &bma220_pm_ops,
> -		.acpi_match_table = ACPI_PTR(bma220_acpi_id),
> +		.acpi_match_table = bma220_acpi_id,
>  	},
>  	.probe =            bma220_probe,
>  	.remove =           bma220_remove,
Andy Shevchenko Aug. 31, 2020, 9:39 a.m. UTC | #2
On Mon, Aug 31, 2020 at 12:19 PM Jonathan Cameron <jic23@kernel.org> wrote:
>
> On Mon, 31 Aug 2020 12:08:10 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
>
> > The driver is quite likely used only on ACPI based platforms and
> > rarely build with CONFIG_ACPI=n. Even though, the few dozens of bytes
> > is better than ugly ifdeffery and inclusion of heavy header.
>
> Given this part is readily available on maker type break out boards
> I doubt it is mostly ACPI.  Rest of the comment is fine though.

In-kernel use seems only ACPI (I grepped for pure SPI driver by name
and didn't find anything).
I hope we will have DT support for that as well (basically means
adding OF ID table).
Jonathan Cameron Aug. 31, 2020, 9:55 a.m. UTC | #3
On Mon, 31 Aug 2020 12:39:10 +0300
Andy Shevchenko <andy.shevchenko@gmail.com> wrote:

> On Mon, Aug 31, 2020 at 12:19 PM Jonathan Cameron <jic23@kernel.org> wrote:
> >
> > On Mon, 31 Aug 2020 12:08:10 +0300
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> >  
> > > The driver is quite likely used only on ACPI based platforms and
> > > rarely build with CONFIG_ACPI=n. Even though, the few dozens of bytes
> > > is better than ugly ifdeffery and inclusion of heavy header.  
> >
> > Given this part is readily available on maker type break out boards
> > I doubt it is mostly ACPI.  Rest of the comment is fine though.  
> 
> In-kernel use seems only ACPI (I grepped for pure SPI driver by name
> and didn't find anything).
> I hope we will have DT support for that as well (basically means
> adding OF ID table).
> 

Good to add the explicit DT support, but I think the nasty fallback is
still in place in which the old style ID table is used if we get a match
without manufacturer ID.

So should be possible to instantiate it from DT even without the table.

Jonathan
Andy Shevchenko Aug. 31, 2020, 10:17 a.m. UTC | #4
On Mon, Aug 31, 2020 at 10:55:04AM +0100, Jonathan Cameron wrote:
> On Mon, 31 Aug 2020 12:39:10 +0300
> Andy Shevchenko <andy.shevchenko@gmail.com> wrote:
> > On Mon, Aug 31, 2020 at 12:19 PM Jonathan Cameron <jic23@kernel.org> wrote:
> > > On Mon, 31 Aug 2020 12:08:10 +0300
> > > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> > >  
> > > > The driver is quite likely used only on ACPI based platforms and
> > > > rarely build with CONFIG_ACPI=n. Even though, the few dozens of bytes
> > > > is better than ugly ifdeffery and inclusion of heavy header.  
> > >
> > > Given this part is readily available on maker type break out boards
> > > I doubt it is mostly ACPI.  Rest of the comment is fine though.  
> > 
> > In-kernel use seems only ACPI (I grepped for pure SPI driver by name
> > and didn't find anything).
> > I hope we will have DT support for that as well (basically means
> > adding OF ID table).
> > 
> 
> Good to add the explicit DT support, but I think the nasty fallback is
> still in place in which the old style ID table is used if we get a match
> without manufacturer ID.
> 
> So should be possible to instantiate it from DT even without the table.

True, but as I said, there is no evidence that there is a single user in kernel.
diff mbox series

Patch

diff --git a/drivers/iio/accel/bma220_spi.c b/drivers/iio/accel/bma220_spi.c
index e55c5f5dd6b4..105c1dece890 100644
--- a/drivers/iio/accel/bma220_spi.c
+++ b/drivers/iio/accel/bma220_spi.c
@@ -5,8 +5,8 @@ 
  * Copyright (c) 2016, Intel Corporation.
  */
 
-#include <linux/acpi.h>
 #include <linux/kernel.h>
+#include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/iio/buffer.h>
 #include <linux/iio/iio.h>
@@ -310,20 +310,18 @@  static const struct spi_device_id bma220_spi_id[] = {
 	{}
 };
 
-#ifdef CONFIG_ACPI
 static const struct acpi_device_id bma220_acpi_id[] = {
 	{"BMA0220", 0},
 	{}
 };
 
 MODULE_DEVICE_TABLE(spi, bma220_spi_id);
-#endif
 
 static struct spi_driver bma220_driver = {
 	.driver = {
 		.name = "bma220_spi",
 		.pm = &bma220_pm_ops,
-		.acpi_match_table = ACPI_PTR(bma220_acpi_id),
+		.acpi_match_table = bma220_acpi_id,
 	},
 	.probe =            bma220_probe,
 	.remove =           bma220_remove,