Re: [PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Lars-Peter Clausen

On 02/02/2015 10:50 AM, Nicholas Mc Guire wrote:

On Mon, 02 Feb 2015, Lars-Peter Clausen wrote:


On 02/02/2015 09:37 AM, Nicholas Mc Guire wrote:

return type of wait_for_completion_timeout is unsigned long not int, rather
than introducing a new variable the wait_for_completion_timeout is moved
into the if condition as the return value is only used to detect timeout.


But the return value is bound by the timeout parameter and we know that
fits into a int. And I really dont like moving the function call into the
if condition, so unless there is some additional explanation why this is
necessary and should be done I'm inclined to nack this.



well having correct types is important for all static code chekcers
and I did not want to add a new variable just for this case
simply because the result is only relevant in the == 0 case
anyway.

I do think that the types being assigned should correct with respect
to the API definition even if it fits in this case.



Signed-off-by: Nicholas Mc Guire 
---

Aside from the fixup of the wait_for_completion_timeout handling
a minor coding style issue in the else branch was fixed - the {} is
not needed for the one-line body.


If one of the branches of a conditional statement has braces the other
branches should also have braces. This is documented in
Documentation/CodingStyle.


my bad - it is not uncommon to be asymetric - but you are right that Chapter 3
states it should not be asymetric in this case - will remove that.

given the botched braces this needs to be redone - let me know if moving
it into the condition is ok (its not uncommon) or if an additional variable
of type unsigned long is the prefered solution.


I prefer the extra variable, but that's personal taste. And maybe add the 
stuff about the static code checker etc to the commit message.


Thanks,
- Lars

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Nicholas Mc Guire
On Mon, 02 Feb 2015, Lars-Peter Clausen wrote:

> On 02/02/2015 09:37 AM, Nicholas Mc Guire wrote:
>> return type of wait_for_completion_timeout is unsigned long not int, rather
>> than introducing a new variable the wait_for_completion_timeout is moved
>> into the if condition as the return value is only used to detect timeout.
>
> But the return value is bound by the timeout parameter and we know that 
> fits into a int. And I really dont like moving the function call into the 
> if condition, so unless there is some additional explanation why this is  
> necessary and should be done I'm inclined to nack this.
>

well having correct types is important for all static code chekcers
and I did not want to add a new variable just for this case
simply because the result is only relevant in the == 0 case
anyway.

I do think that the types being assigned should correct with respect
to the API definition even if it fits in this case.

>>
>> Signed-off-by: Nicholas Mc Guire 
>> ---
>>
>> Aside from the fixup of the wait_for_completion_timeout handling
>> a minor coding style issue in the else branch was fixed - the {} is
>> not needed for the one-line body.
>
> If one of the branches of a conditional statement has braces the other  
> branches should also have braces. This is documented in  
> Documentation/CodingStyle.

my bad - it is not uncommon to be asymetric - but you are right that Chapter 3
states it should not be asymetric in this case - will remove that.

given the botched braces this needs to be redone - let me know if moving
it into the condition is ok (its not uncommon) or if an additional variable
of type unsigned long is the prefered solution.

thanks for your review !

thx!
hofrat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Lars-Peter Clausen

On 02/02/2015 09:37 AM, Nicholas Mc Guire wrote:

return type of wait_for_completion_timeout is unsigned long not int, rather
than introducing a new variable the wait_for_completion_timeout is moved
into the if condition as the return value is only used to detect timeout.


But the return value is bound by the timeout parameter and we know that fits 
into a int. And I really dont like moving the function call into the if 
condition, so unless there is some additional explanation why this is 
necessary and should be done I'm inclined to nack this.




Signed-off-by: Nicholas Mc Guire 
---

Aside from the fixup of the wait_for_completion_timeout handling
a minor coding style issue in the else branch was fixed - the {} is
not needed for the one-line body.


If one of the branches of a conditional statement has braces the other 
branches should also have braces. This is documented in 
Documentation/CodingStyle.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Nicholas Mc Guire
return type of wait_for_completion_timeout is unsigned long not int, rather
than introducing a new variable the wait_for_completion_timeout is moved
into the if condition as the return value is only used to detect timeout.

Signed-off-by: Nicholas Mc Guire 
---

Aside from the fixup of the wait_for_completion_timeout handling
a minor coding style issue in the else branch was fixed - the {} is
not needed for the one-line body.

Patch was compile tested only for imx_v6_v7_defconfig + CONFIG_IIO=m
CONFIG_STAGING=y, CONFIG_AD7780=m, CONFIG_AD_SIGMA_DELTA=m

Patch is against 3.19.0-rc6 -next-20150130

 drivers/iio/adc/ad_sigma_delta.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index d10bd0c..fbc5824 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -196,14 +196,12 @@ static int ad_sd_calibrate(struct ad_sigma_delta 
*sigma_delta,
 
sigma_delta->irq_dis = false;
enable_irq(sigma_delta->spi->irq);
-   ret = wait_for_completion_timeout(_delta->completion, 2*HZ);
-   if (ret == 0) {
+   if (!wait_for_completion_timeout(_delta->completion, 2*HZ)) {
sigma_delta->irq_dis = true;
disable_irq_nosync(sigma_delta->spi->irq);
ret = -EIO;
-   } else {
+   } else
ret = 0;
-   }
 out:
sigma_delta->bus_locked = false;
spi_bus_unlock(sigma_delta->spi->master);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Lars-Peter Clausen

On 02/02/2015 09:37 AM, Nicholas Mc Guire wrote:

return type of wait_for_completion_timeout is unsigned long not int, rather
than introducing a new variable the wait_for_completion_timeout is moved
into the if condition as the return value is only used to detect timeout.


But the return value is bound by the timeout parameter and we know that fits 
into a int. And I really dont like moving the function call into the if 
condition, so unless there is some additional explanation why this is 
necessary and should be done I'm inclined to nack this.




Signed-off-by: Nicholas Mc Guire hof...@osadl.org
---

Aside from the fixup of the wait_for_completion_timeout handling
a minor coding style issue in the else branch was fixed - the {} is
not needed for the one-line body.


If one of the branches of a conditional statement has braces the other 
branches should also have braces. This is documented in 
Documentation/CodingStyle.

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Nicholas Mc Guire
On Mon, 02 Feb 2015, Lars-Peter Clausen wrote:

 On 02/02/2015 09:37 AM, Nicholas Mc Guire wrote:
 return type of wait_for_completion_timeout is unsigned long not int, rather
 than introducing a new variable the wait_for_completion_timeout is moved
 into the if condition as the return value is only used to detect timeout.

 But the return value is bound by the timeout parameter and we know that 
 fits into a int. And I really dont like moving the function call into the 
 if condition, so unless there is some additional explanation why this is  
 necessary and should be done I'm inclined to nack this.


well having correct types is important for all static code chekcers
and I did not want to add a new variable just for this case
simply because the result is only relevant in the == 0 case
anyway.

I do think that the types being assigned should correct with respect
to the API definition even if it fits in this case.


 Signed-off-by: Nicholas Mc Guire hof...@osadl.org
 ---

 Aside from the fixup of the wait_for_completion_timeout handling
 a minor coding style issue in the else branch was fixed - the {} is
 not needed for the one-line body.

 If one of the branches of a conditional statement has braces the other  
 branches should also have braces. This is documented in  
 Documentation/CodingStyle.

my bad - it is not uncommon to be asymetric - but you are right that Chapter 3
states it should not be asymetric in this case - will remove that.

given the botched braces this needs to be redone - let me know if moving
it into the condition is ok (its not uncommon) or if an additional variable
of type unsigned long is the prefered solution.

thanks for your review !

thx!
hofrat

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Lars-Peter Clausen

On 02/02/2015 10:50 AM, Nicholas Mc Guire wrote:

On Mon, 02 Feb 2015, Lars-Peter Clausen wrote:


On 02/02/2015 09:37 AM, Nicholas Mc Guire wrote:

return type of wait_for_completion_timeout is unsigned long not int, rather
than introducing a new variable the wait_for_completion_timeout is moved
into the if condition as the return value is only used to detect timeout.


But the return value is bound by the timeout parameter and we know that
fits into a int. And I really dont like moving the function call into the
if condition, so unless there is some additional explanation why this is
necessary and should be done I'm inclined to nack this.



well having correct types is important for all static code chekcers
and I did not want to add a new variable just for this case
simply because the result is only relevant in the == 0 case
anyway.

I do think that the types being assigned should correct with respect
to the API definition even if it fits in this case.



Signed-off-by: Nicholas Mc Guire hof...@osadl.org
---

Aside from the fixup of the wait_for_completion_timeout handling
a minor coding style issue in the else branch was fixed - the {} is
not needed for the one-line body.


If one of the branches of a conditional statement has braces the other
branches should also have braces. This is documented in
Documentation/CodingStyle.


my bad - it is not uncommon to be asymetric - but you are right that Chapter 3
states it should not be asymetric in this case - will remove that.

given the botched braces this needs to be redone - let me know if moving
it into the condition is ok (its not uncommon) or if an additional variable
of type unsigned long is the prefered solution.


I prefer the extra variable, but that's personal taste. And maybe add the 
stuff about the static code checker etc to the commit message.


Thanks,
- Lars

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 3/3] iio: ad_sigma_delta: cleanup wait_for_completion return handling

2015-02-02 Thread Nicholas Mc Guire
return type of wait_for_completion_timeout is unsigned long not int, rather
than introducing a new variable the wait_for_completion_timeout is moved
into the if condition as the return value is only used to detect timeout.

Signed-off-by: Nicholas Mc Guire hof...@osadl.org
---

Aside from the fixup of the wait_for_completion_timeout handling
a minor coding style issue in the else branch was fixed - the {} is
not needed for the one-line body.

Patch was compile tested only for imx_v6_v7_defconfig + CONFIG_IIO=m
CONFIG_STAGING=y, CONFIG_AD7780=m, CONFIG_AD_SIGMA_DELTA=m

Patch is against 3.19.0-rc6 -next-20150130

 drivers/iio/adc/ad_sigma_delta.c |6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/iio/adc/ad_sigma_delta.c b/drivers/iio/adc/ad_sigma_delta.c
index d10bd0c..fbc5824 100644
--- a/drivers/iio/adc/ad_sigma_delta.c
+++ b/drivers/iio/adc/ad_sigma_delta.c
@@ -196,14 +196,12 @@ static int ad_sd_calibrate(struct ad_sigma_delta 
*sigma_delta,
 
sigma_delta-irq_dis = false;
enable_irq(sigma_delta-spi-irq);
-   ret = wait_for_completion_timeout(sigma_delta-completion, 2*HZ);
-   if (ret == 0) {
+   if (!wait_for_completion_timeout(sigma_delta-completion, 2*HZ)) {
sigma_delta-irq_dis = true;
disable_irq_nosync(sigma_delta-spi-irq);
ret = -EIO;
-   } else {
+   } else
ret = 0;
-   }
 out:
sigma_delta-bus_locked = false;
spi_bus_unlock(sigma_delta-spi-master);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/