From 148096af0bf381c78afe253c07ef1c77778f0e68 Mon Sep 17 00:00:00 2001 From: Maciej Purski Date: Mon, 22 Jan 2018 15:30:06 +0100 Subject: regulator: core: Move of_find_regulator_by_node() to of_regulator.c As of_find_regulator_by_node() is an of function it should be moved from core.c to of_regulator.c. It provides better separation of device tree functions from the core and allows other of_functions in of_regulator.c to resolve device_node to regulator_dev. This will be useful for implementation of parsing coupled regulators properties. Declare of_find_regulator_by_node() function in internal.h as well as regulator_class and dev_to_rdev(), as they are needed by of_find_regulator_by_node(). Signed-off-by: Maciej Purski Signed-off-by: Mark Brown --- drivers/regulator/of_regulator.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/regulator/of_regulator.c') diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 14637a01ba2d..54e810ae93d6 100644 --- a/drivers/regulator/of_regulator.c +++ b/drivers/regulator/of_regulator.c @@ -376,3 +376,17 @@ struct regulator_init_data *regulator_of_get_init_data(struct device *dev, return init_data; } + +static int of_node_match(struct device *dev, const void *data) +{ + return dev->of_node == data; +} + +struct regulator_dev *of_find_regulator_by_node(struct device_node *np) +{ + struct device *dev; + + dev = class_find_device(®ulator_class, NULL, np, of_node_match); + + return dev ? dev_to_rdev(dev) : NULL; +} -- cgit v1.2.3