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


Groups > linux.kernel > #1641064 > unrolled thread

[PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure

Started byNicholas Mc Guire <der.herr@hofr.at>
First post2017-05-14 10:50 +0200
Last post2017-05-14 16:30 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure Nicholas Mc Guire <der.herr@hofr.at> - 2017-05-14 10:50 +0200
    Re: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as  failure Peter Meerwald-Stadler <pmeerw@pmeerw.net> - 2017-05-14 11:50 +0200
      Re: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as  failure Nicholas Mc Guire <der.herr@hofr.at> - 2017-05-14 13:40 +0200
      Re: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as  failure Jonathan Cameron <jic23@kernel.org> - 2017-05-14 16:30 +0200

#1641064 — [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure

FromNicholas Mc Guire <der.herr@hofr.at>
Date2017-05-14 10:50 +0200
Subject[PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure
Message-ID<tGXnX-7Gi-1@gated-at.bofh.it>
If the timeout-case prints a warning message then probably the interrupted
case should also. Further, wait_for_completion_interruptible_timeout()
returns long not int. 

Fixes: commit 03b262f2bbf4 ("iio:pressure: initial zpa2326 barometer support")
Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
---

The original control-flow was technically not wrong just confusing and a bit 
complicated. Not clear if reporting the interrupted case actually is useful,
but given that the timeout is relatively long (200ms) it is not that unlikely
so differentiating the cases seems helpful.

Patch was compile-tested with: x86_64_defconfig + CONFIG_IIO=m, CONFIG_ZPA2326=m

Patch is against v4.11 (localversion-next is next-20170512)

 drivers/iio/pressure/zpa2326.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
index e58a0ad..617926f 100644
--- a/drivers/iio/pressure/zpa2326.c
+++ b/drivers/iio/pressure/zpa2326.c
@@ -867,12 +867,13 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
 {
 	int          ret;
 	unsigned int val;
+	long     timeout;
 
 	zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt");
 
-	ret = wait_for_completion_interruptible_timeout(
+	timeout = wait_for_completion_interruptible_timeout(
 		&private->data_ready, ZPA2326_CONVERSION_JIFFIES);
-	if (ret > 0)
+	if (timeout > 0)
 		/*
 		 * Interrupt handler completed before timeout: return operation
 		 * status.
@@ -882,13 +883,15 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
 	/* Clear all interrupts just to be sure. */
 	regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val);
 
-	if (!ret)
+	if (!timeout) {
 		/* Timed out. */
+		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
+			     timeout);
 		ret = -ETIME;
-
-	if (ret != -ERESTARTSYS)
-		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)",
-			     ret);
+	} else if (timeout < 0) {
+		zpa2326_warn(indio_dev, "wait for one shot interrupt canceled");
+		ret = -ERESTARTSYS;
+	}
 
 	return ret;
 }
-- 
2.1.4

[toc] | [next] | [standalone]


#1641065 — Re: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure

FromPeter Meerwald-Stadler <pmeerw@pmeerw.net>
Date2017-05-14 11:50 +0200
SubjectRe: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure
Message-ID<tGYk1-8lN-7@gated-at.bofh.it>
In reply to#1641064
> If the timeout-case prints a warning message then probably the interrupted
> case should also. Further, wait_for_completion_interruptible_timeout()
> returns long not int. 
> 
> Fixes: commit 03b262f2bbf4 ("iio:pressure: initial zpa2326 barometer support")
> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>

this is actually a v2, looks good to me

> ---
> 
> The original control-flow was technically not wrong just confusing and a bit 
> complicated. Not clear if reporting the interrupted case actually is useful,
> but given that the timeout is relatively long (200ms) it is not that unlikely
> so differentiating the cases seems helpful.
> 
> Patch was compile-tested with: x86_64_defconfig + CONFIG_IIO=m, CONFIG_ZPA2326=m
> 
> Patch is against v4.11 (localversion-next is next-20170512)
> 
>  drivers/iio/pressure/zpa2326.c | 17 ++++++++++-------
>  1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
> index e58a0ad..617926f 100644
> --- a/drivers/iio/pressure/zpa2326.c
> +++ b/drivers/iio/pressure/zpa2326.c
> @@ -867,12 +867,13 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
>  {
>  	int          ret;
>  	unsigned int val;
> +	long     timeout;
>  
>  	zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt");
>  
> -	ret = wait_for_completion_interruptible_timeout(
> +	timeout = wait_for_completion_interruptible_timeout(
>  		&private->data_ready, ZPA2326_CONVERSION_JIFFIES);
> -	if (ret > 0)
> +	if (timeout > 0)
>  		/*
>  		 * Interrupt handler completed before timeout: return operation
>  		 * status.
> @@ -882,13 +883,15 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
>  	/* Clear all interrupts just to be sure. */
>  	regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val);
>  
> -	if (!ret)
> +	if (!timeout) {
>  		/* Timed out. */
> +		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
> +			     timeout);
>  		ret = -ETIME;
> -
> -	if (ret != -ERESTARTSYS)
> -		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)",
> -			     ret);
> +	} else if (timeout < 0) {
> +		zpa2326_warn(indio_dev, "wait for one shot interrupt canceled");
> +		ret = -ERESTARTSYS;
> +	}
>  
>  	return ret;
>  }
> 

-- 

Peter Meerwald-Stadler
Mobile: +43 664 24 44 418

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


#1641073 — Re: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure

FromNicholas Mc Guire <der.herr@hofr.at>
Date2017-05-14 13:40 +0200
SubjectRe: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure
Message-ID<tH02u-10Y-5@gated-at.bofh.it>
In reply to#1641065
On Sun, May 14, 2017 at 11:46:58AM +0200, Peter Meerwald-Stadler wrote:
> 
> > If the timeout-case prints a warning message then probably the interrupted
> > case should also. Further, wait_for_completion_interruptible_timeout()
> > returns long not int. 
> > 
> > Fixes: commit 03b262f2bbf4 ("iio:pressure: initial zpa2326 barometer support")
> > Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> 
> this is actually a v2, looks good to me

yup - I was just not clear if I should have marked is as V2
as not only the subject did change (simply because my first
assumption that the control-flow was buggy was wrong) and if
it would have been marked as V2 with no equivalent original
Patch would that make much sense ?

If it does, I´ll resend with a V2 tag and ref to the original
(wrong) Patch.

Thanks for the review 

> 
> > ---
> > 
> > The original control-flow was technically not wrong just confusing and a bit 
> > complicated. Not clear if reporting the interrupted case actually is useful,
> > but given that the timeout is relatively long (200ms) it is not that unlikely
> > so differentiating the cases seems helpful.
> > 
> > Patch was compile-tested with: x86_64_defconfig + CONFIG_IIO=m, CONFIG_ZPA2326=m
> > 
> > Patch is against v4.11 (localversion-next is next-20170512)
> > 
> >  drivers/iio/pressure/zpa2326.c | 17 ++++++++++-------
> >  1 file changed, 10 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
> > index e58a0ad..617926f 100644
> > --- a/drivers/iio/pressure/zpa2326.c
> > +++ b/drivers/iio/pressure/zpa2326.c
> > @@ -867,12 +867,13 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
> >  {
> >  	int          ret;
> >  	unsigned int val;
> > +	long     timeout;
> >  
> >  	zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt");
> >  
> > -	ret = wait_for_completion_interruptible_timeout(
> > +	timeout = wait_for_completion_interruptible_timeout(
> >  		&private->data_ready, ZPA2326_CONVERSION_JIFFIES);
> > -	if (ret > 0)
> > +	if (timeout > 0)
> >  		/*
> >  		 * Interrupt handler completed before timeout: return operation
> >  		 * status.
> > @@ -882,13 +883,15 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
> >  	/* Clear all interrupts just to be sure. */
> >  	regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val);
> >  
> > -	if (!ret)
> > +	if (!timeout) {
> >  		/* Timed out. */
> > +		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
> > +			     timeout);
> >  		ret = -ETIME;
> > -
> > -	if (ret != -ERESTARTSYS)
> > -		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)",
> > -			     ret);
> > +	} else if (timeout < 0) {
> > +		zpa2326_warn(indio_dev, "wait for one shot interrupt canceled");
> > +		ret = -ERESTARTSYS;
> > +	}
> >  
> >  	return ret;
> >  }
> > 
> 
> -- 
>
thx!
hofrat 

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


#1641094 — Re: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure

FromJonathan Cameron <jic23@kernel.org>
Date2017-05-14 16:30 +0200
SubjectRe: [PATCH RFC] iio: pressure: zpa2326: report interrupted case as failure
Message-ID<tH2GZ-2Gh-5@gated-at.bofh.it>
In reply to#1641065
On 14/05/17 10:46, Peter Meerwald-Stadler wrote:
> 
>> If the timeout-case prints a warning message then probably the interrupted
>> case should also. Further, wait_for_completion_interruptible_timeout()
>> returns long not int.
>>
>> Fixes: commit 03b262f2bbf4 ("iio:pressure: initial zpa2326 barometer support")
>> Signed-off-by: Nicholas Mc Guire <der.herr@hofr.at>
> 
> this is actually a v2, looks good to me
A formal ack would be good!  Anyhow, I'll take that as an informal one.

A typo in the error message that I've fixed.

Applied to the togreg branch of iio.git.  Will be pushed out as testing
for the autobuilders to play with it.

BTW I don't think this one really should have been an RFC. It's a clear
tidy up to some confusing code being proposed for inclusion rather than
to start a discussion!

Jonathan
> 
>> ---
>>
>> The original control-flow was technically not wrong just confusing and a bit
>> complicated. Not clear if reporting the interrupted case actually is useful,
>> but given that the timeout is relatively long (200ms) it is not that unlikely
>> so differentiating the cases seems helpful.
>>
>> Patch was compile-tested with: x86_64_defconfig + CONFIG_IIO=m, CONFIG_ZPA2326=m
>>
>> Patch is against v4.11 (localversion-next is next-20170512)
>>
>>   drivers/iio/pressure/zpa2326.c | 17 ++++++++++-------
>>   1 file changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
>> index e58a0ad..617926f 100644
>> --- a/drivers/iio/pressure/zpa2326.c
>> +++ b/drivers/iio/pressure/zpa2326.c
>> @@ -867,12 +867,13 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
>>   {
>>   	int          ret;
>>   	unsigned int val;
>> +	long     timeout;
>>   
>>   	zpa2326_dbg(indio_dev, "waiting for one shot completion interrupt");
>>   
>> -	ret = wait_for_completion_interruptible_timeout(
>> +	timeout = wait_for_completion_interruptible_timeout(
>>   		&private->data_ready, ZPA2326_CONVERSION_JIFFIES);
>> -	if (ret > 0)
>> +	if (timeout > 0)
>>   		/*
>>   		 * Interrupt handler completed before timeout: return operation
>>   		 * status.
>> @@ -882,13 +883,15 @@ static int zpa2326_wait_oneshot_completion(const struct iio_dev   *indio_dev,
>>   	/* Clear all interrupts just to be sure. */
>>   	regmap_read(private->regmap, ZPA2326_INT_SOURCE_REG, &val);
>>   
>> -	if (!ret)
>> +	if (!timeout) {
>>   		/* Timed out. */
>> +		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)",
>> +			     timeout);
>>   		ret = -ETIME;
>> -
>> -	if (ret != -ERESTARTSYS)
>> -		zpa2326_warn(indio_dev, "no one shot interrupt occurred (%d)",
>> -			     ret);
>> +	} else if (timeout < 0) {
>> +		zpa2326_warn(indio_dev, "wait for one shot interrupt canceled");
cancelled. I'll fix that.
>> +		ret = -ERESTARTSYS;
>> +	}
>>   
>>   	return ret;
>>   }
>>
> 

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web