summaryrefslogtreecommitdiffstats
path: root/drivers/iio
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'staging-5.8-rc1' of ↵Linus Torvalds2020-06-07150-1222/+6948
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging Pull staging/IIO driver updates from Greg KH: "Here is the large set of staging and IIO driver changes for 5.8-rc1 Nothing major, but a lot of new IIO drivers are included in here, along with other core iio cleanups and changes. On the staging driver front, again, nothing noticable. No new deletions or additions, just a ton of tiny cleanups all over the tree done by a lot of different people. Most coding style, but many actual real fixes and cleanups that are nice to see. All of these have been in linux-next for a while with no reported issues" * tag 'staging-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (618 commits) staging: rtl8723bs: Use common packet header constants staging: sm750fb: Add names to proc_setBLANK args staging: most: usb: init return value in default path of switch/case expression staging: vchiq: Get rid of VCHIQ_SERVICE_OPENEND callback reason staging: vchiq: move vchiq_release_message() into vchiq staging: vchi: Get rid of C++ guards staging: vchi: Get rid of not implemented function declarations staging: vchi: Get rid of vchiq_status_to_vchi() staging: vchi: Get rid of vchi_service_set_option() staging: vchi: Merge vchi_msg_queue() into vchi_queue_kernel_message() staging: vchiq: Move copy callback handling into vchiq staging: vchi: Get rid of vchi_queue_user_message() staging: vchi: Get rid of vchi_service_destroy() staging: most: usb: use function sysfs_streq staging: most: usb: add missing put_device calls staging: most: usb: use correct error codes staging: most: usb: replace code to calculate array index staging: most: usb: don't use error path to exit function on success staging: most: usb: move allocation of URB out of critical section staging: most: usb: return 0 instead of variable ...
| * Merge 5.7-rc7 into staging-nextGreg Kroah-Hartman2020-05-257-21/+40
| |\ | | | | | | | | | | | | | | | We need the staging/iio fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
| * | iio:chemical:pms7003: Fix timestamp alignment and prevent data leak.Jonathan Cameron2020-05-221-5/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. As Lars also noted this anti pattern can involve a leak of data to userspace and that indeed can happen here. We close both issues by moving to a suitable structure in the iio_priv() data with alignment explicitly requested. This data is allocated with kzalloc so no data can leak appart from previous readings. Fixes: a1d642266c14 ("iio: chemical: add support for Plantower PMS7003 sensor") Reported-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: <Stable@vger.kernel.org> Acked-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
| * | iio:chemical:sps30: Fix timestamp alignmentJonathan Cameron2020-05-221-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | One of a class of bugs pointed out by Lars in a recent review. iio_push_to_buffers_with_timestamp assumes the buffer used is aligned to the size of the timestamp (8 bytes). This is not guaranteed in this driver which uses an array of smaller elements on the stack. Fixes: 232e0f6ddeae ("iio: chemical: add support for Sensirion SPS30 sensor") Reported-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: <Stable@vger.kernel.org> Acked-by: Tomasz Duszynski <tomasz.duszynski@octakon.com>
| * | iio: adc: stm32-adc: fix a wrong error message when probing interruptsFabrice Gasnier2020-05-221-20/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A wrong error message is printed out currently, like on STM32MP15: - stm32-adc-core 48003000.adc: IRQ index 2 not found. This is seen since commit 7723f4c5ecdb ("driver core: platform: Add an error message to platform_get_irq*()"). The STM32 ADC core driver wrongly requests up to 3 interrupt lines. It should request only the necessary IRQs, based on the compatible: - stm32f4/h7 ADCs share a common interrupt - stm32mp1, has one interrupt line per ADC. So add the number of required interrupts to the compatible data. Fixes: d58c67d1d851 ("iio: adc: stm32-adc: add support for STM32MP1") Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: light: gp2ap002: Take runtime PM reference on light readJonathan Bakker2020-05-221-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The light sensor needs the regulators to be enabled which means the runtime PM needs to be on. This only happened when the proximity part of the chip was enabled. As fallout from this change, only report changes to the prox state in the interrupt handler when it is explicitly enabled. Fixes: 97d642e23037 ("iio: light: Add a driver for Sharp GP2AP002x00F") Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: proximity: ping: pass reference to IIO device as param to ping_read()Alexandru Ardelean2020-05-211-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since there will be some changes to how iio_priv_to_dev() is implemented, it could be that the helper becomes a bit slower, as it will be hidden away in the IIO core. But even without that rework, this looks like it can pass the 'indio_dev' object to ping_read() and obtain the state struct via iio_priv() which is a preferred practice than going back-n-forth (getting the state-struct, then using iio_priv_to_dev() to get the indio_dev object back). Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5592r-base: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-212-15/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. This also removes unused iio_dev pointers. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: proximity: Add driver support for vcnl3020 proximity sensorIvan Mikhaylov2020-05-213-0/+270
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Proximity sensor driver based on light/vcnl4000.c code. For now supports only the single on-demand measurement. The VCNL3020 is a fully integrated proximity sensor. Fully integrated means that the infrared emitter is included in the package. It has 16-bit resolution. It includes a signal processing IC and features standard I2C communication interface. It features an interrupt function. Datasheet: http://www.vishay.com/docs/84150/vcnl3020.pdf Signed-off-by: Ivan Mikhaylov <i.mikhaylov@yadro.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: buffer: remove attrcount_orig var from sysfs creationAlexandru Ardelean2020-05-161-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The variable no longer does anything. It should have been removed with commit 2e036804d773e ("iio: buffer: remove 'scan_el_attrs' attribute group from buffer struct"). That was about the last time this was needed. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: chemical: add atlas-ezo-sensor initial supportMatt Ranostay2020-05-163-0/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | Add driver for Atlas EZO line of sensors with initial support for CO2 the sensor. This is effectively ASCII strings proxied over I2C due to these series of sensors being by default UART. Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: adc: exynos: Simplify Exynos7-specific initKrzysztof Kozlowski2020-05-161-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Exynos7-specific code bits in ADC driver do not play with PHY: the field exynos_adc_data.needs_adc_phy is not set in exynos7_adc_data instance. Therefore the initialization code does not have to check if it is true. Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Tested-by: Alim Akhtar <alim.akhtar@samsung.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: adc: Add scaling support to exynos adc driverJonathan Bakker2020-05-161-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the driver only exposes the raw counts. As we have the regulator voltage and the maximum value (stored in the data mask), we can trivially produce a scaling fraction of voltage / max value. This assumes that the regulator voltage is in fact the max voltage, which appears to be the case for all mainline dts and cross referenced with the public Exynos4412 and S5PV210 datasheets. Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: __iio_update_buffers: Update mode before preenable/after postdisableLars-Peter Clausen2020-05-161-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is clear that we transition to INDIO_DIRECT_MODE when disabling the buffer(s) and it is also clear that we transition from INDIO_DIRECT_MODE when enabling the buffer(s). So leaving the currentmode field INDIO_DIRECT_MODE until after the preenable() callback and updating it to INDIO_DIRECT_MODE before the postdisable() callback doesn't add additional value. On the other hand some drivers will need to perform different actions depending on which mode the device is going to operate in/was operating in. Moving the update of currentmode before preenable() and after postdisable() enables us to have drivers which perform mode dependent actions in those callbacks. Note, was originally not intended as such, but fixes an issue introduced in the at91-sama5d2 adc driver. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Fixes: 065056cb0d0a ("iio: at91-sama5d2_adc: split at91_adc_current_chan_is_touch() helper") Tested-by: Eugen Hristev <eugen.hristev@microchip.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: vf610_dac: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5686: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-162-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5421: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5380: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5764: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5761: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5755: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-8/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. This also changes some internal functions to pass the pointer to the state-struct vs a ref to indio_dev just to access the state-struct again. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5449: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5446: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: dac: ad5360: Replace indio_dev->mlock with own device lockSergiu Cuciurean2020-05-161-6/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As part of the general cleanup of indio_dev->mlock, this change replaces it with a local lock on the device's state structure. This also changes some internal functions to pass the pointer to the state-struct vs a ref to indio_dev just to access the state-struct again. Signed-off-by: Sergiu Cuciurean <sergiu.cuciurean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: accel: Add bma150/smb380 support to bma180Jonathan Bakker2020-05-162-7/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | The bma150/smb380 are very similar to the bma023 but have a temperature channel as well. Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: accel: bma180: Rename center_temp to temp_offsetJonathan Bakker2020-05-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bma180 driver is being extended to support the bma150. Its temperature channel is unsigned so the center_temp naming no longer makes. Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: accel: bma180: Add support for bma023Jonathan Bakker2020-05-162-7/+122
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bma023 chip is similar enough to the bma180 and bma25x that the same driver can support all of them. The biggest differences are the lack of a temperature channel and no low power but still working mode. The bma150 is a close relative of the bma023, but it does have a temperature channel so support is not added for it. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: accel: Make bma180 conflict with input's bma150Jonathan Bakker2020-05-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bma180 IIO driver is being extended for support for the chips support by input's bma150 driver (bma023, bma150, smb380). Don't allow both drivers to be enabled simultaneously as they're for the same hardware. Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | iio: accel: bma180: Prepare for different reset valuesJonathan Bakker2020-05-161-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some variants of the bma180 (eg bma023) have different reset values. In preparation for adding support for them, factor out the reset value into the chip specific data. Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Bakker <xc-racer2@live.ca> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| * | Merge tag 'iio-for-5.8b' of ↵Greg Kroah-Hartman2020-05-1564-606/+3127
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Second set of new device support, cleanups and features for IIO in the 5.8 cycle Usual mixed back but with a few subsystem wide or device type wide cleanups. New device support * adis16475 - New driver supporting adis16470, adis16475, adis16477, adis16465, adis16467, adis16500, adis16505 and adis16507. Includes some rework of the adis library to simplify using it for this new driver. * ak8974 - Add support for Alps hscdt008a. ID only. Related patches add support for scale. * atlas-sensor - Add support for RTD-SM OEM temperature sensor. * cm32181 - Add support for CM3218 including support for SMBUS alert via ACPI resources. * ltc2632 - Add support for ltc2634-12/10/8 DACS including handling per device type numbers of channels. Major Features * cm32181 - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables. Includes minor tidy ups and fixes. * vcnl4000 - Add event support - Add buffered data capture support - Add control of sampling frequency Cleanups and minor fixes. * core - Trivial rework of iio_device_alloc to use an early return and improve readability. - Precursors to addition of multiple buffer support. So far minor refactoring. * subsystem wide - Use get_unaligned_be24 slightly improve readability over open coding it. * adis drivers - Use iio_get_debugfs_dentry access function. * bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180, dmard06, kxsd9 - Drop use of of_match_ptr to allow ACPI based probing via PRP0001. Part of clear out of this to avoid cut and paste into new drivers. * ad5592r, ad5593r - Fix typos * ad5933 - Use managed interfaces to automate error handling and remove. * ak8974 - Fix wrong number of 'real bits' for buffered data. - Refactor to pull measurement code out as separate function. bmp280 - Fix lack of clamp on range during data capture. * at91-sama5d2_adc - Handle unfinished conversions correctly. - Allow use of triggers other than it's own. - Reorganize buffer setup and tear down as part of long running subsystem wide rework. * ccs811 - Add DT binding docs and match table. - Support external reset and wakeup pins. * hid-sensors - Reorganize buffer setup and tear down as part of long running subsystem wide rework. * ltr501 - Constify some structs. * vcnl4000 - Fix an endian issue by using explicit byte swapped i2c accessors. * tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (74 commits) iio: light: ltr501: Constify structs staging: iio: ad5933: attach life-cycle of kfifo buffer to parent device and use managed calls throughout iio: bmp280: fix compensation of humidity iio: light: cm32181: Fix integartion time typo iio: light: cm32181: Add support for parsing CPM0 and CPM1 ACPI tables iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settings iio: light: cm32181: Use units of 1/100000th for calibscale and lux_per_bit iio: light: cm32181: Change reg_init to use a bitmap of which registers to init iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources iio: light: cm32181: Clean up the probe function a bit iio: light: cm32181: Add support for the CM3218 iio: light: cm32181: Add some extra register defines iio: light: cm32181: Add support for ACPI enumeration iio: light: cm32181: Switch to new style i2c-driver probe function iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger iio: vcnl4000: Add buffer support for VCNL4010/20. iio: vcnl4000: Add sampling frequency support for VCNL4010/20. iio: vcnl4000: Add event support for VCNL4010/20. iio: vcnl4000: Factorize data reading and writing. iio: vcnl4000: Fix i2c swapped word reading. ...
| | * | iio: light: ltr501: Constify structsRikard Falkeborn2020-05-111-19/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Constify some data structs that are never changed. In order to do so, also update a couple of functions that now need to accept pointers to const struct instead of struct. While at it, update a few more functions to accept pointers to const struct instead of pointers. This allows the compiler to put more data in the code segment instead of the data segment, as seen by the output of the file command: Before: text data bss dec hex filename 27080 8144 192 35416 8a58 drivers/iio/light/ltr501.o After: text data bss dec hex filename 27688 7536 192 35416 8a58 drivers/iio/light/ltr501.o Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: bmp280: fix compensation of humidityAndreas Klinger2020-05-111-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Limit the output of humidity compensation to the range between 0 and 100 percent. Depending on the calibration parameters of the individual sensor it happens, that a humidity above 100 percent or below 0 percent is calculated, which don't make sense in terms of relative humidity. Add a clamp to the compensation formula as described in the datasheet of the sensor in chapter 4.2.3. Although this clamp is documented, it was never in the driver of the kernel. It depends on the circumstances (calibration parameters, temperature, humidity) if one can see a value above 100 percent without the clamp. The writer of this patch was working with this type of sensor without noting this error. So it seems to be a rare event when this bug occures. Signed-off-by: Andreas Klinger <ak@it-klinger.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Fix integartion time typoHans de Goede2020-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix integartion time typo and while at it improve the comment with the typo a bit in general. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Add support for parsing CPM0 and CPM1 ACPI tablesHans de Goede2020-05-111-0/+101
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On ACPI based systems the CPLM3218 ACPI device node describing the CM3218[1] sensor typically will have some extra tables with register init values for initializing the sensor and calibration info. This is based on a newer version of cm32181.c, with a copyright of: * Copyright (C) 2014 Capella Microsystems Inc. * Author: Kevin Tsai <ktsai@capellamicro.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2, as published * by the Free Software Foundation. Which is floating around on the net in various places, but the changes from this newer version never made it upstream. This was tested on the following models: Acer Switch 10 SW5-012 (CM32181) Asus T100TA (CM3218), Asus T100CHI (CM3218) and HP X2 10-n000nd (CM32181). Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settingsHans de Goede2020-05-101-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make lux_per_bit and lux_per_bit_base_it settings stored in struct cm32181_chip instead of a hardcoded (defined) values. This is a preparation patch for reading some ACPI tables which specify a device specific lux_per_bit value. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Use units of 1/100000th for calibscale and lux_per_bitHans de Goede2020-05-101-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Use units of 1/100000th for calibscale and lux_per_bit. The similar cm3232 driver already uses 1/100000th as unit for calibscale. This allows for higher-accuracy and makes it easier to add support for getting device-specific calibscale and lux_per_bit values from a device's ACPI tables, as the values in the ACPI tables also use 1/100000th units. This units change means that our intermediate values in cm32181_get_lux() may get quite big, change the type of the lux variable to a u64 to deal with this. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Change reg_init to use a bitmap of which registers to initHans de Goede2020-05-101-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a preparation patch for reading some ACPI tables which give init values for multiple registers. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resourcesHans de Goede2020-05-101-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some ACPI systems list 2 I2C resources for the CM3218 sensor. On these systems the first I2cSerialBus ACPI-resource points to the SMBus Alert Response Address (ARA, 0x0c) and the second I2cSerialBus ACPI-resource points to the actual CM3218 sensor address: Method (_CRS, 0, NotSerialized) // _CRS: Current Resource Settings { Name (SBUF, ResourceTemplate () { I2cSerialBusV2 (0x000C, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.I2C3", 0x00, ResourceConsumer, , Exclusive, ) I2cSerialBusV2 (0x0048, ControllerInitiated, 0x00061A80, AddressingMode7Bit, "\\_SB.I2C3", 0x00, ResourceConsumer, , Exclusive, ) Interrupt (ResourceConsumer, Level, ActiveHigh, Exclusive, ,, ) { 0x00000033, } }) Return (SBUF) /* \_SB_.I2C3.ALSD._CRS.SBUF */ } Detect this and take the following step to deal with it: 1. When a SMBus Alert capable sensor has an Alert asserted, it will not respond on its actual I2C address. Read a byte from the ARA to clear any pending Alerts. 2. Create a "dummy" client for the actual I2C address and use that client to communicate with the sensor. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Clean up the probe function a bitHans de Goede2020-05-101-14/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 3 small cleanups to cm32181_probe(): 1. Do not log an error when we fail to allocate memory (as a general rule drivers do not log errors for this as the kernel will already have complained loudly that it could not alloc the mem). 2. Remove the i2c_set_clientdata() call, we never use i2c_get_clientdata() or dev_get_drvdata() anywhere. 3. Add a dev helper variable and use it in various places instead of &client->dev. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Add support for the CM3218Hans de Goede2020-05-101-12/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for the CM3218 which is an older version of the CM32181. This is based on a newer version of cm32181.c, with a copyright of: * Copyright (C) 2014 Capella Microsystems Inc. * Author: Kevin Tsai <ktsai@capellamicro.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2, as published * by the Free Software Foundation. Which is floating around on the net in various places, but the changes from this newer version never made it upstream. This was tested on an Asus T100TA and an Asus T100CHI, which both come with the CM3218 variant of the light sensor. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Add some extra register definesHans de Goede2020-05-101-4/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These come from a newer version of cm32181.c, which is floating around the net, with a copyright of: * Copyright (C) 2014 Capella Microsystems Inc. * Author: Kevin Tsai <ktsai@capellamicro.com> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2, as published * by the Free Software Foundation. Note that this removes the bogus CM32181_CMD_ALS_ENABLE define, there is no enable bit, only a disable bit and enabled is the absence of being disabled. This is a preparation patch for adding support for the older CM3218 model of the light sensor. Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Add support for ACPI enumerationHans de Goede2020-05-101-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for ACPI enumeration, this has been tested on a HP HP Pavilion x2 Detachable 10 (Bay Trail model). Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: light: cm32181: Switch to new style i2c-driver probe functionHans de Goede2020-05-101-12/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Switch to the new style i2c-driver probe_new probe function and drop the unnecessary i2c_device_id table (we do not have any old style board files using this). This is a preparation patch for adding ACPI binding support. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_triggerAlexandru Ardelean2020-05-1012-134/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main intent here is to get rid of the iio_buffer_set_attrs() helper, or at least rework it's usage a bit. The problem with that helper is that it needs a pointer to the buffer, which makes supporting multiple buffers per IIO device a bit more cumbersome. The hid_sensor_setup_trigger() is pretty much used in the same way: - iio_triggered_buffer_setup() gets called before - then hid_sensor_setup_trigger() and hid_sensor_setup_batch_mode() gets called which may attach some fifo attributes This change merges the 2 together under the hid_sensor_setup_trigger() function. Only the &iio_pollfunc_store_time is passed to all devices, so it's not even required to pass it explicitly outside of the common hid_sensor_setup_trigger() function. Moving the devm_iio_triggered_buffer_setup/cleanup() calls into the common place code can help the rework of the buffer code, since it is in one place. One detail of the change is that there are 2 drivers that use devm_iio_triggered_buffer_setup(). That function gets implicitly replaced with iio_triggered_buffer_setup()/cleanup(), but since all drivers call both hid_sensor_setup_trigger9) & hid_sensor_remove_trigger() trigger, the iio_triggered_buffer_cleanup() piggy backs on the hid_sensor_remove_trigger() call, which should cover the cleanup. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: vcnl4000: Add buffer support for VCNL4010/20.Mathieu Othacehe2020-05-032-2/+161
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The VCNL4010 and VCNL4020 chips are able to raise interrupts on data ready. Use it to provide triggered buffer support for proximity data. Those two chips also provide ambient light data. However, they are sampled at different rate than proximity data. As this is not handled by the IIO framework for now, and the sample frequencies of ambient light data are very low, do add buffer support for them. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: vcnl4000: Add sampling frequency support for VCNL4010/20.Mathieu Othacehe2020-05-031-1/+117
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add sampling frequency support for proximity data on VCNL4010 and VCNL4020 chips. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: vcnl4000: Add event support for VCNL4010/20.Mathieu Othacehe2020-05-031-62/+392
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The VCNL4010 and VCNL4020 chips are able to raise interrupts on proximity threshold events. Add support for threshold rising and falling events for those two chips. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: vcnl4000: Factorize data reading and writing.Mathieu Othacehe2020-05-031-2/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Factorize data reading in vcnl4000_measure into a vcnl4000_read_data function. Also add a vcnl4000_write_data function. Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: vcnl4000: Fix i2c swapped word reading.Mathieu Othacehe2020-05-031-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bytes returned by the i2c reading need to be swapped unconditionally. Otherwise, on be16 platforms, an incorrect value will be returned. Taking the slow path via next merge window as its been around a while and we have a patch set dependent on this which would be held up. Fixes: 62a1efb9f868 ("iio: add vcnl4000 combined ALS and proximity sensor") Signed-off-by: Mathieu Othacehe <m.othacehe@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
| | * | iio: imu: adis16xxx: use helper to access iio core debugfs dirAlexandru Ardelean2020-05-035-37/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The IIO core provides a iio_get_debugfs_dentry() helper. It seems that the ADIS IMU drivers access that field directly. This change converts them to use iio_get_debugfs_dentry() instead. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>