aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/regulator
diff options
context:
space:
mode:
authorpascal paillet <p.paillet@st.com>2018-07-05 14:25:56 +0000
committerMark Brown <broonie@kernel.org>2018-07-05 18:55:20 +0100
commited1ae2dd9f242c7a36e8e39100f6a7f6bcdfdd89 (patch)
tree9410814bd9ef17ccd80eaf12b3eed19cb300c81d /drivers/regulator
parentdriver core: Add device_link_remove function (diff)
downloadlinux-dev-ed1ae2dd9f242c7a36e8e39100f6a7f6bcdfdd89.tar.xz
linux-dev-ed1ae2dd9f242c7a36e8e39100f6a7f6bcdfdd89.zip
regulator: core: Link consumer with regulator driver
Add a device link between the consumer and the driver so that the consumer is not suspended before the driver. The goal is to avoid implementing suspend_late ops in regulator drivers. Signed-off-by: pascal paillet <p.paillet@st.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/regulator')
-rw-r--r--drivers/regulator/core.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index da9b0fed8330..bb1324f93143 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -1740,6 +1740,8 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
rdev->use_count = 0;
}
+ device_link_add(dev, &rdev->dev, DL_FLAG_STATELESS);
+
return regulator;
}
@@ -1829,9 +1831,21 @@ static void _regulator_put(struct regulator *regulator)
debugfs_remove_recursive(regulator->debugfs);
- /* remove any sysfs entries */
- if (regulator->dev)
+ if (regulator->dev) {
+ int count = 0;
+ struct regulator *r;
+
+ list_for_each_entry(r, &rdev->consumer_list, list)
+ if (r->dev == regulator->dev)
+ count++;
+
+ if (count == 1)
+ device_link_remove(regulator->dev, &rdev->dev);
+
+ /* remove any sysfs entries */
sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
+ }
+
regulator_lock(rdev);
list_del(&regulator->list);