iio: Replace occurrences of magic number 0 by IIO_CHAN_INFO_RAW
authorRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Tue, 6 Mar 2018 12:02:57 +0000 (09:02 -0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Wed, 7 Mar 2018 20:14:36 +0000 (20:14 +0000)
Usually, functions responsible for reading raw data typically relies on
values from iio_chan_info_enum to correctly identify the type of data to
be read. There is a set of a device driver that uses the magic number 0
instead of IIO_CHAN_INFO_RAW. This patch improves the readability by
replaces the magic number 0 for the appropriate IIO_CHAN_INFO_RAW in six
devices driver in the IIO subsystem.

Signed-off-by: Rodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/accel/hid-sensor-accel-3d.c
drivers/iio/dac/ad5380.c
drivers/iio/dac/ad5764.c
drivers/iio/gyro/hid-sensor-gyro-3d.c
drivers/iio/light/hid-sensor-als.c
drivers/iio/light/lm3533-als.c

index c066a3bdbff7b32cef33be7effa3316eeddbf00d..41d97faf50138905d24cb3dea7da5cbb185062c7 100644 (file)
@@ -155,7 +155,7 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev,
        *val = 0;
        *val2 = 0;
        switch (mask) {
-       case 0:
+       case IIO_CHAN_INFO_RAW:
                hid_sensor_power_state(&accel_state->common_attributes, true);
                report_id = accel_state->accel[chan->scan_index].report_id;
                address = accel_3d_addresses[chan->scan_index];
index 845fd1c0fd9d57322755a8e1bb169c375198c2a9..873c2bf637c0c6ab5d33259b91847294b1f68772 100644 (file)
@@ -158,7 +158,7 @@ static unsigned int ad5380_info_to_reg(struct iio_chan_spec const *chan,
        long info)
 {
        switch (info) {
-       case 0:
+       case IIO_CHAN_INFO_RAW:
                return AD5380_REG_DATA(chan->address);
        case IIO_CHAN_INFO_CALIBBIAS:
                return AD5380_REG_OFFSET(chan->address);
index 033f20eca6164553035e1e82992a92d3ef543f13..9333177062c0c16c5f691ab64ef5b528bd5fa828 100644 (file)
@@ -168,7 +168,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg,
 static int ad5764_chan_info_to_reg(struct iio_chan_spec const *chan, long info)
 {
        switch (info) {
-       case 0:
+       case IIO_CHAN_INFO_RAW:
                return AD5764_REG_DATA(chan->address);
        case IIO_CHAN_INFO_CALIBBIAS:
                return AD5764_REG_OFFSET(chan->address);
index f59995a90387a7f6d17d4082c983c1bd8d884126..36941e69f95956a71898cb714fd3da49b1a19dbf 100644 (file)
@@ -115,7 +115,7 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev,
        *val = 0;
        *val2 = 0;
        switch (mask) {
-       case 0:
+       case IIO_CHAN_INFO_RAW:
                hid_sensor_power_state(&gyro_state->common_attributes, true);
                report_id = gyro_state->gyro[chan->scan_index].report_id;
                address = gyro_3d_addresses[chan->scan_index];
index befd693a4a3170c9ac5b2251616283c3671c6d7c..406caaee9a3c54b6da43a4b697f302a165be927a 100644 (file)
@@ -97,7 +97,7 @@ static int als_read_raw(struct iio_dev *indio_dev,
        *val = 0;
        *val2 = 0;
        switch (mask) {
-       case 0:
+       case IIO_CHAN_INFO_RAW:
                switch (chan->scan_index) {
                case  CHANNEL_SCAN_INDEX_INTENSITY:
                case  CHANNEL_SCAN_INDEX_ILLUM:
index 36208a3652e913c35dac55122bda6b4ac1624e34..ff5a3324b4898554317121d1055b67cce33a4a62 100644 (file)
@@ -199,7 +199,7 @@ static int lm3533_als_read_raw(struct iio_dev *indio_dev,
        int ret;
 
        switch (mask) {
-       case 0:
+       case IIO_CHAN_INFO_RAW:
                switch (chan->type) {
                case IIO_LIGHT:
                        ret = lm3533_als_get_adc(indio_dev, false, val);