public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@suse.de>
To: linux-kernel@vger.kernel.org
Cc: Alan Stern <stern@rowland.harvard.edu>,
	Greg Kroah-Hartman <gregkh@suse.de>
Subject: [PATCH 07/15] PM: don't skip device PM init when CONFIG_PM_SLEEP isn't set and CONFIG_PM is set
Date: Thu, 21 Aug 2008 10:32:55 -0700	[thread overview]
Message-ID: <1219339983-9634-7-git-send-email-gregkh@suse.de> (raw)
In-Reply-To: <20080821173036.GB7974@suse.de>

From: Alan Stern <stern@rowland.harvard.edu>

This patch (as1124) fixes a couple of bugs in the PM core.  The new
dev->power.status field should be initialized regardless of whether
CONFIG_PM_SLEEP is enabled, and similarly dpm_sysfs_add() should be
called whenever CONFIG_PM is enabled.

The patch separates out the call to dpm_sysfs_add() from the call to
device_pm_add().  As a result device_pm_add() can no longer return an
error, so its return type is changed to void.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Romit Dasgupta <romit@ti.com>
Acked-by: Rafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/core.c        |    9 ++++++---
 drivers/base/power/main.c  |   13 +++----------
 drivers/base/power/power.h |    9 +++++++--
 3 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index 44bad73..4004131 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -541,6 +541,7 @@ void device_initialize(struct device *dev)
 	spin_lock_init(&dev->devres_lock);
 	INIT_LIST_HEAD(&dev->devres_head);
 	device_init_wakeup(dev, 0);
+	device_pm_init(dev);
 	set_dev_node(dev, -1);
 }
 
@@ -897,9 +898,10 @@ int device_add(struct device *dev)
 	error = bus_add_device(dev);
 	if (error)
 		goto BusError;
-	error = device_pm_add(dev);
+	error = dpm_sysfs_add(dev);
 	if (error)
-		goto PMError;
+		goto DPMError;
+	device_pm_add(dev);
 	kobject_uevent(&dev->kobj, KOBJ_ADD);
 	bus_attach_device(dev);
 	if (parent)
@@ -920,7 +922,7 @@ int device_add(struct device *dev)
  Done:
 	put_device(dev);
 	return error;
- PMError:
+ DPMError:
 	bus_remove_device(dev);
  BusError:
 	if (dev->bus)
@@ -1007,6 +1009,7 @@ void device_del(struct device *dev)
 	struct class_interface *class_intf;
 
 	device_pm_remove(dev);
+	dpm_sysfs_remove(dev);
 	if (parent)
 		klist_del(&dev->knode_parent);
 	if (MAJOR(dev->devt)) {
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 3250c52..284f564 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -67,10 +67,8 @@ void device_pm_unlock(void)
  *	device_pm_add - add a device to the list of active devices
  *	@dev:	Device to be added to the list
  */
-int device_pm_add(struct device *dev)
+void device_pm_add(struct device *dev)
 {
-	int error;
-
 	pr_debug("PM: Adding info for %s:%s\n",
 		 dev->bus ? dev->bus->name : "No Bus",
 		 kobject_name(&dev->kobj));
@@ -89,13 +87,9 @@ int device_pm_add(struct device *dev)
 		 */
 		WARN_ON(true);
 	}
-	error = dpm_sysfs_add(dev);
-	if (!error) {
-		dev->power.status = DPM_ON;
-		list_add_tail(&dev->power.entry, &dpm_list);
-	}
+
+	list_add_tail(&dev->power.entry, &dpm_list);
 	mutex_unlock(&dpm_list_mtx);
-	return error;
 }
 
 /**
@@ -110,7 +104,6 @@ void device_pm_remove(struct device *dev)
 		 dev->bus ? dev->bus->name : "No Bus",
 		 kobject_name(&dev->kobj));
 	mutex_lock(&dpm_list_mtx);
-	dpm_sysfs_remove(dev);
 	list_del_init(&dev->power.entry);
 	mutex_unlock(&dpm_list_mtx);
 }
diff --git a/drivers/base/power/power.h b/drivers/base/power/power.h
index a3252c0..41f51fa 100644
--- a/drivers/base/power/power.h
+++ b/drivers/base/power/power.h
@@ -1,3 +1,8 @@
+static inline void device_pm_init(struct device *dev)
+{
+	dev->power.status = DPM_ON;
+}
+
 #ifdef CONFIG_PM_SLEEP
 
 /*
@@ -11,12 +16,12 @@ static inline struct device *to_device(struct list_head *entry)
 	return container_of(entry, struct device, power.entry);
 }
 
-extern int device_pm_add(struct device *);
+extern void device_pm_add(struct device *);
 extern void device_pm_remove(struct device *);
 
 #else /* CONFIG_PM_SLEEP */
 
-static inline int device_pm_add(struct device *dev) { return 0; }
+static inline void device_pm_add(struct device *dev) {}
 static inline void device_pm_remove(struct device *dev) {}
 
 #endif
-- 
1.5.6.5


  parent reply	other threads:[~2008-08-21 17:38 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-21 17:30 [GIT PATCH] driver core patches against 2.6.26-rc4 Greg KH
2008-08-21 17:32 ` [PATCH 01/15] kobject: Replace ALL occurrences of '/' with '!' instead of only the first one Greg Kroah-Hartman
2008-08-22 12:41   ` Ville Syrjälä
2008-08-23  2:14     ` Greg KH
2008-08-21 17:32 ` [PATCH 02/15] Japanese translation of Documentation/SubmitChecklist Greg Kroah-Hartman
2008-08-21 17:32 ` [PATCH 03/15] Documentation: HOWTO-ja_JP-sync patch Greg Kroah-Hartman
2008-08-21 17:32 ` [PATCH 04/15] drivers/base/driver.c: remove unused to_dev() macro Greg Kroah-Hartman
2008-08-21 17:32 ` [PATCH 05/15] dev_printk(): constify the `dev' argument Greg Kroah-Hartman
2008-08-21 17:32 ` [PATCH 06/15] driver model: anti-oopsing medicine Greg Kroah-Hartman
2008-08-21 18:24   ` David Brownell
2008-08-21 20:04     ` Greg KH
2008-08-21 17:32 ` Greg Kroah-Hartman [this message]
2008-08-21 17:32 ` [PATCH 08/15] driver core: add init_name to struct device Greg Kroah-Hartman
2008-08-21 17:32 ` [PATCH 09/15] PM: Remove WARN_ON from device_pm_add Greg Kroah-Hartman
2008-08-21 17:32 ` [PATCH 10/15] block: fix partial read() of /proc/{partitions,diskstats} Greg Kroah-Hartman
2008-08-21 17:32 ` [PATCH 11/15] block: drop references taken by class_find_device() Greg Kroah-Hartman
2008-08-21 17:33 ` [PATCH 12/15] UIO: uio_pdrv: fix memory leak Greg Kroah-Hartman
2008-08-21 17:33 ` [PATCH 13/15] UIO: uio_pdrv: fix license specification Greg Kroah-Hartman
2008-08-21 17:33 ` [PATCH 14/15] UIO: generic irq handling for some uio platform devices Greg Kroah-Hartman
2008-08-21 17:33 ` [PATCH 15/15] pnp: fix "add acpi:* modalias entries" Greg Kroah-Hartman

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=1219339983-9634-7-git-send-email-gregkh@suse.de \
    --to=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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