Skip to content

Commit 27daf6e

Browse files
committed
arcnet: com20020: add enable and disable device on open/close
This patch changes the driver to properly work with the linux netif interface. The controller gets enabled on open and disabled on close. Therefor it removes every bogus start of the xceiver. It only gets enabled on com20020_open and disabled on com20020_close. Signed-off-by: Michael Grzeschik <[email protected]>
1 parent b82de0e commit 27daf6e

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

drivers/net/arcnet/com20020.c

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int com20020_check(struct net_device *dev)
118118
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
119119
}
120120

121-
lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
121+
lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
122122
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
123123
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
124124
arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
@@ -131,11 +131,6 @@ int com20020_check(struct net_device *dev)
131131
}
132132
arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
133133

134-
/* Enable TX */
135-
lp->config |= TXENcfg;
136-
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
137-
arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG);
138-
139134
arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
140135
ioaddr, COM20020_REG_W_COMMAND);
141136
status = arcnet_inb(ioaddr, COM20020_REG_R_STATUS);
@@ -169,9 +164,33 @@ static int com20020_set_hwaddr(struct net_device *dev, void *addr)
169164
return 0;
170165
}
171166

167+
static int com20020_netdev_open(struct net_device *dev)
168+
{
169+
int ioaddr = dev->base_addr;
170+
struct arcnet_local *lp = netdev_priv(dev);
171+
172+
lp->config |= TXENcfg;
173+
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
174+
175+
return arcnet_open(dev);
176+
}
177+
178+
static int com20020_netdev_close(struct net_device *dev)
179+
{
180+
int ioaddr = dev->base_addr;
181+
struct arcnet_local *lp = netdev_priv(dev);
182+
183+
arcnet_close(dev);
184+
185+
/* disable transmitter */
186+
lp->config &= ~TXENcfg;
187+
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
188+
return 0;
189+
}
190+
172191
const struct net_device_ops com20020_netdev_ops = {
173-
.ndo_open = arcnet_open,
174-
.ndo_stop = arcnet_close,
192+
.ndo_open = com20020_netdev_open,
193+
.ndo_stop = com20020_netdev_close,
175194
.ndo_start_xmit = arcnet_send_packet,
176195
.ndo_tx_timeout = arcnet_timeout,
177196
.ndo_set_mac_address = com20020_set_hwaddr,
@@ -215,7 +234,7 @@ int com20020_found(struct net_device *dev, int shared)
215234
arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND);
216235
}
217236

218-
lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
237+
lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
219238
/* Default 0x38 + register: Node ID */
220239
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
221240
arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
@@ -274,7 +293,7 @@ static int com20020_reset(struct net_device *dev, int really_reset)
274293
dev->name, arcnet_inb(ioaddr, COM20020_REG_R_STATUS));
275294

276295
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
277-
lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
296+
lp->config |= (lp->timeout << 3) | (lp->backplane << 2);
278297
/* power-up defaults */
279298
arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
280299
arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);

0 commit comments

Comments
 (0)