diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-25 21:42:40 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-11-25 21:42:40 -0500 |
commit | 3ce5ae8d46eed6cdaf38f5c8276f8c66f403d0d6 (patch) | |
tree | 91e35051672245d46c20196e4fce7669d91e6f85 | |
parent | fa590c222fbaa428edb2ce2194638906cea1400a (diff) | |
parent | 794a870e776717ccbd27676a551250613de9c40c (diff) |
Merge tag 'iio-for-3.14a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First set of new features, drivers and cleanups for IIO in the 3.14 cycle.
This mostly consists of patches that didn't quite make the last cycle. Lots
of interesting things under review currently.
Core:
- Add devm_iio_device_register/unregister. I took some convincing on whether
there would be many devices that really were simple enough to need no
explicit actions on removal. Turns out there are some.
- Move some stray docs to above the relevant implemenation.
- Drop a redundant repeated check on the fact the trigger has actually changed
when there is a userspace attempt change it.
Drivers:
New drivers
- Freescale MPL3115A2 Pressure / temperature sensor
New functionality
- hid_sensors: add sensitivity support.
DT bindings
- tsl2563
- hmc5843
Cleanups
- Drop unused scan_type from viperboard adc driver.
- devm_iio_device_register used in viperboard, ad5421, ad5755, adis16130,
adxrs450, vcnl4000, adis16220, ad7816, lpc32xx, adt7316, adis16060, isl29018
and ad2s1200. Note that this was proposed in a number of other drivers
and this revealed a number of missorderings in remove functions. Also for
now I have blocked this on any device that any hardware suspend suport on
the basis that we probably want to power down devices if they have no driver
support loaded.
35 files changed, 598 insertions, 238 deletions
diff --git a/Documentation/devicetree/bindings/iio/light/tsl2563.txt b/Documentation/devicetree/bindings/iio/light/tsl2563.txt new file mode 100644 index 000000000000..f91e809e736e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/light/tsl2563.txt | |||
@@ -0,0 +1,19 @@ | |||
1 | * AMS TAOS TSL2563 ambient light sensor | ||
2 | |||
3 | Required properties: | ||
4 | |||
5 | - compatible : should be "amstaos,tsl2563" | ||
6 | - reg : the I2C address of the sensor | ||
7 | |||
8 | Optional properties: | ||
9 | |||
10 | - amstaos,cover-comp-gain : integer used as multiplier for gain | ||
11 | compensation (default = 1) | ||
12 | |||
13 | Example: | ||
14 | |||
15 | tsl2563@29 { | ||
16 | compatible = "amstaos,tsl2563"; | ||
17 | reg = <0x29>; | ||
18 | amstaos,cover-comp-gain = <16>; | ||
19 | }; | ||
diff --git a/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt b/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt new file mode 100644 index 000000000000..90d5f34db04e --- /dev/null +++ b/Documentation/devicetree/bindings/iio/magnetometer/hmc5843.txt | |||
@@ -0,0 +1,17 @@ | |||
1 | * Honeywell HMC5843 magnetometer sensor | ||
2 | |||
3 | Required properties: | ||
4 | |||
5 | - compatible : should be "honeywell,hmc5843" | ||
6 | - reg : the I2C address of the magnetometer - typically 0x1e | ||
7 | |||
8 | Optional properties: | ||
9 | |||
10 | - gpios : should be device tree identifier of the magnetometer DRDY pin | ||
11 | |||
12 | Example: | ||
13 | |||
14 | hmc5843@1e { | ||
15 | compatible = "honeywell,hmc5843" | ||
16 | reg = <0x1e>; | ||
17 | }; | ||
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index ce95ed1c6d3e..8c75d8506c42 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt | |||
@@ -9,6 +9,7 @@ aeroflexgaisler Aeroflex Gaisler AB | |||
9 | ak Asahi Kasei Corp. | 9 | ak Asahi Kasei Corp. |
10 | altr Altera Corp. | 10 | altr Altera Corp. |
11 | amcc Applied Micro Circuits Corporation (APM, formally AMCC) | 11 | amcc Applied Micro Circuits Corporation (APM, formally AMCC) |
12 | amstaos AMS-Taos Inc. | ||
12 | apm Applied Micro Circuits Corporation (APM) | 13 | apm Applied Micro Circuits Corporation (APM) |
13 | arm ARM Ltd. | 14 | arm ARM Ltd. |
14 | atmel Atmel Corporation | 15 | atmel Atmel Corporation |
diff --git a/Documentation/driver-model/devres.txt b/Documentation/driver-model/devres.txt index 5bdc8cb5fc28..4f7897e99cba 100644 --- a/Documentation/driver-model/devres.txt +++ b/Documentation/driver-model/devres.txt | |||
@@ -242,6 +242,8 @@ IIO | |||
242 | devm_iio_device_free() | 242 | devm_iio_device_free() |
243 | devm_iio_trigger_alloc() | 243 | devm_iio_trigger_alloc() |
244 | devm_iio_trigger_free() | 244 | devm_iio_trigger_free() |
245 | devm_iio_device_register() | ||
246 | devm_iio_device_unregister() | ||
245 | 247 | ||
246 | IO region | 248 | IO region |
247 | devm_request_region() | 249 | devm_request_region() |
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index dcda17395c4e..6b8735ce8345 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c | |||
@@ -262,6 +262,18 @@ static int accel_3d_parse_report(struct platform_device *pdev, | |||
262 | st->accel[1].index, st->accel[1].report_id, | 262 | st->accel[1].index, st->accel[1].report_id, |
263 | st->accel[2].index, st->accel[2].report_id); | 263 | st->accel[2].index, st->accel[2].report_id); |
264 | 264 | ||
265 | /* Set Sensitivity field ids, when there is no individual modifier */ | ||
266 | if (st->common_attributes.sensitivity.index < 0) { | ||
267 | sensor_hub_input_get_attribute_info(hsdev, | ||
268 | HID_FEATURE_REPORT, usage_id, | ||
269 | HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | | ||
270 | HID_USAGE_SENSOR_DATA_ACCELERATION, | ||
271 | &st->common_attributes.sensitivity); | ||
272 | dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", | ||
273 | st->common_attributes.sensitivity.index, | ||
274 | st->common_attributes.sensitivity.report_id); | ||
275 | } | ||
276 | |||
265 | return ret; | 277 | return ret; |
266 | } | 278 | } |
267 | 279 | ||
diff --git a/drivers/iio/adc/mcp3422.c b/drivers/iio/adc/mcp3422.c index 12948325431c..dbdbd77f69ea 100644 --- a/drivers/iio/adc/mcp3422.c +++ b/drivers/iio/adc/mcp3422.c | |||
@@ -362,7 +362,7 @@ static int mcp3422_probe(struct i2c_client *client, | |||
362 | | MCP3422_SAMPLE_RATE_VALUE(MCP3422_SRATE_240)); | 362 | | MCP3422_SAMPLE_RATE_VALUE(MCP3422_SRATE_240)); |
363 | mcp3422_update_config(adc, config); | 363 | mcp3422_update_config(adc, config); |
364 | 364 | ||
365 | err = iio_device_register(indio_dev); | 365 | err = devm_iio_device_register(&client->dev, indio_dev); |
366 | if (err < 0) | 366 | if (err < 0) |
367 | return err; | 367 | return err; |
368 | 368 | ||
@@ -371,12 +371,6 @@ static int mcp3422_probe(struct i2c_client *client, | |||
371 | return 0; | 371 | return 0; |
372 | } | 372 | } |
373 | 373 | ||
374 | static int mcp3422_remove(struct i2c_client *client) | ||
375 | { | ||
376 | iio_device_unregister(i2c_get_clientdata(client)); | ||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static const struct i2c_device_id mcp3422_id[] = { | 374 | static const struct i2c_device_id mcp3422_id[] = { |
381 | { "mcp3422", 2 }, | 375 | { "mcp3422", 2 }, |
382 | { "mcp3423", 3 }, | 376 | { "mcp3423", 3 }, |
@@ -400,7 +394,6 @@ static struct i2c_driver mcp3422_driver = { | |||
400 | .of_match_table = of_match_ptr(mcp3422_of_match), | 394 | .of_match_table = of_match_ptr(mcp3422_of_match), |
401 | }, | 395 | }, |
402 | .probe = mcp3422_probe, | 396 | .probe = mcp3422_probe, |
403 | .remove = mcp3422_remove, | ||
404 | .id_table = mcp3422_id, | 397 | .id_table = mcp3422_id, |
405 | }; | 398 | }; |
406 | module_i2c_driver(mcp3422_driver); | 399 | module_i2c_driver(mcp3422_driver); |
diff --git a/drivers/iio/adc/viperboard_adc.c b/drivers/iio/adc/viperboard_adc.c index 09727a71e9fa..d0add8f9416b 100644 --- a/drivers/iio/adc/viperboard_adc.c +++ b/drivers/iio/adc/viperboard_adc.c | |||
@@ -42,12 +42,6 @@ struct vprbrd_adc { | |||
42 | .indexed = 1, \ | 42 | .indexed = 1, \ |
43 | .channel = _index, \ | 43 | .channel = _index, \ |
44 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ | 44 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \ |
45 | .scan_index = _index, \ | ||
46 | .scan_type = { \ | ||
47 | .sign = 'u', \ | ||
48 | .realbits = 8, \ | ||
49 | .storagebits = 8, \ | ||
50 | }, \ | ||
51 | } | 45 | } |
52 | 46 | ||
53 | static struct iio_chan_spec const vprbrd_adc_iio_channels[] = { | 47 | static struct iio_chan_spec const vprbrd_adc_iio_channels[] = { |
@@ -73,7 +67,7 @@ static int vprbrd_iio_read_raw(struct iio_dev *iio_dev, | |||
73 | mutex_lock(&vb->lock); | 67 | mutex_lock(&vb->lock); |
74 | 68 | ||
75 | admsg->cmd = VPRBRD_ADC_CMD_GET; | 69 | admsg->cmd = VPRBRD_ADC_CMD_GET; |
76 | admsg->chan = chan->scan_index; | 70 | admsg->chan = chan->channel; |
77 | admsg->val = 0x00; | 71 | admsg->val = 0x00; |
78 | 72 | ||
79 | ret = usb_control_msg(vb->usb_dev, | 73 | ret = usb_control_msg(vb->usb_dev, |
@@ -139,7 +133,7 @@ static int vprbrd_adc_probe(struct platform_device *pdev) | |||
139 | indio_dev->channels = vprbrd_adc_iio_channels; | 133 | indio_dev->channels = vprbrd_adc_iio_channels; |
140 | indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels); | 134 | indio_dev->num_channels = ARRAY_SIZE(vprbrd_adc_iio_channels); |
141 | 135 | ||
142 | ret = iio_device_register(indio_dev); | 136 | ret = devm_iio_device_register(&pdev->dev, indio_dev); |
143 | if (ret) { | 137 | if (ret) { |
144 | dev_err(&pdev->dev, "could not register iio (adc)"); | 138 | dev_err(&pdev->dev, "could not register iio (adc)"); |
145 | return ret; | 139 | return ret; |
@@ -150,22 +144,12 @@ static int vprbrd_adc_probe(struct platform_device *pdev) | |||
150 | return 0; | 144 | return 0; |
151 | } | 145 | } |
152 | 146 | ||
153 | static int vprbrd_adc_remove(struct platform_device *pdev) | ||
154 | { | ||
155 | struct iio_dev *indio_dev = platform_get_drvdata(pdev); | ||
156 | |||
157 | iio_device_unregister(indio_dev); | ||
158 | |||
159 | return 0; | ||
160 | } | ||
161 | |||
162 | static struct platform_driver vprbrd_adc_driver = { | 147 | static struct platform_driver vprbrd_adc_driver = { |
163 | .driver = { | 148 | .driver = { |
164 | .name = "viperboard-adc", | 149 | .name = "viperboard-adc", |
165 | .owner = THIS_MODULE, | 150 | .owner = THIS_MODULE, |
166 | }, | 151 | }, |
167 | .probe = vprbrd_adc_probe, | 152 | .probe = vprbrd_adc_probe, |
168 | .remove = vprbrd_adc_remove, | ||
169 | }; | 153 | }; |
170 | 154 | ||
171 | module_platform_driver(vprbrd_adc_driver); | 155 | module_platform_driver(vprbrd_adc_driver); |
diff --git a/drivers/iio/dac/ad5421.c b/drivers/iio/dac/ad5421.c index 3eeaa82075f7..7d1e90811c71 100644 --- a/drivers/iio/dac/ad5421.c +++ b/drivers/iio/dac/ad5421.c | |||
@@ -514,16 +514,7 @@ static int ad5421_probe(struct spi_device *spi) | |||
514 | return ret; | 514 | return ret; |
515 | } | 515 | } |
516 | 516 | ||
517 | return iio_device_register(indio_dev); | 517 | return devm_iio_device_register(&spi->dev, indio_dev); |
518 | } | ||
519 | |||
520 | static int ad5421_remove(struct spi_device *spi) | ||
521 | { | ||
522 | struct iio_dev *indio_dev = spi_get_drvdata(spi); | ||
523 | |||
524 | iio_device_unregister(indio_dev); | ||
525 | |||
526 | return 0; | ||
527 | } | 518 | } |
528 | 519 | ||
529 | static struct spi_driver ad5421_driver = { | 520 | static struct spi_driver ad5421_driver = { |
@@ -532,7 +523,6 @@ static struct spi_driver ad5421_driver = { | |||
532 | .owner = THIS_MODULE, | 523 | .owner = THIS_MODULE, |
533 | }, | 524 | }, |
534 | .probe = ad5421_probe, | 525 | .probe = ad5421_probe, |
535 | .remove = ad5421_remove, | ||
536 | }; | 526 | }; |
537 | module_spi_driver(ad5421_driver); | 527 | module_spi_driver(ad5421_driver); |
538 | 528 | ||
diff --git a/drivers/iio/dac/ad5755.c b/drivers/iio/dac/ad5755.c index 9a78d5abb2f6..ee1e95a3a0c3 100644 --- a/drivers/iio/dac/ad5755.c +++ b/drivers/iio/dac/ad5755.c | |||
@@ -589,16 +589,7 @@ static int ad5755_probe(struct spi_device *spi) | |||
589 | if (ret) | 589 | if (ret) |
590 | return ret; | 590 | return ret; |
591 | 591 | ||
592 | return iio_device_register(indio_dev); | 592 | return devm_iio_device_register(&spi->dev, indio_dev); |
593 | } | ||
594 | |||
595 | static int ad5755_remove(struct spi_device *spi) | ||
596 | { | ||
597 | struct iio_dev *indio_dev = spi_get_drvdata(spi); | ||
598 | |||
599 | iio_device_unregister(indio_dev); | ||
600 | |||
601 | return 0; | ||
602 | } | 593 | } |
603 | 594 | ||
604 | static const struct spi_device_id ad5755_id[] = { | 595 | static const struct spi_device_id ad5755_id[] = { |
@@ -617,7 +608,6 @@ static struct spi_driver ad5755_driver = { | |||
617 | .owner = THIS_MODULE, | 608 | .owner = THIS_MODULE, |
618 | }, | 609 | }, |
619 | .probe = ad5755_probe, | 610 | .probe = ad5755_probe, |
620 | .remove = ad5755_remove, | ||
621 | .id_table = ad5755_id, | 611 | .id_table = ad5755_id, |
622 | }; | 612 | }; |
623 | module_spi_driver(ad5755_driver); | 613 | module_spi_driver(ad5755_driver); |
diff --git a/drivers/iio/gyro/adis16130.c b/drivers/iio/gyro/adis16130.c index 445c2aecfadd..8d08c7ed1ea6 100644 --- a/drivers/iio/gyro/adis16130.c +++ b/drivers/iio/gyro/adis16130.c | |||
@@ -161,13 +161,7 @@ static int adis16130_probe(struct spi_device *spi) | |||
161 | indio_dev->info = &adis16130_info; | 161 | indio_dev->info = &adis16130_info; |
162 | indio_dev->modes = INDIO_DIRECT_MODE; | 162 | indio_dev->modes = INDIO_DIRECT_MODE; |
163 | 163 | ||
164 | return iio_device_register(indio_dev); | 164 | return devm_iio_device_register(&spi->dev, indio_dev); |
165 | } | ||
166 | |||
167 | static int adis16130_remove(struct spi_device *spi) | ||
168 | { | ||
169 | iio_device_unregister(spi_get_drvdata(spi)); | ||
170 | return 0; | ||
171 | } | 165 | } |
172 | 166 | ||
173 | static struct spi_driver adis16130_driver = { | 167 | static struct spi_driver adis16130_driver = { |
@@ -176,7 +170,6 @@ static struct spi_driver adis16130_driver = { | |||
176 | .owner = THIS_MODULE, | 170 | .owner = THIS_MODULE, |
177 | }, | 171 | }, |
178 | .probe = adis16130_probe, | 172 | .probe = adis16130_probe, |
179 | .remove = adis16130_remove, | ||
180 | }; | 173 | }; |
181 | module_spi_driver(adis16130_driver); | 174 | module_spi_driver(adis16130_driver); |
182 | 175 | ||
diff --git a/drivers/iio/gyro/adxrs450.c b/drivers/iio/gyro/adxrs450.c index 1e546ba7ba45..eb0e08ec9e20 100644 --- a/drivers/iio/gyro/adxrs450.c +++ b/drivers/iio/gyro/adxrs450.c | |||
@@ -434,23 +434,14 @@ static int adxrs450_probe(struct spi_device *spi) | |||
434 | indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); | 434 | indio_dev->num_channels = ARRAY_SIZE(adxrs450_channels); |
435 | indio_dev->name = spi->dev.driver->name; | 435 | indio_dev->name = spi->dev.driver->name; |
436 | 436 | ||
437 | ret = iio_device_register(indio_dev); | 437 | ret = devm_iio_device_register(&spi->dev, indio_dev); |
438 | if (ret) | 438 | if (ret) |
439 | return ret; | 439 | return ret; |
440 | 440 | ||
441 | /* Get the device into a sane initial state */ | 441 | /* Get the device into a sane initial state */ |
442 | ret = adxrs450_initial_setup(indio_dev); | 442 | ret = adxrs450_initial_setup(indio_dev); |
443 | if (ret) | 443 | if (ret) |
444 | goto error_initial; | 444 | return ret; |
445 | return 0; | ||
446 | error_initial: | ||
447 | iio_device_unregister(indio_dev); | ||
448 | return ret; | ||
449 | } | ||
450 | |||
451 | static int adxrs450_remove(struct spi_device *spi) | ||
452 | { | ||
453 | iio_device_unregister(spi_get_drvdata(spi)); | ||
454 | 445 | ||
455 | return 0; | 446 | return 0; |
456 | } | 447 | } |
@@ -468,7 +459,6 @@ static struct spi_driver adxrs450_driver = { | |||
468 | .owner = THIS_MODULE, | 459 | .owner = THIS_MODULE, |
469 | }, | 460 | }, |
470 | .probe = adxrs450_probe, | 461 | .probe = adxrs450_probe, |
471 | .remove = adxrs450_remove, | ||
472 | .id_table = adxrs450_id, | 462 | .id_table = adxrs450_id, |
473 | }; | 463 | }; |
474 | module_spi_driver(adxrs450_driver); | 464 | module_spi_driver(adxrs450_driver); |
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index ea01c6bcfb56..97797dbaad34 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c | |||
@@ -262,6 +262,17 @@ static int gyro_3d_parse_report(struct platform_device *pdev, | |||
262 | st->gyro[1].index, st->gyro[1].report_id, | 262 | st->gyro[1].index, st->gyro[1].report_id, |
263 | st->gyro[2].index, st->gyro[2].report_id); | 263 | st->gyro[2].index, st->gyro[2].report_id); |
264 | 264 | ||
265 | /* Set Sensitivity field ids, when there is no individual modifier */ | ||
266 | if (st->common_attributes.sensitivity.index < 0) { | ||
267 | sensor_hub_input_get_attribute_info(hsdev, | ||
268 | HID_FEATURE_REPORT, usage_id, | ||
269 | HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | | ||
270 | HID_USAGE_SENSOR_DATA_ANGL_VELOCITY, | ||
271 | &st->common_attributes.sensitivity); | ||
272 | dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", | ||
273 | st->common_attributes.sensitivity.index, | ||
274 | st->common_attributes.sensitivity.report_id); | ||
275 | } | ||
265 | return ret; | 276 | return ret; |
266 | } | 277 | } |
267 | 278 | ||
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c index 18f72e3d0ed6..2fe88c189f74 100644 --- a/drivers/iio/industrialio-core.c +++ b/drivers/iio/industrialio-core.c | |||
@@ -107,6 +107,11 @@ static const char * const iio_chan_info_postfix[] = { | |||
107 | [IIO_CHAN_INFO_INT_TIME] = "integration_time", | 107 | [IIO_CHAN_INFO_INT_TIME] = "integration_time", |
108 | }; | 108 | }; |
109 | 109 | ||
110 | /** | ||
111 | * iio_find_channel_from_si() - get channel from its scan index | ||
112 | * @indio_dev: device | ||
113 | * @si: scan index to match | ||
114 | */ | ||
110 | const struct iio_chan_spec | 115 | const struct iio_chan_spec |
111 | *iio_find_channel_from_si(struct iio_dev *indio_dev, int si) | 116 | *iio_find_channel_from_si(struct iio_dev *indio_dev, int si) |
112 | { | 117 | { |
@@ -922,6 +927,10 @@ struct device_type iio_device_type = { | |||
922 | .release = iio_dev_release, | 927 | .release = iio_dev_release, |
923 | }; | 928 | }; |
924 | 929 | ||
930 | /** | ||
931 | * iio_device_alloc() - allocate an iio_dev from a driver | ||
932 | * @sizeof_priv: Space to allocate for private structure. | ||
933 | **/ | ||
925 | struct iio_dev *iio_device_alloc(int sizeof_priv) | 934 | struct iio_dev *iio_device_alloc(int sizeof_priv) |
926 | { | 935 | { |
927 | struct iio_dev *dev; | 936 | struct iio_dev *dev; |
@@ -962,6 +971,10 @@ struct iio_dev *iio_device_alloc(int sizeof_priv) | |||
962 | } | 971 | } |
963 | EXPORT_SYMBOL(iio_device_alloc); | 972 | EXPORT_SYMBOL(iio_device_alloc); |
964 | 973 | ||
974 | /** | ||
975 | * iio_device_free() - free an iio_dev from a driver | ||
976 | * @dev: the iio_dev associated with the device | ||
977 | **/ | ||
965 | void iio_device_free(struct iio_dev *dev) | 978 | void iio_device_free(struct iio_dev *dev) |
966 | { | 979 | { |
967 | if (dev) | 980 | if (dev) |
@@ -984,6 +997,20 @@ static int devm_iio_device_match(struct device *dev, void *res, void *data) | |||
984 | return *r == data; | 997 | return *r == data; |
985 | } | 998 | } |
986 | 999 | ||
1000 | /** | ||
1001 | * devm_iio_device_alloc - Resource-managed iio_device_alloc() | ||
1002 | * @dev: Device to allocate iio_dev for | ||
1003 | * @sizeof_priv: Space to allocate for private structure. | ||
1004 | * | ||
1005 | * Managed iio_device_alloc. iio_dev allocated with this function is | ||
1006 | * automatically freed on driver detach. | ||
1007 | * | ||
1008 | * If an iio_dev allocated with this function needs to be freed separately, | ||
1009 | * devm_iio_device_free() must be used. | ||
1010 | * | ||
1011 | * RETURNS: | ||
1012 | * Pointer to allocated iio_dev on success, NULL on failure. | ||
1013 | */ | ||
987 | struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv) | 1014 | struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv) |
988 | { | 1015 | { |
989 | struct iio_dev **ptr, *iio_dev; | 1016 | struct iio_dev **ptr, *iio_dev; |
@@ -1006,6 +1033,13 @@ struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv) | |||
1006 | } | 1033 | } |
1007 | EXPORT_SYMBOL_GPL(devm_iio_device_alloc); | 1034 | EXPORT_SYMBOL_GPL(devm_iio_device_alloc); |
1008 | 1035 | ||
1036 | /** | ||
1037 | * devm_iio_device_free - Resource-managed iio_device_free() | ||
1038 | * @dev: Device this iio_dev belongs to | ||
1039 | * @iio_dev: the iio_dev associated with the device | ||
1040 | * | ||
1041 | * Free iio_dev allocated with devm_iio_device_alloc(). | ||
1042 | */ | ||
1009 | void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev) | 1043 | void devm_iio_device_free(struct device *dev, struct iio_dev *iio_dev) |
1010 | { | 1044 | { |
1011 | int rc; | 1045 | int rc; |
@@ -1080,6 +1114,10 @@ static const struct file_operations iio_buffer_fileops = { | |||
1080 | 1114 | ||
1081 | static const struct iio_buffer_setup_ops noop_ring_setup_ops; | 1115 | static const struct iio_buffer_setup_ops noop_ring_setup_ops; |
1082 | 1116 | ||
1117 | /** | ||
1118 | * iio_device_register() - register a device with the IIO subsystem | ||
1119 | * @indio_dev: Device structure filled by the device driver | ||
1120 | **/ | ||
1083 | int iio_device_register(struct iio_dev *indio_dev) | 1121 | int iio_device_register(struct iio_dev *indio_dev) |
1084 | { | 1122 | { |
1085 | int ret; | 1123 | int ret; |
@@ -1141,6 +1179,10 @@ error_ret: | |||
1141 | } | 1179 | } |
1142 | EXPORT_SYMBOL(iio_device_register); | 1180 | EXPORT_SYMBOL(iio_device_register); |
1143 | 1181 | ||
1182 | /** | ||
1183 | * iio_device_unregister() - unregister a device from the IIO subsystem | ||
1184 | * @indio_dev: Device structure representing the device. | ||
1185 | **/ | ||
1144 | void iio_device_unregister(struct iio_dev *indio_dev) | 1186 | void iio_device_unregister(struct iio_dev *indio_dev) |
1145 | { | 1187 | { |
1146 | mutex_lock(&indio_dev->info_exist_lock); | 1188 | mutex_lock(&indio_dev->info_exist_lock); |
@@ -1161,6 +1203,65 @@ void iio_device_unregister(struct iio_dev *indio_dev) | |||
1161 | mutex_unlock(&indio_dev->info_exist_lock); | 1203 | mutex_unlock(&indio_dev->info_exist_lock); |
1162 | } | 1204 | } |
1163 | EXPORT_SYMBOL(iio_device_unregister); | 1205 | EXPORT_SYMBOL(iio_device_unregister); |
1206 | |||
1207 | static void devm_iio_device_unreg(struct device *dev, void *res) | ||
1208 | { | ||
1209 | iio_device_unregister(*(struct iio_dev **)res); | ||
1210 | } | ||
1211 | |||
1212 | /** | ||
1213 | * devm_iio_device_register - Resource-managed iio_device_register() | ||
1214 | * @dev: Device to allocate iio_dev for | ||
1215 | * @indio_dev: Device structure filled by the device driver | ||
1216 | * | ||
1217 | * Managed iio_device_register. The IIO device registered with this | ||
1218 | * function is automatically unregistered on driver detach. This function | ||
1219 | * calls iio_device_register() internally. Refer to that function for more | ||
1220 | * information. | ||
1221 | * | ||
1222 | * If an iio_dev registered with this function needs to be unregistered | ||
1223 | * separately, devm_iio_device_unregister() must be used. | ||
1224 | * | ||
1225 | * RETURNS: | ||
1226 | * 0 on success, negative error number on failure. | ||
1227 | */ | ||
1228 | int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev) | ||
1229 | { | ||
1230 | struct iio_dev **ptr; | ||
1231 | int ret; | ||
1232 | |||
1233 | ptr = devres_alloc(devm_iio_device_unreg, sizeof(*ptr), GFP_KERNEL); | ||
1234 | if (!ptr) | ||
1235 | return -ENOMEM; | ||
1236 | |||
1237 | *ptr = indio_dev; | ||
1238 | ret = iio_device_register(indio_dev); | ||
1239 | if (!ret) | ||
1240 | devres_add(dev, ptr); | ||
1241 | else | ||
1242 | devres_free(ptr); | ||
1243 | |||
1244 | return ret; | ||
1245 | } | ||
1246 | EXPORT_SYMBOL_GPL(devm_iio_device_register); | ||
1247 | |||
1248 | /** | ||
1249 | * devm_iio_device_unregister - Resource-managed iio_device_unregister() | ||
1250 | * @dev: Device this iio_dev belongs to | ||
1251 | * @indio_dev: the iio_dev associated with the device | ||
1252 | * | ||
1253 | * Unregister iio_dev registered with devm_iio_device_register(). | ||
1254 | */ | ||
1255 | void devm_iio_device_unregister(struct device *dev, struct iio_dev *indio_dev) | ||
1256 | { | ||
1257 | int rc; | ||
1258 | |||
1259 | rc = devres_release(dev, devm_iio_device_unreg, | ||
1260 | devm_iio_device_match, indio_dev); | ||
1261 | WARN_ON(rc); | ||
1262 | } | ||
1263 | EXPORT_SYMBOL_GPL(devm_iio_device_unregister); | ||
1264 | |||
1164 | subsys_initcall(iio_init); | 1265 | subsys_initcall(iio_init); |
1165 | module_exit(iio_exit); | 1266 | module_exit(iio_exit); |
1166 | 1267 | ||
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index c10eab64bc05..bc043fab4cd1 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c | |||
@@ -42,6 +42,12 @@ struct iio_event_interface { | |||
42 | struct attribute_group group; | 42 | struct attribute_group group; |
43 | }; | 43 | }; |
44 | 44 | ||
45 | /** | ||
46 | * iio_push_event() - try to add event to the list for userspace reading | ||
47 | * @indio_dev: IIO device structure | ||
48 | * @ev_code: What event | ||
49 | * @timestamp: When the event occurred | ||
50 | **/ | ||
45 | int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) | 51 | int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp) |
46 | { | 52 | { |
47 | struct iio_event_interface *ev_int = indio_dev->event_interface; | 53 | struct iio_event_interface *ev_int = indio_dev->event_interface; |
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index bf5e70a32d3f..7ba2f002ffca 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c | |||
@@ -318,7 +318,7 @@ static ssize_t iio_trigger_read_current(struct device *dev, | |||
318 | * iio_trigger_write_current() - trigger consumer sysfs set current trigger | 318 | * iio_trigger_write_current() - trigger consumer sysfs set current trigger |
319 | * | 319 | * |
320 | * For trigger consumers the current_trigger interface allows the trigger | 320 | * For trigger consumers the current_trigger interface allows the trigger |
321 | * used for this device to be specified at run time based on the triggers | 321 | * used for this device to be specified at run time based on the trigger's |
322 | * name. | 322 | * name. |
323 | **/ | 323 | **/ |
324 | static ssize_t iio_trigger_write_current(struct device *dev, | 324 | static ssize_t iio_trigger_write_current(struct device *dev, |
@@ -356,7 +356,7 @@ static ssize_t iio_trigger_write_current(struct device *dev, | |||
356 | 356 | ||
357 | indio_dev->trig = trig; | 357 | indio_dev->trig = trig; |
358 | 358 | ||
359 | if (oldtrig && indio_dev->trig != oldtrig) | 359 | if (oldtrig) |
360 | iio_trigger_put(oldtrig); | 360 | iio_trigger_put(oldtrig); |
361 | if (indio_dev->trig) | 361 | if (indio_dev->trig) |
362 | iio_trigger_get(indio_dev->trig); | 362 | iio_trigger_get(indio_dev->trig); |
@@ -506,6 +506,23 @@ static int devm_iio_trigger_match(struct device *dev, void *res, void *data) | |||
506 | return *r == data; | 506 | return *r == data; |
507 | } | 507 | } |
508 | 508 | ||
509 | /** | ||
510 | * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc() | ||
511 | * @dev: Device to allocate iio_trigger for | ||
512 | * @fmt: trigger name format. If it includes format | ||
513 | * specifiers, the additional arguments following | ||
514 | * format are formatted and inserted in the resulting | ||
515 | * string replacing their respective specifiers. | ||
516 | * | ||
517 | * Managed iio_trigger_alloc. iio_trigger allocated with this function is | ||
518 | * automatically freed on driver detach. | ||
519 | * | ||
520 | * If an iio_trigger allocated with this function needs to be freed separately, | ||
521 | * devm_iio_trigger_free() must be used. | ||
522 | * | ||
523 | * RETURNS: | ||
524 | * Pointer to allocated iio_trigger on success, NULL on failure. | ||
525 | */ | ||
509 | struct iio_trigger *devm_iio_trigger_alloc(struct device *dev, | 526 | struct iio_trigger *devm_iio_trigger_alloc(struct device *dev, |
510 | const char *fmt, ...) | 527 | const char *fmt, ...) |
511 | { | 528 | { |
@@ -532,6 +549,13 @@ struct iio_trigger *devm_iio_trigger_alloc(struct device *dev, | |||
532 | } | 549 | } |
533 | EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc); | 550 | EXPORT_SYMBOL_GPL(devm_iio_trigger_alloc); |
534 | 551 | ||
552 | /** | ||
553 | * devm_iio_trigger_free - Resource-managed iio_trigger_free() | ||
554 | * @dev: Device this iio_dev belongs to | ||
555 | * @iio_trig: the iio_trigger associated with the device | ||
556 | * | ||
557 | * Free iio_trigger allocated with devm_iio_trigger_alloc(). | ||
558 | */ | ||
535 | void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig) | 559 | void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig) |
536 | { | 560 | { |
537 | int rc; | 561 | int rc; |
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index fa6ae8cf89ea..0c7f115ee3b3 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c | |||
@@ -229,6 +229,17 @@ static int als_parse_report(struct platform_device *pdev, | |||
229 | dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index, | 229 | dev_dbg(&pdev->dev, "als %x:%x\n", st->als_illum.index, |
230 | st->als_illum.report_id); | 230 | st->als_illum.report_id); |
231 | 231 | ||
232 | /* Set Sensitivity field ids, when there is no individual modifier */ | ||
233 | if (st->common_attributes.sensitivity.index < 0) { | ||
234 | sensor_hub_input_get_attribute_info(hsdev, | ||
235 | HID_FEATURE_REPORT, usage_id, | ||
236 | HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | | ||
237 | HID_USAGE_SENSOR_DATA_LIGHT, | ||
238 | &st->common_attributes.sensitivity); | ||
239 | dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", | ||
240 | st->common_attributes.sensitivity.index, | ||
241 | st->common_attributes.sensitivity.report_id); | ||
242 | } | ||
232 | return ret; | 243 | return ret; |
233 | } | 244 | } |
234 | 245 | ||
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c index 5e5d9dea22c5..0c6e459c86b1 100644 --- a/drivers/iio/light/tsl2563.c +++ b/drivers/iio/light/tsl2563.c | |||
@@ -714,6 +714,7 @@ static int tsl2563_probe(struct i2c_client *client, | |||
714 | struct iio_dev *indio_dev; | 714 | struct iio_dev *indio_dev; |
715 | struct tsl2563_chip *chip; | 715 | struct tsl2563_chip *chip; |
716 | struct tsl2563_platform_data *pdata = client->dev.platform_data; | 716 | struct tsl2563_platform_data *pdata = client->dev.platform_data; |
717 | struct device_node *np = client->dev.of_node; | ||
717 | int err = 0; | 718 | int err = 0; |
718 | u8 id = 0; | 719 | u8 id = 0; |
719 | 720 | ||
@@ -750,6 +751,9 @@ static int tsl2563_probe(struct i2c_client *client, | |||
750 | 751 | ||
751 | if (pdata) | 752 | if (pdata) |
752 | chip->cover_comp_gain = pdata->cover_comp_gain; | 753 | chip->cover_comp_gain = pdata->cover_comp_gain; |
754 | else if (np) | ||
755 | of_property_read_u32(np, "amstaos,cover-comp-gain", | ||
756 | &chip->cover_comp_gain); | ||
753 | else | 757 | else |
754 | chip->cover_comp_gain = 1; | 758 | chip->cover_comp_gain = 1; |
755 | 759 | ||
diff --git a/drivers/iio/light/vcnl4000.c b/drivers/iio/light/vcnl4000.c index ecb3341ef9c0..384ac23f576f 100644 --- a/drivers/iio/light/vcnl4000.c +++ b/drivers/iio/light/vcnl4000.c | |||
@@ -179,13 +179,7 @@ static int vcnl4000_probe(struct i2c_client *client, | |||
179 | indio_dev->name = VCNL4000_DRV_NAME; | 179 | indio_dev->name = VCNL4000_DRV_NAME; |
180 | indio_dev->modes = INDIO_DIRECT_MODE; | 180 | indio_dev->modes = INDIO_DIRECT_MODE; |
181 | 181 | ||
182 | return iio_device_register(indio_dev); | 182 | return devm_iio_device_register(&client->dev, indio_dev); |
183 | } | ||
184 | |||
185 | static int vcnl4000_remove(struct i2c_client *client) | ||
186 | { | ||
187 | iio_device_unregister(i2c_get_clientdata(client)); | ||
188 | return 0; | ||
189 | } | 183 | } |
190 | 184 | ||
191 | static struct i2c_driver vcnl4000_driver = { | 185 | static struct i2c_driver vcnl4000_driver = { |
@@ -194,7 +188,6 @@ static struct i2c_driver vcnl4000_driver = { | |||
194 | .owner = THIS_MODULE, | 188 | .owner = THIS_MODULE, |
195 | }, | 189 | }, |
196 | .probe = vcnl4000_probe, | 190 | .probe = vcnl4000_probe, |
197 | .remove = vcnl4000_remove, | ||
198 | .id_table = vcnl4000_id, | 191 | .id_table = vcnl4000_id, |
199 | }; | 192 | }; |
200 | 193 | ||
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 2634920562fb..67fce1916d21 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c | |||
@@ -263,6 +263,18 @@ static int magn_3d_parse_report(struct platform_device *pdev, | |||
263 | st->magn[1].index, st->magn[1].report_id, | 263 | st->magn[1].index, st->magn[1].report_id, |
264 | st->magn[2].index, st->magn[2].report_id); | 264 | st->magn[2].index, st->magn[2].report_id); |
265 | 265 | ||
266 | /* Set Sensitivity field ids, when there is no individual modifier */ | ||
267 | if (st->common_attributes.sensitivity.index < 0) { | ||
268 | sensor_hub_input_get_attribute_info(hsdev, | ||
269 | HID_FEATURE_REPORT, usage_id, | ||
270 | HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS | | ||
271 | HID_USAGE_SENSOR_DATA_ORIENTATION, | ||
272 | &st->common_attributes.sensitivity); | ||
273 | dev_dbg(&pdev->dev, "Sensitivity index:report %d:%d\n", | ||
274 | st->common_attributes.sensitivity.index, | ||
275 | st->common_attributes.sensitivity.report_id); | ||
276 | } | ||
277 | |||
266 | return ret; | 278 | return ret; |
267 | } | 279 | } |
268 | 280 | ||
diff --git a/drivers/iio/pressure/Kconfig b/drivers/iio/pressure/Kconfig index 4f2e0f9bad8c..a8b9cae5c173 100644 --- a/drivers/iio/pressure/Kconfig +++ b/drivers/iio/pressure/Kconfig | |||
@@ -5,6 +5,18 @@ | |||
5 | 5 | ||
6 | menu "Pressure sensors" | 6 | menu "Pressure sensors" |
7 | 7 | ||
8 | config MPL3115 | ||
9 | tristate "Freescale MPL3115A2 pressure sensor driver" | ||
10 | depends on I2C | ||
11 | select IIO_BUFFER | ||
12 | select IIO_TRIGGERED_BUFFER | ||
13 | help | ||
14 | Say yes here to build support for the Freescale MPL3115A2 | ||
15 | pressure sensor / altimeter. | ||
16 | |||
17 | To compile this driver as a module, choose M here: the module | ||
18 | will be called mpl3115. | ||
19 | |||
8 | config IIO_ST_PRESS | 20 | config IIO_ST_PRESS |
9 | tristate "STMicroelectronics pressure sensor Driver" | 21 | tristate "STMicroelectronics pressure sensor Driver" |
10 | depends on (I2C || SPI_MASTER) && SYSFS | 22 | depends on (I2C || SPI_MASTER) && SYSFS |
diff --git a/drivers/iio/pressure/Makefile b/drivers/iio/pressure/Makefile index be71464c2752..42bb9fcf5436 100644 --- a/drivers/iio/pressure/Makefile +++ b/drivers/iio/pressure/Makefile | |||
@@ -3,6 +3,7 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | # When adding new entries keep the list in alphabetical order | 5 | # When adding new entries keep the list in alphabetical order |
6 | obj-$(CONFIG_MPL3115) += mpl3115.o | ||
6 | obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o | 7 | obj-$(CONFIG_IIO_ST_PRESS) += st_pressure.o |
7 | st_pressure-y := st_pressure_core.o | 8 | st_pressure-y := st_pressure_core.o |
8 | st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o | 9 | st_pressure-$(CONFIG_IIO_BUFFER) += st_pressure_buffer.o |
diff --git a/drivers/iio/pressure/mpl3115.c b/drivers/iio/pressure/mpl3115.c new file mode 100644 index 000000000000..ac8c8ab723e5 --- /dev/null +++ b/drivers/iio/pressure/mpl3115.c | |||
@@ -0,0 +1,329 @@ | |||
1 | /* | ||
2 | * mpl3115.c - Support for Freescale MPL3115A2 pressure/temperature sensor | ||
3 | * | ||
4 | * Copyright (c) 2013 Peter Meerwald <pmeerw@pmeerw.net> | ||
5 | * | ||
6 | * This file is subject to the terms and conditions of version 2 of | ||
7 | * the GNU General Public License. See the file COPYING in the main | ||
8 | * directory of this archive for more details. | ||
9 | * | ||
10 | * (7-bit I2C slave address 0x60) | ||
11 | * | ||
12 | * TODO: FIFO buffer, altimeter mode, oversampling, continuous mode, | ||
13 | * interrupts, user offset correction, raw mode | ||
14 | */ | ||
15 | |||
16 | #include <linux/module.h> | ||
17 | #include <linux/i2c.h> | ||
18 | #include <linux/iio/iio.h> | ||
19 | #include <linux/iio/sysfs.h> | ||
20 | #include <linux/iio/trigger_consumer.h> | ||
21 | #include <linux/iio/buffer.h> | ||
22 | #include <linux/iio/triggered_buffer.h> | ||
23 | #include <linux/delay.h> | ||
24 | |||
25 | #define MPL3115_STATUS 0x00 | ||
26 | #define MPL3115_OUT_PRESS 0x01 /* MSB first, 20 bit */ | ||
27 | #define MPL3115_OUT_TEMP 0x04 /* MSB first, 12 bit */ | ||
28 | #define MPL3115_WHO_AM_I 0x0c | ||
29 | #define MPL3115_CTRL_REG1 0x26 | ||
30 | |||
31 | #define MPL3115_DEVICE_ID 0xc4 | ||
32 | |||
33 | #define MPL3115_STATUS_PRESS_RDY BIT(2) | ||
34 | #define MPL3115_STATUS_TEMP_RDY BIT(1) | ||
35 | |||
36 | #define MPL3115_CTRL_RESET BIT(2) /* software reset */ | ||
37 | #define MPL3115_CTRL_OST BIT(1) /* initiate measurement */ | ||
38 | #define MPL3115_CTRL_ACTIVE BIT(0) /* continuous measurement */ | ||
39 | #define MPL3115_CTRL_OS_258MS (BIT(5) | BIT(4)) /* 64x oversampling */ | ||
40 | |||
41 | struct mpl3115_data { | ||
42 | struct i2c_client *client; | ||
43 | struct mutex lock; | ||
44 | u8 ctrl_reg1; | ||
45 | }; | ||
46 | |||
47 | static int mpl3115_request(struct mpl3115_data *data) | ||
48 | { | ||
49 | int ret, tries = 15; | ||
50 | |||
51 | /* trigger measurement */ | ||
52 | ret = i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1, | ||
53 | data->ctrl_reg1 | MPL3115_CTRL_OST); | ||
54 | if (ret < 0) | ||
55 | return ret; | ||
56 | |||
57 | while (tries-- > 0) { | ||
58 | ret = i2c_smbus_read_byte_data(data->client, MPL3115_CTRL_REG1); | ||
59 | if (ret < 0) | ||
60 | return ret; | ||
61 | /* wait for data ready, i.e. OST cleared */ | ||
62 | if (!(ret & MPL3115_CTRL_OST)) | ||
63 | break; | ||
64 | msleep(20); | ||
65 | } | ||
66 | |||
67 | if (tries < 0) { | ||
68 | dev_err(&data->client->dev, "data not ready\n"); | ||
69 | return -EIO; | ||
70 | } | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static int mpl3115_read_raw(struct iio_dev *indio_dev, | ||
76 | struct iio_chan_spec const *chan, | ||
77 | int *val, int *val2, long mask) | ||
78 | { | ||
79 | struct mpl3115_data *data = iio_priv(indio_dev); | ||
80 | s32 tmp = 0; | ||
81 | int ret; | ||
82 | |||
83 | switch (mask) { | ||
84 | case IIO_CHAN_INFO_RAW: | ||
85 | if (iio_buffer_enabled(indio_dev)) | ||
86 | return -EBUSY; | ||
87 | |||
88 | switch (chan->type) { | ||
89 | case IIO_PRESSURE: /* in 0.25 pascal / LSB */ | ||
90 | mutex_lock(&data->lock); | ||
91 | ret = mpl3115_request(data); | ||
92 | if (ret < 0) { | ||
93 | mutex_unlock(&data->lock); | ||
94 | return ret; | ||
95 | } | ||
96 | ret = i2c_smbus_read_i2c_block_data(data->client, | ||
97 | MPL3115_OUT_PRESS, 3, (u8 *) &tmp); | ||
98 | mutex_unlock(&data->lock); | ||
99 | if (ret < 0) | ||
100 | return ret; | ||
101 | *val = sign_extend32(be32_to_cpu(tmp) >> 12, 23); | ||
102 | return IIO_VAL_INT; | ||
103 | case IIO_TEMP: /* in 0.0625 celsius / LSB */ | ||
104 | mutex_lock(&data->lock); | ||
105 | ret = mpl3115_request(data); | ||
106 | if (ret < 0) { | ||
107 | mutex_unlock(&data->lock); | ||
108 | return ret; | ||
109 | } | ||
110 | ret = i2c_smbus_read_i2c_block_data(data->client, | ||
111 | MPL3115_OUT_TEMP, 2, (u8 *) &tmp); | ||
112 | mutex_unlock(&data->lock); | ||
113 | if (ret < 0) | ||
114 | return ret; | ||
115 | *val = sign_extend32(be32_to_cpu(tmp) >> 20, 15); | ||
116 | return IIO_VAL_INT; | ||
117 | default: | ||
118 | return -EINVAL; | ||
119 | } | ||
120 | case IIO_CHAN_INFO_SCALE: | ||
121 | switch (chan->type) { | ||
122 | case IIO_PRESSURE: | ||
123 | *val = 0; | ||
124 | *val2 = 250; /* want kilopascal */ | ||
125 | return IIO_VAL_INT_PLUS_MICRO; | ||
126 | case IIO_TEMP: | ||
127 | *val = 0; | ||
128 | *val2 = 62500; | ||
129 | return IIO_VAL_INT_PLUS_MICRO; | ||
130 | default: | ||
131 | return -EINVAL; | ||
132 | } | ||
133 | } | ||
134 | return -EINVAL; | ||
135 | } | ||
136 | |||
137 | static irqreturn_t mpl3115_trigger_handler(int irq, void *p) | ||
138 | { | ||
139 | struct iio_poll_func *pf = p; | ||
140 | struct iio_dev *indio_dev = pf->indio_dev; | ||
141 | struct mpl3115_data *data = iio_priv(indio_dev); | ||
142 | u8 buffer[16]; /* 32-bit channel + 16-bit channel + padding + ts */ | ||
143 | int ret, pos = 0; | ||
144 | |||
145 | mutex_lock(&data->lock); | ||
146 | ret = mpl3115_request(data); | ||
147 | if (ret < 0) { | ||
148 | mutex_unlock(&data->lock); | ||
149 | goto done; | ||
150 | } | ||
151 | |||
152 | memset(buffer, 0, sizeof(buffer)); | ||
153 | if (test_bit(0, indio_dev->active_scan_mask)) { | ||
154 | ret = i2c_smbus_read_i2c_block_data(data->client, | ||
155 | MPL3115_OUT_PRESS, 3, &buffer[pos]); | ||
156 | if (ret < 0) { | ||
157 | mutex_unlock(&data->lock); | ||
158 | goto done; | ||
159 | } | ||
160 | pos += 4; | ||
161 | } | ||
162 | |||
163 | if (test_bit(1, indio_dev->active_scan_mask)) { | ||
164 | ret = i2c_smbus_read_i2c_block_data(data->client, | ||
165 | MPL3115_OUT_TEMP, 2, &buffer[pos]); | ||
166 | if (ret < 0) { | ||
167 | mutex_unlock(&data->lock); | ||
168 | goto done; | ||
169 | } | ||
170 | } | ||
171 | mutex_unlock(&data->lock); | ||
172 | |||
173 | iio_push_to_buffers_with_timestamp(indio_dev, buffer, | ||
174 | iio_get_time_ns()); | ||
175 | |||
176 | done: | ||
177 | iio_trigger_notify_done(indio_dev->trig); | ||
178 | return IRQ_HANDLED; | ||
179 | } | ||
180 | |||
181 | static const struct iio_chan_spec mpl3115_channels[] = { | ||
182 | { | ||
183 | .type = IIO_PRESSURE, | ||
184 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), | ||
185 | BIT(IIO_CHAN_INFO_SCALE), | ||
186 | .scan_index = 0, | ||
187 | .scan_type = { | ||
188 | .sign = 's', | ||
189 | .realbits = 20, | ||
190 | .storagebits = 32, | ||
191 | .shift = 12, | ||
192 | .endianness = IIO_BE, | ||
193 | } | ||
194 | }, | ||
195 | { | ||
196 | .type = IIO_TEMP, | ||
197 | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), | ||
198 | BIT(IIO_CHAN_INFO_SCALE), | ||
199 | .scan_index = 1, | ||
200 | .scan_type = { | ||
201 | .sign = 's', | ||
202 | .realbits = 12, | ||
203 | .storagebits = 16, | ||
204 | .shift = 4, | ||
205 | .endianness = IIO_BE, | ||
206 | } | ||
207 | }, | ||
208 | IIO_CHAN_SOFT_TIMESTAMP(2), | ||
209 | }; | ||
210 | |||
211 | static const struct iio_info mpl3115_info = { | ||
212 | .read_raw = &mpl3115_read_raw, | ||
213 | .driver_module = THIS_MODULE, | ||
214 | }; | ||
215 | |||
216 | static int mpl3115_probe(struct i2c_client *client, | ||
217 | const struct i2c_device_id *id) | ||
218 | { | ||
219 | struct mpl3115_data *data; | ||
220 | struct iio_dev *indio_dev; | ||
221 | int ret; | ||
222 | |||
223 | ret = i2c_smbus_read_byte_data(client, MPL3115_WHO_AM_I); | ||
224 | if (ret < 0) | ||
225 | return ret; | ||
226 | if (ret != MPL3115_DEVICE_ID) | ||
227 | return -ENODEV; | ||
228 | |||
229 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); | ||
230 | if (!indio_dev) | ||
231 | return -ENOMEM; | ||
232 | |||
233 | data = iio_priv(indio_dev); | ||
234 | data->client = client; | ||
235 | mutex_init(&data->lock); | ||
236 | |||
237 | i2c_set_clientdata(client, indio_dev); | ||
238 | indio_dev->info = &mpl3115_info; | ||
239 | indio_dev->name = id->name; | ||
240 | indio_dev->dev.parent = &client->dev; | ||
241 | indio_dev->modes = INDIO_DIRECT_MODE; | ||
242 | indio_dev->channels = mpl3115_channels; | ||
243 | indio_dev->num_channels = ARRAY_SIZE(mpl3115_channels); | ||
244 | |||
245 | /* software reset, I2C transfer is aborted (fails) */ | ||
246 | i2c_smbus_write_byte_data(client, MPL3115_CTRL_REG1, | ||
247 | MPL3115_CTRL_RESET); | ||
248 | msleep(50); | ||
249 | |||
250 | data->ctrl_reg1 = MPL3115_CTRL_OS_258MS; | ||
251 | ret = i2c_smbus_write_byte_data(client, MPL3115_CTRL_REG1, | ||
252 | data->ctrl_reg1); | ||
253 | if (ret < 0) | ||
254 | return ret; | ||
255 | |||
256 | ret = iio_triggered_buffer_setup(indio_dev, NULL, | ||
257 | mpl3115_trigger_handler, NULL); | ||
258 | if (ret < 0) | ||
259 | return ret; | ||
260 | |||
261 | ret = iio_device_register(indio_dev); | ||
262 | if (ret < 0) | ||
263 | goto buffer_cleanup; | ||
264 | return 0; | ||
265 | |||
266 | buffer_cleanup: | ||
267 | iio_triggered_buffer_cleanup(indio_dev); | ||
268 | return ret; | ||
269 | } | ||
270 | |||
271 | static int mpl3115_standby(struct mpl3115_data *data) | ||
272 | { | ||
273 | return i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1, | ||
274 | data->ctrl_reg1 & ~MPL3115_CTRL_ACTIVE); | ||
275 | } | ||
276 | |||
277 | static int mpl3115_remove(struct i2c_client *client) | ||
278 | { | ||
279 | struct iio_dev *indio_dev = i2c_get_clientdata(client); | ||
280 | |||
281 | iio_device_unregister(indio_dev); | ||
282 | iio_triggered_buffer_cleanup(indio_dev); | ||
283 | mpl3115_standby(iio_priv(indio_dev)); | ||
284 | |||
285 | return 0; | ||
286 | } | ||
287 | |||
288 | #ifdef CONFIG_PM_SLEEP | ||
289 | static int mpl3115_suspend(struct device *dev) | ||
290 | { | ||
291 | return mpl3115_standby(iio_priv(i2c_get_clientdata( | ||
292 | to_i2c_client(dev)))); | ||
293 | } | ||
294 | |||
295 | static int mpl3115_resume(struct device *dev) | ||
296 | { | ||
297 | struct mpl3115_data *data = iio_priv(i2c_get_clientdata( | ||
298 | to_i2c_client(dev))); | ||
299 | |||
300 | return i2c_smbus_write_byte_data(data->client, MPL3115_CTRL_REG1, | ||
301 | data->ctrl_reg1); | ||
302 | } | ||
303 | |||
304 | static SIMPLE_DEV_PM_OPS(mpl3115_pm_ops, mpl3115_suspend, mpl3115_resume); | ||
305 | #define MPL3115_PM_OPS (&mpl3115_pm_ops) | ||
306 | #else | ||
307 | #define MPL3115_PM_OPS NULL | ||
308 | #endif | ||
309 | |||
310 | static const struct i2c_device_id mpl3115_id[] = { | ||
311 | { "mpl3115", 0 }, | ||
312 | { } | ||
313 | }; | ||
314 | MODULE_DEVICE_TABLE(i2c, mpl3115_id); | ||
315 | |||
316 | static struct i2c_driver mpl3115_driver = { | ||
317 | .driver = { | ||
318 | .name = "mpl3115", | ||
319 | .pm = MPL3115_PM_OPS, | ||
320 | }, | ||
321 | .probe = mpl3115_probe, | ||
322 | .remove = mpl3115_remove, | ||
323 | .id_table = mpl3115_id, | ||
324 | }; | ||
325 | module_i2c_driver(mpl3115_driver); | ||
326 | |||
327 | MODULE_AUTHOR("Peter Meerwald <pmeerw@pmeerw.net>"); | ||
328 | MODULE_DESCRIPTION("Freescale MPL3115 pressure/temperature driver"); | ||
329 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/staging/iio/accel/adis16220_core.c b/drivers/staging/iio/accel/adis16220_core.c index 4c9364b63c77..6f38ca95f9bb 100644 --- a/drivers/staging/iio/accel/adis16220_core.c +++ b/drivers/staging/iio/accel/adis16220_core.c | |||
@@ -439,13 +439,13 @@ static int adis16220_probe(struct spi_device *spi) | |||
439 | indio_dev->channels = adis16220_channels; | 439 | indio_dev->channels = adis16220_channels; |
440 | indio_dev->num_channels = ARRAY_SIZE(adis16220_channels); | 440 | indio_dev->num_channels = ARRAY_SIZE(adis16220_channels); |
441 | 441 | ||
442 | ret = iio_device_register(indio_dev); | 442 | ret = devm_iio_device_register(&spi->dev, indio_dev); |
443 | if (ret) | 443 | if (ret) |
444 | return ret; | 444 | return ret; |
445 | 445 | ||
446 | ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &accel_bin); | 446 | ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &accel_bin); |
447 | if (ret) | 447 | if (ret) |
448 | goto error_unregister_dev; | 448 | return ret; |
449 | 449 | ||
450 | ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &adc1_bin); | 450 | ret = sysfs_create_bin_file(&indio_dev->dev.kobj, &adc1_bin); |
451 | if (ret) | 451 | if (ret) |
@@ -470,8 +470,6 @@ error_rm_adc1_bin: | |||
470 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin); | 470 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin); |
471 | error_rm_accel_bin: | 471 | error_rm_accel_bin: |
472 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); | 472 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); |
473 | error_unregister_dev: | ||
474 | iio_device_unregister(indio_dev); | ||
475 | return ret; | 473 | return ret; |
476 | } | 474 | } |
477 | 475 | ||
@@ -482,7 +480,6 @@ static int adis16220_remove(struct spi_device *spi) | |||
482 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc2_bin); | 480 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc2_bin); |
483 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin); | 481 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &adc1_bin); |
484 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); | 482 | sysfs_remove_bin_file(&indio_dev->dev.kobj, &accel_bin); |
485 | iio_device_unregister(indio_dev); | ||
486 | 483 | ||
487 | return 0; | 484 | return 0; |
488 | } | 485 | } |
diff --git a/drivers/staging/iio/adc/ad7816.c b/drivers/staging/iio/adc/ad7816.c index 9f48e5c74eed..2369cf28412e 100644 --- a/drivers/staging/iio/adc/ad7816.c +++ b/drivers/staging/iio/adc/ad7816.c | |||
@@ -412,7 +412,7 @@ static int ad7816_probe(struct spi_device *spi_dev) | |||
412 | return ret; | 412 | return ret; |
413 | } | 413 | } |
414 | 414 | ||
415 | ret = iio_device_register(indio_dev); | 415 | ret = devm_iio_device_register(&spi_dev->dev, indio_dev); |
416 | if (ret) | 416 | if (ret) |
417 | return ret; | 417 | return ret; |
418 | 418 | ||
@@ -422,15 +422,6 @@ static int ad7816_probe(struct spi_device *spi_dev) | |||
422 | return 0; | 422 | return 0; |
423 | } | 423 | } |
424 | 424 | ||
425 | static int ad7816_remove(struct spi_device *spi_dev) | ||
426 | { | ||
427 | struct iio_dev *indio_dev = dev_get_drvdata(&spi_dev->dev); | ||
428 | |||
429 | iio_device_unregister(indio_dev); | ||
430 | |||
431 | return 0; | ||
432 | } | ||
433 | |||
434 | static const struct spi_device_id ad7816_id[] = { | 425 | static const struct spi_device_id ad7816_id[] = { |
435 | { "ad7816", 0 }, | 426 | { "ad7816", 0 }, |
436 | { "ad7817", 0 }, | 427 | { "ad7817", 0 }, |
@@ -446,7 +437,6 @@ static struct spi_driver ad7816_driver = { | |||
446 | .owner = THIS_MODULE, | 437 | .owner = THIS_MODULE, |
447 | }, | 438 | }, |
448 | .probe = ad7816_probe, | 439 | .probe = ad7816_probe, |
449 | .remove = ad7816_remove, | ||
450 | .id_table = ad7816_id, | 440 | .id_table = ad7816_id, |
451 | }; | 441 | }; |
452 | module_spi_driver(ad7816_driver); | 442 | module_spi_driver(ad7816_driver); |
diff --git a/drivers/staging/iio/adc/lpc32xx_adc.c b/drivers/staging/iio/adc/lpc32xx_adc.c index ef0a21d8ce15..a876ce755351 100644 --- a/drivers/staging/iio/adc/lpc32xx_adc.c +++ b/drivers/staging/iio/adc/lpc32xx_adc.c | |||
@@ -183,7 +183,7 @@ static int lpc32xx_adc_probe(struct platform_device *pdev) | |||
183 | iodev->channels = lpc32xx_adc_iio_channels; | 183 | iodev->channels = lpc32xx_adc_iio_channels; |
184 | iodev->num_channels = ARRAY_SIZE(lpc32xx_adc_iio_channels); | 184 | iodev->num_channels = ARRAY_SIZE(lpc32xx_adc_iio_channels); |
185 | 185 | ||
186 | retval = iio_device_register(iodev); | 186 | retval = devm_iio_device_register(&pdev->dev, iodev); |
187 | if (retval) | 187 | if (retval) |
188 | return retval; | 188 | return retval; |
189 | 189 | ||
@@ -192,15 +192,6 @@ static int lpc32xx_adc_probe(struct platform_device *pdev) | |||
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | static int lpc32xx_adc_remove(struct platform_device *pdev) | ||
196 | { | ||
197 | struct iio_dev *iodev = platform_get_drvdata(pdev); | ||
198 | |||
199 | iio_device_unregister(iodev); | ||
200 | |||
201 | return 0; | ||
202 | } | ||
203 | |||
204 | #ifdef CONFIG_OF | 195 | #ifdef CONFIG_OF |
205 | static const struct of_device_id lpc32xx_adc_match[] = { | 196 | static const struct of_device_id lpc32xx_adc_match[] = { |
206 | { .compatible = "nxp,lpc3220-adc" }, | 197 | { .compatible = "nxp,lpc3220-adc" }, |
@@ -211,7 +202,6 @@ MODULE_DEVICE_TABLE(of, lpc32xx_adc_match); | |||
211 | 202 | ||
212 | static struct platform_driver lpc32xx_adc_driver = { | 203 | static struct platform_driver lpc32xx_adc_driver = { |
213 | .probe = lpc32xx_adc_probe, | 204 | .probe = lpc32xx_adc_probe, |
214 | .remove = lpc32xx_adc_remove, | ||
215 | .driver = { | 205 | .driver = { |
216 | .name = MOD_NAME, | 206 | .name = MOD_NAME, |
217 | .owner = THIS_MODULE, | 207 | .owner = THIS_MODULE, |
diff --git a/drivers/staging/iio/addac/adt7316-i2c.c b/drivers/staging/iio/addac/adt7316-i2c.c index 0feea5541d02..75ddd4f801a3 100644 --- a/drivers/staging/iio/addac/adt7316-i2c.c +++ b/drivers/staging/iio/addac/adt7316-i2c.c | |||
@@ -108,11 +108,6 @@ static int adt7316_i2c_probe(struct i2c_client *client, | |||
108 | return adt7316_probe(&client->dev, &bus, id->name); | 108 | return adt7316_probe(&client->dev, &bus, id->name); |
109 | } | 109 | } |
110 | 110 | ||
111 | static int adt7316_i2c_remove(struct i2c_client *client) | ||
112 | { | ||
113 | return adt7316_remove(&client->dev); | ||
114 | } | ||
115 | |||
116 | static const struct i2c_device_id adt7316_i2c_id[] = { | 111 | static const struct i2c_device_id adt7316_i2c_id[] = { |
117 | { "adt7316", 0 }, | 112 | { "adt7316", 0 }, |
118 | { "adt7317", 0 }, | 113 | { "adt7317", 0 }, |
@@ -132,7 +127,6 @@ static struct i2c_driver adt7316_driver = { | |||
132 | .owner = THIS_MODULE, | 127 | .owner = THIS_MODULE, |
133 | }, | 128 | }, |
134 | .probe = adt7316_i2c_probe, | 129 | .probe = adt7316_i2c_probe, |
135 | .remove = adt7316_i2c_remove, | ||
136 | .id_table = adt7316_i2c_id, | 130 | .id_table = adt7316_i2c_id, |
137 | }; | 131 | }; |
138 | module_i2c_driver(adt7316_driver); | 132 | module_i2c_driver(adt7316_driver); |
diff --git a/drivers/staging/iio/addac/adt7316-spi.c b/drivers/staging/iio/addac/adt7316-spi.c index 7f4f0a8245b4..e480abb72e4a 100644 --- a/drivers/staging/iio/addac/adt7316-spi.c +++ b/drivers/staging/iio/addac/adt7316-spi.c | |||
@@ -116,11 +116,6 @@ static int adt7316_spi_probe(struct spi_device *spi_dev) | |||
116 | return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias); | 116 | return adt7316_probe(&spi_dev->dev, &bus, spi_dev->modalias); |
117 | } | 117 | } |
118 | 118 | ||
119 | static int adt7316_spi_remove(struct spi_device *spi_dev) | ||
120 | { | ||
121 | return adt7316_remove(&spi_dev->dev); | ||
122 | } | ||
123 | |||
124 | static const struct spi_device_id adt7316_spi_id[] = { | 119 | static const struct spi_device_id adt7316_spi_id[] = { |
125 | { "adt7316", 0 }, | 120 | { "adt7316", 0 }, |
126 | { "adt7317", 0 }, | 121 | { "adt7317", 0 }, |
@@ -140,7 +135,6 @@ static struct spi_driver adt7316_driver = { | |||
140 | .owner = THIS_MODULE, | 135 | .owner = THIS_MODULE, |
141 | }, | 136 | }, |
142 | .probe = adt7316_spi_probe, | 137 | .probe = adt7316_spi_probe, |
143 | .remove = adt7316_spi_remove, | ||
144 | .id_table = adt7316_spi_id, | 138 | .id_table = adt7316_spi_id, |
145 | }; | 139 | }; |
146 | module_spi_driver(adt7316_driver); | 140 | module_spi_driver(adt7316_driver); |
diff --git a/drivers/staging/iio/addac/adt7316.c b/drivers/staging/iio/addac/adt7316.c index 80266e801d56..16a8201228ff 100644 --- a/drivers/staging/iio/addac/adt7316.c +++ b/drivers/staging/iio/addac/adt7316.c | |||
@@ -2166,7 +2166,7 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, | |||
2166 | if (ret) | 2166 | if (ret) |
2167 | return -EIO; | 2167 | return -EIO; |
2168 | 2168 | ||
2169 | ret = iio_device_register(indio_dev); | 2169 | ret = devm_iio_device_register(dev, indio_dev); |
2170 | if (ret) | 2170 | if (ret) |
2171 | return ret; | 2171 | return ret; |
2172 | 2172 | ||
@@ -2177,16 +2177,6 @@ int adt7316_probe(struct device *dev, struct adt7316_bus *bus, | |||
2177 | } | 2177 | } |
2178 | EXPORT_SYMBOL(adt7316_probe); | 2178 | EXPORT_SYMBOL(adt7316_probe); |
2179 | 2179 | ||
2180 | int adt7316_remove(struct device *dev) | ||
2181 | { | ||
2182 | struct iio_dev *indio_dev = dev_get_drvdata(dev); | ||
2183 | |||
2184 | iio_device_unregister(indio_dev); | ||
2185 | |||
2186 | return 0; | ||
2187 | } | ||
2188 | EXPORT_SYMBOL(adt7316_remove); | ||
2189 | |||
2190 | MODULE_AUTHOR("Sonic Zhang <sonic.zhang@analog.com>"); | 2180 | MODULE_AUTHOR("Sonic Zhang <sonic.zhang@analog.com>"); |
2191 | MODULE_DESCRIPTION("Analog Devices ADT7316/7/8 and ADT7516/7/9 digital" | 2181 | MODULE_DESCRIPTION("Analog Devices ADT7316/7/8 and ADT7516/7/9 digital" |
2192 | " temperature sensor, ADC and DAC driver"); | 2182 | " temperature sensor, ADC and DAC driver"); |
diff --git a/drivers/staging/iio/addac/adt7316.h b/drivers/staging/iio/addac/adt7316.h index 4d3efff46ae7..2dbfb499528d 100644 --- a/drivers/staging/iio/addac/adt7316.h +++ b/drivers/staging/iio/addac/adt7316.h | |||
@@ -31,6 +31,5 @@ extern const struct dev_pm_ops adt7316_pm_ops; | |||
31 | #define ADT7316_PM_OPS NULL | 31 | #define ADT7316_PM_OPS NULL |
32 | #endif | 32 | #endif |
33 | int adt7316_probe(struct device *dev, struct adt7316_bus *bus, const char *name); | 33 | int adt7316_probe(struct device *dev, struct adt7316_bus *bus, const char *name); |
34 | int adt7316_remove(struct device *dev); | ||
35 | 34 | ||
36 | #endif | 35 | #endif |
diff --git a/drivers/staging/iio/gyro/adis16060_core.c b/drivers/staging/iio/gyro/adis16060_core.c index 6d3d771154f3..d5d395c2e3e4 100644 --- a/drivers/staging/iio/gyro/adis16060_core.c +++ b/drivers/staging/iio/gyro/adis16060_core.c | |||
@@ -167,7 +167,7 @@ static int adis16060_r_probe(struct spi_device *spi) | |||
167 | indio_dev->channels = adis16060_channels; | 167 | indio_dev->channels = adis16060_channels; |
168 | indio_dev->num_channels = ARRAY_SIZE(adis16060_channels); | 168 | indio_dev->num_channels = ARRAY_SIZE(adis16060_channels); |
169 | 169 | ||
170 | ret = iio_device_register(indio_dev); | 170 | ret = devm_iio_device_register(&spi->dev, indio_dev); |
171 | if (ret) | 171 | if (ret) |
172 | return ret; | 172 | return ret; |
173 | 173 | ||
@@ -175,13 +175,6 @@ static int adis16060_r_probe(struct spi_device *spi) | |||
175 | return 0; | 175 | return 0; |
176 | } | 176 | } |
177 | 177 | ||
178 | /* fixme, confirm ordering in this function */ | ||
179 | static int adis16060_r_remove(struct spi_device *spi) | ||
180 | { | ||
181 | iio_device_unregister(spi_get_drvdata(spi)); | ||
182 | return 0; | ||
183 | } | ||
184 | |||
185 | static int adis16060_w_probe(struct spi_device *spi) | 178 | static int adis16060_w_probe(struct spi_device *spi) |
186 | { | 179 | { |
187 | int ret; | 180 | int ret; |
@@ -211,7 +204,6 @@ static struct spi_driver adis16060_r_driver = { | |||
211 | .owner = THIS_MODULE, | 204 | .owner = THIS_MODULE, |
212 | }, | 205 | }, |
213 | .probe = adis16060_r_probe, | 206 | .probe = adis16060_r_probe, |
214 | .remove = adis16060_r_remove, | ||
215 | }; | 207 | }; |
216 | 208 | ||
217 | static struct spi_driver adis16060_w_driver = { | 209 | static struct spi_driver adis16060_w_driver = { |
diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c index 488e690388c9..3660a43b5f08 100644 --- a/drivers/staging/iio/light/isl29018.c +++ b/drivers/staging/iio/light/isl29018.c | |||
@@ -585,7 +585,7 @@ static int isl29018_probe(struct i2c_client *client, | |||
585 | indio_dev->name = id->name; | 585 | indio_dev->name = id->name; |
586 | indio_dev->dev.parent = &client->dev; | 586 | indio_dev->dev.parent = &client->dev; |
587 | indio_dev->modes = INDIO_DIRECT_MODE; | 587 | indio_dev->modes = INDIO_DIRECT_MODE; |
588 | err = iio_device_register(indio_dev); | 588 | err = devm_iio_device_register(&client->dev, indio_dev); |
589 | if (err) { | 589 | if (err) { |
590 | dev_err(&client->dev, "iio registration fails\n"); | 590 | dev_err(&client->dev, "iio registration fails\n"); |
591 | return err; | 591 | return err; |
@@ -594,16 +594,6 @@ static int isl29018_probe(struct i2c_client *client, | |||
594 | return 0; | 594 | return 0; |
595 | } | 595 | } |
596 | 596 | ||
597 | static int isl29018_remove(struct i2c_client *client) | ||
598 | { | ||
599 | struct iio_dev *indio_dev = i2c_get_clientdata(client); | ||
600 | |||
601 | dev_dbg(&client->dev, "%s()\n", __func__); | ||
602 | iio_device_unregister(indio_dev); | ||
603 | |||
604 | return 0; | ||
605 | } | ||
606 | |||
607 | #ifdef CONFIG_PM_SLEEP | 597 | #ifdef CONFIG_PM_SLEEP |
608 | static int isl29018_suspend(struct device *dev) | 598 | static int isl29018_suspend(struct device *dev) |
609 | { | 599 | { |
@@ -664,7 +654,6 @@ static struct i2c_driver isl29018_driver = { | |||
664 | .of_match_table = isl29018_of_match, | 654 | .of_match_table = isl29018_of_match, |
665 | }, | 655 | }, |
666 | .probe = isl29018_probe, | 656 | .probe = isl29018_probe, |
667 | .remove = isl29018_remove, | ||
668 | .id_table = isl29018_id, | 657 | .id_table = isl29018_id, |
669 | }; | 658 | }; |
670 | module_i2c_driver(isl29018_driver); | 659 | module_i2c_driver(isl29018_driver); |
diff --git a/drivers/staging/iio/magnetometer/hmc5843.c b/drivers/staging/iio/magnetometer/hmc5843.c index 99421f90d189..bdb018878296 100644 --- a/drivers/staging/iio/magnetometer/hmc5843.c +++ b/drivers/staging/iio/magnetometer/hmc5843.c | |||
@@ -624,10 +624,17 @@ static const struct i2c_device_id hmc5843_id[] = { | |||
624 | }; | 624 | }; |
625 | MODULE_DEVICE_TABLE(i2c, hmc5843_id); | 625 | MODULE_DEVICE_TABLE(i2c, hmc5843_id); |
626 | 626 | ||
627 | static const struct of_device_id hmc5843_of_match[] = { | ||
628 | { .compatible = "honeywell,hmc5843" }, | ||
629 | {} | ||
630 | }; | ||
631 | MODULE_DEVICE_TABLE(of, hmc5843_of_match); | ||
632 | |||
627 | static struct i2c_driver hmc5843_driver = { | 633 | static struct i2c_driver hmc5843_driver = { |
628 | .driver = { | 634 | .driver = { |
629 | .name = "hmc5843", | 635 | .name = "hmc5843", |
630 | .pm = HMC5843_PM_OPS, | 636 | .pm = HMC5843_PM_OPS, |
637 | .of_match_table = of_match_ptr(hmc5843_of_match), | ||
631 | }, | 638 | }, |
632 | .id_table = hmc5843_id, | 639 | .id_table = hmc5843_id, |
633 | .probe = hmc5843_probe, | 640 | .probe = hmc5843_probe, |
diff --git a/drivers/staging/iio/resolver/ad2s1200.c b/drivers/staging/iio/resolver/ad2s1200.c index 62d30179301f..36eedd8a0ea9 100644 --- a/drivers/staging/iio/resolver/ad2s1200.c +++ b/drivers/staging/iio/resolver/ad2s1200.c | |||
@@ -131,7 +131,7 @@ static int ad2s1200_probe(struct spi_device *spi) | |||
131 | indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels); | 131 | indio_dev->num_channels = ARRAY_SIZE(ad2s1200_channels); |
132 | indio_dev->name = spi_get_device_id(spi)->name; | 132 | indio_dev->name = spi_get_device_id(spi)->name; |
133 | 133 | ||
134 | ret = iio_device_register(indio_dev); | 134 | ret = devm_iio_device_register(&spi->dev, indio_dev); |
135 | if (ret) | 135 | if (ret) |
136 | return ret; | 136 | return ret; |
137 | 137 | ||
@@ -142,13 +142,6 @@ static int ad2s1200_probe(struct spi_device *spi) | |||
142 | return 0; | 142 | return 0; |
143 | } | 143 | } |
144 | 144 | ||
145 | static int ad2s1200_remove(struct spi_device *spi) | ||
146 | { | ||
147 | iio_device_unregister(spi_get_drvdata(spi)); | ||
148 | |||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | static const struct spi_device_id ad2s1200_id[] = { | 145 | static const struct spi_device_id ad2s1200_id[] = { |
153 | { "ad2s1200" }, | 146 | { "ad2s1200" }, |
154 | { "ad2s1205" }, | 147 | { "ad2s1205" }, |
@@ -162,7 +155,6 @@ static struct spi_driver ad2s1200_driver = { | |||
162 | .owner = THIS_MODULE, | 155 | .owner = THIS_MODULE, |
163 | }, | 156 | }, |
164 | .probe = ad2s1200_probe, | 157 | .probe = ad2s1200_probe, |
165 | .remove = ad2s1200_remove, | ||
166 | .id_table = ad2s1200_id, | 158 | .id_table = ad2s1200_id, |
167 | }; | 159 | }; |
168 | module_spi_driver(ad2s1200_driver); | 160 | module_spi_driver(ad2s1200_driver); |
diff --git a/include/linux/hid-sensor-ids.h b/include/linux/hid-sensor-ids.h index 4f945d3ed49f..4cc165887b09 100644 --- a/include/linux/hid-sensor-ids.h +++ b/include/linux/hid-sensor-ids.h | |||
@@ -23,22 +23,26 @@ | |||
23 | 23 | ||
24 | /* Accel 3D (200073) */ | 24 | /* Accel 3D (200073) */ |
25 | #define HID_USAGE_SENSOR_ACCEL_3D 0x200073 | 25 | #define HID_USAGE_SENSOR_ACCEL_3D 0x200073 |
26 | #define HID_USAGE_SENSOR_DATA_ACCELERATION 0x200452 | ||
26 | #define HID_USAGE_SENSOR_ACCEL_X_AXIS 0x200453 | 27 | #define HID_USAGE_SENSOR_ACCEL_X_AXIS 0x200453 |
27 | #define HID_USAGE_SENSOR_ACCEL_Y_AXIS 0x200454 | 28 | #define HID_USAGE_SENSOR_ACCEL_Y_AXIS 0x200454 |
28 | #define HID_USAGE_SENSOR_ACCEL_Z_AXIS 0x200455 | 29 | #define HID_USAGE_SENSOR_ACCEL_Z_AXIS 0x200455 |
29 | 30 | ||
30 | /* ALS (200041) */ | 31 | /* ALS (200041) */ |
31 | #define HID_USAGE_SENSOR_ALS 0x200041 | 32 | #define HID_USAGE_SENSOR_ALS 0x200041 |
33 | #define HID_USAGE_SENSOR_DATA_LIGHT 0x2004d0 | ||
32 | #define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1 | 34 | #define HID_USAGE_SENSOR_LIGHT_ILLUM 0x2004d1 |
33 | 35 | ||
34 | /* Gyro 3D: (200076) */ | 36 | /* Gyro 3D: (200076) */ |
35 | #define HID_USAGE_SENSOR_GYRO_3D 0x200076 | 37 | #define HID_USAGE_SENSOR_GYRO_3D 0x200076 |
38 | #define HID_USAGE_SENSOR_DATA_ANGL_VELOCITY 0x200456 | ||
36 | #define HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS 0x200457 | 39 | #define HID_USAGE_SENSOR_ANGL_VELOCITY_X_AXIS 0x200457 |
37 | #define HID_USAGE_SENSOR_ANGL_VELOCITY_Y_AXIS 0x200458 | 40 | #define HID_USAGE_SENSOR_ANGL_VELOCITY_Y_AXIS 0x200458 |
38 | #define HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS 0x200459 | 41 | #define HID_USAGE_SENSOR_ANGL_VELOCITY_Z_AXIS 0x200459 |
39 | 42 | ||
40 | /* ORIENTATION: Compass 3D: (200083) */ | 43 | /* ORIENTATION: Compass 3D: (200083) */ |
41 | #define HID_USAGE_SENSOR_COMPASS_3D 0x200083 | 44 | #define HID_USAGE_SENSOR_COMPASS_3D 0x200083 |
45 | #define HID_USAGE_SENSOR_DATA_ORIENTATION 0x200470 | ||
42 | #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING 0x200471 | 46 | #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING 0x200471 |
43 | #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_X 0x200472 | 47 | #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_X 0x200472 |
44 | #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_Y 0x200473 | 48 | #define HID_USAGE_SENSOR_ORIENT_MAGN_HEADING_Y 0x200473 |
@@ -117,4 +121,8 @@ | |||
117 | #define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316 | 121 | #define HID_USAGE_SENSOR_PROP_REPORT_STATE 0x200316 |
118 | #define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319 | 122 | #define HID_USAGE_SENSOR_PROY_POWER_STATE 0x200319 |
119 | 123 | ||
124 | /* Per data field properties */ | ||
125 | #define HID_USAGE_SENSOR_DATA_MOD_NONE 0x00 | ||
126 | #define HID_USAGE_SENSOR_DATA_MOD_CHANGE_SENSITIVITY_ABS 0x1000 | ||
127 | |||
120 | #endif | 128 | #endif |
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index 256a90a1bea6..5b125fd554e4 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h | |||
@@ -490,32 +490,12 @@ struct iio_dev { | |||
490 | #endif | 490 | #endif |
491 | }; | 491 | }; |
492 | 492 | ||
493 | /** | ||
494 | * iio_find_channel_from_si() - get channel from its scan index | ||
495 | * @indio_dev: device | ||
496 | * @si: scan index to match | ||
497 | */ | ||
498 | const struct iio_chan_spec | 493 | const struct iio_chan_spec |
499 | *iio_find_channel_from_si(struct iio_dev *indio_dev, int si); | 494 | *iio_find_channel_from_si(struct iio_dev *indio_dev, int si); |
500 | |||
501 | /** | ||
502 | * iio_device_register() - register a device with the IIO subsystem | ||
503 | * @indio_dev: Device structure filled by the device driver | ||
504 | **/ | ||
505 | int iio_device_register(struct iio_dev *indio_dev); | 495 | int iio_device_register(struct iio_dev *indio_dev); |
506 | |||
507 | /** | ||
508 | * iio_device_unregister() - unregister a device from the IIO subsystem | ||
509 | * @indio_dev: Device structure representing the device. | ||
510 | **/ | ||
511 | void iio_device_unregister(struct iio_dev *indio_dev); | 496 | void iio_device_unregister(struct iio_dev *indio_dev); |
512 | 497 | int devm_iio_device_register(struct device *dev, struct iio_dev *indio_dev); | |
513 | /** | 498 | void devm_iio_device_unregister(struct device *dev, struct iio_dev *indio_dev); |
514 | * iio_push_event() - try to add event to the list for userspace reading | ||
515 | * @indio_dev: IIO device structure | ||
516 | * @ev_code: What event | ||
517 | * @timestamp: When the event occurred | ||
518 | **/ | ||
519 | int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp); | 499 | int iio_push_event(struct iio_dev *indio_dev, u64 ev_code, s64 timestamp); |
520 | 500 | ||
521 | extern struct bus_type iio_bus_type; | 501 | extern struct bus_type iio_bus_type; |
@@ -579,10 +559,6 @@ static inline void *iio_device_get_drvdata(struct iio_dev *indio_dev) | |||
579 | 559 | ||
580 | /* Can we make this smaller? */ | 560 | /* Can we make this smaller? */ |
581 | #define IIO_ALIGN L1_CACHE_BYTES | 561 | #define IIO_ALIGN L1_CACHE_BYTES |
582 | /** | ||
583 | * iio_device_alloc() - allocate an iio_dev from a driver | ||
584 | * @sizeof_priv: Space to allocate for private structure. | ||
585 | **/ | ||
586 | struct iio_dev *iio_device_alloc(int sizeof_priv); | 562 | struct iio_dev *iio_device_alloc(int sizeof_priv); |
587 | 563 | ||
588 | static inline void *iio_priv(const struct iio_dev *indio_dev) | 564 | static inline void *iio_priv(const struct iio_dev *indio_dev) |
@@ -596,64 +572,11 @@ static inline struct iio_dev *iio_priv_to_dev(void *priv) | |||
596 | ALIGN(sizeof(struct iio_dev), IIO_ALIGN)); | 572 | ALIGN(sizeof(struct iio_dev), IIO_ALIGN)); |
597 | } | 573 | } |
598 | 574 | ||
599 | /** | ||
600 | * iio_device_free() - free an iio_dev from a driver | ||
601 | * @indio_dev: the iio_dev associated with the device | ||
602 | **/ | ||
603 | void iio_device_free(struct iio_dev *indio_dev); | 575 | void iio_device_free(struct iio_dev *indio_dev); |
604 | |||
605 | /** | ||
606 | * devm_iio_device_alloc - Resource-managed iio_device_alloc() | ||
607 | * @dev: Device to allocate iio_dev for | ||
608 | * @sizeof_priv: Space to allocate for private structure. | ||
609 | * | ||
610 | * Managed iio_device_alloc. iio_dev allocated with this function is | ||
611 | * automatically freed on driver detach. | ||
612 | * | ||
613 | * If an iio_dev allocated with this function needs to be freed separately, | ||
614 | * devm_iio_device_free() must be used. | ||
615 | * | ||
616 | * RETURNS: | ||
617 | * Pointer to allocated iio_dev on success, NULL on failure. | ||
618 | */ | ||
619 | struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv); | 576 | struct iio_dev *devm_iio_device_alloc(struct device *dev, int sizeof_priv); |
620 | |||
621 | /** | ||
622 | * devm_iio_device_free - Resource-managed iio_device_free() | ||
623 | * @dev: Device this iio_dev belongs to | ||
624 | * @indio_dev: the iio_dev associated with the device | ||
625 | * | ||
626 | * Free iio_dev allocated with devm_iio_device_alloc(). | ||
627 | */ | ||
628 | void devm_iio_device_free(struct device *dev, struct iio_dev *indio_dev); | 577 | void devm_iio_device_free(struct device *dev, struct iio_dev *indio_dev); |
629 | |||
630 | /** | ||
631 | * devm_iio_trigger_alloc - Resource-managed iio_trigger_alloc() | ||
632 | * @dev: Device to allocate iio_trigger for | ||
633 | * @fmt: trigger name format. If it includes format | ||
634 | * specifiers, the additional arguments following | ||
635 | * format are formatted and inserted in the resulting | ||
636 | * string replacing their respective specifiers. | ||
637 | * | ||
638 | * Managed iio_trigger_alloc. iio_trigger allocated with this function is | ||
639 | * automatically freed on driver detach. | ||
640 | * | ||
641 | * If an iio_trigger allocated with this function needs to be freed separately, | ||
642 | * devm_iio_trigger_free() must be used. | ||
643 | * | ||
644 | * RETURNS: | ||
645 | * Pointer to allocated iio_trigger on success, NULL on failure. | ||
646 | */ | ||
647 | struct iio_trigger *devm_iio_trigger_alloc(struct device *dev, | 578 | struct iio_trigger *devm_iio_trigger_alloc(struct device *dev, |
648 | const char *fmt, ...); | 579 | const char *fmt, ...); |
649 | |||
650 | /** | ||
651 | * devm_iio_trigger_free - Resource-managed iio_trigger_free() | ||
652 | * @dev: Device this iio_dev belongs to | ||
653 | * @iio_trig: the iio_trigger associated with the device | ||
654 | * | ||
655 | * Free iio_trigger allocated with devm_iio_trigger_alloc(). | ||
656 | */ | ||
657 | void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig); | 580 | void devm_iio_trigger_free(struct device *dev, struct iio_trigger *iio_trig); |
658 | 581 | ||
659 | /** | 582 | /** |