Message ID | 20200421003135.23060-16-andriy.shevchenko@linux.intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v1,01/16] iio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24() | expand |
On Tue, 21 Apr 2020 03:31:35 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > Use these functions instead of open-coding them. > > Cc: Denis Ciocca <denis.ciocca@st.com> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> This one already has the header, so applied to the togreg branch of iio.git and pushed out as testing with no changes :) Jonathan > --- > drivers/iio/common/st_sensors/st_sensors_core.c | 7 +------ > 1 file changed, 1 insertion(+), 6 deletions(-) > > diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c > index 0e35ff06f9af..bfc39ef64718 100644 > --- a/drivers/iio/common/st_sensors/st_sensors_core.c > +++ b/drivers/iio/common/st_sensors/st_sensors_core.c > @@ -20,11 +20,6 @@ > > #include "st_sensors_core.h" > > -static inline u32 st_sensors_get_unaligned_le24(const u8 *p) > -{ > - return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8; > -} > - > int st_sensors_write_data_with_mask(struct iio_dev *indio_dev, > u8 reg_addr, u8 mask, u8 data) > { > @@ -545,7 +540,7 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev, > else if (byte_for_channel == 2) > *data = (s16)get_unaligned_le16(outdata); > else if (byte_for_channel == 3) > - *data = (s32)st_sensors_get_unaligned_le24(outdata); > + *data = (s32)sign_extend32(get_unaligned_le24(outdata), 23); > > st_sensors_free_memory: > kfree(outdata);
On Sat, Apr 25, 2020 at 7:54 PM Jonathan Cameron <jic23@kernel.org> wrote: > > On Tue, 21 Apr 2020 03:31:35 +0300 > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > > > Use these functions instead of open-coding them. > > > > Cc: Denis Ciocca <denis.ciocca@st.com> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> > This one already has the header, so applied to the togreg branch of iio.git > and pushed out as testing with no changes :) Thanks, I'm sorry I didn't compile all of them and by some reason thought they all have it already. Strange we didn't get kbuild bot complains...
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c index 0e35ff06f9af..bfc39ef64718 100644 --- a/drivers/iio/common/st_sensors/st_sensors_core.c +++ b/drivers/iio/common/st_sensors/st_sensors_core.c @@ -20,11 +20,6 @@ #include "st_sensors_core.h" -static inline u32 st_sensors_get_unaligned_le24(const u8 *p) -{ - return (s32)((p[0] | p[1] << 8 | p[2] << 16) << 8) >> 8; -} - int st_sensors_write_data_with_mask(struct iio_dev *indio_dev, u8 reg_addr, u8 mask, u8 data) { @@ -545,7 +540,7 @@ static int st_sensors_read_axis_data(struct iio_dev *indio_dev, else if (byte_for_channel == 2) *data = (s16)get_unaligned_le16(outdata); else if (byte_for_channel == 3) - *data = (s32)st_sensors_get_unaligned_le24(outdata); + *data = (s32)sign_extend32(get_unaligned_le24(outdata), 23); st_sensors_free_memory: kfree(outdata);
Use these functions instead of open-coding them. Cc: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/iio/common/st_sensors/st_sensors_core.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)