]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
power: supply: Add fwnode pointer to power_supply_config struct
authorAdam Thomson <Adam.Thomson.Opensource@diasemi.com>
Tue, 22 May 2018 15:16:23 +0000 (16:16 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 24 May 2018 16:14:27 +0000 (18:14 +0200)
To allow users of the power supply framework to be hw description
agnostic, this commit adds the ability to pass a fwnode pointer,
via the power_supply_config structure, to the initialisation code
of the core, instead of explicitly specifying of_ndoe. If that
fwnode pointer is provided then it will automatically resolve down
to of_node on platforms which support it, otherwise it will be NULL.

In the future, when ACPI support is added, this can be modified to
accommodate ACPI without the need to change calling code which
already provides the fwnode handle in this manner.

Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
Suggested-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Reviewed-by: Sebastian Reichel <sebastian.reichel@collabora.co.uk>
Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/power/supply/power_supply_core.c
include/linux/power_supply.h

index ecd68c2053c5bb5ed0f0d110ccaf879ced384220..f57ab0a27301d067094487d32ea79677f1f7cad8 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/err.h>
 #include <linux/of.h>
 #include <linux/power_supply.h>
+#include <linux/property.h>
 #include <linux/thermal.h>
 #include "power_supply.h"
 
@@ -874,7 +875,8 @@ __power_supply_register(struct device *parent,
        psy->desc = desc;
        if (cfg) {
                psy->drv_data = cfg->drv_data;
-               psy->of_node = cfg->of_node;
+               psy->of_node =
+                       cfg->fwnode ? to_of_node(cfg->fwnode) : cfg->of_node;
                psy->supplied_to = cfg->supplied_to;
                psy->num_supplicants = cfg->num_supplicants;
        }
index 0c9a572a1eb89cf84a7a25df079013be483d9db8..b21c4bd96b84f2b78397114efb3062e68dbe59c6 100644 (file)
@@ -199,6 +199,8 @@ struct power_supply;
 /* Run-time specific power supply configuration */
 struct power_supply_config {
        struct device_node *of_node;
+       struct fwnode_handle *fwnode;
+
        /* Driver private data */
        void *drv_data;