Skip to contentSkip to conversation

sleep notifier cleanup

PATCH In review Johannes Berg 3 participants 15 messages Mar 19, 2007 – Apr 4, 2007

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover sleep notifier cleanup

This patch series gets rid of the various pmu sleep notifier users by various means.

johannes

#1 lore raw

PATCH 1/5 adb: replace sleep notifier with sysdev

This patch replaces the pmu sleep notifier that adb had with a proper sysdevice.

Cc Benjamin Herrenschmidt <[email protected]>
---
 drivers/macintosh/adb.c |   89 ++++++++++++++++++++++++++----------------------
 1 file changed, 50 insertions(+), 39 deletions(-)
drivers/macintosh/adb.c +50 -39
@@ -89,14 +89,6 @@ static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
 
-#ifdef CONFIG_PM
-static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
-static struct pmu_sleep_notifier adb_sleep_notifier = {
-	adb_notify_sleep,
-	SLEEP_LEVEL_ADB,
-};
-#endif
-
 static int adb_scan_bus(void);
 static int do_adb_reset_bus(void);
 static void adbdev_init(void);
@@ -287,10 +279,51 @@ adb_reset_bus(void)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+/*
+ * notify clients before sleep
+ */
+int adb_suspend(struct sys_device *dev, pm_message_t state)
+{
+	adb_got_sleep = 1;
+	/* We need to get a lock on the probe thread */
+	down(&adb_probe_mutex);
+	/* Stop autopoll */
+	if (adb_controller->autopoll)
+		adb_controller->autopoll(0);
+	blocking_notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL);
+
+	return 0;
+}
+
+/*
+ * reset bus after sleep
+ */
+int adb_resume(struct sys_device *dev)
+{
+	adb_got_sleep = 0;
+	up(&adb_probe_mutex);
+	adb_reset_bus();
+	return 0;
+}
+#endif /* CONFIG_PM */
+
+static struct sysdev_class adb_sysclass = {
+#ifdef CONFIG_PM
+	.resume = adb_resume,
+	.suspend = adb_suspend,
+#endif
+	set_kset_name("adb"),
+};
+
+static struct sys_device adb_sysdev = {
+	.cls = &adb_sysclass,
+};
+
 int __init adb_init(void)
 {
 	struct adb_driver *driver;
-	int i;
+	int i, err;
 
 #ifdef CONFIG_PPC32
 	if (!machine_is(chrp) && !machine_is(powermac))
@@ -319,14 +352,19 @@ int __init adb_init(void)
 		printk(KERN_WARNING "Warning: no ADB interface detected\n");
 		adb_controller = NULL;
 	} else {
-#ifdef CONFIG_PM
-		pmu_register_sleep_notifier(&adb_sleep_notifier);
-#endif /* CONFIG_PM */
+		err = sysdev_class_register(&adb_sysclass);
+		if (err)
+			return err;
+		err = sysdev_register(&adb_sysdev);
+		if (err)
+			return err;
+
 #ifdef CONFIG_PPC
 		if (machine_is_compatible("AAPL,PowerBook1998") ||
 			machine_is_compatible("PowerBook1,1"))
 			sleepy_trackpad = 1;
 #endif /* CONFIG_PPC */
+
 		init_completion(&adb_probe_task_comp);
 		adbdev_init();
 		adb_reset_bus();
@@ -336,33 +374,6 @@ int __init adb_init(void)
 
 __initcall(adb_init);
 
-#ifdef CONFIG_PM
-/*
- * notify clients before sleep and reset bus afterwards
- */
-void
-adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
-{
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		adb_got_sleep = 1;
-		/* We need to get a lock on the probe thread */
-		down(&adb_probe_mutex);
-		/* Stop autopoll */
-		if (adb_controller->autopoll)
-			adb_controller->autopoll(0);
-		blocking_notifier_call_chain(&adb_client_list,
-			ADB_MSG_POWERDOWN, NULL);
-		break;
-	case PBOOK_WAKE:
-		adb_got_sleep = 0;
-		up(&adb_probe_mutex);
-		adb_reset_bus();
-		break;
-	}
-}
-#endif /* CONFIG_PM */
-
 static int
 do_adb_reset_bus(void)
 {

--

#2 lore raw

PATCH v2 1/5 adb: replace sleep notifier with class suspend/resume hooks

Subject: adb: replace sleep notifier with class suspend/resume hooks

This patch replaces the pmu sleep notifier that adb had with a proper suspend/resume hooks in the adb class.

Cc Benjamin Herrenschmidt <[email protected]>

---
sysdevs are suspended/resumed with interrupts off which isn't what we want for adb.

---
 drivers/macintosh/adb.c |   74 +++++++++++++++++++++++-------------------------
 1 file changed, 36 insertions(+), 38 deletions(-)
drivers/macintosh/adb.c +36 -38
@@ -89,14 +89,6 @@ static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
 
-#ifdef CONFIG_PM
-static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
-static struct pmu_sleep_notifier adb_sleep_notifier = {
-	adb_notify_sleep,
-	SLEEP_LEVEL_ADB,
-};
-#endif
-
 static int adb_scan_bus(void);
 static int do_adb_reset_bus(void);
 static void adbdev_init(void);
@@ -287,6 +279,35 @@ adb_reset_bus(void)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+/*
+ * notify clients before sleep
+ */
+int adb_suspend(struct device *dev, pm_message_t state)
+{
+	adb_got_sleep = 1;
+	/* We need to get a lock on the probe thread */
+	down(&adb_probe_mutex);
+	/* Stop autopoll */
+	if (adb_controller->autopoll)
+		adb_controller->autopoll(0);
+	blocking_notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL);
+
+	return 0;
+}
+
+/*
+ * reset bus after sleep
+ */
+int adb_resume(struct device *dev)
+{
+	adb_got_sleep = 0;
+	up(&adb_probe_mutex);
+	adb_reset_bus();
+	return 0;
+}
+#endif /* CONFIG_PM */
+
 int __init adb_init(void)
 {
 	struct adb_driver *driver;
@@ -319,14 +340,12 @@ int __init adb_init(void)
 		printk(KERN_WARNING "Warning: no ADB interface detected\n");
 		adb_controller = NULL;
 	} else {
-#ifdef CONFIG_PM
-		pmu_register_sleep_notifier(&adb_sleep_notifier);
-#endif /* CONFIG_PM */
 #ifdef CONFIG_PPC
 		if (machine_is_compatible("AAPL,PowerBook1998") ||
 			machine_is_compatible("PowerBook1,1"))
 			sleepy_trackpad = 1;
 #endif /* CONFIG_PPC */
+
 		init_completion(&adb_probe_task_comp);
 		adbdev_init();
 		adb_reset_bus();
@@ -336,33 +355,6 @@ int __init adb_init(void)
 
 __initcall(adb_init);
 
-#ifdef CONFIG_PM
-/*
- * notify clients before sleep and reset bus afterwards
- */
-void
-adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
-{
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		adb_got_sleep = 1;
-		/* We need to get a lock on the probe thread */
-		down(&adb_probe_mutex);
-		/* Stop autopoll */
-		if (adb_controller->autopoll)
-			adb_controller->autopoll(0);
-		blocking_notifier_call_chain(&adb_client_list,
-			ADB_MSG_POWERDOWN, NULL);
-		break;
-	case PBOOK_WAKE:
-		adb_got_sleep = 0;
-		up(&adb_probe_mutex);
-		adb_reset_bus();
-		break;
-	}
-}
-#endif /* CONFIG_PM */
-
 static int
 do_adb_reset_bus(void)
 {
@@ -881,5 +873,11 @@ adbdev_init(void)
 	adb_dev_class = class_create(THIS_MODULE, "adb");
 	if (IS_ERR(adb_dev_class))
 		return;
+
+#ifdef CONFIG_PM
+	adb_dev_class->suspend = adb_suspend;
+	adb_dev_class->resume = adb_resume;
+#endif
+
 	class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
 }
#3 lore raw

Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks

Quoted 3 lines

This patch replaces the pmu sleep notifier that adb had with a proper suspend/resume hooks in the adb class.

So class suspend/resume hooks are apparently not called unless you do some more magic juju.

I'll work more sysfs foo to fix it. You can probably
make /sys/power/state work and have adb still work by just applying all the patches up to "remove dead code in via-pmu86k".

Then again, which patches do you have applied now? Do you even have this one? I only sent you the other ones, and if you only have those applied then the problem must be elsewhere...

johannes

#4 lore raw

Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks

Quoted 11 lines · Johannes Berg

So class suspend/resume hooks are apparently not called unless you do some more magic juju.

I'll work more sysfs foo to fix it. You can probably
make /sys/power/state work and have adb still work by just applying all the patches up to "remove dead code in via-pmu86k".

Then again, which patches do you have applied now? Do you even have this one? I only sent you the other ones, and if you only have those applied then the problem must be elsewhere...

I didn't have this set of patches applied. I have these:

Subject: [PATCH 1/3] rework pm_ops pm_disk_mode, kill misuse
Subject: [PATCH 2/3] power management: remove firmware disk mode
Subject: [PATCH 3/3] power management: implement pm_ops.valid for everybody

Subject: [PATCH 1/5] powerpc: generic time suspend/resume code
Subject: [PATCH 2/5] powerpc: fix suspend states again
Subject: [PATCH 3/5] powermac: disallow pmu sleep notifiers from aborting
Subject: [PATCH 4/5 v2] powermac: proper sleep management

It does re-probe ADB on resume, and it finds the keyboard every time (thankfully). It just doesn't find the mouse more than about 1 in 10 times. Could it just be a timing thing? Resume seems to be a lot faster with the patches applied.

Signature · 1 line
dwmw2
#5 lore raw

Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks

Quoted 1 line · David Woodhouse

I didn't have this set of patches applied. I have these:

Ok.

Quoted 6 lines

Subject: [PATCH 1/3] rework pm_ops pm_disk_mode, kill misuse
Subject: [PATCH 2/3] power management: remove firmware disk mode
Subject: [PATCH 3/3] power management: implement pm_ops.valid for everybody

Subject: [PATCH 1/5] powerpc: generic time suspend/resume code
Subject: [PATCH 2/5] powerpc: fix suspend states again

Is that the version you have in the fedora CVS? Because that one seems to be an older one that has a bug with set_context.

Quoted 5 lines

Subject: [PATCH 3/5] powermac: disallow pmu sleep notifiers from aborting
Subject: [PATCH 4/5 v2] powermac: proper sleep management

It does re-probe ADB on resume, and it finds the keyboard every time (thankfully).

Interesting.

Quoted 3 lines

It just doesn't find the mouse more than about 1 in 10 times. Could it just be a timing thing? Resume seems to be a lot faster with the patches applied.

I have to admit that I have no idea, I don't have a machine with ADB in it. I'll poke at the code a bit.

johannes

#6 lore raw

Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks

Quoted 2 lines · Johannes Berg

Is that the version you have in the fedora CVS? Because that one seems to be an older one that has a bug with set_context.

Yes. I've updated the patch in CVS; thanks for pointing it out.

Quoted 6 lines
Quoted 5 lines

Subject: [PATCH 3/5] powermac: disallow pmu sleep notifiers from aborting
Subject: [PATCH 4/5 v2] powermac: proper sleep management

It does re-probe ADB on resume, and it finds the keyboard every time (thankfully).

Quoted 8 lines

Interesting.

Quoted 3 lines

It just doesn't find the mouse more than about 1 in 10 times. Could it just be a timing thing? Resume seems to be a lot faster with the patches applied.

I have to admit that I have no idea, I don't have a machine with ADB in it. I'll poke at the code a bit.

Not sure if the subsequent patch was expected to change anything or not, but it doesn't...

 $ dmesg | grep -i adb
PM: Adding info for platform:adb.0
adb: starting probe task...
adb devices: [2]: 2 c4 [3]: 3 1 [7]: 7 1f
ADB keyboard at 2, handler 1
Detected ADB keyboard, type ISO, swapping keys.
input: ADB keyboard as /class/input/input1
input: ADB Powerbook buttons as /class/input/input2
ADB mouse at 3, handler set to 4 (trackpad)
input: ADB mouse as /class/input/input3
adb: finished probe task...
adb adb.0: suspend
adb adb.0: LATE suspend
adb adb.0: EARLY resume
adb adb.0: resuming
adb: starting probe task...
adb devices: [2]: 2 c4 [7]: 7 1f
ADB keyboard at 2, handler 1
adb: finished probe task...
Signature · 1 line
dwmw2
#7 lore raw

Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks

Quoted 2 lines · David Woodhouse

Not sure if the subsequent patch was expected to change anything or not, but it doesn't...

Which patch are you referring to? The one you updated wasn't supposed to change anything here. In fact, we've not actually restored the context for suspend to disk forever ("fix suspend states again").

Quoted 12 lines
 $ dmesg | grep -i adb
PM: Adding info for platform:adb.0
adb: starting probe task...
adb devices: [2]: 2 c4 [3]: 3 1 [7]: 7 1f
ADB keyboard at 2, handler 1
Detected ADB keyboard, type ISO, swapping keys.
input: ADB keyboard as /class/input/input1
input: ADB Powerbook buttons as /class/input/input2
ADB mouse at 3, handler set to 4 (trackpad)
input: ADB mouse as /class/input/input3
adb: finished probe task...
Quoted 8 lines

adb adb.0: suspend
adb adb.0: LATE suspend
adb adb.0: EARLY resume
adb adb.0: resuming
adb: starting probe task...
adb devices: [2]: 2 c4 [7]: 7 1f
ADB keyboard at 2, handler 1
adb: finished probe task...

Right. I really haven't got a clue what this may cause. I'm trying to find something but haven't so far.

johannes

#8 lore raw

Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks

In reply to David Woodhouse
Quoted 24 lines · David Woodhouse
Quoted 11 lines · Johannes Berg

So class suspend/resume hooks are apparently not called unless you do some more magic juju.

I'll work more sysfs foo to fix it. You can probably
make /sys/power/state work and have adb still work by just applying all the patches up to "remove dead code in via-pmu86k".

Then again, which patches do you have applied now? Do you even have this one? I only sent you the other ones, and if you only have those applied then the problem must be elsewhere...

I didn't have this set of patches applied. I have these:

Subject: [PATCH 1/3] rework pm_ops pm_disk_mode, kill misuse
Subject: [PATCH 2/3] power management: remove firmware disk mode
Subject: [PATCH 3/3] power management: implement pm_ops.valid for everybody

Subject: [PATCH 1/5] powerpc: generic time suspend/resume code
Subject: [PATCH 2/5] powerpc: fix suspend states again
Subject: [PATCH 3/5] powermac: disallow pmu sleep notifiers from aborting
Subject: [PATCH 4/5 v2] powermac: proper sleep management

Quoted 4 lines

It does re-probe ADB on resume, and it finds the keyboard every time (thankfully). It just doesn't find the mouse more than about 1 in 10 times. Could it just be a timing thing? Resume seems to be a lot faster with the patches applied.

Hrm... ADB resume is supposed to fire a thread and if you have a trackpad, it's supposed to wait for some time for it to settle...

Ben.

#9 lore raw

PATCH v3 1/5 adb: replace sleep notifier with platform driver suspend/resume hooks

In reply to Johannes Berg

This patch replaces the pmu sleep notifier that adb had with suspend/resume hooks in a new platform driver/device.

Cc Benjamin Herrenschmidt <[email protected]>

---
Yes, it's more a hack. But the whole code is such a mess that I could work for days fixing it. Don't feel like doing that. Of course you can screw yourself by unbinding the adb platform driver from the adb.0 platform device this creates. Tough luck.

 drivers/macintosh/adb.c |   96 ++++++++++++++++++++++++++++--------------------
 1 file changed, 57 insertions(+), 39 deletions(-)
drivers/macintosh/adb.c +57 -39
@@ -89,14 +89,6 @@ static int sleepy_trackpad;
 static int autopoll_devs;
 int __adb_probe_sync;
 
-#ifdef CONFIG_PM
-static void adb_notify_sleep(struct pmu_sleep_notifier *self, int when);
-static struct pmu_sleep_notifier adb_sleep_notifier = {
-	adb_notify_sleep,
-	SLEEP_LEVEL_ADB,
-};
-#endif
-
 static int adb_scan_bus(void);
 static int do_adb_reset_bus(void);
 static void adbdev_init(void);
@@ -287,6 +279,36 @@ adb_reset_bus(void)
 	return 0;
 }
 
+#ifdef CONFIG_PM
+/*
+ * notify clients before sleep
+ */
+static int adb_suspend(struct platform_device *dev, pm_message_t state)
+{
+	adb_got_sleep = 1;
+	/* We need to get a lock on the probe thread */
+	down(&adb_probe_mutex);
+	/* Stop autopoll */
+	if (adb_controller->autopoll)
+		adb_controller->autopoll(0);
+	blocking_notifier_call_chain(&adb_client_list, ADB_MSG_POWERDOWN, NULL);
+
+	return 0;
+}
+
+/*
+ * reset bus after sleep
+ */
+static int adb_resume(struct platform_device *dev)
+{
+	adb_got_sleep = 0;
+	up(&adb_probe_mutex);
+	adb_reset_bus();
+
+	return 0;
+}
+#endif /* CONFIG_PM */
+
 int __init adb_init(void)
 {
 	struct adb_driver *driver;
@@ -319,14 +341,12 @@ int __init adb_init(void)
 		printk(KERN_WARNING "Warning: no ADB interface detected\n");
 		adb_controller = NULL;
 	} else {
-#ifdef CONFIG_PM
-		pmu_register_sleep_notifier(&adb_sleep_notifier);
-#endif /* CONFIG_PM */
 #ifdef CONFIG_PPC
 		if (machine_is_compatible("AAPL,PowerBook1998") ||
 			machine_is_compatible("PowerBook1,1"))
 			sleepy_trackpad = 1;
 #endif /* CONFIG_PPC */
+
 		init_completion(&adb_probe_task_comp);
 		adbdev_init();
 		adb_reset_bus();
@@ -336,33 +356,6 @@ int __init adb_init(void)
 
 __initcall(adb_init);
 
-#ifdef CONFIG_PM
-/*
- * notify clients before sleep and reset bus afterwards
- */
-void
-adb_notify_sleep(struct pmu_sleep_notifier *self, int when)
-{
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		adb_got_sleep = 1;
-		/* We need to get a lock on the probe thread */
-		down(&adb_probe_mutex);
-		/* Stop autopoll */
-		if (adb_controller->autopoll)
-			adb_controller->autopoll(0);
-		blocking_notifier_call_chain(&adb_client_list,
-			ADB_MSG_POWERDOWN, NULL);
-		break;
-	case PBOOK_WAKE:
-		adb_got_sleep = 0;
-		up(&adb_probe_mutex);
-		adb_reset_bus();
-		break;
-	}
-}
-#endif /* CONFIG_PM */
-
 static int
 do_adb_reset_bus(void)
 {
@@ -870,7 +863,29 @@ static const struct file_operations adb_
 	.release	= adb_release,
 };
 
-static void
+static struct platform_driver adb_pfdrv = {
+	.driver = {
+		.name = "adb",
+	},
+#ifdef CONFIG_PM
+	.suspend = adb_suspend,
+	.resume = adb_resume,
+#endif
+};
+
+static struct platform_device adb_pfdev = {
+	.name = "adb",
+};
+
+static int __init
+adb_dummy_probe(struct platform_device *dev)
+{
+	if (dev == &adb_pfdev)
+		return 0;
+	return -ENODEV;
+}
+
+static void __init
 adbdev_init(void)
 {
 	if (register_chrdev(ADB_MAJOR, "adb", &adb_fops)) {
@@ -882,4 +897,7 @@ adbdev_init(void)
 	if (IS_ERR(adb_dev_class))
 		return;
 	class_device_create(adb_dev_class, NULL, MKDEV(ADB_MAJOR, 0), NULL, "adb");
+
+	platform_device_register(&adb_pfdev);
+	platform_driver_probe(&adb_pfdrv, adb_dummy_probe);
 }
#10 lore raw

PATCH 2/5 apm_emu: use generic apm-emulation

In reply to Johannes Berg

This patch removes a huge amount of code that is now in common code in drivers/char/apm-emulation.c

Cc Benjamin Herrenschmidt <[email protected]>
---
 arch/powerpc/Kconfig        |    3 
 drivers/macintosh/Kconfig   |    4 
 drivers/macintosh/apm_emu.c |  521 +++-----------------------------------------
 3 files changed, 50 insertions(+), 478 deletions(-)
drivers/macintosh/Kconfig +3 -1
@@ -109,7 +109,9 @@ config PMAC_SMU
 
 config PMAC_APM_EMU
 	tristate "APM emulation"
-	depends on PPC_PMAC && PPC32 && PM && ADB_PMU
+	select SYS_SUPPORTS_APM_EMULATION
+	select APM_EMULATION
+	depends on ADB_PMU && PM
 
 config PMAC_MEDIABAY
 	bool "Support PowerBook hotswap media bay"
drivers/macintosh/apm_emu.c +44 -477

576 lines not on this page · raw message

arch/powerpc/Kconfig +3 -0
@@ -117,6 +117,9 @@ config GENERIC_BUG
 	default y
 	depends on BUG
 
+config SYS_SUPPORTS_APM_EMULATION
+	bool
+
 config DEFAULT_UIMAGE
 	bool
 	help

--

#11 lore raw

PATCH 3/5 via-pmu: remove LED sleep notifier

In reply to Johannes Berg

The generic LED code now makes sure that suspended devices don't blink, so we no longer need to do it ourselves. For the suspend to disk case, however, we need to make sure that we don't blink if the PMU sysdev was suspended before the LED device.

Cc Benjamin Herrenschmidt <[email protected]>
---
 drivers/macintosh/via-pmu-led.c |   37 +++++--------------------------------
 drivers/macintosh/via-pmu.c     |    2 +-
 2 files changed, 6 insertions(+), 33 deletions(-)
drivers/macintosh/via-pmu-led.c +5 -32
@@ -31,7 +31,8 @@ static spinlock_t pmu_blink_lock;
 static struct adb_request pmu_blink_req;
 /* -1: no change, 0: request off, 1: request on */
 static int requested_change;
-static int sleeping;
+
+extern int pmu_sys_suspended;
 
 static void pmu_req_done(struct adb_request * req)
 {
@@ -41,7 +42,7 @@ static void pmu_req_done(struct adb_requ
 	/* if someone requested a change in the meantime
 	 * (we only see the last one which is fine)
 	 * then apply it now */
-	if (requested_change != -1 && !sleeping)
+	if (requested_change != -1 && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
 	/* reset requested change */
 	requested_change = -1;
@@ -66,7 +67,7 @@ static void pmu_led_set(struct led_class
 		break;
 	}
 	/* if request isn't done, then don't do anything */
-	if (pmu_blink_req.complete && !sleeping)
+	if (pmu_blink_req.complete && !pmu_sys_suspended)
 		pmu_request(&pmu_blink_req, NULL, 4, 0xee, 4, 0, requested_change);
  out:
  	spin_unlock_irqrestore(&pmu_blink_lock, flags);
@@ -80,32 +81,6 @@ static struct led_classdev pmu_led = {
 	.brightness_set = pmu_led_set,
 };
 
-#ifdef CONFIG_PM
-static void pmu_led_sleep_call(struct pmu_sleep_notifier *self, int when)
-{
-	unsigned long flags;
-
-	spin_lock_irqsave(&pmu_blink_lock, flags);
-
-	switch (when) {
-	case PBOOK_SLEEP_REQUEST:
-		sleeping = 1;
-		break;
-	case PBOOK_WAKE:
-		sleeping = 0;
-		break;
-	default:
-		/* do nothing */
-		break;
-	}
-	spin_unlock_irqrestore(&pmu_blink_lock, flags);
-}
-
-static struct pmu_sleep_notifier via_pmu_led_sleep_notif = {
-	.notifier_call = pmu_led_sleep_call,
-};
-#endif
-
 static int __init via_pmu_led_init(void)
 {
 	struct device_node *dt;
@@ -133,9 +108,7 @@ static int __init via_pmu_led_init(void)
 	/* no outstanding req */
 	pmu_blink_req.complete = 1;
 	pmu_blink_req.done = pmu_req_done;
-#ifdef CONFIG_PM
-	pmu_register_sleep_notifier(&via_pmu_led_sleep_notif);
-#endif
+
 	return led_classdev_register(NULL, &pmu_led);
 }
 
drivers/macintosh/via-pmu.c +1 -1
@@ -2699,7 +2699,7 @@ pmu_polled_request(struct adb_request *r
 
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 
-static int pmu_sys_suspended;
+int pmu_sys_suspended;
 
 static int pmu_sys_suspend(struct sys_device *sysdev, pm_message_t state)
 {

--

#12 lore raw

PATCH 4/5 remove awacs dmasound

In reply to Johannes Berg

This patch kills the obsolete awacs dmasound because it is in the way of doing power management improvements since it uses ancient API.

Cc Benjamin Herrenschmidt <[email protected]>
Cc Adrian Bunk <[email protected]>

---
In addition to applying this patch please
git-rm sound/oss/dmasound/awacs_defs.h
git-rm sound/oss/dmasound/dac3550a.c
git-rm sound/oss/dmasound/dmasound_awacs.c
git-rm sound/oss/dmasound/tas3001c.c
git-rm sound/oss/dmasound/tas3001c.h
git-rm sound/oss/dmasound/tas3001c_tables.c
git-rm sound/oss/dmasound/tas3004.c
git-rm sound/oss/dmasound/tas3004.h
git-rm sound/oss/dmasound/tas3004_tables.c
git-rm sound/oss/dmasound/tas_common.c
git-rm sound/oss/dmasound/tas_common.h
git-rm sound/oss/dmasound/tas_eq_prefs.h
git-rm sound/oss/dmasound/tas_ioctl.h
git-rm sound/oss/dmasound/trans_16.c

 sound/oss/dmasound/Kconfig           |   14 
 sound/oss/dmasound/Makefile          |    6 
 sound/oss/dmasound/awacs_defs.h      |  251 --
 sound/oss/dmasound/dac3550a.c        |  209 --
 sound/oss/dmasound/dmasound_awacs.c  | 3187 -----------------------------------
 sound/oss/dmasound/tas3001c.c        |  849 ---------
 sound/oss/dmasound/tas3001c.h        |   64 
 sound/oss/dmasound/tas3001c_tables.c |  375 ----
 sound/oss/dmasound/tas3004.c         | 1138 ------------
 sound/oss/dmasound/tas3004.h         |   77 
 sound/oss/dmasound/tas3004_tables.c  |  301 ---
 sound/oss/dmasound/tas_common.c      |  213 --
 sound/oss/dmasound/tas_common.h      |  284 ---
 sound/oss/dmasound/tas_eq_prefs.h    |   24 
 sound/oss/dmasound/tas_ioctl.h       |   24 
 sound/oss/dmasound/trans_16.c        |  898 ---------
 16 files changed, 7914 deletions(-)
sound/oss/dmasound/Makefile +0 -6
@@ -2,12 +2,6 @@
 # Makefile for the DMA sound driver
 #
 
-dmasound_pmac-y			+= dmasound_awacs.o \
-				   trans_16.o dac3550a.o tas_common.o \
-				   tas3001c.o tas3001c_tables.o \
-				   tas3004.o tas3004_tables.o
-
 obj-$(CONFIG_DMASOUND_ATARI)	+= dmasound_core.o dmasound_atari.o
-obj-$(CONFIG_DMASOUND_PMAC)	+= dmasound_core.o dmasound_pmac.o
 obj-$(CONFIG_DMASOUND_PAULA)	+= dmasound_core.o dmasound_paula.o
 obj-$(CONFIG_DMASOUND_Q40)	+= dmasound_core.o dmasound_q40.o
sound/oss/dmasound/Kconfig +0 -14
@@ -12,20 +12,6 @@ config DMASOUND_ATARI
 	  want). If you want to compile it as a module, say M here and read
 	  <file:Documentation/kbuild/modules.txt>.
 
-config DMASOUND_PMAC
-	tristate "PowerMac DMA sound support"
-	depends on PPC32 && PPC_PMAC && SOUND && I2C && OBSOLETE_OSS
- 	select DMASOUND
-	help
-	  If you want to use the internal audio of your PowerMac in Linux,
-	  answer Y to this question. This will provide a Sun-like /dev/audio,
-	  compatible with the Linux/i386 sound system. Otherwise, say N.
-
-	  This driver is also available as a module ( = code which can be
-	  inserted in and removed from the running kernel whenever you
-	  want). If you want to compile it as a module, say M here and read
-	  <file:Documentation/kbuild/modules.txt>.
-
 config DMASOUND_PAULA
 	tristate "Amiga DMA sound support"
 	depends on (AMIGA || APUS) && SOUND

--

#13 lore raw

PATCH 5/5 via-pmu: kill sleep notifiers completely

In reply to Johannes Berg

This patch kills off the remnants of the ancient sleep notifiers.

Cc Benjamin Herrenschmidt <[email protected]>
---
 drivers/macintosh/via-pmu.c |   68 --------------------------------------------
 include/linux/pmu.h         |   36 -----------------------
 2 files changed, 104 deletions(-)
drivers/macintosh/via-pmu.c +0 -68
@@ -174,7 +174,6 @@ static struct proc_dir_entry *proc_pmu_b
 
 int __fake_sleep;
 int asleep;
-BLOCKING_NOTIFIER_HEAD(sleep_notifier_list);
 
 #ifdef CONFIG_ADB
 static int adb_dev_map;
@@ -1730,67 +1729,7 @@ pmu_present(void)
 	return via != 0;
 }
 
-#ifdef CONFIG_PM
-
-static LIST_HEAD(sleep_notifiers);
-
-int
-pmu_register_sleep_notifier(struct pmu_sleep_notifier *n)
-{
-	struct list_head *list;
-	struct pmu_sleep_notifier *notifier;
-
-	for (list = sleep_notifiers.next; list != &sleep_notifiers;
-	     list = list->next) {
-		notifier = list_entry(list, struct pmu_sleep_notifier, list);
-		if (n->priority > notifier->priority)
-			break;
-	}
-	__list_add(&n->list, list->prev, list);
-	return 0;
-}
-EXPORT_SYMBOL(pmu_register_sleep_notifier);
-
-int
-pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* n)
-{
-	if (n->list.next == 0)
-		return -ENOENT;
-	list_del(&n->list);
-	n->list.next = NULL;
-	return 0;
-}
-EXPORT_SYMBOL(pmu_unregister_sleep_notifier);
-#endif /* CONFIG_PM */
-
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
-
-/* Sleep is broadcast last-to-first */
-static void broadcast_sleep(int when)
-{
-	struct list_head *list;
-	struct pmu_sleep_notifier *notifier;
-
-	for (list = sleep_notifiers.prev; list != &sleep_notifiers;
-	     list = list->prev) {
-		notifier = list_entry(list, struct pmu_sleep_notifier, list);
-		notifier->notifier_call(notifier, when);
-	}
-}
-
-/* Wake is broadcast first-to-last */
-static void broadcast_wake(void)
-{
-	struct list_head *list;
-	struct pmu_sleep_notifier *notifier;
-
-	for (list = sleep_notifiers.next; list != &sleep_notifiers;
-	     list = list->next) {
-		notifier = list_entry(list, struct pmu_sleep_notifier, list);
-		notifier->notifier_call(notifier, PBOOK_WAKE);
-	}
-}
-
 /*
  * This struct is used to store config register values for
  * PCI devices which may get powered off when we sleep.
@@ -2406,10 +2345,6 @@ pmu_release(struct inode *inode, struct 
 #if defined(CONFIG_PM) && defined(CONFIG_PPC32)
 static int powerbook_prepare_sleep(suspend_state_t state)
 {
-	/* Notify old-style device drivers */
-	broadcast_sleep(PBOOK_SLEEP_REQUEST);
-	broadcast_sleep(PBOOK_SLEEP_NOW);
-
 #ifdef CONFIG_PMAC_BACKLIGHT
 	/* Tell backlight code not to muck around with the chip anymore */
 	pmu_backlight_set_sleep(1);
@@ -2491,9 +2426,6 @@ static int powerbook_finish_sleep(suspen
 	pmac_pfunc_base_resume();
 	pmac_pfunc_i2c_resume();
 
-	/* Notify old style drivers */
-	broadcast_wake();
-
 	return 0;
 }
 
include/linux/pmu.h +0 -36
@@ -159,42 +159,6 @@ extern void pmu_unlock(void);
 extern int pmu_present(void);
 extern int pmu_get_model(void);
 
-#ifdef CONFIG_PM
-/*
- * Stuff for putting the powerbook to sleep and waking it again.
- *
- */
-#include <linux/list.h>
-
-struct pmu_sleep_notifier
-{
-	void (*notifier_call)(struct pmu_sleep_notifier *self, int when);
-	int priority;
-	struct list_head list;
-};
-
-/* Code values for calling sleep/wakeup handlers
- */
-#define PBOOK_SLEEP_REQUEST	1
-#define PBOOK_SLEEP_NOW		2
-#define PBOOK_WAKE		3
-
-/* priority levels in notifiers */
-#define SLEEP_LEVEL_VIDEO	100	/* Video driver (first wake) */
-#define SLEEP_LEVEL_MEDIABAY	90	/* Media bay driver */
-#define SLEEP_LEVEL_BLOCK	80	/* IDE, SCSI */
-#define SLEEP_LEVEL_NET		70	/* bmac, gmac */
-#define SLEEP_LEVEL_MISC	60	/* Anything else */
-#define SLEEP_LEVEL_USERLAND	55	/* Reserved for apm_emu */
-#define SLEEP_LEVEL_ADB		50	/* ADB (async) */
-#define SLEEP_LEVEL_SOUND	40	/* Sound driver (blocking) */
-
-/* special register notifier functions */
-int pmu_register_sleep_notifier(struct pmu_sleep_notifier* notifier);
-int pmu_unregister_sleep_notifier(struct pmu_sleep_notifier* notifier);
-
-#endif /* CONFIG_PM */
-
 #define PMU_MAX_BATTERIES	2
 
 /* values for pmu_power_flags */

--

#14 lore raw
In reply to Johannes Berg
Quoted 2 lines · Johannes Berg

This patch series gets rid of the various pmu sleep notifier users by various means.

Forgot to mention, the time suspend patch is required for this since it kills off another user.

johannes