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.
Showing the changes to include/linux/platform_data (1 of 3 files). Show all
Unified · Split
| @@ -228,6 +228,7 @@ struct cros_ec_platform { · 227 unmodified lines | |||
| 228 | /** | 228 | /** |
| 229 | * struct cros_ec_dev - ChromeOS EC device entry point. | 229 | * struct cros_ec_dev - ChromeOS EC device entry point. |
| 230 | * @class_dev: Device structure used in sysfs. | 230 | * @class_dev: Device structure used in sysfs. |
| 231 | * @group: sysfs attributes groups for this EC. | ||
| 231 | * @ec_dev: cros_ec_device structure to talk to the physical device. | 232 | * @ec_dev: cros_ec_device structure to talk to the physical device. |
| 232 | * @dev: Pointer to the platform device. | 233 | * @dev: Pointer to the platform device. |
| 233 | * @debug_info: cros_ec_debugfs structure for debugging information. | 234 | * @debug_info: cros_ec_debugfs structure for debugging information. |
| @@ -237,6 +238,7 @@ struct cros_ec_platform { · 3 unmodified lines | |||
| 237 | */ | 238 | */ |
| 238 | struct cros_ec_dev { | 239 | struct cros_ec_dev { |
| 239 | struct device class_dev; | 240 | struct device class_dev; |
| 241 | const struct attribute_group *group; | ||
| 240 | struct cros_ec_device *ec_dev; | 242 | struct cros_ec_device *ec_dev; |
| 241 | struct device *dev; | 243 | struct device *dev; |
| 242 | struct cros_ec_debugfs *debug_info; | 244 | struct cros_ec_debugfs *debug_info; |