From: Dan Carpenter Date: Tue, 10 Aug 2010 05:37:33 +0000 (+0200) Subject: Staging: iio: signedness bug X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=213fd2270450f7b5f98803e58bc25063c249e032;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git Staging: iio: signedness bug 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 Acked-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index ea5f749c5fe7..2b1828017076 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c @@ -389,11 +389,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]); }