linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Clarify proximity output value interpretation
@ 2015-06-11 15:49 Daniel Baluta
  2015-06-11 15:49 ` [PATCH 1/2] iio: ABI: Clarify proximity output value Daniel Baluta
  2015-06-11 15:49 ` [PATCH 2/2] iio: proximity: sx9500: Fix proximity value Daniel Baluta
  0 siblings, 2 replies; 8+ messages in thread
From: Daniel Baluta @ 2015-06-11 15:49 UTC (permalink / raw)
  To: jic23, pmeerw, vlad.dogaru, tiberiu.a.breana
  Cc: knaack.h, lars, linux-kernel, linux-iio

Proximity sensors indicate high values for closer objects and vice-versa.
This patchset clarifies the ABI and fixes the SX9500 sensor.

We have 5 proximity sensors that got this right (gp2ap020a00f, jsa1212,
vcnl4000, cm36651, ltr501) and 2 that got it wrong (stk3310 and
sx9500).

For SX9500 the fix was trivial and it is included here, for stk3310 there
are more things to do and will try to fix in the near future.

Daniel Baluta (2):
  iio: ABI: Clarify proximity output value
  iio: proximity: sx9500: Fix proximity value

 Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
 drivers/iio/proximity/sx9500.c          | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

-- 
1.9.1


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

* [PATCH 1/2] iio: ABI: Clarify proximity output value
  2015-06-11 15:49 [PATCH 0/2] Clarify proximity output value interpretation Daniel Baluta
@ 2015-06-11 15:49 ` Daniel Baluta
  2015-06-16 20:41   ` Peter Meerwald
  2015-06-11 15:49 ` [PATCH 2/2] iio: proximity: sx9500: Fix proximity value Daniel Baluta
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Baluta @ 2015-06-11 15:49 UTC (permalink / raw)
  To: jic23, pmeerw, vlad.dogaru, tiberiu.a.breana
  Cc: knaack.h, lars, linux-kernel, linux-iio

Current description for proximity measurement is ambiguous. While
the first part says that proximity is measured by observing
reflectivity, the second part incorrectly infers that reported values
should behave like a distance.

This is because of AS3935 lightning sensor which uses the proximity
API, while not being a true proximity sensor.

Fixes:  614e8842ddf ("iio: ABI: add clarification for proximity")
Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
---
 Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index bbed111..70c9b1a 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -1234,10 +1234,8 @@ Description:
 		object is near the sensor, usually be observing
 		reflectivity of infrared or ultrasound emitted.
 		Often these sensors are unit less and as such conversion
-		to SI units is not possible.  Where it is, the units should
-		be meters.  If such a conversion is not possible, the reported
-		values should behave in the same way as a distance, i.e. lower
-		values indicate something is closer to the sensor.
+		to SI units is not possible. Higher proximity measurements
+		indicate closer objects, and vice versa.
 
 What:		/sys/.../iio:deviceX/in_illuminance_input
 What:		/sys/.../iio:deviceX/in_illuminance_raw
-- 
1.9.1


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

* [PATCH 2/2] iio: proximity: sx9500: Fix proximity value
  2015-06-11 15:49 [PATCH 0/2] Clarify proximity output value interpretation Daniel Baluta
  2015-06-11 15:49 ` [PATCH 1/2] iio: ABI: Clarify proximity output value Daniel Baluta
@ 2015-06-11 15:49 ` Daniel Baluta
  2015-06-12  7:40   ` Vlad Dogaru
  1 sibling, 1 reply; 8+ messages in thread
From: Daniel Baluta @ 2015-06-11 15:49 UTC (permalink / raw)
  To: jic23, pmeerw, vlad.dogaru, tiberiu.a.breana
  Cc: knaack.h, lars, linux-kernel, linux-iio

Because of the ABI confusion proximity value exposed by SX9500
was inverted.

Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
---
 drivers/iio/proximity/sx9500.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index 2042e37..01494cd 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data,
 	if (ret < 0)
 		return ret;
 
-	*val = 32767 - (s16)be16_to_cpu(regval);
+	*val = be16_to_cpu(regval);
 
 	return IIO_VAL_INT;
 }
-- 
1.9.1


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

* Re: [PATCH 2/2] iio: proximity: sx9500: Fix proximity value
  2015-06-11 15:49 ` [PATCH 2/2] iio: proximity: sx9500: Fix proximity value Daniel Baluta
@ 2015-06-12  7:40   ` Vlad Dogaru
  2015-06-13 18:21     ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Vlad Dogaru @ 2015-06-12  7:40 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: jic23, pmeerw, tiberiu.a.breana, knaack.h, lars, linux-kernel, linux-iio

On Thu, Jun 11, 2015 at 06:49:34PM +0300, Daniel Baluta wrote:
> Because of the ABI confusion proximity value exposed by SX9500
> was inverted.
> 
> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>

Reviewed-by: Vlad Dogaru <vlad.dogaru@intel.com>

Sorry for causing the confusion, it was the only proximity sensor I had
encountered to date.

> ---
>  drivers/iio/proximity/sx9500.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
> index 2042e37..01494cd 100644
> --- a/drivers/iio/proximity/sx9500.c
> +++ b/drivers/iio/proximity/sx9500.c
> @@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data,
>  	if (ret < 0)
>  		return ret;
>  
> -	*val = 32767 - (s16)be16_to_cpu(regval);
> +	*val = be16_to_cpu(regval);
>  
>  	return IIO_VAL_INT;
>  }
> -- 
> 1.9.1
> 

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

* Re: [PATCH 2/2] iio: proximity: sx9500: Fix proximity value
  2015-06-12  7:40   ` Vlad Dogaru
@ 2015-06-13 18:21     ` Jonathan Cameron
  2015-06-13 18:32       ` Daniel Baluta
  0 siblings, 1 reply; 8+ messages in thread
From: Jonathan Cameron @ 2015-06-13 18:21 UTC (permalink / raw)
  To: Vlad Dogaru, Daniel Baluta
  Cc: pmeerw, tiberiu.a.breana, knaack.h, lars, linux-kernel,
	linux-iio, Greg KH

On 12/06/15 08:40, Vlad Dogaru wrote:
> On Thu, Jun 11, 2015 at 06:49:34PM +0300, Daniel Baluta wrote:
>> Because of the ABI confusion proximity value exposed by SX9500
>> was inverted.
>>
>> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
> 
> Reviewed-by: Vlad Dogaru <vlad.dogaru@intel.com>
> 
> Sorry for causing the confusion, it was the only proximity sensor I had
> encountered to date.
Greg,

I've cc'd you to let you know that this fix causes an ABI change for
one driver.  Technically that driver actually matched with the current documentation,
just the documentation was misleading and lots of drivers have ended up with
the reverse interpretation (question was whether proximity values get larger
or smaller as you get nearer). 

Anyhow, given timing I doubt the pull request will reach you until after the
merge window.  I am also going to mark this for stable to cover the 4.0 and 4.1
kernels that have this driver in them.

Hope that's fine!

Applied to the fixes-togreg branch of iio.git

Daniel, thanks for clearing this mess up and checking through all the drivers
and datasheets to figure out it was only this one!

Jonathan

> 
>> ---
>>  drivers/iio/proximity/sx9500.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
>> index 2042e37..01494cd 100644
>> --- a/drivers/iio/proximity/sx9500.c
>> +++ b/drivers/iio/proximity/sx9500.c
>> @@ -281,7 +281,7 @@ static int sx9500_read_prox_data(struct sx9500_data *data,
>>  	if (ret < 0)
>>  		return ret;
>>  
>> -	*val = 32767 - (s16)be16_to_cpu(regval);
>> +	*val = be16_to_cpu(regval);
>>  
>>  	return IIO_VAL_INT;
>>  }
>> -- 
>> 1.9.1
>>


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

* Re: [PATCH 2/2] iio: proximity: sx9500: Fix proximity value
  2015-06-13 18:21     ` Jonathan Cameron
@ 2015-06-13 18:32       ` Daniel Baluta
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Baluta @ 2015-06-13 18:32 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Vlad Dogaru, Daniel Baluta, Peter Meerwald, Tiberiu Breana,
	Hartmut Knaack, Lars-Peter Clausen, Linux Kernel Mailing List,
	linux-iio, Greg KH

On Sat, Jun 13, 2015 at 9:21 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> On 12/06/15 08:40, Vlad Dogaru wrote:
>> On Thu, Jun 11, 2015 at 06:49:34PM +0300, Daniel Baluta wrote:
>>> Because of the ABI confusion proximity value exposed by SX9500
>>> was inverted.
>>>
>>> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>>
>> Reviewed-by: Vlad Dogaru <vlad.dogaru@intel.com>
>>
>> Sorry for causing the confusion, it was the only proximity sensor I had
>> encountered to date.
> Greg,
>
> I've cc'd you to let you know that this fix causes an ABI change for
> one driver.  Technically that driver actually matched with the current documentation,
> just the documentation was misleading and lots of drivers have ended up with
> the reverse interpretation (question was whether proximity values get larger
> or smaller as you get nearer).
>
> Anyhow, given timing I doubt the pull request will reach you until after the
> merge window.  I am also going to mark this for stable to cover the 4.0 and 4.1
> kernels that have this driver in them.
>
> Hope that's fine!
>
> Applied to the fixes-togreg branch of iio.git
>
> Daniel, thanks for clearing this mess up and checking through all the drivers
> and datasheets to figure out it was only this one!

You are welcome. Also, lets not forget that as mentioned in the cover letter
there is still one driver that needs to be fixed. That is stk3310,
where the fix is not
trivial, but I have already talked with Tiberiu and he will take care of it.

thanks,
Daniel.

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

* Re: [PATCH 1/2] iio: ABI: Clarify proximity output value
  2015-06-11 15:49 ` [PATCH 1/2] iio: ABI: Clarify proximity output value Daniel Baluta
@ 2015-06-16 20:41   ` Peter Meerwald
  2015-06-21 13:39     ` Jonathan Cameron
  0 siblings, 1 reply; 8+ messages in thread
From: Peter Meerwald @ 2015-06-16 20:41 UTC (permalink / raw)
  To: Daniel Baluta
  Cc: jic23, vlad.dogaru, tiberiu.a.breana, knaack.h, lars,
	linux-kernel, linux-iio

Hello,

> Current description for proximity measurement is ambiguous. While
> the first part says that proximity is measured by observing
> reflectivity, the second part incorrectly infers that reported values
> should behave like a distance.
> 
> This is because of AS3935 lightning sensor which uses the proximity
> API, while not being a true proximity sensor.

Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
 
> Fixes:  614e8842ddf ("iio: ABI: add clarification for proximity")
> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
> ---
>  Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
> index bbed111..70c9b1a 100644
> --- a/Documentation/ABI/testing/sysfs-bus-iio
> +++ b/Documentation/ABI/testing/sysfs-bus-iio
> @@ -1234,10 +1234,8 @@ Description:
>  		object is near the sensor, usually be observing

>  		reflectivity of infrared or ultrasound emitted.
>  		Often these sensors are unit less and as such conversion
> -		to SI units is not possible.  Where it is, the units should
> -		be meters.  If such a conversion is not possible, the reported
> -		values should behave in the same way as a distance, i.e. lower
> -		values indicate something is closer to the sensor.
> +		to SI units is not possible. Higher proximity measurements
> +		indicate closer objects, and vice versa.
>  
>  What:		/sys/.../iio:deviceX/in_illuminance_input
>  What:		/sys/.../iio:deviceX/in_illuminance_raw
> 

-- 

Peter Meerwald
+43-664-2444418 (mobile)

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

* Re: [PATCH 1/2] iio: ABI: Clarify proximity output value
  2015-06-16 20:41   ` Peter Meerwald
@ 2015-06-21 13:39     ` Jonathan Cameron
  0 siblings, 0 replies; 8+ messages in thread
From: Jonathan Cameron @ 2015-06-21 13:39 UTC (permalink / raw)
  To: Peter Meerwald, Daniel Baluta
  Cc: vlad.dogaru, tiberiu.a.breana, knaack.h, lars, linux-kernel, linux-iio

On 16/06/15 21:41, Peter Meerwald wrote:
> Hello,
> 
>> Current description for proximity measurement is ambiguous. While
>> the first part says that proximity is measured by observing
>> reflectivity, the second part incorrectly infers that reported values
>> should behave like a distance.
>>
>> This is because of AS3935 lightning sensor which uses the proximity
>> API, while not being a true proximity sensor.
> 
> Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
Thanks Peter, this will stand for the record on the mailing list, but
now the patch is in a public (non testing tree) I'm not going to rebase
to add it to the patch.

Sorry about that, but 3 days too late :(

Jonathan
>  
>> Fixes:  614e8842ddf ("iio: ABI: add clarification for proximity")
>> Signed-off-by: Daniel Baluta <daniel.baluta@intel.com>
>> ---
>>  Documentation/ABI/testing/sysfs-bus-iio | 6 ++----
>>  1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
>> index bbed111..70c9b1a 100644
>> --- a/Documentation/ABI/testing/sysfs-bus-iio
>> +++ b/Documentation/ABI/testing/sysfs-bus-iio
>> @@ -1234,10 +1234,8 @@ Description:
>>  		object is near the sensor, usually be observing
> 
>>  		reflectivity of infrared or ultrasound emitted.
>>  		Often these sensors are unit less and as such conversion
>> -		to SI units is not possible.  Where it is, the units should
>> -		be meters.  If such a conversion is not possible, the reported
>> -		values should behave in the same way as a distance, i.e. lower
>> -		values indicate something is closer to the sensor.
>> +		to SI units is not possible. Higher proximity measurements
>> +		indicate closer objects, and vice versa.
>>  
>>  What:		/sys/.../iio:deviceX/in_illuminance_input
>>  What:		/sys/.../iio:deviceX/in_illuminance_raw
>>
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

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

end of thread, other threads:[~2015-06-21 13:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-11 15:49 [PATCH 0/2] Clarify proximity output value interpretation Daniel Baluta
2015-06-11 15:49 ` [PATCH 1/2] iio: ABI: Clarify proximity output value Daniel Baluta
2015-06-16 20:41   ` Peter Meerwald
2015-06-21 13:39     ` Jonathan Cameron
2015-06-11 15:49 ` [PATCH 2/2] iio: proximity: sx9500: Fix proximity value Daniel Baluta
2015-06-12  7:40   ` Vlad Dogaru
2015-06-13 18:21     ` Jonathan Cameron
2015-06-13 18:32       ` Daniel Baluta

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).