Commit 67464a54 authored by Rodrigo Siqueira's avatar Rodrigo Siqueira Committed by Jonathan Cameron

iio: Replace occurrences of magic number 0 by IIO_CHAN_INFO_RAW

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: default avatarRodrigo Siqueira <rodrigosiqueiramelo@gmail.com>
Signed-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent f22fb87d
...@@ -155,7 +155,7 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev, ...@@ -155,7 +155,7 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev,
*val = 0; *val = 0;
*val2 = 0; *val2 = 0;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
hid_sensor_power_state(&accel_state->common_attributes, true); hid_sensor_power_state(&accel_state->common_attributes, true);
report_id = accel_state->accel[chan->scan_index].report_id; report_id = accel_state->accel[chan->scan_index].report_id;
address = accel_3d_addresses[chan->scan_index]; address = accel_3d_addresses[chan->scan_index];
......
...@@ -158,7 +158,7 @@ static unsigned int ad5380_info_to_reg(struct iio_chan_spec const *chan, ...@@ -158,7 +158,7 @@ static unsigned int ad5380_info_to_reg(struct iio_chan_spec const *chan,
long info) long info)
{ {
switch (info) { switch (info) {
case 0: case IIO_CHAN_INFO_RAW:
return AD5380_REG_DATA(chan->address); return AD5380_REG_DATA(chan->address);
case IIO_CHAN_INFO_CALIBBIAS: case IIO_CHAN_INFO_CALIBBIAS:
return AD5380_REG_OFFSET(chan->address); return AD5380_REG_OFFSET(chan->address);
......
...@@ -168,7 +168,7 @@ static int ad5764_read(struct iio_dev *indio_dev, unsigned int reg, ...@@ -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) static int ad5764_chan_info_to_reg(struct iio_chan_spec const *chan, long info)
{ {
switch (info) { switch (info) {
case 0: case IIO_CHAN_INFO_RAW:
return AD5764_REG_DATA(chan->address); return AD5764_REG_DATA(chan->address);
case IIO_CHAN_INFO_CALIBBIAS: case IIO_CHAN_INFO_CALIBBIAS:
return AD5764_REG_OFFSET(chan->address); return AD5764_REG_OFFSET(chan->address);
......
...@@ -115,7 +115,7 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev, ...@@ -115,7 +115,7 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev,
*val = 0; *val = 0;
*val2 = 0; *val2 = 0;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
hid_sensor_power_state(&gyro_state->common_attributes, true); hid_sensor_power_state(&gyro_state->common_attributes, true);
report_id = gyro_state->gyro[chan->scan_index].report_id; report_id = gyro_state->gyro[chan->scan_index].report_id;
address = gyro_3d_addresses[chan->scan_index]; address = gyro_3d_addresses[chan->scan_index];
......
...@@ -97,7 +97,7 @@ static int als_read_raw(struct iio_dev *indio_dev, ...@@ -97,7 +97,7 @@ static int als_read_raw(struct iio_dev *indio_dev,
*val = 0; *val = 0;
*val2 = 0; *val2 = 0;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
switch (chan->scan_index) { switch (chan->scan_index) {
case CHANNEL_SCAN_INDEX_INTENSITY: case CHANNEL_SCAN_INDEX_INTENSITY:
case CHANNEL_SCAN_INDEX_ILLUM: case CHANNEL_SCAN_INDEX_ILLUM:
......
...@@ -199,7 +199,7 @@ static int lm3533_als_read_raw(struct iio_dev *indio_dev, ...@@ -199,7 +199,7 @@ static int lm3533_als_read_raw(struct iio_dev *indio_dev,
int ret; int ret;
switch (mask) { switch (mask) {
case 0: case IIO_CHAN_INFO_RAW:
switch (chan->type) { switch (chan->type) {
case IIO_LIGHT: case IIO_LIGHT:
ret = lm3533_als_get_adc(indio_dev, false, val); ret = lm3533_als_get_adc(indio_dev, false, val);
......
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