linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
@ 2015-05-19 13:37 Linus Walleij
  2015-05-23 11:33 ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2015-05-19 13:37 UTC (permalink / raw)
  To: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio, Denis CIOCCA
  Cc: Lee Jones, Linus Walleij

Some sensors like the LIS331DL only support 8bit data by a single
register per axis. These utilize the MSB byte. Make it possible
to register these apropriately.

A oneliner change is needed in the ST sensors core to handle 8bit
reads as this is the first supported 8bit sensor.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
ChangeLog v1->v2:
- Change the .storage type to 8 bits.
- Alter the st_sensors_core to cast the byte properly to a signed
  int.
---
 drivers/iio/accel/st_accel_core.c               | 16 ++++++++++++++++
 drivers/iio/common/st_sensors/st_sensors_core.c |  4 +++-
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
index 58d1d13d552a..ad19fb4304df 100644
--- a/drivers/iio/accel/st_accel_core.c
+++ b/drivers/iio/accel/st_accel_core.c
@@ -153,6 +153,22 @@
 #define ST_ACCEL_4_IG1_EN_MASK			0x08
 #define ST_ACCEL_4_MULTIREAD_BIT		true
 
+static const struct iio_chan_spec st_accel_8bit_channels[] = {
+	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+			ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 8,
+			ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1),
+	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+			ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 8, 8,
+			ST_ACCEL_DEFAULT_OUT_Y_L_ADDR+1),
+	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
+			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
+			ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 8, 8,
+			ST_ACCEL_DEFAULT_OUT_Z_L_ADDR+1),
+	IIO_CHAN_SOFT_TIMESTAMP(3)
+};
+
 static const struct iio_chan_spec st_accel_12bit_channels[] = {
 	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
 			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 7973c0457042..9007b618d434 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -434,7 +434,9 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev,
 	if (err < 0)
 		goto st_sensors_free_memory;
 
-	if (byte_for_channel == 2)
+	if (byte_for_channel == 1)
+		*data = (s8)*outdata;
+	else if (byte_for_channel == 2)
 		*data = (s16)get_unaligned_le16(outdata);
 	else if (byte_for_channel == 3)
 		*data = (s32)st_sensors_get_unaligned_le24(outdata);
-- 
1.9.3


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

* Re: [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
  2015-05-19 13:37 [PATCH 1/2 v2] iio: st_accel: support 8bit channel data Linus Walleij
@ 2015-05-23 11:33 ` Jonathan Cameron
  2015-06-04  7:13   ` Linus Walleij
  0 siblings, 1 reply; 7+ messages in thread
From: Jonathan Cameron @ 2015-05-23 11:33 UTC (permalink / raw)
  To: Linus Walleij, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald,
	linux-iio, Denis CIOCCA
  Cc: Lee Jones

On 19/05/15 14:37, Linus Walleij wrote:
> Some sensors like the LIS331DL only support 8bit data by a single
> register per axis. These utilize the MSB byte. Make it possible
> to register these apropriately.
> 
> A oneliner change is needed in the ST sensors core to handle 8bit
> reads as this is the first supported 8bit sensor.
> 
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Looks good to me.  I'll let these sit for a few days though to
give Denis and others a chance to check them out before I apply them.

Thanks
Jonathan 
> ---
> ChangeLog v1->v2:
> - Change the .storage type to 8 bits.
> - Alter the st_sensors_core to cast the byte properly to a signed
>   int.
> ---
>  drivers/iio/accel/st_accel_core.c               | 16 ++++++++++++++++
>  drivers/iio/common/st_sensors/st_sensors_core.c |  4 +++-
>  2 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c
> index 58d1d13d552a..ad19fb4304df 100644
> --- a/drivers/iio/accel/st_accel_core.c
> +++ b/drivers/iio/accel/st_accel_core.c
> @@ -153,6 +153,22 @@
>  #define ST_ACCEL_4_IG1_EN_MASK			0x08
>  #define ST_ACCEL_4_MULTIREAD_BIT		true
>  
> +static const struct iio_chan_spec st_accel_8bit_channels[] = {
> +	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +			ST_SENSORS_SCAN_X, 1, IIO_MOD_X, 's', IIO_LE, 8, 8,
> +			ST_ACCEL_DEFAULT_OUT_X_L_ADDR+1),
> +	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +			ST_SENSORS_SCAN_Y, 1, IIO_MOD_Y, 's', IIO_LE, 8, 8,
> +			ST_ACCEL_DEFAULT_OUT_Y_L_ADDR+1),
> +	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
> +			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> +			ST_SENSORS_SCAN_Z, 1, IIO_MOD_Z, 's', IIO_LE, 8, 8,
> +			ST_ACCEL_DEFAULT_OUT_Z_L_ADDR+1),
> +	IIO_CHAN_SOFT_TIMESTAMP(3)
> +};
> +
>  static const struct iio_chan_spec st_accel_12bit_channels[] = {
>  	ST_SENSORS_LSM_CHANNELS(IIO_ACCEL,
>  			BIT(IIO_CHAN_INFO_RAW) | BIT(IIO_CHAN_INFO_SCALE),
> diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
> index 7973c0457042..9007b618d434 100644
> --- a/drivers/iio/common/st_sensors/st_sensors_core.c
> +++ b/drivers/iio/common/st_sensors/st_sensors_core.c
> @@ -434,7 +434,9 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev,
>  	if (err < 0)
>  		goto st_sensors_free_memory;
>  
> -	if (byte_for_channel == 2)
> +	if (byte_for_channel == 1)
> +		*data = (s8)*outdata;
> +	else if (byte_for_channel == 2)
>  		*data = (s16)get_unaligned_le16(outdata);
>  	else if (byte_for_channel == 3)
>  		*data = (s32)st_sensors_get_unaligned_le24(outdata);
> 


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

* Re: [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
  2015-05-23 11:33 ` Jonathan Cameron
@ 2015-06-04  7:13   ` Linus Walleij
  2015-06-04  7:14     ` Denis CIOCCA
  0 siblings, 1 reply; 7+ messages in thread
From: Linus Walleij @ 2015-06-04  7:13 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald,
	linux-iio@vger.kernel.org, Denis CIOCCA, Lee Jones

On Sat, May 23, 2015 at 1:33 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> On 19/05/15 14:37, Linus Walleij wrote:

>> Some sensors like the LIS331DL only support 8bit data by a single
>> register per axis. These utilize the MSB byte. Make it possible
>> to register these apropriately.
>>
>> A oneliner change is needed in the ST sensors core to handle 8bit
>> reads as this is the first supported 8bit sensor.
>>
>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>
> Looks good to me.  I'll let these sit for a few days though to
> give Denis and others a chance to check them out before I apply them.

It's been a few days. Ping on this!

Yours,
Linus Walleij

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

* Re: [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
  2015-06-04  7:13   ` Linus Walleij
@ 2015-06-04  7:14     ` Denis CIOCCA
  2015-06-04  7:24       ` Daniel Baluta
  0 siblings, 1 reply; 7+ messages in thread
From: Denis CIOCCA @ 2015-06-04  7:14 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Jonathan Cameron, Hartmut Knaack, Lars-Peter Clausen,
	Peter Meerwald, linux-iio@vger.kernel.org, Lee Jones

Sorry I checked but forget to answer...for me it is ok!

Acked.

Denis


> On Jun 4, 2015, at 15:13, Linus Walleij <linus.walleij@linaro.org> wrote:
> 
>> On Sat, May 23, 2015 at 1:33 PM, Jonathan Cameron <jic23@kernel.org> wrote:
>> On 19/05/15 14:37, Linus Walleij wrote:
> 
>>> Some sensors like the LIS331DL only support 8bit data by a single
>>> register per axis. These utilize the MSB byte. Make it possible
>>> to register these apropriately.
>>> 
>>> A oneliner change is needed in the ST sensors core to handle 8bit
>>> reads as this is the first supported 8bit sensor.
>>> 
>>> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
>> 
>> Looks good to me.  I'll let these sit for a few days though to
>> give Denis and others a chance to check them out before I apply them.
> 
> It's been a few days. Ping on this!
> 
> Yours,
> Linus Walleij

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

* Re: [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
  2015-06-04  7:14     ` Denis CIOCCA
@ 2015-06-04  7:24       ` Daniel Baluta
  2015-06-04  7:27         ` Denis CIOCCA
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Baluta @ 2015-06-04  7:24 UTC (permalink / raw)
  To: Denis CIOCCA
  Cc: Linus Walleij, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald, linux-iio@vger.kernel.org,
	Lee Jones

On Thu, Jun 4, 2015 at 10:14 AM, Denis CIOCCA <denis.ciocca@st.com> wrote:
> Sorry I checked but forget to answer...for me it is ok!
>
> Acked.
>
> Denis

Hi Denis,

A formal Ack for a Linux kernel patch should be as follows:

Acked-by: Your Name <youremail@address.com>

thanks,
Daniel.

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

* Re: [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
  2015-06-04  7:24       ` Daniel Baluta
@ 2015-06-04  7:27         ` Denis CIOCCA
  2015-06-07 16:59           ` Jonathan Cameron
  0 siblings, 1 reply; 7+ messages in thread
From: Denis CIOCCA @ 2015-06-04  7:27 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: Linus Walleij, Jonathan Cameron, Hartmut Knaack,
	Lars-Peter Clausen, Peter Meerwald, linux-iio@vger.kernel.org,
	Lee Jones

Hi Daniel,

Yes I know, I'm just using mobile phone...:)...not so easy to write.

Acked-by: Denis Ciocca <denis.ciocca@st.com>

Denis



> On Jun 4, 2015, at 15:24, Daniel Baluta <daniel.baluta@gmail.com> wrote:
> 
>> On Thu, Jun 4, 2015 at 10:14 AM, Denis CIOCCA <denis.ciocca@st.com> wrote:
>> Sorry I checked but forget to answer...for me it is ok!
>> 
>> Acked.
>> 
>> Denis
> 
> Hi Denis,
> 
> A formal Ack for a Linux kernel patch should be as follows:
> 
> Acked-by: Your Name <youremail@address.com>
> 
> thanks,
> Daniel.

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

* Re: [PATCH 1/2 v2] iio: st_accel: support 8bit channel data
  2015-06-04  7:27         ` Denis CIOCCA
@ 2015-06-07 16:59           ` Jonathan Cameron
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Cameron @ 2015-06-07 16:59 UTC (permalink / raw)
  To: Denis CIOCCA, Daniel Baluta
  Cc: Linus Walleij, Hartmut Knaack, Lars-Peter Clausen, Peter Meerwald,
	linux-iio@vger.kernel.org, Lee Jones

On 04/06/15 08:27, Denis CIOCCA wrote:
> Hi Daniel,
> 
> Yes I know, I'm just using mobile phone...:)...not so easy to write.
> 
> Acked-by: Denis Ciocca <denis.ciocca@st.com>
> 
> Denis
I know the feeling!  

Anyhow, applied to the togreg branch of iio.git - pushed out as testing
for the autobuilders to try breaking it.

Thanks,

Jonathan
> 
> 
> 
>> On Jun 4, 2015, at 15:24, Daniel Baluta <daniel.baluta@gmail.com> wrote:
>>
>>> On Thu, Jun 4, 2015 at 10:14 AM, Denis CIOCCA <denis.ciocca@st.com> wrote:
>>> Sorry I checked but forget to answer...for me it is ok!
>>>
>>> Acked.
>>>
>>> Denis
>>
>> Hi Denis,
>>
>> A formal Ack for a Linux kernel patch should be as follows:
>>
>> Acked-by: Your Name <youremail@address.com>
>>
>> thanks,
>> Daniel.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

end of thread, other threads:[~2015-06-07 16:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-19 13:37 [PATCH 1/2 v2] iio: st_accel: support 8bit channel data Linus Walleij
2015-05-23 11:33 ` Jonathan Cameron
2015-06-04  7:13   ` Linus Walleij
2015-06-04  7:14     ` Denis CIOCCA
2015-06-04  7:24       ` Daniel Baluta
2015-06-04  7:27         ` Denis CIOCCA
2015-06-07 16:59           ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).