Commit graph zephyr/drivers/sensor
Author SHA1 Message Date
Chunlei Zhou
fa3f8ba40b drivers: sensor: mpu6050: log the unexpected chip ID
Include the chip ID in the MPU6500-family detection log and in the
error for an unrecognized ID. This exposes the value read from
WHO_AM_I without requiring a separate register read.

Assisted-by: Codex:gpt-6.1-sol
Signed-off-by: Chunlei Zhou <619247683@qq.com>
2026-10-09 17:02:37 +02:00
Chunlei Zhou
31f123356b drivers: sensor: mpu6050: add support for MPU6515
The MPU6515 reports 0x74 in WHO_AM_I, which the driver currently
rejects. Accept this ID and select DEVICE_TYPE_MPU6500 to reuse the
MPU6500 register handling and die temperature conversion.

Assisted-by: Codex:gpt-6.1-sol
Signed-off-by: Chunlei Zhou <619247683@qq.com>
2026-10-09 17:02:37 +02:00
Pete Johanson
8a46a12e9c drivers: sensor: Fix multiple streaming requests for ADXL362
Properly clear the watermark IRQ value when handling no active SQE, to
ensure that multiple sequential streaming requests work properly.

Signed-off-by: Pete Johanson <pete.johanson@analog.com>
2026-10-09 16:51:29 +02:00
Sibo Van Gool
12639bd9a4 drivers: sensor: adxl355: wait for the device after its soft reset
After the reset command the ADXL355 does not respond until it has
reloaded its NVM: reads return 0xFF and writes are ignored. The probe
programmed the device right away with read-modify-writes, which then
started from 0xFF. Depending on timing, one of them landed with the
reserved bits set, for example FILTER = 0x0F (a reserved ODR), and the
device output zero on all axes.

Poll STATUS every 1 ms after the reset until NVM_BUSY is clear, for at
most 100 ms. A STATUS read of 0xFF has NVM_BUSY set, so this also waits
out the time in which the device does not respond.

Fixes #120747

Signed-off-by: Sibo Van Gool <sibo.vangool@hotmail.com>
2026-10-03 09:49:32 +02:00
Benjamin Cabé
02949841e7 drivers: sensor: grow_r502a: fix RX packet length bound
The wire length field counts the payload plus the 2-byte checksum, but
the receive validator compared it against the payload-only package size,
so every full-size data packet was rejected with -EINVAL. Bound the
length by the receive buffer's body capacity instead, and widen the
checksum offset so a 256-byte package length cannot truncate it.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-02 17:37:42 -05:00
Benjamin Cabé
2a6607a554 drivers: sensor: grow_r502a: serialize LED API with the driver mutex
grow_r502a_led_on()/grow_r502a_led_off() called fps_led_control()
without holding drv_data->lock, so a concurrent LED request could
overwrite the shared UART tx/rx buffers of an in-flight sensor
transaction. Take the per-device mutex around the transport call, as
every other entry point does.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-02 17:37:42 -05:00
Benjamin Cabé
0f1b1edca7 drivers: sensor: tad2144: fix fractional part scaling in channel_get
The three converters produce an intermediate value in hundredths of a
unit but scaled the remainder by 1000, while sensor_value::val2 is
expressed in micro-units. Scale by 10000 instead so the reported
fraction is no longer ten times too small.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:37:56 -05:00
Benjamin Cabé
2a4deb7d71 drivers: sensor: tad2144: propagate bus and sample fetch errors
tad214x_sample_fetch() discarded the TAD214x_GetData() result and always
returned 0, and the I2C helpers ignored the i2c_write()/i2c_read()/
i2c_transfer() return codes, so transport failures were reported as
successful reads of stale or never-measured data. Check and propagate
those return codes instead.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:37:56 -05:00
Benjamin Cabé
f74b82178f drivers: sensor: tad2144: honour trigger handler in encoder mode
In encoder mode tad214x_trigger_set() installed the internal quadrature
decoder into drdy_handler, so the application callback was never stored
nor invoked, and it armed the ENCA/ENCB/ENCZ interrupts even when called
with a NULL handler to disable the trigger. The decoder is now a plain
internal step run from tad214x_thread_cb(), the caller's handler is
stored as in the non-encoder branch, and a NULL handler leaves the
encoder interrupts disabled.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:37:56 -05:00
Benjamin Cabé
837d06a3f0 drivers: sensor: tad2144: don't fail init without int-gpios
int-gpios is optional in the binding, but tad214x_init() unconditionally
called tad214x_trigger_init(), which returns -ENODEV for a bus instance
with no interrupt line, leaving the device not ready even for polled use.
Only initialize the trigger when an interrupt GPIO is present, drop the
redundant "default y" so TAD2144_TRIGGER_NONE works, and reject
trigger_set() on interrupt-less instances.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:37:56 -05:00
Benjamin Cabé
6d793f73e5 drivers: sensor: tdk: fix APEX pedometer cadence conversion
The cadence value is in u6.2 format, so the number of samples between
two steps is raw_val / 4, but the conversion divided by
raw_val + (raw_val & 0x03), double-counting the fractional bits and
dividing by zero when no cadence had been reported yet. Divide by
raw_val alone and report 0 steps/s when raw_val is 0.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:36:53 -05:00
Benjamin Cabé
d168e3956b drivers: sensor: icm42x70: fix FIFO frame stride on gyro-less parts
The FIFO packet size was hard-coded to include 6 gyroscope bytes, which
the ICM42370P never puts in a frame, so every frame after the first was
decoded at the wrong offset. Size the read from the actual FIFO
configuration and advance the decode index by the size the frame header
says the frame occupies.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:36:53 -05:00
Benjamin Cabé
78ee7a90f1 drivers: sensor: icm42x70: fix mutex leak on unsupported trigger
icm42x70_trigger_set() took the mutex and disabled the INT1 GPIO
interrupt before validating the trigger type, so returning -ENOTSUP left
the mutex held and the interrupt masked forever. Validate the trigger
type before acquiring anything so the error path has nothing to undo.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:36:53 -05:00
Benjamin Cabé
6b3500459e drivers: sensor: icm42x70: propagate attr_set configuration errors
icm42x70_attr_set() dropped the return value of every configuration
helper and always returned 0, so a rejected ODR, full-scale or APEX
setting looked applied to the caller, and a failed bus write still
updated the cached rate/range used to scale samples. Capture the helper
and HAL status codes, only commit the cached values once the register
write succeeded, and return the result from attr_set.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:36:53 -05:00
Benjamin Cabé
98f0e5cdf8 drivers: sensor: icm42605: enable tap when sensor already started
icm42605_trigger_set() relied on icm42605_turn_on_sensor() to push the
tap_en flag to the chip, but that helper returns -EALREADY once the
sensor is running, so a tap trigger registered after a data-ready
trigger never enabled APEX tap detection. Re-apply the FIFO/APEX
configuration in that case, and only re-enable the interrupt once the
registers have been written.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:35:54 -05:00
Benjamin Cabé
900853acd3 drivers: sensor: icm42605: clear sensor_started on power-down
icm42605_turn_off_sensor() powered down the accel/gyro and bypassed the
FIFO but left drv_data->sensor_started set, so a later re-arm made
icm42605_turn_on_sensor() bail out with -EALREADY and the device stayed
powered off forever. Clear the flag once the sensor is turned off.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:35:54 -05:00
Benjamin Cabé
ff66ff359f drivers: sensor: icm42605: sign-extend FIFO temperature byte
The 8-bit FIFO temperature field is two's complement, but the driver
cast the uint8_t FIFO byte directly to int16_t, zero-extending it and
turning every reading below 25 degC into a bogus 87..148 degC value.
Cast through int8_t so the sign bit is preserved.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:35:54 -05:00
Benjamin Cabé
9ddd67a49f drivers: sensor: icm42605: apply full-scale selector to FS_SEL field
icm42605_set_fs() ORed the raw full-scale index into ACCEL_CONFIG0 and
GYRO_CONFIG0 without shifting it into the FS_SEL field (bits 7:5), so
the range was always left at 000 (+/-16 g / +/-2000 dps) and both the
devicetree accel-fs/gyro-fs properties and SENSOR_ATTR_FULL_SCALE were
silently ignored. Shift the selector into place and derive the
sensitivity constants from the configured range instead of hard-coding
them, so reported values match the range actually programmed.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:35:54 -05:00
Benjamin Cabé
121dc066e4 drivers: sensor: bmi270: only cache range after successful write
set_accel_range() and set_gyro_range() updated the cached full-scale
range before writing the ACC_RANGE/GYR_RANGE register, so a failed
write left the cache disagreeing with the hardware and silently scaled
every subsequent sample. Commit the new range only once the register
write succeeds.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:33:46 -05:00
Benjamin Cabé
cfa54f59e4 drivers: sensor: bmi270: fix any-motion threshold full-scale
The anymo_2 threshold field spans bits [10:0] (1 LSB = 1/2048 g), but
the driver scaled the requested value with BIT_MASK(10), programming
half the requested threshold and capping the maximum at 0.5 g. Use the
correct 11-bit full scale and mask the field before shifting.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:33:46 -05:00
Benjamin Cabé
3d73d6b610 drivers: sensor: bmi270: abort config upload on first write error
The config-file upload loop reassigned ret on every iteration, so a
failed chunk write was overwritten by the next successful one and
write_config_file() returned 0 despite a corrupted upload. Stop the
loop as soon as a chunk write fails so the first bus error is
returned to bmi270_init().

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:33:46 -05:00
Benjamin Cabé
ba6ba6aba3 drivers: sensor: bmi270: clamp final config file upload chunk
write_config_file() always wrote BMI270_WR_LEN (32) bytes per chunk,
reading past the end of config files whose size is not a multiple of 32
(the default max_fifo image is 328 bytes, so the last chunk over-read 24
bytes). Clamp each chunk to the number of bytes actually remaining.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 21:33:46 -05:00
Benjamin Cabé
16d9d2b77c drivers: sensor: max32664c: fix motion config value truncation
The runtime data structure stored motion_time and motion_threshold as
uint8_t while the config structure and devicetree properties use
uint16_t, truncating the binding's default 500 milli-g threshold to 244
and rejecting motion times above 255 ms. Widen both fields to uint16_t.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 17:23:37 -05:00
Benjamin Cabé
4527be44e2 drivers: sensor: max32664c: fix skin contact channel data source
SENSOR_CHAN_MAX32664C_SKIN_CONTACT always read report.scd_state, which
is never populated in SCD only mode or in extended report builds, so it
returned a stale or zero state. Read the SCD classifier in SCD only mode
and the extended report field when extended reports are enabled.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 17:23:37 -05:00
Benjamin Cabé
7ec07a7453 drivers: sensor: max32664c: drain the FIFO in SCD only mode
The worker thread had no case for MAX32664C_OP_MODE_SCD, so the hub
FIFO was never read, the SCD report queue never filled and the status
byte was evaluated uninitialized. Add the SCD read/parse path, clear
the status byte before the switch and report the SCD classifier on the
skin contact channel when running in SCD only mode.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-10-01 17:23:37 -05:00
Nahuel Mesa
4f22202a21 drivers: sensor: silabs: add EMU_TEMP internal die sensor for EFR32
Add a sensor driver for the EMU internal die temperature sensor on
Silicon Labs Series 2 (EFR32) SoCs, exposed via SENSOR_CHAN_DIE_TEMP.
Reads use sl_hal_emu_get_temperature() so the driver also works
unchanged on Series 3.

The devicetree models the EMU as a container node (silabs,emu) with
temp as a child, leaving room to represent other EMU functions later.

Enable the sensor and its die-temp0 alias directly in the
kg100s_rb4332a board devicetree, since it is an internal peripheral
with no board-specific wiring.

Assisted-by: Claude:claude-sonnet-5
Signed-off-by: Nahuel Mesa <nahuel.mesa@focus.uy>
2026-09-30 20:04:41 +02:00
Alain Volmat
c156f337e3 sensor: vl53l0x: use sensor_value_from_milli when applicable
Use the sensor_value_from_milli helper to fill in the sensor_value
struct when applicable.

Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
2026-09-30 10:16:36 -05:00
Alain Volmat
556a229471 drivers: sensor: vl53l5cx: add support for VL53L5CX TOF
The VL53L5CX is a TimeOfFlight sensor allowing to get
multi-area range information.

Signed-off-by: Fabian Blatz <fabianblatz@gmail.com>
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
2026-09-30 10:16:36 -05:00
Darshan Maru
885afa0220 drivers: sensor: tcs34725: add AMS TCS34725 sensor driver
Add support for the AMS TCS34725 color light-to-digital converter
driver. Supports RGBC channel reads via the sensor API, color
temperature calculation, and illuminance (lux) calculation.

Signed-off-by: Darshan Maru <darshan.maru@dnkmail.in>
2026-09-30 12:38:20 +02:00
yi chen
5716f43d06 drivers: sensor: bme280: sign-extend dig_h4/dig_h5
dig_h4 and dig_h5 are signed 12-bit calibration values, but they were
assembled from uint8_t register bytes without sign extension, so any
negative value was read as a large positive one (e.g. -30 became
4066). Both feed into the humidity compensation, which then produces
a wrong reading.

Use sign_extend() to recover the signed values.

Fixes #112381

Signed-off-by: yi chen <94xhn1@gmail.com>
Assisted-by: Claude:claude-opus-5-5
2026-09-29 07:48:47 +02:00
Benjamin Cabé
14e2b5d234 drivers: sensor: fxls8974: sign-extend the raw temperature byte
The TEMP_OUT register holds an 8-bit two's-complement value, but the
byte was assigned straight to the int16_t raw channel, zero-extending
it so every reading below 25 degC came out 256 degC too high. Cast
through int8_t, and initialize val2 which was left uninitialized.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 14:31:12 -04:00
Benjamin Cabé
3352b32cf1 drivers: sensor: fxls8974: release semaphore on error paths
fxls8974_get_accel_data() took data->sem but returned early without
releasing it when the CTRL_REG1 read failed or an unsupported channel
was requested, permanently deadlocking every later driver call. Route
both error paths through the existing unlock/exit tail instead.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 14:31:12 -04:00
Benjamin Cabé
629e17590c drivers: sensor: fxls8974: honor devicetree range property
The driver parsed the devicetree "range" property into its config but
never used it, unconditionally programming (and verifying) the +/-2 g
full-scale range. Map the configured range to the CTRL_REG1 FSR field
and verify the read-back against the requested value.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 14:31:12 -04:00
Benjamin Cabé
a9f3e09b22 drivers: sensor: adltc2990: store current in its own field
Current was scaled in place into pins_v1_v2_values[0]/pins_v3_v4_values[0],
so the SENSOR_CHAN_ALL fetch path clobbered the just-computed current with
the raw differential voltage read back by the voltage step. Give current
dedicated storage and skip the computation for pins that are not configured
as differential, which also avoids scaling a stale value by 1/Rsense.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 07:35:57 -04:00
Benjamin Cabé
e16cafa297 drivers: sensor: adltc2990: cache acq format only after it is written
adltc2990_trigger_measurement() updated the cached acquisition format
before the control register read-modify-write, so a failing I2C transfer
left the cache permanently out of sync with the device and the equality
guard skipped any retry. Cache the format only after the control
register write succeeds.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 07:35:57 -04:00
Benjamin Cabé
137a9d1d76 drivers: sensor: bma4xx: enable the INT1 pad for streaming
The INT1 pad is left disabled by the soft reset at init, so FIFO
interrupts never reach the host and streaming never completes. Enable
it as a push-pull output whose active level follows the int1-gpios
polarity.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 07:35:52 -04:00
Benjamin Cabé
939b1a0e46 drivers: sensor: bma4xx: write correct FIFO flush command value
BMA4XX_CMD_FIFO_FLUSH is the command value 0xB0 written to the CMD
register, not a bit mask, so FIELD_PREP(BMA4XX_CMD_FIFO_FLUSH, 1)
wrote 0x10 and the FIFO was never flushed. Write the command value
directly, as done for the other CMD register writes.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 07:35:52 -04:00
Benjamin Cabé
40d4c2b4d2 drivers: sensor: bma4xx: keep perf mode bit in ACC_CONF write
The performance power mode bit was set in a standalone write to
ACC_CONF, but the later ODR/bandwidth write to the same register
overwrote it with zero, leaving the sensor in CIC averaging mode.
Fold the bit into the ODR/bandwidth value and drop the redundant
write.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 07:35:52 -04:00
Benjamin Cabé
5ccde2a721 drivers: sensor: bma4xx: reject reserved bandwidth parameter values
The driver currently only supports performance mode, where BWP values
above NORM_AVG4 are reserved and stop the data path on a BMA423. Reject
them in attr_set.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 07:35:52 -04:00
Benjamin Cabé
5d38922a5c drivers: sensor: bma4xx: fix double shift of BWP value in attr_set
bma4xx_attr_set_bwp stored the bandwidth parameter pre-shifted by
BMA4XX_SHIFT_ACC_CONF_BWP, but bma4xx_configure applies FIELD_PREP
with BMA4XX_MASK_ACC_CONF_BWP, shifting it again so the chip always
received BWP = 0. Store the raw field value instead, matching the
value domain used by bma4xx_chip_init.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-28 07:35:52 -04:00
Hsiu-Chi Tsai
326d6e4c24 drivers: sensor: adi: ad2s1210: widen the RPM product before dividing
The velocity word is int16_t and the range from the lookup table is
int32_t, so velocity * range is evaluated in 32 bits. It overflows for
the three fastest of the eight ranges: 75000 from |velocity| 28634,
150000 from 14317, 187500 from 11454, and that last threshold is about
a third of full scale. Widen to int64_t before the divide.

Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
2026-09-26 10:34:06 -05:00
Remi Buisson
404c91bd1d drivers: sensor: icm566xx: Fix icm56686 high fsr
Only high fsr is supported by icm56686 driver.

Signed-off-by: Remi Buisson <remi.buisson@tdk.com>
2026-09-26 01:05:31 +02:00
Hsiu-Chi Tsai
42fe88386f drivers: sensor: adi: ad2s1210: reject a partial resolution-gpios
resolution-gpios is read as two lines, RES0 and RES1, through
GPIO_DT_SPEC_INST_GET_BY_IDX_OR() with an empty fallback, while
have_resolution_pins only checks that the property exists. A node with
one entry, or with one of the two set to <0>, builds and then fails at
init with -ENODEV because that spec has no port.

Make both a build error. Omitting the property stays valid, the binding
says the pins may be hard-wired.

Signed-off-by: Hsiu-Chi Tsai <hctsai@linux.com>
2026-09-26 01:03:28 +02:00
Flavio Ceolin
bd936c30d8 drivers: sensor: grow_r502a: drop stale RX buffer on timeout
transceive_packet() left the RX interrupt enabled after a receive
timeout, so late bytes were written through rx_buf.data into the stack
frame of the function that had already returned.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-09-26 00:52:17 +02:00
Flavio Ceolin
96968fac22 drivers: sensor: grow_r502a: bound RX packet length
The packet length from the sensor header was passed to uart_fifo_read()
without checking it against the receive buffer, letting a declared body
larger than the buffer overflow the caller's stack packet.

Signed-off-by: Flavio Ceolin <flavio@hubble.com>
2026-09-26 00:52:17 +02:00
Benjamin Cabé
d64fee9650 drivers: sensor: bmp180: fix X2 divisor in pressure compensation
The pressure compensation computed X2 as B1 * B6^2 / 2^27 because the
divisor constant was 0x8000000 instead of 0x10000000. The datasheet
specifies X2 = (B1 * (B6 * B6 / 2^12)) / 2^16, i.e. B1 * B6^2 / 2^28,
so reported pressure was too low by up to ~10 hPa at temperature
extremes.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-26 00:44:16 +02:00
Benjamin Cabé
79dbc4ea3a drivers: sensor: pat9136: fix NULL SQE on RTIO acquire failure
The SQE-exhaustion error path cleared data->stream.iodev_sqe before
passing it to rtio_iodev_sqe_err(), so the pending submission was always
completed with a NULL pointer. Cache the pointer in a local first, as the
two neighbouring error paths already do.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-26 00:43:33 +02:00
Benjamin Cabé
e859d540bf drivers: sensor: pat9136: fix zeroed q31 scale for mm channels
The millimetre conversion evaluated 2^31 / (2^shift * 1e6) as an integer
division before applying it, truncating the scale factor to 0 for shift
>= 12 and to a ~4.6% low value otherwise. Fold the 2^31/2^shift into a
single left shift applied before the 1e6 divide.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-26 00:43:33 +02:00
Benjamin Cabé
6fee2b87ad drivers: sensor: pat9136: read all resolution registers when streaming
The streaming path only read the RESOLUTION X/Y LOWER registers, leaving
the high bytes of the packed 16-bit resolution values in the RTIO
mempool buffer uninitialized, which made the decoder compute a bogus CPI
and shift. Read all four registers, as the one-shot path already does,
so the resolution comes from the sensor itself.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-26 00:43:33 +02:00
Benjamin Cabé
62cfd28d98 drivers: sensor: paa3905: fix dangling stream SQE on bus error
The stream completion callback armed the data-ready backup timer before
flushing the bus CQEs, then errored the SQE without clearing
data->stream.iodev_sqe, so the timer later dereferenced an SQE already
returned to the RTIO pool. Arm the timer only after the error check, use
handle_result_on_error() on the failure path, and stop the timer there.

Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Assisted-by: Claude:fable-5
2026-09-26 00:43:33 +02:00