From: Somya Anand Date: Sat, 7 Mar 2015 17:50:01 +0000 (+0530) Subject: Staging: iio: Change data type to u16 to avoid unnecessary typecast X-Git-Tag: v5.15~16002^2~138^2~519 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b62a569e4ae2361bac6f601e75aa973d42d7c47d;p=platform%2Fkernel%2Flinux-starfive.git Staging: iio: Change data type to u16 to avoid unnecessary typecast In the adis16220_read16bit() function we earlier used a s16 value 'val' which is used by the adis_read_reg_16 function to read data and takes a u16 value as a parameter. So, this patch changes the data type of 'val' from s16 to u16. It is safe to remove the extra sign extension, since the user of the function uses it to read a 10 unsigned value which will lead to the same result in both cases. Further this patch removes the unnecessary typecast for the simplification of code. In addition to this, initialization of 'val' to 0 is also dropped. This is due to the fact that not initializing helps the compiler provide useful warnings if the code gets changed to return an otherwise uninitialized result. Signed-off-by: Somya Anand Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index d478f51..0396f24 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c @@ -28,16 +28,15 @@ static ssize_t adis16220_read_16bit(struct device *dev, struct iio_dev *indio_dev = dev_to_iio_dev(dev); struct adis16220_state *st = iio_priv(indio_dev); ssize_t ret; - s16 val = 0; + u16 val; /* Take the iio_dev status lock */ mutex_lock(&indio_dev->mlock); - ret = adis_read_reg_16(&st->adis, this_attr->address, - (u16 *)&val); + ret = adis_read_reg_16(&st->adis, this_attr->address, &val); mutex_unlock(&indio_dev->mlock); if (ret) return ret; - return sprintf(buf, "%d\n", val); + return sprintf(buf, "%u\n", val); } static ssize_t adis16220_write_16bit(struct device *dev,