summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/iio/adc/at91_adc.c16
-rw-r--r--drivers/iio/adc/men_z188_adc.c4
-rw-r--r--drivers/iio/adc/twl4030-madc.c1
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c3
-rw-r--r--drivers/iio/magnetometer/ak8975.c9
-rw-r--r--drivers/iio/pressure/mpl3115.c6
-rw-r--r--drivers/staging/iio/Kconfig9
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c12
-rw-r--r--drivers/staging/iio/light/tsl2x7x_core.c8
9 files changed, 37 insertions, 31 deletions
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 3b5bacd4d8da..2b6a9ce9927c 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -510,12 +510,11 @@ static int at91_adc_channel_init(struct iio_dev *idev)
510 return idev->num_channels; 510 return idev->num_channels;
511} 511}
512 512
513static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev, 513static int at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
514 struct at91_adc_trigger *triggers, 514 struct at91_adc_trigger *triggers,
515 const char *trigger_name) 515 const char *trigger_name)
516{ 516{
517 struct at91_adc_state *st = iio_priv(idev); 517 struct at91_adc_state *st = iio_priv(idev);
518 u8 value = 0;
519 int i; 518 int i;
520 519
521 for (i = 0; i < st->trigger_number; i++) { 520 for (i = 0; i < st->trigger_number; i++) {
@@ -528,15 +527,16 @@ static u8 at91_adc_get_trigger_value_by_name(struct iio_dev *idev,
528 return -ENOMEM; 527 return -ENOMEM;
529 528
530 if (strcmp(trigger_name, name) == 0) { 529 if (strcmp(trigger_name, name) == 0) {
531 value = triggers[i].value;
532 kfree(name); 530 kfree(name);
533 break; 531 if (triggers[i].value == 0)
532 return -EINVAL;
533 return triggers[i].value;
534 } 534 }
535 535
536 kfree(name); 536 kfree(name);
537 } 537 }
538 538
539 return value; 539 return -EINVAL;
540} 540}
541 541
542static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state) 542static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
@@ -546,14 +546,14 @@ static int at91_adc_configure_trigger(struct iio_trigger *trig, bool state)
546 struct iio_buffer *buffer = idev->buffer; 546 struct iio_buffer *buffer = idev->buffer;
547 struct at91_adc_reg_desc *reg = st->registers; 547 struct at91_adc_reg_desc *reg = st->registers;
548 u32 status = at91_adc_readl(st, reg->trigger_register); 548 u32 status = at91_adc_readl(st, reg->trigger_register);
549 u8 value; 549 int value;
550 u8 bit; 550 u8 bit;
551 551
552 value = at91_adc_get_trigger_value_by_name(idev, 552 value = at91_adc_get_trigger_value_by_name(idev,
553 st->trigger_list, 553 st->trigger_list,
554 idev->trig->name); 554 idev->trig->name);
555 if (value == 0) 555 if (value < 0)
556 return -EINVAL; 556 return value;
557 557
558 if (state) { 558 if (state) {
559 st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL); 559 st->buffer = kmalloc(idev->scan_bytes, GFP_KERNEL);
diff --git a/drivers/iio/adc/men_z188_adc.c b/drivers/iio/adc/men_z188_adc.c
index 6989c16aec2b..b58d6302521f 100644
--- a/drivers/iio/adc/men_z188_adc.c
+++ b/drivers/iio/adc/men_z188_adc.c
@@ -121,8 +121,8 @@ static int men_z188_probe(struct mcb_device *dev,
121 indio_dev->num_channels = ARRAY_SIZE(z188_adc_iio_channels); 121 indio_dev->num_channels = ARRAY_SIZE(z188_adc_iio_channels);
122 122
123 mem = mcb_request_mem(dev, "z188-adc"); 123 mem = mcb_request_mem(dev, "z188-adc");
124 if (!mem) 124 if (IS_ERR(mem))
125 return -ENOMEM; 125 return PTR_ERR(mem);
126 126
127 adc->base = ioremap(mem->start, resource_size(mem)); 127 adc->base = ioremap(mem->start, resource_size(mem));
128 if (adc->base == NULL) 128 if (adc->base == NULL)
diff --git a/drivers/iio/adc/twl4030-madc.c b/drivers/iio/adc/twl4030-madc.c
index 7de1c4c87942..eb86786e698e 100644
--- a/drivers/iio/adc/twl4030-madc.c
+++ b/drivers/iio/adc/twl4030-madc.c
@@ -645,6 +645,7 @@ int twl4030_get_madc_conversion(int channel_no)
645 req.channels = (1 << channel_no); 645 req.channels = (1 << channel_no);
646 req.method = TWL4030_MADC_SW2; 646 req.method = TWL4030_MADC_SW2;
647 req.active = 0; 647 req.active = 0;
648 req.raw = 0;
648 req.func_cb = NULL; 649 req.func_cb = NULL;
649 ret = twl4030_madc_conversion(&req); 650 ret = twl4030_madc_conversion(&req);
650 if (ret < 0) 651 if (ret < 0)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index 73282cee0c81..a3109a6f4d86 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -75,6 +75,9 @@ int hid_sensor_power_state(struct hid_sensor_common *st, bool state)
75 (s32)report_val); 75 (s32)report_val);
76 } 76 }
77 77
78 sensor_hub_get_feature(st->hsdev, st->power_state.report_id,
79 st->power_state.index,
80 &state_val);
78 return 0; 81 return 0;
79} 82}
80EXPORT_SYMBOL(hid_sensor_power_state); 83EXPORT_SYMBOL(hid_sensor_power_state);
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c
index 09ea5c481f4c..ea08313af0d2 100644
--- a/drivers/iio/magnetometer/ak8975.c
+++ b/drivers/iio/magnetometer/ak8975.c
@@ -373,8 +373,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
373{ 373{
374 struct ak8975_data *data = iio_priv(indio_dev); 374 struct ak8975_data *data = iio_priv(indio_dev);
375 struct i2c_client *client = data->client; 375 struct i2c_client *client = data->client;
376 u16 meas_reg;
377 s16 raw;
378 int ret; 376 int ret;
379 377
380 mutex_lock(&data->lock); 378 mutex_lock(&data->lock);
@@ -422,16 +420,11 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
422 dev_err(&client->dev, "Read axis data fails\n"); 420 dev_err(&client->dev, "Read axis data fails\n");
423 goto exit; 421 goto exit;
424 } 422 }
425 meas_reg = ret;
426 423
427 mutex_unlock(&data->lock); 424 mutex_unlock(&data->lock);
428 425
429 /* Endian conversion of the measured values. */
430 raw = (s16) (le16_to_cpu(meas_reg));
431
432 /* Clamp to valid range. */ 426 /* Clamp to valid range. */
433 raw = clamp_t(s16, raw, -4096, 4095); 427 *val = clamp_t(s16, ret, -4096, 4095);
434 *val = raw;
435 return IIO_VAL_INT; 428 return IIO_VAL_INT;
436 429
437exit: 430exit:
diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c
index ba6d0c520e63..01b2e0b18878 100644
--- a/drivers/iio/pressure/mpl3115.c
+++ b/drivers/iio/pressure/mpl3115.c
@@ -98,7 +98,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
98 mutex_unlock(&data->lock); 98 mutex_unlock(&data->lock);
99 if (ret < 0) 99 if (ret < 0)
100 return ret; 100 return ret;
101 *val = sign_extend32(be32_to_cpu(tmp) >> 12, 23); 101 *val = be32_to_cpu(tmp) >> 12;
102 return IIO_VAL_INT; 102 return IIO_VAL_INT;
103 case IIO_TEMP: /* in 0.0625 celsius / LSB */ 103 case IIO_TEMP: /* in 0.0625 celsius / LSB */
104 mutex_lock(&data->lock); 104 mutex_lock(&data->lock);
@@ -112,7 +112,7 @@ static int mpl3115_read_raw(struct iio_dev *indio_dev,
112 mutex_unlock(&data->lock); 112 mutex_unlock(&data->lock);
113 if (ret < 0) 113 if (ret < 0)
114 return ret; 114 return ret;
115 *val = sign_extend32(be32_to_cpu(tmp) >> 20, 15); 115 *val = sign_extend32(be32_to_cpu(tmp) >> 20, 11);
116 return IIO_VAL_INT; 116 return IIO_VAL_INT;
117 default: 117 default:
118 return -EINVAL; 118 return -EINVAL;
@@ -185,7 +185,7 @@ static const struct iio_chan_spec mpl3115_channels[] = {
185 BIT(IIO_CHAN_INFO_SCALE), 185 BIT(IIO_CHAN_INFO_SCALE),
186 .scan_index = 0, 186 .scan_index = 0,
187 .scan_type = { 187 .scan_type = {
188 .sign = 's', 188 .sign = 'u',
189 .realbits = 20, 189 .realbits = 20,
190 .storagebits = 32, 190 .storagebits = 32,
191 .shift = 12, 191 .shift = 12,
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index b36feb080cba..fa38be0982f9 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -36,10 +36,11 @@ config IIO_SIMPLE_DUMMY_EVENTS
36 Add some dummy events to the simple dummy driver. 36 Add some dummy events to the simple dummy driver.
37 37
38config IIO_SIMPLE_DUMMY_BUFFER 38config IIO_SIMPLE_DUMMY_BUFFER
39 boolean "Buffered capture support" 39 boolean "Buffered capture support"
40 select IIO_KFIFO_BUF 40 select IIO_BUFFER
41 help 41 select IIO_KFIFO_BUF
42 Add buffered data capture to the simple dummy driver. 42 help
43 Add buffered data capture to the simple dummy driver.
43 44
44endif # IIO_SIMPLE_DUMMY 45endif # IIO_SIMPLE_DUMMY
45 46
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index dae8d1a9038e..52d7517b342e 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -846,6 +846,14 @@ static int mxs_lradc_read_single(struct iio_dev *iio_dev, int chan, int *val)
846 LRADC_CTRL1); 846 LRADC_CTRL1);
847 mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0); 847 mxs_lradc_reg_clear(lradc, 0xff, LRADC_CTRL0);
848 848
849 /* Enable / disable the divider per requirement */
850 if (test_bit(chan, &lradc->is_divided))
851 mxs_lradc_reg_set(lradc, 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
852 LRADC_CTRL2);
853 else
854 mxs_lradc_reg_clear(lradc,
855 1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET, LRADC_CTRL2);
856
849 /* Clean the slot's previous content, then set new one. */ 857 /* Clean the slot's previous content, then set new one. */
850 mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0), 858 mxs_lradc_reg_clear(lradc, LRADC_CTRL4_LRADCSELECT_MASK(0),
851 LRADC_CTRL4); 859 LRADC_CTRL4);
@@ -961,15 +969,11 @@ static int mxs_lradc_write_raw(struct iio_dev *iio_dev,
961 if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer && 969 if (val == scale_avail[MXS_LRADC_DIV_DISABLED].integer &&
962 val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) { 970 val2 == scale_avail[MXS_LRADC_DIV_DISABLED].nano) {
963 /* divider by two disabled */ 971 /* divider by two disabled */
964 writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
965 lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_CLR);
966 clear_bit(chan->channel, &lradc->is_divided); 972 clear_bit(chan->channel, &lradc->is_divided);
967 ret = 0; 973 ret = 0;
968 } else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer && 974 } else if (val == scale_avail[MXS_LRADC_DIV_ENABLED].integer &&
969 val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) { 975 val2 == scale_avail[MXS_LRADC_DIV_ENABLED].nano) {
970 /* divider by two enabled */ 976 /* divider by two enabled */
971 writel(1 << LRADC_CTRL2_DIVIDE_BY_TWO_OFFSET,
972 lradc->base + LRADC_CTRL2 + STMP_OFFSET_REG_SET);
973 set_bit(chan->channel, &lradc->is_divided); 977 set_bit(chan->channel, &lradc->is_divided);
974 ret = 0; 978 ret = 0;
975 } 979 }
diff --git a/drivers/staging/iio/light/tsl2x7x_core.c b/drivers/staging/iio/light/tsl2x7x_core.c
index 9e0f2a9c73ae..ab338e3ddd05 100644
--- a/drivers/staging/iio/light/tsl2x7x_core.c
+++ b/drivers/staging/iio/light/tsl2x7x_core.c
@@ -667,9 +667,13 @@ static int tsl2x7x_chip_on(struct iio_dev *indio_dev)
667 chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] = 667 chip->tsl2x7x_config[TSL2X7X_PRX_COUNT] =
668 chip->tsl2x7x_settings.prox_pulse_count; 668 chip->tsl2x7x_settings.prox_pulse_count;
669 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] = 669 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHLO] =
670 chip->tsl2x7x_settings.prox_thres_low; 670 (chip->tsl2x7x_settings.prox_thres_low) & 0xFF;
671 chip->tsl2x7x_config[TSL2X7X_PRX_MINTHRESHHI] =
672 (chip->tsl2x7x_settings.prox_thres_low >> 8) & 0xFF;
671 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] = 673 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHLO] =
672 chip->tsl2x7x_settings.prox_thres_high; 674 (chip->tsl2x7x_settings.prox_thres_high) & 0xFF;
675 chip->tsl2x7x_config[TSL2X7X_PRX_MAXTHRESHHI] =
676 (chip->tsl2x7x_settings.prox_thres_high >> 8) & 0xFF;
673 677
674 /* and make sure we're not already on */ 678 /* and make sure we're not already on */
675 if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) { 679 if (chip->tsl2x7x_chip_status == TSL2X7X_CHIP_WORKING) {