diff mbox series

[v2,4/6] iio: st_sensors: Add ACPI support for lsm303d to the LSM9DS0 IMU driver

Message ID 20230413024013.450165-5-mail@mariushoch.de (mailing list archive)
State Changes Requested
Headers show
Series iio: st_sensors: Add lsm303d support | expand

Commit Message

Marius Hoch April 13, 2023, 2:40 a.m. UTC
The lsm303d can be found as ACCL0001 on various Lenovo devices,
including the Lenovo Yoga Tablet 2 1051-F, where I tested this
patch.

Signed-off-by: Marius Hoch <mail@mariushoch.de>
---
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 10 ++++++++++
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 10 ++++++++++
 2 files changed, 20 insertions(+)

Comments

Jonathan Cameron April 15, 2023, 4:55 p.m. UTC | #1
On Thu, 13 Apr 2023 04:40:11 +0200
Marius Hoch <mail@mariushoch.de> wrote:

> The lsm303d can be found as ACCL0001 on various Lenovo devices,
> including the Lenovo Yoga Tablet 2 1051-F, where I tested this
> patch.
> 
> Signed-off-by: Marius Hoch <mail@mariushoch.de>
> ---
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 10 ++++++++++
>  drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 10 ++++++++++
>  2 files changed, 20 insertions(+)
> 
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> index 64fa77d302e2..79be8d28d965 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
> @@ -12,6 +12,7 @@
>  #include <linux/module.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/regmap.h>
> +#include <linux/acpi.h>
>  
>  #include <linux/iio/common/st_sensors_i2c.h>
>  
> @@ -37,6 +38,14 @@ static const struct i2c_device_id st_lsm9ds0_id_table[] = {
>  };
>  MODULE_DEVICE_TABLE(i2c, st_lsm9ds0_id_table);
>  
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id st_lsm9ds0_acpi_match[] = {
> +	{"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match);
> +#endif

The table is tiny so I'd prefer dropping the complexity of ifdefs
and getting rid of the ACPI_PTR() below. Just assign the pointer
unconditionally.

Rest of the series looks good to me

Thanks,

Jonathan

> +
>  static const struct regmap_config st_lsm9ds0_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -73,6 +82,7 @@ static struct i2c_driver st_lsm9ds0_driver = {
>  	.driver = {
>  		.name = "st-lsm9ds0-i2c",
>  		.of_match_table = st_lsm9ds0_of_match,
> +		.acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match),
>  	},
>  	.probe_new = st_lsm9ds0_i2c_probe,
>  	.id_table = st_lsm9ds0_id_table,
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> index 997b5ff792be..27c5d99ce0e3 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> @@ -12,6 +12,7 @@
>  #include <linux/mod_devicetable.h>
>  #include <linux/regmap.h>
>  #include <linux/spi/spi.h>
> +#include <linux/acpi.h>
>  
>  #include <linux/iio/common/st_sensors_spi.h>
>  
> @@ -37,6 +38,14 @@ static const struct spi_device_id st_lsm9ds0_id_table[] = {
>  };
>  MODULE_DEVICE_TABLE(spi, st_lsm9ds0_id_table);
>  
> +#ifdef CONFIG_ACPI
> +static const struct acpi_device_id st_lsm9ds0_acpi_match[] = {
> +	{"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME},
> +	{ },
> +};
> +MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match);
> +#endif
> +
>  static const struct regmap_config st_lsm9ds0_regmap_config = {
>  	.reg_bits	= 8,
>  	.val_bits	= 8,
> @@ -72,6 +81,7 @@ static struct spi_driver st_lsm9ds0_driver = {
>  	.driver = {
>  		.name = "st-lsm9ds0-spi",
>  		.of_match_table = st_lsm9ds0_of_match,
> +		.acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match),
>  	},
>  	.probe = st_lsm9ds0_spi_probe,
>  	.id_table = st_lsm9ds0_id_table,
Marius Hoch April 15, 2023, 11:17 p.m. UTC | #2
On 15/04/2023 18:55, Jonathan Cameron wrote:
> On Thu, 13 Apr 2023 04:40:11 +0200
> Marius Hoch <mail@mariushoch.de> wrote:
>
>> The lsm303d can be found as ACCL0001 on various Lenovo devices,
>> including the Lenovo Yoga Tablet 2 1051-F, where I tested this
>> patch.
>>
>> Signed-off-by: Marius Hoch <mail@mariushoch.de>
>> ---
>>   drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c | 10 ++++++++++
>>   drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 10 ++++++++++
>>   2 files changed, 20 insertions(+)
>>
>> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
>> index 64fa77d302e2..79be8d28d965 100644
>> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
>> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
>> @@ -12,6 +12,7 @@
>>   #include <linux/module.h>
>>   #include <linux/mod_devicetable.h>
>>   #include <linux/regmap.h>
>> +#include <linux/acpi.h>
>>   
>>   #include <linux/iio/common/st_sensors_i2c.h>
>>   
>> @@ -37,6 +38,14 @@ static const struct i2c_device_id st_lsm9ds0_id_table[] = {
>>   };
>>   MODULE_DEVICE_TABLE(i2c, st_lsm9ds0_id_table);
>>   
>> +#ifdef CONFIG_ACPI
>> +static const struct acpi_device_id st_lsm9ds0_acpi_match[] = {
>> +	{"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME},
>> +	{ },
>> +};
>> +MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match);
>> +#endif
> The table is tiny so I'd prefer dropping the complexity of ifdefs
> and getting rid of the ACPI_PTR() below. Just assign the pointer
> unconditionally.
>
> Rest of the series looks good to me
>
> Thanks,
>
> Jonathan
Thanks for your review, applied in v3.
>> +
>>   static const struct regmap_config st_lsm9ds0_regmap_config = {
>>   	.reg_bits	= 8,
>>   	.val_bits	= 8,
>> @@ -73,6 +82,7 @@ static struct i2c_driver st_lsm9ds0_driver = {
>>   	.driver = {
>>   		.name = "st-lsm9ds0-i2c",
>>   		.of_match_table = st_lsm9ds0_of_match,
>> +		.acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match),
>>   	},
>>   	.probe_new = st_lsm9ds0_i2c_probe,
>>   	.id_table = st_lsm9ds0_id_table,
>> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
>> index 997b5ff792be..27c5d99ce0e3 100644
>> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
>> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
>> @@ -12,6 +12,7 @@
>>   #include <linux/mod_devicetable.h>
>>   #include <linux/regmap.h>
>>   #include <linux/spi/spi.h>
>> +#include <linux/acpi.h>
>>   
>>   #include <linux/iio/common/st_sensors_spi.h>
>>   
>> @@ -37,6 +38,14 @@ static const struct spi_device_id st_lsm9ds0_id_table[] = {
>>   };
>>   MODULE_DEVICE_TABLE(spi, st_lsm9ds0_id_table);
>>   
>> +#ifdef CONFIG_ACPI
>> +static const struct acpi_device_id st_lsm9ds0_acpi_match[] = {
>> +	{"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME},
>> +	{ },
>> +};
>> +MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match);
>> +#endif
>> +
>>   static const struct regmap_config st_lsm9ds0_regmap_config = {
>>   	.reg_bits	= 8,
>>   	.val_bits	= 8,
>> @@ -72,6 +81,7 @@ static struct spi_driver st_lsm9ds0_driver = {
>>   	.driver = {
>>   		.name = "st-lsm9ds0-spi",
>>   		.of_match_table = st_lsm9ds0_of_match,
>> +		.acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match),
>>   	},
>>   	.probe = st_lsm9ds0_spi_probe,
>>   	.id_table = st_lsm9ds0_id_table,
diff mbox series

Patch

diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
index 64fa77d302e2..79be8d28d965 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
@@ -12,6 +12,7 @@ 
 #include <linux/module.h>
 #include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
+#include <linux/acpi.h>
 
 #include <linux/iio/common/st_sensors_i2c.h>
 
@@ -37,6 +38,14 @@  static const struct i2c_device_id st_lsm9ds0_id_table[] = {
 };
 MODULE_DEVICE_TABLE(i2c, st_lsm9ds0_id_table);
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id st_lsm9ds0_acpi_match[] = {
+	{"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME},
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match);
+#endif
+
 static const struct regmap_config st_lsm9ds0_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -73,6 +82,7 @@  static struct i2c_driver st_lsm9ds0_driver = {
 	.driver = {
 		.name = "st-lsm9ds0-i2c",
 		.of_match_table = st_lsm9ds0_of_match,
+		.acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match),
 	},
 	.probe_new = st_lsm9ds0_i2c_probe,
 	.id_table = st_lsm9ds0_id_table,
diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
index 997b5ff792be..27c5d99ce0e3 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
@@ -12,6 +12,7 @@ 
 #include <linux/mod_devicetable.h>
 #include <linux/regmap.h>
 #include <linux/spi/spi.h>
+#include <linux/acpi.h>
 
 #include <linux/iio/common/st_sensors_spi.h>
 
@@ -37,6 +38,14 @@  static const struct spi_device_id st_lsm9ds0_id_table[] = {
 };
 MODULE_DEVICE_TABLE(spi, st_lsm9ds0_id_table);
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id st_lsm9ds0_acpi_match[] = {
+	{"ACCL0001", (kernel_ulong_t)LSM303D_IMU_DEV_NAME},
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, st_lsm9ds0_acpi_match);
+#endif
+
 static const struct regmap_config st_lsm9ds0_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -72,6 +81,7 @@  static struct spi_driver st_lsm9ds0_driver = {
 	.driver = {
 		.name = "st-lsm9ds0-spi",
 		.of_match_table = st_lsm9ds0_of_match,
+		.acpi_match_table = ACPI_PTR(st_lsm9ds0_acpi_match),
 	},
 	.probe = st_lsm9ds0_spi_probe,
 	.id_table = st_lsm9ds0_id_table,