Changeset 744 for GPL/branches
- Timestamp:
- Sep 18, 2022, 11:16:00 AM (3 years ago)
- Location:
- GPL/branches/uniaud32-exp
- Files:
- 
      - 8 edited
 
 - 
          
  alsa-kernel/pci/atiixp.c (modified) (1 diff)
- 
          
  alsa-kernel/pci/bt87x.c (modified) (1 diff)
- 
          
  alsa-kernel/pci/cs4281.c (modified) (1 diff)
- 
          
  alsa-kernel/pci/cs5530.c (modified) (1 diff)
- 
          
  alsa-kernel/pci/fm801.c (modified) (1 diff)
- 
          
  alsa-kernel/pci/hda/hda_intel.c (modified) (1 diff)
- 
          
  include/linux/pci.h (modified) (2 diffs)
- 
          
  lib32/devres.c (modified) (3 diffs)
 
Legend:
- Unmodified
- Added
- Removed
- 
      GPL/branches/uniaud32-exp/alsa-kernel/pci/atiixp.cr737 r744 1563 1563 chip->pci = pci; 1564 1564 chip->irq = -1; 1565 #ifndef TARGET_OS21566 1565 err = pcim_iomap_regions(pci, 1 << 0, "ATI IXP AC97"); 1567 1566 if (err < 0) 1568 1567 return err; 1569 #else1570 err = pci_request_regions(pci, "ATI IXP AC97");1571 if (err < 0) {1572 pci_disable_device(pci);1573 kfree(chip);1574 return err;1575 }1576 #endif1577 1568 chip->addr = pci_resource_start(pci, 0); 1578 #ifndef TARGET_OS21579 1569 chip->remap_addr = pcim_iomap_table(pci)[0]; 1580 #else1581 chip->remap_addr = pci_ioremap_bar(pci, 0);1582 #endif1583 1570 if (devm_request_irq(&pci->dev, pci->irq, snd_atiixp_interrupt, 1584 1571 IRQF_SHARED, KBUILD_MODNAME, chip)) { 
- 
      GPL/branches/uniaud32-exp/alsa-kernel/pci/bt87x.cr737 r744 706 706 spin_lock_init(&chip->reg_lock); 707 707 708 #ifndef TARGET_OS2709 708 err = pcim_iomap_regions(pci, 1 << 0, "Bt87x audio"); 710 709 if (err < 0) 711 710 return err; 712 711 chip->mmio = pcim_iomap_table(pci)[0]; 713 #else714 err = pci_request_regions(pci, "Bt87x audio");715 if (err < 0) {716 kfree(chip);717 pci_disable_device(pci);718 return err;719 }720 chip->mmio = pci_ioremap_bar(pci, 0);721 #endif722 712 chip->reg_control = CTL_A_PWRDN | CTL_DA_ES2 | 723 713 CTL_PKTP_16 | (15 << CTL_DA_SDR_SHIFT); 
- 
      GPL/branches/uniaud32-exp/alsa-kernel/pci/cs4281.cr737 r744 1309 1309 chip->dual_codec = dual_codec; 1310 1310 1311 #ifndef TARGET_OS21312 1311 err = pcim_iomap_regions(pci, 0x03, "CS4281"); /* 2 BARs */ 1313 1312 if (err < 0) 1314 1313 return err; 1315 #else1316 err = pci_request_regions(pci, "CS4281");1317 if (err < 0) {1318 kfree(chip);1319 pci_disable_device(pci);1320 return err;1321 }1322 #endif1323 1314 chip->ba0_addr = pci_resource_start(pci, 0); 1324 1315 chip->ba1_addr = pci_resource_start(pci, 1); 1325 1316 1326 #ifndef TARGET_OS21327 1317 chip->ba0 = pcim_iomap_table(pci)[0]; 1328 1318 chip->ba1 = pcim_iomap_table(pci)[1]; 1329 #else1330 chip->ba0 = pci_ioremap_bar(pci, 0);1331 chip->ba1 = pci_ioremap_bar(pci, 1);1332 #endif1333 1319 if (devm_request_irq(&pci->dev, pci->irq, snd_cs4281_interrupt, 1334 1320 IRQF_SHARED, KBUILD_MODNAME, chip)) { 
- 
      GPL/branches/uniaud32-exp/alsa-kernel/pci/cs5530.cr710 r744 100 100 return err; 101 101 chip->pci_base = pci_resource_start(pci, 0); 102 #ifndef TARGET_OS2103 102 mem = pcim_iomap_table(pci)[0]; 104 #else105 mem = pci_ioremap_bar(pci, 0);106 #endif107 103 map = readw(mem + 0x18); 108 104 
- 
      GPL/branches/uniaud32-exp/alsa-kernel/pci/fm801.cr737 r744 1195 1195 int err; 1196 1196 1197 #ifndef TARGET_OS21198 1197 err = pcim_enable_device(pci); 1199 1198 if (err < 0) 1200 1199 return err; 1201 #else1202 if ((err = pci_enable_device(pci)) < 0)1203 return err;1204 #endif1205 1200 spin_lock_init(&chip->reg_lock); 1206 1201 chip->card = card; 
- 
      GPL/branches/uniaud32-exp/alsa-kernel/pci/hda/hda_intel.cr740 r744 1895 1895 #endif 1896 1896 1897 #ifndef TARGET_OS21898 1897 err = pcim_iomap_regions(pci, 1 << 0, "ICH HD audio"); 1899 #else1900 err = pci_request_regions(pci, "ICH HD audio");1901 #endif1902 1898 if (err < 0) 1903 1899 return err; 1904 1900 1905 1901 bus->addr = pci_resource_start(pci, 0); 1906 #ifndef TARGET_OS21907 1902 bus->remap_addr = pcim_iomap_table(pci)[0]; 1908 #else1909 bus->remap_addr = pci_ioremap_bar(pci, 0);1910 #endif1911 1903 if (chip->driver_type == AZX_DRIVER_SKL) 1912 1904 snd_hdac_bus_parse_capabilities(bus); 
- 
      GPL/branches/uniaud32-exp/include/linux/pci.hr732 r744 781 781 #define dev_is_pci(d) (true) 782 782 int pcim_enable_device(struct pci_dev *pdev); 783 #define pcim_iomap pci_iomap784 783 int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name); 785 784 … … 789 788 } 790 789 void pci_intx(struct pci_dev *pdev, int enable); 790 #define PCI_STD_NUM_BARS 6 /* Number of standard BARs */ 791 int __must_check pci_request_region(struct pci_dev *, int, char *); 792 void pci_release_region(struct pci_dev *, int); 793 void __iomem * const *pcim_iomap_table(struct pci_dev *pdev); 791 794 792 795 #endif /* LINUX_PCI_H */ 
- 
      GPL/branches/uniaud32-exp/lib32/devres.cr737 r744 9 9 10 10 #include <linux/device.h> 11 #include <linux/pci.h> 11 12 #include <linux/module.h> 12 13 #include <linux/slab.h> … … 310 311 return NULL; 311 312 } 313 314 /** 315 * devres_get - Find devres, if non-existent, add one atomically 316 * @dev: Device to lookup or add devres for 317 * @new_res: Pointer to new initialized devres to add if not found 318 * @match: Match function (optional) 319 * @match_data: Data for the match function 320 * 321 * Find the latest devres of @dev which has the same release function 322 * as @new_res and for which @match return 1. If found, @new_res is 323 * freed; otherwise, @new_res is added atomically. 324 * 325 * RETURNS: 326 * Pointer to found or added devres. 327 */ 328 void * devres_get(struct device *dev, void *new_res, 329 dr_match_t match, void *match_data) 330 { 331 struct devres *new_dr = container_of(new_res, struct devres, data); 332 struct devres *dr; 333 unsigned long flags; 334 335 spin_lock_irqsave(&dev->devres_lock, flags); 336 dr = find_dr(dev, new_dr->node.release, match, match_data); 337 if (!dr) { 338 add_dr(dev, &new_dr->node); 339 dr = new_dr; 340 new_res = NULL; 341 } 342 spin_unlock_irqrestore(&dev->devres_lock, flags); 343 devres_free(new_res); 344 345 return dr->data; 346 } 347 EXPORT_SYMBOL_GPL(devres_get); 312 348 313 349 /* … … 527 563 } 528 564 EXPORT_SYMBOL_GPL(devm_kasprintf); 565 566 /* 567 * PCI iomap devres 568 */ 569 #define PCIM_IOMAP_MAX PCI_STD_NUM_BARS 570 571 struct pcim_iomap_devres { 572 void __iomem *table[PCIM_IOMAP_MAX]; 573 }; 574 575 static void pcim_iomap_release(struct device *gendev, void *res) 576 { 577 struct pci_dev *dev = to_pci_dev(gendev); 578 struct pcim_iomap_devres *this = res; 579 int i; 580 581 for (i = 0; i < PCIM_IOMAP_MAX; i++) 582 if (this->table[i]) 583 pci_iounmap(dev, this->table[i]); 584 } 585 586 /** 587 * pcim_iomap_table - access iomap allocation table 588 * @pdev: PCI device to access iomap table for 589 * 590 * Access iomap allocation table for @dev. If iomap table doesn't 591 * exist and @pdev is managed, it will be allocated. All iomaps 592 * recorded in the iomap table are automatically unmapped on driver 593 * detach. 594 * 595 * This function might sleep when the table is first allocated but can 596 * be safely called without context and guaranteed to succeed once 597 * allocated. 598 */ 599 void __iomem * const *pcim_iomap_table(struct pci_dev *pdev) 600 { 601 struct pcim_iomap_devres *dr, *new_dr; 602 603 dr = devres_find(&pdev->dev, pcim_iomap_release, NULL, NULL); 604 if (dr) 605 return dr->table; 606 607 new_dr = devres_alloc(pcim_iomap_release, sizeof(*new_dr), GFP_KERNEL); 608 if (!new_dr) 609 return NULL; 610 dr = devres_get(&pdev->dev, new_dr, NULL, NULL); 611 return dr->table; 612 } 613 EXPORT_SYMBOL(pcim_iomap_table); 614 615 /** 616 * pcim_iomap - Managed pcim_iomap() 617 * @pdev: PCI device to iomap for 618 * @bar: BAR to iomap 619 * @maxlen: Maximum length of iomap 620 * 621 * Managed pci_iomap(). Map is automatically unmapped on driver 622 * detach. 623 */ 624 void __iomem *pcim_iomap(struct pci_dev *pdev, int bar, unsigned long maxlen) 625 { 626 void __iomem **tbl; 627 628 BUG_ON(bar >= PCIM_IOMAP_MAX); 629 630 tbl = (void __iomem **)pcim_iomap_table(pdev); 631 if (!tbl || tbl[bar]) /* duplicate mappings not allowed */ 632 return NULL; 633 634 tbl[bar] = pci_iomap(pdev, bar, maxlen); 635 return tbl[bar]; 636 } 637 EXPORT_SYMBOL(pcim_iomap); 638 639 /** 640 * pcim_iounmap - Managed pci_iounmap() 641 * @pdev: PCI device to iounmap for 642 * @addr: Address to unmap 643 * 644 * Managed pci_iounmap(). @addr must have been mapped using pcim_iomap(). 645 */ 646 void pcim_iounmap(struct pci_dev *pdev, void __iomem *addr) 647 { 648 void __iomem **tbl; 649 int i; 650 651 pci_iounmap(pdev, addr); 652 653 tbl = (void __iomem **)pcim_iomap_table(pdev); 654 BUG_ON(!tbl); 655 656 for (i = 0; i < PCIM_IOMAP_MAX; i++) 657 if (tbl[i] == addr) { 658 tbl[i] = NULL; 659 return; 660 } 661 WARN_ON(1); 662 } 663 EXPORT_SYMBOL(pcim_iounmap); 664 665 /** 666 * pcim_iomap_regions - Request and iomap PCI BARs 667 * @pdev: PCI device to map IO resources for 668 * @mask: Mask of BARs to request and iomap 669 * @name: Name used when requesting regions 670 * 671 * Request and iomap regions specified by @mask. 672 */ 673 int pcim_iomap_regions(struct pci_dev *pdev, int mask, const char *name) 674 { 675 void __iomem * const *iomap; 676 int i, rc; 677 678 iomap = pcim_iomap_table(pdev); 679 if (!iomap) 680 return -ENOMEM; 681 682 for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { 683 unsigned long len; 684 685 if (!(mask & (1 << i))) 686 continue; 687 688 rc = -EINVAL; 689 len = pci_resource_len(pdev, i); 690 if (!len) 691 goto err_inval; 692 693 rc = pci_request_region(pdev, i, name); 694 if (rc) 695 goto err_inval; 696 697 rc = -ENOMEM; 698 if (!pcim_iomap(pdev, i, 0)) 699 goto err_region; 700 } 701 702 return 0; 703 704 err_region: 705 pci_release_region(pdev, i); 706 err_inval: 707 while (--i >= 0) { 708 if (!(mask & (1 << i))) 709 continue; 710 pcim_iounmap(pdev, iomap[i]); 711 pci_release_region(pdev, i); 712 } 713 714 return rc; 715 } 716 EXPORT_SYMBOL(pcim_iomap_regions); 
  Note:
 See   TracChangeset
 for help on using the changeset viewer.
  
