Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031557AbbDXR0f (ORCPT ); Fri, 24 Apr 2015 13:26:35 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:44309 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031567AbbDXRW1 (ORCPT ); Fri, 24 Apr 2015 13:22:27 -0400 From: Michael Grzeschik To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH 19/21] ARCNET: com20020: add enable and disable device on open/close Date: Fri, 24 Apr 2015 19:20:53 +0200 Message-Id: <1429896055-31680-20-git-send-email-m.grzeschik@pengutronix.de> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1429896055-31680-1-git-send-email-m.grzeschik@pengutronix.de> References: <1429896055-31680-1-git-send-email-m.grzeschik@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mgr@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3432 Lines: 99 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 --- drivers/net/arcnet/com20020.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c index 1dbc748..713eb5d 100644 --- a/drivers/net/arcnet/com20020.c +++ b/drivers/net/arcnet/com20020.c @@ -118,7 +118,7 @@ int com20020_check(struct net_device *dev) outb(STARTIOcmd, ioaddr + _COMMAND); } - lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; + lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; /* set node ID to 0x42 (but transmitter is disabled, so it's okay) */ outb(lp->config, ioaddr + _CONFIG); outb(0x42, ioaddr + _XREG); @@ -131,11 +131,6 @@ int com20020_check(struct net_device *dev) } BUGMSG(D_INIT_REASONS, "status after reset: %X\n", status); - /* Enable TX */ - lp->config |= TXENcfg; - outb(lp->config, ioaddr + _CONFIG); - outb(inb(ioaddr + 8), ioaddr + _XREG); - outb((CFLAGScmd | RESETclear | CONFIGclear), ioaddr + _COMMAND); status = inb(ioaddr + _STATUS); @@ -169,9 +164,33 @@ static int com20020_set_hwaddr(struct net_device *dev, void *addr) return 0; } +int com20020_netdev_open(struct net_device *dev) +{ + int ioaddr = dev->base_addr; + struct arcnet_local *lp = netdev_priv(dev); + + lp->config |= TXENcfg; + outb(lp->config, ioaddr + _CONFIG); + + return arcnet_open(dev); +} + +int com20020_netdev_close(struct net_device *dev) +{ + int ioaddr = dev->base_addr; + struct arcnet_local *lp = netdev_priv(dev); + + arcnet_close(dev); + + /* disable transmitter */ + lp->config &= ~TXENcfg; + outb(lp->config, ioaddr + _CONFIG); + return 0; +} + const struct net_device_ops com20020_netdev_ops = { - .ndo_open = arcnet_open, - .ndo_stop = arcnet_close, + .ndo_open = com20020_netdev_open, + .ndo_stop = com20020_netdev_close, .ndo_start_xmit = arcnet_send_packet, .ndo_tx_timeout = arcnet_timeout, .ndo_set_mac_address = com20020_set_hwaddr, @@ -216,8 +235,8 @@ int com20020_found(struct net_device *dev, int shared) outb(STARTIOcmd, ioaddr + _COMMAND); } - lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; - /* Default 0x38 + register: Node ID */ + lp->config = (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; + /* Default 0x18 + register: Node ID */ outb(lp->config, ioaddr + _CONFIG); outb(dev->dev_addr[0], ioaddr + _XREG); @@ -270,7 +289,7 @@ static int com20020_reset(struct net_device *dev, int really_reset) dev->name, inb(ioaddr + _STATUS)); BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__); - lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2); + lp->config |= (lp->timeout << 3) | (lp->backplane << 2); /* power-up defaults */ outb(lp->config, ioaddr + _CONFIG); BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__); -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/