diff mbox

[2/2] adc: exynos_adc: Fix incorrect variable type

Message ID 1364970239-8242-2-git-send-email-sachin.kamat@linaro.org
State Rejected
Headers show

Commit Message

Sachin Kamat April 3, 2013, 6:23 a.m. UTC
wait_for_completion_interruptible_timeout() returns negative value on error
but is assigned to an unsigned variable. Though this might not matter much
as the return value is only tested for '0', for the sake of code correctness
modify the variable type suitably. Without this patch we get the following
smatch error:
drivers/iio/adc/exynos_adc.c:147 exynos_read_raw() error:
'wait_for_completion_interruptible_timeout()' returns negative and
'timeout' is unsigned

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/iio/adc/exynos_adc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Naveen Krishna Ch April 3, 2013, 5:27 p.m. UTC | #1
On 2 April 2013 23:23, Sachin Kamat <sachin.kamat@linaro.org> wrote:
> wait_for_completion_interruptible_timeout() returns negative value on error
> but is assigned to an unsigned variable. Though this might not matter much
> as the return value is only tested for '0', for the sake of code correctness
> modify the variable type suitably. Without this patch we get the following
> smatch error:
> drivers/iio/adc/exynos_adc.c:147 exynos_read_raw() error:
> 'wait_for_completion_interruptible_timeout()' returns negative and
> 'timeout' is unsigned
>
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/iio/adc/exynos_adc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
> index 22d034a..3bf5132 100644
> --- a/drivers/iio/adc/exynos_adc.c
> +++ b/drivers/iio/adc/exynos_adc.c
> @@ -118,7 +118,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>                                 long mask)
>  {
>         struct exynos_adc *info = iio_priv(indio_dev);
> -       unsigned long timeout;
> +       long timeout;
Sachin thank you for your efforts.

Apart from just changing it to long. we seem to have other corner cases
and a CL is under discussion https://patchwork.kernel.org/patch/2279591/

Doug, has replied on it as of today. We will come back with that CL soon.
>         u32 con1, con2;
>
>         if (mask != IIO_CHAN_INFO_RAW)
> --
> 1.7.9.5
>
> --
> 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



--
Shine bright,
(: Nav :)
Sachin Kamat April 4, 2013, 3:35 a.m. UTC | #2
On 3 April 2013 22:57, Naveen Krishna Ch <naveenkrishna.ch@gmail.com> wrote:
> On 2 April 2013 23:23, Sachin Kamat <sachin.kamat@linaro.org> wrote:
>> wait_for_completion_interruptible_timeout() returns negative value on error
>> but is assigned to an unsigned variable. Though this might not matter much
>> as the return value is only tested for '0', for the sake of code correctness
>> modify the variable type suitably. Without this patch we get the following
>> smatch error:
>> drivers/iio/adc/exynos_adc.c:147 exynos_read_raw() error:
>> 'wait_for_completion_interruptible_timeout()' returns negative and
>> 'timeout' is unsigned
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> ---
>>  drivers/iio/adc/exynos_adc.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
>> index 22d034a..3bf5132 100644
>> --- a/drivers/iio/adc/exynos_adc.c
>> +++ b/drivers/iio/adc/exynos_adc.c
>> @@ -118,7 +118,7 @@ static int exynos_read_raw(struct iio_dev *indio_dev,
>>                                 long mask)
>>  {
>>         struct exynos_adc *info = iio_priv(indio_dev);
>> -       unsigned long timeout;
>> +       long timeout;
> Sachin thank you for your efforts.
>
> Apart from just changing it to long. we seem to have other corner cases
> and a CL is under discussion https://patchwork.kernel.org/patch/2279591/

Thanks for pointing this out. I had not seen this earlier. My patch
was to fix an obvious issue with the existing code.
However, since you have more elaborate plans about handling this,
please go ahead with that.
diff mbox

Patch

diff --git a/drivers/iio/adc/exynos_adc.c b/drivers/iio/adc/exynos_adc.c
index 22d034a..3bf5132 100644
--- a/drivers/iio/adc/exynos_adc.c
+++ b/drivers/iio/adc/exynos_adc.c
@@ -118,7 +118,7 @@  static int exynos_read_raw(struct iio_dev *indio_dev,
 				long mask)
 {
 	struct exynos_adc *info = iio_priv(indio_dev);
-	unsigned long timeout;
+	long timeout;
 	u32 con1, con2;
 
 	if (mask != IIO_CHAN_INFO_RAW)