Commit 464ede3ce59ba6144ff117ffa6427cac77fc6807
Committed by
Takashi Iwai
1 parent
50c7d0da64
Exists in
smarc-imx_3.14.28_1.0.0_ga
and in
1 other branch
ALSA: powermac: Remove redundant platform_set_drvdata()
Commit 0998d06310 (device-core: Ensure drvdata = NULL when no driver is bound) removes the need to set driver data field to NULL. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 1 changed file with 0 additions and 1 deletions Inline Diff
sound/ppc/powermac.c
1 | /* | 1 | /* |
2 | * Driver for PowerMac AWACS | 2 | * Driver for PowerMac AWACS |
3 | * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de> | 3 | * Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de> |
4 | * based on dmasound.c. | 4 | * based on dmasound.c. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify | 6 | * This program is free software; you can redistribute it and/or modify |
7 | * it under the terms of the GNU General Public License as published by | 7 | * it under the terms of the GNU General Public License as published by |
8 | * the Free Software Foundation; either version 2 of the License, or | 8 | * the Free Software Foundation; either version 2 of the License, or |
9 | * (at your option) any later version. | 9 | * (at your option) any later version. |
10 | * | 10 | * |
11 | * This program is distributed in the hope that it will be useful, | 11 | * This program is distributed in the hope that it will be useful, |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | * GNU General Public License for more details. | 14 | * GNU General Public License for more details. |
15 | * | 15 | * |
16 | * You should have received a copy of the GNU General Public License | 16 | * You should have received a copy of the GNU General Public License |
17 | * along with this program; if not, write to the Free Software | 17 | * along with this program; if not, write to the Free Software |
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
19 | */ | 19 | */ |
20 | 20 | ||
21 | #include <linux/init.h> | 21 | #include <linux/init.h> |
22 | #include <linux/err.h> | 22 | #include <linux/err.h> |
23 | #include <linux/platform_device.h> | 23 | #include <linux/platform_device.h> |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <sound/core.h> | 25 | #include <sound/core.h> |
26 | #include <sound/initval.h> | 26 | #include <sound/initval.h> |
27 | #include "pmac.h" | 27 | #include "pmac.h" |
28 | #include "awacs.h" | 28 | #include "awacs.h" |
29 | #include "burgundy.h" | 29 | #include "burgundy.h" |
30 | 30 | ||
31 | #define CHIP_NAME "PMac" | 31 | #define CHIP_NAME "PMac" |
32 | 32 | ||
33 | MODULE_DESCRIPTION("PowerMac"); | 33 | MODULE_DESCRIPTION("PowerMac"); |
34 | MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}"); | 34 | MODULE_SUPPORTED_DEVICE("{{Apple,PowerMac}}"); |
35 | MODULE_LICENSE("GPL"); | 35 | MODULE_LICENSE("GPL"); |
36 | 36 | ||
37 | static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ | 37 | static int index = SNDRV_DEFAULT_IDX1; /* Index 0-MAX */ |
38 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ | 38 | static char *id = SNDRV_DEFAULT_STR1; /* ID for this card */ |
39 | static bool enable_beep = 1; | 39 | static bool enable_beep = 1; |
40 | 40 | ||
41 | module_param(index, int, 0444); | 41 | module_param(index, int, 0444); |
42 | MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip."); | 42 | MODULE_PARM_DESC(index, "Index value for " CHIP_NAME " soundchip."); |
43 | module_param(id, charp, 0444); | 43 | module_param(id, charp, 0444); |
44 | MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip."); | 44 | MODULE_PARM_DESC(id, "ID string for " CHIP_NAME " soundchip."); |
45 | module_param(enable_beep, bool, 0444); | 45 | module_param(enable_beep, bool, 0444); |
46 | MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); | 46 | MODULE_PARM_DESC(enable_beep, "Enable beep using PCM."); |
47 | 47 | ||
48 | static struct platform_device *device; | 48 | static struct platform_device *device; |
49 | 49 | ||
50 | 50 | ||
51 | /* | 51 | /* |
52 | */ | 52 | */ |
53 | 53 | ||
54 | static int snd_pmac_probe(struct platform_device *devptr) | 54 | static int snd_pmac_probe(struct platform_device *devptr) |
55 | { | 55 | { |
56 | struct snd_card *card; | 56 | struct snd_card *card; |
57 | struct snd_pmac *chip; | 57 | struct snd_pmac *chip; |
58 | char *name_ext; | 58 | char *name_ext; |
59 | int err; | 59 | int err; |
60 | 60 | ||
61 | err = snd_card_create(index, id, THIS_MODULE, 0, &card); | 61 | err = snd_card_create(index, id, THIS_MODULE, 0, &card); |
62 | if (err < 0) | 62 | if (err < 0) |
63 | return err; | 63 | return err; |
64 | 64 | ||
65 | if ((err = snd_pmac_new(card, &chip)) < 0) | 65 | if ((err = snd_pmac_new(card, &chip)) < 0) |
66 | goto __error; | 66 | goto __error; |
67 | card->private_data = chip; | 67 | card->private_data = chip; |
68 | 68 | ||
69 | switch (chip->model) { | 69 | switch (chip->model) { |
70 | case PMAC_BURGUNDY: | 70 | case PMAC_BURGUNDY: |
71 | strcpy(card->driver, "PMac Burgundy"); | 71 | strcpy(card->driver, "PMac Burgundy"); |
72 | strcpy(card->shortname, "PowerMac Burgundy"); | 72 | strcpy(card->shortname, "PowerMac Burgundy"); |
73 | sprintf(card->longname, "%s (Dev %d) Sub-frame %d", | 73 | sprintf(card->longname, "%s (Dev %d) Sub-frame %d", |
74 | card->shortname, chip->device_id, chip->subframe); | 74 | card->shortname, chip->device_id, chip->subframe); |
75 | if ((err = snd_pmac_burgundy_init(chip)) < 0) | 75 | if ((err = snd_pmac_burgundy_init(chip)) < 0) |
76 | goto __error; | 76 | goto __error; |
77 | break; | 77 | break; |
78 | case PMAC_DACA: | 78 | case PMAC_DACA: |
79 | strcpy(card->driver, "PMac DACA"); | 79 | strcpy(card->driver, "PMac DACA"); |
80 | strcpy(card->shortname, "PowerMac DACA"); | 80 | strcpy(card->shortname, "PowerMac DACA"); |
81 | sprintf(card->longname, "%s (Dev %d) Sub-frame %d", | 81 | sprintf(card->longname, "%s (Dev %d) Sub-frame %d", |
82 | card->shortname, chip->device_id, chip->subframe); | 82 | card->shortname, chip->device_id, chip->subframe); |
83 | if ((err = snd_pmac_daca_init(chip)) < 0) | 83 | if ((err = snd_pmac_daca_init(chip)) < 0) |
84 | goto __error; | 84 | goto __error; |
85 | break; | 85 | break; |
86 | case PMAC_TUMBLER: | 86 | case PMAC_TUMBLER: |
87 | case PMAC_SNAPPER: | 87 | case PMAC_SNAPPER: |
88 | name_ext = chip->model == PMAC_TUMBLER ? "Tumbler" : "Snapper"; | 88 | name_ext = chip->model == PMAC_TUMBLER ? "Tumbler" : "Snapper"; |
89 | sprintf(card->driver, "PMac %s", name_ext); | 89 | sprintf(card->driver, "PMac %s", name_ext); |
90 | sprintf(card->shortname, "PowerMac %s", name_ext); | 90 | sprintf(card->shortname, "PowerMac %s", name_ext); |
91 | sprintf(card->longname, "%s (Dev %d) Sub-frame %d", | 91 | sprintf(card->longname, "%s (Dev %d) Sub-frame %d", |
92 | card->shortname, chip->device_id, chip->subframe); | 92 | card->shortname, chip->device_id, chip->subframe); |
93 | if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0) | 93 | if ( snd_pmac_tumbler_init(chip) < 0 || snd_pmac_tumbler_post_init() < 0) |
94 | goto __error; | 94 | goto __error; |
95 | break; | 95 | break; |
96 | case PMAC_AWACS: | 96 | case PMAC_AWACS: |
97 | case PMAC_SCREAMER: | 97 | case PMAC_SCREAMER: |
98 | name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS"; | 98 | name_ext = chip->model == PMAC_SCREAMER ? "Screamer" : "AWACS"; |
99 | sprintf(card->driver, "PMac %s", name_ext); | 99 | sprintf(card->driver, "PMac %s", name_ext); |
100 | sprintf(card->shortname, "PowerMac %s", name_ext); | 100 | sprintf(card->shortname, "PowerMac %s", name_ext); |
101 | if (chip->is_pbook_3400) | 101 | if (chip->is_pbook_3400) |
102 | name_ext = " [PB3400]"; | 102 | name_ext = " [PB3400]"; |
103 | else if (chip->is_pbook_G3) | 103 | else if (chip->is_pbook_G3) |
104 | name_ext = " [PBG3]"; | 104 | name_ext = " [PBG3]"; |
105 | else | 105 | else |
106 | name_ext = ""; | 106 | name_ext = ""; |
107 | sprintf(card->longname, "%s%s Rev %d", | 107 | sprintf(card->longname, "%s%s Rev %d", |
108 | card->shortname, name_ext, chip->revision); | 108 | card->shortname, name_ext, chip->revision); |
109 | if ((err = snd_pmac_awacs_init(chip)) < 0) | 109 | if ((err = snd_pmac_awacs_init(chip)) < 0) |
110 | goto __error; | 110 | goto __error; |
111 | break; | 111 | break; |
112 | default: | 112 | default: |
113 | snd_printk(KERN_ERR "unsupported hardware %d\n", chip->model); | 113 | snd_printk(KERN_ERR "unsupported hardware %d\n", chip->model); |
114 | err = -EINVAL; | 114 | err = -EINVAL; |
115 | goto __error; | 115 | goto __error; |
116 | } | 116 | } |
117 | 117 | ||
118 | if ((err = snd_pmac_pcm_new(chip)) < 0) | 118 | if ((err = snd_pmac_pcm_new(chip)) < 0) |
119 | goto __error; | 119 | goto __error; |
120 | 120 | ||
121 | chip->initialized = 1; | 121 | chip->initialized = 1; |
122 | if (enable_beep) | 122 | if (enable_beep) |
123 | snd_pmac_attach_beep(chip); | 123 | snd_pmac_attach_beep(chip); |
124 | 124 | ||
125 | snd_card_set_dev(card, &devptr->dev); | 125 | snd_card_set_dev(card, &devptr->dev); |
126 | 126 | ||
127 | if ((err = snd_card_register(card)) < 0) | 127 | if ((err = snd_card_register(card)) < 0) |
128 | goto __error; | 128 | goto __error; |
129 | 129 | ||
130 | platform_set_drvdata(devptr, card); | 130 | platform_set_drvdata(devptr, card); |
131 | return 0; | 131 | return 0; |
132 | 132 | ||
133 | __error: | 133 | __error: |
134 | snd_card_free(card); | 134 | snd_card_free(card); |
135 | return err; | 135 | return err; |
136 | } | 136 | } |
137 | 137 | ||
138 | 138 | ||
139 | static int snd_pmac_remove(struct platform_device *devptr) | 139 | static int snd_pmac_remove(struct platform_device *devptr) |
140 | { | 140 | { |
141 | snd_card_free(platform_get_drvdata(devptr)); | 141 | snd_card_free(platform_get_drvdata(devptr)); |
142 | platform_set_drvdata(devptr, NULL); | ||
143 | return 0; | 142 | return 0; |
144 | } | 143 | } |
145 | 144 | ||
146 | #ifdef CONFIG_PM_SLEEP | 145 | #ifdef CONFIG_PM_SLEEP |
147 | static int snd_pmac_driver_suspend(struct device *dev) | 146 | static int snd_pmac_driver_suspend(struct device *dev) |
148 | { | 147 | { |
149 | struct snd_card *card = dev_get_drvdata(dev); | 148 | struct snd_card *card = dev_get_drvdata(dev); |
150 | snd_pmac_suspend(card->private_data); | 149 | snd_pmac_suspend(card->private_data); |
151 | return 0; | 150 | return 0; |
152 | } | 151 | } |
153 | 152 | ||
154 | static int snd_pmac_driver_resume(struct device *dev) | 153 | static int snd_pmac_driver_resume(struct device *dev) |
155 | { | 154 | { |
156 | struct snd_card *card = dev_get_drvdata(dev); | 155 | struct snd_card *card = dev_get_drvdata(dev); |
157 | snd_pmac_resume(card->private_data); | 156 | snd_pmac_resume(card->private_data); |
158 | return 0; | 157 | return 0; |
159 | } | 158 | } |
160 | 159 | ||
161 | static SIMPLE_DEV_PM_OPS(snd_pmac_pm, snd_pmac_driver_suspend, snd_pmac_driver_resume); | 160 | static SIMPLE_DEV_PM_OPS(snd_pmac_pm, snd_pmac_driver_suspend, snd_pmac_driver_resume); |
162 | #define SND_PMAC_PM_OPS &snd_pmac_pm | 161 | #define SND_PMAC_PM_OPS &snd_pmac_pm |
163 | #else | 162 | #else |
164 | #define SND_PMAC_PM_OPS NULL | 163 | #define SND_PMAC_PM_OPS NULL |
165 | #endif | 164 | #endif |
166 | 165 | ||
167 | #define SND_PMAC_DRIVER "snd_powermac" | 166 | #define SND_PMAC_DRIVER "snd_powermac" |
168 | 167 | ||
169 | static struct platform_driver snd_pmac_driver = { | 168 | static struct platform_driver snd_pmac_driver = { |
170 | .probe = snd_pmac_probe, | 169 | .probe = snd_pmac_probe, |
171 | .remove = snd_pmac_remove, | 170 | .remove = snd_pmac_remove, |
172 | .driver = { | 171 | .driver = { |
173 | .name = SND_PMAC_DRIVER, | 172 | .name = SND_PMAC_DRIVER, |
174 | .owner = THIS_MODULE, | 173 | .owner = THIS_MODULE, |
175 | .pm = SND_PMAC_PM_OPS, | 174 | .pm = SND_PMAC_PM_OPS, |
176 | }, | 175 | }, |
177 | }; | 176 | }; |
178 | 177 | ||
179 | static int __init alsa_card_pmac_init(void) | 178 | static int __init alsa_card_pmac_init(void) |
180 | { | 179 | { |
181 | int err; | 180 | int err; |
182 | 181 | ||
183 | if ((err = platform_driver_register(&snd_pmac_driver)) < 0) | 182 | if ((err = platform_driver_register(&snd_pmac_driver)) < 0) |
184 | return err; | 183 | return err; |
185 | device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0); | 184 | device = platform_device_register_simple(SND_PMAC_DRIVER, -1, NULL, 0); |
186 | return 0; | 185 | return 0; |
187 | 186 | ||
188 | } | 187 | } |
189 | 188 | ||
190 | static void __exit alsa_card_pmac_exit(void) | 189 | static void __exit alsa_card_pmac_exit(void) |
191 | { | 190 | { |
192 | if (!IS_ERR(device)) | 191 | if (!IS_ERR(device)) |
193 | platform_device_unregister(device); | 192 | platform_device_unregister(device); |
194 | platform_driver_unregister(&snd_pmac_driver); | 193 | platform_driver_unregister(&snd_pmac_driver); |
195 | } | 194 | } |
196 | 195 | ||
197 | module_init(alsa_card_pmac_init) | 196 | module_init(alsa_card_pmac_init) |
198 | module_exit(alsa_card_pmac_exit) | 197 | module_exit(alsa_card_pmac_exit) |
199 | 198 |