Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

+44 -35
+4 -4
drivers/iio/adc/bcm_iproc_adc.c
··· 143 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 148 u32 channel_intr_status; 149 149 u32 intr_status; ··· 167 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 172 irqreturn_t retval = IRQ_NONE; 173 173 struct iproc_adc_priv *adc_priv; ··· 181 181 adc_priv = iio_priv(indio_dev); 182 182 183 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 185 intr_status); 186 186 187 187 intr_channels = (intr_status & IPROC_ADC_INTR_MASK) >> IPROC_ADC_INTR; ··· 566 566 } 567 567 568 568 ret = devm_request_threaded_irq(&pdev->dev, adc_priv->irqno, 569 - iproc_adc_interrupt_thread, 570 569 iproc_adc_interrupt_handler, 570 + iproc_adc_interrupt_thread, 571 571 IRQF_SHARED, "iproc-adc", indio_dev); 572 572 if (ret) { 573 573 dev_err(&pdev->dev, "request_irq error %d\n", ret);
+5 -5
drivers/iio/adc/max9611.c
··· 438 438 struct max9611_dev *max9611 = iio_priv(dev_to_iio_dev(dev)); 439 439 unsigned int i, r; 440 440 441 - i = max9611->shunt_resistor_uohm / 1000; 442 - r = max9611->shunt_resistor_uohm % 1000; 441 + i = max9611->shunt_resistor_uohm / 1000000; 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 447 static IIO_DEVICE_ATTR(in_power_shunt_resistor, 0444, ··· 536 536 int ret; 537 537 538 538 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*max9611)); 539 - if (IS_ERR(indio_dev)) 540 - return PTR_ERR(indio_dev); 539 + if (!indio_dev) 540 + return -ENOMEM; 541 541 542 542 i2c_set_clientdata(client, indio_dev); 543 543
+24 -14
drivers/iio/adc/sun4i-gpadc-iio.c
··· 105 105 bool no_irq; 106 106 /* prevents concurrent reads of temperature and ADC */ 107 107 struct mutex mutex; 108 + struct thermal_zone_device *tzd; 109 + struct device *sensor_device; 108 110 }; 109 111 110 112 #define SUN4I_GPADC_ADC_CHANNEL(_channel, _name) { \ ··· 504 502 { 505 503 struct sun4i_gpadc_iio *info = iio_priv(indio_dev); 506 504 const struct of_device_id *of_dev; 507 - struct thermal_zone_device *tzd; 508 505 struct resource *mem; 509 506 void __iomem *base; 510 507 int ret; ··· 533 532 if (!IS_ENABLED(CONFIG_THERMAL_OF)) 534 533 return 0; 535 534 536 - tzd = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, info, 537 - &sun4i_ts_tz_ops); 538 - if (IS_ERR(tzd)) 535 + info->sensor_device = &pdev->dev; 536 + info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 0, 537 + info, &sun4i_ts_tz_ops); 538 + if (IS_ERR(info->tzd)) 539 539 dev_err(&pdev->dev, "could not register thermal sensor: %ld\n", 540 - PTR_ERR(tzd)); 540 + PTR_ERR(info->tzd)); 541 541 542 - return PTR_ERR_OR_ZERO(tzd); 542 + return PTR_ERR_OR_ZERO(info->tzd); 543 543 } 544 544 545 545 static int sun4i_gpadc_probe_mfd(struct platform_device *pdev, ··· 586 584 * of_node, and the device from this driver as third argument to 587 585 * return the temperature. 588 586 */ 589 - struct thermal_zone_device *tzd; 590 - tzd = devm_thermal_zone_of_sensor_register(pdev->dev.parent, 0, 591 - info, 592 - &sun4i_ts_tz_ops); 593 - if (IS_ERR(tzd)) { 587 + info->sensor_device = pdev->dev.parent; 588 + info->tzd = thermal_zone_of_sensor_register(info->sensor_device, 589 + 0, info, 590 + &sun4i_ts_tz_ops); 591 + if (IS_ERR(info->tzd)) { 594 592 dev_err(&pdev->dev, 595 593 "could not register thermal sensor: %ld\n", 596 - PTR_ERR(tzd)); 597 - return PTR_ERR(tzd); 594 + PTR_ERR(info->tzd)); 595 + return PTR_ERR(info->tzd); 598 596 } 599 597 } else { 600 598 indio_dev->num_channels = ··· 690 688 691 689 pm_runtime_put(&pdev->dev); 692 690 pm_runtime_disable(&pdev->dev); 693 - if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF)) 691 + 692 + if (!IS_ENABLED(CONFIG_THERMAL_OF)) 693 + return 0; 694 + 695 + thermal_zone_of_sensor_unregister(info->sensor_device, info->tzd); 696 + 697 + if (!info->no_irq) 694 698 iio_map_array_unregister(indio_dev); 695 699 696 700 return 0; ··· 708 700 { "sun6i-a31-gpadc-iio", (kernel_ulong_t)&sun6i_gpadc_data }, 709 701 { /* sentinel */ }, 710 702 }; 703 + MODULE_DEVICE_TABLE(platform, sun4i_gpadc_id); 711 704 712 705 static struct platform_driver sun4i_gpadc_driver = { 713 706 .driver = { ··· 720 711 .probe = sun4i_gpadc_probe, 721 712 .remove = sun4i_gpadc_remove, 722 713 }; 714 + MODULE_DEVICE_TABLE(of, sun4i_gpadc_of_id); 723 715 724 716 module_platform_driver(sun4i_gpadc_driver); 725 717
+1 -1
drivers/iio/adc/ti_am335x_adc.c
··· 614 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 618 if (indio_dev == NULL) { 619 619 dev_err(&pdev->dev, "failed to allocate iio device\n"); 620 620 return -ENOMEM;
+2 -1
drivers/iio/industrialio-trigger.c
··· 451 451 return len; 452 452 453 453 out_trigger_put: 454 - iio_trigger_put(trig); 454 + if (trig) 455 + iio_trigger_put(trig); 455 456 return ret; 456 457 } 457 458
+2 -2
drivers/iio/light/ltr501.c
··· 74 74 static const struct reg_field reg_field_it = 75 75 REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4); 76 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 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 80 static const struct reg_field reg_field_als_rate = 81 81 REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2); 82 82 static const struct reg_field reg_field_ps_rate =
+6 -8
drivers/iio/proximity/as3935.c
··· 40 40 #define AS3935_AFE_PWR_BIT BIT(0) 41 41 42 42 #define AS3935_INT 0x03 43 - #define AS3935_INT_MASK 0x07 43 + #define AS3935_INT_MASK 0x0f 44 44 #define AS3935_EVENT_INT BIT(3) 45 - #define AS3935_NOISE_INT BIT(1) 45 + #define AS3935_NOISE_INT BIT(0) 46 46 47 47 #define AS3935_DATA 0x07 48 48 #define AS3935_DATA_MASK 0x3F ··· 215 215 216 216 st->buffer[0] = val & AS3935_DATA_MASK; 217 217 iio_push_to_buffers_with_timestamp(indio_dev, &st->buffer, 218 - pf->timestamp); 218 + iio_get_time_ns(indio_dev)); 219 219 err_read: 220 220 iio_trigger_notify_done(indio_dev->trig); 221 221 ··· 244 244 245 245 switch (val) { 246 246 case AS3935_EVENT_INT: 247 - iio_trigger_poll(st->trig); 247 + iio_trigger_poll_chained(st->trig); 248 248 break; 249 249 case AS3935_NOISE_INT: 250 250 dev_warn(&st->spi->dev, "noise level is too high\n"); ··· 269 269 270 270 static void calibrate_as3935(struct as3935_state *st) 271 271 { 272 - mutex_lock(&st->lock); 273 - 274 272 /* mask disturber interrupt bit */ 275 273 as3935_write(st, AS3935_INT, BIT(5)); 276 274 ··· 278 280 279 281 mdelay(2); 280 282 as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); 281 - 282 - mutex_unlock(&st->lock); 283 283 } 284 284 285 285 #ifdef CONFIG_PM_SLEEP ··· 313 317 goto err_resume; 314 318 val &= ~AS3935_AFE_PWR_BIT; 315 319 ret = as3935_write(st, AS3935_AFE_GAIN, val); 320 + 321 + calibrate_as3935(st); 316 322 317 323 err_resume: 318 324 mutex_unlock(&st->lock);