Commit graph

24 commits

Author SHA1 Message Date
Mehdi Djait
f700e55ef6 iio: Rename iio_trigger_poll_chained and add kernel-doc
Rename the function to iio_trigger_poll_nested. Add kernel-doc with
a note on the context where the function is expected to be called.

Signed-off-by: Mehdi Djait <mehdi.djait.k@gmail.com>
Link: https://lore.kernel.org/r/841b533cba28ca25a8e87280c44e45979166e8e2.1677761379.git.mehdi.djait.k@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2023-03-11 12:18:29 +00:00
Jonathan Cameron
4da9438d29 iio: accel: bma400: Use devm_regulator_bulk_get_enable()
This driver only turns the power on at probe and off via a custom
devm_add_action_or_reset() callback. The new
devm_regulator_bulk_get_enable() replaces this boilerplate code.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Jagath Jog J <jagathjog1996@gmail.com>
Reviewed-by: Matti Vaittinen <mazziesaccount@gmail.com>
Link: https://lore.kernel.org/r/20221016163409.320197-3-jic23@kernel.org
2022-12-28 17:19:45 +00:00
Greg Kroah-Hartman
6e6df27064 4th set of IIO fixes for 6.1
Single patch fixing a memory leak in an error path.
 Fine to queue either for 6.2 if too late for 6.1
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmOCXEIRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FoiA7A//bUZgsgl+z9sM6azIqAMDI6efDubi5D5L
 +anh1rnyScocgweTI65uMuafWkBvajy0U7ugXC5TO06BoZNRKj9RMKBTbCBWmOoF
 8laRbffjiKcxZzpVm/kPZZI+vW9Ijq7/mWS16Jc/rKNrLtSN9nobLbwibJ4WwPzc
 LfjTAXwEDvzdXDqCo3F7z5/cPRWdv/GPtgGEYhPQkTGEY1zSZhZ9lG60Ed2NfABu
 VGz4ZAkr4XBFWtBlXoKegr1t/0Ulb/D8hA0p4eCCPDgSNCszhBApTCF6c8quZz8U
 2KmRfi3nJSUNnOigl2gfAzS/HN3WQF9U3m8l8VwGdAo5+qOs4hx0fxb3LZf2Lg3M
 4GqYtYgAi8fI9pDvkbODH47yCQYau0FSEytgoGfEXQvSAiRiwqc4jlKZYZ/fiS6G
 JYIcG1zWXpclmq5ugCFB6vSZKBP3chqplPnOD8Wt/QYCsskkejt2HPuqLYcZH3EQ
 8PfPhKFD2qtlgrYiCjKdkVZlChNeTEXbAHa9nIDSMyhxKMfKvZ9s3vY9w0Z/gpOC
 NzWEesKSj8mfKaWnl3I7k/DvhPyVFw2jzHRZHhd0tmGEaV/GUl0WViWUpgz+G0aG
 c7c87SvDk3bbRLlnnqe6Qb+u9yZNnZjqXHhNHODUk8Iok2Hv+WILX005XoZmvs/1
 LWRfgMJS84A=
 =38dX
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-6.1d' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

4th set of IIO fixes for 6.1

Single patch fixing a memory leak in an error path.
Fine to queue either for 6.2 if too late for 6.1

* tag 'iio-fixes-for-6.1d' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: fix memory leak in iio_device_register_eventset()
  dt-bindings: iio: adc: Remove the property "aspeed,trim-data-valid"
  iio: adc: aspeed: Remove the trim valid dts property.
  iio: core: Fix entry not deleted when iio_register_sw_trigger_type() fails
  iio: accel: bma400: Fix memory leak in bma400_get_steps_reg()
  iio: light: rpr0521: add missing Kconfig dependencies
  iio: health: afe4404: Fix oob read in afe4404_[read|write]_raw
  iio: health: afe4403: Fix oob read in afe4403_read_raw
  iio: light: apds9960: fix wrong register for gesture gain
2022-11-27 15:05:05 +01:00
Greg Kroah-Hartman
56d784d177 1st set of IIO new device support, feature and cleanup for 6.2 (take2)
We have finally managed to take the mlock mutex entirely private so as
 to avoid it being used for multiple purposes.  Now it is just used to
 protect device mode transitions (typically to and from buffered capture).
 
 Includes merge of an immutable i2c branch to get the new
 i2c_client_get_device_id() (thanks to Wolfram for providing the branch).
 
 Based on rc3 to pick up some precursor fixes from early in the cycle and
 avoid an unnecessarily messy history.
 
 New device support
 * adi,ad4310
   - New driver to support this very flexible measurement device including
     a 24 bit ADC. Later fix for documentation build issue.
 * adi,adxl355
   - Add support of the ADXL359 accelerometer.
 * adi,ltc2983
   - Support additional variants of the temperatures sensor:
     LTC2984 with an EEPROM
     LTC2985, LTC2986 with only 10 channels.
 * invensense,icm42600
   - Add support for icm42631 (needed only ID and WHOAMI)
 * kionix,kx022a
   - New driver for this 3 axis accelerometer.
 * maxim,max11401
   - New driver to support this 24-bit 10 channel ADC.
     Includes some new ABI to support configuration of notch filters.
 * mediatek,mt6370
   - Add new driver to support the ADC part of the mt6370.
 * st,lsm6dsx
   - Add support for LSM6DSV accelerometer and gyroscope. Simple additional
     of chip specific data and IDs.
   - Add support for LSM6DSV16X accelerometer and gyroscope.  Compatible with
     features currently implemented for the LSM6DSV.
 * st,stm32-adc
   - Add support for stm32pm13x SoCs.
 
 core / subsystem wide:
  - Add new IIO_STATIC_CONST_DEVICE_ATTR() which is a dance necessary to
    allow for the wrapping of attributes in the code that duplicates them
    for multiple buffers.
  - Harden against future issues with expectation that all buffer attributes
    are iio_dev_attrs by changing the code to take an array of pointers
    of the correct type.
  - Last transitions of drivers to local locks rather than missuses of mlock.
  - Add an iio_device_claim_buffer_mode() callback to avoid a race in the
    max30100 driver without directly using mlock.
  - Move mlock to the opaque IIO device structure to prevent misuse.
  - Add missing spi_device_id tables to support auto loading of modules.
  - Update some ADI maintainers in DT bindings.
  - A few more moves of bus drivers and core module sets to export
    name spaces.
  - Extensive use of new devm_regulator_get_enable() and friends.
  - Switch a bunch of i2c drivers to probe_new() including the bmp280
    which makes use of the new i2c_client_get_device_id() helper to
    simplify this change.
 
 dt-bindings:
  - More use of spi-peripheral-props.yaml.
 
 Features
 * freescale,mpl115
   - Use runtime PM to implement shutdown GPIO support.
 * melexis,mlx90632
   - More sophisticated runtime power management
   - Provide access to sampling frequency.
   - Trivial follow up fixes.
 * microchip,mcp3911
   - Support control of PGA.
 * st,lsm6dsx
   - Add support for software triggers for cases where the IRQ lines
     are not wired up.
 * vishay,vcnl4000
   - Add control of integration time.
 
 Minor cleanups and fixes
 * adi,ad4130
   - Improve ABI documentation formatting.
   - Kconfig dependency fixup.
 * adi,ad5758
   - Minor dt binding fix.
 * adi,ad9834
   - Tidy up line breaks.
 * adi,ade7854
   - Minor improvement in code clarity by replacing a ternary.
 * adi,admv8818
   - Harden code against hardware returning wrong values.
 * adi,adxl355
   - Warn only if unknown device ID detected to allow for fall back
     device tree compatibles on future devices.
 * adi,ltc2983
   - dt-bindings clarifications and general improvements.
   - Ensure DMA safe buffer for bulk writes without relying on current
     regmap implementation choices.
 * avago,adps9960
   - Fix up a disconnect between event enable attributes and what was
     enabled.
 * bosch,bma400
   - Switch to dev_err_probe() from open coded EPROBE_DEFER handling.
 * cosmic,cc10001
   - Fully devm managed probe() and related tidying up.
 * meas,ms5611
   - Add an example of spi-max-frequency.
 * meleixs,mlx90632
   - Tidy up confusing error return value.
   - Style improvements.
 * multiplexer
   - Switch to dev_err_probe() from open coded EPROBE_DEFER handling.
 * qcom,spmi-vadc
   - Minor dt binding improvements.
 * rockchip,saradc
   - Add ID for rv1126.
 * semtech,sx9360
   - Add SAMM0208 ACPI ID. Doesn't appear to be a valid vendor prefix
     but is in the wild.
 * st,lsm6dsx
   - Factor out common code as _device_set_enable().
   - Fix up wrong docs after LSM6DSV addition.
 * st,stm32-adc
   - Manage the min sampling time on all internal channels.
 * trig,sysfs
   - Improve error labels.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmN+fI4RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FogY1Q/7BTdKLbRuFoE4aK9AABv+m4w91s+RlBg6
 eXRw3Gt4IHHht7gIUVZByYztyoKkmW3RzsPafIlfJJkWAsiBpv6gXTW2h6UvjHg8
 SW3k91oVk5iLEeTaUSfJqxHCXX+VRYanyeti53MkpUvR2QUgAengP11N6bWmNXav
 D6OFGSTn9QpJ0XRmEmfxXt3pt/Miuz7GT2sN5ut1ZvTgN0wZ2aMMdEa8w3UQvxoN
 +Iu0Z3kRtltbw5zqTTdJfXPHS3K1I+361zTT6E4KDVun2939C3Tzw6ziy6MIsng+
 nysaMbZTc5MmdIDPYtSlIV+i4S4DyqvAKsv5PBqqbD3oQfo8AkmnyY6Hdygbv23O
 vK23x19GYcpgLQ42C0g+LFUYxJOJMnMiOocISq8V7Df9+CQRNnk4e7s8MvmhAXmu
 VrOT1VDEL8bJFeukiMRtVTsDo/KRHOWUjEi+1dxJ7aOqry8FGrlR4L+ZtjbMTnmw
 V+7CN0euOdpiDV6jJwmXHQvLWlG3wgq7ZHHj6toaFtq8FI4OaQiA7Ko5WuBLTBxw
 V0jtK/Fru77P0aR7dAd5ck6Rwek8N2rSuOvpucLmImt9asZP3uzoM/LRmtv4Gzjq
 Dp8koqSwx6YMtMAHmXgB/2GkSoOV7eByvIkYCoFCxEp2tst+mIOKSQPDKP8PKuRd
 VBSmvuEilis=
 =Fo38
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-6.2a-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next

Jonathan writes:

1st set of IIO new device support, feature and cleanup for 6.2 (take2)

We have finally managed to take the mlock mutex entirely private so as
to avoid it being used for multiple purposes.  Now it is just used to
protect device mode transitions (typically to and from buffered capture).

Includes merge of an immutable i2c branch to get the new
i2c_client_get_device_id() (thanks to Wolfram for providing the branch).

Based on rc3 to pick up some precursor fixes from early in the cycle and
avoid an unnecessarily messy history.

New device support
* adi,ad4310
  - New driver to support this very flexible measurement device including
    a 24 bit ADC. Later fix for documentation build issue.
* adi,adxl355
  - Add support of the ADXL359 accelerometer.
* adi,ltc2983
  - Support additional variants of the temperatures sensor:
    LTC2984 with an EEPROM
    LTC2985, LTC2986 with only 10 channels.
* invensense,icm42600
  - Add support for icm42631 (needed only ID and WHOAMI)
* kionix,kx022a
  - New driver for this 3 axis accelerometer.
* maxim,max11401
  - New driver to support this 24-bit 10 channel ADC.
    Includes some new ABI to support configuration of notch filters.
* mediatek,mt6370
  - Add new driver to support the ADC part of the mt6370.
* st,lsm6dsx
  - Add support for LSM6DSV accelerometer and gyroscope. Simple additional
    of chip specific data and IDs.
  - Add support for LSM6DSV16X accelerometer and gyroscope.  Compatible with
    features currently implemented for the LSM6DSV.
* st,stm32-adc
  - Add support for stm32pm13x SoCs.

core / subsystem wide:
 - Add new IIO_STATIC_CONST_DEVICE_ATTR() which is a dance necessary to
   allow for the wrapping of attributes in the code that duplicates them
   for multiple buffers.
 - Harden against future issues with expectation that all buffer attributes
   are iio_dev_attrs by changing the code to take an array of pointers
   of the correct type.
 - Last transitions of drivers to local locks rather than missuses of mlock.
 - Add an iio_device_claim_buffer_mode() callback to avoid a race in the
   max30100 driver without directly using mlock.
 - Move mlock to the opaque IIO device structure to prevent misuse.
 - Add missing spi_device_id tables to support auto loading of modules.
 - Update some ADI maintainers in DT bindings.
 - A few more moves of bus drivers and core module sets to export
   name spaces.
 - Extensive use of new devm_regulator_get_enable() and friends.
 - Switch a bunch of i2c drivers to probe_new() including the bmp280
   which makes use of the new i2c_client_get_device_id() helper to
   simplify this change.

dt-bindings:
 - More use of spi-peripheral-props.yaml.

Features
* freescale,mpl115
  - Use runtime PM to implement shutdown GPIO support.
* melexis,mlx90632
  - More sophisticated runtime power management
  - Provide access to sampling frequency.
  - Trivial follow up fixes.
* microchip,mcp3911
  - Support control of PGA.
* st,lsm6dsx
  - Add support for software triggers for cases where the IRQ lines
    are not wired up.
* vishay,vcnl4000
  - Add control of integration time.

Minor cleanups and fixes
* adi,ad4130
  - Improve ABI documentation formatting.
  - Kconfig dependency fixup.
* adi,ad5758
  - Minor dt binding fix.
* adi,ad9834
  - Tidy up line breaks.
* adi,ade7854
  - Minor improvement in code clarity by replacing a ternary.
* adi,admv8818
  - Harden code against hardware returning wrong values.
* adi,adxl355
  - Warn only if unknown device ID detected to allow for fall back
    device tree compatibles on future devices.
* adi,ltc2983
  - dt-bindings clarifications and general improvements.
  - Ensure DMA safe buffer for bulk writes without relying on current
    regmap implementation choices.
* avago,adps9960
  - Fix up a disconnect between event enable attributes and what was
    enabled.
* bosch,bma400
  - Switch to dev_err_probe() from open coded EPROBE_DEFER handling.
* cosmic,cc10001
  - Fully devm managed probe() and related tidying up.
* meas,ms5611
  - Add an example of spi-max-frequency.
* meleixs,mlx90632
  - Tidy up confusing error return value.
  - Style improvements.
* multiplexer
  - Switch to dev_err_probe() from open coded EPROBE_DEFER handling.
* qcom,spmi-vadc
  - Minor dt binding improvements.
* rockchip,saradc
  - Add ID for rv1126.
* semtech,sx9360
  - Add SAMM0208 ACPI ID. Doesn't appear to be a valid vendor prefix
    but is in the wild.
* st,lsm6dsx
  - Factor out common code as _device_set_enable().
  - Fix up wrong docs after LSM6DSV addition.
* st,stm32-adc
  - Manage the min sampling time on all internal channels.
* trig,sysfs
  - Improve error labels.

* tag 'iio-for-6.2a-take2' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (146 commits)
  iio: pressure: bmp280: convert to i2c's .probe_new()
  iio: imu: st_lsm6dsx: fix LSM6DSV sensor description
  iio: adc: ad4130: depend on GPIOLIB
  staging: iio: meter: replace ternary operator by if condition
  iio: light: apds9960: Fix iio_event_spec structures
  dt-bindings: iio: imu: Add inv_icm42600 documentation
  iio: imu: inv_icm42600: Add support for icm42631
  dt-bindings: iio: adc: rockchip-saradc: Add saradc for rv1126
  dt-bindings: iio: dac: adi,ad5758: Drop 'contains' from 'adi,dc-dc-mode'
  dt-bindings: iio: imu: st_lsm6dsx: add lsm6dsv16x
  iio: imu: st_lsm6dsx: add support to LSM6DSV16X
  iio: proximity: sx9360: Add a new ACPI hardware ID
  iio: temperature: mlx90632: Add missing static marking on devm_pm_ops
  iio: temperature: mlx90632: Add error handling for devm_pm_runtime_enable()
  iio: temperature: ltc2983: support more parts
  dt-bindings: iio: temperature: ltc2983: support more parts
  dt-bindings: iio: temperature: ltc2983: use generic node name in example
  dt-bindings: iio: temperature: ltc2983: describe broken mux delay property
  dt-bindings: iio: temperature: ltc2983: refine descriptions
  dt-bindings: iio: temperature: ltc2983: change default excitation for custom thermistors
  ...
2022-11-25 18:35:16 +01:00
Yuan Can
2a22b40aea iio: accel: bma400: Switch to use dev_err_probe() helper
In the probe path, dev_err() can be replace with dev_err_probe()
which will check if error code is -EPROBE_DEFER and prints the
error name.

Signed-off-by: Yuan Can <yuancan@huawei.com>
Link: https://lore.kernel.org/r/20220921023915.47300-1-yuancan@huawei.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-23 19:43:56 +00:00
Dong Chenchen
20690cd50e iio: accel: bma400: Fix memory leak in bma400_get_steps_reg()
When regmap_bulk_read() fails, it does not free steps_raw,
which will cause a memory leak issue, this patch fixes it.

Fixes: d221de60ee ("iio: accel: bma400: Add separate channel for step counter")
Signed-off-by: Dong Chenchen <dongchenchen2@huawei.com>
Reviewed-by: Jagath Jog J <jagathjog1996@gmail.com>
Link: https://lore.kernel.org/r/20221110010726.235601-1-dongchenchen2@huawei.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-11-12 17:49:22 +00:00
Jonathan Cameron
57572cacd3 iio: accel: bma400: Ensure VDDIO is enable defore reading the chip ID.
The regulator enables were after the check on the chip variant, which was
very unlikely to return a correct value when not powered.
Presumably all the device anyone is testing on have a regulator that
is already powered up when this code runs for reasons beyond the scope
of this driver. Move the read call down a few lines.

Fixes: 3cf7ded15e ("iio: accel: bma400: basic regulator support")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Dan Robertson <dan@dlrobertson.com>
Cc: <Stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20221002144133.3771029-1-jic23@kernel.org
2022-10-29 12:24:40 +01:00
Jonathan Cameron
6ee2a7058f iio: accel: bma400: Fix smatch warning based on use of unintialized value.
Only specific bits in this value are ever used and those are initialized,
but that is complex to reason about in a checker. Hence, initialize
the value to zero and avoid the complexity.

Smatch warning:
drivers/iio/accel/bma400_core.c:1287 bma400_tap_event_en()
error: uninitialized symbol 'field_value'.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jagath Jog J <jagathjog1996@gmail.com>
Cc: Alexander Potapenko <glider@google.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Jagath Jog J <jagathjog1996@gmail.com>
Fixes: 961db2da15 ("iio: accel: bma400: Add support for single and double tap events")
Link: https://lore.kernel.org/r/20220917131401.2815486-1-jic23@kernel.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21 18:42:57 +01:00
Jagath Jog J
961db2da15 iio: accel: bma400: Add support for single and double tap events
Add support for single and double tap events based on the tap threshold
value, minimum quiet time before and after the tap and minimum time
between the taps in the double tap. The INT1 pin is used to interrupt
and the event is pushed to userspace.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Link: https://lore.kernel.org/r/20220831063117.4141-3-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-05 18:08:42 +01:00
Jonathan Cameron
12c4efe350 iio: core: Fix IIO_ALIGN and rename as it was not sufficiently large
Discussion of the series:
https://lore.kernel.org/all/20220405135758.774016-1-catalin.marinas@arm.com/
mm, arm64: Reduce ARCH_KMALLOC_MINALIGN brought to my attention that
our current IIO usage of L1CACHE_ALIGN is insufficient as their are Arm
platforms out their with non coherent DMA and larger cache lines at
at higher levels of their cache hierarchy.

Rename the define to make it's purpose more explicit. It will be used
much more widely going forwards (to replace incorrect ____cacheline_aligned
markings.

Note this patch will greatly reduce the padding on some architectures
that have smaller requirements for DMA safe buffers.

The history of changing values of ARCH_KMALLOC_MINALIGN via
ARCH_DMA_MINALIGN on arm64 is rather complex. I'm not tagging this
as fixing a particular patch from that route as it's not clear what to tag.

Most recently a change to bring them back inline was reverted because
of some Qualcomm Kryo cores with an L2 cache with 128-byte lines
sitting above the point of coherency.

c1132702c7 Revert "arm64: cache: Lower ARCH_DMA_MINALIGN to 64 (L1_CACHE_BYTES)"
That reverts:
65688d2a05 arm64: cache: Lower ARCH_DMA_MINALIGN to 64 (L1_CACHE_BYTES) which
refers to the change originally being motivated by Thunder x1 performance
rather than correctness.

Fixes: 6f7c8ee585 ("staging:iio: Add ability to allocate private data space to iio_allocate_device")
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20220508175712.647246-2-jic23@kernel.org
2022-06-14 11:53:11 +01:00
Jagath Jog J
3cf122c20b iio: accel: bma400: Add support for activity and inactivity events
Add support for activity and inactivity events for all axis based on the
threshold, duration and hysteresis value set from the userspace. INT1 pin
is used to interrupt and event is pushed to userspace.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Link: https://lore.kernel.org/r/20220505133021.22362-9-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Jagath Jog J
00ee658ff5 iio: accel: bma400: Add activity recognition support
Add support for activity recognition like STILL, WALKING, RUNNING
and these events are pushed to the userspace whenever the STEP
interrupt occurs.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Link: https://lore.kernel.org/r/20220505133021.22362-8-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Jagath Jog J
d024af5b39 iio: accel: bma400: Add step change event
Added support for event when there is a detection of step change.
INT1 pin is used to interrupt and event is pushed to userspace.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Link: https://lore.kernel.org/r/20220505133021.22362-7-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Jagath Jog J
d221de60ee iio: accel: bma400: Add separate channel for step counter
Added channel for step counter which can be enable or disable
through the sysfs interface.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Link: https://lore.kernel.org/r/20220505133021.22362-6-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Jagath Jog J
ffe0ab6a96 iio: accel: bma400: Add triggered buffer support
Added trigger buffer support to read continuous acceleration
and temperature data from device with data ready interrupt which
is mapped to INT1 pin.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220505133021.22362-5-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Jagath Jog J
12c99f859f iio: accel: bma400: conversion to device-managed function
This is a conversion to device-managed by using devm_iio_device_register()
inside probe function. Previously the bma400 was not put into power down
mode in some error paths in probe where it now is, but that should cause
no harm.

The dev_set_drvdata() call, bma400_remove() function and hooks in the I2C
and SPI driver struct is removed as devm_iio_device_register() function is
used to automatically unregister on driver detach.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220505133021.22362-4-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Jagath Jog J
1bd2dc6ea8 iio: accel: bma400: Reordering of header files
Reordering of header files and removing the iio/sysfs.h since
custom attributes are not being used in the driver.

Signed-off-by: Jagath Jog J <jagathjog1996@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20220505133021.22362-3-jagathjog1996@gmail.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11 14:35:26 +01:00
Jonathan Cameron
f9c02c9485 iio:accel:bma400: Move exports into IIO_BMA400 namespace
In order to avoid unnecessary pollution of the global symbol namespace
move the core bma400 functions into a bma400 specific namespace
and import that into the two bus modules.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20220116180535.2367780-5-jic23@kernel.org
2022-02-18 11:36:53 +00:00
Uwe Kleine-König
fa0b148eb3 iio: accel: bma400: Make bma400_remove() return void
When an i2c or spi driver's remove function returns a non-zero error
code nothing happens apart from emitting a generic error message. Make
this error message more device specific and return zero instead in the
remove callbacks. As the return value of bma400_remove() is unused then,
change the function to not yield a return value.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Reviewed-by: Alexandru Ardelean <ardeleanalex@gmail.com>
Link: https://lore.kernel.org/r/20211013203223.2694577-2-u.kleine-koenig@pengutronix.de
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-10-19 08:30:45 +01:00
Andy Shevchenko
b892770a2c iio: Drop Duplicated "mount-matrix" parameter
All of the users of iio_read_mount_matrix() are using the very same
property name. Moreover, the property name is hard coded in the API
documentation.

Make this clear and avoid duplication now and in the future.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Sean Nyekjaer <sean@geanix.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210518112546.44592-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-06-03 18:24:13 +01:00
Alexandru Ardelean
d3be83244c iio: remove explicit IIO device parent assignment
This patch applies the semantic patch:
@@
expression I, P, SP;
@@
   I = devm_iio_device_alloc(P, SP);
   ...
-  I->dev.parent = P;

It updates 302 files and does 307 deletions.
This semantic patch also removes some comments like
'/* Establish that the iio_dev is a child of the i2c device */'

But this is is only done in case where the block is left empty.

The patch does not seem to cover all cases. It looks like in some cases a
different variable is used in some cases to assign the parent, but it
points to the same reference.
In other cases, the block covered by ... may be just too big to be covered
by the semantic patch.

However, this looks pretty good as well, as it does cover a big bulk of the
drivers that should remove the parent assignment.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:59 +01:00
Dan Carpenter
98496ccdf0 iio: accel: bma400: prevent setting accel scale too low
This puts an upper bound on "val2" but it also needs to have a lower
bound (BMA400_SCALE_MIN).

Fixes: 465c811f1f ("iio: accel: Add driver for the BMA400")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-01-18 13:33:11 +00:00
Dan Robertson
3cf7ded15e iio: accel: bma400: basic regulator support
Add support for the VDD and VDDIO regulators using the regulator
framework.

Signed-off-by: Dan Robertson <dan@dlrobertson.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:02 +00:00
Dan Robertson
465c811f1f iio: accel: Add driver for the BMA400
Add a IIO driver for the Bosch BMA400 3-axes ultra-low power accelerometer.
The driver supports reading from the acceleration and temperature
registers. The driver also supports reading and configuring the output data
rate, oversampling ratio, and scale.

Signed-off-by: Dan Robertson <dan@dlrobertson.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-12-29 15:20:02 +00:00