summaryrefslogtreecommitdiff
path: root/drivers/iio/accel
AgeCommit message (Collapse)Author
2025-01-04iio: accel: adxl345: complete the list of definesLothar Rubusch
Having interrupts events and FIFO available allows to evaluate the sensor events. Cover the list of interrupt based sensor events. Keep them in the header file for readability. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20241228232949.72487-5-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-01-04iio: accel: adxl345: add FIFO with watermark eventsLothar Rubusch
Add a basic setup for FIFO with configurable watermark. Add a handler for watermark interrupt events and extend the channel for the scan_index needed for the iio channel. The sensor is configurable to use a FIFO_BYPASSED mode or a FIFO_STREAM mode. For the FIFO_STREAM mode now a watermark can be configured, or disabled by setting 0. Further features require a working FIFO setup. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20241228232949.72487-4-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-01-04iio: accel: adxl345: initialize FIFO delay value for SPILothar Rubusch
Add the possibility to delay FIFO access when SPI is used. According to the datasheet this is needed for the adxl345. When initialization happens over SPI the need for delay is to be signalized, and the delay will be used. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20241228232949.72487-3-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2025-01-04iio: accel: adxl345: introduce interrupt handlingLothar Rubusch
Add the possibility to claim an interrupt. Init the state structure with an interrupt line obtained from the DT. The adxl345 can use two different interrupt lines for event handling. Only one is used. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20241228232949.72487-2-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-28iio: accel: bma220: Use aligned_s64 instead of open coding alignment.Jonathan Cameron
Use this new type to both slightly simplify the code and avoid confusing static analysis tools. Mostly this series is about consistency to avoid this code pattern getting copied into more drivers. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241215182912.481706-15-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-28iio: accel: adxl345: add function to switch measuring modeLothar Rubusch
Replace the powerup / powerdown functions by a generic function to put the sensor in STANDBY, or MEASURE mode. When configuring the FIFO for several features of the accelerometer, it is recommended to put measuring in STANDBY mode. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20241213211909.40896-2-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-11iio: accel: adxl345: rename variable data to stLothar Rubusch
Rename the locally used variable data to st. The st refers to "state", representing the internal state of the driver object. Further it prepares the usage of an internal data pointer needed for the implementation of the sensor features. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20241205171343.308963-3-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-11iio: accel: adxl345: refrase comment on probeLothar Rubusch
Refrase comment on the probe function, avoid naming different hardware. Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com> Link: https://patch.msgid.link/20241205171343.308963-2-l.rubusch@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-08iio: kx022a: document new chip_info structure membersMatti Vaittinen
The kx022a driver supports a few different HW variants. A chip-info structure is used to describe sensor specific details. Support for sensors with different measurement g-ranges was added recently, introducing sensor specific scale arrays. The members of the chip-info structure have been documented using kerneldoc. The newly added members omitted the documentation. It is nice to have all the entries documented for the sake of the consistency. Furthermore, the scale table format may not be self explatonary, nor how the amount of scales is informed. Add documentation to scale table entries to maintain consistency and to make it more obvious how the scales should be represented. Suggested-by: Mehdi Djait <mehdi.djait@linux.intel.com> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Reviewed-by: Mehdi Djait <mehdi.djait@linux.intel.com> Link: https://patch.msgid.link/Z1LDUj-naUdGSM6n@mva-rohm Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: accel: kx022a: Support KX134-1211Matti Vaittinen
The ROHM KX134-1211 has very similar register interface as KX132-1211 does. The main differencies are the content of the "Who am I" identification register and different g-ranges. The KX132-1211 can measure ranges from +/- 2g to +/-16g where the KX134-1211 supports measuring ranges +/- 8g to +/- 64g. Support the ROHM KX134-1211. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/6e95af6b425df6a5ff5218825ec8923f1341f7c3.1732783834.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: kx022a: Support ROHM KX134ACR-LBZMatti Vaittinen
The register interface of the ROHM KX134ACR-LBZ accelerometer is almost identical to the KX132ACR-LBZ. The main difference between these accelerometers is that the KX134ACR-LBZ supports different G-ranges. The driver can model this by informing different scale to users. Also, the content of the "who_am_I" register is different. Add an ID and scales for the KX134ACR-LBZ. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/27c43c595de1f3f698ace671922d4f5a48c3cd54.1732783834.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: accel: kx022a: Support ICs with different G-rangesMatti Vaittinen
The register interface of the ROHM KX134ACR-LBZ accelerometer is almost identical to the KX132ACR-LBZ. Main difference between these accelerometers is that the KX134ACR-LBZ supports G-ranges +/- 8, 16, 32 and 64G. All the other sensors supported by the kx022a driver can measure +/- 2, 4, 8 and 16G. Prepare supporting the KX134ACR-LBZ with different G-ranges by storing a pointer to the scale tables in IC specific structure. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/fc667b1495adf4e3f29ecbb336495c1f18b47e61.1732783834.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: accel: kx022a: Use cleanup.h helpersMatti Vaittinen
A few functions in KX022A need to use mutex for protecting the enabling/disabling of the measurement while configurations are being made. Some of the functions can be slightly simplified by using the __cleanup based scoped mutexes, which allows dropping the goto based unlocking at error path. Simplify error paths using guard(mutex). Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/4785f841ad5f131356ba78b4f3c76f676d86a2e8.1732783834.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: accel: kx022a: Improve reset delayMatti Vaittinen
All the sensors supported by kx022a driver seemed to require some delay after software reset to be operational again. More or less a random msleep(1) was added to cause the driver to go to sleep so the sensor has time to become operational again. Now we have official docuumentation available: https://fscdn.rohm.com/kionix/en/document/AN010_KX022ACR-Z_Power-on_Procedure_E.pdf https://fscdn.rohm.com/kionix/en/document/TN027-Power-On-Procedure.pdf https://fscdn.rohm.com/kionix/en/document/AN011_KX134ACR-LBZ_Power-on_Procedure_E.pdf stating the required time is 2 ms. Due to the nature of the current msleep implementation, the msleep(1) is likely to be sleeping more than 2ms already - but the value "1" is misleading in case someone needs to optimize the start time and change the msleep to a more accurate delay. Hence it is better for "documentation" purposes to use value which actually reflects the specified 2ms wait time. Change the value of delay after software reset to match the specifications and add links to the power-on procedure specifications. Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/ac1b6705945cded0e79593d64e55522681e00f9a.1732105157.git.mazziesaccount@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: accel: fxls8962af: add fxls8967af supportHan Xu
fxls8967af is similar with fxls8962af, the only difference is the device id change to 0x87. Signed-off-by: Han Xu <han.xu@nxp.com> Reviewed-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20241115-fxls-v2-4-95f3df9228ed@nxp.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-07iio: accel: fxls8962af: add fxls8974cf supportHaibo Chen
fxls8974cf is similar with fxls8962af, the only difference is the device id change to 0x86. Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Reviewed-by: Clark Wang <xiaoning.wang@nxp.com> Reviewed-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Frank Li <Frank.Li@nxp.com> Link: https://patch.msgid.link/20241115-fxls-v2-3-95f3df9228ed@nxp.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-12-02module: Convert symbol namespace to string literalPeter Zijlstra
Clean up the existing export namespace code along the same lines of commit 33def8498fdd ("treewide: Convert macro and uses of __section(foo) to __section("foo")") and for the same reason, it is not desired for the namespace argument to be a macro expansion itself. Scripted using git grep -l -e MODULE_IMPORT_NS -e EXPORT_SYMBOL_NS | while read file; do awk -i inplace ' /^#define EXPORT_SYMBOL_NS/ { gsub(/__stringify\(ns\)/, "ns"); print; next; } /^#define MODULE_IMPORT_NS/ { gsub(/__stringify\(ns\)/, "ns"); print; next; } /MODULE_IMPORT_NS/ { $0 = gensub(/MODULE_IMPORT_NS\(([^)]*)\)/, "MODULE_IMPORT_NS(\"\\1\")", "g"); } /EXPORT_SYMBOL_NS/ { if ($0 ~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+),/) { if ($0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/ && $0 !~ /(EXPORT_SYMBOL_NS[^(]*)\(\)/ && $0 !~ /^my/) { getline line; gsub(/[[:space:]]*\\$/, ""); gsub(/[[:space:]]/, "", line); $0 = $0 " " line; } $0 = gensub(/(EXPORT_SYMBOL_NS[^(]*)\(([^,]+), ([^)]+)\)/, "\\1(\\2, \"\\3\")", "g"); } } { print }' $file; done Requested-by: Masahiro Yamada <masahiroy@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://mail.google.com/mail/u/2/#inbox/FMfcgzQXKWgMmjdFwwdsfgxzKpVHWPlc Acked-by: Greg KH <gregkh@linuxfoundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2024-11-09Merge tag 'iio-for-6.13b' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO: 2nd set of new device support, features and cleanup for 6.13 Alongside new drivers and device support there are several large cleanups going on across the IIO tree and we see part of some of those in this pull request. Merged char-misc-next at point of 6.12-rc6 merge to avoid a conflict with a fix for the ad7380 merged earlier this cycle. Note that I previously messed this merge up and had to reconstruct it this morning so a coherent pull request was possible. The new stuff is all the same as has been in linux-next for some time with the exception of the kernel-doc related __private ordering fix that went in yesterday. New device support ================== adi,ad7380 - Support for adaq4370-4 and adaq4370 quad channel ADCs. adi,ad7606 - Various cleanups preceeding support of AD7607, AD7608 and AD7609 ADCs. adi,ad7779 - New driver supproting AD7770, AD7771 and AD7779 ADCs. allegro,als31300 - New driver for this 3D Linear Hall Effect sensor. bosch,bmi270 - Add support BMI260 which is similar but requires a different firmware image. bosch,smi240 - New driver for this IMU. ti,opt3001 - Add support opt3002 light sensor which has a wider spectral range than the opt3001. vishay,veml3235 - New driver for this ambient light sensor. Features ======== hid-sensors - Add support Human Proximity Range and Attention detection (requiring a new classification style channel type) adi,ad3552r - Add backend support and related platform driver to support use with an FPGA IP to allow QSPI + DDR bus operation and much higher data aquisition rates. (various rework preceeded this feature) adi,ad7606 - Various cleanup prior to enabling use with an IIO Backend and PWM trigger enabling much higher speed data capture. bosch,bme680 - Support control of preheat current - Support triggered buffer capture - Add SCALE and RAW channels (needed to enable the buffered capture). bosch,bmp280 - Enable sleeping to save power. - Add interrupt support for bmp3xx and bmp5xx devices. Also update bmp085 to new approach. - Enable data ready trigger. bosch,bmi270 - Add triggered buffer support - Add scale and sampling frequency control. vishay,veml6070 - Support integration time via DT binding for an external resistor value. Cleanup and minor fixes ======================= core - Fix a longstanding issue with event codes for differential channels. Note that not all drivers are yet fixed, but macros have been added to avoid potential repeats of this in future. - Tidy up handling in iio_read_acpi_mount matrix. - Mark iio_dev::priv with __private. Later move the marking before the field name to avoid a kernel-doc issue. treewide - Drop some pointless default n entries in Kconfig. - Add an iio_get_acpi_device_name_and_data() handler to replace some commonly repeated code. - simplify use of 'state' in write_event_config() callback as it is effectively a boolean. Once done make it a boolean (lots of drivers were updated to enable this) - some more use of devm_regulator_get_enable_read_voltage( to replace open coded versions. Where this enables it convert all of remove handling to devm based and drop the remove callback. - check returns from devm_mutex_init() accel drivers - Use aligned_s64 instead of s64 __aligned(8) adi,ad5791 - Add some missing GPIOs and power supplies that presumably were always hard wired on previous boards. - Refactor to use chip_info in device id tables. - Convert probe entirely to devm based simplify code and allowing remove() callback to be dropped. adi,ad7192 - Check return from spi_get_device_match_data() adi,ad74413r - Don't keep an unnecessary copy of the gpio after probe. - Use devm_regulator_get_enable_read_voltage() instead of open coding. - Apply cleanup.h approach to reduce complexity. adi,dac8460 - Fix a wrong compaitble ID due to a stray space. - Add an spi_device_id table. bosch,bmc150 - Drop some likely false ACPI IDs. - Drop left over unused ACPI specific code. bosch,bme680 - Add mising regmap.h include. - Reduce excessive sleep on startup. - Drop some cammelcase usage. - Use fsleep - Generalize read functions to allow for reuse. - Use s16 variable to avoid some incorrect casting bosch,bmg150 - Drop some likely false ACPI IDs. bosch,bmi270 - Drop unused FREQUENCY and SCALE attributes that always returned an error (they wil be back impelmented correctly). - Factor out the chip specific data into a structure to enable simple support for additional devices. isil,isl29018 - Drop ACPI_PTR() and CONFIG_ACPI guards as not worth the trouble for very minor saving. invensense,mpu6050 - Use much simpler test for ACPI firmware. kionix,kxcjk-1013 - Drop unnecessary ACPI entry in the i2c_device_id table. - Drop support KX022-1020 to fix a bug that was introduced with that change. Hopefully a fixed version will replace it soon. - Drop CONFIG guards for PM in favor of pm_ptr() and the compiler removing dead code. - Switch from enum to chip_info structure and add ODR times to that structure. - Deduplicate one of those ODR structures - Drop ACPI_PTR() and move ID table out of config guards. - Minor additional cleanup. liteon,ltr401 - Drop some likely false ACPI Ids and add LTER0303 which is know to be in use. microchip,pac1934 - Use much simpler test for ACPI firmware. vishay,veml6070 - Use unsigned int instead of just unsigned. - Use FIELD_PREP to make setting of field value explicit. Various other minor fixes to documentation * tag 'iio-for-6.13b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (153 commits) iio: Move __private marking before struct element priv in struct iio_dev docs: iio: ad7380: add adaq4370-4 and adaq4380-4 iio: adc: ad7380: add support for adaq4370-4 and adaq4380-4 iio: adc: ad7380: use local dev variable to shorten long lines iio: adc: ad7380: fix oversampling formula dt-bindings: iio: adc: ad7380: add adaq4370-4 and adaq4380-4 compatible parts iio: chemical: bme680: Add support for preheat current iio: chemical: bme680: Add triggered buffer support iio: chemical: bme680: Add SCALE and RAW channels iio: chemical: bme680: refactorize set_mode() mode iio: events: make IIO_EVENT_CODE macro private iio: accel: mma9553: use specialized event code macros iio: dummy: use specialized event code macros iio: adc: ad7280a: use IIO_DIFF_EVENT_CODE macro helper iio: events.h: add event identifier macros for differential channel iio: magnetometer: add Allegro MicroSystems ALS31300 3-D Linear Hall Effect driver dt-bindings: iio: magnetometer: document the Allegro MicroSystems ALS31300 3-D Linear Hall Effect Sensor dt-bindings: vendor-prefixes: Add Allegro MicroSystems, Inc iio: light: apds9960: remove useless return iio: light: apds9960: convert als_int and pxs_int to bool ...
2024-11-08Merge tag 'iio-fixes-for-6.12c' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO: 3rd set of fixes for the 6.12 cycle Usual mixed bag of new issues from this cycle and ancient bugs recently noticed. core - Fix wrong fwnode handle if __fwnode_iio_channel_get_by_name() looks at parents of the provider node. core,backend - Fix a wrong pointer error check. gts library - Fix plausible corner case where the value returned was not set. - Avoid near infinite loop if the size of the table is 0. (neither are an issue for current drivers). adi,ad4000 - Fix reading of unsigned channels that were returning garbage. adi,ad7780 - Prevent a division by zero. adi,ad7923 - Fix buffer overflows in arrays that were not resized when devices with more channels were added to the driver. adi,adxl380 - Check only for negative error codes rather than including the positive channel read values in an error check. invense,common - Fix an issue where changing the sampling rate to another value and back again whilst the FIFO was off would not update things correctly. kionix,kx022a - Fix failure to sign extend value read from device. * tag 'iio-fixes-for-6.12c' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: Fix fwnode_handle in __fwnode_iio_channel_get_by_name() iio: accel: adxl380: fix raw sample read iio: accel: kx022a: Fix raw read format iio: gts: fix infinite loop for gain_to_scaletables() iio: gts: Fix uninitialized symbol 'ret' iio: adc: ad4000: fix reading unsigned data ad7780: fix division by zero in ad7780_write_raw() iio: adc: ad7923: Fix buffer overflow for tx_buf and ring_xfer iio: backend: fix wrong pointer passed to IS_ERR() iio: invensense: fix multiple odr switch when FIFO is off
2024-11-03iio: accel: mma9553: use specialized event code macrosDavid Lechner
Simplify the code by using IIO_UNMOD_EVENT_CODE and IIO_MOD_EVENT_CODE instead of IIO_EVENT_CODE. Signed-off-by: David Lechner <dlechner@baylibre.com> Link: https://patch.msgid.link/20241101-iio-fix-event-macro-use-v1-2-0000c5d09f6d@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: accel: sca3000: use bool for event stateJulien Stephan
Since the write_event_config callback now uses a bool for the state parameter, update the signatures of the functions it calls accordingly. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-9-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: accel: mma9551: use bool for event stateJulien Stephan
Since the write_event_config callback now uses a bool for the state parameter, update the signature of the function it calls accordingly, and use a bool array for event_enabled. Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-8-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: fix write_event_config signatureJulien Stephan
write_event_config callback use an int for state, but it is actually a boolean. iio_ev_state_store is actually using kstrtobool to check user input, then gives the converted boolean value to write_event_config. Fix signature and update all iio drivers to use the new signature. This patch has been partially written using coccinelle with the following script: $ cat iio-bool.cocci // Options: --all-includes virtual patch @c1@ identifier iioinfo; identifier wecfunc; @@ static const struct iio_info iioinfo = { ..., .write_event_config = ( wecfunc | &wecfunc ), ..., }; @@ identifier c1.wecfunc; identifier indio_dev, chan, type, dir, state; @@ int wecfunc(struct iio_dev *indio_dev, const struct iio_chan_spec *chan, enum iio_event_type type, enum iio_event_direction dir, -int +bool state) { ... } make coccicheck MODE=patch COCCI=iio-bool.cocci M=drivers/iio Unfortunately, this script didn't match all files: * all write_event_config callbacks using iio_device_claim_direct_scoped were not detected and not patched. * all files that do not assign and declare the write_event_config callback in the same file. iio.h was also manually updated. The patch was build tested using allmodconfig config. cc: Julia Lawall <julia.lawall@inria.fr> Signed-off-by: Julien Stephan <jstephan@baylibre.com> Link: https://patch.msgid.link/20241031-iio-fix-write-event-config-signature-v2-7-2bcacbb517a2@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-03iio: accel: kxcjk-1013: Deduplicate ODR startup time arrayAndy Shevchenko
The content of kxcj91008_odr_start_up_times and kxcjk1013_odr_start_up_times is identical, deduplicate it. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241101081203.3360421-5-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: accel: adxl380: fix raw sample readAntoniu Miclaus
The adxl380_read_chn function returns either a negative value in case an error occurs or the actual sample. Check only for negative values after a channel is read. Fixes: df36de13677a ("iio: accel: add ADXL380 driver") Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Link: https://patch.msgid.link/20241101095202.20121-1-antoniu.miclaus@analog.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: accel: mma9553: Replace custom implementation of iio_get_acpi_device_name()Andy Shevchenko
IIO core (ACPI part) provides a generic helper that may be used in the driver. Replace custom implementation of iio_get_acpi_device_name(). Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-19-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: accel: mma9551: Replace custom implementation of iio_get_acpi_device_name()Andy Shevchenko
IIO core (ACPI part) provides a generic helper that may be used in the driver. Replace custom implementation of iio_get_acpi_device_name(). Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-18-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: accel: kxcjk-1013: drop ACPI_PTR() and move ID out of CONFIG_ACPI guardsAndy Shevchenko
The complexity of config guards needed for ACPI_PTR() is not worthwhile for the small amount of saved data. This example was doing it correctly but I am proposing dropping this so as to reduce chance of cut and paste where it is done wrong. Also added linux/mod_devicetable.h for struct acpi_device_id definition. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-17-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-11-01iio: accel: kxcjk-1013: Replace a variant of iio_get_acpi_device_name_and_data()Andy Shevchenko
IIO core (ACPI part) provides a generic helper that may be used in the driver. Replace a variant of iio_get_acpi_device_name_and_data(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-16-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-31iio: accel: kx022a: Fix raw read formatMatti Vaittinen
The KX022A provides the accelerometer data in two subsequent registers. The registers are laid out so that the value obtained via bulk-read of these registers can be interpreted as signed 16-bit little endian value. The read value is converted to cpu_endianes and stored into 32bit integer. The le16_to_cpu() casts value to unsigned 16-bit value, and when this is assigned to 32-bit integer the resulting value will always be positive. This has not been a problem to users (at least not all users) of the sysfs interface, who know the data format based on the scan info and who have converted the read value back to 16-bit signed value. This isn't compliant with the ABI however. This, however, will be a problem for those who use the in-kernel interfaces, especially the iio_read_channel_processed_scale(). The iio_read_channel_processed_scale() performs multiplications to the returned (always positive) raw value, which will cause strange results when the data from the sensor has been negative. Fix the read_raw format by casting the result of the le_to_cpu() to signed 16-bit value before assigning it to the integer. This will make the negative readings to be correctly reported as negative. This fix will be visible to users by changing values returned via sysfs to appear in correct (negative) format. Reported-by: Kalle Niemi <kaleposti@gmail.com> Fixes: 7c1d1677b322 ("iio: accel: Support Kionix/ROHM KX022A accelerometer") Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com> Tested-by: Kalle Niemi <kaleposti@gmail.com> Cc: <Stable@vger.kernel.org> Link: https://patch.msgid.link/ZyIxm_zamZfIGrnB@mva-rohm Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Get rid of enum kx_chipsetAndy Shevchenko
Instead of using enum, out of which only a couple of values are being actually used, make a comparisons against pointer to the respective chip_info structures. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-15-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Convert ODR times array to variable in chip_infoAndy Shevchenko
Convert odr_start_up_times array to the variable in chip_info. Tweak whitespace for readablity whilst here. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-14-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Move odr_start_up_times up in the codeAndy Shevchenko
Move odr_start_up_times up in the code in a preparation of the further cleaning up changes. While at it, make it clear what values from enum are being used for the respective array entries. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-13-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Start using chip_info variables instead of enumAndy Shevchenko
Instead of having a enum and keeping IDs as driver data pointers, just have a chip_info struct per supported device. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-12-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Rename kxcjk1013_infoAndy Shevchenko
Rename kxcjk1013_info to kxcjk1013_iio_info in preparatory of further cleaning up changes. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-11-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Use local variable for regsAndy Shevchenko
Use local variable for regs in preparatory of further cleaning up changes. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-10-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Switch from CONFIG_PM guards to pm_ptr() etcAndy Shevchenko
Letting the compiler remove these functions when the kernel is built without CONFIG_PM support is simpler and less error prone than the use of #ifdef based config guards. Removing instances of this approach from IIO also stops them being copied into new drivers. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-9-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Revert "Add support for KX022-1020"Andy Shevchenko
The mentioned change effectively broke the ODR startup timeouts settungs for KX023-1025 case. Let's revert it for now and see how we can handle it with the better approach after switching the driver to use data structure instead of enum. This reverts commit d5cbe1502043124ff8af8136b80f93758c4a61e0. Fixes: d5cbe1502043 ("iio: accel: kxcjk-1013: Add support for KX022-1020") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-8-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: kxcjk-1013: Remove redundant I²C IDAndy Shevchenko
The ACPI IDs are defined in the respective ID tables. Puting them to the I²C ID legacy table has no meaning. Remove that ID. Fixes: 3bfa74f86006 ("iio:kxcjk-1013: Add support for SMO8500 device") Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20241024191200.229894-7-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-28iio: accel: replace s64 __aligned(8) with aligned_s64Jonathan Cameron
e4ca0e59c394 ("types: Complement the aligned types with signed 64-bit one") introduced aligned_s64. Use it for all IIO accelerometer drivers. Reviewed-by: Nuno Sa <nuno.sa@analog.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/20241020180720.496327-1-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-21iio: accel: adxl355: Fix typo "accelaration"WangYuli
There is a spelling mistake of 'accelaration' in comments which should be 'acceleration'. Signed-off-by: WangYuli <wangyuli@uniontech.com> Link: https://patch.msgid.link/9F137828F9F185FD+20241017092221.361511-1-wangyuli@uniontech.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-21Merge 6.12-rc4 into char-misc-nextGreg Kroah-Hartman
We need the iio fixes from 6.12-rc4 in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-10-13Merge tag 'iio-fixes-for-6.12a' of ↵Greg Kroah-Hartman
ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-linus Jonathan writes: IIO: 1st set of fixes for the 6.12 cycle. Most of this pull request is the result of Javier Carrasco doing a careful audit for missing Kconfig dependencies that luck has meant the random builds have never hit. The rest is the usual mix of old bugs that have surfaced and some fallout from the recent merge window. adi,ad5686 - Fix binding duplication of compatible strings. bosch,bma400 - Fix an uninitialized variable in the event tap handling. bosch,bmi323 - Fix several issues in the register saving and restore on suspend/resume sensiron,spd500 - Fix missing CRC8 dependency ti,op3001 - Fix a missing full-scale range value (values above this point were all reported wrongly) vishay,veml6030 - Fix a segmentation fault due to some type confusion. - Fix wrong ambient light sensor resolution. * tag 'iio-fixes-for-6.12a' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (34 commits) iio: frequency: admv4420: fix missing select REMAP_SPI in Kconfig iio: frequency: {admv4420,adrf6780}: format Kconfig entries iio: adc: ad4695: Add missing Kconfig select iio: adc: ti-ads8688: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: hid-sensors: Fix an error handling path in _hid_sensor_set_report_latency() iioc: dac: ltc2664: Fix span variable usage in ltc2664_channel_config() iio: dac: stm32-dac-core: add missing select REGMAP_MMIO in Kconfig iio: dac: ltc1660: add missing select REGMAP_SPI in Kconfig iio: dac: ad5770r: add missing select REGMAP_SPI in Kconfig iio: amplifiers: ada4250: add missing select REGMAP_SPI in Kconfig iio: frequency: adf4377: add missing select REMAP_SPI in Kconfig iio: resolver: ad2s1210: add missing select (TRIGGERED_)BUFFER in Kconfig iio: resolver: ad2s1210 add missing select REGMAP in Kconfig iio: proximity: mb1232: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: pressure: bm1390: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: magnetometer: af8133j: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: light: bu27008: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: chemical: ens160: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: dac: ad5766: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig iio: dac: ad3552r: add missing select IIO_(TRIGGERED_)BUFFER in Kconfig ...
2024-10-12Merge tag 'v6.12-rc2' into test2Jonathan Cameron
Linux 6.12-rc2 Resolved movement of asm/unaligned.h to linux/unaligned.h
2024-10-10iio: Switch back to struct platform_driver::remove()Uwe Kleine-König
After commit 0edb555a65d1 ("platform: Make platform_driver::remove() return void") .remove() is (again) the right callback to implement for platform drivers. Convert all platform drivers below drivers/iio/ to use .remove(), with the eventual goal to drop struct platform_driver::remove_new(). As .remove() and .remove_new() have the same prototypes, conversion is done by just changing the structure member name in the driver initializer. While touching these files, make indention of the struct initializer consistent in several files. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com> Link: https://patch.msgid.link/20241009060056.502059-2-u.kleine-koenig@baylibre.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-06iio: accel: kx022a: add missing select IIO_(TRIGGERED_)BUFFER in KconfigJavier Carrasco
This driver makes use of triggered buffers, but does not select the required modules. Add the missing 'select IIO_BUFFER' and 'select IIO_TRIGGERED_BUFFER'. Fixes: 7c1d1677b322 ("iio: accel: Support Kionix/ROHM KX022A accelerometer") Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Acked-by: Matti Vaittinen <mazziesaccount@gmail.com> Link: https://patch.msgid.link/20241003-iio-select-v1-1-67c0385197cd@gmail.com Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-10-02move asm/unaligned.h to linux/unaligned.hAl Viro
asm/unaligned.h is always an include of asm-generic/unaligned.h; might as well move that thing to linux/unaligned.h and include that - there's nothing arch-specific in that header. auto-generated by the following: for i in `git grep -l -w asm/unaligned.h`; do sed -i -e "s/asm\/unaligned.h/linux\/unaligned.h/" $i done for i in `git grep -l -w asm-generic/unaligned.h`; do sed -i -e "s/asm-generic\/unaligned.h/linux\/unaligned.h/" $i done git mv include/asm-generic/unaligned.h include/linux/unaligned.h git mv tools/include/asm-generic/unaligned.h tools/include/linux/unaligned.h sed -i -e "/unaligned.h/d" include/asm-generic/Kbuild sed -i -e "s/__ASM_GENERIC/__LINUX/" include/linux/unaligned.h tools/include/linux/unaligned.h
2024-09-30iio: accel: hid-sensor-accel-3d: Get platform data via dev_get_platdata()Andy Shevchenko
Access to platform data via dev_get_platdata() getter to make code cleaner. Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://patch.msgid.link/20240902222824.1145571-2-andy.shevchenko@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-09-30iio: hid-sensor: Use aligned data type for timestampAndy Shevchenko
Use aligned_s64 for the timestamp field. Note, the actual data is signed, hence with this we also amend that. While at it, drop redundant __alignment directive. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://patch.msgid.link/20240903180218.3640501-4-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2024-09-30iio: accel: fxls8962af: use irq_get_trigger_type()Jonathan Cameron
Use irq_get_trigger_type() to replace getting the irq data then the type in two steps. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Sean Nyekjaer <sean@geanix.com> Link: https://patch.msgid.link/20240901135950.797396-3-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>