diff options
author | Francois Romieu <romieu@fr.zoreil.com> | 2012-03-09 05:58:46 -0500 |
---|---|---|
committer | Francois Romieu <romieu@fr.zoreil.com> | 2012-04-07 05:47:17 -0400 |
commit | 65712ec016788538d27c0b0452e57b751776914e (patch) | |
tree | e074104a50698a3954783235d54403fbd6fade8d /drivers/net/ethernet/realtek/8139too.c | |
parent | d710ce135731c101b6fc131c07f3db0cdb0d95fd (diff) |
8139too: dev->{base_addr, irq} removal.
Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Diffstat (limited to 'drivers/net/ethernet/realtek/8139too.c')
-rw-r--r-- | drivers/net/ethernet/realtek/8139too.c | 136 |
1 files changed, 56 insertions, 80 deletions
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c index df7fd8d083dc..03df076ed596 100644 --- a/drivers/net/ethernet/realtek/8139too.c +++ b/drivers/net/ethernet/realtek/8139too.c | |||
@@ -148,9 +148,9 @@ static int full_duplex[MAX_UNITS] = {-1, -1, -1, -1, -1, -1, -1, -1}; | |||
148 | 148 | ||
149 | /* Whether to use MMIO or PIO. Default to MMIO. */ | 149 | /* Whether to use MMIO or PIO. Default to MMIO. */ |
150 | #ifdef CONFIG_8139TOO_PIO | 150 | #ifdef CONFIG_8139TOO_PIO |
151 | static int use_io = 1; | 151 | static bool use_io = true; |
152 | #else | 152 | #else |
153 | static int use_io = 0; | 153 | static bool use_io = false; |
154 | #endif | 154 | #endif |
155 | 155 | ||
156 | /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). | 156 | /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). |
@@ -620,7 +620,7 @@ MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver"); | |||
620 | MODULE_LICENSE("GPL"); | 620 | MODULE_LICENSE("GPL"); |
621 | MODULE_VERSION(DRV_VERSION); | 621 | MODULE_VERSION(DRV_VERSION); |
622 | 622 | ||
623 | module_param(use_io, int, 0); | 623 | module_param(use_io, bool, 0); |
624 | MODULE_PARM_DESC(use_io, "Force use of I/O access mode. 0=MMIO 1=PIO"); | 624 | MODULE_PARM_DESC(use_io, "Force use of I/O access mode. 0=MMIO 1=PIO"); |
625 | module_param(multicast_filter_limit, int, 0); | 625 | module_param(multicast_filter_limit, int, 0); |
626 | module_param_array(media, int, NULL, 0); | 626 | module_param_array(media, int, NULL, 0); |
@@ -750,15 +750,22 @@ static void rtl8139_chip_reset (void __iomem *ioaddr) | |||
750 | 750 | ||
751 | static __devinit struct net_device * rtl8139_init_board (struct pci_dev *pdev) | 751 | static __devinit struct net_device * rtl8139_init_board (struct pci_dev *pdev) |
752 | { | 752 | { |
753 | struct device *d = &pdev->dev; | ||
753 | void __iomem *ioaddr; | 754 | void __iomem *ioaddr; |
754 | struct net_device *dev; | 755 | struct net_device *dev; |
755 | struct rtl8139_private *tp; | 756 | struct rtl8139_private *tp; |
756 | u8 tmp8; | 757 | u8 tmp8; |
757 | int rc, disable_dev_on_err = 0; | 758 | int rc, disable_dev_on_err = 0; |
758 | unsigned int i; | 759 | unsigned int i, bar; |
759 | unsigned long pio_start, pio_end, pio_flags, pio_len; | 760 | unsigned long io_len; |
760 | unsigned long mmio_start, mmio_end, mmio_flags, mmio_len; | ||
761 | u32 version; | 761 | u32 version; |
762 | static const struct { | ||
763 | unsigned long mask; | ||
764 | char *type; | ||
765 | } res[] = { | ||
766 | { IORESOURCE_IO, "PIO" }, | ||
767 | { IORESOURCE_MEM, "MMIO" } | ||
768 | }; | ||
762 | 769 | ||
763 | assert (pdev != NULL); | 770 | assert (pdev != NULL); |
764 | 771 | ||
@@ -777,78 +784,45 @@ static __devinit struct net_device * rtl8139_init_board (struct pci_dev *pdev) | |||
777 | if (rc) | 784 | if (rc) |
778 | goto err_out; | 785 | goto err_out; |
779 | 786 | ||
780 | pio_start = pci_resource_start (pdev, 0); | ||
781 | pio_end = pci_resource_end (pdev, 0); | ||
782 | pio_flags = pci_resource_flags (pdev, 0); | ||
783 | pio_len = pci_resource_len (pdev, 0); | ||
784 | |||
785 | mmio_start = pci_resource_start (pdev, 1); | ||
786 | mmio_end = pci_resource_end (pdev, 1); | ||
787 | mmio_flags = pci_resource_flags (pdev, 1); | ||
788 | mmio_len = pci_resource_len (pdev, 1); | ||
789 | |||
790 | /* set this immediately, we need to know before | ||
791 | * we talk to the chip directly */ | ||
792 | pr_debug("PIO region size == 0x%02lX\n", pio_len); | ||
793 | pr_debug("MMIO region size == 0x%02lX\n", mmio_len); | ||
794 | |||
795 | retry: | ||
796 | if (use_io) { | ||
797 | /* make sure PCI base addr 0 is PIO */ | ||
798 | if (!(pio_flags & IORESOURCE_IO)) { | ||
799 | dev_err(&pdev->dev, "region #0 not a PIO resource, aborting\n"); | ||
800 | rc = -ENODEV; | ||
801 | goto err_out; | ||
802 | } | ||
803 | /* check for weird/broken PCI region reporting */ | ||
804 | if (pio_len < RTL_MIN_IO_SIZE) { | ||
805 | dev_err(&pdev->dev, "Invalid PCI I/O region size(s), aborting\n"); | ||
806 | rc = -ENODEV; | ||
807 | goto err_out; | ||
808 | } | ||
809 | } else { | ||
810 | /* make sure PCI base addr 1 is MMIO */ | ||
811 | if (!(mmio_flags & IORESOURCE_MEM)) { | ||
812 | dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n"); | ||
813 | rc = -ENODEV; | ||
814 | goto err_out; | ||
815 | } | ||
816 | if (mmio_len < RTL_MIN_IO_SIZE) { | ||
817 | dev_err(&pdev->dev, "Invalid PCI mem region size(s), aborting\n"); | ||
818 | rc = -ENODEV; | ||
819 | goto err_out; | ||
820 | } | ||
821 | } | ||
822 | |||
823 | rc = pci_request_regions (pdev, DRV_NAME); | 787 | rc = pci_request_regions (pdev, DRV_NAME); |
824 | if (rc) | 788 | if (rc) |
825 | goto err_out; | 789 | goto err_out; |
826 | disable_dev_on_err = 1; | 790 | disable_dev_on_err = 1; |
827 | 791 | ||
828 | /* enable PCI bus-mastering */ | ||
829 | pci_set_master (pdev); | 792 | pci_set_master (pdev); |
830 | 793 | ||
831 | if (use_io) { | 794 | retry: |
832 | ioaddr = pci_iomap(pdev, 0, 0); | 795 | /* PIO bar register comes first. */ |
833 | if (!ioaddr) { | 796 | bar = !use_io; |
834 | dev_err(&pdev->dev, "cannot map PIO, aborting\n"); | 797 | |
835 | rc = -EIO; | 798 | io_len = pci_resource_len(pdev, bar); |
836 | goto err_out; | 799 | |
837 | } | 800 | dev_dbg(d, "%s region size = 0x%02lX\n", res[bar].type, io_len); |
838 | dev->base_addr = pio_start; | 801 | |
839 | tp->regs_len = pio_len; | 802 | if (!(pci_resource_flags(pdev, bar) & res[bar].mask)) { |
840 | } else { | 803 | dev_err(d, "region #%d not a %s resource, aborting\n", bar, |
841 | /* ioremap MMIO region */ | 804 | res[bar].type); |
842 | ioaddr = pci_iomap(pdev, 1, 0); | 805 | rc = -ENODEV; |
843 | if (ioaddr == NULL) { | 806 | goto err_out; |
844 | dev_err(&pdev->dev, "cannot remap MMIO, trying PIO\n"); | 807 | } |
845 | pci_release_regions(pdev); | 808 | if (io_len < RTL_MIN_IO_SIZE) { |
846 | use_io = 1; | 809 | dev_err(d, "Invalid PCI %s region size(s), aborting\n", |
810 | res[bar].type); | ||
811 | rc = -ENODEV; | ||
812 | goto err_out; | ||
813 | } | ||
814 | |||
815 | ioaddr = pci_iomap(pdev, bar, 0); | ||
816 | if (!ioaddr) { | ||
817 | dev_err(d, "cannot map %s\n", res[bar].type); | ||
818 | if (!use_io) { | ||
819 | use_io = true; | ||
847 | goto retry; | 820 | goto retry; |
848 | } | 821 | } |
849 | dev->base_addr = (long) ioaddr; | 822 | rc = -ENODEV; |
850 | tp->regs_len = mmio_len; | 823 | goto err_out; |
851 | } | 824 | } |
825 | tp->regs_len = io_len; | ||
852 | tp->mmio_addr = ioaddr; | 826 | tp->mmio_addr = ioaddr; |
853 | 827 | ||
854 | /* Bring old chips out of low-power mode. */ | 828 | /* Bring old chips out of low-power mode. */ |
@@ -1035,8 +1009,6 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev, | |||
1035 | dev->hw_features |= NETIF_F_RXALL; | 1009 | dev->hw_features |= NETIF_F_RXALL; |
1036 | dev->hw_features |= NETIF_F_RXFCS; | 1010 | dev->hw_features |= NETIF_F_RXFCS; |
1037 | 1011 | ||
1038 | dev->irq = pdev->irq; | ||
1039 | |||
1040 | /* tp zeroed and aligned in alloc_etherdev */ | 1012 | /* tp zeroed and aligned in alloc_etherdev */ |
1041 | tp = netdev_priv(dev); | 1013 | tp = netdev_priv(dev); |
1042 | 1014 | ||
@@ -1062,9 +1034,9 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev, | |||
1062 | 1034 | ||
1063 | pci_set_drvdata (pdev, dev); | 1035 | pci_set_drvdata (pdev, dev); |
1064 | 1036 | ||
1065 | netdev_info(dev, "%s at 0x%lx, %pM, IRQ %d\n", | 1037 | netdev_info(dev, "%s at 0x%p, %pM, IRQ %d\n", |
1066 | board_info[ent->driver_data].name, | 1038 | board_info[ent->driver_data].name, |
1067 | dev->base_addr, dev->dev_addr, dev->irq); | 1039 | ioaddr, dev->dev_addr, pdev->irq); |
1068 | 1040 | ||
1069 | netdev_dbg(dev, "Identified 8139 chip type '%s'\n", | 1041 | netdev_dbg(dev, "Identified 8139 chip type '%s'\n", |
1070 | rtl_chip_info[tp->chipset].name); | 1042 | rtl_chip_info[tp->chipset].name); |
@@ -1339,10 +1311,11 @@ static void mdio_write (struct net_device *dev, int phy_id, int location, | |||
1339 | static int rtl8139_open (struct net_device *dev) | 1311 | static int rtl8139_open (struct net_device *dev) |
1340 | { | 1312 | { |
1341 | struct rtl8139_private *tp = netdev_priv(dev); | 1313 | struct rtl8139_private *tp = netdev_priv(dev); |
1342 | int retval; | ||
1343 | void __iomem *ioaddr = tp->mmio_addr; | 1314 | void __iomem *ioaddr = tp->mmio_addr; |
1315 | const int irq = tp->pci_dev->irq; | ||
1316 | int retval; | ||
1344 | 1317 | ||
1345 | retval = request_irq (dev->irq, rtl8139_interrupt, IRQF_SHARED, dev->name, dev); | 1318 | retval = request_irq(irq, rtl8139_interrupt, IRQF_SHARED, dev->name, dev); |
1346 | if (retval) | 1319 | if (retval) |
1347 | return retval; | 1320 | return retval; |
1348 | 1321 | ||
@@ -1351,7 +1324,7 @@ static int rtl8139_open (struct net_device *dev) | |||
1351 | tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN, | 1324 | tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN, |
1352 | &tp->rx_ring_dma, GFP_KERNEL); | 1325 | &tp->rx_ring_dma, GFP_KERNEL); |
1353 | if (tp->tx_bufs == NULL || tp->rx_ring == NULL) { | 1326 | if (tp->tx_bufs == NULL || tp->rx_ring == NULL) { |
1354 | free_irq(dev->irq, dev); | 1327 | free_irq(irq, dev); |
1355 | 1328 | ||
1356 | if (tp->tx_bufs) | 1329 | if (tp->tx_bufs) |
1357 | dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN, | 1330 | dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN, |
@@ -1377,7 +1350,7 @@ static int rtl8139_open (struct net_device *dev) | |||
1377 | "%s() ioaddr %#llx IRQ %d GP Pins %02x %s-duplex\n", | 1350 | "%s() ioaddr %#llx IRQ %d GP Pins %02x %s-duplex\n", |
1378 | __func__, | 1351 | __func__, |
1379 | (unsigned long long)pci_resource_start (tp->pci_dev, 1), | 1352 | (unsigned long long)pci_resource_start (tp->pci_dev, 1), |
1380 | dev->irq, RTL_R8 (MediaStatus), | 1353 | irq, RTL_R8 (MediaStatus), |
1381 | tp->mii.full_duplex ? "full" : "half"); | 1354 | tp->mii.full_duplex ? "full" : "half"); |
1382 | 1355 | ||
1383 | rtl8139_start_thread(tp); | 1356 | rtl8139_start_thread(tp); |
@@ -2240,9 +2213,12 @@ static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance) | |||
2240 | */ | 2213 | */ |
2241 | static void rtl8139_poll_controller(struct net_device *dev) | 2214 | static void rtl8139_poll_controller(struct net_device *dev) |
2242 | { | 2215 | { |
2243 | disable_irq(dev->irq); | 2216 | struct rtl8139_private *tp = netdev_priv(dev); |
2244 | rtl8139_interrupt(dev->irq, dev); | 2217 | const int irq = tp->pci_dev->irq; |
2245 | enable_irq(dev->irq); | 2218 | |
2219 | disable_irq(irq); | ||
2220 | rtl8139_interrupt(irq, dev); | ||
2221 | enable_irq(irq); | ||
2246 | } | 2222 | } |
2247 | #endif | 2223 | #endif |
2248 | 2224 | ||
@@ -2295,7 +2271,7 @@ static int rtl8139_close (struct net_device *dev) | |||
2295 | 2271 | ||
2296 | spin_unlock_irqrestore (&tp->lock, flags); | 2272 | spin_unlock_irqrestore (&tp->lock, flags); |
2297 | 2273 | ||
2298 | free_irq (dev->irq, dev); | 2274 | free_irq(tp->pci_dev->irq, dev); |
2299 | 2275 | ||
2300 | rtl8139_tx_clear (tp); | 2276 | rtl8139_tx_clear (tp); |
2301 | 2277 | ||