lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1429896055-31680-20-git-send-email-m.grzeschik@pengutronix.de>
Date:	Fri, 24 Apr 2015 19:20:53 +0200
From:	Michael Grzeschik <m.grzeschik@...gutronix.de>
To:	davem@...emloft.net
Cc:	netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel@...gutronix.de
Subject: [PATCH 19/21] 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@...gutronix.de>
---
 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@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ