Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752546AbdLGJr6 (ORCPT ); Thu, 7 Dec 2017 04:47:58 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:33943 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752483AbdLGJrz (ORCPT ); Thu, 7 Dec 2017 04:47:55 -0500 DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20171207094753euoutp01ec771fb3df6c56964ed15403db377d43~9_iHTaivR1073110731euoutp01r X-AuditID: cbfec7f2-f793b6d000003243-9a-5a290e47a3e3 From: Maciej Purski To: Mark Brown Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Liam Girdwood , Rob Herring , Mark Rutland , Marek Szyprowski , Bartlomiej Zolnierkiewicz , Maciej Purski Subject: [PATCH v3 1/4] regulator: core: Move of_find_regulator_by_node() to of_regulator.c Date: Thu, 07 Dec 2017 10:46:12 +0100 Message-id: <1512639975-22241-2-git-send-email-m.purski@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1512639975-22241-1-git-send-email-m.purski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsWy7djPc7rufJpRBjOvmVtsnLGe1WLqwyds FvOPnGO1+Halg8ni8q45bBYLXt5isVh75C67xdLrF5ksWvceYXfg9Fgzbw2jx85Zd9k9Nq3q ZPPo27KK0ePzJrkA1igum5TUnMyy1CJ9uwSujLXHPrEVTJat+DA1t4Fxq0QXIyeHhICJxJu5 E5ggbDGJC/fWs3UxcnEICSxllFi94yGU85lRouvZd0aYjocPJrNDJJYxSizb2s0E4fxnlJjZ d5e1i5GDg01AS2JNezxIg4iAssTV73tZQGqYBXYySey4PpcVJCEsECsxZd5KNhCbRUBV4nXv QrANvAIuEtfmfGSF2CYncfNcJzPITE4BV4mrdwpB5kgILGGTWNn4AepuF4lNp1dC2cISr45v YYew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FAYcmzJRb4Fonqcsh8dw5xVLaMtve7z fDoR5a32dQVvk6fCpgZd5irhYsP4L5MlVCRPTHO+Un1dMW6R8gbB2XvLHbYb9K1MuJrFv+V4 n64SS3FGoqEWc1FxIgDc4F9xLgIAAA== X-CMS-MailID: 20171207094751eucas1p1c10de599329e2c7ece77c8a5ed939401 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171207094751eucas1p1c10de599329e2c7ece77c8a5ed939401 X-RootMTR: 20171207094751eucas1p1c10de599329e2c7ece77c8a5ed939401 References: <1512639975-22241-1-git-send-email-m.purski@samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3613 Lines: 116 As of_find_regulator_by_node() is an of function it should be moved from core to of_regulator.c. It provides better separation of device tree functions from the core and allows other of_functions in of_regulator 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 --- drivers/regulator/core.c | 23 +---------------------- drivers/regulator/internal.h | 9 +++++++++ drivers/regulator/of_regulator.c | 14 ++++++++++++++ 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c index b64b791..9662e54 100644 --- a/drivers/regulator/core.c +++ b/drivers/regulator/core.c @@ -58,8 +58,6 @@ static bool has_full_constraints; static struct dentry *debugfs_root; -static struct class regulator_class; - /* * struct regulator_map * @@ -112,11 +110,6 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, const char *supply_name); static void _regulator_put(struct regulator *regulator); -static struct regulator_dev *dev_to_rdev(struct device *dev) -{ - return container_of(dev, struct regulator_dev, dev); -} - static const char *rdev_get_name(struct regulator_dev *rdev) { if (rdev->constraints && rdev->constraints->name) @@ -1417,20 +1410,6 @@ static void regulator_supply_alias(struct device **dev, const char **supply) } } -static int of_node_match(struct device *dev, const void *data) -{ - return dev->of_node == data; -} - -static 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; -} - static int regulator_match(struct device *dev, const void *data) { struct regulator_dev *r = dev_to_rdev(dev); @@ -3918,7 +3897,7 @@ static void regulator_dev_release(struct device *dev) kfree(rdev); } -static struct class regulator_class = { +struct class regulator_class = { .name = "regulator", .dev_release = regulator_dev_release, .dev_groups = regulator_dev_groups, diff --git a/drivers/regulator/internal.h b/drivers/regulator/internal.h index 66a8ea0..2f3218b 100644 --- a/drivers/regulator/internal.h +++ b/drivers/regulator/internal.h @@ -35,6 +35,15 @@ struct regulator { struct dentry *debugfs; }; +extern struct class regulator_class; + +static inline struct regulator_dev *dev_to_rdev(struct device *dev) +{ + return container_of(dev, struct regulator_dev, dev); +} + +struct regulator_dev *of_find_regulator_by_node(struct device_node *np); + #ifdef CONFIG_OF struct regulator_init_data *regulator_of_get_init_data(struct device *dev, const struct regulator_desc *desc, diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c index 14637a0..54e810a 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; +} -- 2.7.4