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

Configure Feed

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

Merge tag 'staging-4.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging and IIO fixes from Greg KH:
"Here are a small number of patches to resolve some reported IIO and a
staging driver problem. Nothing major here, full details are in the
shortlog below.

All have been in linux-next with no reported issues"

* tag 'staging-4.14-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
staging: bcm2835-audio: Fix memory corruption
iio: adc: at91-sama5d2_adc: fix probe error on missing trigger property
iio: adc: dln2-adc: fix build error
iio: dummy: events: Add missing break
staging: iio: ade7759: fix signed extension bug on shift of a u8
iio: pressure: zpa2326: Remove always-true check which confuses gcc
iio: proximity: as3935: noise detection + threshold changes

+96 -39
+8
Documentation/ABI/testing/sysfs-bus-iio-proximity-as3935
··· 14 14 Show or set the gain boost of the amp, from 0-31 range. 15 15 18 = indoors (default) 16 16 14 = outdoors 17 + 18 + What /sys/bus/iio/devices/iio:deviceX/noise_level_tripped 19 + Date: May 2017 20 + KernelVersion: 4.13 21 + Contact: Matt Ranostay <matt.ranostay@konsulko.com> 22 + Description: 23 + When 1 the noise level is over the trip level and not reporting 24 + valid data
+5
Documentation/devicetree/bindings/iio/proximity/as3935.txt
··· 16 16 - ams,tuning-capacitor-pf: Calibration tuning capacitor stepping 17 17 value 0 - 120pF. This will require using the calibration data from 18 18 the manufacturer. 19 + - ams,nflwdth: Set the noise and watchdog threshold register on 20 + startup. This will need to set according to the noise from the 21 + MCU board, and possibly the local environment. Refer to the 22 + datasheet for the threshold settings. 19 23 20 24 Example: 21 25 ··· 31 27 interrupt-parent = <&gpio1>; 32 28 interrupts = <16 1>; 33 29 ams,tuning-capacitor-pf = <80>; 30 + ams,nflwdth = <0x44>; 34 31 };
+2
drivers/iio/adc/Kconfig
··· 243 243 config DLN2_ADC 244 244 tristate "Diolan DLN-2 ADC driver support" 245 245 depends on MFD_DLN2 246 + select IIO_BUFFER 247 + select IIO_TRIGGERED_BUFFER 246 248 help 247 249 Say yes here to build support for Diolan DLN-2 ADC. 248 250
+29 -16
drivers/iio/adc/at91-sama5d2_adc.c
··· 225 225 char *name; 226 226 unsigned int trgmod_value; 227 227 unsigned int edge_type; 228 + bool hw_trig; 228 229 }; 229 230 230 231 struct at91_adc_state { ··· 255 254 .name = "external_rising", 256 255 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_RISE, 257 256 .edge_type = IRQ_TYPE_EDGE_RISING, 257 + .hw_trig = true, 258 258 }, 259 259 { 260 260 .name = "external_falling", 261 261 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_FALL, 262 262 .edge_type = IRQ_TYPE_EDGE_FALLING, 263 + .hw_trig = true, 263 264 }, 264 265 { 265 266 .name = "external_any", 266 267 .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_EXT_TRIG_ANY, 267 268 .edge_type = IRQ_TYPE_EDGE_BOTH, 269 + .hw_trig = true, 270 + }, 271 + { 272 + .name = "software", 273 + .trgmod_value = AT91_SAMA5D2_TRGR_TRGMOD_NO_TRIGGER, 274 + .edge_type = IRQ_TYPE_NONE, 275 + .hw_trig = false, 268 276 }, 269 277 }; 270 278 ··· 607 597 struct at91_adc_state *st; 608 598 struct resource *res; 609 599 int ret, i; 610 - u32 edge_type; 600 + u32 edge_type = IRQ_TYPE_NONE; 611 601 612 602 indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*st)); 613 603 if (!indio_dev) ··· 651 641 ret = of_property_read_u32(pdev->dev.of_node, 652 642 "atmel,trigger-edge-type", &edge_type); 653 643 if (ret) { 654 - dev_err(&pdev->dev, 655 - "invalid or missing value for atmel,trigger-edge-type\n"); 656 - return ret; 644 + dev_dbg(&pdev->dev, 645 + "atmel,trigger-edge-type not specified, only software trigger available\n"); 657 646 } 658 647 659 648 st->selected_trig = NULL; 660 649 661 - for (i = 0; i < AT91_SAMA5D2_HW_TRIG_CNT; i++) 650 + /* find the right trigger, or no trigger at all */ 651 + for (i = 0; i < AT91_SAMA5D2_HW_TRIG_CNT + 1; i++) 662 652 if (at91_adc_trigger_list[i].edge_type == edge_type) { 663 653 st->selected_trig = &at91_adc_trigger_list[i]; 664 654 break; ··· 727 717 728 718 platform_set_drvdata(pdev, indio_dev); 729 719 730 - ret = at91_adc_buffer_init(indio_dev); 731 - if (ret < 0) { 732 - dev_err(&pdev->dev, "couldn't initialize the buffer.\n"); 733 - goto per_clk_disable_unprepare; 734 - } 720 + if (st->selected_trig->hw_trig) { 721 + ret = at91_adc_buffer_init(indio_dev); 722 + if (ret < 0) { 723 + dev_err(&pdev->dev, "couldn't initialize the buffer.\n"); 724 + goto per_clk_disable_unprepare; 725 + } 735 726 736 - ret = at91_adc_trigger_init(indio_dev); 737 - if (ret < 0) { 738 - dev_err(&pdev->dev, "couldn't setup the triggers.\n"); 739 - goto per_clk_disable_unprepare; 727 + ret = at91_adc_trigger_init(indio_dev); 728 + if (ret < 0) { 729 + dev_err(&pdev->dev, "couldn't setup the triggers.\n"); 730 + goto per_clk_disable_unprepare; 731 + } 740 732 } 741 733 742 734 ret = iio_device_register(indio_dev); 743 735 if (ret < 0) 744 736 goto per_clk_disable_unprepare; 745 737 746 - dev_info(&pdev->dev, "setting up trigger as %s\n", 747 - st->selected_trig->name); 738 + if (st->selected_trig->hw_trig) 739 + dev_info(&pdev->dev, "setting up trigger as %s\n", 740 + st->selected_trig->name); 748 741 749 742 dev_info(&pdev->dev, "version: %x\n", 750 743 readl_relaxed(st->base + AT91_SAMA5D2_VERSION));
+1
drivers/iio/dummy/iio_simple_dummy_events.c
··· 72 72 st->event_en = state; 73 73 else 74 74 return -EINVAL; 75 + break; 75 76 default: 76 77 return -EINVAL; 77 78 }
+3 -7
drivers/iio/pressure/zpa2326.c
··· 865 865 static int zpa2326_wait_oneshot_completion(const struct iio_dev *indio_dev, 866 866 struct zpa2326_private *private) 867 867 { 868 - int ret; 869 868 unsigned int val; 870 869 long timeout; 871 870 ··· 886 887 /* Timed out. */ 887 888 zpa2326_warn(indio_dev, "no one shot interrupt occurred (%ld)", 888 889 timeout); 889 - ret = -ETIME; 890 - } else if (timeout < 0) { 891 - zpa2326_warn(indio_dev, 892 - "wait for one shot interrupt cancelled"); 893 - ret = -ERESTARTSYS; 890 + return -ETIME; 894 891 } 895 892 896 - return ret; 893 + zpa2326_warn(indio_dev, "wait for one shot interrupt cancelled"); 894 + return -ERESTARTSYS; 897 895 } 898 896 899 897 static int zpa2326_init_managed_irq(struct device *parent,
+40 -3
drivers/iio/proximity/as3935.c
··· 39 39 #define AS3935_AFE_GAIN_MAX 0x1F 40 40 #define AS3935_AFE_PWR_BIT BIT(0) 41 41 42 + #define AS3935_NFLWDTH 0x01 43 + #define AS3935_NFLWDTH_MASK 0x7f 44 + 42 45 #define AS3935_INT 0x03 43 46 #define AS3935_INT_MASK 0x0f 47 + #define AS3935_DISTURB_INT BIT(2) 44 48 #define AS3935_EVENT_INT BIT(3) 45 49 #define AS3935_NOISE_INT BIT(0) 46 50 ··· 52 48 #define AS3935_DATA_MASK 0x3F 53 49 54 50 #define AS3935_TUNE_CAP 0x08 51 + #define AS3935_DEFAULTS 0x3C 55 52 #define AS3935_CALIBRATE 0x3D 56 53 57 54 #define AS3935_READ_DATA BIT(14) ··· 67 62 struct mutex lock; 68 63 struct delayed_work work; 69 64 65 + unsigned long noise_tripped; 70 66 u32 tune_cap; 67 + u32 nflwdth_reg; 71 68 u8 buffer[16]; /* 8-bit data + 56-bit padding + 64-bit timestamp */ 72 69 u8 buf[2] ____cacheline_aligned; 73 70 }; ··· 152 145 return len; 153 146 } 154 147 148 + static ssize_t as3935_noise_level_tripped_show(struct device *dev, 149 + struct device_attribute *attr, 150 + char *buf) 151 + { 152 + struct as3935_state *st = iio_priv(dev_to_iio_dev(dev)); 153 + int ret; 154 + 155 + mutex_lock(&st->lock); 156 + ret = sprintf(buf, "%d\n", !time_after(jiffies, st->noise_tripped + HZ)); 157 + mutex_unlock(&st->lock); 158 + 159 + return ret; 160 + } 161 + 155 162 static IIO_DEVICE_ATTR(sensor_sensitivity, S_IRUGO | S_IWUSR, 156 163 as3935_sensor_sensitivity_show, as3935_sensor_sensitivity_store, 0); 157 164 165 + static IIO_DEVICE_ATTR(noise_level_tripped, S_IRUGO, 166 + as3935_noise_level_tripped_show, NULL, 0); 158 167 159 168 static struct attribute *as3935_attributes[] = { 160 169 &iio_dev_attr_sensor_sensitivity.dev_attr.attr, 170 + &iio_dev_attr_noise_level_tripped.dev_attr.attr, 161 171 NULL, 162 172 }; 163 173 ··· 270 246 case AS3935_EVENT_INT: 271 247 iio_trigger_poll_chained(st->trig); 272 248 break; 249 + case AS3935_DISTURB_INT: 273 250 case AS3935_NOISE_INT: 251 + mutex_lock(&st->lock); 252 + st->noise_tripped = jiffies; 253 + mutex_unlock(&st->lock); 274 254 dev_warn(&st->spi->dev, "noise level is too high\n"); 275 255 break; 276 256 } ··· 297 269 298 270 static void calibrate_as3935(struct as3935_state *st) 299 271 { 300 - /* mask disturber interrupt bit */ 301 - as3935_write(st, AS3935_INT, BIT(5)); 302 - 272 + as3935_write(st, AS3935_DEFAULTS, 0x96); 303 273 as3935_write(st, AS3935_CALIBRATE, 0x96); 304 274 as3935_write(st, AS3935_TUNE_CAP, 305 275 BIT(5) | (st->tune_cap / TUNE_CAP_DIV)); 306 276 307 277 mdelay(2); 308 278 as3935_write(st, AS3935_TUNE_CAP, (st->tune_cap / TUNE_CAP_DIV)); 279 + as3935_write(st, AS3935_NFLWDTH, st->nflwdth_reg); 309 280 } 310 281 311 282 #ifdef CONFIG_PM_SLEEP ··· 397 370 return -EINVAL; 398 371 } 399 372 373 + ret = of_property_read_u32(np, 374 + "ams,nflwdth", &st->nflwdth_reg); 375 + if (!ret && st->nflwdth_reg > AS3935_NFLWDTH_MASK) { 376 + dev_err(&spi->dev, 377 + "invalid nflwdth setting of %d\n", 378 + st->nflwdth_reg); 379 + return -EINVAL; 380 + } 381 + 400 382 indio_dev->dev.parent = &spi->dev; 401 383 indio_dev->name = spi_get_device_id(spi)->name; 402 384 indio_dev->channels = as3935_channels; ··· 420 384 return -ENOMEM; 421 385 422 386 st->trig = trig; 387 + st->noise_tripped = jiffies - HZ; 423 388 trig->dev.parent = indio_dev->dev.parent; 424 389 iio_trigger_set_drvdata(trig, indio_dev); 425 390 trig->ops = &iio_interrupt_trigger_ops;
+1 -1
drivers/staging/iio/meter/ade7759.c
··· 172 172 reg_address); 173 173 goto error_ret; 174 174 } 175 - *val = ((u64)st->rx[1] << 32) | (st->rx[2] << 24) | 175 + *val = ((u64)st->rx[1] << 32) | ((u64)st->rx[2] << 24) | 176 176 (st->rx[3] << 16) | (st->rx[4] << 8) | st->rx[5]; 177 177 178 178 error_ret:
+7 -12
drivers/staging/vc04_services/bcm2835-audio/bcm2835-vchiq.c
··· 390 390 __func__, instance); 391 391 instance->alsa_stream = alsa_stream; 392 392 alsa_stream->instance = instance; 393 - ret = 0; // xxx todo -1; 394 - goto err_free_mem; 393 + return 0; 395 394 } 396 395 397 396 /* Initialize and create a VCHI connection */ ··· 400 401 LOG_ERR("%s: failed to initialise VCHI instance (ret=%d)\n", 401 402 __func__, ret); 402 403 403 - ret = -EIO; 404 - goto err_free_mem; 404 + return -EIO; 405 405 } 406 406 ret = vchi_connect(NULL, 0, vchi_instance); 407 407 if (ret) { 408 408 LOG_ERR("%s: failed to connect VCHI instance (ret=%d)\n", 409 409 __func__, ret); 410 410 411 - ret = -EIO; 412 - goto err_free_mem; 411 + kfree(vchi_instance); 412 + return -EIO; 413 413 } 414 414 initted = 1; 415 415 } ··· 419 421 if (IS_ERR(instance)) { 420 422 LOG_ERR("%s: failed to initialize audio service\n", __func__); 421 423 422 - ret = PTR_ERR(instance); 423 - goto err_free_mem; 424 + /* vchi_instance is retained for use the next time. */ 425 + return PTR_ERR(instance); 424 426 } 425 427 426 428 instance->alsa_stream = alsa_stream; 427 429 alsa_stream->instance = instance; 428 430 429 431 LOG_DBG(" success !\n"); 430 - ret = 0; 431 - err_free_mem: 432 - kfree(vchi_instance); 433 432 434 - return ret; 433 + return 0; 435 434 } 436 435 437 436 int bcm2835_audio_open(struct bcm2835_alsa_stream *alsa_stream)