diff options
author | Ivaylo Dimitrov <freemangordon@abv.bg> | 2014-01-13 12:24:00 -0500 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2014-01-18 06:36:04 -0500 |
commit | 3b5c1635d12a670a0fea5542ada5bceb6536ae85 (patch) | |
tree | 5b04b2ef38a2a89b7c447ecaebcaa7f9bbd5b13a | |
parent | 38408d056188be29a6c4e17f3703c796551bb330 (diff) |
iio: tsl2563: Use the correct channel2 member
Use the correct channel2 member instead of channel when dealing with sysfs
reads/writes
Signed-off-by: Ivaylo Dimitrov <ivo.g.dimitrov.75@gmail.com>
Acked-by: Peter Meerwald <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/light/tsl2563.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 5e5d9dea22c5..2be6df3a1350 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c | |||
@@ -460,10 +460,14 @@ static int tsl2563_write_raw(struct iio_dev *indio_dev, | |||
460 | { | 460 | { |
461 | struct tsl2563_chip *chip = iio_priv(indio_dev); | 461 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
462 | 462 | ||
463 | if (chan->channel == IIO_MOD_LIGHT_BOTH) | 463 | if (mask != IIO_CHAN_INFO_CALIBSCALE) |
464 | return -EINVAL; | ||
465 | if (chan->channel2 == IIO_MOD_LIGHT_BOTH) | ||
464 | chip->calib0 = calib_from_sysfs(val); | 466 | chip->calib0 = calib_from_sysfs(val); |
465 | else | 467 | else if (chan->channel2 == IIO_MOD_LIGHT_IR) |
466 | chip->calib1 = calib_from_sysfs(val); | 468 | chip->calib1 = calib_from_sysfs(val); |
469 | else | ||
470 | return -EINVAL; | ||
467 | 471 | ||
468 | return 0; | 472 | return 0; |
469 | } | 473 | } |
@@ -472,14 +476,14 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, | |||
472 | struct iio_chan_spec const *chan, | 476 | struct iio_chan_spec const *chan, |
473 | int *val, | 477 | int *val, |
474 | int *val2, | 478 | int *val2, |
475 | long m) | 479 | long mask) |
476 | { | 480 | { |
477 | int ret = -EINVAL; | 481 | int ret = -EINVAL; |
478 | u32 calib0, calib1; | 482 | u32 calib0, calib1; |
479 | struct tsl2563_chip *chip = iio_priv(indio_dev); | 483 | struct tsl2563_chip *chip = iio_priv(indio_dev); |
480 | 484 | ||
481 | mutex_lock(&chip->lock); | 485 | mutex_lock(&chip->lock); |
482 | switch (m) { | 486 | switch (mask) { |
483 | case IIO_CHAN_INFO_RAW: | 487 | case IIO_CHAN_INFO_RAW: |
484 | case IIO_CHAN_INFO_PROCESSED: | 488 | case IIO_CHAN_INFO_PROCESSED: |
485 | switch (chan->type) { | 489 | switch (chan->type) { |
@@ -498,7 +502,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, | |||
498 | ret = tsl2563_get_adc(chip); | 502 | ret = tsl2563_get_adc(chip); |
499 | if (ret) | 503 | if (ret) |
500 | goto error_ret; | 504 | goto error_ret; |
501 | if (chan->channel == 0) | 505 | if (chan->channel2 == IIO_MOD_LIGHT_BOTH) |
502 | *val = chip->data0; | 506 | *val = chip->data0; |
503 | else | 507 | else |
504 | *val = chip->data1; | 508 | *val = chip->data1; |
@@ -510,7 +514,7 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev, | |||
510 | break; | 514 | break; |
511 | 515 | ||
512 | case IIO_CHAN_INFO_CALIBSCALE: | 516 | case IIO_CHAN_INFO_CALIBSCALE: |
513 | if (chan->channel == 0) | 517 | if (chan->channel2 == IIO_MOD_LIGHT_BOTH) |
514 | *val = calib_to_sysfs(chip->calib0); | 518 | *val = calib_to_sysfs(chip->calib0); |
515 | else | 519 | else |
516 | *val = calib_to_sysfs(chip->calib1); | 520 | *val = calib_to_sysfs(chip->calib1); |