diff options
author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-22 15:53:09 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-05-22 15:53:09 -0400 |
commit | 5a4733df7ef255446a213ee84efa5713a9765688 (patch) | |
tree | f921b8c8f251b7b7b7ad17f75eb5f98c21cc0baa /drivers/iio | |
parent | 08332893e37af6ae779367e78e444f8f9571511d (diff) | |
parent | 82237f268281d338aa35cd014be8ffb0b5445482 (diff) |
Merge tag 'iio-fixes-for-4.12a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus
Jonathan writes:
First set of IIO fixes in the 4.12 cycle.
Matt finally set up the lightning storm he needed to test the as3935.
* core
- Fix a null pointer deference in iio_trigger_write_current when changing
from a non existent trigger to another non existent trigger.
* a3935
- Recalibrate the RCO after resume.
- Fix interrupt mask so that we actually get some interrupts.
- Use iio_trigger_poll_chained as we aren't in interrupt context.
* am335x
- Fix wrong allocation size provided for private data to iio_device_alloc.
* bcm_iproc
- Swapped primary and secondary isr handlers.
* ltr501
- Fix swapped als/ps register fields when enabling interrupts
* max9611
- Wrong scale factor for the shunt_resistor attribute.
* sun4-gpadc
- Module autoloading fixes by adding the device table declarations.
- Fix parent device being used in devm functions.
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/adc/bcm_iproc_adc.c | 8 | ||||
-rw-r--r-- | drivers/iio/adc/max9611.c | 10 | ||||
-rw-r--r-- | drivers/iio/adc/sun4i-gpadc-iio.c | 38 | ||||
-rw-r--r-- | drivers/iio/adc/ti_am335x_adc.c | 2 | ||||
-rw-r--r-- | drivers/iio/industrialio-trigger.c | 3 | ||||
-rw-r--r-- | drivers/iio/light/ltr501.c | 4 | ||||
-rw-r--r-- | drivers/iio/proximity/as3935.c | 14 |
7 files changed, 44 insertions, 35 deletions
diff --git a/drivers/iio/adc/bcm_iproc_adc.c b/drivers/iio/adc/bcm_iproc_adc.c index 21d38c8af21e..7f4f9c4150e3 100644 --- a/drivers/iio/adc/bcm_iproc_adc.c +++ b/drivers/iio/adc/bcm_iproc_adc.c | |||
@@ -143,7 +143,7 @@ static void iproc_adc_reg_dump(struct iio_dev *indio_dev) | |||
143 | iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA); | 143 | iproc_adc_dbg_reg(dev, adc_priv, IPROC_SOFT_BYPASS_DATA); |
144 | } | 144 | } |
145 | 145 | ||
146 | static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data) | 146 | static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data) |
147 | { | 147 | { |
148 | u32 channel_intr_status; | 148 | u32 channel_intr_status; |
149 | u32 intr_status; | 149 | u32 intr_status; |
@@ -167,7 +167,7 @@ static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data) | |||
167 | return IRQ_NONE; | 167 | return IRQ_NONE; |
168 | } | 168 | } |
169 | 169 | ||
170 | static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data) | 170 | static irqreturn_t iproc_adc_interrupt_handler(int irq, void *data) |
171 | { | 171 | { |
172 | irqreturn_t retval = IRQ_NONE; | 172 | irqreturn_t retval = IRQ_NONE; |
173 | struct iproc_adc_priv *adc_priv; | 173 | struct iproc_adc_priv *adc_priv; |
@@ -181,7 +181,7 @@ static irqreturn_t iproc_adc_interrupt_thread(int irq, void *data) | |||
181 | adc_priv = iio_priv(indio_dev); | 181 | adc_priv = iio_priv(indio_dev); |
182 | 182 | ||
183 | regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, &intr_status); | 183 | regmap_read(adc_priv->regmap, IPROC_INTERRUPT_STATUS, &intr_status); |
184 | dev_dbg(&indio_dev->dev, "iproc_adc_interrupt_thread(),INTRPT_STS:%x\n", | 184 | dev_dbg(&indio_dev->dev, "iproc_adc_interrupt_handler(),INTRPT_STS:%x\n", |
185 | intr_status); | 185 | intr_status); |
186 | 186 | ||
187 | intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR; | 187 | intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR; |
@@ -566,8 +566,8 @@ static int iproc_adc_probe(struct platform_device *pdev) | |||
566 | } | 566 | } |
567 | 567 | ||
568 | ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno, | 568 | ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno, |
569 | iproc_adc_interrupt_thread, | ||
570 | iproc_adc_interrupt_handler, | 569 | iproc_adc_interrupt_handler, |
570 | iproc_adc_interrupt_thread, | ||
571 | IRQF_SHARED, "iproc-adc", indio_dev); | 571 | IRQF_SHARED, "iproc-adc", indio_dev); |
572 | if (ret) { | 572 | if (ret) { |
573 | dev_err(&pdev->dev, "request_irq error %d\n", ret); | 573 | dev_err(&pdev->dev, "request_irq error %d\n", ret); |
diff --git a/drivers/iio/adc/max9611.c b/drivers/iio/adc/max9611.c index ec82106480e1..b0526e4b9530 100644 --- a/drivers/iio/adc/max9611.c +++ b/drivers/iio/adc/max9611.c | |||
@@ -438,10 +438,10 @@ static ssize_t max9611_shunt_resistor_show(struct device *dev, | |||
438 | struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev)); | 438 | struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev)); |
439 | unsigned int i, r; | 439 | unsigned int i, r; |
440 | 440 | ||
441 | i = max9611->shunt_resistor_uohm / 1000; | 441 | i = max9611->shunt_resistor_uohm / 1000000; |
442 | r = max9611->shunt_resistor_uohm % 1000; | 442 | r = max9611->shunt_resistor_uohm % 1000000; |
443 | 443 | ||
444 | return sprintf(buf, "%u.%03u\n", i, r); | 444 | return sprintf(buf, "%u.%06u\n", i, r); |
445 | } | 445 | } |
446 | 446 | ||
447 | static IIO_DEVICE_ATTR(in_power_shunt_resistor, 0444, | 447 | static IIO_DEVICE_ATTR(in_power_shunt_resistor, 0444, |
@@ -536,8 +536,8 @@ static int max9611_probe(struct i2c_client *client, | |||
536 | int ret; | 536 | int ret; |
537 | 537 | ||
538 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611)); | 538 | indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611)); |
539 | if (IS_ERR(indio_dev)) | 539 | if (!indio_dev) |
540 | return PTR_ERR(indio_dev); | 540 | return -ENOMEM; |
541 | 541 | ||
542 | i2c_set_clientdata(client, indio_dev); | 542 | i2c_set_clientdata(client, indio_dev); |
543 | 543 | ||
diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c index b23527309088..81d4c39e414a 100644 --- a/drivers/iio/adc/sun4i-gpadc-iio.c +++ b/drivers/iio/adc/sun4i-gpadc-iio.c | |||
@@ -105,6 +105,8 @@ struct sun4i_gpadc_iio { | |||
105 | bool no_irq; | 105 | bool no_irq; |
106 | /* prevents concurrent reads of temperature and ADC */ | 106 | /* prevents concurrent reads of temperature and ADC */ |
107 | struct mutex mutex; | 107 | struct mutex mutex; |
108 | struct thermal_zone_device *tzd; | ||
109 | struct device *sensor_device; | ||
108 | }; | 110 | }; |
109 | 111 | ||
110 | #define SUN4I_GPADC_ADC_CHANNEL(_channel, _name) { \ | 112 | #define SUN4I_GPADC_ADC_CHANNEL(_channel, _name) { \ |
@@ -502,7 +504,6 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, | |||
502 | { | 504 | { |
503 | struct sun4i_gpadc_iio *info = iio_priv(indio_dev); | 505 | struct sun4i_gpadc_iio *info = iio_priv(indio_dev); |
504 | const struct of_device_id *of_dev; | 506 | const struct of_device_id *of_dev; |
505 | struct thermal_zone_device *tzd; | ||
506 | struct resource *mem; | 507 | struct resource *mem; |
507 | void __iomem *base; | 508 | void __iomem *base; |
508 | int ret; | 509 | int ret; |
@@ -532,13 +533,14 @@ static int sun4i_gpadc_probe_dt(struct platform_device *pdev, | |||
532 | if (!IS_ENABLED(CONFIG_THERMAL_OF)) | 533 | if (!IS_ENABLED(CONFIG_THERMAL_OF)) |
533 | return 0; | 534 | return 0; |
534 | 535 | ||
535 | tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info, | 536 | info->sensor_device = &pdev->dev; |
536 | &sun4i_ts_tz_ops); | 537 | info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0, |
537 | if (IS_ERR(tzd)) | 538 | info, &sun4i_ts_tz_ops); |
539 | if (IS_ERR(info->tzd)) | ||
538 | dev_err(&pdev->dev, "could not register thermal sensor: %ld\n", | 540 | dev_err(&pdev->dev, "could not register thermal sensor: %ld\n", |
539 | PTR_ERR(tzd)); | 541 | PTR_ERR(info->tzd)); |
540 | 542 | ||
541 | return PTR_ERR_OR_ZERO(tzd); | 543 | return PTR_ERR_OR_ZERO(info->tzd); |
542 | } | 544 | } |
543 | 545 | ||
544 | static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, | 546 | static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, |
@@ -584,15 +586,15 @@ static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, | |||
584 | * of_node, and the device from this driver as third argument to | 586 | * of_node, and the device from this driver as third argument to |
585 | * return the temperature. | 587 | * return the temperature. |
586 | */ | 588 | */ |
587 | struct thermal_zone_device *tzd; | 589 | info->sensor_device = pdev->dev.parent; |
588 | tzd = devm_thermal_zone_of_sensor_register(pdev->dev.parent, 0, | 590 | info->tzd = thermal_zone_of_sensor_register(info->sensor_device, |
589 | info, | 591 | 0, info, |
590 | &sun4i_ts_tz_ops); | 592 | &sun4i_ts_tz_ops); |
591 | if (IS_ERR(tzd)) { | 593 | if (IS_ERR(info->tzd)) { |
592 | dev_err(&pdev->dev, | 594 | dev_err(&pdev->dev, |
593 | "could not register thermal sensor: %ld\n", | 595 | "could not register thermal sensor: %ld\n", |
594 | PTR_ERR(tzd)); | 596 | PTR_ERR(info->tzd)); |
595 | return PTR_ERR(tzd); | 597 | return PTR_ERR(info->tzd); |
596 | } | 598 | } |
597 | } else { | 599 | } else { |
598 | indio_dev->num_channels = | 600 | indio_dev->num_channels = |
@@ -688,7 +690,13 @@ static int sun4i_gpadc_remove(struct platform_device *pdev) | |||
688 | 690 | ||
689 | pm_runtime_put(&pdev->dev); | 691 | pm_runtime_put(&pdev->dev); |
690 | pm_runtime_disable(&pdev->dev); | 692 | pm_runtime_disable(&pdev->dev); |
691 | if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF)) | 693 | |
694 | if (!IS_ENABLED(CONFIG_THERMAL_OF)) | ||
695 | return 0; | ||
696 | |||
697 | thermal_zone_of_sensor_unregister(info->sensor_device, info->tzd); | ||
698 | |||
699 | if (!info->no_irq) | ||
692 | iio_map_array_unregister(indio_dev); | 700 | iio_map_array_unregister(indio_dev); |
693 | 701 | ||
694 | return 0; | 702 | return 0; |
@@ -700,6 +708,7 @@ static const struct platform_device_id sun4i_gpadc_id[] = { | |||
700 | { "sun6i-a31-gpadc-iio", (kernel_ulong_t)&sun6i_gpadc_data }, | 708 | { "sun6i-a31-gpadc-iio", (kernel_ulong_t)&sun6i_gpadc_data }, |
701 | { /* sentinel */ }, | 709 | { /* sentinel */ }, |
702 | }; | 710 | }; |
711 | MODULE_DEVICE_TABLE(platform, sun4i_gpadc_id); | ||
703 | 712 | ||
704 | static struct platform_driver sun4i_gpadc_driver = { | 713 | static struct platform_driver sun4i_gpadc_driver = { |
705 | .driver = { | 714 | .driver = { |
@@ -711,6 +720,7 @@ static struct platform_driver sun4i_gpadc_driver = { | |||
711 | .probe = sun4i_gpadc_probe, | 720 | .probe = sun4i_gpadc_probe, |
712 | .remove = sun4i_gpadc_remove, | 721 | .remove = sun4i_gpadc_remove, |
713 | }; | 722 | }; |
723 | MODULE_DEVICE_TABLE(of, sun4i_gpadc_of_id); | ||
714 | 724 | ||
715 | module_platform_driver(sun4i_gpadc_driver); | 725 | module_platform_driver(sun4i_gpadc_driver); |
716 | 726 | ||
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index 4282ceca3d8f..6cbed7eb118a 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
@@ -614,7 +614,7 @@ static int tiadc_probe(struct platform_device *pdev) | |||
614 | return -EINVAL; | 614 | return -EINVAL; |
615 | } | 615 | } |
616 | 616 | ||
617 | indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*indio_dev)); | 617 | indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev)); |
618 | if (indio_dev == NULL) { | 618 | if (indio_dev == NULL) { |
619 | dev_err(&pdev->dev, "failed to allocate iio device\n"); | 619 | dev_err(&pdev->dev, "failed to allocate iio device\n"); |
620 | return -ENOMEM; | 620 | return -ENOMEM; |
diff --git a/drivers/iio/industrialio-trigger.c b/drivers/iio/industrialio-trigger.c index 978e1592c2a3..4061fed93f1f 100644 --- a/drivers/iio/industrialio-trigger.c +++ b/drivers/iio/industrialio-trigger.c | |||
@@ -451,7 +451,8 @@ static ssize_t iio_trigger_write_current(struct device *dev, | |||
451 | return len; | 451 | return len; |
452 | 452 | ||
453 | out_trigger_put: | 453 | out_trigger_put: |
454 | iio_trigger_put(trig); | 454 | if (trig) |
455 | iio_trigger_put(trig); | ||
455 | return ret; | 456 | return ret; |
456 | } | 457 | } |
457 | 458 | ||
diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c index b30e0c1c6cc4..67838edd8b37 100644 --- a/drivers/iio/light/ltr501.c +++ b/drivers/iio/light/ltr501.c | |||
@@ -74,9 +74,9 @@ static const int int_time_mapping[] = {100000, 50000, 200000, 400000}; | |||
74 | static const struct reg_field reg_field_it = | 74 | static const struct reg_field reg_field_it = |
75 | REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4); | 75 | REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4); |
76 | static const struct reg_field reg_field_als_intr = | 76 | static const struct reg_field reg_field_als_intr = |
77 | REG_FIELD(LTR501_INTR, 0, 0); | ||
78 | static const struct reg_field reg_field_ps_intr = | ||
79 | REG_FIELD(LTR501_INTR, 1, 1); | 77 | REG_FIELD(LTR501_INTR, 1, 1); |
78 | static const struct reg_field reg_field_ps_intr = | ||
79 | REG_FIELD(LTR501_INTR, 0, 0); | ||
80 | static const struct reg_field reg_field_als_rate = | 80 | static const struct reg_field reg_field_als_rate = |
81 | REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2); | 81 | REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2); |
82 | static const struct reg_field reg_field_ps_rate = | 82 | static const struct reg_field reg_field_ps_rate = |
diff --git a/drivers/iio/proximity/as3935.c b/drivers/iio/proximity/as3935.c index ddf9bee89f77..aa4df0dcc8c9 100644 --- a/drivers/iio/proximity/as3935.c +++ b/drivers/iio/proximity/as3935.c | |||
@@ -40,9 +40,9 @@ | |||
40 | #define AS3935_AFE_PWR_BIT BIT(0) | 40 | #define AS3935_AFE_PWR_BIT BIT(0) |
41 | 41 | ||
42 | #define AS3935_INT 0x03 | 42 | #define AS3935_INT 0x03 |
43 | #define AS3935_INT_MASK 0x07 | 43 | #define AS3935_INT_MASK 0x0f |
44 | #define AS3935_EVENT_INT BIT(3) | 44 | #define AS3935_EVENT_INT BIT(3) |
45 | #define AS3935_NOISE_INT BIT(1) | 45 | #define AS3935_NOISE_INT BIT(0) |
46 | 46 | ||
47 | #define AS3935_DATA 0x07 | 47 | #define AS3935_DATA 0x07 |
48 | #define AS3935_DATA_MASK 0x3F | 48 | #define AS3935_DATA_MASK 0x3F |
@@ -215,7 +215,7 @@ static irqreturn_t as3935_trigger_handler(int irq, void *private) | |||
215 | 215 | ||
216 | st->buffer[0] = val & AS3935_DATA_MASK; | 216 | st->buffer[0] = val & AS3935_DATA_MASK; |
217 | iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer, | 217 | iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer, |
218 | pf->timestamp); | 218 | iio_get_time_ns(indio_dev)); |
219 | err_read: | 219 | err_read: |
220 | iio_trigger_notify_done(indio_dev->trig); | 220 | iio_trigger_notify_done(indio_dev->trig); |
221 | 221 | ||
@@ -244,7 +244,7 @@ static void as3935_event_work(struct work_struct *work) | |||
244 | 244 | ||
245 | switch (val) { | 245 | switch (val) { |
246 | case AS3935_EVENT_INT: | 246 | case AS3935_EVENT_INT: |
247 | iio_trigger_poll(st->trig); | 247 | iio_trigger_poll_chained(st->trig); |
248 | break; | 248 | break; |
249 | case AS3935_NOISE_INT: | 249 | case AS3935_NOISE_INT: |
250 | dev_warn(&st->spi->dev, "noise level is too high\n"); | 250 | dev_warn(&st->spi->dev, "noise level is too high\n"); |
@@ -269,8 +269,6 @@ static irqreturn_t as3935_interrupt_handler(int irq, void *private) | |||
269 | 269 | ||
270 | static void calibrate_as3935(struct as3935_state *st) | 270 | static void calibrate_as3935(struct as3935_state *st) |
271 | { | 271 | { |
272 | mutex_lock(&st->lock); | ||
273 | |||
274 | /* mask disturber interrupt bit */ | 272 | /* mask disturber interrupt bit */ |
275 | as3935_write(st, AS3935_INT, BIT(5)); | 273 | as3935_write(st, AS3935_INT, BIT(5)); |
276 | 274 | ||
@@ -280,8 +278,6 @@ static void calibrate_as3935(struct as3935_state *st) | |||
280 | 278 | ||
281 | mdelay(2); | 279 | mdelay(2); |
282 | as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); | 280 | as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); |
283 | |||
284 | mutex_unlock(&st->lock); | ||
285 | } | 281 | } |
286 | 282 | ||
287 | #ifdef CONFIG_PM_SLEEP | 283 | #ifdef CONFIG_PM_SLEEP |
@@ -318,6 +314,8 @@ static int as3935_resume(struct device *dev) | |||
318 | val &= ~AS3935_AFE_PWR_BIT; | 314 | val &= ~AS3935_AFE_PWR_BIT; |
319 | ret = as3935_write(st, AS3935_AFE_GAIN, val); | 315 | ret = as3935_write(st, AS3935_AFE_GAIN, val); |
320 | 316 | ||
317 | calibrate_as3935(st); | ||
318 | |||
321 | err_resume: | 319 | err_resume: |
322 | mutex_unlock(&st->lock); | 320 | mutex_unlock(&st->lock); |
323 | 321 | ||