aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-17 01:41:38 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-17 01:41:38 -0400
commit78077256bc08348d587e318957ceb41fe4d4afae (patch)
tree8bc82e916d40a0593519b718a8e85fcf5022be4e
parentade7615de0643a9da628688e661e08148cd7c463 (diff)
parent67dbf54a3b03881c7b683801fa49ca1f2c4c3bcf (diff)
Merge tag 'iio-fixes-for-3.11a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes: The first round of IIO fixes for the 3.11 cycle. This set is larger than I would like, partly due to my lack of review time in the weeks before the merge window and partly because a couple of large drivers and the subsystem as a whole seem to be getting a lot more exposure and testing recently. 1) A long term bug in trigger handling gave a double free of the device. 2) Wrong return value handling means offsets are ignored in iio_convert_raw_to_processed_unlocked. 3) The iio_channel_has_info utility function was incorrectly updated during the recent info_mask split, this is now fixed. 4) mxs-lradc has a couple of little fixes. 5) A couple of missing .driver_module entries meant that drivers could be removed from underneath their users. 6) Error path fixes for ad7303 and lis3l02dq. 7) The scale value for presure in the lps331ap driver was out by a factor of 100.
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c1
-rw-r--r--drivers/iio/dac/ad7303.c4
-rw-r--r--drivers/iio/industrialio-trigger.c2
-rw-r--r--drivers/iio/inkern.c2
-rw-r--r--drivers/iio/pressure/st_pressure_core.c6
-rw-r--r--drivers/staging/iio/accel/lis3l02dq_core.c2
-rw-r--r--drivers/staging/iio/adc/ad7291.c1
-rw-r--r--drivers/staging/iio/adc/mxs-lradc.c18
-rw-r--r--include/linux/iio/iio.h4
9 files changed, 22 insertions, 18 deletions
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 4427e8e46a7f..0ad208a69c29 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -183,6 +183,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
183 183
184static const struct iio_info tiadc_info = { 184static const struct iio_info tiadc_info = {
185 .read_raw = &tiadc_read_raw, 185 .read_raw = &tiadc_read_raw,
186 .driver_module = THIS_MODULE,
186}; 187};
187 188
188static int tiadc_probe(struct platform_device *pdev) 189static int tiadc_probe(struct platform_device *pdev)
diff --git a/drivers/iio/dac/ad7303.c b/drivers/iio/dac/ad7303.c
index 85aeef60dc5f..d546f50f9258 100644
--- a/drivers/iio/dac/ad7303.c
+++ b/drivers/iio/dac/ad7303.c
@@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi)
235 235
236 if (ext_ref) { 236 if (ext_ref) {
237 st->vref_reg = regulator_get(&spi->dev, "REF"); 237 st->vref_reg = regulator_get(&spi->dev, "REF");
238 if (IS_ERR(st->vref_reg)) 238 if (IS_ERR(st->vref_reg)) {
239 ret = PTR_ERR(st->vref_reg);
239 goto err_disable_vdd_reg; 240 goto err_disable_vdd_reg;
241 }
240 242
241 ret = regulator_enable(st->vref_reg); 243 ret = regulator_enable(st->vref_reg);
242 if (ret) 244 if (ret)
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c
index 4d6c7d84e155..ea8a4146620d 100644
--- a/drivers/iio/industrialio-trigger.c
+++ b/drivers/iio/industrialio-trigger.c
@@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
104 104
105 ida_simple_remove(&iio_trigger_ida, trig_info->id); 105 ida_simple_remove(&iio_trigger_ida, trig_info->id);
106 /* Possible issue in here */ 106 /* Possible issue in here */
107 device_unregister(&trig_info->dev); 107 device_del(&trig_info->dev);
108} 108}
109EXPORT_SYMBOL(iio_trigger_unregister); 109EXPORT_SYMBOL(iio_trigger_unregister);
110 110
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
index 98ddc323add0..0cf5f8e06cfc 100644
--- a/drivers/iio/inkern.c
+++ b/drivers/iio/inkern.c
@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
451 int ret; 451 int ret;
452 452
453 ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET); 453 ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
454 if (ret == 0) 454 if (ret >= 0)
455 raw64 += offset; 455 raw64 += offset;
456 456
457 scale_type = iio_channel_read(chan, &scale_val, &scale_val2, 457 scale_type = iio_channel_read(chan, &scale_val, &scale_val2,
diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c
index 9c343b40665e..3ffbc56917b4 100644
--- a/drivers/iio/pressure/st_pressure_core.c
+++ b/drivers/iio/pressure/st_pressure_core.c
@@ -28,7 +28,9 @@
28#include <linux/iio/common/st_sensors.h> 28#include <linux/iio/common/st_sensors.h>
29#include "st_pressure.h" 29#include "st_pressure.h"
30 30
31#define ST_PRESS_MBAR_TO_KPASCAL(x) (x * 10) 31#define ST_PRESS_LSB_PER_MBAR 4096UL
32#define ST_PRESS_KPASCAL_NANO_SCALE (100000000UL / \
33 ST_PRESS_LSB_PER_MBAR)
32#define ST_PRESS_NUMBER_DATA_CHANNELS 1 34#define ST_PRESS_NUMBER_DATA_CHANNELS 1
33 35
34/* DEFAULT VALUE FOR SENSORS */ 36/* DEFAULT VALUE FOR SENSORS */
@@ -51,8 +53,8 @@
51#define ST_PRESS_1_FS_ADDR 0x23 53#define ST_PRESS_1_FS_ADDR 0x23
52#define ST_PRESS_1_FS_MASK 0x30 54#define ST_PRESS_1_FS_MASK 0x30
53#define ST_PRESS_1_FS_AVL_1260_VAL 0x00 55#define ST_PRESS_1_FS_AVL_1260_VAL 0x00
54#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141)
55#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000 56#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000
57#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
56#define ST_PRESS_1_BDU_ADDR 0x20 58#define ST_PRESS_1_BDU_ADDR 0x20
57#define ST_PRESS_1_BDU_MASK 0x04 59#define ST_PRESS_1_BDU_MASK 0x04
58#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22 60#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22
diff --git a/drivers/staging/iio/accel/lis3l02dq_core.c b/drivers/staging/iio/accel/lis3l02dq_core.c
index 1bfe5d81792b..8ed75a94f465 100644
--- a/drivers/staging/iio/accel/lis3l02dq_core.c
+++ b/drivers/staging/iio/accel/lis3l02dq_core.c
@@ -257,6 +257,8 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
257 ret = lis3l02dq_read_reg_s16(indio_dev, reg, val); 257 ret = lis3l02dq_read_reg_s16(indio_dev, reg, val);
258 } 258 }
259 mutex_unlock(&indio_dev->mlock); 259 mutex_unlock(&indio_dev->mlock);
260 if (ret < 0)
261 goto error_ret;
260 return IIO_VAL_INT; 262 return IIO_VAL_INT;
261 case IIO_CHAN_INFO_SCALE: 263 case IIO_CHAN_INFO_SCALE:
262 *val = 0; 264 *val = 0;
diff --git a/drivers/staging/iio/adc/ad7291.c b/drivers/staging/iio/adc/ad7291.c
index 3fc79e582750..a2e61c2fc8d1 100644
--- a/drivers/staging/iio/adc/ad7291.c
+++ b/drivers/staging/iio/adc/ad7291.c
@@ -517,6 +517,7 @@ static const struct iio_info ad7291_info = {
517 .read_event_value = &ad7291_read_event_value, 517 .read_event_value = &ad7291_read_event_value,
518 .write_event_value = &ad7291_write_event_value, 518 .write_event_value = &ad7291_write_event_value,
519 .event_attrs = &ad7291_event_attribute_group, 519 .event_attrs = &ad7291_event_attribute_group,
520 .driver_module = THIS_MODULE,
520}; 521};
521 522
522static int ad7291_probe(struct i2c_client *client, 523static int ad7291_probe(struct i2c_client *client,
diff --git a/drivers/staging/iio/adc/mxs-lradc.c b/drivers/staging/iio/adc/mxs-lradc.c
index d92c97a59d61..9f52a2857929 100644
--- a/drivers/staging/iio/adc/mxs-lradc.c
+++ b/drivers/staging/iio/adc/mxs-lradc.c
@@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
234{ 234{
235 struct mxs_lradc *lradc = iio_priv(iio_dev); 235 struct mxs_lradc *lradc = iio_priv(iio_dev);
236 int ret; 236 int ret;
237 unsigned long mask;
238 237
239 if (m != IIO_CHAN_INFO_RAW) 238 if (m != IIO_CHAN_INFO_RAW)
240 return -EINVAL; 239 return -EINVAL;
@@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
243 if (chan->channel > LRADC_MAX_TOTAL_CHANS) 242 if (chan->channel > LRADC_MAX_TOTAL_CHANS)
244 return -EINVAL; 243 return -EINVAL;
245 244
246 /* Validate the channel if it doesn't intersect with reserved chans. */
247 bitmap_set(&mask, chan->channel, 1);
248 ret = iio_validate_scan_mask_onehot(iio_dev, &mask);
249 if (ret)
250 return -EINVAL;
251
252 /* 245 /*
253 * See if there is no buffered operation in progess. If there is, simply 246 * See if there is no buffered operation in progess. If there is, simply
254 * bail out. This can be improved to support both buffered and raw IO at 247 * bail out. This can be improved to support both buffered and raw IO at
@@ -661,12 +654,13 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
661{ 654{
662 int ret; 655 int ret;
663 struct iio_trigger *trig; 656 struct iio_trigger *trig;
657 struct mxs_lradc *lradc = iio_priv(iio);
664 658
665 trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id); 659 trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
666 if (trig == NULL) 660 if (trig == NULL)
667 return -ENOMEM; 661 return -ENOMEM;
668 662
669 trig->dev.parent = iio->dev.parent; 663 trig->dev.parent = lradc->dev;
670 iio_trigger_set_drvdata(trig, iio); 664 iio_trigger_set_drvdata(trig, iio);
671 trig->ops = &mxs_lradc_trigger_ops; 665 trig->ops = &mxs_lradc_trigger_ops;
672 666
@@ -676,15 +670,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
676 return ret; 670 return ret;
677 } 671 }
678 672
679 iio->trig = trig; 673 lradc->trig = trig;
680 674
681 return 0; 675 return 0;
682} 676}
683 677
684static void mxs_lradc_trigger_remove(struct iio_dev *iio) 678static void mxs_lradc_trigger_remove(struct iio_dev *iio)
685{ 679{
686 iio_trigger_unregister(iio->trig); 680 struct mxs_lradc *lradc = iio_priv(iio);
687 iio_trigger_free(iio->trig); 681
682 iio_trigger_unregister(lradc->trig);
683 iio_trigger_free(lradc->trig);
688} 684}
689 685
690static int mxs_lradc_buffer_preenable(struct iio_dev *iio) 686static int mxs_lradc_buffer_preenable(struct iio_dev *iio)
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index 8d171f427632..3d35b7023591 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -211,8 +211,8 @@ struct iio_chan_spec {
211static inline bool iio_channel_has_info(const struct iio_chan_spec *chan, 211static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
212 enum iio_chan_info_enum type) 212 enum iio_chan_info_enum type)
213{ 213{
214 return (chan->info_mask_separate & type) | 214 return (chan->info_mask_separate & BIT(type)) |
215 (chan->info_mask_shared_by_type & type); 215 (chan->info_mask_shared_by_type & BIT(type));
216} 216}
217 217
218#define IIO_ST(si, rb, sb, sh) \ 218#define IIO_ST(si, rb, sb, sh) \