From: Zhang Lixu lixu.zhang@intel.com
[ Upstream commit ad02ca57e44e9936fca5095840fad9d4b47c5559 ]
On Intel platforms, the HID_USAGE_SENSOR_HUMAN_PROXIMITY report size is 16 bits. This patch adds support for handling 16-bit report sizes for the HID_USAGE_SENSOR_HUMAN_PROXIMITY usage in the HID sensor proximity driver.
Previously, the driver only supported 8-bit and 32-bit report sizes. With this change, the driver can now correctly process 16-bit proximity data, ensuring accurate human presence detection on platforms where this report size is used.
Signed-off-by: Zhang Lixu lixu.zhang@intel.com Acked-by: Srinivas Pandruvada srinivas.pandruvada@linux.intel.com Link: https://patch.msgid.link/20250317013634.4117399-1-lixu.zhang@intel.com Signed-off-by: Jonathan Cameron Jonathan.Cameron@huawei.com Signed-off-by: Sasha Levin sashal@kernel.org ---
Based on my analysis of the commit and the context provided, I'll now provide my recommendation:
**YES**
## Extensive Analysis
### Code Change Analysis
The commit adds support for 16-bit report sizes in the HID sensor proximity driver by adding a simple `case 2:` clause to the existing switch statement in the `prox_capture_sample()` function:
```c switch (raw_len) { case 1: prox_state->human_presence[chan] = *(u8 *)raw_data * multiplier; return 0; +case 2: + prox_state->human_presence[chan] = *(u16 *)raw_data * multiplier; + return 0; case 4: prox_state->human_presence[chan] = *(u32 *)raw_data * multiplier; return 0; } ```
### Why This Should Be Backported
1. **Important Bug Fix**: The commit message clearly states this is needed for Intel platforms where `HID_USAGE_SENSOR_HUMAN_PROXIMITY` uses 16-bit reports. Without this change, these platforms cannot correctly process proximity data, making the sensor completely non- functional for 16-bit report sizes.
2. **Minimal Risk and Scope**: The change is extremely small (3 lines added) and follows the exact same pattern as existing 8-bit and 32-bit cases. It's confined to a single function and only affects the data parsing path for proximity sensors.
3. **Pattern Consistency**: Looking at the grep results from other IIO drivers, handling multiple data sizes (including 16-bit) in switch statements is a common pattern throughout the IIO subsystem. This change follows established conventions.
4. **Hardware Compatibility**: The commit enables proper functionality on Intel platforms that use 16-bit proximity reports. This is a hardware compatibility fix rather than a new feature.
5. **No Architectural Changes**: The change doesn't modify any APIs, data structures, or architectural components - it simply extends the existing data size handling logic.
6. **Similar Successful Backports**: Looking at the reference commits, we see that Similar Commit #3 and #4 were both backported (Status: YES), and both were fixes for scale/data handling issues in HID sensor drivers. This commit follows the same pattern of fixing data handling bugs.
7. **Clear Failure Mode**: Without this fix, Intel platforms with 16-bit proximity reports would fail to capture proximity data, returning `-EINVAL` and making the proximity sensor completely unusable.
8. **Industry-Standard Fix**: The commit comes from Intel (Zhang Lixu) with acknowledgment from the HID sensor maintainer (Srinivas Pandruvada), indicating this addresses a real hardware compatibility issue.
### Risk Assessment
The risk is extremely low because: - The change only affects the specific case where `raw_len == 2` - Existing 8-bit and 32-bit handling remains unchanged - The code follows the exact same pattern as existing cases - No memory management or complex logic is involved - Failure would be immediate and obvious (wrong data values)
This commit clearly meets the stable tree criteria: it fixes an important hardware compatibility bug with minimal risk and no architectural changes.
drivers/iio/light/hid-sensor-prox.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index 4c65b32d34ce4..46f788b0bc3e2 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c @@ -215,6 +215,9 @@ static int prox_capture_sample(struct hid_sensor_hub_device *hsdev, case 1: prox_state->human_presence[chan] = *(u8 *)raw_data * multiplier; return 0; + case 2: + prox_state->human_presence[chan] = *(u16 *)raw_data * multiplier; + return 0; case 4: prox_state->human_presence[chan] = *(u32 *)raw_data * multiplier; return 0;