Changeset 717 for GPL/trunk/alsa-kernel/pci/via82xx.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/via82xx.c
r703 r717 1916 1916 { 1917 1917 struct gameport *gp; 1918 struct resource *r;1919 1918 1920 1919 if (!joystick) 1921 1920 return -ENODEV; 1922 1921 1923 r = request_region(JOYSTICK_ADDR, 8, "VIA686 gameport");1924 if (!r) {1922 if (!devm_request_region(chip->card->dev, JOYSTICK_ADDR, 8, 1923 "VIA686 gameport")) { 1925 1924 dev_warn(chip->card->dev, "cannot reserve joystick port %#x\n", 1926 1925 JOYSTICK_ADDR); … … 1932 1931 dev_err(chip->card->dev, 1933 1932 "cannot allocate memory for gameport\n"); 1934 release_and_free_resource(r);1935 1933 return -ENOMEM; 1936 1934 } … … 1940 1938 gameport_set_dev_parent(gp, &chip->pci->dev); 1941 1939 gp->io = JOYSTICK_ADDR; 1942 gameport_set_port_data(gp, r);1943 1940 1944 1941 /* Enable legacy joystick port */ … … 1954 1951 { 1955 1952 if (chip->gameport) { 1956 struct resource *r = gameport_get_port_data(chip->gameport);1957 1958 1953 gameport_unregister_port(chip->gameport); 1959 1954 chip->gameport = NULL; 1960 release_and_free_resource(r);1961 1955 } 1962 1956 } … … 2068 2062 } 2069 2063 if (mpu_port >= 0x200) 2070 chip->mpu_res = request_region(mpu_port, 2, "VIA82xx MPU401"); 2064 chip->mpu_res = devm_request_region(&chip->pci->dev, mpu_port, 2065 2, "VIA82xx MPU401"); 2071 2066 if (chip->mpu_res) { 2072 2067 if (rev_h) … … 2307 2302 #endif /* CONFIG_PM_SLEEP */ 2308 2303 2309 static int snd_via82xx_free(struct via82xx *chip) 2310 { 2304 static void snd_via82xx_free(struct snd_card *card) 2305 { 2306 struct via82xx *chip = card->private_data; 2311 2307 unsigned int i; 2312 2308 2313 if (chip->irq < 0)2314 goto __end_hw;2315 2309 /* disable interrupts */ 2316 2310 for (i = 0; i < chip->num_devs; i++) 2317 2311 snd_via82xx_channel_reset(chip, &chip->devs[i]); 2318 2319 if (chip->irq >= 0)2320 free_irq(chip->irq, chip);2321 __end_hw:2322 release_and_free_resource(chip->mpu_res);2323 pci_release_regions(chip->pci);2324 2312 2325 2313 if (chip->chip_type == TYPE_VIA686) { … … 2328 2316 pci_write_config_byte(chip->pci, VIA_PNP_CONTROL, chip->old_legacy_cfg); 2329 2317 } 2330 pci_disable_device(chip->pci);2331 kfree(chip);2332 return 0;2333 }2334 2335 static int snd_via82xx_dev_free(struct snd_device *device)2336 {2337 struct via82xx *chip = device->device_data;2338 return snd_via82xx_free(chip);2339 2318 } 2340 2319 … … 2343 2322 int chip_type, 2344 2323 int revision, 2345 unsigned int ac97_clock, 2346 struct via82xx **r_via) 2347 { 2348 struct via82xx *chip; 2324 unsigned int ac97_clock) 2325 { 2326 struct via82xx *chip = card->private_data; 2349 2327 int err; 2350 static const struct snd_device_ops ops = { 2351 .dev_free = snd_via82xx_dev_free, 2352 }; 2353 2354 err = pci_enable_device(pci); 2328 2329 err = pcim_enable_device(pci); 2355 2330 if (err < 0) 2356 2331 return err; 2357 2358 chip = kzalloc(sizeof(*chip), GFP_KERNEL);2359 if (!chip) {2360 pci_disable_device(pci);2361 return -ENOMEM;2362 }2363 2332 2364 2333 chip->chip_type = chip_type; … … 2378 2347 2379 2348 err = pci_request_regions(pci, card->driver); 2380 if (err < 0) { 2381 kfree(chip); 2382 pci_disable_device(pci); 2349 if (err < 0) 2383 2350 return err; 2384 }2385 2351 chip->port = pci_resource_start(pci, 0); 2386 if ( request_irq(pci->irq,2387 chip_type == TYPE_VIA8233 ?2388 snd_via8233_interrupt :snd_via686_interrupt,2389 IRQF_SHARED,2390 KBUILD_MODNAME, chip)) {2352 if (devm_request_irq(&pci->dev, pci->irq, 2353 chip_type == TYPE_VIA8233 ? 2354 snd_via8233_interrupt : snd_via686_interrupt, 2355 IRQF_SHARED, 2356 KBUILD_MODNAME, chip)) { 2391 2357 dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq); 2392 snd_via82xx_free(chip);2393 2358 return -EBUSY; 2394 2359 } 2395 2360 chip->irq = pci->irq; 2396 2361 card->sync_irq = chip->irq; 2362 card->private_free = snd_via82xx_free; 2397 2363 if (ac97_clock >= 8000 && ac97_clock <= 48000) 2398 2364 chip->ac97_clock = ac97_clock; 2399 2365 2400 2366 err = snd_via82xx_chip_init(chip); 2401 if (err < 0) { 2402 snd_via82xx_free(chip); 2367 if (err < 0) 2403 2368 return err; 2404 }2405 2406 err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);2407 if (err < 0) {2408 snd_via82xx_free(chip);2409 return err;2410 }2411 2369 2412 2370 /* The 8233 ac97 controller does not implement the master bit … … 2414 2372 * We call pci_set_master here because it does not hurt. */ 2415 2373 pci_set_master(pci); 2416 2417 *r_via = chip;2418 2374 return 0; 2419 2375 } … … 2507 2463 }; 2508 2464 2509 static int snd_via82xx_probe(struct pci_dev *pci,2510 const struct pci_device_id *pci_id)2465 static int __snd_via82xx_probe(struct pci_dev *pci, 2466 const struct pci_device_id *pci_id) 2511 2467 { 2512 2468 struct snd_card *card; … … 2516 2472 int err; 2517 2473 2518 err = snd_card_new(&pci->dev, index, id, THIS_MODULE, 0, &card); 2474 err = snd_devm_card_new(&pci->dev, index, id, THIS_MODULE, 2475 sizeof(*chip), &card); 2519 2476 if (err < 0) 2520 2477 return err; 2478 chip = card->private_data; 2521 2479 2522 2480 card_type = pci_id->driver_data; … … 2557 2515 default: 2558 2516 dev_err(card->dev, "invalid card type %d\n", card_type); 2559 err = -EINVAL; 2560 goto __error; 2517 return -EINVAL; 2561 2518 } 2562 2519 2563 2520 err = snd_via82xx_create(card, pci, chip_type, pci->revision, 2564 ac97_clock , &chip);2521 ac97_clock); 2565 2522 if (err < 0) 2566 goto __error; 2567 card->private_data = chip; 2523 return err; 2568 2524 err = snd_via82xx_mixer_new(chip, ac97_quirk); 2569 2525 if (err < 0) 2570 goto __error;2526 return err; 2571 2527 2572 2528 if (chip_type == TYPE_VIA686) { 2573 2529 err = snd_via686_pcm_new(chip); 2574 2530 if (err < 0) 2575 goto __error;2531 return err; 2576 2532 err = snd_via686_init_misc(chip); 2577 2533 if (err < 0) 2578 goto __error;2534 return err; 2579 2535 } else { 2580 2536 if (chip_type == TYPE_VIA8233A) { 2581 2537 err = snd_via8233a_pcm_new(chip); 2582 2538 if (err < 0) 2583 goto __error;2539 return err; 2584 2540 // chip->dxs_fixed = 1; /* FIXME: use 48k for DXS #3? */ 2585 2541 } else { 2586 2542 err = snd_via8233_pcm_new(chip); 2587 2543 if (err < 0) 2588 goto __error;2544 return err; 2589 2545 if (dxs_support == VIA_DXS_48K) 2590 2546 chip->dxs_fixed = 1; … … 2598 2554 err = snd_via8233_init_misc(chip); 2599 2555 if (err < 0) 2600 goto __error;2556 return err; 2601 2557 } 2602 2558 … … 2612 2568 2613 2569 err = snd_card_register(card); 2614 if (err < 0) { 2615 snd_card_free(card); 2570 if (err < 0) 2616 2571 return err; 2617 }2618 2572 pci_set_drvdata(pci, card); 2619 2573 return 0; 2620 2621 __error: 2622 snd_card_free(card); 2623 return err; 2624 } 2625 2626 static void snd_via82xx_remove(struct pci_dev *pci) 2627 { 2628 snd_card_free(pci_get_drvdata(pci)); 2574 } 2575 2576 static int snd_via82xx_probe(struct pci_dev *pci, 2577 const struct pci_device_id *pci_id) 2578 { 2579 return snd_card_free_on_error(&pci->dev, __snd_via82xx_probe(pci, pci_id)); 2629 2580 } 2630 2581 … … 2633 2584 .id_table = snd_via82xx_ids, 2634 2585 .probe = snd_via82xx_probe, 2635 .remove = snd_via82xx_remove,2636 2586 .driver = { 2637 2587 .pm = SND_VIA82XX_PM_OPS,
Note:
See TracChangeset
for help on using the changeset viewer.