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

Pull char/misc/IIO driver fixes from Greg KH:
"Here are a bunch of small driver fixes (mostly all IIO) for 6.15-rc6.
Included in here are:

- loads of tiny IIO driver fixes for reported issues

- hyperv driver fix for a much-reported and worked on sysfs ring
buffer creation bug

All of these have been in linux-next for over a week (the IIO ones for
many weeks now), with no reported issues"

* tag 'char-misc-6.15-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (30 commits)
Drivers: hv: Make the sysfs node size for the ring buffer dynamic
uio_hv_generic: Fix sysfs creation path for ring buffer
iio: adis16201: Correct inclinometer channel resolution
iio: adc: ad7606: fix serial register access
iio: pressure: mprls0025pa: use aligned_s64 for timestamp
iio: imu: adis16550: align buffers for timestamp
staging: iio: adc: ad7816: Correct conditional logic for store mode
iio: adc: ad7266: Fix potential timestamp alignment issue.
iio: adc: ad7768-1: Fix insufficient alignment of timestamp.
iio: adc: dln2: Use aligned_s64 for timestamp
iio: accel: adxl355: Make timestamp 64-bit aligned using aligned_s64
iio: temp: maxim-thermocouple: Fix potential lack of DMA safe buffer.
iio: chemical: pms7003: use aligned_s64 for timestamp
iio: chemical: sps30: use aligned_s64 for timestamp
iio: imu: inv_mpu6050: align buffer for timestamp
iio: imu: st_lsm6dsx: Fix wakeup source leaks on device unbind
iio: adc: qcom-spmi-iadc: Fix wakeup source leaks on device unbind
iio: accel: fxls8962af: Fix wakeup source leaks on device unbind
iio: adc: ad7380: fix event threshold shift
iio: hid-sensor-prox: Fix incorrect OFFSET calculation
...

+241 -96
+6
drivers/hv/hyperv_vmbus.h
··· 477 477 478 478 #endif /* CONFIG_HYPERV_TESTING */ 479 479 480 + /* Create and remove sysfs entry for memory mapped ring buffers for a channel */ 481 + int hv_create_ring_sysfs(struct vmbus_channel *channel, 482 + int (*hv_mmap_ring_buffer)(struct vmbus_channel *channel, 483 + struct vm_area_struct *vma)); 484 + int hv_remove_ring_sysfs(struct vmbus_channel *channel); 485 + 480 486 #endif /* _HYPERV_VMBUS_H */
+108 -1
drivers/hv/vmbus_drv.c
··· 1802 1802 } 1803 1803 static VMBUS_CHAN_ATTR_RO(subchannel_id); 1804 1804 1805 + static int hv_mmap_ring_buffer_wrapper(struct file *filp, struct kobject *kobj, 1806 + const struct bin_attribute *attr, 1807 + struct vm_area_struct *vma) 1808 + { 1809 + struct vmbus_channel *channel = container_of(kobj, struct vmbus_channel, kobj); 1810 + 1811 + /* 1812 + * hv_(create|remove)_ring_sysfs implementation ensures that mmap_ring_buffer 1813 + * is not NULL. 1814 + */ 1815 + return channel->mmap_ring_buffer(channel, vma); 1816 + } 1817 + 1818 + static struct bin_attribute chan_attr_ring_buffer = { 1819 + .attr = { 1820 + .name = "ring", 1821 + .mode = 0600, 1822 + }, 1823 + .mmap = hv_mmap_ring_buffer_wrapper, 1824 + }; 1805 1825 static struct attribute *vmbus_chan_attrs[] = { 1806 1826 &chan_attr_out_mask.attr, 1807 1827 &chan_attr_in_mask.attr, ··· 1838 1818 &chan_attr_out_full_total.attr, 1839 1819 &chan_attr_monitor_id.attr, 1840 1820 &chan_attr_subchannel_id.attr, 1821 + NULL 1822 + }; 1823 + 1824 + static struct bin_attribute *vmbus_chan_bin_attrs[] = { 1825 + &chan_attr_ring_buffer, 1841 1826 NULL 1842 1827 }; 1843 1828 ··· 1866 1841 return attr->mode; 1867 1842 } 1868 1843 1844 + static umode_t vmbus_chan_bin_attr_is_visible(struct kobject *kobj, 1845 + const struct bin_attribute *attr, int idx) 1846 + { 1847 + const struct vmbus_channel *channel = 1848 + container_of(kobj, struct vmbus_channel, kobj); 1849 + 1850 + /* Hide ring attribute if channel's ring_sysfs_visible is set to false */ 1851 + if (attr == &chan_attr_ring_buffer && !channel->ring_sysfs_visible) 1852 + return 0; 1853 + 1854 + return attr->attr.mode; 1855 + } 1856 + 1857 + static size_t vmbus_chan_bin_size(struct kobject *kobj, 1858 + const struct bin_attribute *bin_attr, int a) 1859 + { 1860 + const struct vmbus_channel *channel = 1861 + container_of(kobj, struct vmbus_channel, kobj); 1862 + 1863 + return channel->ringbuffer_pagecount << PAGE_SHIFT; 1864 + } 1865 + 1869 1866 static const struct attribute_group vmbus_chan_group = { 1870 1867 .attrs = vmbus_chan_attrs, 1871 - .is_visible = vmbus_chan_attr_is_visible 1868 + .bin_attrs = vmbus_chan_bin_attrs, 1869 + .is_visible = vmbus_chan_attr_is_visible, 1870 + .is_bin_visible = vmbus_chan_bin_attr_is_visible, 1871 + .bin_size = vmbus_chan_bin_size, 1872 1872 }; 1873 1873 1874 1874 static const struct kobj_type vmbus_chan_ktype = { 1875 1875 .sysfs_ops = &vmbus_chan_sysfs_ops, 1876 1876 .release = vmbus_chan_release, 1877 1877 }; 1878 + 1879 + /** 1880 + * hv_create_ring_sysfs() - create "ring" sysfs entry corresponding to ring buffers for a channel. 1881 + * @channel: Pointer to vmbus_channel structure 1882 + * @hv_mmap_ring_buffer: function pointer for initializing the function to be called on mmap of 1883 + * channel's "ring" sysfs node, which is for the ring buffer of that channel. 1884 + * Function pointer is of below type: 1885 + * int (*hv_mmap_ring_buffer)(struct vmbus_channel *channel, 1886 + * struct vm_area_struct *vma)) 1887 + * This has a pointer to the channel and a pointer to vm_area_struct, 1888 + * used for mmap, as arguments. 1889 + * 1890 + * Sysfs node for ring buffer of a channel is created along with other fields, however its 1891 + * visibility is disabled by default. Sysfs creation needs to be controlled when the use-case 1892 + * is running. 1893 + * For example, HV_NIC device is used either by uio_hv_generic or hv_netvsc at any given point of 1894 + * time, and "ring" sysfs is needed only when uio_hv_generic is bound to that device. To avoid 1895 + * exposing the ring buffer by default, this function is reponsible to enable visibility of 1896 + * ring for userspace to use. 1897 + * Note: Race conditions can happen with userspace and it is not encouraged to create new 1898 + * use-cases for this. This was added to maintain backward compatibility, while solving 1899 + * one of the race conditions in uio_hv_generic while creating sysfs. 1900 + * 1901 + * Returns 0 on success or error code on failure. 1902 + */ 1903 + int hv_create_ring_sysfs(struct vmbus_channel *channel, 1904 + int (*hv_mmap_ring_buffer)(struct vmbus_channel *channel, 1905 + struct vm_area_struct *vma)) 1906 + { 1907 + struct kobject *kobj = &channel->kobj; 1908 + 1909 + channel->mmap_ring_buffer = hv_mmap_ring_buffer; 1910 + channel->ring_sysfs_visible = true; 1911 + 1912 + return sysfs_update_group(kobj, &vmbus_chan_group); 1913 + } 1914 + EXPORT_SYMBOL_GPL(hv_create_ring_sysfs); 1915 + 1916 + /** 1917 + * hv_remove_ring_sysfs() - remove ring sysfs entry corresponding to ring buffers for a channel. 1918 + * @channel: Pointer to vmbus_channel structure 1919 + * 1920 + * Hide "ring" sysfs for a channel by changing its is_visible attribute and updating sysfs group. 1921 + * 1922 + * Returns 0 on success or error code on failure. 1923 + */ 1924 + int hv_remove_ring_sysfs(struct vmbus_channel *channel) 1925 + { 1926 + struct kobject *kobj = &channel->kobj; 1927 + int ret; 1928 + 1929 + channel->ring_sysfs_visible = false; 1930 + ret = sysfs_update_group(kobj, &vmbus_chan_group); 1931 + channel->mmap_ring_buffer = NULL; 1932 + return ret; 1933 + } 1934 + EXPORT_SYMBOL_GPL(hv_remove_ring_sysfs); 1878 1935 1879 1936 /* 1880 1937 * vmbus_add_channel_kobj - setup a sub-directory under device/channels
+2 -2
drivers/iio/accel/adis16201.c
··· 211 211 BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14), 212 212 ADIS_AUX_ADC_CHAN(ADIS16201_AUX_ADC_REG, ADIS16201_SCAN_AUX_ADC, 0, 12), 213 213 ADIS_INCLI_CHAN(X, ADIS16201_XINCL_OUT_REG, ADIS16201_SCAN_INCLI_X, 214 - BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14), 214 + BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 12), 215 215 ADIS_INCLI_CHAN(Y, ADIS16201_YINCL_OUT_REG, ADIS16201_SCAN_INCLI_Y, 216 - BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 14), 216 + BIT(IIO_CHAN_INFO_CALIBBIAS), 0, 12), 217 217 IIO_CHAN_SOFT_TIMESTAMP(7) 218 218 }; 219 219
+1 -1
drivers/iio/accel/adxl355_core.c
··· 231 231 u8 transf_buf[3]; 232 232 struct { 233 233 u8 buf[14]; 234 - s64 ts; 234 + aligned_s64 ts; 235 235 } buffer; 236 236 } __aligned(IIO_DMA_MINALIGN); 237 237 };
+3 -7
drivers/iio/accel/adxl367.c
··· 601 601 if (ret) 602 602 return ret; 603 603 604 + st->odr = odr; 605 + 604 606 /* Activity timers depend on ODR */ 605 607 ret = _adxl367_set_act_time_ms(st, st->act_time_ms); 606 608 if (ret) 607 609 return ret; 608 610 609 - ret = _adxl367_set_inact_time_ms(st, st->inact_time_ms); 610 - if (ret) 611 - return ret; 612 - 613 - st->odr = odr; 614 - 615 - return 0; 611 + return _adxl367_set_inact_time_ms(st, st->inact_time_ms); 616 612 } 617 613 618 614 static int adxl367_set_odr(struct iio_dev *indio_dev, enum adxl367_odr odr)
+5 -2
drivers/iio/accel/fxls8962af-core.c
··· 1226 1226 if (ret) 1227 1227 return ret; 1228 1228 1229 - if (device_property_read_bool(dev, "wakeup-source")) 1230 - device_init_wakeup(dev, true); 1229 + if (device_property_read_bool(dev, "wakeup-source")) { 1230 + ret = devm_device_init_wakeup(dev); 1231 + if (ret) 1232 + return dev_err_probe(dev, ret, "Failed to init wakeup\n"); 1233 + } 1231 1234 1232 1235 return devm_iio_device_register(dev, indio_dev); 1233 1236 }
+1 -1
drivers/iio/adc/ad7266.c
··· 45 45 */ 46 46 struct { 47 47 __be16 sample[2]; 48 - s64 timestamp; 48 + aligned_s64 timestamp; 49 49 } data __aligned(IIO_DMA_MINALIGN); 50 50 }; 51 51
+22 -10
drivers/iio/adc/ad7380.c
··· 1211 1211 struct ad7380_state *st = iio_priv(indio_dev); 1212 1212 int ret; 1213 1213 1214 + spi_offload_trigger_disable(st->offload, st->offload_trigger); 1215 + spi_unoptimize_message(&st->offload_msg); 1216 + 1214 1217 if (st->seq) { 1215 1218 ret = regmap_update_bits(st->regmap, 1216 1219 AD7380_REG_ADDR_CONFIG1, ··· 1224 1221 1225 1222 st->seq = false; 1226 1223 } 1227 - 1228 - spi_offload_trigger_disable(st->offload, st->offload_trigger); 1229 - 1230 - spi_unoptimize_message(&st->offload_msg); 1231 1224 1232 1225 return 0; 1233 1226 } ··· 1610 1611 return ret; 1611 1612 } 1612 1613 1613 - static int ad7380_get_alert_th(struct ad7380_state *st, 1614 + static int ad7380_get_alert_th(struct iio_dev *indio_dev, 1615 + const struct iio_chan_spec *chan, 1614 1616 enum iio_event_direction dir, 1615 1617 int *val) 1616 1618 { 1617 - int ret, tmp; 1619 + struct ad7380_state *st = iio_priv(indio_dev); 1620 + const struct iio_scan_type *scan_type; 1621 + int ret, tmp, shift; 1622 + 1623 + scan_type = iio_get_current_scan_type(indio_dev, chan); 1624 + if (IS_ERR(scan_type)) 1625 + return PTR_ERR(scan_type); 1626 + 1627 + /* 1628 + * The register value is 12-bits and is compared to the most significant 1629 + * bits of raw value, therefore a shift is required to convert this to 1630 + * the same scale as the raw value. 1631 + */ 1632 + shift = scan_type->realbits - 12; 1618 1633 1619 1634 switch (dir) { 1620 1635 case IIO_EV_DIR_RISING: ··· 1638 1625 if (ret) 1639 1626 return ret; 1640 1627 1641 - *val = FIELD_GET(AD7380_ALERT_HIGH_TH, tmp); 1628 + *val = FIELD_GET(AD7380_ALERT_HIGH_TH, tmp) << shift; 1642 1629 return IIO_VAL_INT; 1643 1630 case IIO_EV_DIR_FALLING: 1644 1631 ret = regmap_read(st->regmap, ··· 1647 1634 if (ret) 1648 1635 return ret; 1649 1636 1650 - *val = FIELD_GET(AD7380_ALERT_LOW_TH, tmp); 1637 + *val = FIELD_GET(AD7380_ALERT_LOW_TH, tmp) << shift; 1651 1638 return IIO_VAL_INT; 1652 1639 default: 1653 1640 return -EINVAL; ··· 1661 1648 enum iio_event_info info, 1662 1649 int *val, int *val2) 1663 1650 { 1664 - struct ad7380_state *st = iio_priv(indio_dev); 1665 1651 int ret; 1666 1652 1667 1653 switch (info) { ··· 1668 1656 if (!iio_device_claim_direct(indio_dev)) 1669 1657 return -EBUSY; 1670 1658 1671 - ret = ad7380_get_alert_th(st, dir, val); 1659 + ret = ad7380_get_alert_th(indio_dev, chan, dir, val); 1672 1660 1673 1661 iio_device_release_direct(indio_dev); 1674 1662 return ret;
+8 -3
drivers/iio/adc/ad7606.c
··· 1236 1236 st->write_scale = ad7616_write_scale_sw; 1237 1237 st->write_os = &ad7616_write_os_sw; 1238 1238 1239 - ret = st->bops->sw_mode_config(indio_dev); 1240 - if (ret) 1241 - return ret; 1239 + if (st->bops->sw_mode_config) { 1240 + ret = st->bops->sw_mode_config(indio_dev); 1241 + if (ret) 1242 + return ret; 1243 + } 1242 1244 1243 1245 /* Activate Burst mode and SEQEN MODE */ 1244 1246 return ad7606_write_mask(st, AD7616_CONFIGURATION_REGISTER, ··· 1269 1267 1270 1268 st->write_scale = ad7606_write_scale_sw; 1271 1269 st->write_os = &ad7606_write_os_sw; 1270 + 1271 + if (!st->bops->sw_mode_config) 1272 + return 0; 1272 1273 1273 1274 return st->bops->sw_mode_config(indio_dev); 1274 1275 }
+1 -1
drivers/iio/adc/ad7606_spi.c
··· 131 131 { 132 132 .tx_buf = &st->d16[0], 133 133 .len = 2, 134 - .cs_change = 0, 134 + .cs_change = 1, 135 135 }, { 136 136 .rx_buf = &st->d16[1], 137 137 .len = 2,
+1 -1
drivers/iio/adc/ad7768-1.c
··· 168 168 union { 169 169 struct { 170 170 __be32 chan; 171 - s64 timestamp; 171 + aligned_s64 timestamp; 172 172 } scan; 173 173 __be32 d32; 174 174 u8 d8[2];
+1 -1
drivers/iio/adc/dln2-adc.c
··· 466 466 struct iio_dev *indio_dev = pf->indio_dev; 467 467 struct { 468 468 __le16 values[DLN2_ADC_MAX_CHANNELS]; 469 - int64_t timestamp_space; 469 + aligned_s64 timestamp_space; 470 470 } data; 471 471 struct dln2_adc_get_all_vals dev_data; 472 472 struct dln2_adc *dln2 = iio_priv(indio_dev);
+3 -1
drivers/iio/adc/qcom-spmi-iadc.c
··· 543 543 else 544 544 return ret; 545 545 } else { 546 - device_init_wakeup(iadc->dev, 1); 546 + ret = devm_device_init_wakeup(iadc->dev); 547 + if (ret) 548 + return dev_err_probe(iadc->dev, ret, "Failed to init wakeup\n"); 547 549 } 548 550 549 551 ret = iadc_update_offset(iadc);
+8 -9
drivers/iio/adc/rockchip_saradc.c
··· 520 520 if (info->reset) 521 521 rockchip_saradc_reset_controller(info->reset); 522 522 523 - /* 524 - * Use a default value for the converter clock. 525 - * This may become user-configurable in the future. 526 - */ 527 - ret = clk_set_rate(info->clk, info->data->clk_rate); 528 - if (ret < 0) 529 - return dev_err_probe(&pdev->dev, ret, 530 - "failed to set adc clk rate\n"); 531 - 532 523 ret = regulator_enable(info->vref); 533 524 if (ret < 0) 534 525 return dev_err_probe(&pdev->dev, ret, ··· 546 555 if (IS_ERR(info->clk)) 547 556 return dev_err_probe(&pdev->dev, PTR_ERR(info->clk), 548 557 "failed to get adc clock\n"); 558 + /* 559 + * Use a default value for the converter clock. 560 + * This may become user-configurable in the future. 561 + */ 562 + ret = clk_set_rate(info->clk, info->data->clk_rate); 563 + if (ret < 0) 564 + return dev_err_probe(&pdev->dev, ret, 565 + "failed to set adc clk rate\n"); 549 566 550 567 platform_set_drvdata(pdev, indio_dev); 551 568
+3 -2
drivers/iio/chemical/pms7003.c
··· 5 5 * Copyright (c) Tomasz Duszynski <tduszyns@gmail.com> 6 6 */ 7 7 8 - #include <linux/unaligned.h> 9 8 #include <linux/completion.h> 10 9 #include <linux/device.h> 11 10 #include <linux/errno.h> ··· 18 19 #include <linux/module.h> 19 20 #include <linux/mutex.h> 20 21 #include <linux/serdev.h> 22 + #include <linux/types.h> 23 + #include <linux/unaligned.h> 21 24 22 25 #define PMS7003_DRIVER_NAME "pms7003" 23 26 ··· 77 76 /* Used to construct scan to push to the IIO buffer */ 78 77 struct { 79 78 u16 data[3]; /* PM1, PM2P5, PM10 */ 80 - s64 ts; 79 + aligned_s64 ts; 81 80 } scan; 82 81 }; 83 82
+1 -1
drivers/iio/chemical/sps30.c
··· 108 108 int ret; 109 109 struct { 110 110 s32 data[4]; /* PM1, PM2P5, PM4, PM10 */ 111 - s64 ts; 111 + aligned_s64 ts; 112 112 } scan; 113 113 114 114 mutex_lock(&state->lock);
+4
drivers/iio/common/hid-sensors/hid-sensor-attributes.c
··· 66 66 {HID_USAGE_SENSOR_HUMIDITY, 0, 1000, 0}, 67 67 {HID_USAGE_SENSOR_HINGE, 0, 0, 17453293}, 68 68 {HID_USAGE_SENSOR_HINGE, HID_USAGE_SENSOR_UNITS_DEGREES, 0, 17453293}, 69 + 70 + {HID_USAGE_SENSOR_HUMAN_PRESENCE, 0, 1, 0}, 71 + {HID_USAGE_SENSOR_HUMAN_PROXIMITY, 0, 1, 0}, 72 + {HID_USAGE_SENSOR_HUMAN_ATTENTION, 0, 1, 0}, 69 73 }; 70 74 71 75 static void simple_div(int dividend, int divisor, int *whole,
+1 -1
drivers/iio/imu/adis16550.c
··· 836 836 u16 dummy; 837 837 bool valid; 838 838 struct iio_poll_func *pf = p; 839 - __be32 data[ADIS16550_MAX_SCAN_DATA]; 839 + __be32 data[ADIS16550_MAX_SCAN_DATA] __aligned(8); 840 840 struct iio_dev *indio_dev = pf->indio_dev; 841 841 struct adis16550 *st = iio_priv(indio_dev); 842 842 struct adis *adis = iio_device_get_drvdata(indio_dev);
+2 -4
drivers/iio/imu/bmi270/bmi270_core.c
··· 918 918 FIELD_PREP(BMI270_ACC_CONF_ODR_MSK, 919 919 BMI270_ACC_CONF_ODR_100HZ) | 920 920 FIELD_PREP(BMI270_ACC_CONF_BWP_MSK, 921 - BMI270_ACC_CONF_BWP_NORMAL_MODE) | 922 - BMI270_PWR_CONF_ADV_PWR_SAVE_MSK); 921 + BMI270_ACC_CONF_BWP_NORMAL_MODE)); 923 922 if (ret) 924 923 return dev_err_probe(dev, ret, "Failed to configure accelerometer"); 925 924 ··· 926 927 FIELD_PREP(BMI270_GYR_CONF_ODR_MSK, 927 928 BMI270_GYR_CONF_ODR_200HZ) | 928 929 FIELD_PREP(BMI270_GYR_CONF_BWP_MSK, 929 - BMI270_GYR_CONF_BWP_NORMAL_MODE) | 930 - BMI270_PWR_CONF_ADV_PWR_SAVE_MSK); 930 + BMI270_GYR_CONF_BWP_NORMAL_MODE)); 931 931 if (ret) 932 932 return dev_err_probe(dev, ret, "Failed to configure gyroscope"); 933 933
+1 -1
drivers/iio/imu/inv_mpu6050/inv_mpu_ring.c
··· 50 50 u16 fifo_count; 51 51 u32 fifo_period; 52 52 s64 timestamp; 53 - u8 data[INV_MPU6050_OUTPUT_DATA_SIZE]; 53 + u8 data[INV_MPU6050_OUTPUT_DATA_SIZE] __aligned(8); 54 54 size_t i, nb; 55 55 56 56 mutex_lock(&st->lock);
+6
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_buffer.c
··· 392 392 if (fifo_status & cpu_to_le16(ST_LSM6DSX_FIFO_EMPTY_MASK)) 393 393 return 0; 394 394 395 + if (!pattern_len) 396 + pattern_len = ST_LSM6DSX_SAMPLE_SIZE; 397 + 395 398 fifo_len = (le16_to_cpu(fifo_status) & fifo_diff_mask) * 396 399 ST_LSM6DSX_CHAN_SIZE; 397 400 fifo_len = (fifo_len / pattern_len) * pattern_len; ··· 625 622 ST_LSM6DSX_TAGGED_SAMPLE_SIZE; 626 623 if (!fifo_len) 627 624 return 0; 625 + 626 + if (!pattern_len) 627 + pattern_len = ST_LSM6DSX_TAGGED_SAMPLE_SIZE; 628 628 629 629 for (read_len = 0; read_len < fifo_len; read_len += pattern_len) { 630 630 err = st_lsm6dsx_read_block(hw,
+5 -2
drivers/iio/imu/st_lsm6dsx/st_lsm6dsx_core.c
··· 2719 2719 } 2720 2720 2721 2721 if (device_property_read_bool(dev, "wakeup-source") || 2722 - (pdata && pdata->wakeup_source)) 2723 - device_init_wakeup(dev, true); 2722 + (pdata && pdata->wakeup_source)) { 2723 + err = devm_device_init_wakeup(dev); 2724 + if (err) 2725 + return dev_err_probe(dev, err, "Failed to init wakeup\n"); 2726 + } 2724 2727 2725 2728 return 0; 2726 2729 }
+14 -8
drivers/iio/light/hid-sensor-prox.c
··· 34 34 struct iio_chan_spec channels[MAX_CHANNELS]; 35 35 u32 channel2usage[MAX_CHANNELS]; 36 36 u32 human_presence[MAX_CHANNELS]; 37 - int scale_pre_decml; 38 - int scale_post_decml; 39 - int scale_precision; 37 + int scale_pre_decml[MAX_CHANNELS]; 38 + int scale_post_decml[MAX_CHANNELS]; 39 + int scale_precision[MAX_CHANNELS]; 40 40 unsigned long scan_mask[2]; /* One entry plus one terminator. */ 41 41 int num_channels; 42 42 }; ··· 116 116 ret_type = IIO_VAL_INT; 117 117 break; 118 118 case IIO_CHAN_INFO_SCALE: 119 - *val = prox_state->scale_pre_decml; 120 - *val2 = prox_state->scale_post_decml; 121 - ret_type = prox_state->scale_precision; 119 + if (chan->scan_index >= prox_state->num_channels) 120 + return -EINVAL; 121 + 122 + *val = prox_state->scale_pre_decml[chan->scan_index]; 123 + *val2 = prox_state->scale_post_decml[chan->scan_index]; 124 + ret_type = prox_state->scale_precision[chan->scan_index]; 122 125 break; 123 126 case IIO_CHAN_INFO_OFFSET: 124 - *val = hid_sensor_convert_exponent( 125 - prox_state->prox_attr[chan->scan_index].unit_expo); 127 + *val = 0; 126 128 ret_type = IIO_VAL_INT; 127 129 break; 128 130 case IIO_CHAN_INFO_SAMP_FREQ: ··· 251 249 st->prox_attr[index].size); 252 250 dev_dbg(&pdev->dev, "prox %x:%x\n", st->prox_attr[index].index, 253 251 st->prox_attr[index].report_id); 252 + st->scale_precision[index] = 253 + hid_sensor_format_scale(usage_id, &st->prox_attr[index], 254 + &st->scale_pre_decml[index], 255 + &st->scale_post_decml[index]); 254 256 index++; 255 257 } 256 258
+3 -2
drivers/iio/light/opt3001.c
··· 788 788 int ret; 789 789 bool wake_result_ready_queue = false; 790 790 enum iio_chan_type chan_type = opt->chip_info->chan_type; 791 + bool ok_to_ignore_lock = opt->ok_to_ignore_lock; 791 792 792 - if (!opt->ok_to_ignore_lock) 793 + if (!ok_to_ignore_lock) 793 794 mutex_lock(&opt->lock); 794 795 795 796 ret = i2c_smbus_read_word_swapped(opt->client, OPT3001_CONFIGURATION); ··· 827 826 } 828 827 829 828 out: 830 - if (!opt->ok_to_ignore_lock) 829 + if (!ok_to_ignore_lock) 831 830 mutex_unlock(&opt->lock); 832 831 833 832 if (wake_result_ready_queue)
+6 -11
drivers/iio/pressure/mprls0025pa.h
··· 34 34 struct mpr_data; 35 35 struct mpr_ops; 36 36 37 - /** 38 - * struct mpr_chan 39 - * @pres: pressure value 40 - * @ts: timestamp 41 - */ 42 - struct mpr_chan { 43 - s32 pres; 44 - s64 ts; 45 - }; 46 - 47 37 enum mpr_func_id { 48 38 MPR_FUNCTION_A, 49 39 MPR_FUNCTION_B, ··· 59 69 * reading in a loop until data is ready 60 70 * @completion: handshake from irq to read 61 71 * @chan: channel values for buffered mode 72 + * @chan.pres: pressure value 73 + * @chan.ts: timestamp 62 74 * @buffer: raw conversion data 63 75 */ 64 76 struct mpr_data { ··· 79 87 struct gpio_desc *gpiod_reset; 80 88 int irq; 81 89 struct completion completion; 82 - struct mpr_chan chan; 90 + struct { 91 + s32 pres; 92 + aligned_s64 ts; 93 + } chan; 83 94 u8 buffer[MPR_MEASUREMENT_RD_SIZE] __aligned(IIO_DMA_MINALIGN); 84 95 }; 85 96
+1 -1
drivers/iio/temperature/maxim_thermocouple.c
··· 121 121 struct maxim_thermocouple_data { 122 122 struct spi_device *spi; 123 123 const struct maxim_thermocouple_chip *chip; 124 + char tc_type; 124 125 125 126 u8 buffer[16] __aligned(IIO_DMA_MINALIGN); 126 - char tc_type; 127 127 }; 128 128 129 129 static int maxim_thermocouple_read(struct maxim_thermocouple_data *data,
+1 -1
drivers/staging/iio/adc/ad7816.c
··· 136 136 struct iio_dev *indio_dev = dev_to_iio_dev(dev); 137 137 struct ad7816_chip_info *chip = iio_priv(indio_dev); 138 138 139 - if (strcmp(buf, "full")) { 139 + if (strcmp(buf, "full") == 0) { 140 140 gpiod_set_value(chip->rdwr_pin, 1); 141 141 chip->mode = AD7816_FULL; 142 142 } else {
+17 -22
drivers/uio/uio_hv_generic.c
··· 131 131 vmbus_device_unregister(channel->device_obj); 132 132 } 133 133 134 - /* Sysfs API to allow mmap of the ring buffers 134 + /* Function used for mmap of ring buffer sysfs interface. 135 135 * The ring buffer is allocated as contiguous memory by vmbus_open 136 136 */ 137 - static int hv_uio_ring_mmap(struct file *filp, struct kobject *kobj, 138 - const struct bin_attribute *attr, 139 - struct vm_area_struct *vma) 137 + static int 138 + hv_uio_ring_mmap(struct vmbus_channel *channel, struct vm_area_struct *vma) 140 139 { 141 - struct vmbus_channel *channel 142 - = container_of(kobj, struct vmbus_channel, kobj); 143 140 void *ring_buffer = page_address(channel->ringbuffer_page); 144 141 145 142 if (channel->state != CHANNEL_OPENED_STATE) ··· 145 148 return vm_iomap_memory(vma, virt_to_phys(ring_buffer), 146 149 channel->ringbuffer_pagecount << PAGE_SHIFT); 147 150 } 148 - 149 - static const struct bin_attribute ring_buffer_bin_attr = { 150 - .attr = { 151 - .name = "ring", 152 - .mode = 0600, 153 - }, 154 - .size = 2 * SZ_2M, 155 - .mmap = hv_uio_ring_mmap, 156 - }; 157 151 158 152 /* Callback from VMBUS subsystem when new channel created. */ 159 153 static void ··· 166 178 /* Disable interrupts on sub channel */ 167 179 new_sc->inbound.ring_buffer->interrupt_mask = 1; 168 180 set_channel_read_mode(new_sc, HV_CALL_ISR); 169 - 170 - ret = sysfs_create_bin_file(&new_sc->kobj, &ring_buffer_bin_attr); 181 + ret = hv_create_ring_sysfs(new_sc, hv_uio_ring_mmap); 171 182 if (ret) { 172 183 dev_err(device, "sysfs create ring bin file failed; %d\n", ret); 173 184 vmbus_close(new_sc); ··· 337 350 goto fail_close; 338 351 } 339 352 340 - ret = sysfs_create_bin_file(&channel->kobj, &ring_buffer_bin_attr); 341 - if (ret) 342 - dev_notice(&dev->device, 343 - "sysfs create ring bin file failed; %d\n", ret); 353 + /* 354 + * This internally calls sysfs_update_group, which returns a non-zero value if it executes 355 + * before sysfs_create_group. This is expected as the 'ring' will be created later in 356 + * vmbus_device_register() -> vmbus_add_channel_kobj(). Thus, no need to check the return 357 + * value and print warning. 358 + * 359 + * Creating/exposing sysfs in driver probe is not encouraged as it can lead to race 360 + * conditions with userspace. For backward compatibility, "ring" sysfs could not be removed 361 + * or decoupled from uio_hv_generic probe. Userspace programs can make use of inotify 362 + * APIs to make sure that ring is created. 363 + */ 364 + hv_create_ring_sysfs(channel, hv_uio_ring_mmap); 344 365 345 366 hv_set_drvdata(dev, pdata); 346 367 ··· 370 375 if (!pdata) 371 376 return; 372 377 373 - sysfs_remove_bin_file(&dev->channel->kobj, &ring_buffer_bin_attr); 378 + hv_remove_ring_sysfs(dev->channel); 374 379 uio_unregister_device(&pdata->info); 375 380 hv_uio_cleanup(dev, pdata); 376 381
+6
include/linux/hyperv.h
··· 1002 1002 1003 1003 /* The max size of a packet on this channel */ 1004 1004 u32 max_pkt_size; 1005 + 1006 + /* function to mmap ring buffer memory to the channel's sysfs ring attribute */ 1007 + int (*mmap_ring_buffer)(struct vmbus_channel *channel, struct vm_area_struct *vma); 1008 + 1009 + /* boolean to control visibility of sysfs for ring buffer */ 1010 + bool ring_sysfs_visible; 1005 1011 }; 1006 1012 1007 1013 #define lock_requestor(channel, flags) \