Commit 8b675271 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'fixes-togreg_8_7_2012' of...

Merge tag 'fixes-togreg_8_7_2012' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Mixed bag of IIO fixes.

Quite a few cases of interrupt handlers returning
errors and a few more specific bits and bobs.

Most of these only effect fairly obscure error
paths. The IRQF_ONESHOT one may cause trouble
given the requests will now be rejected.

Jonathan

8_7_2012
parents 0ab19005 7b762741
......@@ -292,7 +292,7 @@ int iio_buffer_register(struct iio_dev *indio_dev,
if (channels[i].scan_index >
(int)indio_dev->masklength - 1)
indio_dev->masklength
= indio_dev->channels[i].scan_index + 1;
= channels[i].scan_index + 1;
ret = iio_buffer_add_channel_sysfs(indio_dev,
&channels[i]);
......
......@@ -345,7 +345,6 @@ static inline int __iio_add_event_config_attrs(struct iio_dev *indio_dev)
{
int j, ret, attrcount = 0;
INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
/* Dynically created from the channels array */
for (j = 0; j < indio_dev->num_channels; j++) {
ret = iio_device_add_event_sysfs(indio_dev,
......@@ -396,6 +395,8 @@ int iio_device_register_eventset(struct iio_dev *indio_dev)
goto error_ret;
}
INIT_LIST_HEAD(&indio_dev->event_interface->dev_attr_list);
iio_setup_ev_int(indio_dev->event_interface);
if (indio_dev->info->event_attrs != NULL) {
attr = indio_dev->info->event_attrs->attrs;
......
......@@ -193,7 +193,6 @@ struct iio_channel *iio_channel_get_all(const char *name)
c->map->adc_channel_label);
if (chans[mapind].channel == NULL) {
ret = -EINVAL;
iio_device_put(chans[mapind].indio_dev);
goto error_free_chans;
}
iio_device_get(chans[mapind].indio_dev);
......
......@@ -70,7 +70,7 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
return -ENOMEM;
goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)
......@@ -85,8 +85,9 @@ static irqreturn_t adis16201_trigger_handler(int irq, void *p)
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
......
......@@ -69,7 +69,7 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
return -ENOMEM;
goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
......@@ -86,8 +86,9 @@ static irqreturn_t adis16203_trigger_handler(int irq, void *p)
(u8 *)data,
pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
......
......@@ -66,7 +66,7 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
return -ENOMEM;
goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
......@@ -81,8 +81,9 @@ static irqreturn_t adis16204_trigger_handler(int irq, void *p)
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
......
......@@ -66,7 +66,7 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
return -ENOMEM;
goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
......@@ -81,8 +81,9 @@ static irqreturn_t adis16209_trigger_handler(int irq, void *p)
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
......
......@@ -64,7 +64,7 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
return -ENOMEM;
goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
......@@ -79,8 +79,9 @@ static irqreturn_t adis16240_trigger_handler(int irq, void *p)
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
......
......@@ -143,7 +143,7 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
if (data == NULL) {
dev_err(indio_dev->dev.parent,
"memory alloc failed in buffer bh");
return -ENOMEM;
goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength))
......@@ -156,8 +156,9 @@ static irqreturn_t lis3l02dq_trigger_handler(int irq, void *p)
= pf->timestamp;
buffer->access->store_to(buffer, (u8 *)data, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
......
......@@ -1189,7 +1189,7 @@ static int __devinit sca3000_probe(struct spi_device *spi)
ret = request_threaded_irq(spi->irq,
NULL,
&sca3000_event_handler,
IRQF_TRIGGER_FALLING,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
"sca3000",
indio_dev);
if (ret)
......
......@@ -82,7 +82,7 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
b_sent = spi_sync(st->spi, &st->ring_msg);
if (b_sent)
return b_sent;
goto done;
if (indio_dev->scan_timestamp) {
time_ns = iio_get_time_ns();
......@@ -95,6 +95,8 @@ static irqreturn_t ad7298_trigger_handler(int irq, void *p)
buf[i] = be16_to_cpu(st->rx_buf[i]);
indio_dev->buffer->access->store_to(ring, (u8 *)buf, time_ns);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
......
......@@ -31,7 +31,7 @@ static irqreturn_t ad7476_trigger_handler(int irq, void *p)
rxbuf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (rxbuf == NULL)
return -ENOMEM;
goto done;
b_sent = spi_read(st->spi, rxbuf,
st->chip_info->channel[0].scan_type.storagebits / 8);
......
......@@ -402,7 +402,7 @@ static int __devinit ad7816_probe(struct spi_device *spi_dev)
ret = request_threaded_irq(spi_dev->irq,
NULL,
&ad7816_event_handler,
IRQF_TRIGGER_LOW,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
indio_dev->name,
indio_dev);
if (ret)
......
......@@ -82,7 +82,7 @@ static irqreturn_t ad7887_trigger_handler(int irq, void *p)
buf = kzalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
goto done;
b_sent = spi_sync(st->spi, st->ring_msg);
if (b_sent)
......
......@@ -350,10 +350,10 @@ static irqreturn_t ad799x_event_handler(int irq, void *private)
ret = ad799x_i2c_read8(st, AD7998_ALERT_STAT_REG, &status);
if (ret)
return ret;
goto done;
if (!status)
return -EIO;
goto done;
ad799x_i2c_write8(st, AD7998_ALERT_STAT_REG, AD7998_ALERT_STAT_CLEAR);
......@@ -372,6 +372,7 @@ static irqreturn_t ad799x_event_handler(int irq, void *private)
iio_get_time_ns());
}
done:
return IRQ_HANDLED;
}
......
......@@ -81,8 +81,6 @@ static irqreturn_t ad799x_trigger_handler(int irq, void *p)
ring->access->store_to(indio_dev->buffer, rxbuf, time_ns);
done:
kfree(rxbuf);
if (b_sent < 0)
return b_sent;
out:
iio_trigger_notify_done(indio_dev->trig);
......
......@@ -397,7 +397,7 @@ static irqreturn_t adt7310_event_handler(int irq, void *private)
ret = adt7310_spi_read_byte(chip, ADT7310_STATUS, &status);
if (ret)
return ret;
goto done;
if (status & ADT7310_STAT_T_HIGH)
iio_push_event(indio_dev,
......@@ -417,6 +417,8 @@ static irqreturn_t adt7310_event_handler(int irq, void *private)
IIO_EV_TYPE_THRESH,
IIO_EV_DIR_RISING),
timestamp);
done:
return IRQ_HANDLED;
}
......@@ -778,7 +780,7 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
ret = request_threaded_irq(spi_dev->irq,
NULL,
&adt7310_event_handler,
irq_flags,
irq_flags | IRQF_ONESHOT,
indio_dev->name,
indio_dev);
if (ret)
......@@ -790,7 +792,8 @@ static int __devinit adt7310_probe(struct spi_device *spi_dev)
ret = request_threaded_irq(adt7310_platform_data[0],
NULL,
&adt7310_event_handler,
adt7310_platform_data[1],
adt7310_platform_data[1] |
IRQF_ONESHOT,
indio_dev->name,
indio_dev);
if (ret)
......
......@@ -257,7 +257,7 @@ static ssize_t adt7410_store_resolution(struct device *dev,
chip->config = config;
return ret;
return len;
}
static IIO_DEVICE_ATTR(resolution, S_IRUGO | S_IWUSR,
......@@ -293,26 +293,17 @@ static ssize_t adt7410_convert_temperature(struct adt7410_chip_info *chip,
{
char sign = ' ';
if (chip->config & ADT7410_RESOLUTION) {
if (data & ADT7410_T16_VALUE_SIGN) {
/* convert supplement to positive value */
data = (u16)((ADT7410_T16_VALUE_SIGN << 1) - (u32)data);
sign = '-';
}
return sprintf(buf, "%c%d.%.7d\n", sign,
(data >> ADT7410_T16_VALUE_FLOAT_OFFSET),
(data & ADT7410_T16_VALUE_FLOAT_MASK) * 78125);
} else {
if (data & ADT7410_T13_VALUE_SIGN) {
/* convert supplement to positive value */
data >>= ADT7410_T13_VALUE_OFFSET;
data = (ADT7410_T13_VALUE_SIGN << 1) - data;
sign = '-';
}
return sprintf(buf, "%c%d.%.4d\n", sign,
(data >> ADT7410_T13_VALUE_FLOAT_OFFSET),
(data & ADT7410_T13_VALUE_FLOAT_MASK) * 625);
if (!(chip->config & ADT7410_RESOLUTION))
data &= ~0x7;
if (data & ADT7410_T16_VALUE_SIGN) {
/* convert supplement to positive value */
data = (u16)((ADT7410_T16_VALUE_SIGN << 1) - (u32)data);
sign = '-';
}
return sprintf(buf, "%c%d.%.7d\n", sign,
(data >> ADT7410_T16_VALUE_FLOAT_OFFSET),
(data & ADT7410_T16_VALUE_FLOAT_MASK) * 78125);
}
static ssize_t adt7410_show_value(struct device *dev,
......@@ -742,7 +733,7 @@ static int __devinit adt7410_probe(struct i2c_client *client,
ret = request_threaded_irq(client->irq,
NULL,
&adt7410_event_handler,
IRQF_TRIGGER_LOW,
IRQF_TRIGGER_LOW | IRQF_ONESHOT,
id->name,
indio_dev);
if (ret)
......@@ -754,7 +745,8 @@ static int __devinit adt7410_probe(struct i2c_client *client,
ret = request_threaded_irq(adt7410_platform_data[0],
NULL,
&adt7410_event_handler,
adt7410_platform_data[1],
adt7410_platform_data[1] |
IRQF_ONESHOT,
id->name,
indio_dev);
if (ret)
......
......@@ -64,11 +64,11 @@ static irqreturn_t max1363_trigger_handler(int irq, void *p)
* no harm.
*/
if (numvals == 0)
return IRQ_HANDLED;
goto done;
rxbuf = kmalloc(d_size, GFP_KERNEL);
if (rxbuf == NULL)
return -ENOMEM;
goto done;
if (st->chip_info->bits != 8)
b_sent = i2c_master_recv(st->client, rxbuf, numvals*2);
else
......
......@@ -585,7 +585,8 @@ static int __devinit ad7150_probe(struct i2c_client *client,
NULL,
&ad7150_event_handler,
IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING,
IRQF_TRIGGER_FALLING |
IRQF_ONESHOT,
"ad7150_irq1",
indio_dev);
if (ret)
......@@ -598,7 +599,8 @@ static int __devinit ad7150_probe(struct i2c_client *client,
NULL,
&ad7150_event_handler,
IRQF_TRIGGER_RISING |
IRQF_TRIGGER_FALLING,
IRQF_TRIGGER_FALLING |
IRQF_ONESHOT,
"ad7150_irq2",
indio_dev);
if (ret)
......
......@@ -69,7 +69,7 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
return -ENOMEM;
goto done;
}
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength) &&
......@@ -84,8 +84,9 @@ static irqreturn_t adis16260_trigger_handler(int irq, void *p)
ring->access->store_to(ring, (u8 *)data, pf->timestamp);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
done:
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
......
......@@ -52,7 +52,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL)
return -ENOMEM;
goto done;
if (!bitmap_empty(indio_dev->active_scan_mask, indio_dev->masklength)) {
/*
......@@ -91,6 +91,7 @@ static irqreturn_t iio_simple_dummy_trigger_h(int irq, void *p)
kfree(data);
done:
/*
* Tell the core we are done with this trigger and ready for the
* next one.
......
......@@ -125,20 +125,20 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
dev_err(&st->us->dev, "memory alloc failed in ring bh");
return -ENOMEM;
goto done;
}
if (scan_count) {
if (st->variant->flags & ADIS16400_NO_BURST) {
ret = adis16350_spi_read_all(indio_dev, st->rx);
if (ret < 0)
goto err;
goto done;
for (; i < scan_count; i++)
data[i] = *(s16 *)(st->rx + i*2);
} else {
ret = adis16400_spi_read_burst(indio_dev, st->rx);
if (ret < 0)
goto err;
goto done;
for (; i < scan_count; i++) {
j = __ffs(mask);
mask &= ~(1 << j);
......@@ -152,14 +152,11 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
*((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
ring->access->store_to(indio_dev->buffer, (u8 *) data, pf->timestamp);
done:
kfree(data);
iio_trigger_notify_done(indio_dev->trig);
kfree(data);
return IRQ_HANDLED;
err:
kfree(data);
return ret;
}
void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
......
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