summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2020-04-19iio: move 'indio_dev->info' null check first in __iio_device_register()Alexandru Ardelean1-3/+3
Moves this to be the first check, as it's very simple and fails the registration earlier, instead of potentially initializing the 'indio_dev->label' and checking for duplicate indexes, and then failing with this simple-check. This is a minor optimization, since '__iio_device_register()' will waste fewer validation cycles in case 'indio_dev->info' is NULL. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: buffer: remove 'scan_el_attrs' attribute group from buffer structAlexandru Ardelean2-14/+0
This field doesn't seem used. It seems that only 'buffer->attrs' was ever used to extend sysfs attributes for an IIO buffer. Moving forward, it may not make sense to keep it. This patch removes the field and it's initialization code. Since we want to rework IIO buffer, to be able to add more buffers per IIO device, we will merge [somehow] the 'buffer' & 'scan_elements' groups, and we will continue to add the attributes to the 'buffer' group. Removing it here, will also make the rework here a bit smaller, since this code will not be present. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: adis: Add a missing '\n' in a log messageChristophe JAILLET1-1/+1
Message logged by 'dev_xxx()' or 'pr_xxx()' should end with a '\n'. Fixes: 1fd456702692 ("iio: imu: adis: add support product ID check in adis_initial_startup") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: xilinx-xadc: Fix typoLars-Peter Clausen1-1/+1
Fix a typo. 'at the a time' -> 'at a time'. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: adc: rockchip-saradc: add description for px30Johan Jonker1-0/+1
The description below is already in use for px30.dtsi, but was somehow never added to a document, so add "rockchip,px30-saradc", "rockchip,rk3399-saradc" for saradc nodes on a px30 platform to rockchip-saradc.yaml. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: adc: rockchip-saradc: add description for rk3308Johan Jonker1-0/+1
The description below is already in use for rk3308.dtsi, but was somehow never added to a document, so add "rockchip,rk3308-saradc", "rockchip,rk3399-saradc" for saradc nodes on a rk3308 platform to rockchip-saradc.yaml. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: adc: convert rockchip saradc bindings to yamlJohan Jonker2-37/+78
Current dts files with 'saradc' nodes are manually verified. In order to automate this process rockchip-saradc.txt has to be converted to yaml. Signed-off-by: Johan Jonker <jbx6244@gmail.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: dma-buffer: Cleanup buffer.h/buffer_impl.h includesLars-Peter Clausen2-2/+1
The IIO DMA buffer is a DMA buffer implementation. As such it should include buffer_impl.h rather than buffer.h. The include to buffer.h in buffer-dma.h should be buffer_impl.h so it has access to the struct iio_buffer definition. The code currently only works because all places that use buffer-dma.h include buffer_impl.h before it. The include to buffer.h in industrialio-buffer-dma.c can be removed since those file does not reference any of buffer consumer functions. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: adc: Add MAX1241 driverAlexandru Lazar3-0/+238
Add driver for the Maxim MAX1241 12-bit, single-channel ADC. Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1240-MAX1241.pdf Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Alexandru Lazar <alazar@startmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: adc: Add MAX1241 bindingsAlexandru Lazar1-0/+63
Add device-tree bindings documentation for the MAX1241 device driver. Signed-off-by: Alexandru Lazar <alazar@startmail.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: accel: st_sensors: add support for LIS2HH12Gaëtan André4-1/+85
Add support for STMicroelectronics LISHH12 accelerometer in st_accel framework. https://www.st.com/resource/en/datasheet/lis2hh12.pdf Signed-off-by: Gaëtan André <rvlander@gaetanandre.eu> Reviewed-by: Stephan Gerhold <stephan@gerhold.net> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: st_sensors: add st,lis2hh12 compatible entryGaëtan André1-0/+1
Add LIS2HH12 compatible entry. Signed-off-by: Gaëtan André <rvlander@gaetanandre.eu> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: st_lsm6dsx: Add sensor hub device LIS3MDLJimmy Assarsson1-0/+64
Add LIS3MDL register map to sensor hub device table. Tested with LSM6DSM. Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: st_lsm6dsx: Increase ODR_LIST_SIZEJimmy Assarsson1-1/+1
Support for sensor with up to 8 different ODR settings. Required for supporting LIS3MDL as sensor hub slave device. Signed-off-by: Jimmy Assarsson <jimmyassarsson@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: adis16460: use DEFINE_DEBUGFS_ATTRIBUTE instead of ↵Rohit Sarkar1-12/+15
DEFINE_SIMPLE_ATTRIBUTE debugfs_create_file_unsafe does not protect the fops handed to it against file removal. DEFINE_DEBUGFS_ATTRIBUTE makes the fops aware of the file lifetime and thus protects it against removal. Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> Tested-by Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: adis16400: use DEFINE_DEBUGFS_ATTRIBUTE instead of ↵Rohit Sarkar1-9/+10
DEFINE_SIMPLE_ATTRIBUTE debugfs_create_file_unsafe does not protect the fops handed to it against file removal. DEFINE_DEBUGFS_ATTRIBUTE makes the fops aware of the file lifetime and thus protects it against removal. Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> Tested-by Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: st_lsm6dsx: configure full scale on slave device if supportedLorenzo Bianconi1-0/+33
Introduce st_lsm6dsx_shub_set_full_scale routine in order to configure the i2c slave device sensitivity Tested-by: Jimmy Assarsson <jimmyassarsson@gmail.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: dac: stm32-dac: convert bindings to json-schemaFabrice Gasnier2-63/+110
Convert the STM32 DAC binding to DT schema format using json-schema Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: tsl2563: convert bindings to YAMLNishant Malpani2-19/+49
Convert the TSL2563 device tree bindings to the new YAML format. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: adc: add bindings doc for AD9467 ADCAlexandru Ardelean1-0/+65
This change adds the binding doc for the AD9467 ADC. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: adc: ad9467: add support AD9467 ADCMichael Hennerich3-0/+438
The AD9467 is a 16-bit, monolithic, IF sampling analog-to-digital converter (ADC). It is optimized for high performanceover wide bandwidths and ease of use. The product operates at a 250 MSPS conversion rate and is designed for wireless receivers, instrumentation, and test equipment that require a high dynamic range. The ADC requires 1.8 V and 3.3 V power supplies and a low voltage differential input clock for full performance operation. No external reference or driver components are required for many applications. Data outputs are LVDS compatible (ANSI-644 compatible) and include the means to reduce the overall current needed for short trace distances. Since the chip can operate at such high sample-rates (much higher than classical interfaces), it requires that a DMA controller be used to interface directly to the chip and push data into memory. Typically, the AXI ADC IP core is used to interface with it. Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD9467.pdf Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19dt-bindings: iio: adc: add bindings doc for AXI ADC driverAlexandru Ardelean1-0/+62
This change adds the bindings documentation for the AXI ADC driver. Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: adc: adi-axi-adc: add support for AXI ADC IP coreMichael Hennerich4-0/+567
This change adds support for the Analog Devices Generic AXI ADC IP core. The IP core is used for interfacing with analog-to-digital (ADC) converters that require either a high-speed serial interface (JESD204B/C) or a source synchronous parallel interface (LVDS/CMOS). Usually, some other interface type (i.e SPI) is used as a control interface for the actual ADC, while the IP core (controlled via this driver), will interface to the data-lines of the ADC and handle the streaming of data into memory via DMA. Because of this, the AXI ADC driver needs the other SPI-ADC driver to register with it. The SPI-ADC needs to be register via the SPI framework, while the AXI ADC registers as a platform driver. The two cannot be ordered in a hierarchy as both drivers have their own registers, and trying to organize this [in a hierarchy becomes] problematic when trying to map memory/registers. There are some modes where the AXI ADC can operate as standalone ADC, but those will be implemented at a later point in time. DocLink: https://wiki.analog.com/resources/fpga/docs/axi_adc_ip Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: buffer-dmaengine: add dev-managed calls for buffer allocAlexandru Ardelean2-0/+42
Currently, when using a 'iio_dmaengine_buffer_alloc()', an matching call to 'iio_dmaengine_buffer_free()' must be made. With this change, this can be avoided by using 'devm_iio_dmaengine_buffer_alloc()'. The buffer will get free'd via the device's devres handling. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: buffer-dmaengine: use %zu specifier for sprintf(align)Alexandru Ardelean1-1/+1
The 'size_t' type behaves differently on 64-bit architectures, and causes compiler a warning of the sort "format '%u' expects argument of type 'unsigned int', but argument 3 has type 'size_t {aka long unsigned int}'". This change adds the correct specifier for the 'align' field. Fixes: 4538c18568099 ("iio: buffer-dmaengine: Report buffer length requirements") Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19include: fpga: adi-axi-common.h: add version helper macrosAlexandru Ardelean1-0/+4
The format for all ADI AXI IP cores is the same. i.e. 'major.minor.patch'. This patch adds the helper macros to be re-used in ADI AXI drivers. Acked-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19include: fpga: adi-axi-common.h: fixup whitespace tab -> spaceAlexandru Ardelean1-1/+1
The initial version use a tab between '#define' & 'ADI_AXI_REG_VERSION'. This changes it to space. The change is purely cosmetic. Acked-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: buffer: drop left-over 'stufftoread' fieldAlexandru Ardelean1-3/+0
This seems like a left-over from a7348347ba8a4 ("staging:iio: Add polling of events on the ring access chrdev."). Then it was moved into the sca3000 driver around 9dd4694dafbd8 ("iio: staging: sca3000: hide stufftoread logic"), and that one seemed to be the only user of this. Then it eventually was no longer used after 152a6a884ae1 ("staging:iio:accel:sca3000 move to hybrid hard / soft buffer design.") Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: temperature: ltc2983: remove redundant comparison to boolRohit Sarkar1-2/+2
Remove redundant comparison to a boolean variable. Fixes coccinelle warning: drivers/iio/temperature//ltc2983.c:393:20-32: WARNING: Comparison to bool drivers/iio/temperature//ltc2983.c:394:20-32: WARNING: Comparison to bool Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: inv_mpu6050: add debugfs register r/w interfaceRohit Sarkar1-0/+19
The debugfs interface provides direct access to read and write device registers if debugfs is enabled. Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Join string literals backAndy Shevchenko1-2/+1
For easy grepping on debug purposes join string literals back in the messages. No functional change. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Drop unneeded explicit castingsAndy Shevchenko1-10/+7
In few places the unnecessary explicit castings are being used. Drop them for good. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Explicitly mark GPIO optionalAndy Shevchenko1-2/+2
Show by using a corresponding API call that GPIO is optional. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Convert to use ->read_avail()Andy Shevchenko1-44/+25
Convert to use ->read_avail() instead of open-coded attribute handling. Suggested-by: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: pressure: bmp280: Tolerate IRQ before registeringAndy Shevchenko1-1/+4
With DEBUG_SHIRQ enabled we have a kernel crash [ 116.482696] BUG: kernel NULL pointer dereference, address: 0000000000000000 ... [ 116.606571] Call Trace: [ 116.609023] <IRQ> [ 116.611047] complete+0x34/0x50 [ 116.614206] bmp085_eoc_irq+0x9/0x10 [bmp280] because DEBUG_SHIRQ mechanism fires an IRQ before registration and drivers ought to be able to handle an interrupt happening before request_irq() returns. Fixes: aae953949651 ("iio: pressure: bmp280: add support for BMP085 EOC interrupt") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: inv_mpu6050: convert to use i2c_new_client_device()Wolfram Sang1-3/+5
Move away from the deprecated API and return the shiny new ERRPTR where useful. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Acked-by: Jean-Baptiste Maneyrol <jmaneyrol@invensense.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: magn: bmc150: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: inv_mpu6050_spi: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: inv_mpu6050_i2c: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: bmi160_spi: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: imu: bmi160_i2c: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: gyro: mpu3050: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: gyro: bmg160_spi: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: gyro: bmg160_i2c: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: accel: kxsd9: Use vsprintf extension %pe for symbolic error nameNishant Malpani1-2/+2
Utilize %pe format specifier from vsprintf while printing error logs with dev_err(). Discards the use of unnecessary explicit casting and prints symbolic error name which might prove to be convenient during debugging. Signed-off-by: Nishant Malpani <nish.malpani25@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: adc: ad7793: use read_avail iio hook for scale availableAlexandru Ardelean1-18/+37
This change uses the read_avail and '.info_mask_shared_by_type_available' modifier to set the available scale. Essentially, nothing changes to the driver's ABI. The main idea for this patch is to remove the AD7793 driver from checkpatch's radar. There have been about ~3 attempts to fix/break the 'in_voltage-voltage_scale_available' attribute, because checkpatch assumed it to be an arithmetic operation and people were trying to change that. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: buffer: Don't allow buffers without any channels enabled to be activatedLars-Peter Clausen1-0/+7
Before activating a buffer make sure that at least one channel is enabled. Activating a buffer with 0 channels enabled doesn't make too much sense and disallowing this case makes sure that individual driver don't have to add special case code to handle it. Currently, without this patch enabling a buffer is possible and no error is produced. With this patch -EINVAL is returned. An example of execution with this patch and some instrumented print-code: root@analog:~# cd /sys/bus/iio/devices/iio\:device3/buffer root@analog:/sys/bus/iio/devices/iio:device3/buffer# echo 1 > enable 0: iio_verify_update 748 indio_dev->masklength 2 *insert_buffer->scan_mask 00000000 1: iio_verify_update 753 2:__iio_update_buffers 1115 ret -22 3: iio_buffer_store_enable 1241 ret -22 -bash: echo: write error: Invalid argument 1, 2 & 3 are exit-error paths. 0 the first print in iio_verify_update() rergardless of error path. Without this patch (and same instrumented print-code): root@analog:~# cd /sys/bus/iio/devices/iio\:device3/buffer root@analog:/sys/bus/iio/devices/iio:device3/buffer# echo 1 > enable 0: iio_verify_update 748 indio_dev->masklength 2 *insert_buffer->scan_mask 00000000 root@analog:/sys/bus/iio/devices/iio:device3/buffer# Buffer is enabled with no error. Note from Jonathan: Probably not suitable for automatic application to stable. This has been there from the very start. It tidies up an odd corner case but won't effect any 'real' users. Fixes: 84b36ce5f79c0 ("staging:iio: Add support for multiple buffers") Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: tsl2772: Use scnprintf() for avoiding potential buffer overflowTakashi Iwai1-3/+3
snprintf() is a hard-to-use function, it's especially difficult to use it for concatenating substrings in a buffer with a limited size. Since snprintf() returns the would-be-output size, not the actual size, the subsequent use of snprintf() may go beyond the given limit easily. Although the current code doesn't actually overflow the buffer, it's an incorrect usage. This patch replaces such snprintf() calls with a safer version, scnprintf(). Also this fixes the incorrect argument of the buffer limit size passed to snprintf(), too. The size has to be decremented for the remaining length. Signed-off-by: Takashi Iwai <tiwai@suse.de> Reviewed-by: Brian Masney <masneyb@onstation.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: adc: max1363: replace uses of mlockRohit Sarkar1-9/+23
Replace usage indio_dev's mlock with either local lock or iio_device_claim_direct_mode. Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19iio: health: max30100: use generic property handlerRohit Sarkar1-4/+3
Instead of of_property_read_xxx use device_property_read_xxx as it is compatible with ACPI too as opposed to only device tree. Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>