power: supply: core: add support for custom sysfs attributes
authorSebastian Reichel <sebastian.reichel@collabora.com>
Thu, 27 Sep 2018 13:46:03 +0000 (15:46 +0200)
committerSebastian Reichel <sre@kernel.org>
Wed, 12 Dec 2018 23:15:06 +0000 (00:15 +0100)
Add functionality to setup device specific sysfs attributes
in a race condition free manner

Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/power_supply_core.c
include/linux/power_supply.h

index 93007cb..569790e 100644 (file)
@@ -1018,6 +1018,7 @@ __power_supply_register(struct device *parent,
        dev_set_drvdata(dev, psy);
        psy->desc = desc;
        if (cfg) {
+               dev->groups = cfg->attr_grp;
                psy->drv_data = cfg->drv_data;
                psy->of_node =
                        cfg->fwnode ? to_of_node(cfg->fwnode) : cfg->of_node;
index 84fe93f..57b2ab8 100644 (file)
@@ -204,6 +204,9 @@ struct power_supply_config {
        /* Driver private data */
        void *drv_data;
 
+       /* Device specific sysfs attributes */
+       const struct attribute_group **attr_grp;
+
        char **supplied_to;
        size_t num_supplicants;
 };