Skip to content

Commit 7807725

Browse files
committed
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.
2 parents ade7615 + 67dbf54 commit 7807725

File tree

9 files changed

+22
-18
lines changed

9 files changed

+22
-18
lines changed

drivers/iio/adc/ti_am335x_adc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev,
183183

184184
static const struct iio_info tiadc_info = {
185185
.read_raw = &tiadc_read_raw,
186+
.driver_module = THIS_MODULE,
186187
};
187188

188189
static int tiadc_probe(struct platform_device *pdev)

drivers/iio/dac/ad7303.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@ static int ad7303_probe(struct spi_device *spi)
235235

236236
if (ext_ref) {
237237
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);
239240
goto err_disable_vdd_reg;
241+
}
240242

241243
ret = regulator_enable(st->vref_reg);
242244
if (ret)

drivers/iio/industrialio-trigger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void iio_trigger_unregister(struct iio_trigger *trig_info)
104104

105105
ida_simple_remove(&iio_trigger_ida, trig_info->id);
106106
/* Possible issue in here */
107-
device_unregister(&trig_info->dev);
107+
device_del(&trig_info->dev);
108108
}
109109
EXPORT_SYMBOL(iio_trigger_unregister);
110110

drivers/iio/inkern.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ static int iio_convert_raw_to_processed_unlocked(struct iio_channel *chan,
451451
int ret;
452452

453453
ret = iio_channel_read(chan, &offset, NULL, IIO_CHAN_INFO_OFFSET);
454-
if (ret == 0)
454+
if (ret >= 0)
455455
raw64 += offset;
456456

457457
scale_type = iio_channel_read(chan, &scale_val, &scale_val2,

drivers/iio/pressure/st_pressure_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
#include <linux/iio/common/st_sensors.h>
2929
#include "st_pressure.h"
3030

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)
3234
#define ST_PRESS_NUMBER_DATA_CHANNELS 1
3335

3436
/* DEFAULT VALUE FOR SENSORS */
@@ -51,8 +53,8 @@
5153
#define ST_PRESS_1_FS_ADDR 0x23
5254
#define ST_PRESS_1_FS_MASK 0x30
5355
#define ST_PRESS_1_FS_AVL_1260_VAL 0x00
54-
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_MBAR_TO_KPASCAL(244141)
5556
#define ST_PRESS_1_FS_AVL_TEMP_GAIN 2083000
57+
#define ST_PRESS_1_FS_AVL_1260_GAIN ST_PRESS_KPASCAL_NANO_SCALE
5658
#define ST_PRESS_1_BDU_ADDR 0x20
5759
#define ST_PRESS_1_BDU_MASK 0x04
5860
#define ST_PRESS_1_DRDY_IRQ_ADDR 0x22

drivers/staging/iio/accel/lis3l02dq_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@ static int lis3l02dq_read_raw(struct iio_dev *indio_dev,
257257
ret = lis3l02dq_read_reg_s16(indio_dev, reg, val);
258258
}
259259
mutex_unlock(&indio_dev->mlock);
260+
if (ret < 0)
261+
goto error_ret;
260262
return IIO_VAL_INT;
261263
case IIO_CHAN_INFO_SCALE:
262264
*val = 0;

drivers/staging/iio/adc/ad7291.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ static const struct iio_info ad7291_info = {
517517
.read_event_value = &ad7291_read_event_value,
518518
.write_event_value = &ad7291_write_event_value,
519519
.event_attrs = &ad7291_event_attribute_group,
520+
.driver_module = THIS_MODULE,
520521
};
521522

522523
static int ad7291_probe(struct i2c_client *client,

drivers/staging/iio/adc/mxs-lradc.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
234234
{
235235
struct mxs_lradc *lradc = iio_priv(iio_dev);
236236
int ret;
237-
unsigned long mask;
238237

239238
if (m != IIO_CHAN_INFO_RAW)
240239
return -EINVAL;
@@ -243,12 +242,6 @@ static int mxs_lradc_read_raw(struct iio_dev *iio_dev,
243242
if (chan->channel > LRADC_MAX_TOTAL_CHANS)
244243
return -EINVAL;
245244

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-
252245
/*
253246
* See if there is no buffered operation in progess. If there is, simply
254247
* 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)
661654
{
662655
int ret;
663656
struct iio_trigger *trig;
657+
struct mxs_lradc *lradc = iio_priv(iio);
664658

665659
trig = iio_trigger_alloc("%s-dev%i", iio->name, iio->id);
666660
if (trig == NULL)
667661
return -ENOMEM;
668662

669-
trig->dev.parent = iio->dev.parent;
663+
trig->dev.parent = lradc->dev;
670664
iio_trigger_set_drvdata(trig, iio);
671665
trig->ops = &mxs_lradc_trigger_ops;
672666

@@ -676,15 +670,17 @@ static int mxs_lradc_trigger_init(struct iio_dev *iio)
676670
return ret;
677671
}
678672

679-
iio->trig = trig;
673+
lradc->trig = trig;
680674

681675
return 0;
682676
}
683677

684678
static void mxs_lradc_trigger_remove(struct iio_dev *iio)
685679
{
686-
iio_trigger_unregister(iio->trig);
687-
iio_trigger_free(iio->trig);
680+
struct mxs_lradc *lradc = iio_priv(iio);
681+
682+
iio_trigger_unregister(lradc->trig);
683+
iio_trigger_free(lradc->trig);
688684
}
689685

690686
static int mxs_lradc_buffer_preenable(struct iio_dev *iio)

include/linux/iio/iio.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,8 @@ struct iio_chan_spec {
211211
static inline bool iio_channel_has_info(const struct iio_chan_spec *chan,
212212
enum iio_chan_info_enum type)
213213
{
214-
return (chan->info_mask_separate & type) |
215-
(chan->info_mask_shared_by_type & type);
214+
return (chan->info_mask_separate & BIT(type)) |
215+
(chan->info_mask_shared_by_type & BIT(type));
216216
}
217217

218218
#define IIO_ST(si, rb, sb, sh) \

0 commit comments

Comments
 (0)