Message ID | 20200421003135.23060-15-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:34 +0300 Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote: > This makes the driver code slightly easier to read. > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Added missing header and applied, Thanks, Jonathan > --- > drivers/iio/temperature/max31856.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c > index b4cb21ab2e85..e1966889a962 100644 > --- a/drivers/iio/temperature/max31856.c > +++ b/drivers/iio/temperature/max31856.c > @@ -168,7 +168,7 @@ static int max31856_thermocouple_read(struct max31856_data *data, > if (ret) > return ret; > /* Skip last 5 dead bits of LTCBL */ > - *val = (reg_val[0] << 16 | reg_val[1] << 8 | reg_val[2]) >> 5; > + *val = get_unaligned_be24(®_val[0]) >> 5; > /* Check 7th bit of LTCBH reg. value for sign*/ > if (reg_val[0] & 0x80) > *val -= 0x80000; > @@ -185,7 +185,7 @@ static int max31856_thermocouple_read(struct max31856_data *data, > /* Get Cold Junction Temp. offset register value */ > offset_cjto = reg_val[0]; > /* Get CJTH and CJTL value and skip last 2 dead bits of CJTL */ > - *val = (reg_val[1] << 8 | reg_val[2]) >> 2; > + *val = get_unaligned_be16(®_val[1]) >> 2; > /* As per datasheet add offset into CJTH and CJTL */ > *val += offset_cjto; > /* Check 7th bit of CJTH reg. value for sign */
diff --git a/drivers/iio/temperature/max31856.c b/drivers/iio/temperature/max31856.c index b4cb21ab2e85..e1966889a962 100644 --- a/drivers/iio/temperature/max31856.c +++ b/drivers/iio/temperature/max31856.c @@ -168,7 +168,7 @@ static int max31856_thermocouple_read(struct max31856_data *data, if (ret) return ret; /* Skip last 5 dead bits of LTCBL */ - *val = (reg_val[0] << 16 | reg_val[1] << 8 | reg_val[2]) >> 5; + *val = get_unaligned_be24(®_val[0]) >> 5; /* Check 7th bit of LTCBH reg. value for sign*/ if (reg_val[0] & 0x80) *val -= 0x80000; @@ -185,7 +185,7 @@ static int max31856_thermocouple_read(struct max31856_data *data, /* Get Cold Junction Temp. offset register value */ offset_cjto = reg_val[0]; /* Get CJTH and CJTL value and skip last 2 dead bits of CJTL */ - *val = (reg_val[1] << 8 | reg_val[2]) >> 2; + *val = get_unaligned_be16(®_val[1]) >> 2; /* As per datasheet add offset into CJTH and CJTL */ *val += offset_cjto; /* Check 7th bit of CJTH reg. value for sign */
This makes the driver code slightly easier to read. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> --- drivers/iio/temperature/max31856.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)