Root/target/linux/lantiq/patches-3.0/204-owrt-dm9000-polling.patch

1--- a/drivers/net/dm9000.c
2+++ b/drivers/net/dm9000.c
3@@ -19,6 +19,7 @@
4  * Sascha Hauer <s.hauer@pengutronix.de>
5  */
6 
7+#define DEBUG
8 #include <linux/module.h>
9 #include <linux/ioport.h>
10 #include <linux/netdevice.h>
11@@ -125,6 +126,8 @@ typedef struct board_info {
12     struct delayed_work phy_poll;
13     struct net_device *ndev;
14 
15+ struct delayed_work irq_poll; /* for use in irq polling mode */
16+
17     spinlock_t lock;
18 
19     struct mii_if_info mii;
20@@ -824,6 +827,8 @@ static void dm9000_timeout(struct net_de
21     netif_stop_queue(dev);
22     dm9000_reset(db);
23     dm9000_init_dm9000(dev);
24+ dm9000_reset(db);
25+ dm9000_init_dm9000(dev);
26     /* We can accept TX packets again */
27     dev->trans_start = jiffies; /* prevent tx timeout */
28     netif_wake_queue(dev);
29@@ -895,6 +900,12 @@ dm9000_start_xmit(struct sk_buff *skb, s
30     /* free this SKB */
31     dev_kfree_skb(skb);
32 
33+ /* directly poll afterwards */
34+ if (dev->irq == -1) {
35+ cancel_delayed_work(&db->irq_poll);
36+ schedule_delayed_work(&db->irq_poll, 1);
37+ }
38+
39     return NETDEV_TX_OK;
40 }
41 
42@@ -1136,6 +1147,18 @@ static void dm9000_poll_controller(struc
43 }
44 #endif
45 
46+static void dm9000_poll_irq(struct work_struct *w)
47+{
48+ struct delayed_work *dw = to_delayed_work(w);
49+ board_info_t *db = container_of(dw, board_info_t, irq_poll);
50+ struct net_device *ndev = db->ndev;
51+
52+ dm9000_interrupt(0, ndev);
53+
54+ if (netif_running(ndev))
55+ schedule_delayed_work(&db->irq_poll, HZ /100);
56+}
57+
58 /*
59  * Open the interface.
60  * The interface is opened whenever "ifconfig" actives it.
61@@ -1149,14 +1172,15 @@ dm9000_open(struct net_device *dev)
62     if (netif_msg_ifup(db))
63         dev_dbg(db->dev, "enabling %s\n", dev->name);
64 
65- /* If there is no IRQ type specified, default to something that
66- * may work, and tell the user that this is a problem */
67+ if (dev->irq != -1) {
68+ /* If there is no IRQ type specified, default to something that
69+ * may work, and tell the user that this is a problem */
70 
71- if (irqflags == IRQF_TRIGGER_NONE)
72- dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
73-
74- irqflags |= IRQF_SHARED;
75+ if (irqflags == IRQF_TRIGGER_NONE)
76+ dev_warn(db->dev, "WARNING: no IRQ resource flags set.\n");
77 
78+ irqflags |= IRQF_SHARED;
79+ }
80     /* GPIO0 on pre-activate PHY, Reg 1F is not set by reset */
81     iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */
82     mdelay(1); /* delay needs by DM9000B */
83@@ -1165,8 +1189,14 @@ dm9000_open(struct net_device *dev)
84     dm9000_reset(db);
85     dm9000_init_dm9000(dev);
86 
87- if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
88- return -EAGAIN;
89+ /* testing: init a second time */
90+ dm9000_reset(db);
91+ dm9000_init_dm9000(dev);
92+
93+ if (dev->irq != -1) {
94+ if (request_irq(dev->irq, dm9000_interrupt, irqflags, dev->name, dev))
95+ return -EAGAIN;
96+ }
97 
98     /* Init driver variable */
99     db->dbug_cnt = 0;
100@@ -1174,6 +1204,9 @@ dm9000_open(struct net_device *dev)
101     mii_check_media(&db->mii, netif_msg_link(db), 1);
102     netif_start_queue(dev);
103     
104+ if (dev->irq == -1)
105+ schedule_delayed_work(&db->irq_poll, HZ / 100);
106+
107     dm9000_schedule_poll(db);
108 
109     return 0;
110@@ -1371,6 +1404,7 @@ dm9000_probe(struct platform_device *pde
111     mutex_init(&db->addr_lock);
112 
113     INIT_DELAYED_WORK(&db->phy_poll, dm9000_poll_work);
114+ INIT_DELAYED_WORK(&db->irq_poll, dm9000_poll_irq);
115 
116     db->addr_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
117     db->data_res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
118

Archive Download this file



interactive