diff options
author | pascal paillet <p.paillet@st.com> | 2018-07-05 10:25:56 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-07-05 13:55:20 -0400 |
commit | ed1ae2dd9f242c7a36e8e39100f6a7f6bcdfdd89 (patch) | |
tree | 9410814bd9ef17ccd80eaf12b3eed19cb300c81d | |
parent | d8842211b6f63d3f069df973d137de0a85964965 (diff) |
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>
-rw-r--r-- | drivers/regulator/core.c | 18 |
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, | |||
1740 | rdev->use_count = 0; | 1740 | rdev->use_count = 0; |
1741 | } | 1741 | } |
1742 | 1742 | ||
1743 | device_link_add(dev, &rdev->dev, DL_FLAG_STATELESS); | ||
1744 | |||
1743 | return regulator; | 1745 | return regulator; |
1744 | } | 1746 | } |
1745 | 1747 | ||
@@ -1829,9 +1831,21 @@ static void _regulator_put(struct regulator *regulator) | |||
1829 | 1831 | ||
1830 | debugfs_remove_recursive(regulator->debugfs); | 1832 | debugfs_remove_recursive(regulator->debugfs); |
1831 | 1833 | ||
1832 | /* remove any sysfs entries */ | 1834 | if (regulator->dev) { |
1833 | if (regulator->dev) | 1835 | int count = 0; |
1836 | struct regulator *r; | ||
1837 | |||
1838 | list_for_each_entry(r, &rdev->consumer_list, list) | ||
1839 | if (r->dev == regulator->dev) | ||
1840 | count++; | ||
1841 | |||
1842 | if (count == 1) | ||
1843 | device_link_remove(regulator->dev, &rdev->dev); | ||
1844 | |||
1845 | /* remove any sysfs entries */ | ||
1834 | sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); | 1846 | sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); |
1847 | } | ||
1848 | |||
1835 | regulator_lock(rdev); | 1849 | regulator_lock(rdev); |
1836 | list_del(®ulator->list); | 1850 | list_del(®ulator->list); |
1837 | 1851 | ||