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

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

+11 -8
+1
drivers/net/arcnet/arcdevice.h
··· 164 164 #define CONFIGcmd 0x05 /* define configuration */ 165 165 #define CFLAGScmd 0x06 /* clear flags */ 166 166 #define TESTcmd 0x07 /* load test flags */ 167 + #define STARTIOcmd 0x18 /* start internal operation */ 167 168 168 169 /* flags for "clear flags" command */ 169 170 #define RESETclear 0x08 /* power-on-reset */
+9 -8
drivers/net/arcnet/com20020.c
··· 94 94 int ioaddr = dev->base_addr, status; 95 95 struct arcnet_local *lp = netdev_priv(dev); 96 96 97 - arcnet_outb(0x18 | 0x80, ioaddr, COM20020_REG_W_CONFIG); 97 + arcnet_outb(XTOcfg(3) | RESETcfg, ioaddr, COM20020_REG_W_CONFIG); 98 98 udelay(5); 99 - arcnet_outb(0x18 , ioaddr, COM20020_REG_W_CONFIG); 99 + arcnet_outb(XTOcfg(3), ioaddr, COM20020_REG_W_CONFIG); 100 100 mdelay(RESETtime); 101 101 102 102 lp->setup = lp->clockm ? 0 : (lp->clockp << 1); ··· 115 115 116 116 /* must now write the magic "restart operation" command */ 117 117 mdelay(1); 118 - arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND); 118 + arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND); 119 119 } 120 120 121 - lp->config = 0x21 | (lp->timeout << 3) | (lp->backplane << 2); 121 + lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; 122 122 /* set node ID to 0x42 (but transmitter is disabled, so it's okay) */ 123 123 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 124 124 arcnet_outb(0x42, ioaddr, COM20020_REG_W_XREG); ··· 132 132 arc_printk(D_INIT_REASONS, dev, "status after reset: %X\n", status); 133 133 134 134 /* Enable TX */ 135 - arcnet_outb(0x39, ioaddr, COM20020_REG_W_CONFIG); 135 + lp->config |= TXENcfg; 136 + arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 136 137 arcnet_outb(arcnet_inb(ioaddr, 8), ioaddr, COM20020_REG_W_XREG); 137 138 138 139 arcnet_outb(CFLAGScmd | RESETclear | CONFIGclear, ··· 212 211 213 212 /* must now write the magic "restart operation" command */ 214 213 mdelay(1); 215 - arcnet_outb(0x18, ioaddr, COM20020_REG_W_COMMAND); 214 + arcnet_outb(STARTIOcmd, ioaddr, COM20020_REG_W_COMMAND); 216 215 } 217 216 218 - lp->config = 0x20 | (lp->timeout << 3) | (lp->backplane << 2) | 1; 217 + lp->config = TXENcfg | (lp->timeout << 3) | (lp->backplane << 2) | SUB_NODE; 219 218 /* Default 0x38 + register: Node ID */ 220 219 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 221 220 arcnet_outb(dev->dev_addr[0], ioaddr, COM20020_REG_W_XREG); ··· 281 280 282 281 if (really_reset) { 283 282 /* reset the card */ 284 - arcnet_outb(lp->config | 0x80, ioaddr, COM20020_REG_W_CONFIG); 283 + arcnet_outb(lp->config | RESETcfg, ioaddr, COM20020_REG_W_CONFIG); 285 284 udelay(5); 286 285 arcnet_outb(lp->config, ioaddr, COM20020_REG_W_CONFIG); 287 286 mdelay(RESETtime * 2);
+1
drivers/net/arcnet/com20020.h
··· 86 86 /* in the CONFIG register */ 87 87 #define RESETcfg 0x80 /* put card in reset state */ 88 88 #define TXENcfg 0x20 /* enable TX */ 89 + #define XTOcfg(x) ((x) << 3) /* extended timeout */ 89 90 90 91 /* in SETUP register */ 91 92 #define PROMISCset 0x10 /* enable RCV_ALL */