diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-21 19:45:36 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-09-21 19:45:36 -0400 |
| commit | 617408101362c830779b8b4c7eca9efefe0beab1 (patch) | |
| tree | d370cb25197b774f0367ec727c8ebb45d8ecb01a | |
| parent | c3cb718acc17f8e0d6b4b8d1f8ca9a20d1999159 (diff) | |
| parent | bda2f8fca20b564ac8edb2b9c080d942c2144359 (diff) | |
Merge tag 'iio-fixes-for-3.12a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes:
First round of IIO fixes for 3.12
A series of wrong 'struct dev' assumptions in suspend/resume callbacks
following on from this issue being identified in a new driver review.
One to watch out for in future.
A number of driver specific fixes
1) at91 - fix a overflow in clock rate computation
2) dummy - Kconfig dependency issue
3) isl29018 - uninitialized value
4) hmc5843 - measurement conversion bug introduced by recent cleanup.
5) ade7854-spi - wrong return value.
Some IIO core fixes
1) Wrong value picked up for event code creation for a modified channel
2) A null dereference on failure to initialize a buffer after no buffer has
been in use, when using the available_scan_masks approach.
3) Sampling not stopped when a device is removed. Effects forced removal
such as hot unplugging.
4) Prevent device going away if a chrdev is still open in userspace.
5) Prevent race on chardev opening and device being freed.
6) Add a missing iio_buffer_init in the call back buffer.
These last few are the first part of a set from Lars-Peter Clausen who
has been taking a closer look at our removal paths and buffer handling
than anyone has for quite some time.
| -rw-r--r-- | drivers/iio/accel/bma180.c | 4 | ||||
| -rw-r--r-- | drivers/iio/adc/at91_adc.c | 11 | ||||
| -rw-r--r-- | drivers/iio/buffer_cb.c | 2 | ||||
| -rw-r--r-- | drivers/iio/dac/mcp4725.c | 12 | ||||
| -rw-r--r-- | drivers/iio/iio_core.h | 4 | ||||
| -rw-r--r-- | drivers/iio/industrialio-buffer.c | 30 | ||||
| -rw-r--r-- | drivers/iio/industrialio-core.c | 31 | ||||
| -rw-r--r-- | drivers/iio/industrialio-event.c | 20 | ||||
| -rw-r--r-- | drivers/iio/temperature/tmp006.c | 6 | ||||
| -rw-r--r-- | drivers/staging/iio/Kconfig | 2 | ||||
| -rw-r--r-- | drivers/staging/iio/light/isl29018.c | 1 | ||||
| -rw-r--r-- | drivers/staging/iio/magnetometer/hmc5843.c | 2 | ||||
| -rw-r--r-- | drivers/staging/iio/meter/ade7854-spi.c | 2 |
13 files changed, 91 insertions, 36 deletions
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index 12e32e6b4103..81e3dc260993 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c | |||
| @@ -620,7 +620,7 @@ static int bma180_remove(struct i2c_client *client) | |||
| 620 | #ifdef CONFIG_PM_SLEEP | 620 | #ifdef CONFIG_PM_SLEEP |
| 621 | static int bma180_suspend(struct device *dev) | 621 | static int bma180_suspend(struct device *dev) |
| 622 | { | 622 | { |
| 623 | struct iio_dev *indio_dev = dev_to_iio_dev(dev); | 623 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); |
| 624 | struct bma180_data *data = iio_priv(indio_dev); | 624 | struct bma180_data *data = iio_priv(indio_dev); |
| 625 | int ret; | 625 | int ret; |
| 626 | 626 | ||
| @@ -633,7 +633,7 @@ static int bma180_suspend(struct device *dev) | |||
| 633 | 633 | ||
| 634 | static int bma180_resume(struct device *dev) | 634 | static int bma180_resume(struct device *dev) |
| 635 | { | 635 | { |
| 636 | struct iio_dev *indio_dev = dev_to_iio_dev(dev); | 636 | struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev)); |
| 637 | struct bma180_data *data = iio_priv(indio_dev); | 637 | struct bma180_data *data = iio_priv(indio_dev); |
| 638 | int ret; | 638 | int ret; |
| 639 | 639 | ||
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 84be63bdf038..0f16b553e063 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
| @@ -556,7 +556,7 @@ static const struct iio_info at91_adc_info = { | |||
| 556 | 556 | ||
| 557 | static int at91_adc_probe(struct platform_device *pdev) | 557 | static int at91_adc_probe(struct platform_device *pdev) |
| 558 | { | 558 | { |
| 559 | unsigned int prsc, mstrclk, ticks, adc_clk, shtim; | 559 | unsigned int prsc, mstrclk, ticks, adc_clk, adc_clk_khz, shtim; |
| 560 | int ret; | 560 | int ret; |
| 561 | struct iio_dev *idev; | 561 | struct iio_dev *idev; |
| 562 | struct at91_adc_state *st; | 562 | struct at91_adc_state *st; |
| @@ -649,6 +649,7 @@ static int at91_adc_probe(struct platform_device *pdev) | |||
| 649 | */ | 649 | */ |
| 650 | mstrclk = clk_get_rate(st->clk); | 650 | mstrclk = clk_get_rate(st->clk); |
| 651 | adc_clk = clk_get_rate(st->adc_clk); | 651 | adc_clk = clk_get_rate(st->adc_clk); |
| 652 | adc_clk_khz = adc_clk / 1000; | ||
| 652 | prsc = (mstrclk / (2 * adc_clk)) - 1; | 653 | prsc = (mstrclk / (2 * adc_clk)) - 1; |
| 653 | 654 | ||
| 654 | if (!st->startup_time) { | 655 | if (!st->startup_time) { |
| @@ -662,15 +663,15 @@ static int at91_adc_probe(struct platform_device *pdev) | |||
| 662 | * defined in the electrical characteristics of the board, divided by 8. | 663 | * defined in the electrical characteristics of the board, divided by 8. |
| 663 | * The formula thus is : Startup Time = (ticks + 1) * 8 / ADC Clock | 664 | * The formula thus is : Startup Time = (ticks + 1) * 8 / ADC Clock |
| 664 | */ | 665 | */ |
| 665 | ticks = round_up((st->startup_time * adc_clk / | 666 | ticks = round_up((st->startup_time * adc_clk_khz / |
| 666 | 1000000) - 1, 8) / 8; | 667 | 1000) - 1, 8) / 8; |
| 667 | /* | 668 | /* |
| 668 | * a minimal Sample and Hold Time is necessary for the ADC to guarantee | 669 | * a minimal Sample and Hold Time is necessary for the ADC to guarantee |
| 669 | * the best converted final value between two channels selection | 670 | * the best converted final value between two channels selection |
| 670 | * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock | 671 | * The formula thus is : Sample and Hold Time = (shtim + 1) / ADCClock |
| 671 | */ | 672 | */ |
| 672 | shtim = round_up((st->sample_hold_time * adc_clk / | 673 | shtim = round_up((st->sample_hold_time * adc_clk_khz / |
| 673 | 1000000) - 1, 1); | 674 | 1000) - 1, 1); |
| 674 | 675 | ||
| 675 | reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask; | 676 | reg = AT91_ADC_PRESCAL_(prsc) & st->registers->mr_prescal_mask; |
| 676 | reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask; | 677 | reg |= AT91_ADC_STARTUP_(ticks) & st->registers->mr_startup_mask; |
diff --git a/drivers/iio/buffer_cb.c b/drivers/iio/buffer_cb.c index 9d19ba74f22b..415f3c6efd72 100644 --- a/drivers/iio/buffer_cb.c +++ b/drivers/iio/buffer_cb.c | |||
| @@ -41,6 +41,8 @@ struct iio_cb_buffer *iio_channel_get_all_cb(struct device *dev, | |||
| 41 | goto error_ret; | 41 | goto error_ret; |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | iio_buffer_init(&cb_buff->buffer); | ||
| 45 | |||
| 44 | cb_buff->private = private; | 46 | cb_buff->private = private; |
| 45 | cb_buff->cb = cb; | 47 | cb_buff->cb = cb; |
| 46 | cb_buff->buffer.access = &iio_cb_access; | 48 | cb_buff->buffer.access = &iio_cb_access; |
diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 1f4a48e6a82c..1397b6e0e414 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c | |||
| @@ -37,21 +37,21 @@ struct mcp4725_data { | |||
| 37 | 37 | ||
| 38 | static int mcp4725_suspend(struct device *dev) | 38 | static int mcp4725_suspend(struct device *dev) |
| 39 | { | 39 | { |
| 40 | struct iio_dev *indio_dev = dev_to_iio_dev(dev); | 40 | struct mcp4725_data *data = iio_priv(i2c_get_clientdata( |
| 41 | struct mcp4725_data *data = iio_priv(indio_dev); | 41 | to_i2c_client(dev))); |
| 42 | u8 outbuf[2]; | 42 | u8 outbuf[2]; |
| 43 | 43 | ||
| 44 | outbuf[0] = (data->powerdown_mode + 1) << 4; | 44 | outbuf[0] = (data->powerdown_mode + 1) << 4; |
| 45 | outbuf[1] = 0; | 45 | outbuf[1] = 0; |
| 46 | data->powerdown = true; | 46 | data->powerdown = true; |
| 47 | 47 | ||
| 48 | return i2c_master_send(to_i2c_client(dev), outbuf, 2); | 48 | return i2c_master_send(data->client, outbuf, 2); |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | static int mcp4725_resume(struct device *dev) | 51 | static int mcp4725_resume(struct device *dev) |
| 52 | { | 52 | { |
| 53 | struct iio_dev *indio_dev = dev_to_iio_dev(dev); | 53 | struct mcp4725_data *data = iio_priv(i2c_get_clientdata( |
| 54 | struct mcp4725_data *data = iio_priv(indio_dev); | 54 | to_i2c_client(dev))); |
| 55 | u8 outbuf[2]; | 55 | u8 outbuf[2]; |
| 56 | 56 | ||
| 57 | /* restore previous DAC value */ | 57 | /* restore previous DAC value */ |
| @@ -59,7 +59,7 @@ static int mcp4725_resume(struct device *dev) | |||
| 59 | outbuf[1] = data->dac_value & 0xff; | 59 | outbuf[1] = data->dac_value & 0xff; |
| 60 | data->powerdown = false; | 60 | data->powerdown = false; |
| 61 | 61 | ||
| 62 | return i2c_master_send(to_i2c_client(dev), outbuf, 2); | 62 | return i2c_master_send(data->client, outbuf, 2); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | #ifdef CONFIG_PM_SLEEP | 65 | #ifdef CONFIG_PM_SLEEP |
diff --git a/drivers/iio/iio_core.h b/drivers/iio/iio_core.h index 05c1b74502a3..9b32253b824b 100644 --- a/drivers/iio/iio_core.h +++ b/drivers/iio/iio_core.h | |||
| @@ -49,11 +49,15 @@ ssize_t iio_buffer_read_first_n_outer(struct file *filp, char __user *buf, | |||
| 49 | #define iio_buffer_poll_addr (&iio_buffer_poll) | 49 | #define iio_buffer_poll_addr (&iio_buffer_poll) |
| 50 | #define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer) | 50 | #define iio_buffer_read_first_n_outer_addr (&iio_buffer_read_first_n_outer) |
| 51 | 51 | ||
| 52 | void iio_disable_all_buffers(struct iio_dev *indio_dev); | ||
| 53 | |||
| 52 | #else | 54 | #else |
| 53 | 55 | ||
| 54 | #define iio_buffer_poll_addr NULL | 56 | #define iio_buffer_poll_addr NULL |
| 55 | #define iio_buffer_read_first_n_outer_addr NULL | 57 | #define iio_buffer_read_first_n_outer_addr NULL |
| 56 | 58 | ||
| 59 | static inline void iio_disable_all_buffers(struct iio_dev *indio_dev) {} | ||
| 60 | |||
| 57 | #endif | 61 | #endif |
| 58 | 62 | ||
| 59 | int iio_device_register_eventset(struct iio_dev *indio_dev); | 63 | int iio_device_register_eventset(struct iio_dev *indio_dev); |
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index e73033f3839a..2710f7245c3b 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
| @@ -460,6 +460,25 @@ static int iio_compute_scan_bytes(struct iio_dev *indio_dev, const long *mask, | |||
| 460 | return bytes; | 460 | return bytes; |
| 461 | } | 461 | } |
| 462 | 462 | ||
| 463 | void iio_disable_all_buffers(struct iio_dev *indio_dev) | ||
