diff mbox series

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

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

Commit Message

Marius Hoch April 15, 2023, 11:11 p.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 | 7 +++++++
 drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c | 7 +++++++
 2 files changed, 14 insertions(+)

Comments

Linus Walleij April 21, 2023, 8:43 a.m. UTC | #1
On Sun, Apr 16, 2023 at 1:12 AM 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>

Acked-by: Linus Walleij <linus.walleij@linaro.org>

Yours,
Linus Walleij
Marius Hoch May 2, 2023, 2:51 p.m. UTC | #2
Hi,

On 16/04/2023 01:11, Marius Hoch wrote:
<snip>
> diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> index 997b5ff792be..55f3738193af 100644
> --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> @@ -37,6 +37,12 @@ static const struct spi_device_id st_lsm9ds0_id_table[] = {
>   };
>   MODULE_DEVICE_TABLE(spi, st_lsm9ds0_id_table);
>   
> +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);
> +
>   static const struct regmap_config st_lsm9ds0_regmap_config = {
>   	.reg_bits	= 8,
>   	.val_bits	= 8,
> @@ -72,6 +78,7 @@ static struct spi_driver st_lsm9ds0_driver = {
>   	.driver = {
>   		.name = "st-lsm9ds0-spi",
>   		.of_match_table = st_lsm9ds0_of_match,
> +		.acpi_match_table = st_lsm9ds0_acpi_match,
>   	},
>   	.probe = st_lsm9ds0_spi_probe,
>   	.id_table = st_lsm9ds0_id_table,
I just realized that these changes (the SPI ones, not the I2C ones) are 
entirely superfluous, and I'm not sure why I added this in the first 
place. In the Lenovo Yoga Tablet 2 series (which seem to be the only 
devices exposing this as "ACCL0001"), the device is accessible via I2C. 
Just to make sure, I re-tested the patch chain without this change.

@Jonathan: Shall I upload an entirely new patch set (v4), do this in a 
separate new clean up commit, or do you want to just drop these changes 
to drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c? I'm fine with any of 
these options.

Cheers,
Marius
Jonathan Cameron May 7, 2023, 1:50 p.m. UTC | #3
On Tue, 2 May 2023 16:51:42 +0200
Marius Hoch <mail@mariushoch.de> wrote:

> Hi,
> 
> On 16/04/2023 01:11, Marius Hoch wrote:
> <snip>
> > diff --git a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> > index 997b5ff792be..55f3738193af 100644
> > --- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> > +++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
> > @@ -37,6 +37,12 @@ static const struct spi_device_id st_lsm9ds0_id_table[] = {
> >   };
> >   MODULE_DEVICE_TABLE(spi, st_lsm9ds0_id_table);
> >   
> > +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);
> > +
> >   static const struct regmap_config st_lsm9ds0_regmap_config = {
> >   	.reg_bits	= 8,
> >   	.val_bits	= 8,
> > @@ -72,6 +78,7 @@ static struct spi_driver st_lsm9ds0_driver = {
> >   	.driver = {
> >   		.name = "st-lsm9ds0-spi",
> >   		.of_match_table = st_lsm9ds0_of_match,
> > +		.acpi_match_table = st_lsm9ds0_acpi_match,
> >   	},
> >   	.probe = st_lsm9ds0_spi_probe,
> >   	.id_table = st_lsm9ds0_id_table,  
> I just realized that these changes (the SPI ones, not the I2C ones) are 
> entirely superfluous, and I'm not sure why I added this in the first 
> place. In the Lenovo Yoga Tablet 2 series (which seem to be the only 
> devices exposing this as "ACCL0001"), the device is accessible via I2C. 
> Just to make sure, I re-tested the patch chain without this change.
> 
> @Jonathan: Shall I upload an entirely new patch set (v4), do this in a 
> separate new clean up commit, or do you want to just drop these changes 
> to drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c? I'm fine with any of 
> these options.

I'll drop it and push out a new version of the togreg tree.

Thanks for pointing this out.

Jonathan

> 
> Cheers,
> Marius
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..52f1ea6c457f 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_i2c.c
@@ -37,6 +37,12 @@  static const struct i2c_device_id st_lsm9ds0_id_table[] = {
 };
 MODULE_DEVICE_TABLE(i2c, st_lsm9ds0_id_table);
 
+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);
+
 static const struct regmap_config st_lsm9ds0_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -73,6 +79,7 @@  static struct i2c_driver st_lsm9ds0_driver = {
 	.driver = {
 		.name = "st-lsm9ds0-i2c",
 		.of_match_table = st_lsm9ds0_of_match,
+		.acpi_match_table = 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..55f3738193af 100644
--- a/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
+++ b/drivers/iio/imu/st_lsm9ds0/st_lsm9ds0_spi.c
@@ -37,6 +37,12 @@  static const struct spi_device_id st_lsm9ds0_id_table[] = {
 };
 MODULE_DEVICE_TABLE(spi, st_lsm9ds0_id_table);
 
+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);
+
 static const struct regmap_config st_lsm9ds0_regmap_config = {
 	.reg_bits	= 8,
 	.val_bits	= 8,
@@ -72,6 +78,7 @@  static struct spi_driver st_lsm9ds0_driver = {
 	.driver = {
 		.name = "st-lsm9ds0-spi",
 		.of_match_table = st_lsm9ds0_of_match,
+		.acpi_match_table = st_lsm9ds0_acpi_match,
 	},
 	.probe = st_lsm9ds0_spi_probe,
 	.id_table = st_lsm9ds0_id_table,