public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 1/2] Staging: iio: signedness bug
@ 2010-08-10  5:37 Dan Carpenter
  2010-08-10  9:40 ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-08-10  5:37 UTC (permalink / raw)
  To: kernel-janitors

i2c_smbus_read_byte_data() returns an s32 type.  We need to change
"rate" to signed for the error handling to work.

Also I changed it to propogate the error code instead of just returning
-EINVAL.  Other error codes could be -EAGAIN for example.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
index 92f6c6f..3d3bac4 100644
--- a/drivers/staging/iio/magnetometer/hmc5843.c
+++ b/drivers/staging/iio/magnetometer/hmc5843.c
@@ -385,11 +385,11 @@ static ssize_t show_sampling_frequency(struct device *dev,
 	struct iio_dev *indio_dev = dev_get_drvdata(dev);
 	struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
 	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
-	u32 rate;
+	s32 rate;
 
 	rate = i2c_smbus_read_byte_data(client,  this_attr->address);
 	if (rate < 0)
-		return -EINVAL;
+		return rate;
 	rate = (rate & RATE_BITMASK) >> RATE_OFFSET;
 	return sprintf(buf, "%s\n", regval_to_samp_freq[rate]);
 }

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

* Re: [patch 1/2] Staging: iio: signedness bug
  2010-08-10  5:37 [patch 1/2] Staging: iio: signedness bug Dan Carpenter
@ 2010-08-10  9:40 ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2010-08-10  9:40 UTC (permalink / raw)
  To: kernel-janitors

On 08/10/10 06:37, Dan Carpenter wrote:
> i2c_smbus_read_byte_data() returns an s32 type.  We need to change
> "rate" to signed for the error handling to work.
> 
> Also I changed it to propogate the error code instead of just returning
> -EINVAL.  Other error codes could be -EAGAIN for example.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: Jonathan Cameron <jic23@cam.ac.uk>

Thanks
> 
> diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c
> index 92f6c6f..3d3bac4 100644
> --- a/drivers/staging/iio/magnetometer/hmc5843.c
> +++ b/drivers/staging/iio/magnetometer/hmc5843.c
> @@ -385,11 +385,11 @@ static ssize_t show_sampling_frequency(struct device *dev,
>  	struct iio_dev *indio_dev = dev_get_drvdata(dev);
>  	struct i2c_client *client = to_i2c_client(indio_dev->dev.parent);
>  	struct iio_dev_attr *this_attr = to_iio_dev_attr(attr);
> -	u32 rate;
> +	s32 rate;
>  
>  	rate = i2c_smbus_read_byte_data(client,  this_attr->address);
>  	if (rate < 0)
> -		return -EINVAL;
> +		return rate;
>  	rate = (rate & RATE_BITMASK) >> RATE_OFFSET;
>  	return sprintf(buf, "%s\n", regval_to_samp_freq[rate]);
>  }


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

end of thread, other threads:[~2010-08-10  9:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-10  5:37 [patch 1/2] Staging: iio: signedness bug Dan Carpenter
2010-08-10  9:40 ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox