Changeset 717 for GPL/trunk/alsa-kernel/pci/cs5535audio/cs5535audio.c
- Timestamp:
- Aug 7, 2022, 6:11:12 PM (3 years ago)
- Location:
- GPL/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GPL/trunk
- Property svn:mergeinfo changed
/GPL/branches/uniaud32-next merged: 710-716
- Property svn:mergeinfo changed
-
GPL/trunk/alsa-kernel/pci/cs5535audio/cs5535audio.c
r703 r717 242 242 } 243 243 244 static int snd_cs5535audio_free(struct cs5535audio *cs5535au) 245 { 246 pci_set_power_state(cs5535au->pci, PCI_D3hot); 247 248 if (cs5535au->irq >= 0) 249 free_irq(cs5535au->irq, cs5535au); 250 251 pci_release_regions(cs5535au->pci); 252 pci_disable_device(cs5535au->pci); 253 kfree(cs5535au); 254 return 0; 255 } 256 257 static int snd_cs5535audio_dev_free(struct snd_device *device) 258 { 259 struct cs5535audio *cs5535au = device->device_data; 260 return snd_cs5535audio_free(cs5535au); 244 static void snd_cs5535audio_free(struct snd_card *card) 245 { 246 olpc_quirks_cleanup(); 261 247 } 262 248 263 249 static int snd_cs5535audio_create(struct snd_card *card, 264 struct pci_dev *pci, 265 struct cs5535audio **rcs5535au) 266 { 267 struct cs5535audio *cs5535au; 268 250 struct pci_dev *pci) 251 { 252 struct cs5535audio *cs5535au = card->private_data; 269 253 int err; 270 static const struct snd_device_ops ops = { 271 .dev_free = snd_cs5535audio_dev_free, 272 }; 273 274 *rcs5535au = NULL; 275 err = pci_enable_device(pci); 254 255 err = pcim_enable_device(pci); 276 256 if (err < 0) 277 257 return err; … … 279 259 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32))) { 280 260 dev_warn(card->dev, "unable to get 32bit dma\n"); 281 err = -ENXIO; 282 goto pcifail; 283 } 284 285 cs5535au = kzalloc(sizeof(*cs5535au), GFP_KERNEL); 286 if (cs5535au == NULL) { 287 err = -ENOMEM; 288 goto pcifail; 261 return -ENXIO; 289 262 } 290 263 … … 295 268 296 269 err = pci_request_regions(pci, "CS5535 Audio"); 297 if (err < 0) { 298 kfree(cs5535au); 299 goto pcifail; 300 } 270 if (err < 0) 271 return err; 301 272 302 273 cs5535au->port = pci_resource_start(pci, 0); 303 274 304 if ( request_irq(pci->irq, snd_cs5535audio_interrupt,305 IRQF_SHARED, KBUILD_MODNAME, cs5535au)) {275 if (devm_request_irq(&pci->dev, pci->irq, snd_cs5535audio_interrupt, 276 IRQF_SHARED, KBUILD_MODNAME, cs5535au)) { 306 277 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 307 err = -EBUSY; 308 goto sndfail; 278 return -EBUSY; 309 279 } 310 280 … … 313 283 pci_set_master(pci); 314 284 315 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, cs5535au, &ops);316 if (err < 0)317 goto sndfail;318 319 *rcs5535au = cs5535au;320 285 return 0; 321 322 sndfail: /* leave the device alive, just kill the snd */ 323 snd_cs5535audio_free(cs5535au); 324 return err; 325 326 pcifail: 327 pci_disable_device(pci); 328 return err; 329 } 330 331 static int snd_cs5535audio_probe(struct pci_dev *pci, 332 const struct pci_device_id *pci_id) 286 } 287 288 static int __snd_cs5535audio_probe(struct pci_dev *pci, 289 const struct pci_device_id *pci_id) 333 290 { 334 291 static int dev; … … 344 301 } 345 302 346 err = snd_ card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,347 0, &card);348 if (err < 0) 349 return err; 350 351 err = snd_cs5535audio_create(card, pci, &cs5535au);352 if (err < 0) 353 goto probefail_out;354 355 card->private_data = cs5535au;303 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE, 304 sizeof(*cs5535au), &card); 305 if (err < 0) 306 return err; 307 cs5535au = card->private_data; 308 card->private_free = snd_cs5535audio_free; 309 310 err = snd_cs5535audio_create(card, pci); 311 if (err < 0) 312 return err; 356 313 357 314 err = snd_cs5535audio_mixer(cs5535au); 358 315 if (err < 0) 359 goto probefail_out;316 return err; 360 317 361 318 err = snd_cs5535audio_pcm(cs5535au); 362 319 if (err < 0) 363 goto probefail_out;320 return err; 364 321 365 322 strcpy(card->driver, DRIVER_NAME); … … 372 329 err = snd_card_register(card); 373 330 if (err < 0) 374 goto probefail_out;331 return err; 375 332 376 333 pci_set_drvdata(pci, card); 377 334 dev++; 378 335 return 0; 379 380 probefail_out: 381 snd_card_free(card); 382 return err; 383 } 384 385 static void snd_cs5535audio_remove(struct pci_dev *pci) 386 { 387 olpc_quirks_cleanup(); 388 snd_card_free(pci_get_drvdata(pci)); 336 } 337 338 static int snd_cs5535audio_probe(struct pci_dev *pci, 339 const struct pci_device_id *pci_id) 340 { 341 return snd_card_free_on_error(&pci->dev, __snd_cs5535audio_probe(pci, pci_id)); 389 342 } 390 343 … … 393 346 .id_table = snd_cs5535audio_ids, 394 347 .probe = snd_cs5535audio_probe, 395 .remove = snd_cs5535audio_remove,396 348 #ifdef CONFIG_PM_SLEEP 397 349 .driver = {
Note:
See TracChangeset
for help on using the changeset viewer.