PM / Domains: Simplify detaching a device from its genpd
There's no need to validate the PM domain by using genpd_lookup_dev() when removing the device via genpd's genpd_dev_pm_detach() function. That's because this function can't be called, unless there is a valid PM domain for the device. To simplify the behaviour, let's move code from pm_genpd_remove_device() into a new internal function, genpd_remove_device(), which is called from pm_genpd_remove_device() and genpd_dev_pm_detach(). Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Lina Iyer <lina.iyer@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
This commit is contained in:
parent
609bed67bd
commit
85168d56cc
|
@ -1121,13 +1121,8 @@ int __pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__pm_genpd_add_device);
|
EXPORT_SYMBOL_GPL(__pm_genpd_add_device);
|
||||||
|
|
||||||
/**
|
static int genpd_remove_device(struct generic_pm_domain *genpd,
|
||||||
* pm_genpd_remove_device - Remove a device from an I/O PM domain.
|
struct device *dev)
|
||||||
* @genpd: PM domain to remove the device from.
|
|
||||||
* @dev: Device to be removed.
|
|
||||||
*/
|
|
||||||
int pm_genpd_remove_device(struct generic_pm_domain *genpd,
|
|
||||||
struct device *dev)
|
|
||||||
{
|
{
|
||||||
struct generic_pm_domain_data *gpd_data;
|
struct generic_pm_domain_data *gpd_data;
|
||||||
struct pm_domain_data *pdd;
|
struct pm_domain_data *pdd;
|
||||||
|
@ -1135,10 +1130,6 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
|
||||||
|
|
||||||
dev_dbg(dev, "%s()\n", __func__);
|
dev_dbg(dev, "%s()\n", __func__);
|
||||||
|
|
||||||
if (!genpd || genpd != genpd_lookup_dev(dev))
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
/* The above validation also means we have existing domain_data. */
|
|
||||||
pdd = dev->power.subsys_data->domain_data;
|
pdd = dev->power.subsys_data->domain_data;
|
||||||
gpd_data = to_gpd_data(pdd);
|
gpd_data = to_gpd_data(pdd);
|
||||||
dev_pm_qos_remove_notifier(dev, &gpd_data->nb);
|
dev_pm_qos_remove_notifier(dev, &gpd_data->nb);
|
||||||
|
@ -1170,6 +1161,20 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* pm_genpd_remove_device - Remove a device from an I/O PM domain.
|
||||||
|
* @genpd: PM domain to remove the device from.
|
||||||
|
* @dev: Device to be removed.
|
||||||
|
*/
|
||||||
|
int pm_genpd_remove_device(struct generic_pm_domain *genpd,
|
||||||
|
struct device *dev)
|
||||||
|
{
|
||||||
|
if (!genpd || genpd != genpd_lookup_dev(dev))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
return genpd_remove_device(genpd, dev);
|
||||||
|
}
|
||||||
EXPORT_SYMBOL_GPL(pm_genpd_remove_device);
|
EXPORT_SYMBOL_GPL(pm_genpd_remove_device);
|
||||||
|
|
||||||
static int genpd_add_subdomain(struct generic_pm_domain *genpd,
|
static int genpd_add_subdomain(struct generic_pm_domain *genpd,
|
||||||
|
@ -1797,14 +1802,14 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
pd = genpd_lookup_dev(dev);
|
pd = dev_to_genpd(dev);
|
||||||
if (!pd)
|
if (IS_ERR(pd))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dev_dbg(dev, "removing from PM domain %s\n", pd->name);
|
dev_dbg(dev, "removing from PM domain %s\n", pd->name);
|
||||||
|
|
||||||
for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
|
for (i = 1; i < GENPD_RETRY_MAX_MS; i <<= 1) {
|
||||||
ret = pm_genpd_remove_device(pd, dev);
|
ret = genpd_remove_device(pd, dev);
|
||||||
if (ret != -EAGAIN)
|
if (ret != -EAGAIN)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue