2015-04-24 17:26:41

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 00/21] ARCNET: Defibrillation

Hi!

This patch series tries to reanimate the ARCNET hardware layer to be
somehow readable and maintainable again. It includes a lot of cleanup
patches. It also adds some fixes which leads the layer to become usable
again. And as a special treatment it adds more features like correct
loading and unloading of the com20020 card.

Cheers,
Michael

Michael Grzeschik (21):
com20020-pci: add dev_port for udev handling
ARCNET: fix hard_header_len limit
ARCNET: capmode: fix transfer length
ARCNET: whitespace, tab and codingstyle fixes
ARCNET: remove unneeded macros
ARCNET: com20020: remove unneeded macros
ARCNET: rimi: remove unneeded macros
ARCNET: com90io: remove unneeded macros
ARCNET: com90xx: remove unneeded macros
ARCNET: com20020: fix ioaddr prefixes
ARCNET: rimi: fix ioaddr prefixes
ARCNET: com90io: fix ioaddr prefixes
ARCNET: com90xx: fix ioaddr prefixes
ARCNET: arc-rawmode: reorder module functions
ARCNET: capmode: remove extra function and use C99 in struct
ARCNET: capmode: move dev_free_skb to its only user
ARCNET: com20020: replace magic numbers with readable macros
ARCNET: com20020: remove obsolete BUS_ALIGN offset factor
ARCNET: com20020: add enable and disable device on open/close
ARCNET: com20020-pci: reformat structs to C99 format
ARCNET: com20020-pci: add rotary index support

drivers/net/arcnet/arc-rawmode.c | 91 +++++-------
drivers/net/arcnet/arc-rimi.c | 42 ++----
drivers/net/arcnet/arcnet.c | 192 +++++++++++-------------
drivers/net/arcnet/capmode.c | 32 ++--
drivers/net/arcnet/com20020-isa.c | 4 +-
drivers/net/arcnet/com20020-pci.c | 66 ++++++++-
drivers/net/arcnet/com20020.c | 152 +++++++++++--------
drivers/net/arcnet/com20020_cs.c | 302 ++++++++++++++++++--------------------
drivers/net/arcnet/com90io.c | 98 ++++++-------
drivers/net/arcnet/com90xx.c | 65 ++++----
include/linux/arcdevice.h | 15 +-
include/linux/com20020.h | 69 +++------
include/uapi/linux/if_arcnet.h | 48 +++---
13 files changed, 572 insertions(+), 604 deletions(-)

--
2.1.4


2015-04-24 17:28:49

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 01/21] com20020-pci: add dev_port for udev handling

This patch sets the dev_port according to the index of
the card. This can be used by udev to name the ports
in userspace.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com20020-pci.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index 96edc13..9fa4eee 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -96,6 +96,7 @@ static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
ret = -ENOMEM;
goto out_port;
}
+ dev->dev_port = i;

dev->netdev_ops = &com20020_netdev_ops;

--
2.1.4

2015-04-24 17:28:44

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 02/21] ARCNET: fix hard_header_len limit

The commit <9c7077622dd9> ("packet: make packet_snd fail on len smaller
than l2 header") adds the check for minimum packet length of the used l2.
For arcnet the hardware header length is not the complete archdr which
includes hard + soft header. This patch changes the length to
sizeof(arc_hardware).

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/arcnet.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 10f71c73..816d0e9 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -326,7 +326,7 @@ static void arcdev_setup(struct net_device *dev)
dev->type = ARPHRD_ARCNET;
dev->netdev_ops = &arcnet_netdev_ops;
dev->header_ops = &arcnet_header_ops;
- dev->hard_header_len = sizeof(struct archdr);
+ dev->hard_header_len = sizeof(struct arc_hardware);
dev->mtu = choose_mtu();

dev->addr_len = ARCNET_ALEN;
--
2.1.4

2015-04-24 17:26:38

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 03/21] ARCNET: capmode: fix transfer length

The commit <52edc17f94f7bd4d9> ("bugfixes and new hardware support for
arcnet driver") adds fixes for the packet length calculations in
arc-rawmode. As the capmode protocol is derived from the arc-rawmode
code, the capmode also needs the fixes.

rx():
- Fixed error in received packet lengths; 256 byte packets were
being received as 257 bytes packets.

prepare_tx():
- Fixed error in transmit length calcs; 257 byte packets were being
transmitted as 260 byte packets.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/capmode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index 42fce91..b6868a2 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -49,7 +49,7 @@ static void rx(struct net_device *dev, int bufnum,

BUGMSG(D_DURING, "it's a raw(cap) packet (length=%d)\n", length);

- if (length >= MinTU)
+ if (length > MTU)
ofs = 512 - length;
else
ofs = 256 - length;
@@ -156,7 +156,7 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
length, XMTU);
length = XMTU;
}
- if (length > MinTU) {
+ if (length >= MinTU) {
hard->offset[0] = 0;
hard->offset[1] = ofs = 512 - length;
} else if (length > MTU) {
--
2.1.4

2015-04-24 17:26:25

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 04/21] ARCNET: whitespace, tab and codingstyle fixes

This patch removes trailing whitespaces in the whole
the ARCNET layer. It also replaces the use of space
with tabs and changes fixes the codingstyle on those lines.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/arc-rawmode.c | 4 +-
drivers/net/arcnet/arc-rimi.c | 2 +-
drivers/net/arcnet/arcnet.c | 116 +++++++--------
drivers/net/arcnet/com20020-isa.c | 2 +-
drivers/net/arcnet/com20020.c | 13 +-
drivers/net/arcnet/com20020_cs.c | 298 ++++++++++++++++++--------------------
drivers/net/arcnet/com90io.c | 2 +-
drivers/net/arcnet/com90xx.c | 4 +-
include/linux/arcdevice.h | 7 +-
include/linux/com20020.h | 4 +-
include/uapi/linux/if_arcnet.h | 48 +++---
11 files changed, 239 insertions(+), 261 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index 705e6ce..b603470 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - "raw mode" packet encapsulation (no soft headers)
- *
+ *
* Written 1994-1999 by Avery Pennarun.
* Derived from skeleton.c by Donald Becker.
*
@@ -150,7 +150,7 @@ static int build_header(struct sk_buff *skb, struct net_device *dev,
/* see linux/net/ethernet/eth.c to see where I got the following */

if (dev->flags & (IFF_LOOPBACK | IFF_NOARP)) {
- /*
+ /*
* FIXME: fill in the last byte of the dest ipaddr here to better
* comply with RFC1051 in "noarp" mode.
*/
diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index b8b4c7b..4c95d3c 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - "RIM I" (entirely mem-mapped) cards
- *
+ *
* Written 1994-1999 by Avery Pennarun.
* Written 1999-2000 by Martin Mares <[email protected]>.
* Derived from skeleton.c by Donald Becker.
diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 816d0e9..f83034c 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - device-independent routines
- *
+ *
* Written 1997 by David Woodhouse.
* Written 1994-1999 by Avery Pennarun.
* Written 1999-2000 by Martin Mares <[email protected]>.
@@ -20,12 +20,12 @@
* modified by SRC, incorporated herein by reference.
*
* **********************
- *
+ *
* The change log is now in a file called ChangeLog in this directory.
*
* Sources:
* - Crynwr arcnet.com/arcether.com packet drivers.
- * - arcnet.c v0.00 dated 1/1/94 and apparently by
+ * - arcnet.c v0.00 dated 1/1/94 and apparently by
* Donald Becker - it didn't work :)
* - skeleton.c v0.05 dated 11/16/93 by Donald Becker
* (from Linux Kernel 1.1.45)
@@ -168,7 +168,6 @@ void arcnet_dump_skb(struct net_device *dev,
EXPORT_SYMBOL(arcnet_dump_skb);
#endif

-
/*
* Dump the contents of an ARCnet buffer
*/
@@ -184,11 +183,11 @@ static void arcnet_dump_packet(struct net_device *dev, int bufnum,

/* hw.copy_from_card expects IRQ context so take the IRQ lock
to keep it single threaded */
- if(take_arcnet_lock)
+ if (take_arcnet_lock)
spin_lock_irqsave(&lp->lock, flags);

lp->hw.copy_from_card(dev, bufnum, 0, buf, 512);
- if(take_arcnet_lock)
+ if (take_arcnet_lock)
spin_unlock_irqrestore(&lp->lock, flags);

/* if the offset[0] byte is nonzero, this is a 256-byte packet */
@@ -229,11 +228,10 @@ void arcnet_unregister_proto(struct ArcProto *proto)
}
}

-
/*
* Add a buffer to the queue. Only the interrupt handler is allowed to do
* this, unless interrupts are disabled.
- *
+ *
* Note: we don't check for a full queue, since there aren't enough buffers
* to more than fill it.
*/
@@ -248,13 +246,12 @@ static void release_arcbuf(struct net_device *dev, int bufnum)
BUGLVL(D_DURING) {
BUGMSG(D_DURING, "release_arcbuf: freed #%d; buffer queue is now: ",
bufnum);
- for (i = lp->next_buf; i != lp->first_free_buf; i = (i+1) % 5)
+ for (i = lp->next_buf; i != lp->first_free_buf; i = (i + 1) % 5)
BUGMSG2(D_DURING, "#%d ", lp->buf_queue[i]);
BUGMSG2(D_DURING, "\n");
}
}

-
/*
* Get a buffer from the queue. If this returns -1, there are no buffers
* available.
@@ -284,7 +281,7 @@ static int get_arcbuf(struct net_device *dev)

BUGLVL(D_DURING) {
BUGMSG(D_DURING, "get_arcbuf: got #%d; buffer queue is now: ", buf);
- for (i = lp->next_buf; i != lp->first_free_buf; i = (i+1) % 5)
+ for (i = lp->next_buf; i != lp->first_free_buf; i = (i + 1) % 5)
BUGMSG2(D_DURING, "#%d ", lp->buf_queue[i]);
BUGMSG2(D_DURING, "\n");
}
@@ -293,7 +290,6 @@ static int get_arcbuf(struct net_device *dev)
return buf;
}

-
static int choose_mtu(void)
{
int count, mtu = 65535;
@@ -346,7 +342,7 @@ struct net_device *alloc_arcdev(const char *name)
dev = alloc_netdev(sizeof(struct arcnet_local),
name && *name ? name : "arc%d", NET_NAME_UNKNOWN,
arcdev_setup);
- if(dev) {
+ if (dev) {
struct arcnet_local *lp = netdev_priv(dev);
spin_lock_init(&lp->lock);
}
@@ -380,7 +376,6 @@ int arcnet_open(struct net_device *dev)
BUGMSG2(D_PROTO, "\n");
}

-
BUGMSG(D_INIT, "arcnet_open: resetting card.\n");

/* try to put the card in a defined state - if it fails the first
@@ -490,8 +485,8 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,

BUGMSG(D_DURING,
"create header from %d to %d; protocol %d (%Xh); size %u.\n",
- saddr ? *(uint8_t *) saddr : -1,
- daddr ? *(uint8_t *) daddr : -1,
+ saddr ? *(uint8_t *)saddr : -1,
+ daddr ? *(uint8_t *)daddr : -1,
type, type, len);

if (skb->len!=0 && len != skb->len)
@@ -499,19 +494,19 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
skb->len, len);


- /* Type is host order - ? */
- if(type == ETH_P_ARCNET) {
- proto = arc_raw_proto;
- BUGMSG(D_DEBUG, "arc_raw_proto used. proto='%c'\n",proto->suffix);
- _daddr = daddr ? *(uint8_t *) daddr : 0;
- }
+ /* Type is host order - ? */
+ if (type == ETH_P_ARCNET) {
+ proto = arc_raw_proto;
+ BUGMSG(D_DEBUG, "arc_raw_proto used. proto='%c'\n", proto->suffix);
+ _daddr = daddr ? *(uint8_t *)daddr : 0;
+ }
else if (!daddr) {
/*
* if the dest addr isn't provided, we can't choose an encapsulation!
* Store the packet type (eg. ETH_P_IP) for now, and we'll push on a
* real header when we do rebuild_header.
*/
- *(uint16_t *) skb_push(skb, 2) = type;
+ *(uint16_t *)skb_push(skb, 2) = type;
/*
* XXX: Why not use skb->mac_len?
*/
@@ -522,7 +517,7 @@ static int arcnet_header(struct sk_buff *skb, struct net_device *dev,
}
else {
/* otherwise, we can just add the header as usual. */
- _daddr = *(uint8_t *) daddr;
+ _daddr = *(uint8_t *)daddr;
proto_num = lp->default_proto[_daddr];
proto = arc_proto_map[proto_num];
BUGMSG(D_DURING, "building header for %02Xh using protocol '%c'\n",
@@ -572,9 +567,9 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,

spin_lock_irqsave(&lp->lock, flags);
AINTMASK(0);
- if(lp->next_tx == -1)
+ if (lp->next_tx == -1) {
txbuf = get_arcbuf(dev);
- else {
+ } else {
txbuf = -1;
}
if (txbuf != -1) {
@@ -678,7 +673,7 @@ void arcnet_timeout(struct net_device *dev)
AINTMASK(0);
lp->intmask |= TXFREEflag|EXCNAKflag;
AINTMASK(lp->intmask);
-
+
spin_unlock_irqrestore(&lp->lock, flags);

if (time_after(jiffies, lp->last_timeout + 10*HZ)) {
@@ -710,7 +705,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)

lp = netdev_priv(dev);
BUG_ON(!lp);
-
+
spin_lock(&lp->lock);

/*
@@ -731,7 +726,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
boguscount = 5;
do {
status = ASTATUS();
- diagstatus = (status >> 8) & 0xFF;
+ diagstatus = (status >> 8) & 0xFF;

BUGMSG(D_DEBUG, "%s: %d: %s: status=%x\n",
__FILE__,__LINE__,__func__,status);
@@ -740,7 +735,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
/*
* RESET flag was enabled - card is resetting and if RX is
* disabled, it's NOT because we just got a packet.
- *
+ *
* The card is in an undefined state. Clear it out and start over.
*/
if (status & RESETflag) {
@@ -751,14 +746,14 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
/* get out of the interrupt handler! */
break;
}
- /*
+ /*
* RX is inhibited - we must have received something. Prepare to
* receive into the next buffer.
- *
+ *
* We don't actually copy the received packet from the card until
* after the transmit handler runs (and possibly launches the next
* tx); this should improve latency slightly if we get both types
- * of interrupts at once.
+ * of interrupts at once.
*/
recbuf = -1;
if (status & lp->intmask & NORXflag) {
@@ -775,17 +770,17 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
didsomething++;
}

- if((diagstatus & EXCNAKflag)) {
+ if ((diagstatus & EXCNAKflag)) {
BUGMSG(D_DURING, "EXCNAK IRQ (diagstat=%Xh)\n",
diagstatus);

- ACOMMAND(NOTXcmd); /* disable transmit */
- lp->excnak_pending = 1;
+ ACOMMAND(NOTXcmd); /* disable transmit */
+ lp->excnak_pending = 1;

- ACOMMAND(EXCNAKclear);
+ ACOMMAND(EXCNAKclear);
lp->intmask &= ~(EXCNAKflag);
- didsomething++;
- }
+ didsomething++;
+ }


/* a transmit finished, and we're interested in it. */
@@ -795,7 +790,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
BUGMSG(D_DURING, "TX IRQ (stat=%Xh)\n", status);

if (lp->cur_tx != -1 && !lp->timed_out) {
- if(!(status & TXACKflag)) {
+ if (!(status & TXACKflag)) {
if (lp->lasttrans_dest != 0) {
BUGMSG(D_EXTRA,
"transmit was not acknowledged! "
@@ -813,16 +808,17 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)

if (lp->outgoing.proto &&
lp->outgoing.proto->ack_tx) {
- int ackstatus;
- if(status & TXACKflag)
- ackstatus=2;
- else if(lp->excnak_pending)
- ackstatus=1;
- else
- ackstatus=0;
-
- lp->outgoing.proto
- ->ack_tx(dev, ackstatus);
+ int ackstatus;
+
+ if (status & TXACKflag)
+ ackstatus = 2;
+ else if (lp->excnak_pending)
+ ackstatus = 1;
+ else
+ ackstatus = 0;
+
+ lp->outgoing.proto
+ ->ack_tx(dev, ackstatus);
}
}
if (lp->cur_tx != -1)
@@ -842,11 +838,10 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
if (lp->outgoing.proto->continue_tx(dev, txbuf)) {
/* that was the last segment */
dev->stats.tx_bytes += lp->outgoing.skb->len;
- if(!lp->outgoing.proto->ack_tx)
- {
- dev_kfree_skb_irq(lp->outgoing.skb);
- lp->outgoing.proto = NULL;
- }
+ if (!lp->outgoing.proto->ack_tx) {
+ dev_kfree_skb_irq(lp->outgoing.skb);
+ lp->outgoing.proto = NULL;
+ }
}
lp->next_tx = txbuf;
}
@@ -871,7 +866,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
BUGMSG(D_RECON, "Network reconfiguration detected (status=%Xh)\n",
status);
/* MYRECON bit is at bit 7 of diagstatus */
- if(diagstatus & 0x80)
+ if (diagstatus & 0x80)
BUGMSG(D_RECON,"Put out that recon myself\n");

/* is the RECON info empty or old? */
@@ -920,9 +915,8 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
BUGMSG(D_DURING, "not recon: clearing counters anyway.\n");
}

- if(didsomething) {
+ if (didsomething)
retval |= IRQ_HANDLED;
- }
}
while (--boguscount && didsomething);

@@ -930,16 +924,14 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
ASTATUS(), boguscount);
BUGMSG(D_DURING, "\n");

-
AINTMASK(0);
udelay(1);
AINTMASK(lp->intmask);
-
+
spin_unlock(&lp->lock);
return retval;
}

-
/*
* This is a generic packet receiver that calls arcnet??_rx depending on the
* protocol ID found.
@@ -1002,7 +994,6 @@ static void arcnet_rx(struct net_device *dev, int bufnum)
arc_proto_map[soft->proto]->rx(dev, bufnum, &pkt, length);
}

-
static void null_rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length)
{
@@ -1025,7 +1016,6 @@ static int null_build_header(struct sk_buff *skb, struct net_device *dev,
return 0;
}

-
/* the "do nothing" prepare_tx function warns that there's nothing to do. */
static int null_prepare_tx(struct net_device *dev, struct archdr *pkt,
int length, int bufnum)
diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index 45c61a2..d8746ca 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - COM20020 chipset support
- *
+ *
* Written 1997 by David Woodhouse.
* Written 1994-1999 by Avery Pennarun.
* Written 1999-2000 by Martin Mares <[email protected]>.
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 1a84378..0d84f6c 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - COM20020 chipset support
- *
+ *
* Written 1997 by David Woodhouse.
* Written 1994-1999 by Avery Pennarun.
* Written 1999 by Martin Mares <[email protected]>.
@@ -108,7 +108,7 @@ int com20020_check(struct net_device *dev)
{
SET_SUBADR(SUB_SETUP2);
outb(lp->setup2, _XREG);
-
+
/* must now write the magic "restart operation" command */
mdelay(1);
outb(0x18, _COMMAND);
@@ -202,7 +202,7 @@ int com20020_found(struct net_device *dev, int shared)
{
SET_SUBADR(SUB_SETUP2);
outb(lp->setup2, _XREG);
-
+
/* must now write the magic "restart operation" command */
mdelay(1);
outb(0x18, _COMMAND);
@@ -232,7 +232,7 @@ int com20020_found(struct net_device *dev, int shared)
BUGMSG(D_NORMAL, "Using extended timeout value of %d.\n", lp->timeout);

BUGMSG(D_NORMAL, "Using CKP %d - data rate %s.\n",
- lp->setup >> 1,
+ lp->setup >> 1,
clockrates[3 - ((lp->setup2 & 0xF0) >> 4) + ((lp->setup & 0x0F) >> 1)]);

if (register_netdev(dev)) {
@@ -242,10 +242,9 @@ int com20020_found(struct net_device *dev, int shared)
return 0;
}

-
-/*
+/*
* Do a hardware reset on the card, and set up necessary registers.
- *
+ *
* This should be called as little as possible, because it disrupts the
* token on the network (causes a RECON) and requires a significant delay.
*
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index 057d958..aee4455 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - COM20020 PCMCIA support
- *
+ *
* Written 1994-1999 by Avery Pennarun,
* based on an ISA version by David Woodhouse.
* Derived from ibmtr_cs.c by Steve Kipisz (pcmcia-cs 3.1.4)
@@ -19,14 +19,14 @@
* Director, National Security Agency. This software may only be used
* and distributed according to the terms of the GNU General Public License as
* modified by SRC, incorporated herein by reference.
- *
+ *
* **********************
* Changes:
* Arnaldo Carvalho de Melo <[email protected]> - 08/08/2000
* - reorganize kmallocs in com20020_attach, checking all for failure
* and releasing the previous allocations if one fails
* **********************
- *
+ *
* For more details, see drivers/net/arcnet.c
*
* **********************
@@ -53,33 +53,31 @@
static void regdump(struct net_device *dev)
{
#ifdef DEBUG
- int ioaddr = dev->base_addr;
- int count;
-
- netdev_dbg(dev, "register dump:\n");
- for (count = ioaddr; count < ioaddr + 16; count++)
- {
- if (!(count % 16))
- pr_cont("%04X:", count);
- pr_cont(" %02X", inb(count));
- }
- pr_cont("\n");
-
- netdev_dbg(dev, "buffer0 dump:\n");
+ int ioaddr = dev->base_addr;
+ int count;
+
+ netdev_dbg(dev, "register dump:\n");
+ for (count = ioaddr; count < ioaddr + 16; count++) {
+ if (!(count % 16))
+ pr_cont("%04X:", count);
+ pr_cont(" %02X", inb(count));
+ }
+ pr_cont("\n");
+
+ netdev_dbg(dev, "buffer0 dump:\n");
/* set up the address register */
- count = 0;
+ count = 0;
outb((count >> 8) | RDDATAflag | AUTOINCflag, _ADDR_HI);
outb(count & 0xff, _ADDR_LO);
-
- for (count = 0; count < 256+32; count++)
- {
- if (!(count % 16))
- pr_cont("%04X:", count);
-
- /* copy the data */
- pr_cont(" %02X", inb(_MEMDATA));
- }
- pr_cont("\n");
+
+ for (count = 0; count < 256 + 32; count++) {
+ if (!(count % 16))
+ pr_cont("%04X:", count);
+
+ /* copy the data */
+ pr_cont(" %02X", inb(_MEMDATA));
+ }
+ pr_cont("\n");
#endif
}

@@ -114,169 +112,161 @@ static void com20020_detach(struct pcmcia_device *p_dev);

static int com20020_probe(struct pcmcia_device *p_dev)
{
- struct com20020_dev *info;
- struct net_device *dev;
- struct arcnet_local *lp;
+ struct com20020_dev *info;
+ struct net_device *dev;
+ struct arcnet_local *lp;

- dev_dbg(&p_dev->dev, "com20020_attach()\n");
+ dev_dbg(&p_dev->dev, "com20020_attach()\n");

- /* Create new network device */
- info = kzalloc(sizeof(*info), GFP_KERNEL);
- if (!info)
- goto fail_alloc_info;
+ /* Create new network device */
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (!info)
+ goto fail_alloc_info;

- dev = alloc_arcdev("");
- if (!dev)
- goto fail_alloc_dev;
+ dev = alloc_arcdev("");
+ if (!dev)
+ goto fail_alloc_dev;

- lp = netdev_priv(dev);
- lp->timeout = timeout;
- lp->backplane = backplane;
- lp->clockp = clockp;
- lp->clockm = clockm & 3;
- lp->hw.owner = THIS_MODULE;
+ lp = netdev_priv(dev);
+ lp->timeout = timeout;
+ lp->backplane = backplane;
+ lp->clockp = clockp;
+ lp->clockm = clockm & 3;
+ lp->hw.owner = THIS_MODULE;

- /* fill in our module parameters as defaults */
- dev->dev_addr[0] = node;
+ /* fill in our module parameters as defaults */
+ dev->dev_addr[0] = node;

- p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
- p_dev->resource[0]->end = 16;
- p_dev->config_flags |= CONF_ENABLE_IRQ;
+ p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
+ p_dev->resource[0]->end = 16;
+ p_dev->config_flags |= CONF_ENABLE_IRQ;

- info->dev = dev;
- p_dev->priv = info;
+ info->dev = dev;
+ p_dev->priv = info;

- return com20020_config(p_dev);
+ return com20020_config(p_dev);

fail_alloc_dev:
- kfree(info);
+ kfree(info);
fail_alloc_info:
- return -ENOMEM;
+ return -ENOMEM;
} /* com20020_attach */

static void com20020_detach(struct pcmcia_device *link)
{
- struct com20020_dev *info = link->priv;
- struct net_device *dev = info->dev;
+ struct com20020_dev *info = link->priv;
+ struct net_device *dev = info->dev;

- dev_dbg(&link->dev, "detach...\n");
+ dev_dbg(&link->dev, "detach...\n");

- dev_dbg(&link->dev, "com20020_detach\n");
+ dev_dbg(&link->dev, "com20020_detach\n");

- dev_dbg(&link->dev, "unregister...\n");
+ dev_dbg(&link->dev, "unregister...\n");

- unregister_netdev(dev);
+ unregister_netdev(dev);

- /*
- * this is necessary because we register our IRQ separately
- * from card services.
- */
- if (dev->irq)
- free_irq(dev->irq, dev);
+ /* this is necessary because we register our IRQ separately
+ * from card services.
+ */
+ if (dev->irq)
+ free_irq(dev->irq, dev);

- com20020_release(link);
+ com20020_release(link);

- /* Unlink device structure, free bits */
- dev_dbg(&link->dev, "unlinking...\n");
- if (link->priv)
- {
- dev = info->dev;
- if (dev)
- {
- dev_dbg(&link->dev, "kfree...\n");
- free_netdev(dev);
+ /* Unlink device structure, free bits */
+ dev_dbg(&link->dev, "unlinking...\n");
+ if (link->priv) {
+ dev = info->dev;
+ if (dev) {
+ dev_dbg(&link->dev, "kfree...\n");
+ free_netdev(dev);
+ }
+ dev_dbg(&link->dev, "kfree2...\n");
+ kfree(info);
}
- dev_dbg(&link->dev, "kfree2...\n");
- kfree(info);
- }

} /* com20020_detach */

static int com20020_config(struct pcmcia_device *link)
{
- struct arcnet_local *lp;
- struct com20020_dev *info;
- struct net_device *dev;
- int i, ret;
- int ioaddr;
+ struct arcnet_local *lp;
+ struct com20020_dev *info;
+ struct net_device *dev;
+ int i, ret;
+ int ioaddr;
+
+ info = link->priv;
+ dev = info->dev;

- info = link->priv;
- dev = info->dev;
+ dev_dbg(&link->dev, "config...\n");

- dev_dbg(&link->dev, "config...\n");
+ dev_dbg(&link->dev, "com20020_config\n");

- dev_dbg(&link->dev, "com20020_config\n");
+ dev_dbg(&link->dev, "baseport1 is %Xh\n",
+ (unsigned int)link->resource[0]->start);

- dev_dbg(&link->dev, "baseport1 is %Xh\n",
- (unsigned int) link->resource[0]->start);
+ i = -ENODEV;
+ link->io_lines = 16;

- i = -ENODEV;
- link->io_lines = 16;
+ if (!link->resource[0]->start) {
+ for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10) {
+ link->resource[0]->start = ioaddr;
+ i = pcmcia_request_io(link);
+ if (i == 0)
+ break;
+ }
+ } else {
+ i = pcmcia_request_io(link);
+ }

- if (!link->resource[0]->start)
- {
- for (ioaddr = 0x100; ioaddr < 0x400; ioaddr += 0x10)
+ if (i != 0)
{
- link->resource[0]->start = ioaddr;
- i = pcmcia_request_io(link);
- if (i == 0)
- break;
+ dev_dbg(&link->dev, "requestIO failed totally!\n");
+ goto failed;
}
- }
- else
- i = pcmcia_request_io(link);
-
- if (i != 0)
- {
- dev_dbg(&link->dev, "requestIO failed totally!\n");
- goto failed;
- }
-
- ioaddr = dev->base_addr = link->resource[0]->start;
- dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr);
-
- dev_dbg(&link->dev, "request IRQ %d\n",
- link->irq);
- if (!link->irq)
- {
- dev_dbg(&link->dev, "requestIRQ failed totally!\n");
- goto failed;
- }
-
- dev->irq = link->irq;
-
- ret = pcmcia_enable_device(link);
- if (ret)
- goto failed;
-
- if (com20020_check(dev))
- {
- regdump(dev);
- goto failed;
- }
-
- lp = netdev_priv(dev);
- lp->card_name = "PCMCIA COM20020";
- lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
-
- SET_NETDEV_DEV(dev, &link->dev);
-
- i = com20020_found(dev, 0); /* calls register_netdev */
-
- if (i != 0) {
- dev_notice(&link->dev,
- "com20020_found() failed\n");
- goto failed;
- }
-
- netdev_dbg(dev, "port %#3lx, irq %d\n",
- dev->base_addr, dev->irq);
- return 0;
-
-failed:
- dev_dbg(&link->dev, "com20020_config failed...\n");
- com20020_release(link);
- return -ENODEV;
+
+ ioaddr = dev->base_addr = link->resource[0]->start;
+ dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr);
+
+ dev_dbg(&link->dev, "request IRQ %d\n",
+ link->irq);
+
+ if (!link->irq) {
+ dev_dbg(&link->dev, "requestIRQ failed totally!\n");
+ goto failed;
+ }
+
+ dev->irq = link->irq;
+
+ ret = pcmcia_enable_device(link);
+ if (ret)
+ goto failed;
+
+ if (com20020_check(dev)) {
+ regdump(dev);
+ goto failed;
+ }
+
+ lp = netdev_priv(dev);
+ lp->card_name = "PCMCIA COM20020";
+ lp->card_flags = ARC_CAN_10MBIT; /* pretend all of them can 10Mbit */
+
+ SET_NETDEV_DEV(dev, &link->dev);
+
+ i = com20020_found(dev, 0); /* calls register_netdev */
+
+ if (i != 0) {
+ dev_notice(&link->dev, "com20020_found() failed\n");
+ goto failed;
+ }
+
+ netdev_dbg(dev, "port %#3lx, irq %d\n", dev->base_addr, dev->irq);
+ return 0;
+
+ failed:
+ dev_dbg(&link->dev, "com20020_config failed...\n");
+ com20020_release(link);
+ return -ENODEV;
} /* com20020_config */

static void com20020_release(struct pcmcia_device *link)
diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 487d780..b1279af 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - COM90xx chipset (IO-mapped buffers)
- *
+ *
* Written 1997 by David Woodhouse.
* Written 1994-1999 by Avery Pennarun.
* Written 1999-2000 by Martin Mares <[email protected]>.
diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index b80fbe4..03bd71c 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - COM90xx chipset (memory-mapped buffers)
- *
+ *
* Written 1994-1999 by Avery Pennarun.
* Written 1999 by Martin Mares <[email protected]>.
* Derived from skeleton.c by Donald Becker.
@@ -579,7 +579,7 @@ static void com90xx_setmask(struct net_device *dev, int mask)

/*
* Do a hardware reset on the card, and set up necessary registers.
- *
+ *
* This should be called as little as possible, because it disrupts the
* token on the network (causes a RECON) and requires a significant delay.
*
diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
index df03562..81f336f 100644
--- a/include/linux/arcdevice.h
+++ b/include/linux/arcdevice.h
@@ -51,7 +51,7 @@

/*
* Debugging bitflags: each option can be enabled individually.
- *
+ *
* Note: only debug flags included in the ARCNET_DEBUG_MAX define will
* actually be available. GCC will (at least, GCC 2.7.0 will) notice
* lines using a BUGLVL not in ARCNET_DEBUG_MAX and automatically optimize
@@ -182,7 +182,6 @@ extern int arcnet_debug;
#define ARC_CAN_10MBIT 2 /* card uses COM20022, supporting 10MBit,
but default is 2.5MBit. */

-
/* information needed to define an encapsulation driver */
struct ArcProto {
char suffix; /* a for RFC1201, e for ether-encap, etc. */
@@ -263,13 +262,13 @@ struct arcnet_local {
* situations in which we (for example) want to pre-load a transmit
* buffer, or start receiving while we copy a received packet to
* memory.
- *
+ *
* The rules: only the interrupt handler is allowed to _add_ buffers to
* the queue; thus, this doesn't require a lock. Both the interrupt
* handler and the transmit function will want to _remove_ buffers, so
* we need to handle the situation where they try to do it at the same
* time.
- *
+ *
* If next_buf == first_free_buf, the queue is empty. Since there are
* only four possible buffers, the queue should never be full.
*/
diff --git a/include/linux/com20020.h b/include/linux/com20020.h
index 8589899..5ce5c7d 100644
--- a/include/linux/com20020.h
+++ b/include/linux/com20020.h
@@ -1,6 +1,6 @@
/*
* Linux ARCnet driver - COM20020 chipset support - function declarations
- *
+ *
* Written 1997 by David Woodhouse.
* Written 1994-1999 by Avery Pennarun.
* Derived from skeleton.c by Donald Becker.
@@ -81,7 +81,7 @@ struct com20020_dev {
#define _SUBADR (ioaddr+BUS_ALIGN*5) /* the extended port _XREG refers to */
#define _CONFIG (ioaddr+BUS_ALIGN*6) /* configuration register */
#define _XREG (ioaddr+BUS_ALIGN*7) /* extra registers (indexed by _CONFIG
- or _SUBADR) */
+ or _SUBADR) */

/* in the ADDR_HI register */
#define RDDATAflag 0x80 /* next access is a read (not a write) */
diff --git a/include/uapi/linux/if_arcnet.h b/include/uapi/linux/if_arcnet.h
index 46e34bd..1fa78f4 100644
--- a/include/uapi/linux/if_arcnet.h
+++ b/include/uapi/linux/if_arcnet.h
@@ -57,10 +57,10 @@
* The RFC1201-specific components of an arcnet packet header.
*/
struct arc_rfc1201 {
- __u8 proto; /* protocol ID field - varies */
- __u8 split_flag; /* for use with split packets */
- __be16 sequence; /* sequence number */
- __u8 payload[0]; /* space remaining in packet (504 bytes)*/
+ __u8 proto; /* protocol ID field - varies */
+ __u8 split_flag; /* for use with split packets */
+ __be16 sequence; /* sequence number */
+ __u8 payload[0]; /* space remaining in packet (504 bytes) */
};
#define RFC1201_HDR_SIZE 4

@@ -69,8 +69,8 @@ struct arc_rfc1201 {
* The RFC1051-specific components.
*/
struct arc_rfc1051 {
- __u8 proto; /* ARC_P_RFC1051_ARP/RFC1051_IP */
- __u8 payload[0]; /* 507 bytes */
+ __u8 proto; /* ARC_P_RFC1051_ARP/RFC1051_IP */
+ __u8 payload[0]; /* 507 bytes */
};
#define RFC1051_HDR_SIZE 1

@@ -80,16 +80,16 @@ struct arc_rfc1051 {
* and some data.
*/
struct arc_eth_encap {
- __u8 proto; /* Always ARC_P_ETHER */
- struct ethhdr eth; /* standard ethernet header (yuck!) */
- __u8 payload[0]; /* 493 bytes */
+ __u8 proto; /* Always ARC_P_ETHER */
+ struct ethhdr eth; /* standard ethernet header (yuck!) */
+ __u8 payload[0]; /* 493 bytes */
};
#define ETH_ENCAP_HDR_SIZE 14


struct arc_cap {
__u8 proto;
- __u8 cookie[sizeof(int)]; /* Actually NOT sent over the network */
+ __u8 cookie[sizeof(int)]; /* Actually NOT sent over the network */
union {
__u8 ack;
__u8 raw[0]; /* 507 bytes */
@@ -105,9 +105,9 @@ struct arc_cap {
* driver.
*/
struct arc_hardware {
- __u8 source, /* source ARCnet - filled in automagically */
- dest, /* destination ARCnet - 0 for broadcast */
- offset[2]; /* offset bytes (some weird semantics) */
+ __u8 source, /* source ARCnet - filled in automagically */
+ dest, /* destination ARCnet - 0 for broadcast */
+ offset[2]; /* offset bytes (some weird semantics) */
};
#define ARC_HDR_SIZE 4

@@ -116,17 +116,17 @@ struct arc_hardware {
* when you do a raw packet capture).
*/
struct archdr {
- /* hardware requirements */
- struct arc_hardware hard;
-
- /* arcnet encapsulation-specific bits */
- union {
- struct arc_rfc1201 rfc1201;
- struct arc_rfc1051 rfc1051;
- struct arc_eth_encap eth_encap;
- struct arc_cap cap;
- __u8 raw[0]; /* 508 bytes */
- } soft;
+ /* hardware requirements */
+ struct arc_hardware hard;
+
+ /* arcnet encapsulation-specific bits */
+ union {
+ struct arc_rfc1201 rfc1201;
+ struct arc_rfc1051 rfc1051;
+ struct arc_eth_encap eth_encap;
+ struct arc_cap cap;
+ __u8 raw[0]; /* 508 bytes */
+ } soft;
};

#endif /* _LINUX_IF_ARCNET_H */
--
2.1.4

2015-04-24 17:22:37

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 05/21] ARCNET: remove unneeded macros

The simple macros ARCRESET, ACOMMAND, ASTATUS, AINTMASK are unnecessary
indirections to the use of registers. This patch removes them and improves the
readability of the code.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/arcnet.c | 68 +++++++++++++++++++++++----------------------
include/linux/arcdevice.h | 7 -----
2 files changed, 35 insertions(+), 40 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index f83034c..4990b0d 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -382,7 +382,7 @@ int arcnet_open(struct net_device *dev)
* time, actually reset it.
*/
error = -ENODEV;
- if (ARCRESET(0) && ARCRESET(1))
+ if (lp->hw.reset(dev, 0) && lp->hw.reset(dev, 1))
goto out_module_put;

newmtu = choose_mtu();
@@ -427,22 +427,22 @@ int arcnet_open(struct net_device *dev)
"DOS networking programs!\n");

BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
- if (ASTATUS() & RESETflag) {
+ if (lp->hw.status(dev) & RESETflag) {
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
- ACOMMAND(CFLAGScmd | RESETclear);
+ lp->hw.command(dev, CFLAGScmd | RESETclear);
}


BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
/* make sure we're ready to receive IRQ's. */
- AINTMASK(0);
+ lp->hw.intmask(dev, 0);
udelay(1); /* give it time to set the mask before
* we reset it again. (may not even be
* necessary)
*/
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
lp->intmask = NORXflag | RECONflag;
- AINTMASK(lp->intmask);
+ lp->hw.intmask(dev, lp->intmask);
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

netif_start_queue(dev);
@@ -463,9 +463,9 @@ int arcnet_close(struct net_device *dev)
netif_stop_queue(dev);

/* flush TX and disable RX */
- AINTMASK(0);
- ACOMMAND(NOTXcmd); /* stop transmit */
- ACOMMAND(NORXcmd); /* disable receive */
+ lp->hw.intmask(dev, 0);
+ lp->hw.command(dev, NOTXcmd); /* stop transmit */
+ lp->hw.command(dev, NORXcmd); /* disable receive */
mdelay(1);

/* shut down the card */
@@ -545,7 +545,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,

BUGMSG(D_DURING,
"transmit requested (status=%Xh, txbufs=%d/%d, len=%d, protocol %x)\n",
- ASTATUS(), lp->cur_tx, lp->next_tx, skb->len,skb->protocol);
+ lp->hw.status(dev), lp->cur_tx, lp->next_tx, skb->len, skb->protocol);

pkt = (struct archdr *) skb->data;
soft = &pkt->soft.rfc1201;
@@ -566,7 +566,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
netif_stop_queue(dev);

spin_lock_irqsave(&lp->lock, flags);
- AINTMASK(0);
+ lp->hw.intmask(dev, 0);
if (lp->next_tx == -1) {
txbuf = get_arcbuf(dev);
} else {
@@ -601,14 +601,16 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
freeskb = 0;
}

- BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__func__,ASTATUS());
+ BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",
+ __FILE__, __LINE__, __func__, lp->hw.status(dev));
/* make sure we didn't ignore a TX IRQ while we were in here */
- AINTMASK(0);
+ lp->hw.intmask(dev, 0);

- BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
+ BUGMSG(D_DEBUG, "%s: %d: %s\n", __FILE__, __LINE__, __func__);
lp->intmask |= TXFREEflag|EXCNAKflag;
- AINTMASK(lp->intmask);
- BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",__FILE__,__LINE__,__func__,ASTATUS());
+ lp->hw.intmask(dev, lp->intmask);
+ BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",
+ __FILE__, __LINE__, __func__, lp->hw.status(dev));

spin_unlock_irqrestore(&lp->lock, flags);
if (freeskb) {
@@ -627,7 +629,7 @@ static int go_tx(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);

BUGMSG(D_DURING, "go_tx: status=%Xh, intmask=%Xh, next_tx=%d, cur_tx=%d\n",
- ASTATUS(), lp->intmask, lp->next_tx, lp->cur_tx);
+ lp->hw.status(dev), lp->intmask, lp->next_tx, lp->cur_tx);

if (lp->cur_tx != -1 || lp->next_tx == -1)
return 0;
@@ -638,7 +640,7 @@ static int go_tx(struct net_device *dev)
lp->next_tx = -1;

/* start sending */
- ACOMMAND(TXcmd | (lp->cur_tx << 3));
+ lp->hw.command(dev, TXcmd | (lp->cur_tx << 3));

dev->stats.tx_packets++;
lp->lasttrans_dest = lp->lastload_dest;
@@ -655,7 +657,7 @@ void arcnet_timeout(struct net_device *dev)
{
unsigned long flags;
struct arcnet_local *lp = netdev_priv(dev);
- int status = ASTATUS();
+ int status = lp->hw.status(dev);
char *msg;

spin_lock_irqsave(&lp->lock, flags);
@@ -665,14 +667,14 @@ void arcnet_timeout(struct net_device *dev)
msg = "";
dev->stats.tx_aborted_errors++;
lp->timed_out = 1;
- ACOMMAND(NOTXcmd | (lp->cur_tx << 3));
+ lp->hw.command(dev, NOTXcmd | (lp->cur_tx << 3));
}
dev->stats.tx_errors++;

/* make sure we didn't miss a TX or a EXC NAK IRQ */
- AINTMASK(0);
+ lp->hw.intmask(dev, 0);
lp->intmask |= TXFREEflag|EXCNAKflag;
- AINTMASK(lp->intmask);
+ lp->hw.intmask(dev, lp->intmask);

spin_unlock_irqrestore(&lp->lock, flags);

@@ -713,19 +715,19 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
* away (but nothing else).
*/
if (!netif_running(dev)) {
- if (ASTATUS() & RESETflag)
- ACOMMAND(CFLAGScmd | RESETclear);
- AINTMASK(0);
+ if (lp->hw.status(dev) & RESETflag)
+ lp->hw.command(dev, CFLAGScmd | RESETclear);
+ lp->hw.intmask(dev, 0);
spin_unlock(&lp->lock);
return retval;
}

BUGMSG(D_DURING, "in arcnet_inthandler (status=%Xh, intmask=%Xh)\n",
- ASTATUS(), lp->intmask);
+ lp->hw.status(dev), lp->intmask);

boguscount = 5;
do {
- status = ASTATUS();
+ status = lp->hw.status(dev);
diagstatus = (status >> 8) & 0xFF;

BUGMSG(D_DEBUG, "%s: %d: %s: status=%x\n",
@@ -765,7 +767,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
if (lp->cur_rx != -1) {
BUGMSG(D_DURING, "enabling receive to buffer #%d\n",
lp->cur_rx);
- ACOMMAND(RXcmd | (lp->cur_rx << 3) | RXbcasts);
+ lp->hw.command(dev, RXcmd | (lp->cur_rx << 3) | RXbcasts);
}
didsomething++;
}
@@ -774,10 +776,10 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
BUGMSG(D_DURING, "EXCNAK IRQ (diagstat=%Xh)\n",
diagstatus);

- ACOMMAND(NOTXcmd); /* disable transmit */
+ lp->hw.command(dev, NOTXcmd); /* disable transmit */
lp->excnak_pending = 1;

- ACOMMAND(EXCNAKclear);
+ lp->hw.command(dev, EXCNAKclear);
lp->intmask &= ~(EXCNAKflag);
didsomething++;
}
@@ -860,7 +862,7 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
didsomething++;
}
if (status & lp->intmask & RECONflag) {
- ACOMMAND(CFLAGScmd | CONFIGclear);
+ lp->hw.command(dev, CFLAGScmd | CONFIGclear);
dev->stats.tx_carrier_errors++;

BUGMSG(D_RECON, "Network reconfiguration detected (status=%Xh)\n",
@@ -921,12 +923,12 @@ irqreturn_t arcnet_interrupt(int irq, void *dev_id)
while (--boguscount && didsomething);

BUGMSG(D_DURING, "arcnet_interrupt complete (status=%Xh, count=%d)\n",
- ASTATUS(), boguscount);
+ lp->hw.status(dev), boguscount);
BUGMSG(D_DURING, "\n");

- AINTMASK(0);
+ lp->hw.intmask(dev, 0);
udelay(1);
- AINTMASK(lp->intmask);
+ lp->hw.intmask(dev, lp->intmask);

spin_unlock(&lp->lock);
return retval;
diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
index 81f336f..c20f100 100644
--- a/include/linux/arcdevice.h
+++ b/include/linux/arcdevice.h
@@ -314,13 +314,6 @@ struct arcnet_local {
};


-#define ARCRESET(x) (lp->hw.reset(dev, (x)))
-#define ACOMMAND(x) (lp->hw.command(dev, (x)))
-#define ASTATUS() (lp->hw.status(dev))
-#define AINTMASK(x) (lp->hw.intmask(dev, (x)))
-
-
-
#if ARCNET_DEBUG_MAX & D_SKB
void arcnet_dump_skb(struct net_device *dev, struct sk_buff *skb, char *desc);
#else
--
2.1.4

2015-04-24 17:22:33

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 06/21] ARCNET: com20020: remove unneeded macros

The macros SET_SUBADR, ARCRESET, ARCRESET0, ACOMMAND, ASTATUS, AINTMASK
and ADIAGSTATUS are unnecessary indirections to the use of registers.
This patch removes them and improves the readability of the code.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com20020-isa.c | 2 +-
drivers/net/arcnet/com20020-pci.c | 2 +-
drivers/net/arcnet/com20020.c | 56 ++++++++++++++++++++++-----------------
include/linux/com20020.h | 33 -----------------------
4 files changed, 34 insertions(+), 59 deletions(-)

diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index d8746ca..c674511 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -68,7 +68,7 @@ static int __init com20020isa_probe(struct net_device *dev)
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
- if (ASTATUS() == 0xFF) {
+ if (inb(_STATUS) == 0xFF) {
BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
err = -ENODEV;
goto out;
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index 9fa4eee..18c0b1f 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -132,7 +132,7 @@ static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
lp->timeout = timeout;
lp->hw.owner = THIS_MODULE;

- if (ASTATUS() == 0xFF) {
+ if (inb(_STATUS) == 0xFF) {
pr_err("IO address %Xh is empty!\n", ioaddr);
ret = -EIO;
goto out_port;
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 0d84f6c..ed0cdd3 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -91,7 +91,10 @@ int com20020_check(struct net_device *dev)
int ioaddr = dev->base_addr, status;
struct arcnet_local *lp = netdev_priv(dev);

- ARCRESET0;
+ /* reset the card */
+ outb(0x18 | 0x80, _CONFIG);
+ udelay(5);
+ outb(0x18, _CONFIG);
mdelay(RESETtime);

lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
@@ -101,12 +104,13 @@ int com20020_check(struct net_device *dev)
/* Enable P1Mode for backplane mode */
lp->setup = lp->setup | P1MODE;

- SET_SUBADR(SUB_SETUP1);
+ lp->config = (lp->config & ~0x03) | SUB_SETUP1;
+ outb(lp->config, _CONFIG);
outb(lp->setup, _XREG);

if (lp->clockm != 0)
{
- SET_SUBADR(SUB_SETUP2);
+ outb(SUB_SETUP2, _SUBADR);
outb(lp->setup2, _XREG);

/* must now write the magic "restart operation" command */
@@ -116,10 +120,10 @@ int com20020_check(struct net_device *dev)

lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
- SETCONF;
+ outb(lp->config, _CONFIG);
outb(0x42, ioaddr + BUS_ALIGN*7);

- status = ASTATUS();
+ status = inb(_STATUS);

if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) {
BUGMSG(D_NORMAL, "status invalid (%Xh).\n", status);
@@ -131,9 +135,9 @@ int com20020_check(struct net_device *dev)
outb(0x39, _CONFIG);
outb(inb(ioaddr + BUS_ALIGN*8), ioaddr + BUS_ALIGN*7);

- ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
+ outb((CFLAGScmd | RESETclear | CONFIGclear), _COMMAND);

- status = ASTATUS();
+ status = inb(_STATUS);
BUGMSG(D_INIT_REASONS, "status after reset acknowledged: %X\n",
status);

@@ -156,7 +160,8 @@ static int com20020_set_hwaddr(struct net_device *dev, void *addr)
struct sockaddr *hwaddr = addr;

memcpy(dev->dev_addr, hwaddr->sa_data, 1);
- SET_SUBADR(SUB_NODE);
+ lp->config = (lp->config & ~0x03) | SUB_NODE;
+ outb(lp->config, _CONFIG);
outb(dev->dev_addr[0], _XREG);

return 0;
@@ -195,12 +200,13 @@ int com20020_found(struct net_device *dev, int shared)
if (!dev->dev_addr[0])
dev->dev_addr[0] = inb(ioaddr + BUS_ALIGN*8); /* FIXME: do this some other way! */

- SET_SUBADR(SUB_SETUP1);
+ lp->config = (lp->config & ~0x03) | SUB_SETUP1;
+ outb(lp->config, _CONFIG);
outb(lp->setup, _XREG);

if (lp->card_flags & ARC_CAN_10MBIT)
{
- SET_SUBADR(SUB_SETUP2);
+ outb(SUB_SETUP2, _SUBADR);
outb(lp->setup2, _XREG);

/* must now write the magic "restart operation" command */
@@ -210,7 +216,7 @@ int com20020_found(struct net_device *dev, int shared)

lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
/* Default 0x38 + register: Node ID */
- SETCONF;
+ outb(lp->config, _CONFIG);
outb(dev->dev_addr[0], _XREG);

/* reserve the irq */
@@ -259,22 +265,24 @@ static int com20020_reset(struct net_device *dev, int really_reset)
BUGMSG(D_DEBUG, "%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n",
__FILE__,__LINE__,__func__,dev,lp,dev->name);
BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n",
- dev->name, ASTATUS());
+ dev->name, inb(_STATUS));

BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
/* power-up defaults */
- SETCONF;
+ outb(lp->config, _CONFIG);
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

if (really_reset) {
/* reset the card */
- ARCRESET;
+ outb(lp->config | 0x80, _CONFIG);
+ udelay(5);
+ outb(lp->config, _CONFIG);
mdelay(RESETtime * 2); /* COM20020 seems to be slower sometimes */
}
/* clear flags & end reset */
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
- ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
+ outb((CFLAGScmd | RESETclear | CONFIGclear), _COMMAND);

/* verify that the ARCnet signature byte is present */
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
@@ -287,26 +295,24 @@ static int com20020_reset(struct net_device *dev, int really_reset)
return 1;
}
/* enable extended (512-byte) packets */
- ACOMMAND(CONFIGcmd | EXTconf);
+ outb((CONFIGcmd | EXTconf), _COMMAND);
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

/* done! return success. */
return 0;
}

-
static void com20020_setmask(struct net_device *dev, int mask)
{
u_int ioaddr = dev->base_addr;
BUGMSG(D_DURING, "Setting mask to %x at %x\n",mask,ioaddr);
- AINTMASK(mask);
+ outb((mask), _INTMASK);
}

-
static void com20020_command(struct net_device *dev, int cmd)
{
u_int ioaddr = dev->base_addr;
- ACOMMAND(cmd);
+ outb(cmd, _COMMAND);
}


@@ -314,7 +320,7 @@ static int com20020_status(struct net_device *dev)
{
u_int ioaddr = dev->base_addr;

- return ASTATUS() + (ADIAGSTATUS()<<8);
+ return inb(_STATUS) + (inb(_DIAGSTAT) << 8);
}

static void com20020_close(struct net_device *dev)
@@ -324,7 +330,7 @@ static void com20020_close(struct net_device *dev)

/* disable transmitter */
lp->config &= ~TXENcfg;
- SETCONF;
+ outb(lp->config, _CONFIG);
}

/* Set or clear the multicast filter for this adaptor.
@@ -342,7 +348,8 @@ static void com20020_set_mc_list(struct net_device *dev)
if ((dev->flags & IFF_PROMISC) && (dev->flags & IFF_UP)) { /* Enable promiscuous mode */
if (!(lp->setup & PROMISCset))
BUGMSG(D_NORMAL, "Setting promiscuous flag...\n");
- SET_SUBADR(SUB_SETUP1);
+ lp->config = (lp->config & ~0x03) | SUB_SETUP1;
+ outb(lp->config, _CONFIG);
lp->setup |= PROMISCset;
outb(lp->setup, _XREG);
} else
@@ -350,7 +357,8 @@ static void com20020_set_mc_list(struct net_device *dev)
{
if ((lp->setup & PROMISCset))
BUGMSG(D_NORMAL, "Resetting promiscuous flag...\n");
- SET_SUBADR(SUB_SETUP1);
+ lp->config = (lp->config & ~0x03) | SUB_SETUP1;
+ outb(lp->config, _CONFIG);
lp->setup &= ~PROMISCset;
outb(lp->setup, _XREG);
}
diff --git a/include/linux/com20020.h b/include/linux/com20020.h
index 5ce5c7d..2aaa57d 100644
--- a/include/linux/com20020.h
+++ b/include/linux/com20020.h
@@ -109,37 +109,4 @@ struct com20020_dev {
#define SUB_BUSCTL 5 /* bus control options */
#define SUB_DMACOUNT 6 /* DMA count options */

-#define SET_SUBADR(x) do { \
- if ((x) < 4) \
- { \
- lp->config = (lp->config & ~0x03) | (x); \
- SETCONF; \
- } \
- else \
- { \
- outb(x, _SUBADR); \
- } \
-} while (0)
-
-#undef ARCRESET
-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ARCRESET { outb(lp->config | 0x80, _CONFIG); \
- udelay(5); \
- outb(lp->config , _CONFIG); \
- }
-#define ARCRESET0 { outb(0x18 | 0x80, _CONFIG); \
- udelay(5); \
- outb(0x18 , _CONFIG); \
- }
-
-#define ASTATUS() inb(_STATUS)
-#define ADIAGSTATUS() inb(_DIAGSTAT)
-#define ACOMMAND(cmd) outb((cmd),_COMMAND)
-#define AINTMASK(msk) outb((msk),_INTMASK)
-
-#define SETCONF outb(lp->config, _CONFIG)
-
#endif /* __COM20020_H */
--
2.1.4

2015-04-24 17:23:43

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 07/21] ARCNET: rimi: remove unneeded macros

The simple macros ARCRESET, ACOMMAND, ASTATUS, AINTMASK are unnecessary
indirections to the use of registers. This patch removes them and improves the
readability of the code.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/arc-rimi.c | 24 +++++++-----------------
1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index 4c95d3c..c920b86 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -69,16 +69,6 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse
#define _ADDR_LO (ioaddr+14)
#define _CONFIG (ioaddr+2) /* Configuration register */

-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ASTATUS() readb(_STATUS)
-#define ACOMMAND(cmd) writeb((cmd),_COMMAND)
-#define AINTMASK(msk) writeb((msk),_INTMASK)
-#define SETCONF() writeb(lp->config,_CONFIG)
-
-
/*
* We cannot probe for a RIM I card; one reason is I don't know how to reset
* them. In fact, we can't even get their node ID automatically. So, we
@@ -263,17 +253,17 @@ static int arcrimi_reset(struct net_device *dev, int really_reset)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS());
+ BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, readb(_STATUS));

if (really_reset) {
writeb(TESTvalue, ioaddr - 0x800); /* fake reset */
return 0;
}
- ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */
- ACOMMAND(CFLAGScmd | CONFIGclear);
+ writeb(CFLAGScmd | RESETclear, _COMMAND); /* clear flags & end reset */
+ writeb(CFLAGScmd | CONFIGclear, _COMMAND);

/* enable extended (512-byte) packets */
- ACOMMAND(CONFIGcmd | EXTconf);
+ writeb(CONFIGcmd | EXTconf, _COMMAND);

/* done! return success. */
return 0;
@@ -284,7 +274,7 @@ static void arcrimi_setmask(struct net_device *dev, int mask)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- AINTMASK(mask);
+ writeb(mask, _INTMASK);
}

static int arcrimi_status(struct net_device *dev)
@@ -292,7 +282,7 @@ static int arcrimi_status(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- return ASTATUS();
+ return readb(_STATUS);
}

static void arcrimi_command(struct net_device *dev, int cmd)
@@ -300,7 +290,7 @@ static void arcrimi_command(struct net_device *dev, int cmd)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- ACOMMAND(cmd);
+ writeb(cmd, _COMMAND);
}

static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
--
2.1.4

2015-04-24 17:26:45

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 08/21] ARCNET: com90io: remove unneeded macros

The simple macros ARCRESET, ACOMMAND, ASTATUS, AINTMASK are unnecessary
indirections to the use of registers. This patch removes them and
improves the readability of the code.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com90io.c | 36 +++++++++++++-----------------------
1 file changed, 13 insertions(+), 23 deletions(-)

diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index b1279af..6bc6366 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -69,16 +69,6 @@ static void com90io_copy_from_card(struct net_device *dev, int bufnum, int offse
#define _ADDR_LO (ioaddr+14)
#define _CONFIG (ioaddr+2) /* Configuration register */

-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ASTATUS() inb(_STATUS)
-#define ACOMMAND(cmd) outb((cmd),_COMMAND)
-#define AINTMASK(msk) outb((msk),_INTMASK)
-#define SETCONF() outb((lp->config),_CONFIG)
-
-
/****************************************************************************
* *
* IO-mapped operation routines *
@@ -164,14 +154,14 @@ static int __init com90io_probe(struct net_device *dev)
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
- if (ASTATUS() == 0xFF) {
+ if (inb(_STATUS) == 0xFF) {
BUGMSG(D_INIT_REASONS, "IO address %x empty\n", ioaddr);
goto err_out;
}
inb(_RESET);
mdelay(RESETtime);

- status = ASTATUS();
+ status = inb(_STATUS);

if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
BUGMSG(D_INIT_REASONS, "Status invalid (%Xh).\n", status);
@@ -179,11 +169,11 @@ static int __init com90io_probe(struct net_device *dev)
}
BUGMSG(D_INIT_REASONS, "Status after reset: %X\n", status);

- ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
+ outb(CFLAGScmd | RESETclear | CONFIGclear, _COMMAND);

BUGMSG(D_INIT_REASONS, "Status after reset acknowledged: %X\n", status);

- status = ASTATUS();
+ status = inb(_STATUS);

if (status & RESETflag) {
BUGMSG(D_INIT_REASONS, "Eternal reset (status=%Xh)\n", status);
@@ -259,7 +249,7 @@ static int __init com90io_found(struct net_device *dev)
lp->hw.copy_from_card = com90io_copy_from_card;

lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;
- SETCONF();
+ outb(lp->config, _CONFIG);

/* get and check the station ID from offset 1 in shmem */

@@ -293,7 +283,7 @@ static int com90io_reset(struct net_device *dev, int really_reset)
struct arcnet_local *lp = netdev_priv(dev);
short ioaddr = dev->base_addr;

- BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, ASTATUS());
+ BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, inb(_STATUS));

if (really_reset) {
/* reset the card */
@@ -302,10 +292,10 @@ static int com90io_reset(struct net_device *dev, int really_reset)
}
/* Set the thing to IO-mapped, 8-bit mode */
lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag;
- SETCONF();
+ outb(lp->config, _CONFIG);

- ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */
- ACOMMAND(CFLAGScmd | CONFIGclear);
+ outb(CFLAGScmd | RESETclear, _COMMAND); /* clear flags & end reset */
+ outb(CFLAGScmd | CONFIGclear, _COMMAND);

/* verify that the ARCnet signature byte is present */
if (get_buffer_byte(dev, 0) != TESTvalue) {
@@ -313,7 +303,7 @@ static int com90io_reset(struct net_device *dev, int really_reset)
return 1;
}
/* enable extended (512-byte) packets */
- ACOMMAND(CONFIGcmd | EXTconf);
+ outb(CONFIGcmd | EXTconf, _COMMAND);

/* done! return success. */
return 0;
@@ -324,7 +314,7 @@ static void com90io_command(struct net_device *dev, int cmd)
{
short ioaddr = dev->base_addr;

- ACOMMAND(cmd);
+ outb(cmd, _COMMAND);
}


@@ -332,7 +322,7 @@ static int com90io_status(struct net_device *dev)
{
short ioaddr = dev->base_addr;

- return ASTATUS();
+ return inb(_STATUS);
}


@@ -340,7 +330,7 @@ static void com90io_setmask(struct net_device *dev, int mask)
{
short ioaddr = dev->base_addr;

- AINTMASK(mask);
+ outb(mask, _INTMASK);
}

static void com90io_copy_to_card(struct net_device *dev, int bufnum, int offset,
--
2.1.4

2015-04-24 17:23:32

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 09/21] ARCNET: com90xx: remove unneeded macros

The simple macros ARCRESET, ACOMMAND, ASTATUS, AINTMASK are unnecessary
indirections to the use of registers. This patch removes them and
improves the readability of the code.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com90xx.c | 35 +++++++++++++----------------------
1 file changed, 13 insertions(+), 22 deletions(-)

diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index 03bd71c..2b99a04 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -89,15 +89,6 @@ static int numcards;
#define _ADDR_HI (ioaddr+15) /* Control registers for said */
#define _ADDR_LO (ioaddr+14)

-#undef ASTATUS
-#undef ACOMMAND
-#undef AINTMASK
-
-#define ASTATUS() inb(_STATUS)
-#define ACOMMAND(cmd) outb((cmd),_COMMAND)
-#define AINTMASK(msk) outb((msk),_INTMASK)
-
-
static int com90xx_skip_probe __initdata = 0;

/* Module parameters */
@@ -175,7 +166,7 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
- if (ASTATUS() == 0xFF) {
+ if (inb(_STATUS) == 0xFF) {
BUGMSG2(D_INIT_REASONS, "(empty)\n");
BUGMSG2(D_INIT_REASONS, "S1: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
@@ -317,7 +308,7 @@ static void __init com90xx_probe(void)
BUGMSG2(D_INIT, "%Xh ", *port);

ioaddr = *port;
- status = ASTATUS();
+ status = inb(_STATUS);

if ((status & 0x9D)
!= (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
@@ -328,8 +319,8 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
- ACOMMAND(CFLAGScmd | RESETclear | CONFIGclear);
- status = ASTATUS();
+ outb(CFLAGScmd | RESETclear | CONFIGclear, _COMMAND);
+ status = inb(_STATUS);
if (status & RESETflag) {
BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
status);
@@ -348,9 +339,9 @@ static void __init com90xx_probe(void)
* we tell it to start receiving.
*/
airqmask = probe_irq_on();
- AINTMASK(NORXflag);
+ outb(NORXflag, _INTMASK);
udelay(1);
- AINTMASK(0);
+ outb(0, _INTMASK);
airq = probe_irq_off(airqmask);

if (airq <= 0) {
@@ -557,7 +548,7 @@ static void com90xx_command(struct net_device *dev, int cmd)
{
short ioaddr = dev->base_addr;

- ACOMMAND(cmd);
+ outb(cmd, _COMMAND);
}


@@ -565,7 +556,7 @@ static int com90xx_status(struct net_device *dev)
{
short ioaddr = dev->base_addr;

- return ASTATUS();
+ return inb(_STATUS);
}


@@ -573,7 +564,7 @@ static void com90xx_setmask(struct net_device *dev, int mask)
{
short ioaddr = dev->base_addr;

- AINTMASK(mask);
+ outb(mask, _INTMASK);
}


@@ -590,15 +581,15 @@ static int com90xx_reset(struct net_device *dev, int really_reset)
struct arcnet_local *lp = netdev_priv(dev);
short ioaddr = dev->base_addr;

- BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", ASTATUS());
+ BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", inb(_STATUS));

if (really_reset) {
/* reset the card */
inb(_RESET);
mdelay(RESETtime);
}
- ACOMMAND(CFLAGScmd | RESETclear); /* clear flags & end reset */
- ACOMMAND(CFLAGScmd | CONFIGclear);
+ outb(CFLAGScmd | RESETclear, _COMMAND); /* clear flags & end reset */
+ outb(CFLAGScmd | CONFIGclear, _COMMAND);

/* don't do this until we verify that it doesn't hurt older cards! */
/* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */
@@ -610,7 +601,7 @@ static int com90xx_reset(struct net_device *dev, int really_reset)
return 1;
}
/* enable extended (512-byte) packets */
- ACOMMAND(CONFIGcmd | EXTconf);
+ outb(CONFIGcmd | EXTconf, _COMMAND);

/* clean out all the memory to make debugging make more sense :) */
BUGLVL(D_DURING)
--
2.1.4

2015-04-24 17:26:33

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 10/21] ARCNET: com20020: fix ioaddr prefixes

This patch removes the use of the variable ioaddr in the macros
and uses it directly in the calling functions. This improves
the readability of the code and changes the macros to be used as
offsets.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com20020-isa.c | 2 +-
drivers/net/arcnet/com20020.c | 89 ++++++++++++++++++++-------------------
drivers/net/arcnet/com20020_cs.c | 6 +--
include/linux/com20020.h | 20 ++++-----
4 files changed, 59 insertions(+), 58 deletions(-)

diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c
index c674511..3e5be24 100644
--- a/drivers/net/arcnet/com20020-isa.c
+++ b/drivers/net/arcnet/com20020-isa.c
@@ -68,7 +68,7 @@ static int __init com20020isa_probe(struct net_device *dev)
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
- if (inb(_STATUS) == 0xFF) {
+ if (inb(ioaddr + _STATUS) == 0xFF) {
BUGMSG(D_NORMAL, "IO address %x empty\n", ioaddr);
err = -ENODEV;
goto out;
diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index ed0cdd3..4b4bb96 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -63,11 +63,11 @@ static void com20020_copy_from_card(struct net_device *dev, int bufnum,
int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;

/* set up the address register */
- outb((ofs >> 8) | RDDATAflag | AUTOINCflag, _ADDR_HI);
- outb(ofs & 0xff, _ADDR_LO);
+ outb((ofs >> 8) | RDDATAflag | AUTOINCflag, ioaddr + _ADDR_HI);
+ outb(ofs & 0xff, ioaddr + _ADDR_LO);

/* copy the data */
- TIME("insb", count, insb(_MEMDATA, buf, count));
+ TIME("insb", count, insb(ioaddr + _MEMDATA, buf, count));
}


@@ -77,11 +77,11 @@ static void com20020_copy_to_card(struct net_device *dev, int bufnum,
int ioaddr = dev->base_addr, ofs = 512 * bufnum + offset;

/* set up the address register */
- outb((ofs >> 8) | AUTOINCflag, _ADDR_HI);
- outb(ofs & 0xff, _ADDR_LO);
+ outb((ofs >> 8) | AUTOINCflag, ioaddr + _ADDR_HI);
+ outb(ofs & 0xff, ioaddr + _ADDR_LO);

/* copy the data */
- TIME("outsb", count, outsb(_MEMDATA, buf, count));
+ TIME("outsb", count, outsb(ioaddr + _MEMDATA, buf, count));
}


@@ -92,9 +92,9 @@ int com20020_check(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);

/* reset the card */
- outb(0x18 | 0x80, _CONFIG);
+ outb(0x18 | 0x80, ioaddr + _CONFIG);
udelay(5);
- outb(0x18, _CONFIG);
+ outb(0x18, ioaddr + _CONFIG);
mdelay(RESETtime);

lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
@@ -105,25 +105,25 @@ int com20020_check(struct net_device *dev)
lp->setup = lp->setup | P1MODE;

lp->config = (lp->config & ~0x03) | SUB_SETUP1;
- outb(lp->config, _CONFIG);
- outb(lp->setup, _XREG);
+ outb(lp->config, ioaddr + _CONFIG);
+ outb(lp->setup, ioaddr + _XREG);

if (lp->clockm != 0)
{
- outb(SUB_SETUP2, _SUBADR);
- outb(lp->setup2, _XREG);
+ outb(SUB_SETUP2, ioaddr + _SUBADR);
+ outb(lp->setup2, ioaddr + _XREG);

/* must now write the magic "restart operation" command */
mdelay(1);
- outb(0x18, _COMMAND);
+ outb(0x18, ioaddr + _COMMAND);
}

lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
/* set node ID to 0x42 (but transmitter is disabled, so it's okay) */
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);
outb(0x42, ioaddr + BUS_ALIGN*7);

- status = inb(_STATUS);
+ status = inb(ioaddr + _STATUS);

if ((status & 0x99) != (NORXflag | TXFREEflag | RESETflag)) {
BUGMSG(D_NORMAL, "status invalid (%Xh).\n", status);
@@ -132,20 +132,21 @@ int com20020_check(struct net_device *dev)
BUGMSG(D_INIT_REASONS, "status after reset: %X\n", status);

/* Enable TX */
- outb(0x39, _CONFIG);
+ outb(0x39, ioaddr + _CONFIG);
outb(inb(ioaddr + BUS_ALIGN*8), ioaddr + BUS_ALIGN*7);

- outb((CFLAGScmd | RESETclear | CONFIGclear), _COMMAND);
+ outb((CFLAGScmd | RESETclear | CONFIGclear), ioaddr + _COMMAND);

- status = inb(_STATUS);
+ status = inb(ioaddr + _STATUS);
BUGMSG(D_INIT_REASONS, "status after reset acknowledged: %X\n",
status);

/* Read first location of memory */
- outb(0 | RDDATAflag | AUTOINCflag, _ADDR_HI);
- outb(0, _ADDR_LO);
+ outb(0 | RDDATAflag | AUTOINCflag, ioaddr + _ADDR_HI);
+ outb(0, ioaddr + _ADDR_LO);

- if ((status = inb(_MEMDATA)) != TESTvalue) {
+ status = inb(ioaddr + _MEMDATA);
+ if (status != TESTvalue) {
BUGMSG(D_NORMAL, "Signature byte not found (%02Xh != D1h).\n",
status);
return -ENODEV;
@@ -161,8 +162,8 @@ static int com20020_set_hwaddr(struct net_device *dev, void *addr)

memcpy(dev->dev_addr, hwaddr->sa_data, 1);
lp->config = (lp->config & ~0x03) | SUB_NODE;
- outb(lp->config, _CONFIG);
- outb(dev->dev_addr[0], _XREG);
+ outb(lp->config, ioaddr + _CONFIG);
+ outb(dev->dev_addr[0], ioaddr + _XREG);

return 0;
}
@@ -201,23 +202,23 @@ int com20020_found(struct net_device *dev, int shared)
dev->dev_addr[0] = inb(ioaddr + BUS_ALIGN*8); /* FIXME: do this some other way! */

lp->config = (lp->config & ~0x03) | SUB_SETUP1;
- outb(lp->config, _CONFIG);
- outb(lp->setup, _XREG);
+ outb(lp->config, ioaddr + _CONFIG);
+ outb(lp->setup, ioaddr + _XREG);

if (lp->card_flags & ARC_CAN_10MBIT)
{
- outb(SUB_SETUP2, _SUBADR);
- outb(lp->setup2, _XREG);
+ outb(SUB_SETUP2, ioaddr + _SUBADR);
+ outb(lp->setup2, ioaddr + _XREG);

/* must now write the magic "restart operation" command */
mdelay(1);
- outb(0x18, _COMMAND);
+ outb(0x18, ioaddr + _COMMAND);
}

lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
/* Default 0x38 + register: Node ID */
- outb(lp->config, _CONFIG);
- outb(dev->dev_addr[0], _XREG);
+ outb(lp->config, ioaddr + _CONFIG);
+ outb(dev->dev_addr[0], ioaddr + _XREG);

/* reserve the irq */
if (request_irq(dev->irq, arcnet_interrupt, shared,
@@ -265,24 +266,24 @@ static int com20020_reset(struct net_device *dev, int really_reset)
BUGMSG(D_DEBUG, "%s: %d: %s: dev: %p, lp: %p, dev->name: %s\n",
__FILE__,__LINE__,__func__,dev,lp,dev->name);
BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n",
- dev->name, inb(_STATUS));
+ dev->name, inb(ioaddr + _STATUS));

BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2);
/* power-up defaults */
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

if (really_reset) {
/* reset the card */
- outb(lp->config | 0x80, _CONFIG);
+ outb(lp->config | 0x80, ioaddr + _CONFIG);
udelay(5);
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);
mdelay(RESETtime * 2); /* COM20020 seems to be slower sometimes */
}
/* clear flags & end reset */
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
- outb((CFLAGScmd | RESETclear | CONFIGclear), _COMMAND);
+ outb((CFLAGScmd | RESETclear | CONFIGclear), ioaddr + _COMMAND);

/* verify that the ARCnet signature byte is present */
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);
@@ -295,7 +296,7 @@ static int com20020_reset(struct net_device *dev, int really_reset)
return 1;
}
/* enable extended (512-byte) packets */
- outb((CONFIGcmd | EXTconf), _COMMAND);
+ outb((CONFIGcmd | EXTconf), ioaddr + _COMMAND);
BUGMSG(D_DEBUG, "%s: %d: %s\n",__FILE__,__LINE__,__func__);

/* done! return success. */
@@ -306,13 +307,13 @@ static void com20020_setmask(struct net_device *dev, int mask)
{
u_int ioaddr = dev->base_addr;
BUGMSG(D_DURING, "Setting mask to %x at %x\n",mask,ioaddr);
- outb((mask), _INTMASK);
+ outb((mask), ioaddr + _INTMASK);
}

static void com20020_command(struct net_device *dev, int cmd)
{
u_int ioaddr = dev->base_addr;
- outb(cmd, _COMMAND);
+ outb(cmd, ioaddr + _COMMAND);
}


@@ -320,7 +321,7 @@ static int com20020_status(struct net_device *dev)
{
u_int ioaddr = dev->base_addr;

- return inb(_STATUS) + (inb(_DIAGSTAT) << 8);
+ return inb(ioaddr + _STATUS) + (inb(ioaddr + _DIAGSTAT) << 8);
}

static void com20020_close(struct net_device *dev)
@@ -330,7 +331,7 @@ static void com20020_close(struct net_device *dev)

/* disable transmitter */
lp->config &= ~TXENcfg;
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);
}

/* Set or clear the multicast filter for this adaptor.
@@ -349,18 +350,18 @@ static void com20020_set_mc_list(struct net_device *dev)
if (!(lp->setup & PROMISCset))
BUGMSG(D_NORMAL, "Setting promiscuous flag...\n");
lp->config = (lp->config & ~0x03) | SUB_SETUP1;
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);
lp->setup |= PROMISCset;
- outb(lp->setup, _XREG);
+ outb(lp->setup, ioaddr + _XREG);
} else
/* Disable promiscuous mode, use normal mode */
{
if ((lp->setup & PROMISCset))
BUGMSG(D_NORMAL, "Resetting promiscuous flag...\n");
lp->config = (lp->config & ~0x03) | SUB_SETUP1;
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);
lp->setup &= ~PROMISCset;
- outb(lp->setup, _XREG);
+ outb(lp->setup, ioaddr + _XREG);
}
}

diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index aee4455..dfde685 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -67,15 +67,15 @@ static void regdump(struct net_device *dev)
netdev_dbg(dev, "buffer0 dump:\n");
/* set up the address register */
count = 0;
- outb((count >> 8) | RDDATAflag | AUTOINCflag, _ADDR_HI);
- outb(count & 0xff, _ADDR_LO);
+ outb((count >> 8) | RDDATAflag | AUTOINCflag, ioaddr + _ADDR_HI);
+ outb(count & 0xff, ioaddr + _ADDR_LO);

for (count = 0; count < 256 + 32; count++) {
if (!(count % 16))
pr_cont("%04X:", count);

/* copy the data */
- pr_cont(" %02X", inb(_MEMDATA));
+ pr_cont(" %02X", inb(ioaddr + _MEMDATA));
}
pr_cont("\n");
#endif
diff --git a/include/linux/com20020.h b/include/linux/com20020.h
index 2aaa57d..c2d8647 100644
--- a/include/linux/com20020.h
+++ b/include/linux/com20020.h
@@ -71,16 +71,16 @@ struct com20020_dev {
int index;
};

-#define _INTMASK (ioaddr+BUS_ALIGN*0) /* writable */
-#define _STATUS (ioaddr+BUS_ALIGN*0) /* readable */
-#define _COMMAND (ioaddr+BUS_ALIGN*1) /* standard arcnet commands */
-#define _DIAGSTAT (ioaddr+BUS_ALIGN*1) /* diagnostic status register */
-#define _ADDR_HI (ioaddr+BUS_ALIGN*2) /* control registers for IO-mapped memory */
-#define _ADDR_LO (ioaddr+BUS_ALIGN*3)
-#define _MEMDATA (ioaddr+BUS_ALIGN*4) /* data port for IO-mapped memory */
-#define _SUBADR (ioaddr+BUS_ALIGN*5) /* the extended port _XREG refers to */
-#define _CONFIG (ioaddr+BUS_ALIGN*6) /* configuration register */
-#define _XREG (ioaddr+BUS_ALIGN*7) /* extra registers (indexed by _CONFIG
+#define _INTMASK (BUS_ALIGN*0) /* writable */
+#define _STATUS (BUS_ALIGN*0) /* readable */
+#define _COMMAND (BUS_ALIGN*1) /* standard arcnet commands */
+#define _DIAGSTAT (BUS_ALIGN*1) /* diagnostic status register */
+#define _ADDR_HI (BUS_ALIGN*2) /* control registers for IO-mapped memory */
+#define _ADDR_LO (BUS_ALIGN*3)
+#define _MEMDATA (BUS_ALIGN*4) /* data port for IO-mapped memory */
+#define _SUBADR (BUS_ALIGN*5) /* the extended port _XREG refers to */
+#define _CONFIG (BUS_ALIGN*6) /* configuration register */
+#define _XREG (BUS_ALIGN*7) /* extra registers (indexed by _CONFIG
or _SUBADR) */

/* in the ADDR_HI register */
--
2.1.4

2015-04-24 17:23:45

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 11/21] ARCNET: rimi: fix ioaddr prefixes

This patch removes the use of the variable ioaddr in the macros
and uses it directly in the calling functions. This improves
the readability of the code and changes the macros to be used as
offsets.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/arc-rimi.c | 30 +++++++++++++++---------------
1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/net/arcnet/arc-rimi.c b/drivers/net/arcnet/arc-rimi.c
index c920b86..6e28a51 100644
--- a/drivers/net/arcnet/arc-rimi.c
+++ b/drivers/net/arcnet/arc-rimi.c
@@ -60,14 +60,14 @@ static void arcrimi_copy_from_card(struct net_device *dev, int bufnum, int offse
#define MIRROR_SIZE (BUFFER_SIZE*4)

/* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK (ioaddr+0) /* writable */
-#define _STATUS (ioaddr+0) /* readable */
-#define _COMMAND (ioaddr+1) /* writable, returns random vals on read (?) */
-#define _RESET (ioaddr+8) /* software reset (on read) */
-#define _MEMDATA (ioaddr+12) /* Data port for IO-mapped memory */
-#define _ADDR_HI (ioaddr+15) /* Control registers for said */
-#define _ADDR_LO (ioaddr+14)
-#define _CONFIG (ioaddr+2) /* Configuration register */
+#define _INTMASK 0 /* writable */
+#define _STATUS 0 /* readable */
+#define _COMMAND 1 /* writable, returns random vals on read (?) */
+#define _RESET 8 /* software reset (on read) */
+#define _MEMDATA 12 /* Data port for IO-mapped memory */
+#define _ADDR_HI 15 /* Control registers for said */
+#define _ADDR_LO 14
+#define _CONFIG 2 /* Configuration register */

/*
* We cannot probe for a RIM I card; one reason is I don't know how to reset
@@ -253,17 +253,17 @@ static int arcrimi_reset(struct net_device *dev, int really_reset)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, readb(_STATUS));
+ BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, readb(ioaddr + _STATUS));

if (really_reset) {
writeb(TESTvalue, ioaddr - 0x800); /* fake reset */
return 0;
}
- writeb(CFLAGScmd | RESETclear, _COMMAND); /* clear flags & end reset */
- writeb(CFLAGScmd | CONFIGclear, _COMMAND);
+ writeb(CFLAGScmd | RESETclear, ioaddr + _COMMAND); /* clear flags & end reset */
+ writeb(CFLAGScmd | CONFIGclear, ioaddr + _COMMAND);

/* enable extended (512-byte) packets */
- writeb(CONFIGcmd | EXTconf, _COMMAND);
+ writeb(CONFIGcmd | EXTconf, ioaddr + _COMMAND);

/* done! return success. */
return 0;
@@ -274,7 +274,7 @@ static void arcrimi_setmask(struct net_device *dev, int mask)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- writeb(mask, _INTMASK);
+ writeb(mask, ioaddr + _INTMASK);
}

static int arcrimi_status(struct net_device *dev)
@@ -282,7 +282,7 @@ static int arcrimi_status(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- return readb(_STATUS);
+ return readb(ioaddr + _STATUS);
}

static void arcrimi_command(struct net_device *dev, int cmd)
@@ -290,7 +290,7 @@ static void arcrimi_command(struct net_device *dev, int cmd)
struct arcnet_local *lp = netdev_priv(dev);
void __iomem *ioaddr = lp->mem_start + 0x800;

- writeb(cmd, _COMMAND);
+ writeb(cmd, ioaddr + _COMMAND);
}

static void arcrimi_copy_to_card(struct net_device *dev, int bufnum, int offset,
--
2.1.4

2015-04-24 17:23:51

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 12/21] ARCNET: com90io: fix ioaddr prefixes

This patch removes the use of the variable ioaddr in the macros
and uses it directly in the calling functions. This improves
the readability of the code and changes the macros to be used as
offsets.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com90io.c | 86 ++++++++++++++++++++++----------------------
1 file changed, 43 insertions(+), 43 deletions(-)

diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c
index 6bc6366..df7314d 100644
--- a/drivers/net/arcnet/com90io.c
+++ b/drivers/net/arcnet/com90io.c
@@ -60,14 +60,14 @@ static void com90io_copy_from_card(struct net_device *dev, int bufnum, int offse
#define ARCNET_TOTAL_SIZE 16

/* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK (ioaddr+0) /* writable */
-#define _STATUS (ioaddr+0) /* readable */
-#define _COMMAND (ioaddr+1) /* writable, returns random vals on read (?) */
-#define _RESET (ioaddr+8) /* software reset (on read) */
-#define _MEMDATA (ioaddr+12) /* Data port for IO-mapped memory */
-#define _ADDR_HI (ioaddr+15) /* Control registers for said */
-#define _ADDR_LO (ioaddr+14)
-#define _CONFIG (ioaddr+2) /* Configuration register */
+#define _INTMASK 0 /* writable */
+#define _STATUS 0 /* readable */
+#define _COMMAND 1 /* writable, returns random vals on read (?) */
+#define _RESET 8 /* software reset (on read) */
+#define _MEMDATA 12 /* Data port for IO-mapped memory */
+#define _ADDR_HI 15 /* Control registers for said */
+#define _ADDR_LO 14
+#define _CONFIG 2 /* Configuration register */

/****************************************************************************
* *
@@ -82,10 +82,10 @@ static u_char get_buffer_byte(struct net_device *dev, unsigned offset)
{
int ioaddr = dev->base_addr;

- outb(offset >> 8, _ADDR_HI);
- outb(offset & 0xff, _ADDR_LO);
+ outb(offset >> 8, ioaddr + _ADDR_HI);
+ outb(offset & 0xff, ioaddr + _ADDR_LO);

- return inb(_MEMDATA);
+ return inb(ioaddr + _MEMDATA);
}

#ifdef ONE_AT_A_TIME_TX
@@ -93,10 +93,10 @@ static void put_buffer_byte(struct net_device *dev, unsigned offset, u_char datu
{
int ioaddr = dev->base_addr;

- outb(offset >> 8, _ADDR_HI);
- outb(offset & 0xff, _ADDR_LO);
+ outb(offset >> 8, ioaddr + _ADDR_HI);
+ outb(offset & 0xff, ioaddr + _ADDR_LO);

- outb(datum, _MEMDATA);
+ outb(datum, ioaddr + _MEMDATA);
}

#endif
@@ -106,14 +106,14 @@ static void get_whole_buffer(struct net_device *dev, unsigned offset, unsigned l
{
int ioaddr = dev->base_addr;

- outb((offset >> 8) | AUTOINCflag, _ADDR_HI);
- outb(offset & 0xff, _ADDR_LO);
+ outb((offset >> 8) | AUTOINCflag, ioaddr + _ADDR_HI);
+ outb(offset & 0xff, ioaddr + _ADDR_LO);

while (length--)
#ifdef ONE_AT_A_TIME_RX
*(dest++) = get_buffer_byte(dev, offset++);
#else
- *(dest++) = inb(_MEMDATA);
+ *(dest++) = inb(ioaddr + _MEMDATA);
#endif
}

@@ -121,14 +121,14 @@ static void put_whole_buffer(struct net_device *dev, unsigned offset, unsigned l
{
int ioaddr = dev->base_addr;

- outb((offset >> 8) | AUTOINCflag, _ADDR_HI);
- outb(offset & 0xff, _ADDR_LO);
+ outb((offset >> 8) | AUTOINCflag, ioaddr + _ADDR_HI);
+ outb(offset & 0xff, ioaddr + _ADDR_LO);

while (length--)
#ifdef ONE_AT_A_TIME_TX
put_buffer_byte(dev, offset++, *(dest++));
#else
- outb(*(dest++), _MEMDATA);
+ outb(*(dest++), ioaddr + _MEMDATA);
#endif
}

@@ -154,14 +154,14 @@ static int __init com90io_probe(struct net_device *dev)
ioaddr, ioaddr + ARCNET_TOTAL_SIZE - 1);
return -ENXIO;
}
- if (inb(_STATUS) == 0xFF) {
+ if (inb(ioaddr + _STATUS) == 0xFF) {
BUGMSG(D_INIT_REASONS, "IO address %x empty\n", ioaddr);
goto err_out;
}
- inb(_RESET);
+ inb(ioaddr + _RESET);
mdelay(RESETtime);

- status = inb(_STATUS);
+ status = inb(ioaddr + _STATUS);

if ((status & 0x9D) != (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
BUGMSG(D_INIT_REASONS, "Status invalid (%Xh).\n", status);
@@ -169,24 +169,24 @@ static int __init com90io_probe(struct net_device *dev)
}
BUGMSG(D_INIT_REASONS, "Status after reset: %X\n", status);

- outb(CFLAGScmd | RESETclear | CONFIGclear, _COMMAND);
+ outb(CFLAGScmd | RESETclear | CONFIGclear, ioaddr + _COMMAND);

BUGMSG(D_INIT_REASONS, "Status after reset acknowledged: %X\n", status);

- status = inb(_STATUS);
+ status = inb(ioaddr + _STATUS);

if (status & RESETflag) {
BUGMSG(D_INIT_REASONS, "Eternal reset (status=%Xh)\n", status);
goto err_out;
}
- outb((0x16 | IOMAPflag) & ~ENABLE16flag, _CONFIG);
+ outb((0x16 | IOMAPflag) & ~ENABLE16flag, ioaddr + _CONFIG);

/* Read first loc'n of memory */

- outb(AUTOINCflag, _ADDR_HI);
- outb(0, _ADDR_LO);
+ outb(AUTOINCflag, ioaddr + _ADDR_HI);
+ outb(0, ioaddr + _ADDR_LO);

- if ((status = inb(_MEMDATA)) != 0xd1) {
+ if ((status = inb(ioaddr + _MEMDATA)) != 0xd1) {
BUGMSG(D_INIT_REASONS, "Signature byte not found"
" (%Xh instead).\n", status);
goto err_out;
@@ -199,9 +199,9 @@ static int __init com90io_probe(struct net_device *dev)
*/

airqmask = probe_irq_on();
- outb(NORXflag, _INTMASK);
+ outb(NORXflag, ioaddr + _INTMASK);
udelay(1);
- outb(0, _INTMASK);
+ outb(0, ioaddr + _INTMASK);
dev->irq = probe_irq_off(airqmask);

if ((int)dev->irq <= 0) {
@@ -249,7 +249,7 @@ static int __init com90io_found(struct net_device *dev)
lp->hw.copy_from_card = com90io_copy_from_card;

lp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);

/* get and check the station ID from offset 1 in shmem */

@@ -257,7 +257,7 @@ static int __init com90io_found(struct net_device *dev)

err = register_netdev(dev);
if (err) {
- outb((inb(_CONFIG) & ~IOMAPflag), _CONFIG);
+ outb((inb(ioaddr + _CONFIG) & ~IOMAPflag), ioaddr + _CONFIG);
free_irq(dev->irq, dev);
release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
return err;
@@ -283,19 +283,19 @@ static int com90io_reset(struct net_device *dev, int really_reset)
struct arcnet_local *lp = netdev_priv(dev);
short ioaddr = dev->base_addr;

- BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, inb(_STATUS));
+ BUGMSG(D_INIT, "Resetting %s (status=%02Xh)\n", dev->name, inb(ioaddr + _STATUS));

if (really_reset) {
/* reset the card */
- inb(_RESET);
+ inb(ioaddr + _RESET);
mdelay(RESETtime);
}
/* Set the thing to IO-mapped, 8-bit mode */
lp->config = (0x1C | IOMAPflag) & ~ENABLE16flag;
- outb(lp->config, _CONFIG);
+ outb(lp->config, ioaddr + _CONFIG);

- outb(CFLAGScmd | RESETclear, _COMMAND); /* clear flags & end reset */
- outb(CFLAGScmd | CONFIGclear, _COMMAND);
+ outb(CFLAGScmd | RESETclear, ioaddr + _COMMAND); /* clear flags & end reset */
+ outb(CFLAGScmd | CONFIGclear, ioaddr + _COMMAND);

/* verify that the ARCnet signature byte is present */
if (get_buffer_byte(dev, 0) != TESTvalue) {
@@ -303,7 +303,7 @@ static int com90io_reset(struct net_device *dev, int really_reset)
return 1;
}
/* enable extended (512-byte) packets */
- outb(CONFIGcmd | EXTconf, _COMMAND);
+ outb(CONFIGcmd | EXTconf, ioaddr + _COMMAND);

/* done! return success. */
return 0;
@@ -314,7 +314,7 @@ static void com90io_command(struct net_device *dev, int cmd)
{
short ioaddr = dev->base_addr;

- outb(cmd, _COMMAND);
+ outb(cmd, ioaddr + _COMMAND);
}


@@ -322,7 +322,7 @@ static int com90io_status(struct net_device *dev)
{
short ioaddr = dev->base_addr;

- return inb(_STATUS);
+ return inb(ioaddr + _STATUS);
}


@@ -330,7 +330,7 @@ static void com90io_setmask(struct net_device *dev, int mask)
{
short ioaddr = dev->base_addr;

- outb(mask, _INTMASK);
+ outb(mask, ioaddr + _INTMASK);
}

static void com90io_copy_to_card(struct net_device *dev, int bufnum, int offset,
@@ -412,7 +412,7 @@ static void __exit com90io_exit(void)
unregister_netdev(dev);

/* Set the thing back to MMAP mode, in case the old driver is loaded later */
- outb((inb(_CONFIG) & ~IOMAPflag), _CONFIG);
+ outb((inb(ioaddr + _CONFIG) & ~IOMAPflag), ioaddr + _CONFIG);

free_irq(dev->irq, dev);
release_region(dev->base_addr, ARCNET_TOTAL_SIZE);
--
2.1.4

2015-04-24 17:23:40

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 13/21] ARCNET: com90xx: fix ioaddr prefixes

This patch removes the use of the variable ioaddr in the macros
and uses it directly in the calling functions. This improves
the readability of the code and changes the macros to be used as
offsets.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com90xx.c | 52 ++++++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c
index 2b99a04..d8a9fe5 100644
--- a/drivers/net/arcnet/com90xx.c
+++ b/drivers/net/arcnet/com90xx.c
@@ -80,14 +80,14 @@ static int numcards;
#define MIRROR_SIZE (BUFFER_SIZE*4)

/* COM 9026 controller chip --> ARCnet register addresses */
-#define _INTMASK (ioaddr+0) /* writable */
-#define _STATUS (ioaddr+0) /* readable */
-#define _COMMAND (ioaddr+1) /* writable, returns random vals on read (?) */
-#define _CONFIG (ioaddr+2) /* Configuration register */
-#define _RESET (ioaddr+8) /* software reset (on read) */
-#define _MEMDATA (ioaddr+12) /* Data port for IO-mapped memory */
-#define _ADDR_HI (ioaddr+15) /* Control registers for said */
-#define _ADDR_LO (ioaddr+14)
+#define _INTMASK 0 /* writable */
+#define _STATUS 0 /* readable */
+#define _COMMAND 1 /* writable, returns random vals on read (?) */
+#define _CONFIG 2 /* Configuration register */
+#define _RESET 8 /* software reset (on read) */
+#define _MEMDATA 12 /* Data port for IO-mapped memory */
+#define _ADDR_HI 15 /* Control registers for said */
+#define _ADDR_LO 14

static int com90xx_skip_probe __initdata = 0;

@@ -166,7 +166,7 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
- if (inb(_STATUS) == 0xFF) {
+ if (inb(ioaddr + _STATUS) == 0xFF) {
BUGMSG2(D_INIT_REASONS, "(empty)\n");
BUGMSG2(D_INIT_REASONS, "S1: ");
BUGLVL(D_INIT_REASONS) numprint = 0;
@@ -174,7 +174,7 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
- inb(_RESET); /* begin resetting card */
+ inb(ioaddr + _RESET); /* begin resetting card */

BUGMSG2(D_INIT_REASONS, "\n");
BUGMSG2(D_INIT_REASONS, "S1: ");
@@ -308,7 +308,7 @@ static void __init com90xx_probe(void)
BUGMSG2(D_INIT, "%Xh ", *port);

ioaddr = *port;
- status = inb(_STATUS);
+ status = inb(ioaddr + _STATUS);

if ((status & 0x9D)
!= (NORXflag | RECONflag | TXFREEflag | RESETflag)) {
@@ -319,8 +319,8 @@ static void __init com90xx_probe(void)
*port-- = ports[--numports];
continue;
}
- outb(CFLAGScmd | RESETclear | CONFIGclear, _COMMAND);
- status = inb(_STATUS);
+ outb(CFLAGScmd | RESETclear | CONFIGclear, ioaddr + _COMMAND);
+ status = inb(ioaddr + _STATUS);
if (status & RESETflag) {
BUGMSG2(D_INIT_REASONS, " (eternal reset, status=%Xh)\n",
status);
@@ -339,9 +339,9 @@ static void __init com90xx_probe(void)
* we tell it to start receiving.
*/
airqmask = probe_irq_on();
- outb(NORXflag, _INTMASK);
+ outb(NORXflag, ioaddr + _INTMASK);
udelay(1);
- outb(0, _INTMASK);
+ outb(0, ioaddr + _INTMASK);
airq = probe_irq_off(airqmask);

if (airq <= 0) {
@@ -367,14 +367,14 @@ static void __init com90xx_probe(void)
*/
#ifdef FAST_PROBE
if (numports > 1 || numshmems > 1) {
- inb(_RESET);
+ inb(ioaddr + _RESET);
mdelay(RESETtime);
} else {
/* just one shmem and port, assume they match */
writeb(TESTvalue, iomem[0]);
}
#else
- inb(_RESET);
+ inb(ioaddr + _RESET);
mdelay(RESETtime);
#endif

@@ -548,7 +548,7 @@ static void com90xx_command(struct net_device *dev, int cmd)
{
short ioaddr = dev->base_addr;

- outb(cmd, _COMMAND);
+ outb(cmd, ioaddr + _COMMAND);
}


@@ -556,7 +556,7 @@ static int com90xx_status(struct net_device *dev)
{
short ioaddr = dev->base_addr;

- return inb(_STATUS);
+ return inb(ioaddr + _STATUS);
}


@@ -564,7 +564,7 @@ static void com90xx_setmask(struct net_device *dev, int mask)
{
short ioaddr = dev->base_addr;

- outb(mask, _INTMASK);
+ outb(mask, ioaddr + _INTMASK);
}


@@ -581,18 +581,18 @@ static int com90xx_reset(struct net_device *dev, int really_reset)
struct arcnet_local *lp = netdev_priv(dev);
short ioaddr = dev->base_addr;

- BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", inb(_STATUS));
+ BUGMSG(D_INIT, "Resetting (status=%02Xh)\n", inb(ioaddr + _STATUS));

if (really_reset) {
/* reset the card */
- inb(_RESET);
+ inb(ioaddr + _RESET);
mdelay(RESETtime);
}
- outb(CFLAGScmd | RESETclear, _COMMAND); /* clear flags & end reset */
- outb(CFLAGScmd | CONFIGclear, _COMMAND);
+ outb(CFLAGScmd | RESETclear, ioaddr + _COMMAND); /* clear flags & end reset */
+ outb(CFLAGScmd | CONFIGclear, ioaddr + _COMMAND);

/* don't do this until we verify that it doesn't hurt older cards! */
- /* outb(inb(_CONFIG) | ENABLE16flag, _CONFIG); */
+ /* outb(inb(ioaddr + _CONFIG) | ENABLE16flag, ioaddr + _CONFIG); */

/* verify that the ARCnet signature byte is present */
if (readb(lp->mem_start) != TESTvalue) {
@@ -601,7 +601,7 @@ static int com90xx_reset(struct net_device *dev, int really_reset)
return 1;
}
/* enable extended (512-byte) packets */
- outb(CONFIGcmd | EXTconf, _COMMAND);
+ outb(CONFIGcmd | EXTconf, ioaddr + _COMMAND);

/* clean out all the memory to make debugging make more sense :) */
BUGLVL(D_DURING)
--
2.1.4

2015-04-24 17:26:22

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 14/21] ARCNET: arc-rawmode: reorder module functions

This patch moves the module_init and module_exit patches to
the end of the file. It also replaces the printk with pr_info.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/arc-rawmode.c | 87 ++++++++++++++++++----------------------
1 file changed, 38 insertions(+), 49 deletions(-)

diff --git a/drivers/net/arcnet/arc-rawmode.c b/drivers/net/arcnet/arc-rawmode.c
index b603470..68466b3 100644
--- a/drivers/net/arcnet/arc-rawmode.c
+++ b/drivers/net/arcnet/arc-rawmode.c
@@ -35,55 +35,6 @@

#define VERSION "arcnet: raw mode (`r') encapsulation support loaded.\n"

-
-static void rx(struct net_device *dev, int bufnum,
- struct archdr *pkthdr, int length);
-static int build_header(struct sk_buff *skb, struct net_device *dev,
- unsigned short type, uint8_t daddr);
-static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,
- int bufnum);
-
-static struct ArcProto rawmode_proto =
-{
- .suffix = 'r',
- .mtu = XMTU,
- .rx = rx,
- .build_header = build_header,
- .prepare_tx = prepare_tx,
- .continue_tx = NULL,
- .ack_tx = NULL
-};
-
-
-static int __init arcnet_raw_init(void)
-{
- int count;
-
- printk(VERSION);
-
- for (count = 0; count < 256; count++)
- if (arc_proto_map[count] == arc_proto_default)
- arc_proto_map[count] = &rawmode_proto;
-
- /* for raw mode, we only set the bcast proto if there's no better one */
- if (arc_bcast_proto == arc_proto_default)
- arc_bcast_proto = &rawmode_proto;
-
- arc_proto_default = &rawmode_proto;
- return 0;
-}
-
-static void __exit arcnet_raw_exit(void)
-{
- arcnet_unregister_proto(&rawmode_proto);
-}
-
-module_init(arcnet_raw_init);
-module_exit(arcnet_raw_exit);
-
-MODULE_LICENSE("GPL");
-
-
/* packet receiver */
static void rx(struct net_device *dev, int bufnum,
struct archdr *pkthdr, int length)
@@ -201,3 +152,41 @@ static int prepare_tx(struct net_device *dev, struct archdr *pkt, int length,

return 1; /* done */
}
+
+static struct ArcProto rawmode_proto = {
+ .suffix = 'r',
+ .mtu = XMTU,
+ .rx = rx,
+ .build_header = build_header,
+ .prepare_tx = prepare_tx,
+ .continue_tx = NULL,
+ .ack_tx = NULL
+};
+
+static int __init arcnet_raw_init(void)
+{
+ int count;
+
+ pr_info(VERSION);
+
+ for (count = 0; count < 256; count++)
+ if (arc_proto_map[count] == arc_proto_default)
+ arc_proto_map[count] = &rawmode_proto;
+
+ /* for raw mode, we only set the bcast proto if there's no better one */
+ if (arc_bcast_proto == arc_proto_default)
+ arc_bcast_proto = &rawmode_proto;
+
+ arc_proto_default = &rawmode_proto;
+ return 0;
+}
+
+static void __exit arcnet_raw_exit(void)
+{
+ arcnet_unregister_proto(&rawmode_proto);
+}
+
+module_init(arcnet_raw_init);
+module_exit(arcnet_raw_exit);
+
+MODULE_LICENSE("GPL");
--
2.1.4

2015-04-24 17:28:47

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 15/21] ARCNET: capmode: remove extra function and use C99 in struct

This patch cleans the capmode protocol module. It removes the obsolete
function arcnet_cap_init and uses the C99 struct definition. It also
replaces printk with pr_info.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/capmode.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/net/arcnet/capmode.c b/drivers/net/arcnet/capmode.c
index b6868a2..91ec9fa 100644
--- a/drivers/net/arcnet/capmode.c
+++ b/drivers/net/arcnet/capmode.c
@@ -229,22 +229,22 @@ free_outskb:
return 0;
}

-static struct ArcProto capmode_proto =
-{
- 'r',
- XMTU,
- 0,
- rx,
- build_header,
- prepare_tx,
- NULL,
- ack_tx
+static struct ArcProto capmode_proto = {
+ .suffix = 'r',
+ .mtu = XMTU,
+ .rx = rx,
+ .build_header = build_header,
+ .prepare_tx = prepare_tx,
+ .continue_tx = NULL,
+ .ack_tx = ack_tx
};

-static void arcnet_cap_init(void)
+static int __init capmode_module_init(void)
{
int count;

+ pr_info(VERSION);
+
for (count = 1; count <= 8; count++)
if (arc_proto_map[count] == arc_proto_default)
arc_proto_map[count] = &capmode_proto;
@@ -255,12 +255,6 @@ static void arcnet_cap_init(void)

arc_proto_default = &capmode_proto;
arc_raw_proto = &capmode_proto;
-}
-
-static int __init capmode_module_init(void)
-{
- printk(VERSION);
- arcnet_cap_init();
return 0;
}

--
2.1.4

2015-04-24 17:23:28

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 16/21] ARCNET: capmode: move dev_free_skb to its only user

The call for dev_free_skb is done only once. This patch
moves its call to its only user and removes the obsolete
condition variable.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/arcnet.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/arcnet/arcnet.c b/drivers/net/arcnet/arcnet.c
index 4990b0d..5eec14d 100644
--- a/drivers/net/arcnet/arcnet.c
+++ b/drivers/net/arcnet/arcnet.c
@@ -541,7 +541,7 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
struct ArcProto *proto;
int txbuf;
unsigned long flags;
- int freeskb, retval;
+ int retval;

BUGMSG(D_DURING,
"transmit requested (status=%Xh, txbufs=%d/%d, len=%d, protocol %x)\n",
@@ -578,15 +578,13 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
/* done right away and we don't want to acknowledge
the package later - forget about it now */
dev->stats.tx_bytes += skb->len;
- freeskb = 1;
+ dev_kfree_skb(skb);
} else {
/* do it the 'split' way */
lp->outgoing.proto = proto;
lp->outgoing.skb = skb;
lp->outgoing.pkt = pkt;

- freeskb = 0;
-
if (proto->continue_tx &&
proto->continue_tx(dev, txbuf)) {
BUGMSG(D_NORMAL,
@@ -598,7 +596,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
lp->next_tx = txbuf;
} else {
retval = NETDEV_TX_BUSY;
- freeskb = 0;
}

BUGMSG(D_DEBUG, "%s: %d: %s, status: %x\n",
@@ -613,9 +610,6 @@ netdev_tx_t arcnet_send_packet(struct sk_buff *skb,
__FILE__, __LINE__, __func__, lp->hw.status(dev));

spin_unlock_irqrestore(&lp->lock, flags);
- if (freeskb) {
- dev_kfree_skb(skb);
- }
return retval; /* no need to try again */
}

--
2.1.4

2015-04-24 17:23:25

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 17/21] ARCNET: com20020: replace magic numbers with readable macros

This patch replaces all magic numbers in the driver with
proper named macros. For the case of XTOcfg and STARTIOcmd
it introduces the new macros.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com20020.c | 21 +++++++++++----------
include/linux/arcdevice.h | 1 +
include/linux/com20020.h | 1 +
3 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 4b4bb96..27ad484 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -92,9 +92,9 @@ int com20020_check(struct net_device *dev)
struct arcnet_local *lp = netdev_priv(dev);

/* reset the card */
- outb(0x18 | 0x80, ioaddr + _CONFIG);
+ outb(XTOcfg(3) | RESETcfg, ioaddr + _CONFIG);
udelay(5);
- outb(0x18, ioaddr + _CONFIG);
+ outb(XTOcfg(3), ioaddr + _CONFIG);
mdelay(RESETtime);

lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
@@ -115,13 +115,13 @@ int com20020_check(struct net_device *dev)

/* must now write the magic "restart operation" command */
mdelay(1);
- outb(0x18, ioaddr + _COMMAND);
+ outb(STARTIOcmd, ioaddr + _COMMAND);
}

- lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2);
+ lp->config = TXENcfg | (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 + BUS_ALIGN*7);
+ outb(0x42, ioaddr + _XREG);

status = inb(ioaddr + _STATUS);

@@ -132,8 +132,9 @@ int com20020_check(struct net_device *dev)
BUGMSG(D_INIT_REASONS, "status after reset: %X\n", status);

/* Enable TX */
- outb(0x39, ioaddr + _CONFIG);
- outb(inb(ioaddr + BUS_ALIGN*8), ioaddr + BUS_ALIGN*7);
+ lp->config |= TXENcfg;
+ outb(lp->config, ioaddr + _CONFIG);
+ outb(inb(ioaddr + BUS_ALIGN * 8), ioaddr + _XREG);

outb((CFLAGScmd | RESETclear | CONFIGclear), ioaddr + _COMMAND);

@@ -212,10 +213,10 @@ int com20020_found(struct net_device *dev, int shared)

/* must now write the magic "restart operation" command */
mdelay(1);
- outb(0x18, ioaddr + _COMMAND);
+ outb(STARTIOcmd, ioaddr + _COMMAND);
}

- lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1;
+ lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE;
/* Default 0x38 + register: Node ID */
outb(lp->config, ioaddr + _CONFIG);
outb(dev->dev_addr[0], ioaddr + _XREG);
@@ -276,7 +277,7 @@ static int com20020_reset(struct net_device *dev, int really_reset)

if (really_reset) {
/* reset the card */
- outb(lp->config | 0x80, ioaddr + _CONFIG);
+ outb(lp->config | RESETcfg, ioaddr + _CONFIG);
udelay(5);
outb(lp->config, ioaddr + _CONFIG);
mdelay(RESETtime * 2); /* COM20020 seems to be slower sometimes */
diff --git a/include/linux/arcdevice.h b/include/linux/arcdevice.h
index c20f100..bc3b085 100644
--- a/include/linux/arcdevice.h
+++ b/include/linux/arcdevice.h
@@ -155,6 +155,7 @@ extern int arcnet_debug;
#define CONFIGcmd 0x05 /* define configuration */
#define CFLAGScmd 0x06 /* clear flags */
#define TESTcmd 0x07 /* load test flags */
+#define STARTIOcmd 0x18 /* start internal operation */

/* flags for "clear flags" command */
#define RESETclear 0x08 /* power-on-reset */
diff --git a/include/linux/com20020.h b/include/linux/com20020.h
index c2d8647..f194b74 100644
--- a/include/linux/com20020.h
+++ b/include/linux/com20020.h
@@ -92,6 +92,7 @@ struct com20020_dev {
/* in the CONFIG register */
#define RESETcfg 0x80 /* put card in reset state */
#define TXENcfg 0x20 /* enable TX */
+#define XTOcfg(x) ((x) << 3) /* extended timeout */

/* in SETUP register */
#define PROMISCset 0x10 /* enable RCV_ALL */
--
2.1.4

2015-04-24 17:23:53

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 18/21] ARCNET: com20020: remove obsolete BUS_ALIGN offset factor

This patch removes the obsolete macro BUS_ALIGN as the kernel option
CONFIG_SA1100_CT6001 is not longer available.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com20020.c | 4 ++--
include/linux/com20020.h | 27 ++++++++++-----------------
2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/net/arcnet/com20020.c b/drivers/net/arcnet/com20020.c
index 27ad484..1dbc748 100644
--- a/drivers/net/arcnet/com20020.c
+++ b/drivers/net/arcnet/com20020.c
@@ -134,7 +134,7 @@ int com20020_check(struct net_device *dev)
/* Enable TX */
lp->config |= TXENcfg;
outb(lp->config, ioaddr + _CONFIG);
- outb(inb(ioaddr + BUS_ALIGN * 8), ioaddr + _XREG);
+ outb(inb(ioaddr + 8), ioaddr + _XREG);

outb((CFLAGScmd | RESETclear | CONFIGclear), ioaddr + _COMMAND);

@@ -200,7 +200,7 @@ int com20020_found(struct net_device *dev, int shared)
lp->hw.close = com20020_close;

if (!dev->dev_addr[0])
- dev->dev_addr[0] = inb(ioaddr + BUS_ALIGN*8); /* FIXME: do this some other way! */
+ dev->dev_addr[0] = inb(ioaddr + 8); /* FIXME: do this some other way! */

lp->config = (lp->config & ~0x03) | SUB_SETUP1;
outb(lp->config, ioaddr + _CONFIG);
diff --git a/include/linux/com20020.h b/include/linux/com20020.h
index f194b74..939d69d 100644
--- a/include/linux/com20020.h
+++ b/include/linux/com20020.h
@@ -34,13 +34,6 @@ extern const struct net_device_ops com20020_netdev_ops;
/* The number of low I/O ports used by the card. */
#define ARCNET_TOTAL_SIZE 8

-/* various register addresses */
-#ifdef CONFIG_SA1100_CT6001
-#define BUS_ALIGN 2 /* 8 bit device on a 16 bit bus - needs padding */
-#else
-#define BUS_ALIGN 1
-#endif
-
#define PLX_PCI_MAX_CARDS 2

struct com20020_pci_channel_map {
@@ -71,16 +64,16 @@ struct com20020_dev {
int index;
};

-#define _INTMASK (BUS_ALIGN*0) /* writable */
-#define _STATUS (BUS_ALIGN*0) /* readable */
-#define _COMMAND (BUS_ALIGN*1) /* standard arcnet commands */
-#define _DIAGSTAT (BUS_ALIGN*1) /* diagnostic status register */
-#define _ADDR_HI (BUS_ALIGN*2) /* control registers for IO-mapped memory */
-#define _ADDR_LO (BUS_ALIGN*3)
-#define _MEMDATA (BUS_ALIGN*4) /* data port for IO-mapped memory */
-#define _SUBADR (BUS_ALIGN*5) /* the extended port _XREG refers to */
-#define _CONFIG (BUS_ALIGN*6) /* configuration register */
-#define _XREG (BUS_ALIGN*7) /* extra registers (indexed by _CONFIG
+#define _INTMASK 0 /* writable */
+#define _STATUS 0 /* readable */
+#define _COMMAND 1 /* standard arcnet commands */
+#define _DIAGSTAT 1 /* diagnostic status register */
+#define _ADDR_HI 2 /* control registers for IO-mapped memory */
+#define _ADDR_LO 3
+#define _MEMDATA 4 /* data port for IO-mapped memory */
+#define _SUBADR 5 /* the extended port _XREG refers to */
+#define _CONFIG 6 /* configuration register */
+#define _XREG 7 /* extra registers (indexed by _CONFIG
or _SUBADR) */

/* in the ADDR_HI register */
--
2.1.4

2015-04-24 17:26:35

by Michael Grzeschik

[permalink] [raw]
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 <[email protected]>
---
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

2015-04-24 17:23:58

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 20/21] ARCNET: com20020-pci: reformat structs to C99 format

This patch changes the macro definitions to match the C99
formating. This improves the readability.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com20020-pci.c | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index 18c0b1f..de8c894 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -191,7 +191,11 @@ static struct com20020_pci_card_info card_info_10mbit = {
.name = "ARC-PCI",
.devcount = 1,
.chan_map_tbl = {
- { 2, 0x00, 0x08 },
+ {
+ .bar = 2,
+ .offset = 0x00,
+ .size = 0x08,
+ },
},
.flags = ARC_CAN_10MBIT,
};
@@ -200,7 +204,11 @@ static struct com20020_pci_card_info card_info_5mbit = {
.name = "ARC-PCI",
.devcount = 1,
.chan_map_tbl = {
- { 2, 0x00, 0x08 },
+ {
+ .bar = 2,
+ .offset = 0x00,
+ .size = 0x08,
+ },
},
.flags = ARC_IS_5MBIT,
};
@@ -210,7 +218,11 @@ static struct com20020_pci_card_info card_info_sohard = {
.devcount = 1,
/* SOHARD needs PCI base addr 4 */
.chan_map_tbl = {
- {4, 0x00, 0x08},
+ {
+ .bar = 4,
+ .offset = 0x00,
+ .size = 0x08
+ },
},
.flags = ARC_CAN_10MBIT,
};
@@ -219,7 +231,11 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
.name = "EAE PLX-PCI ARC1",
.devcount = 1,
.chan_map_tbl = {
- { 2, 0x00, 0x08 },
+ {
+ .bar = 2,
+ .offset = 0x00,
+ .size = 0x08,
+ },
},
.flags = ARC_CAN_10MBIT,
};
@@ -228,8 +244,15 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.name = "EAE PLX-PCI MA1",
.devcount = 2,
.chan_map_tbl = {
- { 2, 0x00, 0x08 },
- { 2, 0x08, 0x08 }
+ {
+ .bar = 2,
+ .offset = 0x00,
+ .size = 0x08,
+ }, {
+ .bar = 2,
+ .offset = 0x08,
+ .size = 0x08,
+ }
},
.flags = ARC_CAN_10MBIT,
};
--
2.1.4

2015-04-24 17:23:37

by Michael Grzeschik

[permalink] [raw]
Subject: [PATCH 21/21] ARCNET: com20020-pci: add rotary index support

The EAE PLX-PCI card has a special rotary encoder
to configure the address of every card individually.
We take this information for the initial setup of
the cards dev_id.

Signed-off-by: Michael Grzeschik <[email protected]>
---
drivers/net/arcnet/com20020-pci.c | 28 ++++++++++++++++++++++++++++
include/linux/com20020.h | 4 ++++
2 files changed, 32 insertions(+)

diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index de8c894..308adb9 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -67,6 +67,7 @@ static void com20020pci_remove(struct pci_dev *pdev);
static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct com20020_pci_card_info *ci;
+ struct com20020_pci_channel_map *mm;
struct net_device *dev;
struct arcnet_local *lp;
struct com20020_priv *priv;
@@ -83,9 +84,21 @@ static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *i

ci = (struct com20020_pci_card_info *)id->driver_data;
priv->ci = ci;
+ mm = &ci->misc_map;

INIT_LIST_HEAD(&priv->list_dev);

+ if (mm->size) {
+ ioaddr = pci_resource_start(pdev, mm->bar) + mm->offset;
+ r = devm_request_region(&pdev->dev, ioaddr, mm->size,
+ "com20020-pci");
+ if (!r) {
+ pr_err("IO region %xh-%xh already allocated.\n",
+ ioaddr, ioaddr + mm->size - 1);
+ return -EBUSY;
+ }
+ priv->misc = ioaddr;
+ }

for (i = 0; i < ci->devcount; i++) {
struct com20020_pci_channel_map *cm = &ci->chan_map_tbl[i];
@@ -132,6 +145,9 @@ static int com20020pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
lp->timeout = timeout;
lp->hw.owner = THIS_MODULE;

+ /* Get the dev_id from the PLX rotary coder */
+ dev->dev_id = inb(priv->misc + ci->rotary) >> 4;
+
if (inb(_STATUS) == 0xFF) {
pr_err("IO address %Xh is empty!\n", ioaddr);
ret = -EIO;
@@ -237,6 +253,12 @@ static struct com20020_pci_card_info card_info_eae_arc1 = {
.size = 0x08,
},
},
+ .misc_map = {
+ .bar = 2,
+ .offset = 0x10,
+ .size = 0x04,
+ },
+ .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
};

@@ -254,6 +276,12 @@ static struct com20020_pci_card_info card_info_eae_ma1 = {
.size = 0x08,
}
},
+ .misc_map = {
+ .bar = 2,
+ .offset = 0x10,
+ .size = 0x04,
+ },
+ .rotary = 0x0,
.flags = ARC_CAN_10MBIT,
};

diff --git a/include/linux/com20020.h b/include/linux/com20020.h
index 939d69d..8028ef8 100644
--- a/include/linux/com20020.h
+++ b/include/linux/com20020.h
@@ -47,6 +47,9 @@ struct com20020_pci_card_info {
int devcount;

struct com20020_pci_channel_map chan_map_tbl[PLX_PCI_MAX_CARDS];
+ struct com20020_pci_channel_map misc_map;
+
+ int rotary;

unsigned int flags;
};
@@ -54,6 +57,7 @@ struct com20020_pci_card_info {
struct com20020_priv {
struct com20020_pci_card_info *ci;
struct list_head list_dev;
+ int __iomem misc;
};

struct com20020_dev {
--
2.1.4

2015-04-24 18:48:02

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
> Hi!

Hello.

> This patch series tries to reanimate the ARCNET hardware layer to be
> somehow readable and maintainable again. It includes a lot of cleanup
> patches. It also adds some fixes which leads the layer to become usable
> again. And as a special treatment it adds more features like correct
> loading and unloading of the com20020 card.

Wow. Good for you, but why? Does anyone still use these?

2015-04-24 21:14:55

by Marc Kleine-Budde

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

On 04/24/2015 08:47 PM, Joe Perches wrote:
> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
>> Hi!
>
> Hello.
>
>> This patch series tries to reanimate the ARCNET hardware layer to be
>> somehow readable and maintainable again. It includes a lot of cleanup
>> patches. It also adds some fixes which leads the layer to become usable
>> again. And as a special treatment it adds more features like correct
>> loading and unloading of the com20020 card.
>
> Wow. Good for you, but why? Does anyone still use these?

Yes, there are parts of the industry where "old" machines are
retrofitted with new hardware...and a lot of these machines still talk
ARCNET :)

Marc

--
Pengutronix e.K. | Marc Kleine-Budde |
Industrial Linux Solutions | Phone: +49-231-2826-924 |
Vertretung West/Dortmund | Fax: +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de |


Attachments:
signature.asc (801.00 B)
OpenPGP digital signature

2015-04-24 23:04:54

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 06/21] ARCNET: com20020: remove unneeded macros

On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
> The macros SET_SUBADR, ARCRESET, ARCRESET0, ACOMMAND, ASTATUS, AINTMASK
> and ADIAGSTATUS are unnecessary indirections to the use of registers.
> This patch removes them and improves the readability of the code.

This breaks compilation.

Please compile test your patches before sending them.

2015-04-25 03:59:00

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

From: Marc Kleine-Budde <[email protected]>
Date: Fri, 24 Apr 2015 23:14:41 +0200

> On 04/24/2015 08:47 PM, Joe Perches wrote:
>> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
>>> Hi!
>>
>> Hello.
>>
>>> This patch series tries to reanimate the ARCNET hardware layer to be
>>> somehow readable and maintainable again. It includes a lot of cleanup
>>> patches. It also adds some fixes which leads the layer to become usable
>>> again. And as a special treatment it adds more features like correct
>>> loading and unloading of the com20020 card.
>>
>> Wow. Good for you, but why? Does anyone still use these?
>
> Yes, there are parts of the industry where "old" machines are
> retrofitted with new hardware...and a lot of these machines still talk
> ARCNET :)

But the real issue is, this layer is development wise in the same
category as the IDE layer.

Any non-trivial change is nothing but pure risk, especially given the
low level of test coverage the code gets.

So I really only want to see the most critical obvious bug fixes
submitted for this layer and drivers.

And no I will not accept an argument stating that you have to
restructure and clean this code up in order to fix the bugs. That's
bogus.

I'm rejecting this patch series, sorry.

2015-04-25 03:59:41

by David Miller

[permalink] [raw]
Subject: Re: [PATCH 06/21] ARCNET: com20020: remove unneeded macros

From: Joe Perches <[email protected]>
Date: Fri, 24 Apr 2015 16:04:45 -0700

> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
>> The macros SET_SUBADR, ARCRESET, ARCRESET0, ACOMMAND, ASTATUS, AINTMASK
>> and ADIAGSTATUS are unnecessary indirections to the use of registers.
>> This patch removes them and improves the readability of the code.
>
> This breaks compilation.
>
> Please compile test your patches before sending them.

This makes this patch series even more unacceptable.

2015-04-25 05:21:34

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

On Fri, 2015-04-24 at 23:58 -0400, David Miller wrote:
> From: Marc Kleine-Budde <[email protected]>
> Date: Fri, 24 Apr 2015 23:14:41 +0200
> > On 04/24/2015 08:47 PM, Joe Perches wrote:
> >> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
> >>> This patch series tries to reanimate the ARCNET hardware layer to be
> >>> somehow readable and maintainable again. It includes a lot of cleanup
> >>> patches. It also adds some fixes which leads the layer to become usable
> >>> again. And as a special treatment it adds more features like correct
> >>> loading and unloading of the com20020 card.
> >> Wow. Good for you, but why? Does anyone still use these?
> > Yes, there are parts of the industry where "old" machines are
> > retrofitted with new hardware...and a lot of these machines still talk
> > ARCNET :)
>
> But the real issue is, this layer is development wise in the same
> category as the IDE layer.
>
> Any non-trivial change is nothing but pure risk, especially given the
> low level of test coverage the code gets.
>
> So I really only want to see the most critical obvious bug fixes
> submitted for this layer and drivers.
>
> And no I will not accept an argument stating that you have to
> restructure and clean this code up in order to fix the bugs. That's
> bogus.

I think that arcnet is a fairly simple protocol.

Given the current state of the code, if someone wants to
make the code better, it might be better to wholesale
replace what's there instead of incrementally modifying it.

It's not that difficult to make what's there style cleaner
though. Most if it is trivial sed style replacements.

Dunno. It doesn't look like that big a job actually, but I
don't use it nor could I do testing on actual hardware.

If pengutronix wants help, I probably could.

2015-04-27 14:13:54

by Michael Grzeschik

[permalink] [raw]
Subject: Re: [PATCH 06/21] ARCNET: com20020: remove unneeded macros

On Fri, Apr 24, 2015 at 04:04:45PM -0700, Joe Perches wrote:
> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
> > The macros SET_SUBADR, ARCRESET, ARCRESET0, ACOMMAND, ASTATUS, AINTMASK
> > and ADIAGSTATUS are unnecessary indirections to the use of registers.
> > This patch removes them and improves the readability of the code.
>
> This breaks compilation.
>
> Please compile test your patches before sending them.

Sorry, but I can not reproduce this break.
What was your base you applied this series on?

Can you send me the failure you get?

Thanks,
Michael

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2015-04-27 14:57:22

by Michael Grzeschik

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

Hi!

On Fri, Apr 24, 2015 at 11:58:53PM -0400, David Miller wrote:
> From: Marc Kleine-Budde <[email protected]>
> Date: Fri, 24 Apr 2015 23:14:41 +0200
>
> > On 04/24/2015 08:47 PM, Joe Perches wrote:
> >> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
> >>> Hi!
> >>
> >> Hello.
> >>
> >>> This patch series tries to reanimate the ARCNET hardware layer to be
> >>> somehow readable and maintainable again. It includes a lot of cleanup
> >>> patches. It also adds some fixes which leads the layer to become usable
> >>> again. And as a special treatment it adds more features like correct
> >>> loading and unloading of the com20020 card.
> >>
> >> Wow. Good for you, but why? Does anyone still use these?
> >
> > Yes, there are parts of the industry where "old" machines are
> > retrofitted with new hardware...and a lot of these machines still talk
> > ARCNET :)
>
> But the real issue is, this layer is development wise in the same
> category as the IDE layer.
>
> Any non-trivial change is nothing but pure risk, especially given the
> low level of test coverage the code gets.

Do you count coding style patches as non-trivial or trivial
patches?

> So I really only want to see the most critical obvious bug fixes
> submitted for this layer and drivers.

The cleanup changes I submitted should not change the actual behaviour.
Replacing the register access macros with their equivalent outb/inb
seems pretty obvious. What is your opinion on those?

I see that the "ARCNET: whitespace, tab and codingstyle fixes" patch is
pretty mixed up and not very reliable. But Joe has sent me a nice series
for the cleanup.

> And no I will not accept an argument stating that you have to
> restructure and clean this code up in order to fix the bugs. That's
> bogus.

OK.

I have the following patches in this series which fix bugs found during
my development:

com20020-pci: add dev_port for udev handling
ARCNET: fix hard_header_len limit
ARCNET: com20020: add enable and disable device on open/close

I would send a new series containing only those patches with more
detailed patch descriptions, if that's fine with you?

Regards,
Michael

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2015-04-30 03:49:30

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

On Mon, 2015-04-27 at 16:57 +0200, Michael Grzeschik wrote:
> Hi!
>
> On Fri, Apr 24, 2015 at 11:58:53PM -0400, David Miller wrote:
> > From: Marc Kleine-Budde <[email protected]>
> > Date: Fri, 24 Apr 2015 23:14:41 +0200
> >
> > > On 04/24/2015 08:47 PM, Joe Perches wrote:
> > >> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
> > >>> Hi!
> > >>
> > >> Hello.
> > >>
> > >>> This patch series tries to reanimate the ARCNET hardware layer to be
> > >>> somehow readable and maintainable again. It includes a lot of cleanup
> > >>> patches. It also adds some fixes which leads the layer to become usable
> > >>> again. And as a special treatment it adds more features like correct
> > >>> loading and unloading of the com20020 card.
> > >>
> > >> Wow. Good for you, but why? Does anyone still use these?
> > >
> > > Yes, there are parts of the industry where "old" machines are
> > > retrofitted with new hardware...and a lot of these machines still talk
> > > ARCNET :)
> >
> > But the real issue is, this layer is development wise in the same
> > category as the IDE layer.
> >
> > Any non-trivial change is nothing but pure risk, especially given the
> > low level of test coverage the code gets.
>
> Do you count coding style patches as non-trivial or trivial
> patches?
>
> > So I really only want to see the most critical obvious bug fixes
> > submitted for this layer and drivers.
>
> The cleanup changes I submitted should not change the actual behaviour.
> Replacing the register access macros with their equivalent outb/inb
> seems pretty obvious. What is your opinion on those?
>
> I see that the "ARCNET: whitespace, tab and codingstyle fixes" patch is
> pretty mixed up and not very reliable. But Joe has sent me a nice series
> for the cleanup.
>
> > And no I will not accept an argument stating that you have to
> > restructure and clean this code up in order to fix the bugs. That's
> > bogus.
>
> OK.
>
> I have the following patches in this series which fix bugs found during
> my development:
>
> com20020-pci: add dev_port for udev handling
> ARCNET: fix hard_header_len limit
> ARCNET: com20020: add enable and disable device on open/close
>
> I would send a new series containing only those patches with more
> detailed patch descriptions, if that's fine with you?

I was away for a few days and while out I did another
restructuring of all the inb/outb/readb/writeb code
removing all the A<FOO> macros. It removes all the
dependencies on ioaddr and names all the offsets with
new defines.

I could post if you like.

I think it's a lot cleaner and easier to read.

2015-05-05 16:43:19

by Michael Grzeschik

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

Hi,

and sorry for the delay.

On Wed, Apr 29, 2015 at 08:49:25PM -0700, Joe Perches wrote:
> On Mon, 2015-04-27 at 16:57 +0200, Michael Grzeschik wrote:
> > Hi!
> >
> > On Fri, Apr 24, 2015 at 11:58:53PM -0400, David Miller wrote:
> > > From: Marc Kleine-Budde <[email protected]>
> > > Date: Fri, 24 Apr 2015 23:14:41 +0200
> > >
> > > > On 04/24/2015 08:47 PM, Joe Perches wrote:
> > > >> On Fri, 2015-04-24 at 19:20 +0200, Michael Grzeschik wrote:
> > > >>> Hi!
> > > >>
> > > >> Hello.
> > > >>
> > > >>> This patch series tries to reanimate the ARCNET hardware layer to be
> > > >>> somehow readable and maintainable again. It includes a lot of cleanup
> > > >>> patches. It also adds some fixes which leads the layer to become usable
> > > >>> again. And as a special treatment it adds more features like correct
> > > >>> loading and unloading of the com20020 card.
> > > >>
> > > >> Wow. Good for you, but why? Does anyone still use these?
> > > >
> > > > Yes, there are parts of the industry where "old" machines are
> > > > retrofitted with new hardware...and a lot of these machines still talk
> > > > ARCNET :)
> > >
> > > But the real issue is, this layer is development wise in the same
> > > category as the IDE layer.
> > >
> > > Any non-trivial change is nothing but pure risk, especially given the
> > > low level of test coverage the code gets.
> >
> > Do you count coding style patches as non-trivial or trivial
> > patches?
> >
> > > So I really only want to see the most critical obvious bug fixes
> > > submitted for this layer and drivers.
> >
> > The cleanup changes I submitted should not change the actual behaviour.
> > Replacing the register access macros with their equivalent outb/inb
> > seems pretty obvious. What is your opinion on those?
> >
> > I see that the "ARCNET: whitespace, tab and codingstyle fixes" patch is
> > pretty mixed up and not very reliable. But Joe has sent me a nice series
> > for the cleanup.
> >
> > > And no I will not accept an argument stating that you have to
> > > restructure and clean this code up in order to fix the bugs. That's
> > > bogus.
> >
> > OK.
> >
> > I have the following patches in this series which fix bugs found during
> > my development:
> >
> > com20020-pci: add dev_port for udev handling
> > ARCNET: fix hard_header_len limit
> > ARCNET: com20020: add enable and disable device on open/close
> >
> > I would send a new series containing only those patches with more
> > detailed patch descriptions, if that's fine with you?
>
> I was away for a few days and while out I did another
> restructuring of all the inb/outb/readb/writeb code
> removing all the A<FOO> macros. It removes all the
> dependencies on ioaddr and names all the offsets with
> new defines.
>
> I could post if you like.

Sure, you should do that! I will rework my patches on top of them.

> I think it's a lot cleaner and easier to read.

OK!

I would like to know what David things about the whole work.

Thanks,
Michael

--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |

2015-05-05 17:02:36

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 00/21] ARCNET: Defibrillation

On Tue, 2015-05-05 at 18:43 +0200, Michael Grzeschik wrote:
> On Wed, Apr 29, 2015 at 08:49:25PM -0700, Joe Perches wrote:
> > I was away for a few days and while out I did another
> > restructuring of all the inb/outb/readb/writeb code
> > removing all the A<FOO> macros. It removes all the
> > dependencies on ioaddr and names all the offsets with
> > new defines.
> >
> > I could post if you like.
>
> Sure, you should do that! I will rework my patches on top of them.

As it's ~400KB and very few are likely interested,
I'll send them to you privately.

> I would like to know what David things about the whole work.

I think he already said what he thinks.

As arcnet has neither a maintainer nor an active
user base, arcnet is in "bugfix only mode".

Testing coverage is the biggest issue.

If you want to become the maintainer for arcnet
and have sufficient time and hardware to verify
that changes don't break things, great!

Responsibility then shifts to you.

Enjoy! (and thanks)