0

I want to extend the generic sysfs class power-supply with some specific attributes. What is the proper way to do that?

I'm confused after reading the sysfs power-supply documentation. According to it, it is recommended to use the existing class as it is and to implement specific attributes in the device driver resp. extend the attributes of it under */sysfs/devices/housekeeper/power-supply/special-attribute*.

rhand
  • 1,176
  • 4
  • 17
  • 45
  • 1
    If you grep for `attr_grp` in drivers/power/supply/*.c, you will see a few examples where this has been done, setting the `attr_grp` member of `struct power_supply_config` to point to groups of attributes, and passing a pointer to this struct as the third parameter of the call to `power_supply_register()` or `devm_power_supply_register()`. – Ian Abbott Sep 25 '19 at 16:35
  • This works from kernel version 5, right? – Dimitri Ratz Sep 27 '19 at 07:16
  • Yes, it was added in 5.0. There was a way to add custom attributes to power supply device drivers before 5.0, but they suffered from a race-condition in sysfs. – Ian Abbott Sep 27 '19 at 09:35

0 Answers0