Skip to contentSkip to conversation

iio: hid-sensor-als: Return 0 for HID_USAGE_SENSOR_TIME_TIMESTAMP

PATCH In review Srinivas Pandruvada 2 participants 2 messages Feb 4, 2024

Subsystems (3)
lore
Share & tools
lore

Srinivas Pandruvada

author maintainer
#0 lore raw

PATCH 1/1 iio: hid-sensor-als: Return 0 for HID_USAGE_SENSOR_TIME_TIMESTAMP

When als_capture_sample() is called with usage ID HID_USAGE_SENSOR_TIME_TIMESTAMP, return 0. The HID sensor core ignores the return value for capture_sample() callback, so return value doesn't make difference. But correct the return value to return success instead of -EINVAL.

---
As part of review comments for series "Add support of color temperature and chromaticity". This is separate from the series as this is unrelated.

 drivers/iio/light/hid-sensor-als.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/light/hid-sensor-als.c +1 -0
index 5cd27f04b45e..b6c4bef2a7bb 100644
@@ -226,6 +226,7 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev,
 	case HID_USAGE_SENSOR_TIME_TIMESTAMP:
 		als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,
 								    *(s64 *)raw_data);
+		ret = 0;
 		break;
 	default:
 		break;
Signature · 1 line
2.43.0
maintainer
#1 lore raw
Quoted 7 lines · On Sun, 4 Feb 2024 04:56:17 -0800 Srinivas Pandruvada…

When als_capture_sample() is called with usage ID HID_USAGE_SENSOR_TIME_TIMESTAMP, return 0. The HID sensor core ignores the return value for capture_sample() callback, so return value doesn't make difference. But correct the return value to return success instead of -EINVAL.

Applied and marked for stable.

Whilst this is the minimal fix (and so the right one!) it would be good to change this as a follow up to just use direct returns as then this sort of bug won't get reintroduced and the code will be a bit simpler.

Jonathan

Quoted 20 lines

---
As part of review comments for series "Add support of color temperature and chromaticity". This is separate from the series as this is unrelated.

 drivers/iio/light/hid-sensor-als.c | 1 +
 1 file changed, 1 insertion(+)
drivers/iio/light/hid-sensor-als.c +1 -0
index 5cd27f04b45e..b6c4bef2a7bb 100644
@@ -226,6 +226,7 @@ static int als_capture_sample(struct hid_sensor_hub_device *hsdev,
 	case HID_USAGE_SENSOR_TIME_TIMESTAMP:
 		als_state->timestamp = hid_sensor_convert_timestamp(&als_state->common_attributes,
 								    *(s64 *)raw_data);
+		ret = 0;
 		break;
 	default:
 		break;