public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Michael Buesch <mb@bu3sch.de>,
	pm list <linux-pm@lists.linux-foundation.org>,
	Alan Stern <stern@rowland.harvard.edu>,
	Len Brown <lenb@kernel.org>, LKML <linux-kernel@vger.kernel.org>,
	Pavel Machek <pavel@ucw.cz>,
	bcm43xx-dev@lists.berlios.de,
	Alessandro Rubini <rubini@vision.unipv.it>,
	Richard Purdie <rpurdie@rpsys.net>
Subject: [PATCH -mm 4/5] Leds: Add possibility to remove leds classdevs during suspend/resume
Date: Fri, 25 Jan 2008 01:36:29 +0100	[thread overview]
Message-ID: <200801250136.30292.rjw@sisk.pl> (raw)
In-Reply-To: <200801250127.21966.rjw@sisk.pl>

From: Rafael J. Wysocki <rjw@sisk.pl>

Make it possible to unregister a led classdev object in a safe way
during a suspend/resume cycle.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 drivers/leds/led-class.c |   13 +++++++++----
 include/linux/leds.h     |   10 +++++++++-
 2 files changed, 18 insertions(+), 5 deletions(-)

Index: linux-2.6.24-rc8-mm1/drivers/leds/led-class.c
===================================================================
--- linux-2.6.24-rc8-mm1.orig/drivers/leds/led-class.c
+++ linux-2.6.24-rc8-mm1/drivers/leds/led-class.c
@@ -137,12 +137,14 @@ err_out:
 EXPORT_SYMBOL_GPL(led_classdev_register);
 
 /**
- * led_classdev_unregister - unregisters a object of led_properties class.
+ * __led_classdev_unregister - unregisters a object of led_properties class.
  * @led_cdev: the led device to unregister
+ * @suspended: indicates whether system-wide suspend or resume is in progress
  *
  * Unregisters a previously registered via led_classdev_register object.
  */
-void led_classdev_unregister(struct led_classdev *led_cdev)
+void __led_classdev_unregister(struct led_classdev *led_cdev,
+				      bool suspended)
 {
 	device_remove_file(led_cdev->dev, &dev_attr_brightness);
 #ifdef CONFIG_LEDS_TRIGGERS
@@ -153,13 +155,16 @@ void led_classdev_unregister(struct led_
 	up_write(&led_cdev->trigger_lock);
 #endif
 
-	device_unregister(led_cdev->dev);
+	if (suspended)
+		device_pm_schedule_removal(led_cdev->dev);
+	else
+		device_unregister(led_cdev->dev);
 
 	down_write(&leds_list_lock);
 	list_del(&led_cdev->node);
 	up_write(&leds_list_lock);
 }
-EXPORT_SYMBOL_GPL(led_classdev_unregister);
+EXPORT_SYMBOL_GPL(__led_classdev_unregister);
 
 static int __init leds_init(void)
 {
Index: linux-2.6.24-rc8-mm1/include/linux/leds.h
===================================================================
--- linux-2.6.24-rc8-mm1.orig/include/linux/leds.h
+++ linux-2.6.24-rc8-mm1/include/linux/leds.h
@@ -59,7 +59,15 @@ struct led_classdev {
 
 extern int led_classdev_register(struct device *parent,
 				 struct led_classdev *led_cdev);
-extern void led_classdev_unregister(struct led_classdev *led_cdev);
+extern void __led_classdev_unregister(struct led_classdev *led_cdev, bool sus);
+static inline void led_classdev_unregister(struct led_classdev *lcd)
+{
+	__led_classdev_unregister(lcd, false);
+}
+static inline void led_classdev_unregister_suspended(struct led_classdev *lcd)
+{
+	__led_classdev_unregister(lcd, true);
+}
 extern void led_classdev_suspend(struct led_classdev *led_cdev);
 extern void led_classdev_resume(struct led_classdev *led_cdev);
 


  parent reply	other threads:[~2008-01-25  0:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-25  0:27 [PATCH -mm 0/5] b43: Fix suspend/resume deadlock Rafael J. Wysocki
2008-01-25  0:30 ` [PATCH -mm 1/5] PM: Export device_pm_schedule_removal Rafael J. Wysocki
2008-01-25  7:44   ` Pavel Machek
2008-01-28 17:59   ` patch pm-export-device_pm_schedule_removal.patch added to gregkh-2.6 tree gregkh
2008-01-25  0:31 ` [PATCH -mm 2/5] Misc: Add possibility to remove misc devices during suspend/resume Rafael J. Wysocki
2008-01-25  0:35 ` [PATCH -mm 3/5] HWRNG: Add possibility to remove hwrng " Rafael J. Wysocki
2008-01-25  0:36 ` Rafael J. Wysocki [this message]
2008-01-25  0:37 ` [PATCH -mm 5/5] b43: Avoid unregistering device objects during suspend Rafael J. Wysocki
2008-01-25  7:47   ` Pavel Machek
2008-01-25 10:13     ` Michael Buesch
2008-01-25 11:45       ` Rafael J. Wysocki
2008-01-25 14:58     ` Alan Stern
2008-01-25 21:16       ` Pavel Machek

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=200801250136.30292.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=akpm@linux-foundation.org \
    --cc=bcm43xx-dev@lists.berlios.de \
    --cc=lenb@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=mb@bu3sch.de \
    --cc=pavel@ucw.cz \
    --cc=rpurdie@rpsys.net \
    --cc=rubini@vision.unipv.it \
    --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