Commit 48436e82 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'iio-fixes-for-4.5a' of...

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
parents 8d9b39c6 7e1da863
...@@ -213,6 +213,7 @@ config STK8312 ...@@ -213,6 +213,7 @@ config STK8312
config STK8BA50 config STK8BA50
tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver" tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver"
depends on I2C depends on I2C
depends on IIO_TRIGGER
help help
Say yes here to get support for the Sensortek STK8BA50 3-axis Say yes here to get support for the Sensortek STK8BA50 3-axis
accelerometer. accelerometer.
......
...@@ -409,6 +409,7 @@ config TWL6030_GPADC ...@@ -409,6 +409,7 @@ config TWL6030_GPADC
config VF610_ADC config VF610_ADC
tristate "Freescale vf610 ADC driver" tristate "Freescale vf610 ADC driver"
depends on OF depends on OF
depends on HAS_IOMEM
select IIO_BUFFER select IIO_BUFFER
select IIO_TRIGGERED_BUFFER select IIO_TRIGGERED_BUFFER
help help
......
...@@ -289,7 +289,7 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev, ...@@ -289,7 +289,7 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
goto error_kfifo_free; goto error_kfifo_free;
indio_dev->setup_ops = setup_ops; indio_dev->setup_ops = setup_ops;
indio_dev->modes |= INDIO_BUFFER_HARDWARE; indio_dev->modes |= INDIO_BUFFER_SOFTWARE;
return 0; return 0;
......
...@@ -300,6 +300,7 @@ static int mcp4725_probe(struct i2c_client *client, ...@@ -300,6 +300,7 @@ static int mcp4725_probe(struct i2c_client *client,
data->client = client; data->client = client;
indio_dev->dev.parent = &client->dev; indio_dev->dev.parent = &client->dev;
indio_dev->name = id->name;
indio_dev->info = &mcp4725_info; indio_dev->info = &mcp4725_info;
indio_dev->channels = &mcp4725_channel; indio_dev->channels = &mcp4725_channel;
indio_dev->num_channels = 1; indio_dev->num_channels = 1;
......
...@@ -349,6 +349,8 @@ EXPORT_SYMBOL_GPL(iio_channel_get); ...@@ -349,6 +349,8 @@ EXPORT_SYMBOL_GPL(iio_channel_get);
void iio_channel_release(struct iio_channel *channel) void iio_channel_release(struct iio_channel *channel)
{ {
if (!channel)
return;
iio_device_put(channel->indio_dev); iio_device_put(channel->indio_dev);
kfree(channel); kfree(channel);
} }
......
...@@ -54,7 +54,9 @@ static const struct iio_chan_spec acpi_als_channels[] = { ...@@ -54,7 +54,9 @@ static const struct iio_chan_spec acpi_als_channels[] = {
.realbits = 32, .realbits = 32,
.storagebits = 32, .storagebits = 32,
}, },
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW), /* _RAW is here for backward ABI compatibility */
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
BIT(IIO_CHAN_INFO_PROCESSED),
}, },
}; };
...@@ -152,7 +154,7 @@ static int acpi_als_read_raw(struct iio_dev *indio_dev, ...@@ -152,7 +154,7 @@ static int acpi_als_read_raw(struct iio_dev *indio_dev,
s32 temp_val; s32 temp_val;
int ret; int ret;
if (mask != IIO_CHAN_INFO_RAW) if ((mask != IIO_CHAN_INFO_PROCESSED) && (mask != IIO_CHAN_INFO_RAW))
return -EINVAL; return -EINVAL;
/* we support only illumination (_ALI) so far. */ /* we support only illumination (_ALI) so far. */
......
...@@ -180,7 +180,7 @@ static const struct ltr501_samp_table ltr501_ps_samp_table[] = { ...@@ -180,7 +180,7 @@ static const struct ltr501_samp_table ltr501_ps_samp_table[] = {
{500000, 2000000} {500000, 2000000}
}; };
static unsigned int ltr501_match_samp_freq(const struct ltr501_samp_table *tab, static int ltr501_match_samp_freq(const struct ltr501_samp_table *tab,
int len, int val, int val2) int len, int val, int val2)
{ {
int i, freq; int i, freq;
......
...@@ -117,7 +117,7 @@ static int mpl115_read_raw(struct iio_dev *indio_dev, ...@@ -117,7 +117,7 @@ static int mpl115_read_raw(struct iio_dev *indio_dev,
*val = ret >> 6; *val = ret >> 6;
return IIO_VAL_INT; return IIO_VAL_INT;
case IIO_CHAN_INFO_OFFSET: case IIO_CHAN_INFO_OFFSET:
*val = 605; *val = -605;
*val2 = 750000; *val2 = 750000;
return IIO_VAL_INT_PLUS_MICRO; return IIO_VAL_INT_PLUS_MICRO;
case IIO_CHAN_INFO_SCALE: case IIO_CHAN_INFO_SCALE:
......
...@@ -217,8 +217,12 @@ static ssize_t ade7753_write_16bit(struct device *dev, ...@@ -217,8 +217,12 @@ static ssize_t ade7753_write_16bit(struct device *dev,
static int ade7753_reset(struct device *dev) static int ade7753_reset(struct device *dev)
{ {
u16 val; u16 val;
int ret;
ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
if (ret)
return ret;
ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
val |= BIT(6); /* Software Chip Reset */ val |= BIT(6); /* Software Chip Reset */
return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val); return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
...@@ -343,8 +347,12 @@ static int ade7753_set_irq(struct device *dev, bool enable) ...@@ -343,8 +347,12 @@ static int ade7753_set_irq(struct device *dev, bool enable)
static int ade7753_stop_device(struct device *dev) static int ade7753_stop_device(struct device *dev)
{ {
u16 val; u16 val;
int ret;
ret = ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
if (ret)
return ret;
ade7753_spi_read_reg_16(dev, ADE7753_MODE, &val);
val |= BIT(4); /* AD converters can be turned off */ val |= BIT(4); /* AD converters can be turned off */
return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val); return ade7753_spi_write_reg_16(dev, ADE7753_MODE, val);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment