diff options
Diffstat (limited to 'sound/pcmcia/pdaudiocf')
-rw-r--r-- | sound/pcmcia/pdaudiocf/pdaudiocf.c | 86 | ||||
-rw-r--r-- | sound/pcmcia/pdaudiocf/pdaudiocf.h | 2 |
2 files changed, 26 insertions, 62 deletions
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c index 77caf43a3109..adfdce7499d1 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.c +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c | |||
@@ -57,18 +57,12 @@ static struct snd_card *card_list[SNDRV_CARDS]; | |||
57 | /* | 57 | /* |
58 | * prototypes | 58 | * prototypes |
59 | */ | 59 | */ |
60 | static void pdacf_config(dev_link_t *link); | 60 | static int pdacf_config(struct pcmcia_device *link); |
61 | static void snd_pdacf_detach(struct pcmcia_device *p_dev); | 61 | static void snd_pdacf_detach(struct pcmcia_device *p_dev); |
62 | 62 | ||
63 | static void pdacf_release(dev_link_t *link) | 63 | static void pdacf_release(struct pcmcia_device *link) |
64 | { | 64 | { |
65 | if (link->state & DEV_CONFIG) { | 65 | pcmcia_disable_device(link); |
66 | /* release cs resources */ | ||
67 | pcmcia_release_configuration(link->handle); | ||
68 | pcmcia_release_io(link->handle, &link->io); | ||
69 | pcmcia_release_irq(link->handle, &link->irq); | ||
70 | link->state &= ~DEV_CONFIG; | ||
71 | } | ||
72 | } | 66 | } |
73 | 67 | ||
74 | /* | 68 | /* |
@@ -76,7 +70,7 @@ static void pdacf_release(dev_link_t *link) | |||
76 | */ | 70 | */ |
77 | static int snd_pdacf_free(struct snd_pdacf *pdacf) | 71 | static int snd_pdacf_free(struct snd_pdacf *pdacf) |
78 | { | 72 | { |
79 | dev_link_t *link = &pdacf->link; | 73 | struct pcmcia_device *link = pdacf->p_dev; |
80 | 74 | ||
81 | pdacf_release(link); | 75 | pdacf_release(link); |
82 | 76 | ||
@@ -96,10 +90,9 @@ static int snd_pdacf_dev_free(struct snd_device *device) | |||
96 | /* | 90 | /* |
97 | * snd_pdacf_attach - attach callback for cs | 91 | * snd_pdacf_attach - attach callback for cs |
98 | */ | 92 | */ |
99 | static int snd_pdacf_attach(struct pcmcia_device *p_dev) | 93 | static int snd_pdacf_probe(struct pcmcia_device *link) |
100 | { | 94 | { |
101 | int i; | 95 | int i; |
102 | dev_link_t *link; /* Info for cardmgr */ | ||
103 | struct snd_pdacf *pdacf; | 96 | struct snd_pdacf *pdacf; |
104 | struct snd_card *card; | 97 | struct snd_card *card; |
105 | static struct snd_device_ops ops = { | 98 | static struct snd_device_ops ops = { |
@@ -139,7 +132,7 @@ static int snd_pdacf_attach(struct pcmcia_device *p_dev) | |||
139 | pdacf->index = i; | 132 | pdacf->index = i; |
140 | card_list[i] = card; | 133 | card_list[i] = card; |
141 | 134 | ||
142 | link = &pdacf->link; | 135 | pdacf->p_dev = link; |
143 | link->priv = pdacf; | 136 | link->priv = pdacf; |
144 | 137 | ||
145 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; | 138 | link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO; |
@@ -156,13 +149,7 @@ static int snd_pdacf_attach(struct pcmcia_device *p_dev) | |||
156 | link->conf.ConfigIndex = 1; | 149 | link->conf.ConfigIndex = 1; |
157 | link->conf.Present = PRESENT_OPTION; | 150 | link->conf.Present = PRESENT_OPTION; |
158 | 151 | ||
159 | /* Chain drivers */ | 152 | return pdacf_config(link); |
160 | link->next = NULL; | ||
161 | |||
162 | link->handle = p_dev; | ||
163 | pdacf_config(link); | ||
164 | |||
165 | return 0; | ||
166 | } | 153 | } |
167 | 154 | ||
168 | 155 | ||
@@ -209,9 +196,8 @@ static int snd_pdacf_assign_resources(struct snd_pdacf *pdacf, int port, int irq | |||
209 | /* | 196 | /* |
210 | * snd_pdacf_detach - detach callback for cs | 197 | * snd_pdacf_detach - detach callback for cs |
211 | */ | 198 | */ |
212 | static void snd_pdacf_detach(struct pcmcia_device *p_dev) | 199 | static void snd_pdacf_detach(struct pcmcia_device *link) |
213 | { | 200 | { |
214 | dev_link_t *link = dev_to_instance(p_dev); | ||
215 | struct snd_pdacf *chip = link->priv; | 201 | struct snd_pdacf *chip = link->priv; |
216 | 202 | ||
217 | snd_printdd(KERN_DEBUG "pdacf_detach called\n"); | 203 | snd_printdd(KERN_DEBUG "pdacf_detach called\n"); |
@@ -230,13 +216,11 @@ static void snd_pdacf_detach(struct pcmcia_device *p_dev) | |||
230 | #define CS_CHECK(fn, ret) \ | 216 | #define CS_CHECK(fn, ret) \ |
231 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) | 217 | do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0) |
232 | 218 | ||
233 | static void pdacf_config(dev_link_t *link) | 219 | static int pdacf_config(struct pcmcia_device *link) |
234 | { | 220 | { |
235 | client_handle_t handle = link->handle; | ||
236 | struct snd_pdacf *pdacf = link->priv; | 221 | struct snd_pdacf *pdacf = link->priv; |
237 | tuple_t tuple; | 222 | tuple_t tuple; |
238 | cisparse_t *parse = NULL; | 223 | cisparse_t *parse = NULL; |
239 | config_info_t conf; | ||
240 | u_short buf[32]; | 224 | u_short buf[32]; |
241 | int last_fn, last_ret; | 225 | int last_fn, last_ret; |
242 | 226 | ||
@@ -244,7 +228,7 @@ static void pdacf_config(dev_link_t *link) | |||
244 | parse = kmalloc(sizeof(*parse), GFP_KERNEL); | 228 | parse = kmalloc(sizeof(*parse), GFP_KERNEL); |
245 | if (! parse) { | 229 | if (! parse) { |
246 | snd_printk(KERN_ERR "pdacf_config: cannot allocate\n"); | 230 | snd_printk(KERN_ERR "pdacf_config: cannot allocate\n"); |
247 | return; | 231 | return -ENOMEM; |
248 | } | 232 | } |
249 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; | 233 | tuple.DesiredTuple = CISTPL_CFTABLE_ENTRY; |
250 | tuple.Attributes = 0; | 234 | tuple.Attributes = 0; |
@@ -252,71 +236,51 @@ static void pdacf_config(dev_link_t *link) | |||
252 | tuple.TupleDataMax = sizeof(buf); | 236 | tuple.TupleDataMax = sizeof(buf); |
253 | tuple.TupleOffset = 0; | 237 | tuple.TupleOffset = 0; |
254 | tuple.DesiredTuple = CISTPL_CONFIG; | 238 | tuple.DesiredTuple = CISTPL_CONFIG; |
255 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(handle, &tuple)); | 239 | CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); |
256 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(handle, &tuple)); | 240 | CS_CHECK(GetTupleData, pcmcia_get_tuple_data(link, &tuple)); |
257 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(handle, &tuple, parse)); | 241 | CS_CHECK(ParseTuple, pcmcia_parse_tuple(link, &tuple, parse)); |
258 | link->conf.ConfigBase = parse->config.base; | 242 | link->conf.ConfigBase = parse->config.base; |
259 | link->conf.ConfigIndex = 0x5; | 243 | link->conf.ConfigIndex = 0x5; |
260 | kfree(parse); | 244 | kfree(parse); |
261 | 245 | ||
262 | CS_CHECK(GetConfigurationInfo, pcmcia_get_configuration_info(handle, &conf)); | 246 | CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io)); |
263 | link->conf.Vcc = conf.Vcc; | 247 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); |
264 | 248 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); | |
265 | /* Configure card */ | ||
266 | link->state |= DEV_CONFIG; | ||
267 | |||
268 | CS_CHECK(RequestIO, pcmcia_request_io(handle, &link->io)); | ||
269 | CS_CHECK(RequestIRQ, pcmcia_request_irq(link->handle, &link->irq)); | ||
270 | CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link->handle, &link->conf)); | ||
271 | 249 | ||
272 | if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0) | 250 | if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0) |
273 | goto failed; | 251 | goto failed; |
274 | 252 | ||
275 | link->dev = &pdacf->node; | 253 | link->dev_node = &pdacf->node; |
276 | link->state &= ~DEV_CONFIG_PENDING; | 254 | return 0; |
277 | return; | ||
278 | 255 | ||
279 | cs_failed: | 256 | cs_failed: |
280 | cs_error(link->handle, last_fn, last_ret); | 257 | cs_error(link, last_fn, last_ret); |
281 | failed: | 258 | failed: |
282 | pcmcia_release_configuration(link->handle); | 259 | pcmcia_disable_device(link); |
283 | pcmcia_release_io(link->handle, &link->io); | 260 | return -ENODEV; |
284 | pcmcia_release_irq(link->handle, &link->irq); | ||
285 | } | 261 | } |
286 | 262 | ||
287 | #ifdef CONFIG_PM | 263 | #ifdef CONFIG_PM |
288 | 264 | ||
289 | static int pdacf_suspend(struct pcmcia_device *dev) | 265 | static int pdacf_suspend(struct pcmcia_device *link) |
290 | { | 266 | { |
291 | dev_link_t *link = dev_to_instance(dev); | ||
292 | struct snd_pdacf *chip = link->priv; | 267 | struct snd_pdacf *chip = link->priv; |
293 | 268 | ||
294 | snd_printdd(KERN_DEBUG "SUSPEND\n"); | 269 | snd_printdd(KERN_DEBUG "SUSPEND\n"); |
295 | link->state |= DEV_SUSPEND; | ||
296 | if (chip) { | 270 | if (chip) { |
297 | snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); | 271 | snd_printdd(KERN_DEBUG "snd_pdacf_suspend calling\n"); |
298 | snd_pdacf_suspend(chip, PMSG_SUSPEND); | 272 | snd_pdacf_suspend(chip, PMSG_SUSPEND); |
299 | } | 273 | } |
300 | 274 | ||
301 | snd_printdd(KERN_DEBUG "RESET_PHYSICAL\n"); | ||
302 | if (link->state & DEV_CONFIG) | ||
303 | pcmcia_release_configuration(link->handle); | ||
304 | |||
305 | return 0; | 275 | return 0; |
306 | } | 276 | } |
307 | 277 | ||
308 | static int pdacf_resume(struct pcmcia_device *dev) | 278 | static int pdacf_resume(struct pcmcia_device *link) |
309 | { | 279 | { |
310 | dev_link_t *link = dev_to_instance(dev); | ||
311 | struct snd_pdacf *chip = link->priv; | 280 | struct snd_pdacf *chip = link->priv; |
312 | 281 | ||
313 | snd_printdd(KERN_DEBUG "RESUME\n"); | 282 | snd_printdd(KERN_DEBUG "RESUME\n"); |
314 | link->state &= ~DEV_SUSPEND; | 283 | if (pcmcia_dev_present(link)) { |
315 | |||
316 | snd_printdd(KERN_DEBUG "CARD_RESET\n"); | ||
317 | if (DEV_OK(link)) { | ||
318 | snd_printdd(KERN_DEBUG "requestconfig...\n"); | ||
319 | pcmcia_request_configuration(link->handle, &link->conf); | ||
320 | if (chip) { | 284 | if (chip) { |
321 | snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); | 285 | snd_printdd(KERN_DEBUG "calling snd_pdacf_resume\n"); |
322 | snd_pdacf_resume(chip); | 286 | snd_pdacf_resume(chip); |
@@ -343,7 +307,7 @@ static struct pcmcia_driver pdacf_cs_driver = { | |||
343 | .drv = { | 307 | .drv = { |
344 | .name = "snd-pdaudiocf", | 308 | .name = "snd-pdaudiocf", |
345 | }, | 309 | }, |
346 | .probe = snd_pdacf_attach, | 310 | .probe = snd_pdacf_probe, |
347 | .remove = snd_pdacf_detach, | 311 | .remove = snd_pdacf_detach, |
348 | .id_table = snd_pdacf_ids, | 312 | .id_table = snd_pdacf_ids, |
349 | #ifdef CONFIG_PM | 313 | #ifdef CONFIG_PM |
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.h b/sound/pcmcia/pdaudiocf/pdaudiocf.h index 2744f189a613..9a14a4f64bd3 100644 --- a/sound/pcmcia/pdaudiocf/pdaudiocf.h +++ b/sound/pcmcia/pdaudiocf/pdaudiocf.h | |||
@@ -116,7 +116,7 @@ struct snd_pdacf { | |||
116 | void *pcm_area; | 116 | void *pcm_area; |
117 | 117 | ||
118 | /* pcmcia stuff */ | 118 | /* pcmcia stuff */ |
119 | dev_link_t link; | 119 | struct pcmcia_device *p_dev; |
120 | dev_node_t node; | 120 | dev_node_t node; |
121 | }; | 121 | }; |
122 | 122 | ||