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 'char-misc-6.18-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc

Pull char / misc / IIO fixes from Greg KH:
"Here are some much-delayed char/misc/iio driver fixes for 6.18-rc8.

Fixes in here include:

- lots of iio driver bugfixes for reported issues.

- counter driver bugfix

- slimbus driver bugfix

- mei tiny bugfix

- nvmem layout uevent bugfix

All of these have been in linux-next for a while, but due to travel on
my side, I haven't had a chance to get them to you"

* tag 'char-misc-6.18-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (23 commits)
nvmem: layouts: fix nvmem_layout_bus_uevent
iio: accel: bmc150: Fix irq assumption regression
most: usb: fix double free on late probe failure
slimbus: ngd: Fix reference count leak in qcom_slim_ngd_notify_slaves
firmware: stratix10-svc: fix bug in saving controller data
mei: fix error flow in probe
iio: st_lsm6dsx: Fixed calibrated timestamp calculation
iio: humditiy: hdc3020: fix units for thresholds and hysteresis
iio: humditiy: hdc3020: fix units for temperature and humidity measurement
iio: imu: st_lsm6dsx: fix array size for st_lsm6dsx_settings fields
iio: accel: fix ADXL355 startup race condition
iio: adc: ad7124: fix temperature channel
iio:common:ssp_sensors: Fix an error handling path ssp_probe()
iio: adc: ad7280a: fix ad7280_store_balance_timer()
iio: buffer-dmaengine: enable .get_dma_dev()
iio: buffer-dma: support getting the DMA channel
iio: buffer: support getting dma channel from the buffer
iio: pressure: bmp280: correct meas_time_us calculation
iio: adc: stm32-dfsdm: fix st,adc-alt-channel property handling
iio: adc: ad7380: fix SPI offload trigger rate
...

+214 -113
+1 -1
drivers/counter/microchip-tcb-capture.c
··· 451 451 static int mchp_tc_irq_enable(struct counter_device *const counter, int irq) 452 452 { 453 453 struct mchp_tc_data *const priv = counter_priv(counter); 454 - int ret = devm_request_irq(counter->parent, irq, mchp_tc_isr, 0, 454 + int ret = devm_request_irq(counter->parent, irq, mchp_tc_isr, IRQF_SHARED, 455 455 dev_name(counter->parent), counter); 456 456 457 457 if (ret < 0)
+4 -3
drivers/firmware/stratix10-svc.c
··· 134 134 * @complete_status: state for completion 135 135 * @svc_fifo_lock: protect access to service message data queue 136 136 * @invoke_fn: function to issue secure monitor call or hypervisor call 137 + * @svc: manages the list of client svc drivers 137 138 * 138 139 * This struct is used to create communication channels for service clients, to 139 140 * handle secure monitor or hypervisor call. ··· 151 150 struct completion complete_status; 152 151 spinlock_t svc_fifo_lock; 153 152 svc_invoke_fn *invoke_fn; 153 + struct stratix10_svc *svc; 154 154 }; 155 155 156 156 /** ··· 1208 1206 ret = -ENOMEM; 1209 1207 goto err_free_kfifo; 1210 1208 } 1209 + controller->svc = svc; 1211 1210 1212 1211 svc->stratix10_svc_rsu = platform_device_alloc(STRATIX10_RSU, 0); 1213 1212 if (!svc->stratix10_svc_rsu) { ··· 1240 1237 if (ret) 1241 1238 goto err_unregister_fcs_dev; 1242 1239 1243 - dev_set_drvdata(dev, svc); 1244 - 1245 1240 pr_info("Intel Service Layer Driver Initialized\n"); 1246 1241 1247 1242 return 0; ··· 1257 1256 1258 1257 static void stratix10_svc_drv_remove(struct platform_device *pdev) 1259 1258 { 1260 - struct stratix10_svc *svc = dev_get_drvdata(&pdev->dev); 1261 1259 struct stratix10_svc_controller *ctrl = platform_get_drvdata(pdev); 1260 + struct stratix10_svc *svc = ctrl->svc; 1262 1261 1263 1262 of_platform_depopulate(ctrl->dev); 1264 1263
+39 -5
drivers/iio/accel/adxl355_core.c
··· 56 56 #define ADXL355_POWER_CTL_DRDY_MSK BIT(2) 57 57 #define ADXL355_SELF_TEST_REG 0x2E 58 58 #define ADXL355_RESET_REG 0x2F 59 + #define ADXL355_BASE_ADDR_SHADOW_REG 0x50 60 + #define ADXL355_SHADOW_REG_COUNT 5 59 61 60 62 #define ADXL355_DEVID_AD_VAL 0xAD 61 63 #define ADXL355_DEVID_MST_VAL 0x1D ··· 296 294 static int adxl355_setup(struct adxl355_data *data) 297 295 { 298 296 unsigned int regval; 297 + int retries = 5; /* the number is chosen based on empirical reasons */ 299 298 int ret; 299 + u8 *shadow_regs __free(kfree) = kzalloc(ADXL355_SHADOW_REG_COUNT, GFP_KERNEL); 300 + 301 + if (!shadow_regs) 302 + return -ENOMEM; 300 303 301 304 ret = regmap_read(data->regmap, ADXL355_DEVID_AD_REG, &regval); 302 305 if (ret) ··· 328 321 if (regval != ADXL355_PARTID_VAL) 329 322 dev_warn(data->dev, "Invalid DEV ID 0x%02x\n", regval); 330 323 331 - /* 332 - * Perform a software reset to make sure the device is in a consistent 333 - * state after start-up. 334 - */ 335 - ret = regmap_write(data->regmap, ADXL355_RESET_REG, ADXL355_RESET_CODE); 324 + /* Read shadow registers to be compared after reset */ 325 + ret = regmap_bulk_read(data->regmap, 326 + ADXL355_BASE_ADDR_SHADOW_REG, 327 + shadow_regs, ADXL355_SHADOW_REG_COUNT); 336 328 if (ret) 337 329 return ret; 330 + 331 + do { 332 + if (--retries == 0) { 333 + dev_err(data->dev, "Shadow registers mismatch\n"); 334 + return -EIO; 335 + } 336 + 337 + /* 338 + * Perform a software reset to make sure the device is in a consistent 339 + * state after start-up. 340 + */ 341 + ret = regmap_write(data->regmap, ADXL355_RESET_REG, 342 + ADXL355_RESET_CODE); 343 + if (ret) 344 + return ret; 345 + 346 + /* Wait at least 5ms after software reset */ 347 + usleep_range(5000, 10000); 348 + 349 + /* Read shadow registers for comparison */ 350 + ret = regmap_bulk_read(data->regmap, 351 + ADXL355_BASE_ADDR_SHADOW_REG, 352 + data->buffer.buf, 353 + ADXL355_SHADOW_REG_COUNT); 354 + if (ret) 355 + return ret; 356 + } while (memcmp(shadow_regs, data->buffer.buf, 357 + ADXL355_SHADOW_REG_COUNT)); 338 358 339 359 ret = regmap_update_bits(data->regmap, ADXL355_POWER_CTL_REG, 340 360 ADXL355_POWER_CTL_DRDY_MSK,
+5
drivers/iio/accel/bmc150-accel-core.c
··· 523 523 const struct bmc150_accel_interrupt_info *info = intr->info; 524 524 int ret; 525 525 526 + /* We do not always have an IRQ */ 527 + if (data->irq <= 0) 528 + return 0; 529 + 526 530 if (state) { 527 531 if (atomic_inc_return(&intr->users) > 1) 528 532 return 0; ··· 1700 1696 } 1701 1697 1702 1698 if (irq > 0) { 1699 + data->irq = irq; 1703 1700 ret = devm_request_threaded_irq(dev, irq, 1704 1701 bmc150_accel_irq_handler, 1705 1702 bmc150_accel_irq_thread_handler,
+1
drivers/iio/accel/bmc150-accel.h
··· 58 58 59 59 struct bmc150_accel_data { 60 60 struct regmap *regmap; 61 + int irq; 61 62 struct regulator_bulk_data regulators[2]; 62 63 struct bmc150_accel_interrupt interrupts[BMC150_ACCEL_INTERRUPTS]; 63 64 struct bmc150_accel_trigger triggers[BMC150_ACCEL_TRIGGERS];
+1 -1
drivers/iio/adc/ad4030.c
··· 385 385 struct ad4030_state *st = iio_priv(indio_dev); 386 386 const struct iio_scan_type *scan_type; 387 387 388 - scan_type = iio_get_current_scan_type(indio_dev, st->chip->channels); 388 + scan_type = iio_get_current_scan_type(indio_dev, chan); 389 389 if (IS_ERR(scan_type)) 390 390 return PTR_ERR(scan_type); 391 391
+8 -4
drivers/iio/adc/ad7124.c
··· 1525 1525 int ret, i; 1526 1526 1527 1527 for (i = 0; i < st->num_channels; i++) { 1528 - 1529 - if (indio_dev->channels[i].type != IIO_VOLTAGE) 1530 - continue; 1531 - 1532 1528 /* 1533 1529 * For calibration the OFFSET register should hold its reset default 1534 1530 * value. For the GAIN register there is no such requirement but ··· 1533 1537 */ 1534 1538 st->channels[i].cfg.calibration_offset = 0x800000; 1535 1539 st->channels[i].cfg.calibration_gain = st->gain_default; 1540 + 1541 + /* 1542 + * Only the main voltage input channels are important enough 1543 + * to be automatically calibrated here. For everything else, 1544 + * just use the default values set above. 1545 + */ 1546 + if (indio_dev->channels[i].type != IIO_VOLTAGE) 1547 + continue; 1536 1548 1537 1549 /* 1538 1550 * Full-scale calibration isn't supported at gain 1, so skip in
+1 -1
drivers/iio/adc/ad7280a.c
··· 541 541 int val, val2; 542 542 int ret; 543 543 544 - ret = iio_str_to_fixpoint(buf, 1000, &val, &val2); 544 + ret = iio_str_to_fixpoint(buf, 100, &val, &val2); 545 545 if (ret) 546 546 return ret; 547 547
+8
drivers/iio/adc/ad7380.c
··· 1227 1227 if (ret) 1228 1228 return ret; 1229 1229 1230 + /* 1231 + * When the sequencer is required to read all channels, we need to 1232 + * trigger twice per sample period in order to read one complete set 1233 + * of samples. 1234 + */ 1235 + if (st->seq) 1236 + config.periodic.frequency_hz *= 2; 1237 + 1230 1238 ret = spi_offload_trigger_enable(st->offload, st->offload_trigger, &config); 1231 1239 if (ret) 1232 1240 spi_unoptimize_message(&st->offload_msg);
+1 -1
drivers/iio/adc/rtq6056.c
··· 300 300 return IIO_VAL_INT; 301 301 case RTQ6056_REG_SHUNTVOLT: 302 302 case RTQ6056_REG_CURRENT: 303 - *val = sign_extend32(regval, 16); 303 + *val = sign_extend32(regval, 15); 304 304 return IIO_VAL_INT; 305 305 default: 306 306 return -EINVAL;
+2 -3
drivers/iio/adc/stm32-dfsdm-adc.c
··· 725 725 } 726 726 df_ch->src = val; 727 727 728 - ret = fwnode_property_read_u32(node, "st,adc-alt-channel", &df_ch->alt_si); 729 - if (ret != -EINVAL) 730 - df_ch->alt_si = 0; 728 + if (fwnode_property_present(node, "st,adc-alt-channel")) 729 + df_ch->alt_si = 1; 731 730 732 731 if (adc->dev_data->type == DFSDM_IIO) { 733 732 backend = devm_iio_backend_fwnode_get(&indio_dev->dev, NULL, node);
+6
drivers/iio/buffer/industrialio-buffer-dma.c
··· 786 786 } 787 787 EXPORT_SYMBOL_NS_GPL(iio_dma_buffer_enqueue_dmabuf, "IIO_DMA_BUFFER"); 788 788 789 + struct device *iio_dma_buffer_get_dma_dev(struct iio_buffer *buffer) 790 + { 791 + return iio_buffer_to_queue(buffer)->dev; 792 + } 793 + EXPORT_SYMBOL_NS_GPL(iio_dma_buffer_get_dma_dev, "IIO_DMA_BUFFER"); 794 + 789 795 void iio_dma_buffer_lock_queue(struct iio_buffer *buffer) 790 796 { 791 797 struct iio_dma_buffer_queue *queue = iio_buffer_to_queue(buffer);
+2
drivers/iio/buffer/industrialio-buffer-dmaengine.c
··· 177 177 .lock_queue = iio_dma_buffer_lock_queue, 178 178 .unlock_queue = iio_dma_buffer_unlock_queue, 179 179 180 + .get_dma_dev = iio_dma_buffer_get_dma_dev, 181 + 180 182 .modes = INDIO_BUFFER_HARDWARE, 181 183 .flags = INDIO_BUFFER_FLAG_FIXED_WATERMARK, 182 184 };
+3 -1
drivers/iio/common/ssp_sensors/ssp_dev.c
··· 503 503 ret = spi_setup(spi); 504 504 if (ret < 0) { 505 505 dev_err(&spi->dev, "Failed to setup spi\n"); 506 - return ret; 506 + goto err_setup_spi; 507 507 } 508 508 509 509 data->fw_dl_state = SSP_FW_DL_STATE_NONE; ··· 568 568 err_setup_irq: 569 569 mutex_destroy(&data->pending_lock); 570 570 mutex_destroy(&data->comm_lock); 571 + err_setup_spi: 572 + mfd_remove_devices(&spi->dev); 571 573 572 574 dev_err(&spi->dev, "Probe failed!\n"); 573 575
+43 -30
drivers/iio/humidity/hdc3020.c
··· 72 72 #define HDC3020_MAX_TEMP_HYST_MICRO 164748607 73 73 #define HDC3020_MAX_HUM_MICRO 99220264 74 74 75 + /* Divide 65535 from the datasheet by 5 to avoid overflows */ 76 + #define HDC3020_THRESH_FRACTION (65535 / 5) 77 + 75 78 struct hdc3020_data { 76 79 struct i2c_client *client; 77 80 struct gpio_desc *reset_gpio; ··· 304 301 case IIO_CHAN_INFO_SCALE: 305 302 *val2 = 65536; 306 303 if (chan->type == IIO_TEMP) 307 - *val = 175; 304 + *val = 175 * MILLI; 308 305 else 309 - *val = 100; 306 + *val = 100 * MILLI; 310 307 return IIO_VAL_FRACTIONAL; 311 308 312 309 case IIO_CHAN_INFO_OFFSET: ··· 379 376 int temp; 380 377 381 378 /* 382 - * Get the temperature threshold from 9 LSBs, shift them to get 383 - * the truncated temperature threshold representation and 384 - * calculate the threshold according to the formula in the 385 - * datasheet. Result is degree celsius scaled by 65535. 379 + * Get the temperature threshold from 9 LSBs, shift them to get the 380 + * truncated temperature threshold representation and calculate the 381 + * threshold according to the explicit formula in the datasheet: 382 + * T(C) = -45 + (175 * temp) / 65535. 383 + * Additionally scale by HDC3020_THRESH_FRACTION to avoid precision loss 384 + * when calculating threshold and hysteresis values. Result is degree 385 + * celsius scaled by HDC3020_THRESH_FRACTION. 386 386 */ 387 387 temp = FIELD_GET(HDC3020_THRESH_TEMP_MASK, thresh) << 388 388 HDC3020_THRESH_TEMP_TRUNC_SHIFT; 389 389 390 - return -2949075 + (175 * temp); 390 + return -2949075 / 5 + (175 / 5 * temp); 391 391 } 392 392 393 393 static int hdc3020_thresh_get_hum(u16 thresh) ··· 400 394 /* 401 395 * Get the humidity threshold from 7 MSBs, shift them to get the 402 396 * truncated humidity threshold representation and calculate the 403 - * threshold according to the formula in the datasheet. Result is 404 - * percent scaled by 65535. 397 + * threshold according to the explicit formula in the datasheet: 398 + * RH(%) = 100 * hum / 65535. 399 + * Additionally scale by HDC3020_THRESH_FRACTION to avoid precision loss 400 + * when calculating threshold and hysteresis values. Result is percent 401 + * scaled by HDC3020_THRESH_FRACTION. 405 402 */ 406 403 hum = FIELD_GET(HDC3020_THRESH_HUM_MASK, thresh) << 407 404 HDC3020_THRESH_HUM_TRUNC_SHIFT; 408 405 409 - return hum * 100; 406 + return hum * 100 / 5; 410 407 } 411 408 412 409 static u16 hdc3020_thresh_set_temp(int s_temp, u16 curr_thresh) ··· 464 455 else 465 456 s_clr = s_thresh + s_hyst; 466 457 467 - /* Divide by 65535 to get units of micro */ 468 - return div_s64(s_clr, 65535); 458 + /* Divide by HDC3020_THRESH_FRACTION to get units of micro */ 459 + return div_s64(s_clr, HDC3020_THRESH_FRACTION); 469 460 } 470 461 471 462 static int _hdc3020_write_thresh(struct hdc3020_data *data, u16 reg, u16 val) ··· 516 507 517 508 clr = ret; 518 509 /* Scale value to include decimal part into calculations */ 519 - s_val = (val < 0) ? (val * 1000000 - val2) : (val * 1000000 + val2); 510 + s_val = (val < 0) ? (val * 1000 - val2) : (val * 1000 + val2); 520 511 switch (chan->type) { 521 512 case IIO_TEMP: 522 513 switch (info) { ··· 532 523 /* Calculate old hysteresis */ 533 524 s_thresh = (s64)hdc3020_thresh_get_temp(thresh) * 1000000; 534 525 s_clr = (s64)hdc3020_thresh_get_temp(clr) * 1000000; 535 - s_hyst = div_s64(abs(s_thresh - s_clr), 65535); 526 + s_hyst = div_s64(abs(s_thresh - s_clr), 527 + HDC3020_THRESH_FRACTION); 536 528 /* Set new threshold */ 537 529 thresh = reg_val; 538 530 /* Set old hysteresis */ ··· 542 532 case IIO_EV_INFO_HYSTERESIS: 543 533 /* 544 534 * Function hdc3020_thresh_get_temp returns temperature 545 - * in degree celsius scaled by 65535. Scale by 1000000 546 - * to be able to subtract scaled hysteresis value. 535 + * in degree celsius scaled by HDC3020_THRESH_FRACTION. 536 + * Scale by 1000000 to be able to subtract scaled 537 + * hysteresis value. 547 538 */ 548 539 s_thresh = (s64)hdc3020_thresh_get_temp(thresh) * 1000000; 549 540 /* 550 541 * Units of s_val are in micro degree celsius, scale by 551 - * 65535 to get same units as s_thresh. 542 + * HDC3020_THRESH_FRACTION to get same units as s_thresh. 552 543 */ 553 544 s_val = min(abs(s_val), HDC3020_MAX_TEMP_HYST_MICRO); 554 - s_hyst = (s64)s_val * 65535; 545 + s_hyst = (s64)s_val * HDC3020_THRESH_FRACTION; 555 546 s_clr = hdc3020_thresh_clr(s_thresh, s_hyst, dir); 556 547 s_clr = max(s_clr, HDC3020_MIN_TEMP_MICRO); 557 548 s_clr = min(s_clr, HDC3020_MAX_TEMP_MICRO); ··· 576 565 /* Calculate old hysteresis */ 577 566 s_thresh = (s64)hdc3020_thresh_get_hum(thresh) * 1000000; 578 567 s_clr = (s64)hdc3020_thresh_get_hum(clr) * 1000000; 579 - s_hyst = div_s64(abs(s_thresh - s_clr), 65535); 568 + s_hyst = div_s64(abs(s_thresh - s_clr), 569 + HDC3020_THRESH_FRACTION); 580 570 /* Set new threshold */ 581 571 thresh = reg_val; 582 572 /* Try to set old hysteresis */ ··· 586 574 case IIO_EV_INFO_HYSTERESIS: 587 575 /* 588 576 * Function hdc3020_thresh_get_hum returns relative 589 - * humidity in percent scaled by 65535. Scale by 1000000 590 - * to be able to subtract scaled hysteresis value. 577 + * humidity in percent scaled by HDC3020_THRESH_FRACTION. 578 + * Scale by 1000000 to be able to subtract scaled 579 + * hysteresis value. 591 580 */ 592 581 s_thresh = (s64)hdc3020_thresh_get_hum(thresh) * 1000000; 593 582 /* 594 - * Units of s_val are in micro percent, scale by 65535 595 - * to get same units as s_thresh. 583 + * Units of s_val are in micro percent, scale by 584 + * HDC3020_THRESH_FRACTION to get same units as s_thresh. 596 585 */ 597 - s_hyst = (s64)s_val * 65535; 586 + s_hyst = (s64)s_val * HDC3020_THRESH_FRACTION; 598 587 s_clr = hdc3020_thresh_clr(s_thresh, s_hyst, dir); 599 588 s_clr = max(s_clr, 0); 600 589 s_clr = min(s_clr, HDC3020_MAX_HUM_MICRO); ··· 643 630 thresh = hdc3020_thresh_get_temp(ret); 644 631 switch (info) { 645 632 case IIO_EV_INFO_VALUE: 646 - *val = thresh; 633 + *val = thresh * MILLI; 647 634 break; 648 635 case IIO_EV_INFO_HYSTERESIS: 649 636 ret = hdc3020_read_be16(data, reg_clr); ··· 651 638 return ret; 652 639 653 640 clr = hdc3020_thresh_get_temp(ret); 654 - *val = abs(thresh - clr); 641 + *val = abs(thresh - clr) * MILLI; 655 642 break; 656 643 default: 657 644 return -EOPNOTSUPP; 658 645 } 659 - *val2 = 65535; 646 + *val2 = HDC3020_THRESH_FRACTION; 660 647 return IIO_VAL_FRACTIONAL; 661 648 case IIO_HUMIDITYRELATIVE: 662 649 thresh = hdc3020_thresh_get_hum(ret); 663 650 switch (info) { 664 651 case IIO_EV_INFO_VALUE: 665 - *val = thresh; 652 + *val = thresh * MILLI; 666 653 break; 667 654 case IIO_EV_INFO_HYSTERESIS: 668 655 ret = hdc3020_read_be16(data, reg_clr); ··· 670 657 return ret; 671 658 672 659 clr = hdc3020_thresh_get_hum(ret); 673 - *val = abs(thresh - clr); 660 + *val = abs(thresh - clr) * MILLI; 674 661 break; 675 662 default: 676 663 return -EOPNOTSUPP; 677 664 } 678 - *val2 = 65535; 665 + *val2 = HDC3020_THRESH_FRACTION; 679 666 return IIO_VAL_FRACTIONAL; 680 667 default: 681 668 return -EOPNOTSUPP;
+29 -11
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx.h
··· 192 192 * @fifo_en: Hw timer FIFO enable register info (addr + mask). 193 193 * @decimator: Hw timer FIFO decimator register info (addr + mask). 194 194 * @freq_fine: Difference in % of ODR with respect to the typical. 195 + * @ts_sensitivity: Nominal timestamp sensitivity. 196 + * @ts_trim_coeff: Coefficient for calculating the calibrated timestamp gain. 197 + * This coefficient comes into play when linearizing the formula 198 + * used to calculate the calibrated timestamp (please see the 199 + * relevant formula in the AN for the specific IMU). 200 + * For example, in the case of LSM6DSO we have: 201 + * 202 + * 1 / (1 + x) ~= 1 - x (Taylor’s Series) 203 + * ttrim[s] = 1 / (40000 * (1 + 0.0015 * val)) (from AN5192) 204 + * ttrim[ns] ~= 25000 - 37.5 * val 205 + * ttrim[ns] ~= 25000 - (37500 * val) / 1000 206 + * 207 + * so, replacing ts_sensitivity = 25000 and 208 + * ts_trim_coeff = 37500 209 + * 210 + * ttrim[ns] ~= ts_sensitivity - (ts_trim_coeff * val) / 1000 195 211 */ 196 212 struct st_lsm6dsx_hw_ts_settings { 197 213 struct st_lsm6dsx_reg timer_en; ··· 215 199 struct st_lsm6dsx_reg fifo_en; 216 200 struct st_lsm6dsx_reg decimator; 217 201 u8 freq_fine; 202 + u16 ts_sensitivity; 203 + u16 ts_trim_coeff; 218 204 }; 219 205 220 206 /** ··· 268 250 u8 wakeup_src_z_mask; 269 251 u8 wakeup_src_y_mask; 270 252 u8 wakeup_src_x_mask; 253 + }; 254 + 255 + enum st_lsm6dsx_sensor_id { 256 + ST_LSM6DSX_ID_GYRO, 257 + ST_LSM6DSX_ID_ACC, 258 + ST_LSM6DSX_ID_EXT0, 259 + ST_LSM6DSX_ID_EXT1, 260 + ST_LSM6DSX_ID_EXT2, 261 + ST_LSM6DSX_ID_MAX 271 262 }; 272 263 273 264 enum st_lsm6dsx_ext_sensor_id { ··· 364 337 struct st_lsm6dsx_odr_table_entry odr_table[2]; 365 338 struct st_lsm6dsx_samples_to_discard samples_to_discard[2]; 366 339 struct st_lsm6dsx_fs_table_entry fs_table[2]; 367 - struct st_lsm6dsx_reg decimator[ST_LSM6DSX_MAX_ID]; 368 - struct st_lsm6dsx_reg batch[ST_LSM6DSX_MAX_ID]; 340 + struct st_lsm6dsx_reg decimator[ST_LSM6DSX_ID_MAX]; 341 + struct st_lsm6dsx_reg batch[2]; 369 342 struct st_lsm6dsx_fifo_ops fifo_ops; 370 343 struct st_lsm6dsx_hw_ts_settings ts_settings; 371 344 struct st_lsm6dsx_shub_settings shub_settings; 372 345 struct st_lsm6dsx_event_settings event_settings; 373 - }; 374 - 375 - enum st_lsm6dsx_sensor_id { 376 - ST_LSM6DSX_ID_GYRO, 377 - ST_LSM6DSX_ID_ACC, 378 - ST_LSM6DSX_ID_EXT0, 379 - ST_LSM6DSX_ID_EXT1, 380 - ST_LSM6DSX_ID_EXT2, 381 - ST_LSM6DSX_ID_MAX, 382 346 }; 383 347 384 348 enum st_lsm6dsx_fifo_mode {
+8 -11
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 94 94 95 95 #define ST_LSM6DSX_REG_WHOAMI_ADDR 0x0f 96 96 97 - #define ST_LSM6DSX_TS_SENSITIVITY 25000UL /* 25us */ 98 - 99 97 static const struct iio_chan_spec st_lsm6dsx_acc_channels[] = { 100 98 ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x28, IIO_MOD_X, 0), 101 99 ST_LSM6DSX_CHANNEL_ACC(IIO_ACCEL, 0x2a, IIO_MOD_Y, 1), ··· 981 983 .mask = GENMASK(7, 6), 982 984 }, 983 985 .freq_fine = 0x63, 986 + .ts_sensitivity = 25000, 987 + .ts_trim_coeff = 37500, 984 988 }, 985 989 .shub_settings = { 986 990 .page_mux = { ··· 1196 1196 .mask = GENMASK(7, 6), 1197 1197 }, 1198 1198 .freq_fine = 0x63, 1199 + .ts_sensitivity = 25000, 1200 + .ts_trim_coeff = 37500, 1199 1201 }, 1200 1202 .event_settings = { 1201 1203 .enable_reg = { ··· 1373 1371 .mask = GENMASK(7, 6), 1374 1372 }, 1375 1373 .freq_fine = 0x4f, 1374 + .ts_sensitivity = 21701, 1375 + .ts_trim_coeff = 28212, 1376 1376 }, 1377 1377 .shub_settings = { 1378 1378 .page_mux = { ··· 2252 2248 } 2253 2249 2254 2250 /* calibrate timestamp sensitivity */ 2255 - hw->ts_gain = ST_LSM6DSX_TS_SENSITIVITY; 2251 + hw->ts_gain = ts_settings->ts_sensitivity; 2256 2252 if (ts_settings->freq_fine) { 2257 2253 err = regmap_read(hw->regmap, ts_settings->freq_fine, &val); 2258 2254 if (err < 0) 2259 2255 return err; 2260 2256 2261 - /* 2262 - * linearize the AN5192 formula: 2263 - * 1 / (1 + x) ~= 1 - x (Taylor’s Series) 2264 - * ttrim[s] = 1 / (40000 * (1 + 0.0015 * val)) 2265 - * ttrim[ns] ~= 25000 - 37.5 * val 2266 - * ttrim[ns] ~= 25000 - (37500 * val) / 1000 2267 - */ 2268 - hw->ts_gain -= ((s8)val * 37500) / 1000; 2257 + hw->ts_gain -= ((s8)val * ts_settings->ts_trim_coeff) / 1000; 2269 2258 } 2270 2259 2271 2260 return 0;
+16 -5
drivers/iio/industrialio-buffer.c
··· 1623 1623 return 0; 1624 1624 } 1625 1625 1626 + static struct device *iio_buffer_get_dma_dev(const struct iio_dev *indio_dev, 1627 + struct iio_buffer *buffer) 1628 + { 1629 + if (buffer->access->get_dma_dev) 1630 + return buffer->access->get_dma_dev(buffer); 1631 + 1632 + return indio_dev->dev.parent; 1633 + } 1634 + 1626 1635 static struct dma_buf_attachment * 1627 1636 iio_buffer_find_attachment(struct iio_dev_buffer_pair *ib, 1628 1637 struct dma_buf *dmabuf, bool nonblock) 1629 1638 { 1630 - struct device *dev = ib->indio_dev->dev.parent; 1631 1639 struct iio_buffer *buffer = ib->buffer; 1640 + struct device *dma_dev = iio_buffer_get_dma_dev(ib->indio_dev, buffer); 1632 1641 struct dma_buf_attachment *attach = NULL; 1633 1642 struct iio_dmabuf_priv *priv; 1634 1643 1635 1644 guard(mutex)(&buffer->dmabufs_mutex); 1636 1645 1637 1646 list_for_each_entry(priv, &buffer->dmabufs, entry) { 1638 - if (priv->attach->dev == dev 1647 + if (priv->attach->dev == dma_dev 1639 1648 && priv->attach->dmabuf == dmabuf) { 1640 1649 attach = priv->attach; 1641 1650 break; ··· 1662 1653 { 1663 1654 struct iio_dev *indio_dev = ib->indio_dev; 1664 1655 struct iio_buffer *buffer = ib->buffer; 1656 + struct device *dma_dev = iio_buffer_get_dma_dev(indio_dev, buffer); 1665 1657 struct dma_buf_attachment *attach; 1666 1658 struct iio_dmabuf_priv *priv, *each; 1667 1659 struct dma_buf *dmabuf; ··· 1689 1679 goto err_free_priv; 1690 1680 } 1691 1681 1692 - attach = dma_buf_attach(dmabuf, indio_dev->dev.parent); 1682 + attach = dma_buf_attach(dmabuf, dma_dev); 1693 1683 if (IS_ERR(attach)) { 1694 1684 err = PTR_ERR(attach); 1695 1685 goto err_dmabuf_put; ··· 1729 1719 * combo. If we do, refuse to attach. 1730 1720 */ 1731 1721 list_for_each_entry(each, &buffer->dmabufs, entry) { 1732 - if (each->attach->dev == indio_dev->dev.parent 1722 + if (each->attach->dev == dma_dev 1733 1723 && each->attach->dmabuf == dmabuf) { 1734 1724 /* 1735 1725 * We unlocked the reservation object, so going through ··· 1768 1758 { 1769 1759 struct iio_buffer *buffer = ib->buffer; 1770 1760 struct iio_dev *indio_dev = ib->indio_dev; 1761 + struct device *dma_dev = iio_buffer_get_dma_dev(indio_dev, buffer); 1771 1762 struct iio_dmabuf_priv *priv; 1772 1763 struct dma_buf *dmabuf; 1773 1764 int dmabuf_fd, ret = -EPERM; ··· 1783 1772 guard(mutex)(&buffer->dmabufs_mutex); 1784 1773 1785 1774 list_for_each_entry(priv, &buffer->dmabufs, entry) { 1786 - if (priv->attach->dev == indio_dev->dev.parent 1775 + if (priv->attach->dev == dma_dev 1787 1776 && priv->attach->dmabuf == dmabuf) { 1788 1777 list_del(&priv->entry); 1789 1778
+9 -6
drivers/iio/pressure/bmp280-core.c
··· 1040 1040 unsigned int reg, meas_time_us; 1041 1041 int ret; 1042 1042 1043 - /* Check if we are using a BME280 device */ 1044 - if (data->oversampling_humid) 1045 - meas_time_us = BMP280_PRESS_HUMID_MEAS_OFFSET + 1046 - BIT(data->oversampling_humid) * BMP280_MEAS_DUR; 1043 + /* Constant part of the measurement time */ 1044 + meas_time_us = BMP280_MEAS_OFFSET; 1047 1045 1048 - else 1049 - meas_time_us = 0; 1046 + /* 1047 + * Check if we are using a BME280 device, 1048 + * Humidity measurement time 1049 + */ 1050 + if (data->chip_info->oversampling_humid_avail) 1051 + meas_time_us += BMP280_PRESS_HUMID_MEAS_OFFSET + 1052 + BIT(data->oversampling_humid) * BMP280_MEAS_DUR; 1050 1053 1051 1054 /* Pressure measurement time */ 1052 1055 meas_time_us += BMP280_PRESS_HUMID_MEAS_OFFSET +
+6 -7
drivers/misc/mei/pci-me.c
··· 223 223 hw->mem_addr = pcim_iomap_table(pdev)[0]; 224 224 hw->read_fws = mei_me_read_fws; 225 225 226 + err = mei_register(dev, &pdev->dev); 227 + if (err) 228 + goto end; 229 + 226 230 pci_enable_msi(pdev); 227 231 228 232 hw->irq = pdev->irq; ··· 241 237 if (err) { 242 238 dev_err(&pdev->dev, "request_threaded_irq failure. irq = %d\n", 243 239 pdev->irq); 244 - goto end; 240 + goto deregister; 245 241 } 246 - 247 - err = mei_register(dev, &pdev->dev); 248 - if (err) 249 - goto release_irq; 250 242 251 243 if (mei_start(dev)) { 252 244 dev_err(&pdev->dev, "init hw failure.\n"); ··· 283 283 return 0; 284 284 285 285 deregister: 286 - mei_deregister(dev); 287 - release_irq: 288 286 mei_cancel_work(dev); 289 287 mei_disable_interrupts(dev); 290 288 free_irq(pdev->irq, dev); 289 + mei_deregister(dev); 291 290 end: 292 291 dev_err(&pdev->dev, "initialization failed.\n"); 293 292 return err;
+6 -7
drivers/misc/mei/pci-txe.c
··· 87 87 hw = to_txe_hw(dev); 88 88 hw->mem_addr = pcim_iomap_table(pdev); 89 89 90 + err = mei_register(dev, &pdev->dev); 91 + if (err) 92 + goto end; 93 + 90 94 pci_enable_msi(pdev); 91 95 92 96 /* clear spurious interrupts */ ··· 110 106 if (err) { 111 107 dev_err(&pdev->dev, "mei: request_threaded_irq failure. irq = %d\n", 112 108 pdev->irq); 113 - goto end; 109 + goto deregister; 114 110 } 115 - 116 - err = mei_register(dev, &pdev->dev); 117 - if (err) 118 - goto release_irq; 119 111 120 112 if (mei_start(dev)) { 121 113 dev_err(&pdev->dev, "init hw failure.\n"); ··· 145 145 return 0; 146 146 147 147 deregister: 148 - mei_deregister(dev); 149 - release_irq: 150 148 mei_cancel_work(dev); 151 149 mei_disable_interrupts(dev); 152 150 free_irq(pdev->irq, dev); 151 + mei_deregister(dev); 153 152 end: 154 153 dev_err(&pdev->dev, "initialization failed.\n"); 155 154 return err;
+5 -6
drivers/misc/mei/platform-vsc.c
··· 362 362 363 363 ret = mei_register(mei_dev, dev); 364 364 if (ret) 365 - goto err_dereg; 365 + goto err; 366 366 367 367 ret = mei_start(mei_dev); 368 368 if (ret) { 369 369 dev_err_probe(dev, ret, "init hw failed\n"); 370 - goto err_cancel; 370 + goto err; 371 371 } 372 372 373 373 pm_runtime_enable(mei_dev->parent); 374 374 375 375 return 0; 376 376 377 - err_dereg: 378 - mei_deregister(mei_dev); 379 - 380 - err_cancel: 377 + err: 381 378 mei_cancel_work(mei_dev); 382 379 383 380 vsc_tp_register_event_cb(tp, NULL, NULL); 384 381 385 382 mei_disable_interrupts(mei_dev); 383 + 384 + mei_deregister(mei_dev); 386 385 387 386 return ret; 388 387 }
+5 -9
drivers/most/most_usb.c
··· 1058 1058 1059 1059 ret = most_register_interface(&mdev->iface); 1060 1060 if (ret) 1061 - goto err_free_busy_urbs; 1061 + return ret; 1062 1062 1063 1063 mutex_lock(&mdev->io_mutex); 1064 1064 if (le16_to_cpu(usb_dev->descriptor.idProduct) == USB_DEV_ID_OS81118 || ··· 1068 1068 if (!mdev->dci) { 1069 1069 mutex_unlock(&mdev->io_mutex); 1070 1070 most_deregister_interface(&mdev->iface); 1071 - ret = -ENOMEM; 1072 - goto err_free_busy_urbs; 1071 + return -ENOMEM; 1073 1072 } 1074 1073 1075 1074 mdev->dci->dev.init_name = "dci"; ··· 1077 1078 mdev->dci->dev.release = release_dci; 1078 1079 if (device_register(&mdev->dci->dev)) { 1079 1080 mutex_unlock(&mdev->io_mutex); 1081 + put_device(&mdev->dci->dev); 1080 1082 most_deregister_interface(&mdev->iface); 1081 - ret = -ENOMEM; 1082 - goto err_free_dci; 1083 + return -ENOMEM; 1083 1084 } 1084 1085 mdev->dci->usb_device = mdev->usb_device; 1085 1086 } 1086 1087 mutex_unlock(&mdev->io_mutex); 1087 1088 return 0; 1088 - err_free_dci: 1089 - put_device(&mdev->dci->dev); 1090 - err_free_busy_urbs: 1091 - kfree(mdev->busy_urbs); 1089 + 1092 1090 err_free_ep_address: 1093 1091 kfree(mdev->ep_address); 1094 1092 err_free_cap:
+1 -1
drivers/nvmem/layouts.c
··· 51 51 int ret; 52 52 53 53 ret = of_device_uevent_modalias(dev, env); 54 - if (ret != ENODEV) 54 + if (ret != -ENODEV) 55 55 return ret; 56 56 57 57 return 0;
+1
drivers/slimbus/qcom-ngd-ctrl.c
··· 1241 1241 1242 1242 if (slim_get_logical_addr(sbdev)) 1243 1243 dev_err(ctrl->dev, "Failed to get logical address\n"); 1244 + put_device(&sbdev->dev); 1244 1245 } 1245 1246 } 1246 1247
+1
include/linux/iio/buffer-dma.h
··· 174 174 size_t size, bool cyclic); 175 175 void iio_dma_buffer_lock_queue(struct iio_buffer *buffer); 176 176 void iio_dma_buffer_unlock_queue(struct iio_buffer *buffer); 177 + struct device *iio_dma_buffer_get_dma_dev(struct iio_buffer *buffer); 177 178 178 179 #endif
+2
include/linux/iio/buffer_impl.h
··· 50 50 * @enqueue_dmabuf: called from userspace via ioctl to queue this DMABUF 51 51 * object to this buffer. Requires a valid DMABUF fd, that 52 52 * was previouly attached to this buffer. 53 + * @get_dma_dev: called to get the DMA channel associated with this buffer. 53 54 * @lock_queue: called when the core needs to lock the buffer queue; 54 55 * it is used when enqueueing DMABUF objects. 55 56 * @unlock_queue: used to unlock a previously locked buffer queue ··· 91 90 struct iio_dma_buffer_block *block, 92 91 struct dma_fence *fence, struct sg_table *sgt, 93 92 size_t size, bool cyclic); 93 + struct device * (*get_dma_dev)(struct iio_buffer *buffer); 94 94 void (*lock_queue)(struct iio_buffer *buffer); 95 95 void (*unlock_queue)(struct iio_buffer *buffer); 96 96