Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 267056
b: refs/heads/master
c: cd0ea67
h: refs/heads/master
v: v3
  • Loading branch information
Rafael J. Wysocki committed Sep 26, 2011
1 parent 80b3a56 commit 11a9ca9
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0d41da2e31e81f5c8aaabe17f769de4304b2d4c8
refs/heads/master: cd0ea672f58d5cfdea271c45cec0c897f2b792aa
28 changes: 19 additions & 9 deletions trunk/drivers/base/power/domain.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,12 @@ static int __pm_genpd_save_device(struct pm_domain_data *pdd,
struct generic_pm_domain *genpd)
__releases(&genpd->lock) __acquires(&genpd->lock)
{
struct generic_pm_domain_data *gpd_data = to_gpd_data(pdd);
struct device *dev = pdd->dev;
struct device_driver *drv = dev->driver;
int ret = 0;

if (pdd->need_restore)
if (gpd_data->need_restore)
return 0;

mutex_unlock(&genpd->lock);
Expand All @@ -210,7 +211,7 @@ static int __pm_genpd_save_device(struct pm_domain_data *pdd,
mutex_lock(&genpd->lock);

if (!ret)
pdd->need_restore = true;
gpd_data->need_restore = true;

return ret;
}
Expand All @@ -224,10 +225,11 @@ static void __pm_genpd_restore_device(struct pm_domain_data *pdd,
struct generic_pm_domain *genpd)
__releases(&genpd->lock) __acquires(&genpd->lock)
{
struct generic_pm_domain_data *gpd_data = to_gpd_data(pdd);
struct device *dev = pdd->dev;
struct device_driver *drv = dev->driver;

if (!pdd->need_restore)
if (!gpd_data->need_restore)
return;

mutex_unlock(&genpd->lock);
Expand All @@ -244,7 +246,7 @@ static void __pm_genpd_restore_device(struct pm_domain_data *pdd,

mutex_lock(&genpd->lock);

pdd->need_restore = false;
gpd_data->need_restore = false;
}

/**
Expand Down Expand Up @@ -493,7 +495,7 @@ static int pm_genpd_runtime_resume(struct device *dev)
mutex_lock(&genpd->lock);
}
finish_wait(&genpd->status_wait_queue, &wait);
__pm_genpd_restore_device(&dev->power.subsys_data->domain_data, genpd);
__pm_genpd_restore_device(dev->power.subsys_data->domain_data, genpd);
genpd->resume_count--;
genpd_set_active(genpd);
wake_up_all(&genpd->status_wait_queue);
Expand Down Expand Up @@ -1080,6 +1082,7 @@ static void pm_genpd_complete(struct device *dev)
*/
int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
{
struct generic_pm_domain_data *gpd_data;
struct pm_domain_data *pdd;
int ret = 0;

Expand All @@ -1106,14 +1109,20 @@ int pm_genpd_add_device(struct generic_pm_domain *genpd, struct device *dev)
goto out;
}

gpd_data = kzalloc(sizeof(*gpd_data), GFP_KERNEL);
if (!gpd_data) {
ret = -ENOMEM;
goto out;
}

genpd->device_count++;

dev->pm_domain = &genpd->domain;
dev_pm_get_subsys_data(dev);
pdd = &dev->power.subsys_data->domain_data;
pdd->dev = dev;
pdd->need_restore = false;
list_add_tail(&pdd->list_node, &genpd->dev_list);
dev->power.subsys_data->domain_data = &gpd_data->base;
gpd_data->base.dev = dev;
gpd_data->need_restore = false;
list_add_tail(&gpd_data->base.list_node, &genpd->dev_list);

out:
genpd_release_lock(genpd);
Expand Down Expand Up @@ -1152,6 +1161,7 @@ int pm_genpd_remove_device(struct generic_pm_domain *genpd,
pdd->dev = NULL;
dev_pm_put_subsys_data(dev);
dev->pm_domain = NULL;
kfree(to_gpd_data(pdd));

genpd->device_count--;

Expand Down
3 changes: 1 addition & 2 deletions trunk/include/linux/pm.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ struct wakeup_source;
struct pm_domain_data {
struct list_head list_node;
struct device *dev;
bool need_restore;
};

struct pm_subsys_data {
Expand All @@ -434,7 +433,7 @@ struct pm_subsys_data {
struct list_head clock_list;
#endif
#ifdef CONFIG_PM_GENERIC_DOMAINS
struct pm_domain_data domain_data;
struct pm_domain_data *domain_data;
#endif
};

Expand Down
10 changes: 10 additions & 0 deletions trunk/include/linux/pm_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ struct gpd_link {
struct list_head slave_node;
};

struct generic_pm_domain_data {
struct pm_domain_data base;
bool need_restore;
};

static inline struct generic_pm_domain_data *to_gpd_data(struct pm_domain_data *pdd)
{
return container_of(pdd, struct generic_pm_domain_data, base);
}

#ifdef CONFIG_PM_GENERIC_DOMAINS
extern int pm_genpd_add_device(struct generic_pm_domain *genpd,
struct device *dev);
Expand Down

0 comments on commit 11a9ca9

Please sign in to comment.