arcnet: com20020: replace magic numbers with readable macros
authorMichael Grzeschik <m.grzeschik@pengutronix.de>
Wed, 15 Apr 2015 09:43:57 +0000 (11:43 +0200)
committerMichael Grzeschik <m.grzeschik@pengutronix.de>
Wed, 23 Sep 2015 06:44:28 +0000 (08:44 +0200)
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 <m.grzeschik@pengutronix.de>
drivers/net/arcnet/arcdevice.h
drivers/net/arcnet/com20020.c
drivers/net/arcnet/com20020.h

index 4c1c44c85b086613243eef339e8f1f6f07ba831f..d7fdea11e694c01345f55e955d29e1a2bbe7a8b2 100644 (file)
@@ -164,6 +164,7 @@ do {                                                                        \
 #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 */
index d4162750a354848e942362e5a06ec97181fa8b92..c82f323a8c2b8fecd0f1c6a33d253db176088df5 100644 (file)
@@ -94,9 +94,9 @@ int com20020_check(struct net_device *dev)
        int ioaddr = dev->base_addr, status;
        struct arcnet_local *lp = netdev_priv(dev);
 
-       arcnet_outb(0x18 | 0x80, ioaddr, COM20020_REG_W_CONFIG);
+       arcnet_outb(XTOcfg(3) | RESETcfg, ioaddr, COM20020_REG_W_CONFIG);
        udelay(5);
-       arcnet_outb(0x18 , ioaddr, COM20020_REG_W_CONFIG);
+       arcnet_outb(XTOcfg(3), ioaddr, COM20020_REG_W_CONFIG);
        mdelay(RESETtime);
 
        lp->setup = lp->clockm ? 0 : (lp->clockp << 1);
@@ -115,10 +115,10 @@ int com20020_check(struct net_device *dev)
 
                /* must now write the magic "restart operation" command */
                mdelay(1);
-               arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND);
+               arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_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) */
        arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
        arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG);
@@ -132,7 +132,8 @@ int com20020_check(struct net_device *dev)
        arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status);
 
        /* Enable TX */
-       arcnet_outb(0x39, ioaddr, COM20020_REG_W_CONFIG);
+       lp->config |= TXENcfg;
+       arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
        arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG);
 
        arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear,
@@ -211,10 +212,10 @@ int com20020_found(struct net_device *dev, int shared)
 
                /* must now write the magic "restart operation" command */
                mdelay(1);
-               arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND);
+               arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_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 */
        arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
        arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG);
@@ -280,7 +281,7 @@ static int com20020_reset(struct net_device *dev, int really_reset)
 
        if (really_reset) {
                /* reset the card */
-               arcnet_outb(lp->config | 0x80, ioaddr, COM20020_REG_W_CONFIG);
+               arcnet_outb(lp->config | RESETcfg, ioaddr, COM20020_REG_W_CONFIG);
                udelay(5);
                arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG);
                mdelay(RESETtime * 2);
index ffb19464b607f33fad0a24ee31c3e44aebb6dd9a..22a460f39fb93854022aacfca639287aa11958b8 100644 (file)
@@ -86,6 +86,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 */
This page took 0.036069 seconds and 5 git commands to generate.