]> git.baikalelectronics.ru Git - kernel.git/commitdiff
iio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24()
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Tue, 21 Apr 2020 00:31:20 +0000 (03:31 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 3 May 2020 08:47:18 +0000 (09:47 +0100)
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: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad_sigma_delta.c

index 8115b6de1d6c9fbd70b0b7f5a2d6e1deed673964..dd3d54b3bc8bba19612451e4546a326181fc3512 100644 (file)
@@ -70,9 +70,7 @@ int ad_sd_write_reg(struct ad_sigma_delta *sigma_delta, unsigned int reg,
 
        switch (size) {
        case 3:
-               data[1] = val >> 16;
-               data[2] = val >> 8;
-               data[3] = val;
+               put_unaligned_be24(val, &data[1]);
                break;
        case 2:
                put_unaligned_be16(val, &data[1]);
@@ -157,9 +155,7 @@ int ad_sd_read_reg(struct ad_sigma_delta *sigma_delta,
                *val = get_unaligned_be32(sigma_delta->data);
                break;
        case 3:
-               *val = (sigma_delta->data[0] << 16) |
-                       (sigma_delta->data[1] << 8) |
-                       sigma_delta->data[2];
+               *val = get_unaligned_be24(&sigma_delta->data[0]);
                break;
        case 2:
                *val = get_unaligned_be16(sigma_delta->data);