Commit 3b5c1635 authored by Ivaylo Dimitrov's avatar Ivaylo Dimitrov Committed by Jonathan Cameron

iio: tsl2563: Use the correct channel2 member

Use the correct channel2 member instead of channel when dealing with sysfs
reads/writes
Signed-off-by: default avatarIvaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Acked-by: default avatarPeter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 38408d05
...@@ -460,10 +460,14 @@ static int tsl2563_write_raw(struct iio_dev *indio_dev, ...@@ -460,10 +460,14 @@ static int tsl2563_write_raw(struct iio_dev *indio_dev,
{ {
struct tsl2563_chip *chip = iio_priv(indio_dev); struct tsl2563_chip *chip = iio_priv(indio_dev);
if (chan->channel == IIO_MOD_LIGHT_BOTH) if (mask != IIO_CHAN_INFO_CALIBSCALE)
return -EINVAL;
if (chan->channel2 == IIO_MOD_LIGHT_BOTH)
chip->calib0 = calib_from_sysfs(val); chip->calib0 = calib_from_sysfs(val);
else else if (chan->channel2 == IIO_MOD_LIGHT_IR)
chip->calib1 = calib_from_sysfs(val); chip->calib1 = calib_from_sysfs(val);
else
return -EINVAL;
return 0; return 0;
} }
...@@ -472,14 +476,14 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, ...@@ -472,14 +476,14 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan, struct iio_chan_spec const *chan,
int *val, int *val,
int *val2, int *val2,
long m) long mask)
{ {
int ret = -EINVAL; int ret = -EINVAL;
u32 calib0, calib1; u32 calib0, calib1;
struct tsl2563_chip *chip = iio_priv(indio_dev); struct tsl2563_chip *chip = iio_priv(indio_dev);
mutex_lock(&chip->lock); mutex_lock(&chip->lock);
switch (m) { switch (mask) {
case IIO_CHAN_INFO_RAW: case IIO_CHAN_INFO_RAW:
case IIO_CHAN_INFO_PROCESSED: case IIO_CHAN_INFO_PROCESSED:
switch (chan->type) { switch (chan->type) {
...@@ -498,7 +502,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, ...@@ -498,7 +502,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
ret = tsl2563_get_adc(chip); ret = tsl2563_get_adc(chip);
if (ret) if (ret)
goto error_ret; goto error_ret;
if (chan->channel == 0) if (chan->channel2 == IIO_MOD_LIGHT_BOTH)
*val = chip->data0; *val = chip->data0;
else else
*val = chip->data1; *val = chip->data1;
...@@ -510,7 +514,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, ...@@ -510,7 +514,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
break; break;
case IIO_CHAN_INFO_CALIBSCALE: case IIO_CHAN_INFO_CALIBSCALE:
if (chan->channel == 0) if (chan->channel2 == IIO_MOD_LIGHT_BOTH)
*val = calib_to_sysfs(chip->calib0); *val = calib_to_sysfs(chip->calib0);
else else
*val = calib_to_sysfs(chip->calib1); *val = calib_to_sysfs(chip->calib1);
......
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