Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1518797 > unrolled thread

[PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does

Started byBrian Masney <masneyb@onstation.org>
First post2016-11-10 10:40 +0100
Last post2016-11-12 18:20 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does Brian Masney <masneyb@onstation.org> - 2016-11-10 10:40 +0100
    Re: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to  match what the code does Jonathan Cameron <jic23@kernel.org> - 2016-11-12 17:40 +0100
      Re: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to  match what the code does Brian Masney <masneyb@onstation.org> - 2016-11-12 18:00 +0100
        Re: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to  match what the code does Jonathan Cameron <jic23@kernel.org> - 2016-11-12 18:20 +0100

#1518797 — [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does

FromBrian Masney <masneyb@onstation.org>
Date2016-11-10 10:40 +0100
Subject[PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does
Message-ID<sBTZU-3Mb-7@gated-at.bofh.it>
If channel 0 does not have any data, then the code sets the lux to zero.
The corresponding comment says that the last value is returned. This
updates the comment to correctly reflect what the code does.

Signed-off-by: Brian Masney <masneyb@onstation.org>
---
 drivers/staging/iio/light/tsl2583.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
index 52a39a6..390ff8b 100644
--- a/drivers/staging/iio/light/tsl2583.c
+++ b/drivers/staging/iio/light/tsl2583.c
@@ -221,7 +221,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
 		goto return_max;
 
 	if (!ch0) {
-		/* have no data, so return LAST VALUE */
+		/* have no data, so return 0 */
 		ret = 0;
 		chip->als_cur_info.lux = 0;
 		goto done;
-- 
2.7.4

[toc] | [next] | [standalone]


#1520269 — Re: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does

FromJonathan Cameron <jic23@kernel.org>
Date2016-11-12 17:40 +0100
SubjectRe: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does
Message-ID<sCJvs-4tA-15@gated-at.bofh.it>
In reply to#1518797
On 10/11/16 09:25, Brian Masney wrote:
> If channel 0 does not have any data, then the code sets the lux to zero.
> The corresponding comment says that the last value is returned. This
> updates the comment to correctly reflect what the code does.
> 
> Signed-off-by: Brian Masney <masneyb@onstation.org>
Better perhaps to just return an error, -EAGAIN perhaps?
I'm not sure why it would not give a value.
> ---
>  drivers/staging/iio/light/tsl2583.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/iio/light/tsl2583.c b/drivers/staging/iio/light/tsl2583.c
> index 52a39a6..390ff8b 100644
> --- a/drivers/staging/iio/light/tsl2583.c
> +++ b/drivers/staging/iio/light/tsl2583.c
> @@ -221,7 +221,7 @@ static int tsl2583_get_lux(struct iio_dev *indio_dev)
>  		goto return_max;
>  
>  	if (!ch0) {
> -		/* have no data, so return LAST VALUE */
> +		/* have no data, so return 0 */
>  		ret = 0;
>  		chip->als_cur_info.lux = 0;
>  		goto done;
> 

[toc] | [prev] | [next] | [standalone]


#1520278 — Re: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does

FromBrian Masney <masneyb@onstation.org>
Date2016-11-12 18:00 +0100
SubjectRe: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does
Message-ID<sCJOP-4AL-41@gated-at.bofh.it>
In reply to#1520269
On Sat, Nov 12, 2016 at 04:36:37PM +0000, Jonathan Cameron wrote:
> On 10/11/16 09:25, Brian Masney wrote:
> > If channel 0 does not have any data, then the code sets the lux to zero.
> > The corresponding comment says that the last value is returned. This
> > updates the comment to correctly reflect what the code does.
> > 
> > Signed-off-by: Brian Masney <masneyb@onstation.org>
> Better perhaps to just return an error, -EAGAIN perhaps?
> I'm not sure why it would not give a value.

This check is to avoid a division by zero. Here is the relevant code
that wasn't shown in the diff:

	if (!ch0) {
		/* have no data, so return 0 */
		ret = 0;
		chip->als_cur_info.lux = 0;
		goto done;
	}

	/* calculate ratio */
	ratio = (ch1 << 15) / ch0;

Channel 0 is sensitive to both infrared and visible light. In total
darkness, the sensor should return 0. Correct me if I am wrong, but
I believe that returning 0 here is more correct than -EAGAIN.

Brian

[toc] | [prev] | [next] | [standalone]


#1520287 — Re: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does

FromJonathan Cameron <jic23@kernel.org>
Date2016-11-12 18:20 +0100
SubjectRe: [PATCH v3 16/28] staging: iio: tsl2583: updated code comment to match what the code does
Message-ID<sCK8a-4X1-31@gated-at.bofh.it>
In reply to#1520278
On 12/11/16 16:59, Brian Masney wrote:
> On Sat, Nov 12, 2016 at 04:36:37PM +0000, Jonathan Cameron wrote:
>> On 10/11/16 09:25, Brian Masney wrote:
>>> If channel 0 does not have any data, then the code sets the lux to zero.
>>> The corresponding comment says that the last value is returned. This
>>> updates the comment to correctly reflect what the code does.
>>>
>>> Signed-off-by: Brian Masney <masneyb@onstation.org>
>> Better perhaps to just return an error, -EAGAIN perhaps?
>> I'm not sure why it would not give a value.
> 
> This check is to avoid a division by zero. Here is the relevant code
> that wasn't shown in the diff:
> 
> 	if (!ch0) {
> 		/* have no data, so return 0 */
> 		ret = 0;
> 		chip->als_cur_info.lux = 0;
> 		goto done;
> 	}
> 
> 	/* calculate ratio */
> 	ratio = (ch1 << 15) / ch0;
> 
> Channel 0 is sensitive to both infrared and visible light. In total
> darkness, the sensor should return 0. Correct me if I am wrong, but
> I believe that returning 0 here is more correct than -EAGAIN.
> 
> Brian
> 
Fair enough I hadn't understood that.  Maybe expand the comment
to cover that?

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web