From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: linux-pm <linux-pm@lists.osdl.org>
Cc: Pavel Machek <pavel@ucw.cz>
Subject: [RFC][PATCH 1/2] PM: Remove pm_parent from dev_pm_info
Date: Sat, 9 Jun 2007 23:31:21 +0200 [thread overview]
Message-ID: <200706092331.22140.rjw@sisk.pl> (raw)
In-Reply-To: <200706092329.08166.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
The pm_parent member of struct dev_pm_info (defined in include/linux/pm.h) is
only used to check if the device's parent is in the right state while the
device is being suspended or resumed. However, this can be done just as well
with the help of the parent pointer in struct device, so pm_parent can be
removed along with some code that handles it.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
drivers/base/power/main.c | 36 ++++++++++--------------------------
drivers/base/power/resume.c | 7 +++----
drivers/base/power/suspend.c | 7 +++----
include/linux/pm.h | 3 ---
4 files changed, 16 insertions(+), 37 deletions(-)
Index: linux-2.6.22-rc4/drivers/base/power/main.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/base/power/main.c 2007-06-08 13:09:16.000000000 +0200
+++ linux-2.6.22-rc4/drivers/base/power/main.c 2007-06-09 22:19:44.000000000 +0200
@@ -31,28 +31,7 @@ DEFINE_MUTEX(dpm_list_mtx);
int (*platform_enable_wakeup)(struct device *dev, int is_on);
-
-/**
- * device_pm_set_parent - Specify power dependency.
- * @dev: Device who needs power.
- * @parent: Device that supplies power.
- *
- * This function is used to manually describe a power-dependency
- * relationship. It may be used to specify a transversal relationship
- * (where the power supplier is not the physical (or electrical)
- * ancestor of a specific device.
- * The effect of this is that the supplier will not be powered down
- * before the power dependent.
- */
-
-void device_pm_set_parent(struct device * dev, struct device * parent)
-{
- put_device(dev->power.pm_parent);
- dev->power.pm_parent = get_device(parent);
-}
-EXPORT_SYMBOL_GPL(device_pm_set_parent);
-
-int device_pm_add(struct device * dev)
+int device_pm_add(struct device *dev)
{
int error;
@@ -61,21 +40,26 @@ int device_pm_add(struct device * dev)
kobject_name(&dev->kobj));
mutex_lock(&dpm_list_mtx);
list_add_tail(&dev->power.entry, &dpm_active);
- device_pm_set_parent(dev, dev->parent);
- if ((error = dpm_sysfs_add(dev)))
+ /*
+ * The device's parent must not be released until the device itself is
+ * removed from the dpm_active list.
+ */
+ get_device(dev->parent);
+ error = dpm_sysfs_add(dev);
+ if (error)
list_del(&dev->power.entry);
mutex_unlock(&dpm_list_mtx);
return error;
}
-void device_pm_remove(struct device * dev)
+void device_pm_remove(struct device *dev)
{
pr_debug("PM: Removing info for %s:%s\n",
dev->bus ? dev->bus->name : "No Bus",
kobject_name(&dev->kobj));
mutex_lock(&dpm_list_mtx);
dpm_sysfs_remove(dev);
- put_device(dev->power.pm_parent);
+ put_device(dev->parent);
list_del_init(&dev->power.entry);
mutex_unlock(&dpm_list_mtx);
}
Index: linux-2.6.22-rc4/drivers/base/power/resume.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/base/power/resume.c 2007-06-08 13:09:16.000000000 +0200
+++ linux-2.6.22-rc4/drivers/base/power/resume.c 2007-06-09 21:12:43.000000000 +0200
@@ -29,12 +29,11 @@ int resume_device(struct device * dev)
down(&dev->sem);
- if (dev->power.pm_parent
- && dev->power.pm_parent->power.power_state.event) {
+ if (dev->parent && dev->parent->power.power_state.event) {
dev_err(dev, "PM: resume from %d, parent %s still %d\n",
dev->power.power_state.event,
- dev->power.pm_parent->bus_id,
- dev->power.pm_parent->power.power_state.event);
+ dev->parent->bus_id,
+ dev->parent->power.power_state.event);
}
if (dev->bus && dev->bus->resume) {
Index: linux-2.6.22-rc4/drivers/base/power/suspend.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/base/power/suspend.c 2007-06-08 13:09:16.000000000 +0200
+++ linux-2.6.22-rc4/drivers/base/power/suspend.c 2007-06-09 21:12:40.000000000 +0200
@@ -55,13 +55,12 @@ int suspend_device(struct device * dev,
dev_dbg(dev, "PM: suspend %d-->%d\n",
dev->power.power_state.event, state.event);
}
- if (dev->power.pm_parent
- && dev->power.pm_parent->power.power_state.event) {
+ if (dev->parent && dev->parent->power.power_state.event) {
dev_err(dev,
"PM: suspend %d->%d, parent %s already %d\n",
dev->power.power_state.event, state.event,
- dev->power.pm_parent->bus_id,
- dev->power.pm_parent->power.power_state.event);
+ dev->parent->bus_id,
+ dev->parent->power.power_state.event);
}
dev->power.prev_state = dev->power.power_state;
Index: linux-2.6.22-rc4/include/linux/pm.h
===================================================================
--- linux-2.6.22-rc4.orig/include/linux/pm.h 2007-06-08 13:09:17.000000000 +0200
+++ linux-2.6.22-rc4/include/linux/pm.h 2007-06-09 21:12:45.000000000 +0200
@@ -237,13 +237,10 @@ struct dev_pm_info {
unsigned should_wakeup:1;
pm_message_t prev_state;
void * saved_state;
- struct device * pm_parent;
struct list_head entry;
#endif
};
-extern void device_pm_set_parent(struct device * dev, struct device * parent);
-
extern int device_power_down(pm_message_t state);
extern void device_power_up(void);
extern void device_resume(void);
next prev parent reply other threads:[~2007-06-09 21:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-09 21:29 [RFC][PATCH 0/2] PM: Remove two fields from dev_pm_info Rafael J. Wysocki
2007-06-09 21:31 ` Rafael J. Wysocki [this message]
2007-06-09 21:32 ` [RFC][PATCH 2/2] PM: Remove saved_state " Rafael J. Wysocki
2007-06-10 14:32 ` Alan Stern
2007-06-10 17:10 ` Rafael J. Wysocki
2007-06-10 23:31 ` [RFC][PATCH] PM: Remove prev_state " Rafael J. Wysocki
2007-06-11 14:14 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200706092331.22140.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=linux-pm@lists.osdl.org \
--cc=pavel@ucw.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox