Skip to content

Commit 48436e8

Browse files
committed
Merge tag 'iio-fixes-for-4.5a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes: First set of IIO fixes for the 4.5 cycle. This set comprises those not dependent on patches in the 4.5 merge cycle. A second set will follow shortly with ones that are. * core in kernel interfaces - fix a possible NULL dereference that is a theoretical possibility via odd usage of iio_channel_release. Pretty much a hardening of the interface, but observed in the wild with the twl4030_charger driver. * acpi-als - report the data as processed as it is in lux. This fixes a wrong use of the IIO ABI. However, old _raw version retained to avoid breaking any userspace in the wild that is relying on that (none known but it doesn't hurt us much to retain it) * ade7753 - fix some error handling to avoid use of unitialized data. * ltr501 - use a signed return type for ltr501_match_samp_freq so as to allow returning of an error code. * mcp4725 - set name field of struct iio_dev to ensure the sysfs name attribute doesn't give NULL. * mpl115 - temperature offset sign is wrong. * stk8ba50 - IIO_TRIGGER dependency added * ti_am335x_adc - Label buffer as a software buffer. It's actually a hybrid of a true hardware buffer feeding a kfifo, but the meaning of these fields has changed a little recently and in this case it should be labeled a software buffer ensure it is allowed to use the kfifo. * vf610_adc - HAS_IOMEM dependency
2 parents 8d9b39c + 7e1da86 commit 48436e8

File tree

9 files changed

+22
-7
lines changed

9 files changed

+22
-7
lines changed

drivers/iio/accel/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ config STK8312
213213
config STK8BA50
214214
tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver"
215215
depends on I2C
216+
depends on IIO_TRIGGER
216217
help
217218
Say yes here to get support for the Sensortek STK8BA50 3-axis
218219
accelerometer.

drivers/iio/adc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ config TWL6030_GPADC
409409
config VF610_ADC
410410
tristate "Freescale vf610 ADC driver"
411411
depends on OF
412+
depends on HAS_IOMEM
412413
select IIO_BUFFER
413414
select IIO_TRIGGERED_BUFFER
414415
help

drivers/iio/adc/ti_am335x_adc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
289289
goto error_kfifo_free;
290290

291291
indio_dev->setup_ops = setup_ops;
292-
indio_dev->modes |= INDIO_BUFFER_HARDWARE;
292+
indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
293293

294294
return 0;
295295

drivers/iio/dac/mcp4725.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ static int mcp4725_probe(struct i2c_client *client,
300300
data->client = client;
301301

302302
indio_dev->dev.parent = &client->dev;
303+
indio_dev->name = id->name;
303304
indio_dev->info = &mcp4725_info;
304305
indio_dev->channels = &mcp4725_channel;
305306
indio_dev->num_channels = 1;

drivers/iio/inkern.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ EXPORT_SYMBOL_GPL(iio_channel_get);
349349

350350
void iio_channel_release(struct iio_channel *channel)
351351
{
352+
if (!channel)
353+
return;
352354
iio_device_put(channel->indio_dev);
353355
kfree(channel);
354356
}

drivers/iio/light/acpi-als.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@ static const struct iio_chan_spec acpi_als_channels[] = {
5454
.realbits = 32,
5555
.storagebits = 32,
5656
},
57-
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
57+
/* _RAW is here for backward ABI compatibility */
58+
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
59+
BIT(IIO_CHAN_INFO_PROCESSED),
5860
},
5961
};
6062

@@ -152,7 +154,7 @@ static int acpi_als_read_raw(struct iio_dev *indio_dev,
152154
s32 temp_val;
153155
int ret;
154156

155-
if (mask != IIO_CHAN_INFO_RAW)
157+
if ((mask != IIO_CHAN_INFO_PROCESSED) && (mask != IIO_CHAN_INFO_RAW))
156158
return -EINVAL;
157159

158160
/* we support only illumination (_ALI) so far. */

drivers/iio/light/ltr501.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ static const struct ltr501_samp_table ltr501_ps_samp_table[] = {
180180
{500000, 2000000}
181181
};
182182

183-
static unsigned int ltr501_match_samp_freq(const struct ltr501_samp_table *tab,
183+
static int ltr501_match_samp_freq(const struct ltr501_samp_table *tab,
184184
int len, int val, int val2)
185185
{
186186
int i, freq;

drivers/iio/pressure/mpl115.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static int mpl115_read_raw(struct iio_dev *indio_dev,
117117
*val = ret >> 6;
118118
return IIO_VAL_INT;
119119
case IIO_CHAN_INFO_OFFSET:
120-
*val = 605;
120+
*val = -605;
121121
*val2 = 750000;
122122
return IIO_VAL_INT_PLUS_MICRO;
123123
case IIO_CHAN_INFO_SCALE:

drivers/staging/iio/meter/ade7753.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,12 @@ static ssize_t ade7753_write_16bit(struct device *dev,
217217
static int ade7753_reset(struct device *dev)
218218
{
219219
u16 val;
220+
int ret;
221+
222+
ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
223+
if (ret)
224+
return ret;
220225

221-
ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
222226
val |= BIT(6); /* Software Chip Reset */
223227

224228
return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
@@ -343,8 +347,12 @@ static int ade7753_set_irq(struct device *dev, bool enable)
343347
static int ade7753_stop_device(struct device *dev)
344348
{
345349
u16 val;
350+
int ret;
351+
352+
ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
353+
if (ret)
354+
return ret;
346355

347-
ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
348356
val |= BIT(4); /* AD converters can be turned off */
349357

350358
return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);

0 commit comments

Comments
 (0)