aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/arm
diff options
context:
space:
mode:
authorAndrew Victor <andrew@sanpeople.com>2006-12-05 08:09:16 -0500
committerJeff Garzik <jeff@garzik.org>2006-12-07 04:58:32 -0500
commitc57ee096b6caf8f7e17abe46185d24f2b649b9f9 (patch)
treed2977aa4455fc852b0f1e366e990500369daa90a /drivers/net/arm
parent8d1413b28033c49c7f1a4d320e815d7a5531acee (diff)
[PATCH] AT91RM9200 Ethernet: Remove 'at91_dev' and use netdev_priv()
Remove the global 'at91_dev' variable. Use netdev_priv() instead of casting dev->priv directly. Signed-off-by: Andrew Victor <andrew@sanpeople.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/arm')
-rw-r--r--drivers/net/arm/at91_ether.c55
1 files changed, 25 insertions, 30 deletions
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c
index b54b857e357e..58da5b773350 100644
--- a/drivers/net/arm/at91_ether.c
+++ b/drivers/net/arm/at91_ether.c
@@ -41,8 +41,6 @@
41#define DRV_NAME "at91_ether" 41#define DRV_NAME "at91_ether"
42#define DRV_VERSION "1.0" 42#define DRV_VERSION "1.0"
43 43
44static struct net_device *at91_dev;
45
46static struct timer_list check_timer; 44static struct timer_list check_timer;
47#define LINK_POLL_INTERVAL (HZ) 45#define LINK_POLL_INTERVAL (HZ)
48 46
@@ -146,7 +144,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int
146 */ 144 */
147static void update_linkspeed(struct net_device *dev, int silent) 145static void update_linkspeed(struct net_device *dev, int silent)
148{ 146{
149 struct at91_private *lp = (struct at91_private *) dev->priv; 147 struct at91_private *lp = netdev_priv(dev);
150 unsigned int bmsr, bmcr, lpa, mac_cfg; 148 unsigned int bmsr, bmcr, lpa, mac_cfg;
151 unsigned int speed, duplex; 149 unsigned int speed, duplex;
152 150
@@ -199,7 +197,7 @@ static void update_linkspeed(struct net_device *dev, int silent)
199static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id) 197static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
200{ 198{
201 struct net_device *dev = (struct net_device *) dev_id; 199 struct net_device *dev = (struct net_device *) dev_id;
202 struct at91_private *lp = (struct at91_private *) dev->priv; 200 struct at91_private *lp = netdev_priv(dev);
203 unsigned int phy; 201 unsigned int phy;
204 202
205 /* 203 /*
@@ -242,7 +240,7 @@ done:
242 */ 240 */
243static void enable_phyirq(struct net_device *dev) 241static void enable_phyirq(struct net_device *dev)
244{ 242{
245 struct at91_private *lp = (struct at91_private *) dev->priv; 243 struct at91_private *lp = netdev_priv(dev);
246 unsigned int dsintr, irq_number; 244 unsigned int dsintr, irq_number;
247 int status; 245 int status;
248 246
@@ -294,7 +292,7 @@ static void enable_phyirq(struct net_device *dev)
294 */ 292 */
295static void disable_phyirq(struct net_device *dev) 293static void disable_phyirq(struct net_device *dev)
296{ 294{
297 struct at91_private *lp = (struct at91_private *) dev->priv; 295 struct at91_private *lp = netdev_priv(dev);
298 unsigned int dsintr; 296 unsigned int dsintr;
299 unsigned int irq_number; 297 unsigned int irq_number;
300 298
@@ -340,7 +338,7 @@ static void disable_phyirq(struct net_device *dev)
340#if 0 338#if 0
341static void reset_phy(struct net_device *dev) 339static void reset_phy(struct net_device *dev)
342{ 340{
343 struct at91_private *lp = (struct at91_private *) dev->priv; 341 struct at91_private *lp = netdev_priv(dev);
344 unsigned int bmcr; 342 unsigned int bmcr;
345 343
346 spin_lock_irq(&lp->lock); 344 spin_lock_irq(&lp->lock);
@@ -590,7 +588,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val
590 588
591static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 589static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
592{ 590{
593 struct at91_private *lp = (struct at91_private *) dev->priv; 591 struct at91_private *lp = netdev_priv(dev);
594 int ret; 592 int ret;
595 593
596 spin_lock_irq(&lp->lock); 594 spin_lock_irq(&lp->lock);
@@ -611,7 +609,7 @@ static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm
611 609
612static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 610static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
613{ 611{
614 struct at91_private *lp = (struct at91_private *) dev->priv; 612 struct at91_private *lp = netdev_priv(dev);
615 int ret; 613 int ret;
616 614
617 spin_lock_irq(&lp->lock); 615 spin_lock_irq(&lp->lock);
@@ -627,7 +625,7 @@ static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm
627 625
628static int at91ether_nwayreset(struct net_device *dev) 626static int at91ether_nwayreset(struct net_device *dev)
629{ 627{
630 struct at91_private *lp = (struct at91_private *) dev->priv; 628 struct at91_private *lp = netdev_priv(dev);
631 int ret; 629 int ret;
632 630
633 spin_lock_irq(&lp->lock); 631 spin_lock_irq(&lp->lock);
@@ -658,7 +656,7 @@ static const struct ethtool_ops at91ether_ethtool_ops = {
658 656
659static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 657static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
660{ 658{
661 struct at91_private *lp = (struct at91_private *) dev->priv; 659 struct at91_private *lp = netdev_priv(dev);
662 int res; 660 int res;
663 661
664 if (!netif_running(dev)) 662 if (!netif_running(dev))
@@ -680,7 +678,7 @@ static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
680 */ 678 */
681static void at91ether_start(struct net_device *dev) 679static void at91ether_start(struct net_device *dev)
682{ 680{
683 struct at91_private *lp = (struct at91_private *) dev->priv; 681 struct at91_private *lp = netdev_priv(dev);
684 struct recv_desc_bufs *dlist, *dlist_phys; 682 struct recv_desc_bufs *dlist, *dlist_phys;
685 int i; 683 int i;
686 unsigned long ctl; 684 unsigned long ctl;
@@ -712,7 +710,7 @@ static void at91ether_start(struct net_device *dev)
712 */ 710 */
713static int at91ether_open(struct net_device *dev) 711static int at91ether_open(struct net_device *dev)
714{ 712{
715 struct at91_private *lp = (struct at91_private *) dev->priv; 713 struct at91_private *lp = netdev_priv(dev);
716 unsigned long ctl; 714 unsigned long ctl;
717 715
718 if (!is_valid_ether_addr(dev->dev_addr)) 716 if (!is_valid_ether_addr(dev->dev_addr))
@@ -752,7 +750,7 @@ static int at91ether_open(struct net_device *dev)
752 */ 750 */
753static int at91ether_close(struct net_device *dev) 751static int at91ether_close(struct net_device *dev)
754{ 752{
755 struct at91_private *lp = (struct at91_private *) dev->priv; 753 struct at91_private *lp = netdev_priv(dev);
756 unsigned long ctl; 754 unsigned long ctl;
757 755
758 /* Disable Receiver and Transmitter */ 756 /* Disable Receiver and Transmitter */
@@ -779,7 +777,7 @@ static int at91ether_close(struct net_device *dev)
779 */ 777 */
780static int at91ether_tx(struct sk_buff *skb, struct net_device *dev) 778static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
781{ 779{
782 struct at91_private *lp = (struct at91_private *) dev->priv; 780 struct at91_private *lp = netdev_priv(dev);
783 781
784 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) { 782 if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) {
785 netif_stop_queue(dev); 783 netif_stop_queue(dev);
@@ -811,7 +809,7 @@ static int at91ether_tx(struct sk_buff *skb, struct net_device *dev)
811 */ 809 */
812static struct net_device_stats *at91ether_stats(struct net_device *dev) 810static struct net_device_stats *at91ether_stats(struct net_device *dev)
813{ 811{
814 struct at91_private *lp = (struct at91_private *) dev->priv; 812 struct at91_private *lp = netdev_priv(dev);
815 int ale, lenerr, seqe, lcol, ecol; 813 int ale, lenerr, seqe, lcol, ecol;
816 814
817 if (netif_running(dev)) { 815 if (netif_running(dev)) {
@@ -847,7 +845,7 @@ static struct net_device_stats *at91ether_stats(struct net_device *dev)
847 */ 845 */
848static void at91ether_rx(struct net_device *dev) 846static void at91ether_rx(struct net_device *dev)
849{ 847{
850 struct at91_private *lp = (struct at91_private *) dev->priv; 848 struct at91_private *lp = netdev_priv(dev);
851 struct recv_desc_bufs *dlist; 849 struct recv_desc_bufs *dlist;
852 unsigned char *p_recv; 850 unsigned char *p_recv;
853 struct sk_buff *skb; 851 struct sk_buff *skb;
@@ -891,7 +889,7 @@ static void at91ether_rx(struct net_device *dev)
891static irqreturn_t at91ether_interrupt(int irq, void *dev_id) 889static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
892{ 890{
893 struct net_device *dev = (struct net_device *) dev_id; 891 struct net_device *dev = (struct net_device *) dev_id;
894 struct at91_private *lp = (struct at91_private *) dev->priv; 892 struct at91_private *lp = netdev_priv(dev);
895 unsigned long intstatus, ctl; 893 unsigned long intstatus, ctl;
896 894
897 /* MAC Interrupt Status register indicates what interrupts are pending. 895 /* MAC Interrupt Status register indicates what interrupts are pending.
@@ -939,9 +937,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
939 unsigned int val; 937 unsigned int val;
940 int res; 938 int res;
941 939
942 if (at91_dev) /* already initialized */
943 return 0;
944
945 dev = alloc_etherdev(sizeof(struct at91_private)); 940 dev = alloc_etherdev(sizeof(struct at91_private));
946 if (!dev) 941 if (!dev)
947 return -ENOMEM; 942 return -ENOMEM;
@@ -957,7 +952,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
957 } 952 }
958 953
959 /* Allocate memory for DMA Receive descriptors */ 954 /* Allocate memory for DMA Receive descriptors */
960 lp = (struct at91_private *)dev->priv; 955 lp = netdev_priv(dev);
961 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL); 956 lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL);
962 if (lp->dlist == NULL) { 957 if (lp->dlist == NULL) {
963 free_irq(dev->irq, dev); 958 free_irq(dev->irq, dev);
@@ -1024,7 +1019,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add
1024 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); 1019 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1025 return res; 1020 return res;
1026 } 1021 }
1027 at91_dev = dev;
1028 1022
1029 /* Determine current link speed */ 1023 /* Determine current link speed */
1030 spin_lock_irq(&lp->lock); 1024 spin_lock_irq(&lp->lock);
@@ -1115,15 +1109,16 @@ static int __init at91ether_probe(struct platform_device *pdev)
1115 1109
1116static int __devexit at91ether_remove(struct platform_device *pdev) 1110static int __devexit at91ether_remove(struct platform_device *pdev)
1117{ 1111{
1118 struct at91_private *lp = (struct at91_private *) at91_dev->priv; 1112 struct net_device *dev = platform_get_drvdata(pdev);
1113 struct at91_private *lp = netdev_priv(dev);
1119 1114
1120 unregister_netdev(at91_dev); 1115 unregister_netdev(dev);
1121 free_irq(at91_dev->irq, at91_dev); 1116 free_irq(dev->irq, dev);
1122 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); 1117 dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys);
1123 clk_put(lp->ether_clk); 1118 clk_put(lp->ether_clk);
1124 1119
1125 free_netdev(at91_dev); 1120 platform_set_drvdata(pdev, NULL);
1126 at91_dev = NULL; 1121 free_netdev(dev);
1127 return 0; 1122 return 0;
1128} 1123}
1129 1124
@@ -1131,8 +1126,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
1131 1126
1132static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg) 1127static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1133{ 1128{
1134 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1135 struct net_device *net_dev = platform_get_drvdata(pdev); 1129 struct net_device *net_dev = platform_get_drvdata(pdev);
1130 struct at91_private *lp = netdev_priv(net_dev);
1136 int phy_irq = lp->board_data.phy_irq_pin; 1131 int phy_irq = lp->board_data.phy_irq_pin;
1137 1132
1138 if (netif_running(net_dev)) { 1133 if (netif_running(net_dev)) {
@@ -1149,8 +1144,8 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
1149 1144
1150static int at91ether_resume(struct platform_device *pdev) 1145static int at91ether_resume(struct platform_device *pdev)
1151{ 1146{
1152 struct at91_private *lp = (struct at91_private *) at91_dev->priv;
1153 struct net_device *net_dev = platform_get_drvdata(pdev); 1147 struct net_device *net_dev = platform_get_drvdata(pdev);
1148 struct at91_private *lp = netdev_priv(net_dev);
1154 int phy_irq = lp->board_data.phy_irq_pin; 1149 int phy_irq = lp->board_data.phy_irq_pin;
1155 1150
1156 if (netif_running(net_dev)) { 1151 if (netif_running(net_dev)) {