Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <m.grzeschik@pengutronix.de>

+29 -10
+29 -10
drivers/net/arcnet/com20020.c
··· 118 118 arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND); 119 119 } 120 120 121 - lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; 121 + lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; 122 122 /* set node ID to 0x42 (but transmitter is disabled, so it's okay) */ 123 123 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 124 124 arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG); ··· 130 130 return -ENODEV; 131 131 } 132 132 arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status); 133 - 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 133 139 134 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear, 140 135 ioaddr, COM20020_REG_W_COMMAND); ··· 164 169 return 0; 165 170 } 166 171 172 + static int com20020_netdev_open(struct net_device *dev) 173 + { 174 + int ioaddr = dev->base_addr; 175 + struct arcnet_local *lp = netdev_priv(dev); 176 + 177 + lp->config |= TXENcfg; 178 + arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 179 + 180 + return arcnet_open(dev); 181 + } 182 + 183 + static int com20020_netdev_close(struct net_device *dev) 184 + { 185 + int ioaddr = dev->base_addr; 186 + struct arcnet_local *lp = netdev_priv(dev); 187 + 188 + arcnet_close(dev); 189 + 190 + /* disable transmitter */ 191 + lp->config &= ~TXENcfg; 192 + arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 193 + return 0; 194 + } 195 + 167 196 const struct net_device_ops com20020_netdev_ops = { 168 - .ndo_open = arcnet_open, 169 - .ndo_stop = arcnet_close, 197 + .ndo_open = com20020_netdev_open, 198 + .ndo_stop = com20020_netdev_close, 170 199 .ndo_start_xmit = arcnet_send_packet, 171 200 .ndo_tx_timeout = arcnet_timeout, 172 201 .ndo_set_mac_address = com20020_set_hwaddr, ··· 234 215 arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND); 235 216 } 236 217 237 - lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; 218 + lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; 238 219 /* Default 0x38 + register: Node ID */ 239 220 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 240 221 arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG); ··· 293 274 dev->name, arcnet_inb(ioaddr, COM20020_REG_R_STATUS)); 294 275 295 276 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__); 296 - lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2); 277 + lp->config |= (lp->timeout << 3) | (lp->backplane << 2); 297 278 /* power-up defaults */ 298 279 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 299 280 arc_printk(D_DEBUG, dev, "%s: %d: %s\n", __FILE__, __LINE__, __func__);