* [PATCH 1/5] adb: replace sleep notifier with sysdev
2007-03-19 18:18 [PATCH 0/5] sleep notifier cleanup Johannes Berg
@ 2007-03-19 18:18 ` Johannes Berg
2007-03-20 0:15 ` [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks Johannes Berg
2007-03-19 18:18 ` [PATCH 2/5] apm_emu: use generic apm-emulation Johannes Berg
` (4 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Johannes Berg @ 2007-03-19 18:18 UTC (permalink / raw)
To: linuxppc-dev
This patch replaces the pmu sleep notifier that adb had with a proper
sysdevice.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/macintosh/adb.c | 89 ++++++++++++++++++++++++++----------------------
1 file changed, 50 insertions(+), 39 deletions(-)
--- linux-2.6.orig/drivers/macintosh/adb.c 2007-03-19 19:15:06.553321419 +0100
+++ linux-2.6/drivers/macintosh/adb.c 2007-03-19 19:15:08.613321419 +0100
@@ -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)
{
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks
2007-03-19 18:18 ` [PATCH 1/5] adb: replace sleep notifier with sysdev Johannes Berg
@ 2007-03-20 0:15 ` Johannes Berg
2007-04-04 8:41 ` Johannes Berg
0 siblings, 1 reply; 15+ messages in thread
From: Johannes Berg @ 2007-03-20 0:15 UTC (permalink / raw)
To: linuxppc-dev
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.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
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(-)
--- linux-2.6.orig/drivers/macintosh/adb.c 2007-03-20 00:46:44.676994679 +0100
+++ linux-2.6/drivers/macintosh/adb.c 2007-03-20 01:14:31.200043284 +0100
@@ -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");
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks
2007-03-20 0:15 ` [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks Johannes Berg
@ 2007-04-04 8:41 ` Johannes Berg
2007-04-04 13:03 ` David Woodhouse
2007-04-04 13:37 ` [PATCH 1/5 v3] adb: replace sleep notifier with platform driver " Johannes Berg
0 siblings, 2 replies; 15+ messages in thread
From: Johannes Berg @ 2007-04-04 8:41 UTC (permalink / raw)
To: linuxppc-dev; +Cc: David Woodhouse
[-- Attachment #1: Type: text/plain, Size: 595 bytes --]
> 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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks
2007-04-04 8:41 ` Johannes Berg
@ 2007-04-04 13:03 ` David Woodhouse
2007-04-04 17:07 ` Johannes Berg
2007-04-04 23:12 ` Benjamin Herrenschmidt
2007-04-04 13:37 ` [PATCH 1/5 v3] adb: replace sleep notifier with platform driver " Johannes Berg
1 sibling, 2 replies; 15+ messages in thread
From: David Woodhouse @ 2007-04-04 13:03 UTC (permalink / raw)
To: Johannes Berg; +Cc: linuxppc-dev
On Wed, 2007-04-04 at 10:41 +0200, Johannes Berg wrote:
>
> 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.
--
dwmw2
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks
2007-04-04 13:03 ` David Woodhouse
@ 2007-04-04 17:07 ` Johannes Berg
2007-04-04 21:20 ` David Woodhouse
2007-04-04 23:12 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 15+ messages in thread
From: Johannes Berg @ 2007-04-04 17:07 UTC (permalink / raw)
To: David Woodhouse; +Cc: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 1131 bytes --]
On Wed, 2007-04-04 at 09:03 -0400, David Woodhouse wrote:
> I didn't have this set of patches applied. I have these:
Ok.
> 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.
> 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.
> 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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks
2007-04-04 17:07 ` Johannes Berg
@ 2007-04-04 21:20 ` David Woodhouse
2007-04-04 21:48 ` Johannes Berg
0 siblings, 1 reply; 15+ messages in thread
From: David Woodhouse @ 2007-04-04 21:20 UTC (permalink / raw)
To: Johannes Berg; +Cc: linuxppc-dev
On Wed, 2007-04-04 at 19:07 +0200, Johannes Berg wrote:
> 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.
> > 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.
>
> > 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...
--
dwmw2
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks
2007-04-04 21:20 ` David Woodhouse
@ 2007-04-04 21:48 ` Johannes Berg
0 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2007-04-04 21:48 UTC (permalink / raw)
To: David Woodhouse; +Cc: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]
On Wed, 2007-04-04 at 17:20 -0400, David Woodhouse wrote:
> 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").
> $ 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...
Right. I really haven't got a clue what this may cause. I'm trying to
find something but haven't so far.
johannes
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/5 v2] adb: replace sleep notifier with class suspend/resume hooks
2007-04-04 13:03 ` David Woodhouse
2007-04-04 17:07 ` Johannes Berg
@ 2007-04-04 23:12 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 15+ messages in thread
From: Benjamin Herrenschmidt @ 2007-04-04 23:12 UTC (permalink / raw)
To: David Woodhouse; +Cc: linuxppc-dev, Johannes Berg
On Wed, 2007-04-04 at 09:03 -0400, David Woodhouse wrote:
> On Wed, 2007-04-04 at 10:41 +0200, Johannes Berg wrote:
> >
> > 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.
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.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/5 v3] adb: replace sleep notifier with platform driver suspend/resume hooks
2007-04-04 8:41 ` Johannes Berg
2007-04-04 13:03 ` David Woodhouse
@ 2007-04-04 13:37 ` Johannes Berg
1 sibling, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2007-04-04 13:37 UTC (permalink / raw)
To: linuxppc-dev; +Cc: David Woodhouse
This patch replaces the pmu sleep notifier that adb had with
suspend/resume hooks in a new platform driver/device.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
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(-)
--- wireless-dev.orig/drivers/macintosh/adb.c 2007-04-04 14:01:41.044706154 +0200
+++ wireless-dev/drivers/macintosh/adb.c 2007-04-04 15:34:02.998565695 +0200
@@ -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);
}
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 2/5] apm_emu: use generic apm-emulation
2007-03-19 18:18 [PATCH 0/5] sleep notifier cleanup Johannes Berg
2007-03-19 18:18 ` [PATCH 1/5] adb: replace sleep notifier with sysdev Johannes Berg
@ 2007-03-19 18:18 ` Johannes Berg
2007-03-19 18:18 ` [PATCH 3/5] via-pmu: remove LED sleep notifier Johannes Berg
` (3 subsequent siblings)
5 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2007-03-19 18:18 UTC (permalink / raw)
To: linuxppc-dev
This patch removes a huge amount of code that is now in common code
in drivers/char/apm-emulation.c
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/Kconfig | 3
drivers/macintosh/Kconfig | 4
drivers/macintosh/apm_emu.c | 521 +++-----------------------------------------
3 files changed, 50 insertions(+), 478 deletions(-)
--- linux-2.6.orig/drivers/macintosh/Kconfig 2007-03-19 19:14:54.173321419 +0100
+++ linux-2.6/drivers/macintosh/Kconfig 2007-03-19 19:15:09.183321419 +0100
@@ -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"
--- linux-2.6.orig/drivers/macintosh/apm_emu.c 2007-03-19 19:15:06.563321419 +0100
+++ linux-2.6/drivers/macintosh/apm_emu.c 2007-03-19 19:15:09.183321419 +0100
@@ -1,9 +1,7 @@
-/* APM emulation layer for PowerMac
- *
- * Copyright 2001 Benjamin Herrenschmidt (benh@kernel.crashing.org)
+/*
+ * APM emulation for PMU-based machines
*
- * Lots of code inherited from apm.c, see appropriate notice in
- * arch/i386/kernel/apm.c
+ * Copyright 2001 Benjamin Herrenschmidt (benh@kernel.crashing.org)
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -18,429 +16,39 @@
*
*/
-#include <linux/module.h>
-
-#include <linux/poll.h>
-#include <linux/types.h>
-#include <linux/stddef.h>
-#include <linux/timer.h>
-#include <linux/fcntl.h>
-#include <linux/slab.h>
-#include <linux/stat.h>
-#include <linux/proc_fs.h>
-#include <linux/miscdevice.h>
-#include <linux/apm_bios.h>
-#include <linux/init.h>
-#include <linux/sched.h>
-#include <linux/pm.h>
#include <linux/kernel.h>
-#include <linux/smp_lock.h>
-
+#include <linux/module.h>
+#include <linux/apm-emulation.h>
#include <linux/adb.h>
#include <linux/pmu.h>
-#include <asm/system.h>
-#include <asm/uaccess.h>
-#include <asm/machdep.h>
-
-#undef DEBUG
-
-#ifdef DEBUG
-#define DBG(args...) printk(KERN_DEBUG args)
-//#define DBG(args...) xmon_printf(args)
-#else
-#define DBG(args...) do { } while (0)
-#endif
-
-/*
- * The apm_bios device is one of the misc char devices.
- * This is its minor number.
- */
-#define APM_MINOR_DEV 134
-
-/*
- * Maximum number of events stored
- */
-#define APM_MAX_EVENTS 20
-
-#define FAKE_APM_BIOS_VERSION 0x0101
-
-#define APM_USER_NOTIFY_TIMEOUT (5*HZ)
-
-/*
- * The per-file APM data
- */
-struct apm_user {
- int magic;
- struct apm_user * next;
- int suser: 1;
- int suspend_waiting: 1;
- int suspends_pending;
- int suspends_read;
- int event_head;
- int event_tail;
- apm_event_t events[APM_MAX_EVENTS];
-};
-
-/*
- * The magic number in apm_user
- */
-#define APM_BIOS_MAGIC 0x4101
-
-/*
- * Local variables
- */
-static int suspends_pending;
-
-static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue);
-static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue);
-static struct apm_user * user_list;
-
-static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when);
-static struct pmu_sleep_notifier apm_sleep_notifier = {
- apm_notify_sleep,
- SLEEP_LEVEL_USERLAND,
-};
-
-static const char driver_version[] = "0.5"; /* no spaces */
-
-#ifdef DEBUG
-static char * apm_event_name[] = {
- "system standby",
- "system suspend",
- "normal resume",
- "critical resume",
- "low battery",
- "power status change",
- "update time",
- "critical suspend",
- "user standby",
- "user suspend",
- "system standby resume",
- "capabilities change"
-};
-#define NR_APM_EVENT_NAME \
- (sizeof(apm_event_name) / sizeof(apm_event_name[0]))
-
-#endif
-
-static int queue_empty(struct apm_user *as)
-{
- return as->event_head == as->event_tail;
-}
-
-static apm_event_t get_queued_event(struct apm_user *as)
-{
- as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
- return as->events[as->event_tail];
-}
-
-static void queue_event(apm_event_t event, struct apm_user *sender)
-{
- struct apm_user * as;
-
- DBG("apm_emu: queue_event(%s)\n", apm_event_name[event-1]);
- if (user_list == NULL)
- return;
- for (as = user_list; as != NULL; as = as->next) {
- if (as == sender)
- continue;
- as->event_head = (as->event_head + 1) % APM_MAX_EVENTS;
- if (as->event_head == as->event_tail) {
- static int notified;
-
- if (notified++ == 0)
- printk(KERN_ERR "apm_emu: an event queue overflowed\n");
- as->event_tail = (as->event_tail + 1) % APM_MAX_EVENTS;
- }
- as->events[as->event_head] = event;
- if (!as->suser)
- continue;
- switch (event) {
- case APM_SYS_SUSPEND:
- case APM_USER_SUSPEND:
- as->suspends_pending++;
- suspends_pending++;
- break;
- case APM_NORMAL_RESUME:
- as->suspend_waiting = 0;
- break;
- }
- }
- wake_up_interruptible(&apm_waitqueue);
-}
-
-static int check_apm_user(struct apm_user *as, const char *func)
-{
- if ((as == NULL) || (as->magic != APM_BIOS_MAGIC)) {
- printk(KERN_ERR "apm_emu: %s passed bad filp\n", func);
- return 1;
- }
- return 0;
-}
-
-static ssize_t do_read(struct file *fp, char __user *buf, size_t count, loff_t *ppos)
-{
- struct apm_user * as;
- size_t i;
- apm_event_t event;
- DECLARE_WAITQUEUE(wait, current);
-
- as = fp->private_data;
- if (check_apm_user(as, "read"))
- return -EIO;
- if (count < sizeof(apm_event_t))
- return -EINVAL;
- if (queue_empty(as)) {
- if (fp->f_flags & O_NONBLOCK)
- return -EAGAIN;
- add_wait_queue(&apm_waitqueue, &wait);
-repeat:
- set_current_state(TASK_INTERRUPTIBLE);
- if (queue_empty(as) && !signal_pending(current)) {
- schedule();
- goto repeat;
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&apm_waitqueue, &wait);
- }
- i = count;
- while ((i >= sizeof(event)) && !queue_empty(as)) {
- event = get_queued_event(as);
- DBG("apm_emu: do_read, returning: %s\n", apm_event_name[event-1]);
- if (copy_to_user(buf, &event, sizeof(event))) {
- if (i < count)
- break;
- return -EFAULT;
- }
- switch (event) {
- case APM_SYS_SUSPEND:
- case APM_USER_SUSPEND:
- as->suspends_read++;
- break;
- }
- buf += sizeof(event);
- i -= sizeof(event);
- }
- if (i < count)
- return count - i;
- if (signal_pending(current))
- return -ERESTARTSYS;
- return 0;
-}
-
-static unsigned int do_poll(struct file *fp, poll_table * wait)
-{
- struct apm_user * as;
-
- as = fp->private_data;
- if (check_apm_user(as, "poll"))
- return 0;
- poll_wait(fp, &apm_waitqueue, wait);
- if (!queue_empty(as))
- return POLLIN | POLLRDNORM;
- return 0;
-}
-
-static int do_ioctl(struct inode * inode, struct file *filp,
- u_int cmd, u_long arg)
-{
- struct apm_user * as;
- DECLARE_WAITQUEUE(wait, current);
-
- as = filp->private_data;
- if (check_apm_user(as, "ioctl"))
- return -EIO;
- if (!as->suser)
- return -EPERM;
- switch (cmd) {
- case APM_IOC_SUSPEND:
- /* If a suspend message was sent to userland, we
- * consider this as a confirmation message
- */
- if (as->suspends_read > 0) {
- as->suspends_read--;
- as->suspends_pending--;
- suspends_pending--;
- } else {
- // Route to PMU suspend ?
- break;
- }
- as->suspend_waiting = 1;
- add_wait_queue(&apm_waitqueue, &wait);
- DBG("apm_emu: ioctl waking up sleep waiter !\n");
- wake_up(&apm_suspend_waitqueue);
- mb();
- while(as->suspend_waiting && !signal_pending(current)) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule();
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&apm_waitqueue, &wait);
- break;
- default:
- return -EINVAL;
- }
- return 0;
-}
-
-static int do_release(struct inode * inode, struct file * filp)
-{
- struct apm_user * as;
-
- as = filp->private_data;
- if (check_apm_user(as, "release"))
- return 0;
- filp->private_data = NULL;
- lock_kernel();
- if (as->suspends_pending > 0) {
- suspends_pending -= as->suspends_pending;
- if (suspends_pending <= 0)
- wake_up(&apm_suspend_waitqueue);
- }
- if (user_list == as)
- user_list = as->next;
- else {
- struct apm_user * as1;
-
- for (as1 = user_list;
- (as1 != NULL) && (as1->next != as);
- as1 = as1->next)
- ;
- if (as1 == NULL)
- printk(KERN_ERR "apm: filp not in user list\n");
- else
- as1->next = as->next;
- }
- unlock_kernel();
- kfree(as);
- return 0;
-}
-
-static int do_open(struct inode * inode, struct file * filp)
-{
- struct apm_user * as;
-
- as = kmalloc(sizeof(*as), GFP_KERNEL);
- if (as == NULL) {
- printk(KERN_ERR "apm: cannot allocate struct of size %d bytes\n",
- sizeof(*as));
- return -ENOMEM;
- }
- as->magic = APM_BIOS_MAGIC;
- as->event_tail = as->event_head = 0;
- as->suspends_pending = 0;
- as->suspends_read = 0;
- /*
- * XXX - this is a tiny bit broken, when we consider BSD
- * process accounting. If the device is opened by root, we
- * instantly flag that we used superuser privs. Who knows,
- * we might close the device immediately without doing a
- * privileged operation -- cevans
- */
- as->suser = capable(CAP_SYS_ADMIN);
- as->next = user_list;
- user_list = as;
- filp->private_data = as;
-
- DBG("apm_emu: opened by %s, suser: %d\n", current->comm, (int)as->suser);
-
- return 0;
-}
-
-/* Wait for all clients to ack the suspend request. APM API
- * doesn't provide a way to NAK, but this could be added
- * here.
- */
-static void wait_all_suspend(void)
-{
- DECLARE_WAITQUEUE(wait, current);
-
- add_wait_queue(&apm_suspend_waitqueue, &wait);
- DBG("apm_emu: wait_all_suspend(), suspends_pending: %d\n", suspends_pending);
- while(suspends_pending > 0) {
- set_current_state(TASK_UNINTERRUPTIBLE);
- schedule();
- }
- set_current_state(TASK_RUNNING);
- remove_wait_queue(&apm_suspend_waitqueue, &wait);
-
- DBG("apm_emu: wait_all_suspend() - complete !\n");
-}
-
-static void apm_notify_sleep(struct pmu_sleep_notifier *self, int when)
-{
- switch(when) {
- case PBOOK_SLEEP_REQUEST:
- queue_event(APM_SYS_SUSPEND, NULL);
- wait_all_suspend();
- break;
- case PBOOK_WAKE:
- queue_event(APM_NORMAL_RESUME, NULL);
- break;
- }
-}
-
#define APM_CRITICAL 10
#define APM_LOW 30
-static int apm_emu_get_info(char *buf, char **start, off_t fpos, int length)
+static void pmu_apm_get_power_status(struct apm_power_info *info)
{
- /* Arguments, with symbols from linux/apm_bios.h. Information is
- from the Get Power Status (0x0a) call unless otherwise noted.
-
- 0) Linux driver version (this will change if format changes)
- 1) APM BIOS Version. Usually 1.0, 1.1 or 1.2.
- 2) APM flags from APM Installation Check (0x00):
- bit 0: APM_16_BIT_SUPPORT
- bit 1: APM_32_BIT_SUPPORT
- bit 2: APM_IDLE_SLOWS_CLOCK
- bit 3: APM_BIOS_DISABLED
- bit 4: APM_BIOS_DISENGAGED
- 3) AC line status
- 0x00: Off-line
- 0x01: On-line
- 0x02: On backup power (BIOS >= 1.1 only)
- 0xff: Unknown
- 4) Battery status
- 0x00: High
- 0x01: Low
- 0x02: Critical
- 0x03: Charging
- 0x04: Selected battery not present (BIOS >= 1.2 only)
- 0xff: Unknown
- 5) Battery flag
- bit 0: High
- bit 1: Low
- bit 2: Critical
- bit 3: Charging
- bit 7: No system battery
- 0xff: Unknown
- 6) Remaining battery life (percentage of charge):
- 0-100: valid
- -1: Unknown
- 7) Remaining battery life (time units):
- Number of remaining minutes or seconds
- -1: Unknown
- 8) min = minutes; sec = seconds */
-
- unsigned short ac_line_status;
- unsigned short battery_status = 0;
- unsigned short battery_flag = 0xff;
- int percentage = -1;
- int time_units = -1;
- int real_count = 0;
- int i;
- char * p = buf;
- char charging = 0;
- long charge = -1;
- long amperage = 0;
- unsigned long btype = 0;
+ int percentage = -1;
+ int batteries = 0;
+ int time_units = -1;
+ int real_count = 0;
+ int i;
+ char charging = 0;
+ long charge = -1;
+ long amperage = 0;
+ unsigned long btype = 0;
+
+ info->battery_status = APM_BATTERY_STATUS_UNKNOWN;
+ info->battery_flag = APM_BATTERY_FLAG_UNKNOWN;
+ info->units = APM_UNITS_MINS;
+
+ if (pmu_power_flags & PMU_PWR_AC_PRESENT)
+ info->ac_line_status = APM_AC_ONLINE;
+ else
+ info->ac_line_status = APM_AC_OFFLINE;
- ac_line_status = ((pmu_power_flags & PMU_PWR_AC_PRESENT) != 0);
for (i=0; i<pmu_battery_count; i++) {
if (pmu_batteries[i].flags & PMU_BATT_PRESENT) {
- battery_status++;
+ batteries++;
if (percentage < 0)
percentage = 0;
if (charge < 0)
@@ -456,9 +64,9 @@ static int apm_emu_get_info(char *buf, c
charging++;
}
}
- if (0 == battery_status)
- ac_line_status = 1;
- battery_status = 0xff;
+ if (batteries == 0)
+ info->ac_line_status = APM_AC_ONLINE;
+
if (real_count) {
if (amperage < 0) {
if (btype == PMU_BATT_TYPE_SMART)
@@ -468,85 +76,44 @@ static int apm_emu_get_info(char *buf, c
}
percentage /= real_count;
if (charging > 0) {
- battery_status = 0x03;
- battery_flag = 0x08;
+ info->battery_status = APM_BATTERY_STATUS_CHARGING;
+ info->battery_flag = APM_BATTERY_FLAG_CHARGING;
} else if (percentage <= APM_CRITICAL) {
- battery_status = 0x02;
- battery_flag = 0x04;
+ info->battery_status = APM_BATTERY_STATUS_CRITICAL;
+ info->battery_flag = APM_BATTERY_FLAG_CRITICAL;
} else if (percentage <= APM_LOW) {
- battery_status = 0x01;
- battery_flag = 0x02;
+ info->battery_status = APM_BATTERY_STATUS_LOW;
+ info->battery_flag = APM_BATTERY_FLAG_LOW;
} else {
- battery_status = 0x00;
- battery_flag = 0x01;
+ info->battery_status = APM_BATTERY_STATUS_HIGH;
+ info->battery_flag = APM_BATTERY_FLAG_HIGH;
}
}
- p += sprintf(p, "%s %d.%d 0x%02x 0x%02x 0x%02x 0x%02x %d%% %d %s\n",
- driver_version,
- (FAKE_APM_BIOS_VERSION >> 8) & 0xff,
- FAKE_APM_BIOS_VERSION & 0xff,
- 0,
- ac_line_status,
- battery_status,
- battery_flag,
- percentage,
- time_units,
- "min");
- return p - buf;
+ info->battery_life = percentage;
+ info->time = time_units;
}
-static const struct file_operations apm_bios_fops = {
- .owner = THIS_MODULE,
- .read = do_read,
- .poll = do_poll,
- .ioctl = do_ioctl,
- .open = do_open,
- .release = do_release,
-};
-
-static struct miscdevice apm_device = {
- APM_MINOR_DEV,
- "apm_bios",
- &apm_bios_fops
-};
-
static int __init apm_emu_init(void)
{
- struct proc_dir_entry *apm_proc;
-
- if (sys_ctrler != SYS_CTRLER_PMU) {
- printk(KERN_INFO "apm_emu: Requires a machine with a PMU.\n");
- return -ENODEV;
- }
-
- apm_proc = create_proc_info_entry("apm", 0, NULL, apm_emu_get_info);
- if (apm_proc)
- apm_proc->owner = THIS_MODULE;
+ apm_get_power_status = pmu_apm_get_power_status;
- if (misc_register(&apm_device) != 0)
- printk(KERN_INFO "Could not create misc. device for apm\n");
-
- pmu_register_sleep_notifier(&apm_sleep_notifier);
-
- printk(KERN_INFO "apm_emu: APM Emulation %s initialized.\n", driver_version);
+ printk(KERN_INFO "apm_emu: PMU APM Emulation initialized.\n");
return 0;
}
static void __exit apm_emu_exit(void)
{
- pmu_unregister_sleep_notifier(&apm_sleep_notifier);
- misc_deregister(&apm_device);
- remove_proc_entry("apm", NULL);
+ if (apm_get_power_status == pmu_apm_get_power_status)
+ apm_get_power_status = NULL;
- printk(KERN_INFO "apm_emu: APM Emulation removed.\n");
+ printk(KERN_INFO "apm_emu: PMU APM Emulation removed.\n");
}
module_init(apm_emu_init);
module_exit(apm_emu_exit);
MODULE_AUTHOR("Benjamin Herrenschmidt");
-MODULE_DESCRIPTION("APM emulation layer for PowerMac");
+MODULE_DESCRIPTION("APM emulation for PowerMac");
MODULE_LICENSE("GPL");
-
--- linux-2.6.orig/arch/powerpc/Kconfig 2007-03-19 19:15:04.233321419 +0100
+++ linux-2.6/arch/powerpc/Kconfig 2007-03-19 19:15:09.223321419 +0100
@@ -117,6 +117,9 @@ config GENERIC_BUG
default y
depends on BUG
+config SYS_SUPPORTS_APM_EMULATION
+ bool
+
config DEFAULT_UIMAGE
bool
help
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 3/5] via-pmu: remove LED sleep notifier
2007-03-19 18:18 [PATCH 0/5] sleep notifier cleanup Johannes Berg
2007-03-19 18:18 ` [PATCH 1/5] adb: replace sleep notifier with sysdev Johannes Berg
2007-03-19 18:18 ` [PATCH 2/5] apm_emu: use generic apm-emulation Johannes Berg
@ 2007-03-19 18:18 ` Johannes Berg
2007-03-19 18:18 ` [PATCH 4/5] remove awacs dmasound Johannes Berg
` (2 subsequent siblings)
5 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2007-03-19 18:18 UTC (permalink / raw)
To: linuxppc-dev
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.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/macintosh/via-pmu-led.c | 37 +++++--------------------------------
drivers/macintosh/via-pmu.c | 2 +-
2 files changed, 6 insertions(+), 33 deletions(-)
--- linux-2.6.orig/drivers/macintosh/via-pmu-led.c 2007-03-19 19:15:06.563321419 +0100
+++ linux-2.6/drivers/macintosh/via-pmu-led.c 2007-03-19 19:32:30.813321419 +0100
@@ -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);
}
--- linux-2.6.orig/drivers/macintosh/via-pmu.c 2007-03-19 19:27:38.293321419 +0100
+++ linux-2.6/drivers/macintosh/via-pmu.c 2007-03-19 19:32:04.053321419 +0100
@@ -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)
{
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 4/5] remove awacs dmasound
2007-03-19 18:18 [PATCH 0/5] sleep notifier cleanup Johannes Berg
` (2 preceding siblings ...)
2007-03-19 18:18 ` [PATCH 3/5] via-pmu: remove LED sleep notifier Johannes Berg
@ 2007-03-19 18:18 ` Johannes Berg
2007-03-19 18:18 ` [PATCH 5/5] via-pmu: kill sleep notifiers completely Johannes Berg
2007-03-19 18:44 ` [PATCH 0/5] sleep notifier cleanup Johannes Berg
5 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2007-03-19 18:18 UTC (permalink / raw)
To: linuxppc-dev; +Cc: Adrian Bunk
This patch kills the obsolete awacs dmasound because it is in
the way of doing power management improvements since it uses
ancient API.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Adrian Bunk <bunk@stusta.de>
---
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(-)
--- linux-2.6.orig/sound/oss/dmasound/Makefile 2007-03-19 19:14:52.773321419 +0100
+++ linux-2.6/sound/oss/dmasound/Makefile 2007-03-19 19:15:10.443321419 +0100
@@ -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
--- linux-2.6.orig/sound/oss/dmasound/Kconfig 2007-03-19 19:14:53.523321419 +0100
+++ linux-2.6/sound/oss/dmasound/Kconfig 2007-03-19 19:15:10.533321419 +0100
@@ -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
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 5/5] via-pmu: kill sleep notifiers completely
2007-03-19 18:18 [PATCH 0/5] sleep notifier cleanup Johannes Berg
` (3 preceding siblings ...)
2007-03-19 18:18 ` [PATCH 4/5] remove awacs dmasound Johannes Berg
@ 2007-03-19 18:18 ` Johannes Berg
2007-03-19 18:44 ` [PATCH 0/5] sleep notifier cleanup Johannes Berg
5 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2007-03-19 18:18 UTC (permalink / raw)
To: linuxppc-dev
This patch kills off the remnants of the ancient sleep notifiers.
Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
drivers/macintosh/via-pmu.c | 68 --------------------------------------------
include/linux/pmu.h | 36 -----------------------
2 files changed, 104 deletions(-)
--- linux-2.6.orig/drivers/macintosh/via-pmu.c 2007-03-19 19:32:04.053321419 +0100
+++ linux-2.6/drivers/macintosh/via-pmu.c 2007-03-19 19:34:16.793321419 +0100
@@ -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;
}
--- linux-2.6.orig/include/linux/pmu.h 2007-03-19 19:26:35.943321419 +0100
+++ linux-2.6/include/linux/pmu.h 2007-03-19 19:34:16.803321419 +0100
@@ -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 */
--
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 0/5] sleep notifier cleanup
2007-03-19 18:18 [PATCH 0/5] sleep notifier cleanup Johannes Berg
` (4 preceding siblings ...)
2007-03-19 18:18 ` [PATCH 5/5] via-pmu: kill sleep notifiers completely Johannes Berg
@ 2007-03-19 18:44 ` Johannes Berg
5 siblings, 0 replies; 15+ messages in thread
From: Johannes Berg @ 2007-03-19 18:44 UTC (permalink / raw)
To: linuxppc-dev
[-- Attachment #1: Type: text/plain, Size: 260 bytes --]
On Mon, 2007-03-19 at 19:18 +0100, Johannes Berg wrote:
> 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
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 190 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread