Commit Graph

1444188 Commits

Author SHA1 Message Date
Stepan Ionichev
f608e9c032 Documentation: iio: make ADXL Y-axis calibbias description consistent
The Y-axis calibbias rows in adxl345.rst, adxl313.rst and adxl380.rst
use a different wording than the matching X-axis and Z-axis rows in
the same tables: the X/Z rows say "Calibration offset for the
X/Z-axis accelerometer channel." while the Y row says "Y-axis (or
y-axis) acceleration offset correction".

Make the Y-axis row match the other two so each driver's sysfs
table has consistent capitalisation and wording.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Stepan Ionichev
2f856ad3f7 Documentation: iio: fix typo in triggered-buffers example
In the "IIO triggered buffer setup" example, iio_triggered_buffer_setup()
is called with "sensor_iio_polfunc" (single 'l') while the function is
defined and later referenced as "sensor_iio_pollfunc" (double 'l'). Fix
the misspelling so the example is consistent.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Stepan Ionichev
b049fb4081 iio: adc: ad7192: fix GPOCON register access annotation
The comment next to AD7192_REG_GPOCON marks the register as RO,
but the AD7192 datasheet (Rev. A, page 24, GPOCON REGISTER) says:
"The GPOCON register is an 8-bit register from which data can be
read or to which data can be written."

The driver itself uses ad_sd_write_reg() against this register in
ad7192_show_scale() / write paths to control the bridge power-down
switch and digital outputs, which matches the RW datasheet
description. Update the comment to RW so it does not mislead
future readers.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Raffael Raiel Trindade
469ad4d50f iio: light: vcnl4000: use lock guard()
Use guard() and scoped_guard() for handling mutex lock instead of manually
locking and unlocking. Remove gotos in error handling logic. This prevents
forgotten locks on early exits.

Signed-off-by: Raffael Raiel Trindade <raffaelraiel@usp.br>
Co-developed-by: Kim Carvalho <kim.ca@usp.br>
Signed-off-by: Kim Carvalho <kim.ca@usp.br>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Maxwell Doose
29bf2693c9 dt-bindings: iio: chemical: sensirion,scd30: Update maintainers field
Tomasz Duszynski is no longer the maintainer of the SCD30 driver.
Replace his entry with mine.

Link: https://lore.kernel.org/linux-iio/20260507172404.80435-1-m32285159@gmail.com/
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Joshua Crofts
a9a00d727b iio: magnetometer: ak8975: fix potential kernel stack memory leak
Currently in the AK8975 driver there are four instances where potential
uninitialized kernel stack memory leaks can occur. If
i2c_smbus_read_i2c_block_data_or_emulated() returns a value less than
the size of the buffer, uninitialized bytes are retained in the buffer
and later the buffer is passed on to IIO buffers, potentially leaking
memory to userspace.

Fix this by adding checks whether the return value of the function is
equal to the size of the buffer and subsequently if the value is
lesser than zero to distinguish from a returned error code.

Fixes: bc11ca4a0b ("iio:magnetometer:ak8975: triggered buffer support")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260513-ak8975-fix-v1-1-104ea605dd54%40gmail.com
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Joshua Crofts
eaead586b3 iio: magnetometer: ak8975: ensure device is awake for buffered capture
Currently, the ak8975_start_read_axis() can be called while the device
is autosuspended, causing two issues:

1. I2C transfers in the aforementioned function will fail or timeout
because ak8975_runtime_suspend() disables the device regulators.
2. Since ak8975_fill_buffer() does not hold runtime references,
ak8975_runtime_suspend() can run concurrently, and since PM callbacks
do not use a locking mechanism, it may cause a race accessing the
control register via the I2C bus.

Fix this issue by adding struct iio_buffer_setup_ops that contains
preenable and postdisable functions to ensure correct that device is
powered on when running a buffered capture.

Fixes: bc11ca4a0b ("iio:magnetometer:ak8975: triggered buffer support")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260511-magnetometer-fixes-post-pickup-v7-0-9d910faa28b6%40gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Hungyu Lin
8bf3e7a9de staging: iio: addac: adt7316: document SPI interface switching sequence
The device powers up in I2C mode. Switching to SPI mode
requires sending a sequence of SPI writes as described in
the datasheet.

During this sequence, the device may still be in I2C mode,
so SPI transactions may not be recognized and can fail.
Such errors are therefore ignored.

Add a comment to clarify this behavior.

Datasheet: https://www.analog.com/en/products/adt7316.html
Reviewed-by: Maxwell Doose <m32285159@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:40 +01:00
Andy Shevchenko
79ab48ae4f iio: magnetometer: ak8975: consistently use 'data' parameter
Some of the functions use 'client', some use 'data', and some use both.
Refactor the driver to consistently use 'data' in all cases.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Joshua Crofts
46dd701a39 iio: magnetometer: ak8975: check if gpiod read was successful
Add a check that ensures that valid data has been read from GPIOD. If
not, log an error and return the negative read value.

Suggested-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: Maxwell Doose <m32285159@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Joshua Crofts
cfa30b4330 iio: magnetometer: ak8975: modernize polling loops with iopoll() macros
The driver currently uses while loops and msleep() for polling during
conversion waits.

Replace the custom polling loops with readx_poll_timeout() and
read_poll_timeout() macros from <linux/iopoll.h>. This reduces
boilerplate, standardizes timeout handling and improves overall code
readability, keeping the original timing and error behaviour. Add
<linux/time.h> for USEC_PER_MSEC macro instead of using magic numbers.

Assisted-by: Gemini:3.1-Pro
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Sanjay Chitroda
bdc573d5c3 MAINTAINERS: Update maintainer for IIO drivers
The listed Analog Devices domain email for Cosmin Tanislav is no
longer valid, and he is no longer maintaining these IIO drivers.

Add Marcelo Schmitt as the maintainer from Analog Devices to continue
support and maintenance of the affected drivers.

Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Reviewed-by: Marcelo Schmitt <marcelo.schmitt@analog.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Sanjay Chitroda
d350cb2b23 MAINTAINERS: Update Analog Devices IIO drivers entry
Lars-Peter Clausen is currently busy and is therefore removed from the
ANALOG DEVICES INC IIO DRIVERS entry, with input from Jonathan.

Add Analog Devices mailing list as contact and Nuno Sá as maintainer
for the ANALOG DEVICES INC IIO DRIVERS entry for coverage support.

Suggested-by: Jonathan Cameron <jonathan.cameron@huawei.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Sanjay Chitroda <sanjayembeddedse@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Uwe Kleine-König (The Capable Hub)
3f439a2a5b iio: Drop unused driver_data in four i2c drivers
For the four drivers the .driver_data member of i2c_device_id is
write-only. Drop the explicit assignment.

While touching these arrays use a named initializer to assign the .name
member, which is easier to parse for a human.

Signed-off-by: Uwe Kleine-König (The Capable Hub) <u.kleine-koenig@baylibre.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Piyush Patle
0ce8e3b445 iio: adc: hx711: move scale computation to per-device storage
The gain-to-scale table is global today, so probe-time scale updates for
one device overwrite the values used by any earlier device instance.

Fix this by making the gain table const and storing the computed scale
values per device in hx711_data.

No functional change for single-sensor configurations.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Piyush Patle
d20605e181 dt-bindings: iio: adc: hx711: clean up existing binding text
Rewrite the binding description and property text so it describes the
existing HX711 hardware behavior directly instead of documenting old
driver implementation details.

Also clarify that clock-frequency controls the SCK bit-bang timing.

No functional change.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Antony Kurniawan Soemardi
92767f9f57 dt-bindings: iio: adc: qcom,pm8018-adc: add label property for ADC channels
Add a new optional label property for ADC channels to help users
identify each channel when reading values from the sysfs interface.

Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:39 +01:00
Antony Kurniawan Soemardi
70a1012793 iio: adc: qcom-pm8xxx-xoadc: add support for reading channel labels
Implement the .read_label callback to allow userspace to identify ADC
channels via the "label" property in the device tree. The name field in
pm8xxx_chan_info is renamed to label to better reflect its purpose. If
no label is provided in the device tree, it defaults to the hardware
datasheet name.

The change has been tested on Sony Xperia SP (PM8921).

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com>
Reviewed-by: Linus Walleij <linusw@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Antony Kurniawan Soemardi
fcec89dfec iio: adc: qcom-pm8xxx-xoadc: remove redundant error logs when reading values
Drop dev_err() logging for -EINVAL and -ETIMEDOUT cases and rely on
return values to report errors, reducing unnecessary log noise.

Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Antony Kurniawan Soemardi <linux@smankusors.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Stepan Ionichev
01b7517513 iio: accel: adxl355: replace usleep_range() with fsleep()
The "at least 5ms" wait after software reset has no specific upper
bound. Use fsleep() with 5 * USEC_PER_MSEC to make the unit
explicit at the call site.

No functional change.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Stepan Ionichev
7e6a73eda9 iio: adc: ad7192: replace usleep_range() with fsleep()
The AD7192 datasheet (Rev. A, page 34, RESET section) says:
"When a reset is initiated, the user must allow a period of
500 us before accessing any of the on-chip registers."

Use fsleep(500) instead of usleep_range(500, 1000).

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Md Shofiqul Islam
01437ab511 iio: adc: ti-ads1298: Remove unnecessary CONFIG2 write during init
The driver was enabling the internal test signal (INT_TEST), double
amplitude (TEST_AMP), and fast frequency (TEST_FREQ_FAST) bits in
CONFIG2 during initialization. These bits activate an internal square
wave generator intended for device testing and calibration, not normal
ECG operation.

CONFIG2 defaults to having only the RESERVED bit set after reset, which
is the correct value for normal operation. Remove the write entirely
since it would just be writing the reset default value.

Suggested-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Md Shofiqul Islam
5d7b3df5c1 iio: adc: ti-ads1298: Add parentheses around macro parameter
ADS1298_REG_CHnSET() is missing parentheses around the parameter 'n'.
Add them to follow kernel macro coding style and prevent potential
operator precedence issues if the argument is an expression.

Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com>
Acked-by: Mike Looijmans <mike.looijmans@topic.nl>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Md Shofiqul Islam
d0f23d8a90 iio: adc: ti-ads1298: Fix incorrect timeout comment
At the lowest supported data rate of 250Hz, one conversion period is
4ms, not 40ms. The 50ms timeout is deliberately conservative to allow
for kernel scheduling latency, which can be significant under load or
on slow machines.

Fix the comment to state the correct conversion time, use "lowest sample
rate" for clarity, and explain that the extra margin exists to absorb
scheduling latency so that no one is tempted to shrink the timeout to
match the conversion period.

Also drop the redundant ret variable assignment by using the return value
of wait_for_completion_timeout() directly in the if() condition.

Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Stepan Ionichev
af74304c9f iio: frequency: adrf6780: replace usleep_range() with fsleep()
The ADRF6780 datasheet (Rev. D, page 23, ADC section) says:
"Wait approximately 200 us for the ADC to be ready."

fsleep(200) expands to the same usleep_range(200, 250). Use the
flexible sleep helper, which picks the right primitive for the
given microsecond delay.

Replace the generic "Recommended delay for the ADC to be ready"
comment with the datasheet reference so the "why" of the wait is
visible at the call site.

No functional change.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Stepan Ionichev
a67d263922 iio: adc: ad7793: replace usleep_range() with fsleep()
The AD7792/AD7793 datasheet (Rev. B, page 25, RESET section)
says: "When a reset is initiated, the user must allow a period
of 500 us before accessing any of the on-chip registers."

Use fsleep(500) instead of usleep_range(500, 2000). The 500 us
minimum stays the same; fsleep() picks the upper slack itself
(about +25% on a default config -- narrower than the original
2000 us).

Add a code comment with the datasheet reference so the "why"
of the wait is visible at the call site.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:38 +01:00
Stepan Ionichev
8e9c394520 iio: chemical: scd30: reject (response=NULL, size>0) in scd30_i2c_command()
scd30_i2c_command() takes an opaque "response" buffer plus its size.
At the start of the function the code already checks if response is
NULL (via the rsp local), but the response-decoding loop after the
i2c transfer always dereferences rsp without re-checking. With the
current callers in scd30_core.c this is harmless, since write
commands pass response=NULL together with size=0 (so the loop body
is never entered).

The (response=NULL, size>0) combination has no useful meaning: there
is nowhere to put the bytes that come back from the chip. Treat it
as an invalid argument and bail out at the top of the function with
-EINVAL, instead of silently doing the i2c transfer and dereferencing
a NULL pointer in the decode loop.

smatch flagged the inconsistency:

  drivers/iio/chemical/scd30_i2c.c:104 scd30_i2c_command() error: we
    previously assumed rsp could be null (see line 77)

No functional change for the existing callers, which only ever use
(response=NULL, size=0) for writes and (response!=NULL, size>0) for
reads.

Signed-off-by: Stepan Ionichev <sozdayvek@gmail.com>
Acked-by: Maxwell Doose <m32285159@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Giorgi Tchankvetadze
ae008f6539 iio: chemical: scd30: make command lookup table const
scd30_i2c_cmd_lookup_tbl contains fixed opcodes and is
only read by scd30_i2c_command(). Make it const to document that it's immutable
and allow it to be placed in read-only memory.

Signed-off-by: Giorgi Tchankvetadze <giorgitchankvetadze1997@gmail.com>
Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com>
Acked-by: Maxwell Doose <m32285159@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Andy Shevchenko
49d7edc9bd iio: magnetometer: yamaha-yas530: replace usleep_range() with fsleep()
Replace usleep_range() with fsleep() to allow the kernel
to select the most appropriate delay mechanism based on duration.
Using USEC_PER_MSEC makes the unit conversion explicit.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Andy Shevchenko
6a0814f6f9 iio: magnetometer: yamaha-yas530: Use devm_mutex_init() for mutex initialization
Use devm_mutex_init() since it brings some benefits when
CONFIG_DEBUG_MUTEXES is enabled.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Andy Shevchenko
10ecf78420 iio: magnetometer: yamaha-yas530: Get rid of i2c_client_get_device_id()
Instead of relying on the name from ID table, which might be ambiguous
in some cases, use explicit product label in the driver data. With that
being done, get rid of i2c_client_get_device_id() call.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Maxwell Doose
4452b868d6 MAINTAINERS: Add myself as SCD30 maintainer
The current maintainer's email is no longer valid and the driver is
being orphaned. Replace his entry with mine, as I am volunteering to
take over.

Link: https://lore.kernel.org/linux-iio/20260507170950.37a46820@jic23-huawei/T/#t
Signed-off-by: Maxwell Doose <m32285159@gmail.com>
Reviewed-by: Stepan Ionichev <sozdayvek@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Felipe Ribeiro de Souza
a42fea8596 iio: adc: ingenic-adc: use guard()() and scoped_guard() to handle synchronisation
Replace mutex_lock() and mutex_unlock() calls with guard()() in
functions ingenic_adc_set_adcmd(), ingenic_adc_set_config(),
ingenic_adc_enable(), ingenic_adc_capture(), and with scoped_guard()
in function ingenic_adc_read_chan_info_raw().

This removes the need to call the unlock function, as the lock is
automatically released when the function return or the scope exits
for any other case.

Signed-off-by: Felipe Ribeiro de Souza <felipers@ime.usp.br>
Co-developed-by: Lucas Ivars Cadima Ciziks <lucas@ciziks.com>
Signed-off-by: Lucas Ivars Cadima Ciziks <lucas@ciziks.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Felipe Ribeiro de Souza
7ea43bebc7 iio: adc: ingenic-adc: refactor ingenic_adc_read_chan_info_raw()
Extract the sample logic from ingenic_adc_read_chan_info_raw() into
a new helper function __ingenic_adc_read_chan() to improve code
readability and modularity.

The helper handles the mutex-protected section for sampling channels,
while the main function manages mutex and clock enabling/disabling.

Signed-off-by: Felipe Ribeiro de Souza <felipers@ime.usp.br>
Co-developed-by: Lucas Ivars Cadima Ciziks <lucas@ciziks.com>
Signed-off-by: Lucas Ivars Cadima Ciziks <lucas@ciziks.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Felipe Ribeiro de Souza
a3c9f67859 iio: adc: ingenic-adc: rename ingenic_adc_enable_unlocked() function
Rename ingenic_adc_enable_unlocked() to __ingenic_adc_enable() to
better reflect that this helper must be called with the lock held.

Signed-off-by: Felipe Ribeiro de Souza <felipers@ime.usp.br>
Co-developed-by: Lucas Ivars Cadima Ciziks <lucas@ciziks.com>
Signed-off-by: Lucas Ivars Cadima Ciziks <lucas@ciziks.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Andy Shevchenko
a474d5cbdf iio: magnetometer: ak8975: unify return code variable name
In one case 'rc' is used in the other 'err', the most use 'ret'.
Make the latter use the former, id est 'ret'.

While at it, drop unneeded ' < 0' checks.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:37 +01:00
Andy Shevchenko
dbb1f2fa2b iio: magnetometer: ak8975: reduce usage of magic lengths of the buffer
Reduce usage of magic lengths of the supplied buffer by replacing them
with the corresponding sizeof():s.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Andy Shevchenko
77e7524944 iio: magnetometer: ak8975: remove duplicate error message
The devm_request_irq() already prints an error message.
Remove the duplicate.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Andy Shevchenko
6982743df9 iio: magnetometer: ak8975: drop duplicate NULL check
The gpiod_set_consumer_name() is NULL-aware, no need to perform the same
check in the caller.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Andy Shevchenko
4cff988383 iio: magnetometer: ak8975: avoid using temporary variable
Avoid using temporary variable in ak8975_read_axis(). With that being done,
the clamp_t() call becomes idiomatic in the driver and can be factored out
to a helper later on (and if needed).

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Joshua Crofts
c0b3561c8e iio: magnetometer: ak8975: pass conversion timeouts as arguments
Refactor wait_conversion_complete*_() helper function to accept poll
and timeout values directly as parameters. This improves the
readability of the code and does not rely on hardcoded macros.

Besides that, fix the home grown and obviously wrong in some cases the
jiffy-based timeout.

Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Joshua Crofts
acea3560f3 iio: magnetometer: ak8975: fix wrong errno on return
The driver currently returns -EINVAL on polling timeout instead of
-ETIMEDOUT.

Replace return code for -ETIMEDOUT and remove unnecessary error
message as -ETIMEDOUT is a standard POSIX error. Also replace
instances of -EINVAL in comments.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Joshua Crofts
833ca882b7 iio: magnetometer: ak8975: change 'u8*' to 'u8 *' in cast
Change 'u8*' cast to 'u8 *' as the former triggers a checkpatch error.
Also fix the indentation of parameters in
i2c_smbus_read_i2c_block_data_or_emulated() function.

No functional change.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Reviewed-by: Maxwell Doose <m32285159@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Joshua Crofts
1fcd1fef65 iio: magnetometer: ak8975: replace usleep_range() with fsleep()
Replace usleep_range() calls with fsleep(), passing the minimum value
required by the sensor for hardware delays.

fsleep() automatically selects the optimal sleep mechanism, simplifying
driver code and time management.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Joshua Crofts
9d59def370 iio: magnetometer: ak8975: update headers per IWYU principle
Remove kernel.h proxy header and unused headers (slab.h, iio/sysfs.h,
iio/trigger.h). Add missing headers to ensure atomicity (array_size.h,
dev_printk.h, asm/byteorder.h, irqreturn.h, minmax.h, property.h,
types.h, wait.h).

Audited using the include-what-you-use tool.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: Maxwell Doose <m32285159@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Joshua Crofts
bde5858a27 iio: magnetometer: ak8975: sort headers alphabetically
Sort include headers alphabetically to improve coding style and
readability.

No functional change.

Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com>
Reviewed-by: Maxwell Doose <m32285159@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:36 +01:00
Andy Shevchenko
e94944d736 iio: magnetometer: ak8975: Add missed pm_runtime_put_autosuspend() call
On the failure in the ak8975_read_axis() the PM runtime gets unbalanced.
Balance it by calling pm_runtime_put_autosuspend() on error path as well.

Fixes: cde4cb5dd4 ("iio: magn: ak8975: deploy runtime and system PM")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260505-magnetometer-fixes-v5-0-831b9b5550fc%40gmail.com
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:35 +01:00
Kim Seer Paller
67f4f2b31d iio: ABI: Add DAC 500ohm, 3.85kohm, and 16kohm powerdown modes
Add powerdown mode entries for DACs with 500 Ohm, 3.85 kOhm, and
16 kOhm resistor to ground output impedance states. These are used
by the AD3531/AD3531R 4-channel DAC.

Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:35 +01:00
Wang Zihan
f2c7187e26 iio: adxl313: fix typos in documentation
Add missing space in "ADXL313is" and improve grammar for
"a single types of channels" to "multiple channels of a single type"
as suggested by Jonathan Cameron.

Wrap long line as suggested by Andy Shevchenko.

Signed-off-by: Wang Zihan <jiyu03@qq.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:35 +01:00
Pedro Barletta Gennari
f326d8f8f0 iio: light: iqs621-als: prefer early error handling over if (!ret)
Handle errors as early as possible by replacing 'if (!ret)' with the
more common form 'if (ret)'. This makes the code easier to read.

Signed-off-by: Pedro Barletta Gennari <pedro.pbg@usp.br>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2026-05-31 10:59:35 +01:00