Commit c1909ab0 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Jonathan Cameron

iio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24()

This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarNuno Sá <nuno.sa@analog.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 0d4b2184
...@@ -70,9 +70,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg, ...@@ -70,9 +70,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
switch (size) { switch (size) {
case 3: case 3:
data[1] = val >> 16; put_unaligned_be24(val, &data[1]);
data[2] = val >> 8;
data[3] = val;
break; break;
case 2: case 2:
put_unaligned_be16(val, &data[1]); put_unaligned_be16(val, &data[1]);
...@@ -157,9 +155,7 @@ int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta, ...@@ -157,9 +155,7 @@ int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta,
*val = get_unaligned_be32(sigma_delta->data); *val = get_unaligned_be32(sigma_delta->data);
break; break;
case 3: case 3:
*val = (sigma_delta->data[0] << 16) | *val = get_unaligned_be24(&sigma_delta->data[0]);
(sigma_delta->data[1] << 8) |
sigma_delta->data[2];
break; break;
case 2: case 2:
*val = get_unaligned_be16(sigma_delta->data); *val = get_unaligned_be16(sigma_delta->data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment