On 18/12/2017, Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote: > > What if a module registering the hook is loaded after > sysfs_add_battery() has run for the battery object in question? The battery module keeps track of the batteries that get added or removed from the system. When a hook is registered, it will always get a list of currently present batteries not matter of the time when the hook is loaded. > What if it attempts to register a hook while this code is running? If was not able to produce any race conditions, but I have added some locking mechanisms in the new, 7th revision of the patch. > What if two entities try to add or remove hooks simultaneously? This has been solved in version 7 with mutual exclusions. > Don't you think any locking or other synchronization is necessary? I have implemented mutual exclusions. > Also, what if someone attempts to add a hook when the ACPI battery > module is not loaded? Will that still work? The module that requests the hooks will fail to load with the following > [ 149.259127] thinkpad_acpi: Unknown symbol battery_hook_register (err 0) > [ 149.259158] thinkpad_acpi: Unknown symbol battery_hook_unregister (err 0) > Thanks, > Rafael > -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html