diff options
author | Atsushi Nemoto <anemo@mba.ocn.ne.jp> | 2008-04-10 11:24:45 -0400 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2008-04-16 20:06:49 -0400 |
commit | 22adf7e536df12b1793448972c908cb21ea5a17a (patch) | |
tree | 7841fb16c4693e5e5bde2eba6e2dd3880938e39e /drivers/net/tc35815.c | |
parent | ee79b7fbf0dbb9e6392d0aee73bf722b29e43c40 (diff) |
tc35815: Use managed pci iomap helper
Use managed pci functions and kill unnecessary volatiles.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/tc35815.c')
-rw-r--r-- | drivers/net/tc35815.c | 121 |
1 files changed, 38 insertions, 83 deletions
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c index 5f4a14fd564f..60eff784d5e4 100644 --- a/drivers/net/tc35815.c +++ b/drivers/net/tc35815.c | |||
@@ -94,37 +94,37 @@ static struct tc35815_options { | |||
94 | * Registers | 94 | * Registers |
95 | */ | 95 | */ |
96 | struct tc35815_regs { | 96 | struct tc35815_regs { |
97 | volatile __u32 DMA_Ctl; /* 0x00 */ | 97 | __u32 DMA_Ctl; /* 0x00 */ |
98 | volatile __u32 TxFrmPtr; | 98 | __u32 TxFrmPtr; |
99 | volatile __u32 TxThrsh; | 99 | __u32 TxThrsh; |
100 | volatile __u32 TxPollCtr; | 100 | __u32 TxPollCtr; |
101 | volatile __u32 BLFrmPtr; | 101 | __u32 BLFrmPtr; |
102 | volatile __u32 RxFragSize; | 102 | __u32 RxFragSize; |
103 | volatile __u32 Int_En; | 103 | __u32 Int_En; |
104 | volatile __u32 FDA_Bas; | 104 | __u32 FDA_Bas; |
105 | volatile __u32 FDA_Lim; /* 0x20 */ | 105 | __u32 FDA_Lim; /* 0x20 */ |
106 | volatile __u32 Int_Src; | 106 | __u32 Int_Src; |
107 | volatile __u32 unused0[2]; | 107 | __u32 unused0[2]; |
108 | volatile __u32 PauseCnt; | 108 | __u32 PauseCnt; |
109 | volatile __u32 RemPauCnt; | 109 | __u32 RemPauCnt; |
110 | volatile __u32 TxCtlFrmStat; | 110 | __u32 TxCtlFrmStat; |
111 | volatile __u32 unused1; | 111 | __u32 unused1; |
112 | volatile __u32 MAC_Ctl; /* 0x40 */ | 112 | __u32 MAC_Ctl; /* 0x40 */ |
113 | volatile __u32 CAM_Ctl; | 113 | __u32 CAM_Ctl; |
114 | volatile __u32 Tx_Ctl; | 114 | __u32 Tx_Ctl; |
115 | volatile __u32 Tx_Stat; | 115 | __u32 Tx_Stat; |
116 | volatile __u32 Rx_Ctl; | 116 | __u32 Rx_Ctl; |
117 | volatile __u32 Rx_Stat; | 117 | __u32 Rx_Stat; |
118 | volatile __u32 MD_Data; | 118 | __u32 MD_Data; |
119 | volatile __u32 MD_CA; | 119 | __u32 MD_CA; |
120 | volatile __u32 CAM_Adr; /* 0x60 */ | 120 | __u32 CAM_Adr; /* 0x60 */ |
121 | volatile __u32 CAM_Data; | 121 | __u32 CAM_Data; |
122 | volatile __u32 CAM_Ena; | 122 | __u32 CAM_Ena; |
123 | volatile __u32 PROM_Ctl; | 123 | __u32 PROM_Ctl; |
124 | volatile __u32 PROM_Data; | 124 | __u32 PROM_Data; |
125 | volatile __u32 Algn_Cnt; | 125 | __u32 Algn_Cnt; |
126 | volatile __u32 CRC_Cnt; | 126 | __u32 CRC_Cnt; |
127 | volatile __u32 Miss_Cnt; | 127 | __u32 Miss_Cnt; |
128 | }; | 128 | }; |
129 | 129 | ||
130 | /* | 130 | /* |
@@ -396,8 +396,8 @@ struct FrFD { | |||
396 | }; | 396 | }; |
397 | 397 | ||
398 | 398 | ||
399 | #define tc_readl(addr) readl(addr) | 399 | #define tc_readl(addr) ioread32(addr) |
400 | #define tc_writel(d, addr) writel(d, addr) | 400 | #define tc_writel(d, addr) iowrite32(d, addr) |
401 | 401 | ||
402 | #define TC35815_TX_TIMEOUT msecs_to_jiffies(400) | 402 | #define TC35815_TX_TIMEOUT msecs_to_jiffies(400) |
403 | 403 | ||
@@ -663,7 +663,6 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev, | |||
663 | struct net_device *dev; | 663 | struct net_device *dev; |
664 | struct tc35815_local *lp; | 664 | struct tc35815_local *lp; |
665 | int rc; | 665 | int rc; |
666 | unsigned long mmio_start, mmio_end, mmio_flags, mmio_len; | ||
667 | DECLARE_MAC_BUF(mac); | 666 | DECLARE_MAC_BUF(mac); |
668 | 667 | ||
669 | static int printed_version; | 668 | static int printed_version; |
@@ -690,45 +689,14 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev, | |||
690 | lp->dev = dev; | 689 | lp->dev = dev; |
691 | 690 | ||
692 | /* enable device (incl. PCI PM wakeup), and bus-mastering */ | 691 | /* enable device (incl. PCI PM wakeup), and bus-mastering */ |
693 | rc = pci_enable_device (pdev); | 692 | rc = pcim_enable_device(pdev); |
694 | if (rc) | 693 | if (rc) |
695 | goto err_out; | 694 | goto err_out; |
696 | 695 | rc = pcim_iomap_regions(pdev, 1 << 1, MODNAME); | |
697 | mmio_start = pci_resource_start (pdev, 1); | ||
698 | mmio_end = pci_resource_end (pdev, 1); | ||
699 | mmio_flags = pci_resource_flags (pdev, 1); | ||
700 | mmio_len = pci_resource_len (pdev, 1); | ||
701 | |||
702 | /* set this immediately, we need to know before | ||
703 | * we talk to the chip directly */ | ||
704 | |||
705 | /* make sure PCI base addr 1 is MMIO */ | ||
706 | if (!(mmio_flags & IORESOURCE_MEM)) { | ||
707 | dev_err(&pdev->dev, "region #1 not an MMIO resource, aborting\n"); | ||
708 | rc = -ENODEV; | ||
709 | goto err_out; | ||
710 | } | ||
711 | |||
712 | /* check for weird/broken PCI region reporting */ | ||
713 | if ((mmio_len < sizeof(struct tc35815_regs))) { | ||
714 | dev_err(&pdev->dev, "Invalid PCI region size(s), aborting\n"); | ||
715 | rc = -ENODEV; | ||
716 | goto err_out; | ||
717 | } | ||
718 | |||
719 | rc = pci_request_regions (pdev, MODNAME); | ||
720 | if (rc) | 696 | if (rc) |
721 | goto err_out; | 697 | goto err_out; |
722 | 698 | pci_set_master(pdev); | |
723 | pci_set_master (pdev); | 699 | ioaddr = pcim_iomap_table(pdev)[1]; |
724 | |||
725 | /* ioremap MMIO region */ | ||
726 | ioaddr = ioremap (mmio_start, mmio_len); | ||
727 | if (ioaddr == NULL) { | ||
728 | dev_err(&pdev->dev, "cannot remap MMIO, aborting\n"); | ||
729 | rc = -EIO; | ||
730 | goto err_out_free_res; | ||
731 | } | ||
732 | 700 | ||
733 | /* Initialize the device structure. */ | 701 | /* Initialize the device structure. */ |
734 | dev->open = tc35815_open; | 702 | dev->open = tc35815_open; |
@@ -768,7 +736,7 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev, | |||
768 | 736 | ||
769 | rc = register_netdev (dev); | 737 | rc = register_netdev (dev); |
770 | if (rc) | 738 | if (rc) |
771 | goto err_out_unmap; | 739 | goto err_out; |
772 | 740 | ||
773 | memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); | 741 | memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); |
774 | printk(KERN_INFO "%s: %s at 0x%lx, %s, IRQ %d\n", | 742 | printk(KERN_INFO "%s: %s at 0x%lx, %s, IRQ %d\n", |
@@ -791,10 +759,6 @@ static int __devinit tc35815_init_one (struct pci_dev *pdev, | |||
791 | 759 | ||
792 | return 0; | 760 | return 0; |
793 | 761 | ||
794 | err_out_unmap: | ||
795 | iounmap(ioaddr); | ||
796 | err_out_free_res: | ||
797 | pci_release_regions (pdev); | ||
798 | err_out: | 762 | err_out: |
799 | free_netdev (dev); | 763 | free_netdev (dev); |
800 | return rc; | 764 | return rc; |
@@ -804,17 +768,8 @@ err_out: | |||
804 | static void __devexit tc35815_remove_one (struct pci_dev *pdev) | 768 | static void __devexit tc35815_remove_one (struct pci_dev *pdev) |
805 | { | 769 | { |
806 | struct net_device *dev = pci_get_drvdata (pdev); | 770 | struct net_device *dev = pci_get_drvdata (pdev); |
807 | unsigned long mmio_addr; | ||
808 | |||
809 | mmio_addr = dev->base_addr; | ||
810 | 771 | ||
811 | unregister_netdev (dev); | 772 | unregister_netdev (dev); |
812 | |||
813 | if (mmio_addr) { | ||
814 | iounmap ((void __iomem *)mmio_addr); | ||
815 | pci_release_regions (pdev); | ||
816 | } | ||
817 | |||
818 | free_netdev (dev); | 773 | free_netdev (dev); |
819 | 774 | ||
820 | pci_set_drvdata (pdev, NULL); | 775 | pci_set_drvdata (pdev, NULL); |