]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
platform/chrome: Resolve kb_wake_angle visibility race
authorTzung-Bi Shih <tzungbi@kernel.org>
Tue, 7 Apr 2026 10:26:15 +0000 (10:26 +0000)
committerTzung-Bi Shih <tzungbi@kernel.org>
Mon, 11 May 2026 03:09:30 +0000 (03:09 +0000)
commitc40f5f9927b5bf6062daa1e293ae32d83afc963e
treeeda7f3ffeced4a9e6e9b6e91e742c44bdf592d74
parent5d6919055dec134de3c40167a490f33c74c12581
platform/chrome: Resolve kb_wake_angle visibility race

A race condition exists between the probe of cros-ec-sysfs and
cros-ec-sensorhub.

The `kb_wake_angle` attribute should only be visible if the sensor hub
detects two or more accelerometers.  If cros_ec_sysfs_probe() runs
before cros_ec_sensorhub_register() completes sensor enumeration, the
sysfs attributes are created while `has_kb_wake_angle` is still false,
hiding `kb_wake_angle` incorrectly.

Store the created attribute group pointer in `ec_dev->group`.  When
the sensor hub completes sensor enumeration, it checks for this group
and calls sysfs_update_group() to notify the sysfs core to re-evaluate
attribute visibility.  This ensures the `kb_wake_angle` attribute
visibility is correctly updated regardless of the driver probe order.

Co-developed-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Link: https://lore.kernel.org/r/20260407102615.1605317-1-tzungbi@kernel.org
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
drivers/platform/chrome/cros_ec_sensorhub.c
drivers/platform/chrome/cros_ec_sysfs.c
include/linux/platform_data/cros_ec_proto.h