diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 11:17:08 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:28:44 -0500 |
commit | 5e12bea0833e47117c31f13b528e31dc8112de57 (patch) | |
tree | d0e35b6a75cf3605d4e4a64f380d5b46a7eff393 /sound/ppc/powermac.c | |
parent | e4f163d96080dda40fd02df725f3672d035e4c5a (diff) |
[ALSA] powermac - Use platform_device
Modules: PPC,PPC PMAC driver,PPC PowerMac driver
Rewrite the probe/remove with platform_device.
Move the PM support to platform_device's callbacks.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/ppc/powermac.c')
-rw-r--r-- | sound/ppc/powermac.c | 67 |
1 files changed, 51 insertions, 16 deletions
diff --git a/sound/ppc/powermac.c b/sound/ppc/powermac.c index db139cdee28b..efa06fe5f01b 100644 --- a/sound/ppc/powermac.c +++ b/sound/ppc/powermac.c | |||
@@ -20,6 +20,8 @@ | |||
20 | 20 | ||
21 | #include <sound/driver.h> | 21 | #include <sound/driver.h> |
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/err.h> | ||
24 | #include <linux/platform_device.h> | ||
23 | #include <linux/moduleparam.h> | 25 | #include <linux/moduleparam.h> |
24 | #include <sound/core.h> | 26 | #include <sound/core.h> |
25 | #include <sound/initval.h> | 27 | #include <sound/initval.h> |
@@ -46,15 +48,9 @@ MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); | |||
46 | 48 | ||
47 | 49 | ||
48 | /* | 50 | /* |
49 | * card entry | ||
50 | */ | 51 | */ |
51 | 52 | ||
52 | static struct snd_card *snd_pmac_card = NULL; | 53 | static int __init snd_pmac_probe(struct platform_device *devptr) |
53 | |||
54 | /* | ||
55 | */ | ||
56 | |||
57 | static int __init snd_pmac_probe(void) | ||
58 | { | 54 | { |
59 | struct snd_card *card; | 55 | struct snd_card *card; |
60 | struct snd_pmac *chip; | 56 | struct snd_pmac *chip; |
@@ -67,6 +63,7 @@ static int __init snd_pmac_probe(void) | |||
67 | 63 | ||
68 | if ((err = snd_pmac_new(card, &chip)) < 0) | 64 | if ((err = snd_pmac_new(card, &chip)) < 0) |
69 | goto __error; | 65 | goto __error; |
66 | card->private_data = chip; | ||
70 | 67 | ||
71 | switch (chip->model) { | 68 | switch (chip->model) { |
72 | case PMAC_BURGUNDY: | 69 | case PMAC_BURGUNDY: |
@@ -131,13 +128,12 @@ static int __init snd_pmac_probe(void) | |||
131 | if (enable_beep) | 128 | if (enable_beep) |
132 | snd_pmac_attach_beep(chip); | 129 | snd_pmac_attach_beep(chip); |
133 | 130 | ||
134 | if ((err = snd_card_set_generic_dev(card)) < 0) | 131 | snd_card_set_dev(card, &devptr->dev); |
135 | goto __error; | ||
136 | 132 | ||
137 | if ((err = snd_card_register(card)) < 0) | 133 | if ((err = snd_card_register(card)) < 0) |
138 | goto __error; | 134 | goto __error; |
139 | 135 | ||
140 | snd_pmac_card = card; | 136 | platform_set_drvdata(devptr, card); |
141 | return 0; | 137 | return 0; |
142 | 138 | ||
143 | __error: | 139 | __error: |
@@ -146,23 +142,62 @@ __error: | |||
146 | } | 142 | } |
147 | 143 | ||
148 | 144 | ||
149 | /* | 145 | static int __devexit snd_pmac_remove(struct platform_device *devptr) |
150 | * MODULE stuff | 146 | { |
151 | */ | 147 | snd_card_free(platform_get_drvdata(devptr)); |
148 | platform_set_drvdata(devptr, NULL); | ||
149 | return 0; | ||
150 | } | ||
151 | |||
152 | #ifdef CONFIG_PM | ||
153 | static int snd_pmac_driver_suspend(struct platform_device *devptr, pm_message_t state) | ||
154 | { | ||
155 | struct snd_card *card = platform_get_drvdata(devptr); | ||
156 | snd_pmac_suspend(card->private_data); | ||
157 | return 0; | ||
158 | } | ||
159 | |||
160 | static int snd_pmac_driver_resume(struct platform_device *devptr) | ||
161 | { | ||
162 | struct snd_card *card = platform_get_drvdata(devptr); | ||
163 | snd_pmac_resume(card->private_data); | ||
164 | return 0; | ||
165 | } | ||
166 | #endif | ||
167 | |||
168 | #define SND_PMAC_DRIVER "snd_powermac" | ||
169 | |||
170 | static struct platform_driver snd_pmac_driver = { | ||
171 | .probe = snd_pmac_probe, | ||
172 | .remove = __devexit_p(snd_pmac_remove), | ||
173 | #ifdef CONFIG_PM | ||
174 | .suspend = snd_pmac_driver_suspend, | ||
175 | .resume = snd_pmac_driver_resume, | ||
176 | #endif | ||
177 | .driver = { | ||
178 | .name = SND_PMAC_DRIVER | ||
179 | }, | ||
180 | }; | ||
152 | 181 | ||
153 | static int __init alsa_card_pmac_init(void) | 182 | static int __init alsa_card_pmac_init(void) |
154 | { | 183 | { |
155 | int err; | 184 | int err; |
156 | if ((err = snd_pmac_probe()) < 0) | 185 | struct platform_device *device; |
186 | |||
187 | if ((err = platform_driver_register(&snd_pmac_driver)) < 0) | ||
157 | return err; | 188 | return err; |
189 | device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0); | ||
190 | if (IS_ERR(device)) { | ||
191 | platform_driver_unregister(&snd_pmac_driver); | ||
192 | return PTR_ERR(device); | ||
193 | } | ||
158 | return 0; | 194 | return 0; |
159 | 195 | ||
160 | } | 196 | } |
161 | 197 | ||
162 | static void __exit alsa_card_pmac_exit(void) | 198 | static void __exit alsa_card_pmac_exit(void) |
163 | { | 199 | { |
164 | if (snd_pmac_card) | 200 | platform_driver_unregister(&snd_pmac_driver); |
165 | snd_card_free(snd_pmac_card); | ||
166 | } | 201 | } |
167 | 202 | ||
168 | module_init(alsa_card_pmac_init) | 203 | module_init(alsa_card_pmac_init) |