aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-25 15:50:11 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-11-25 15:50:11 -0500
commit1676587bca910f805515afe418c1792592c0c8ae (patch)
treed3c43efd588875e625a01dca05c654c6403104a4
parent5fa9576a1b975910d975f6535fdcddc79f6adf17 (diff)
parent0ee005c7dc2803125275e24598f0fb37775a6af3 (diff)
Merge tag 'fixes-for-3.13a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes: First round of fixes for IIO in the 3.13 cycle. The usual mixed bag of fixes. * 3 cases where kconfig dependencies were missing. We need to keep a closer eye on this in new drivers. * hid_sensors was abusing the iio_dev->trigger pointer. We had a round of clearing this out some time ago but this driver clearly slipped through. * A misuse of the IIO_ST macro, in mcp3422, which we should really make a concertive effort to finish removing. * Avoid a double free introduced by recent buffer reference counting in the one driver that (quite reasonably!) does things differently (am335x) * A missing mutex_unlock in kxsd9 that means that driver has been non functional for some time and no one noticed (including me who for once actually has one of the supported devices). * An incorrect assumption about the parameters of sign_extend32 in mcp3422. So nothing controversial. The only substantial patch is the hid_sensors one and that is actually just adding a new pointer to the devices private state then moving the code over to it.
-rw-r--r--drivers/iio/accel/hid-sensor-accel-3d.c5
-rw-r--r--drivers/iio/accel/kxsd9.c7
-rw-r--r--drivers/iio/adc/at91_adc.c1
-rw-r--r--drivers/iio/adc/mcp3422.c8
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c7
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.c9
-rw-r--r--drivers/iio/common/hid-sensors/hid-sensor-trigger.h2
-rw-r--r--drivers/iio/gyro/hid-sensor-gyro-3d.c5
-rw-r--r--drivers/iio/light/Kconfig2
-rw-r--r--drivers/iio/light/hid-sensor-als.c5
-rw-r--r--drivers/iio/magnetometer/Kconfig2
-rw-r--r--drivers/iio/magnetometer/hid-sensor-magn-3d.c5
-rw-r--r--drivers/iio/magnetometer/mag3110.c7
-rw-r--r--drivers/staging/iio/magnetometer/Kconfig2
-rw-r--r--include/linux/hid-sensor-hub.h3
15 files changed, 46 insertions, 24 deletions
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index dcda17395c4e..1cae4e920c9b 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -350,7 +350,7 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
350error_iio_unreg: 350error_iio_unreg:
351 iio_device_unregister(indio_dev); 351 iio_device_unregister(indio_dev);
352error_remove_trigger: 352error_remove_trigger:
353 hid_sensor_remove_trigger(indio_dev); 353 hid_sensor_remove_trigger(&accel_state->common_attributes);
354error_unreg_buffer_funcs: 354error_unreg_buffer_funcs:
355 iio_triggered_buffer_cleanup(indio_dev); 355 iio_triggered_buffer_cleanup(indio_dev);
356error_free_dev_mem: 356error_free_dev_mem:
@@ -363,10 +363,11 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
363{ 363{
364 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 364 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
365 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 365 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
366 struct accel_3d_state *accel_state = iio_priv(indio_dev);
366 367
367 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D); 368 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ACCEL_3D);
368 iio_device_unregister(indio_dev); 369 iio_device_unregister(indio_dev);
369 hid_sensor_remove_trigger(indio_dev); 370 hid_sensor_remove_trigger(&accel_state->common_attributes);
370 iio_triggered_buffer_cleanup(indio_dev); 371 iio_triggered_buffer_cleanup(indio_dev);
371 kfree(indio_dev->channels); 372 kfree(indio_dev->channels);
372 373
diff --git a/drivers/iio/accel/kxsd9.c b/drivers/iio/accel/kxsd9.c
index d72118d1189c..98ba761cbb9c 100644
--- a/drivers/iio/accel/kxsd9.c
+++ b/drivers/iio/accel/kxsd9.c
@@ -112,9 +112,10 @@ static int kxsd9_read(struct iio_dev *indio_dev, u8 address)
112 mutex_lock(&st->buf_lock); 112 mutex_lock(&st->buf_lock);
113 st->tx[0] = KXSD9_READ(address); 113 st->tx[0] = KXSD9_READ(address);
114 ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers)); 114 ret = spi_sync_transfer(st->us, xfers, ARRAY_SIZE(xfers));
115 if (ret) 115 if (!ret)
116 return ret; 116 ret = (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0);
117 return (((u16)(st->rx[0])) << 8) | (st->rx[1] & 0xF0); 117 mutex_unlock(&st->buf_lock);
118 return ret;
118} 119}
119 120
120static IIO_CONST_ATTR(accel_scale_available, 121static IIO_CONST_ATTR(accel_scale_available,
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
index 17df74908db1..5b1aa027c034 100644
--- a/drivers/iio/adc/at91_adc.c
+++ b/drivers/iio/adc/at91_adc.c
@@ -1047,6 +1047,7 @@ static int at91_adc_probe(struct platform_device *pdev)
1047 } else { 1047 } else {
1048 if (!st->caps->has_tsmr) { 1048 if (!st->caps->has_tsmr) {
1049 dev_err(&pdev->dev, "We don't support non-TSMR adc\n"); 1049 dev_err(&pdev->dev, "We don't support non-TSMR adc\n");
1050 ret = -ENODEV;
1050 goto error_disable_adc_clk; 1051 goto error_disable_adc_clk;
1051 } 1052 }
1052 1053
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c
index 12948325431c..c8c1baaec6c1 100644
--- a/drivers/iio/adc/mcp3422.c
+++ b/drivers/iio/adc/mcp3422.c
@@ -88,10 +88,10 @@ static const int mcp3422_sample_rates[4] = {
88 88
89/* sample rates to sign extension table */ 89/* sample rates to sign extension table */
90static const int mcp3422_sign_extend[4] = { 90static const int mcp3422_sign_extend[4] = {
91 [MCP3422_SRATE_240] = 12, 91 [MCP3422_SRATE_240] = 11,
92 [MCP3422_SRATE_60] = 14, 92 [MCP3422_SRATE_60] = 13,
93 [MCP3422_SRATE_15] = 16, 93 [MCP3422_SRATE_15] = 15,
94 [MCP3422_SRATE_3] = 18 }; 94 [MCP3422_SRATE_3] = 17 };
95 95
96/* Client data (each client gets its own) */ 96/* Client data (each client gets its own) */
97struct mcp3422 { 97struct mcp3422 {
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index 728411ec7642..d4d748214e4b 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -229,12 +229,15 @@ static int tiadc_iio_buffered_hardware_setup(struct iio_dev *indio_dev,
229 unsigned long flags, 229 unsigned long flags,
230 const struct iio_buffer_setup_ops *setup_ops) 230 const struct iio_buffer_setup_ops *setup_ops)
231{ 231{
232 struct iio_buffer *buffer;
232 int ret; 233 int ret;
233 234
234 indio_dev->buffer = iio_kfifo_allocate(indio_dev); 235 buffer = iio_kfifo_allocate(indio_dev);
235 if (!indio_dev->buffer) 236 if (!buffer)
236 return -ENOMEM; 237 return -ENOMEM;
237 238
239 iio_device_attach_buffer(indio_dev, buffer);
240
238 ret = request_threaded_irq(irq, pollfunc_th, pollfunc_bh, 241 ret = request_threaded_irq(irq, pollfunc_th, pollfunc_bh,
239 flags, indio_dev->name, indio_dev); 242 flags, indio_dev->name, indio_dev);
240 if (ret) 243 if (ret)
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
index b6e77e0fc420..bbd6426c9726 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.c
@@ -55,11 +55,10 @@ static int hid_sensor_data_rdy_trigger_set_state(struct iio_trigger *trig,
55 return 0; 55 return 0;
56} 56}
57 57
58void hid_sensor_remove_trigger(struct iio_dev *indio_dev) 58void hid_sensor_remove_trigger(struct hid_sensor_common *attrb)
59{ 59{
60 iio_trigger_unregister(indio_dev->trig); 60 iio_trigger_unregister(attrb->trigger);
61 iio_trigger_free(indio_dev->trig); 61 iio_trigger_free(attrb->trigger);
62 indio_dev->trig = NULL;
63} 62}
64EXPORT_SYMBOL(hid_sensor_remove_trigger); 63EXPORT_SYMBOL(hid_sensor_remove_trigger);
65 64
@@ -90,7 +89,7 @@ int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
90 dev_err(&indio_dev->dev, "Trigger Register Failed\n"); 89 dev_err(&indio_dev->dev, "Trigger Register Failed\n");
91 goto error_free_trig; 90 goto error_free_trig;
92 } 91 }
93 indio_dev->trig = trig; 92 indio_dev->trig = attrb->trigger = trig;
94 93
95 return ret; 94 return ret;
96 95
diff --git a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
index 9a8731478eda..ca02f7811aa8 100644
--- a/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
+++ b/drivers/iio/common/hid-sensors/hid-sensor-trigger.h
@@ -21,6 +21,6 @@
21 21
22int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name, 22int hid_sensor_setup_trigger(struct iio_dev *indio_dev, const char *name,
23 struct hid_sensor_common *attrb); 23 struct hid_sensor_common *attrb);
24void hid_sensor_remove_trigger(struct iio_dev *indio_dev); 24void hid_sensor_remove_trigger(struct hid_sensor_common *attrb);
25 25
26#endif 26#endif
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index ea01c6bcfb56..e54f0f4959d3 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -348,7 +348,7 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
348error_iio_unreg: 348error_iio_unreg:
349 iio_device_unregister(indio_dev); 349 iio_device_unregister(indio_dev);
350error_remove_trigger: 350error_remove_trigger:
351 hid_sensor_remove_trigger(indio_dev); 351 hid_sensor_remove_trigger(&gyro_state->common_attributes);
352error_unreg_buffer_funcs: 352error_unreg_buffer_funcs:
353 iio_triggered_buffer_cleanup(indio_dev); 353 iio_triggered_buffer_cleanup(indio_dev);
354error_free_dev_mem: 354error_free_dev_mem:
@@ -361,10 +361,11 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)
361{ 361{
362 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 362 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
363 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 363 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
364 struct gyro_3d_state *gyro_state = iio_priv(indio_dev);
364 365
365 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D); 366 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_GYRO_3D);
366 iio_device_unregister(indio_dev); 367 iio_device_unregister(indio_dev);
367 hid_sensor_remove_trigger(indio_dev); 368 hid_sensor_remove_trigger(&gyro_state->common_attributes);
368 iio_triggered_buffer_cleanup(indio_dev); 369 iio_triggered_buffer_cleanup(indio_dev);
369 kfree(indio_dev->channels); 370 kfree(indio_dev->channels);
370 371
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index f98c2b509254..b0d65df3ede2 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -81,6 +81,8 @@ config SENSORS_LM3533
81config TCS3472 81config TCS3472
82 tristate "TAOS TCS3472 color light-to-digital converter" 82 tristate "TAOS TCS3472 color light-to-digital converter"
83 depends on I2C 83 depends on I2C
84 select IIO_BUFFER
85 select IIO_TRIGGERED_BUFFER
84 help 86 help
85 If you say yes here you get support for the TAOS TCS3472 87 If you say yes here you get support for the TAOS TCS3472
86 family of color light-to-digital converters with IR filter. 88 family of color light-to-digital converters with IR filter.
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index fa6ae8cf89ea..8e8b9d722853 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -314,7 +314,7 @@ static int hid_als_probe(struct platform_device *pdev)
314error_iio_unreg: 314error_iio_unreg:
315 iio_device_unregister(indio_dev); 315 iio_device_unregister(indio_dev);
316error_remove_trigger: 316error_remove_trigger:
317 hid_sensor_remove_trigger(indio_dev); 317 hid_sensor_remove_trigger(&als_state->common_attributes);
318error_unreg_buffer_funcs: 318error_unreg_buffer_funcs:
319 iio_triggered_buffer_cleanup(indio_dev); 319 iio_triggered_buffer_cleanup(indio_dev);
320error_free_dev_mem: 320error_free_dev_mem:
@@ -327,10 +327,11 @@ static int hid_als_remove(struct platform_device *pdev)
327{ 327{
328 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 328 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
329 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 329 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
330 struct als_state *als_state = iio_priv(indio_dev);
330 331
331 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS); 332 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_ALS);
332 iio_device_unregister(indio_dev); 333 iio_device_unregister(indio_dev);
333 hid_sensor_remove_trigger(indio_dev); 334 hid_sensor_remove_trigger(&als_state->common_attributes);
334 iio_triggered_buffer_cleanup(indio_dev); 335 iio_triggered_buffer_cleanup(indio_dev);
335 kfree(indio_dev->channels); 336 kfree(indio_dev->channels);
336 337
diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig
index 0cf09637b35b..d86d226dcd67 100644
--- a/drivers/iio/magnetometer/Kconfig
+++ b/drivers/iio/magnetometer/Kconfig
@@ -19,6 +19,8 @@ config AK8975
19config MAG3110 19config MAG3110
20 tristate "Freescale MAG3110 3-Axis Magnetometer" 20 tristate "Freescale MAG3110 3-Axis Magnetometer"
21 depends on I2C 21 depends on I2C
22 select IIO_BUFFER
23 select IIO_TRIGGERED_BUFFER
22 help 24 help
23 Say yes here to build support for the Freescale MAG3110 3-Axis 25 Say yes here to build support for the Freescale MAG3110 3-Axis
24 magnetometer. 26 magnetometer.
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 2634920562fb..b26e1028a0a0 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -351,7 +351,7 @@ static int hid_magn_3d_probe(struct platform_device *pdev)
351error_iio_unreg: 351error_iio_unreg:
352 iio_device_unregister(indio_dev); 352 iio_device_unregister(indio_dev);
353error_remove_trigger: 353error_remove_trigger:
354 hid_sensor_remove_trigger(indio_dev); 354 hid_sensor_remove_trigger(&magn_state->common_attributes);
355error_unreg_buffer_funcs: 355error_unreg_buffer_funcs:
356 iio_triggered_buffer_cleanup(indio_dev); 356 iio_triggered_buffer_cleanup(indio_dev);
357error_free_dev_mem: 357error_free_dev_mem:
@@ -364,10 +364,11 @@ static int hid_magn_3d_remove(struct platform_device *pdev)
364{ 364{
365 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data; 365 struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
366 struct iio_dev *indio_dev = platform_get_drvdata(pdev); 366 struct iio_dev *indio_dev = platform_get_drvdata(pdev);
367 struct magn_3d_state *magn_state = iio_priv(indio_dev);
367 368
368 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D); 369 sensor_hub_remove_callback(hsdev, HID_USAGE_SENSOR_COMPASS_3D);
369 iio_device_unregister(indio_dev); 370 iio_device_unregister(indio_dev);
370 hid_sensor_remove_trigger(indio_dev); 371 hid_sensor_remove_trigger(&magn_state->common_attributes);
371 iio_triggered_buffer_cleanup(indio_dev); 372 iio_triggered_buffer_cleanup(indio_dev);
372 kfree(indio_dev->channels); 373 kfree(indio_dev->channels);
373 374
diff --git a/drivers/iio/magnetometer/mag3110.c b/drivers/iio/magnetometer/mag3110.c
index 783c5b417356..becf54496967 100644
--- a/drivers/iio/magnetometer/mag3110.c
+++ b/drivers/iio/magnetometer/mag3110.c
@@ -250,7 +250,12 @@ done:
250 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ 250 .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
251 BIT(IIO_CHAN_INFO_SCALE), \ 251 BIT(IIO_CHAN_INFO_SCALE), \
252 .scan_index = idx, \ 252 .scan_index = idx, \
253 .scan_type = IIO_ST('s', 16, 16, IIO_BE), \ 253 .scan_type = { \
254 .sign = 's', \
255 .realbits = 16, \
256 .storagebits = 16, \
257 .endianness = IIO_BE, \
258 }, \
254} 259}
255 260
256static const struct iio_chan_spec mag3110_channels[] = { 261static const struct iio_chan_spec mag3110_channels[] = {
diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig
index a3ea69e9d800..34634da1f9f7 100644
--- a/drivers/staging/iio/magnetometer/Kconfig
+++ b/drivers/staging/iio/magnetometer/Kconfig
@@ -6,6 +6,8 @@ menu "Magnetometer sensors"
6config SENSORS_HMC5843 6config SENSORS_HMC5843
7 tristate "Honeywell HMC5843/5883/5883L 3-Axis Magnetometer" 7 tristate "Honeywell HMC5843/5883/5883L 3-Axis Magnetometer"
8 depends on I2C 8 depends on I2C
9 select IIO_BUFFER
10 select IIO_TRIGGERED_BUFFER
9 help 11 help
10 Say Y here to add support for the Honeywell HMC5843, HMC5883 and 12 Say Y here to add support for the Honeywell HMC5843, HMC5883 and
11 HMC5883L 3-Axis Magnetometer (digital compass). 13 HMC5883L 3-Axis Magnetometer (digital compass).
diff --git a/include/linux/hid-sensor-hub.h b/include/linux/hid-sensor-hub.h
index a265af294ea4..206a2af6b62b 100644
--- a/include/linux/hid-sensor-hub.h
+++ b/include/linux/hid-sensor-hub.h
@@ -21,6 +21,8 @@
21 21
22#include <linux/hid.h> 22#include <linux/hid.h>
23#include <linux/hid-sensor-ids.h> 23#include <linux/hid-sensor-ids.h>
24#include <linux/iio/iio.h>
25#include <linux/iio/trigger.h>
24 26
25/** 27/**
26 * struct hid_sensor_hub_attribute_info - Attribute info 28 * struct hid_sensor_hub_attribute_info - Attribute info
@@ -184,6 +186,7 @@ struct hid_sensor_common {
184 struct platform_device *pdev; 186 struct platform_device *pdev;
185 unsigned usage_id; 187 unsigned usage_id;
186 bool data_ready; 188 bool data_ready;
189 struct iio_trigger *trigger;
187 struct hid_sensor_hub_attribute_info poll; 190 struct hid_sensor_hub_attribute_info poll;
188 struct hid_sensor_hub_attribute_info report_state; 191 struct hid_sensor_hub_attribute_info report_state;
189 struct hid_sensor_hub_attribute_info power_state; 192 struct hid_sensor_hub_attribute_info power_state;