All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] iio: accel: add support for LIS302DL variant
@ 2022-02-27 22:36 Sicelo A. Mhlongo
  2022-02-28 10:20 ` Jonathan Cameron
  0 siblings, 1 reply; 3+ messages in thread
From: Sicelo A. Mhlongo @ 2022-02-27 22:36 UTC (permalink / raw)
  To: Jonathan Cameron, Lars-Peter Clausen, linux-iio, Linus Walleij

Add support for STMicroelectronics LIS302DL accelerometer to the st_accel
framework.

https://www.st.com/resource/en/datasheet/lis302dl.pdf

Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
---
 drivers/iio/accel/st_accel.h      | 2 ++
 drivers/iio/accel/st_accel_core.c | 1 +
 drivers/iio/accel/st_accel_i2c.c  | 5 +++++
 3 files changed, 8 insertions(+)

diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
index 8750dea56fcb..15f4b7944362 100644
--- a/drivers/iio/accel/st_accel.h
+++ b/drivers/iio/accel/st_accel.h
@@ -37,6 +37,7 @@ enum st_accel_type {
 	LIS2DE12,
 	LIS2HH12,
 	ST_ACCEL_MAX,
+	LIS302DL,
 };
 
 #define H3LIS331DL_ACCEL_DEV_NAME	"h3lis331dl_accel"
@@ -61,6 +62,7 @@ enum st_accel_type {
 #define LIS3DE_ACCEL_DEV_NAME		"lis3de"
 #define LIS2DE12_ACCEL_DEV_NAME		"lis2de12"
 #define LIS2HH12_ACCEL_DEV_NAME		"lis2hh12"
+#define LIS302DL_ACCEL_DEV_NAME		"lis302dl"
 
 #ifdef CONFIG_IIO_BUFFER
 int st_accel_allocate_ring(struct iio_dev *indio_dev);
diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 31ea19d0ba71..2a353c51c84a 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -444,6 +444,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
 		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
 		.sensors_supported = {
 			[0] = LIS331DL_ACCEL_DEV_NAME,
+			[1] = LIS302DL_ACCEL_DEV_NAME,
 		},
 		.ch = (struct iio_chan_spec *)st_accel_8bit_channels,
 		.odr = {
diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
index c0ce78eebad9..086e8af89e18 100644
--- a/drivers/iio/accel/st_accel_i2c.c
+++ b/drivers/iio/accel/st_accel_i2c.c
@@ -107,6 +107,10 @@ static const struct of_device_id st_accel_of_match[] = {
 		.compatible = "st,lis2hh12",
 		.data = LIS2HH12_ACCEL_DEV_NAME,
 	},
+	{
+		.compatible = "st,lis302dl",
+		.data = LIS302DL_ACCEL_DEV_NAME,
+	},
 	{},
 };
 MODULE_DEVICE_TABLE(of, st_accel_of_match);
@@ -142,6 +146,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
 	{ LIS3DE_ACCEL_DEV_NAME },
 	{ LIS2DE12_ACCEL_DEV_NAME },
 	{ LIS2HH12_ACCEL_DEV_NAME },
+	{ LIS302DL_ACCEL_DEV_NAME },
 	{},
 };
 MODULE_DEVICE_TABLE(i2c, st_accel_id_table);
-- 
2.35.1


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

* Re: [PATCH 1/2] iio: accel: add support for LIS302DL variant
  2022-02-27 22:36 [PATCH 1/2] iio: accel: add support for LIS302DL variant Sicelo A. Mhlongo
@ 2022-02-28 10:20 ` Jonathan Cameron
  2022-02-28 13:47   ` Sicelo
  0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Cameron @ 2022-02-28 10:20 UTC (permalink / raw)
  To: Sicelo A. Mhlongo
  Cc: Jonathan Cameron, Lars-Peter Clausen, linux-iio, Linus Walleij

On Mon, 28 Feb 2022 00:36:42 +0200
"Sicelo A. Mhlongo" <absicsz@gmail.com> wrote:

> Add support for STMicroelectronics LIS302DL accelerometer to the st_accel
> framework.
> 
> https://www.st.com/resource/en/datasheet/lis302dl.pdf
> 
> Signed-off-by: Sicelo A. Mhlongo <absicsz@gmail.com>
> ---
>  drivers/iio/accel/st_accel.h      | 2 ++
>  drivers/iio/accel/st_accel_core.c | 1 +
>  drivers/iio/accel/st_accel_i2c.c  | 5 +++++
>  3 files changed, 8 insertions(+)
> 
> diff --git a/drivers/iio/accel/st_accel.h b/drivers/iio/accel/st_accel.h
> index 8750dea56fcb..15f4b7944362 100644
> --- a/drivers/iio/accel/st_accel.h
> +++ b/drivers/iio/accel/st_accel.h
> @@ -37,6 +37,7 @@ enum st_accel_type {
>  	LIS2DE12,
>  	LIS2HH12,
>  	ST_ACCEL_MAX,

Think about what ST_ACCEL_MAX is for...

You'll want to be above that.

However, more interestingly nothing actually uses this enum, so
you could post a precursor patch that gets rid of it entirely.

Jonathan

> +	LIS302DL,
>  };
>  
>  #define H3LIS331DL_ACCEL_DEV_NAME	"h3lis331dl_accel"
> @@ -61,6 +62,7 @@ enum st_accel_type {
>  #define LIS3DE_ACCEL_DEV_NAME		"lis3de"
>  #define LIS2DE12_ACCEL_DEV_NAME		"lis2de12"
>  #define LIS2HH12_ACCEL_DEV_NAME		"lis2hh12"
> +#define LIS302DL_ACCEL_DEV_NAME		"lis302dl"
>  
>  #ifdef CONFIG_IIO_BUFFER
>  int st_accel_allocate_ring(struct iio_dev *indio_dev);
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 31ea19d0ba71..2a353c51c84a 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -444,6 +444,7 @@ static const struct st_sensor_settings st_accel_sensors_settings[] = {
>  		.wai_addr = ST_SENSORS_DEFAULT_WAI_ADDRESS,
>  		.sensors_supported = {
>  			[0] = LIS331DL_ACCEL_DEV_NAME,
> +			[1] = LIS302DL_ACCEL_DEV_NAME,
>  		},
>  		.ch = (struct iio_chan_spec *)st_accel_8bit_channels,
>  		.odr = {
> diff --git a/drivers/iio/accel/st_accel_i2c.c b/drivers/iio/accel/st_accel_i2c.c
> index c0ce78eebad9..086e8af89e18 100644
> --- a/drivers/iio/accel/st_accel_i2c.c
> +++ b/drivers/iio/accel/st_accel_i2c.c
> @@ -107,6 +107,10 @@ static const struct of_device_id st_accel_of_match[] = {
>  		.compatible = "st,lis2hh12",
>  		.data = LIS2HH12_ACCEL_DEV_NAME,
>  	},
> +	{
> +		.compatible = "st,lis302dl",
> +		.data = LIS302DL_ACCEL_DEV_NAME,
> +	},
>  	{},
>  };
>  MODULE_DEVICE_TABLE(of, st_accel_of_match);
> @@ -142,6 +146,7 @@ static const struct i2c_device_id st_accel_id_table[] = {
>  	{ LIS3DE_ACCEL_DEV_NAME },
>  	{ LIS2DE12_ACCEL_DEV_NAME },
>  	{ LIS2HH12_ACCEL_DEV_NAME },
> +	{ LIS302DL_ACCEL_DEV_NAME },
>  	{},
>  };
>  MODULE_DEVICE_TABLE(i2c, st_accel_id_table);


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

* Re: [PATCH 1/2] iio: accel: add support for LIS302DL variant
  2022-02-28 10:20 ` Jonathan Cameron
@ 2022-02-28 13:47   ` Sicelo
  0 siblings, 0 replies; 3+ messages in thread
From: Sicelo @ 2022-02-28 13:47 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: Lars-Peter Clausen, linux-iio, Linus Walleij

Hi Jonathan

Thank you very much for your review.

On Mon, Feb 28, 2022 at 10:20:21AM +0000, Jonathan Cameron wrote:
> >  	LIS2HH12,
> >  	ST_ACCEL_MAX,
> 
> Think about what ST_ACCEL_MAX is for...
> 
> You'll want to be above that.

I missed this. Thanks for pointing out. I'll prepare a v2.

> However, more interestingly nothing actually uses this enum, so
> you could post a precursor patch that gets rid of it entirely.

Indeed. I noticed this, but thought it had been added for some reason,
or future use. If you agree that removal makes sense, I'll submit that
too.

Also, I have also learned that I should have sent the patch for the
dt_bindings [1] as 1/2 instead of 2/2 as I did. Sincere apologies.

[1] https://lore.kernel.org/linux-iio/Yhv9M%2FaXptQSKQju@tp440p.steeds.sam/T/#u

Regards
Sicelo

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

end of thread, other threads:[~2022-02-28 13:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-27 22:36 [PATCH 1/2] iio: accel: add support for LIS302DL variant Sicelo A. Mhlongo
2022-02-28 10:20 ` Jonathan Cameron
2022-02-28 13:47   ` Sicelo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.