History

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.

Tzung-Bi Shih committed 7 months ago

Commit c40f5f91 parent 5d691903 files · +10 −3Browse files

Showing the changes to include/linux/platform_data (1 of 3 files). Show all

Unified · Split

include/linux/platform_data/cros_ec_proto.h+2−0
@@ -228,6 +228,7 @@ struct cros_ec_platform { · 227 unmodified lines
228228 /**
229229 * struct cros_ec_dev - ChromeOS EC device entry point.
230230 * @class_dev: Device structure used in sysfs.
231+ * @group: sysfs attributes groups for this EC.
231232 * @ec_dev: cros_ec_device structure to talk to the physical device.
232233 * @dev: Pointer to the platform device.
233234 * @debug_info: cros_ec_debugfs structure for debugging information.
@@ -237,6 +238,7 @@ struct cros_ec_platform { · 3 unmodified lines
237238 */
238239 struct cros_ec_dev {
239240 struct device class_dev;
241+ const struct attribute_group *group;
240242 struct cros_ec_device *ec_dev;
241243 struct device *dev;
242244 struct cros_ec_debugfs *debug_info;