Skip to content

Commit c45f812

Browse files
Matthew Whiteheaddavem330
authored andcommitted
8390 : Replace ei_debug with msg_enable/NETIF_MSG_* feature
Removed the shared ei_debug variable. Replaced it by adding u32 msg_enable to the private struct ei_device. Now each 8390 ethernet instance has a per-device logging variable. Changed older style printk() calls to more canonical forms. Tested on: ne, ne2k-pci, smc-ultra, and wd hardware. V4.0 - Substituted pr_info() and pr_debug() for printk() KERN_INFO and KERN_DEBUG V3.0 - Checked for cases where pr_cont() was most appropriate choice. - Changed module parameter from 'debug' to 'msg_enable' because debug was no longer the best description. V2.0 - Changed netif_msg_(drv|probe|ifdown|rx_err|tx_err|tx_queued|intr|rx_status|hw) to netif_(dbg|info|warn|err) where possible. Signed-off-by: Matthew Whitehead <tedheadster@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 7e98056 commit c45f812

File tree

16 files changed

+426
-302
lines changed

16 files changed

+426
-302
lines changed

drivers/net/ethernet/8390/8390.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ struct e8390_pkt_hdr {
2121
unsigned short count; /* header + packet length in bytes */
2222
};
2323

24-
#ifdef notdef
25-
extern int ei_debug;
26-
#else
27-
#define ei_debug 1
28-
#endif
29-
3024
#ifdef CONFIG_NET_POLL_CONTROLLER
3125
void ei_poll(struct net_device *dev);
3226
void eip_poll(struct net_device *dev);
@@ -99,6 +93,7 @@ struct ei_device {
9993
u32 *reg_offset; /* Register mapping table */
10094
spinlock_t page_lock; /* Page register locks */
10195
unsigned long priv; /* Private field to store bus IDs etc. */
96+
u32 msg_enable; /* debug message level */
10297
#ifdef AX88796_PLATFORM
10398
unsigned char rxcr_base; /* default value for RXCR */
10499
#endif

drivers/net/ethernet/8390/apne.c

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,15 @@ static const char version[] =
116116

117117
static int apne_owned; /* signal if card already owned */
118118

119+
static u32 apne_msg_enable;
120+
module_param_named(msg_enable, apne_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
121+
MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");
122+
119123
struct net_device * __init apne_probe(int unit)
120124
{
121125
struct net_device *dev;
126+
struct ei_device *ei_local;
127+
122128
#ifndef MANUAL_CONFIG
123129
char tuple[8];
124130
#endif
@@ -133,11 +139,11 @@ struct net_device * __init apne_probe(int unit)
133139
if ( !(AMIGAHW_PRESENT(PCMCIA)) )
134140
return ERR_PTR(-ENODEV);
135141

136-
printk("Looking for PCMCIA ethernet card : ");
142+
pr_info("Looking for PCMCIA ethernet card : ");
137143

138144
/* check if a card is inserted */
139145
if (!(PCMCIA_INSERTED)) {
140-
printk("NO PCMCIA card inserted\n");
146+
pr_cont("NO PCMCIA card inserted\n");
141147
return ERR_PTR(-ENODEV);
142148
}
143149

@@ -148,21 +154,23 @@ struct net_device * __init apne_probe(int unit)
148154
sprintf(dev->name, "eth%d", unit);
149155
netdev_boot_setup_check(dev);
150156
}
157+
ei_local = netdev_priv(dev);
158+
ei_local->msg_enable = apne_msg_enable;
151159

152160
/* disable pcmcia irq for readtuple */
153161
pcmcia_disable_irq();
154162

155163
#ifndef MANUAL_CONFIG
156164
if ((pcmcia_copy_tuple(CISTPL_FUNCID, tuple, 8) < 3) ||
157165
(tuple[2] != CISTPL_FUNCID_NETWORK)) {
158-
printk("not an ethernet card\n");
166+
pr_cont("not an ethernet card\n");
159167
/* XXX: shouldn't we re-enable irq here? */
160168
free_netdev(dev);
161169
return ERR_PTR(-ENODEV);
162170
}
163171
#endif
164172

165-
printk("ethernet PCMCIA card inserted\n");
173+
pr_cont("ethernet PCMCIA card inserted\n");
166174

167175
if (!init_pcmcia()) {
168176
/* XXX: shouldn't we re-enable irq here? */
@@ -204,11 +212,12 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
204212
int neX000, ctron;
205213
#endif
206214
static unsigned version_printed;
215+
struct ei_device *ei_local = netdev_priv(dev);
207216

208-
if (ei_debug && version_printed++ == 0)
209-
printk(version);
217+
if ((apne_msg_enable & NETIF_MSG_DRV) && (version_printed++ == 0))
218+
netdev_info(dev, version);
210219

211-
printk("PCMCIA NE*000 ethercard probe");
220+
netdev_info(dev, "PCMCIA NE*000 ethercard probe");
212221

213222
/* Reset card. Who knows what dain-bramaged state it was left in. */
214223
{ unsigned long reset_start_time = jiffies;
@@ -217,7 +226,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
217226

218227
while ((inb(ioaddr + NE_EN0_ISR) & ENISR_RESET) == 0)
219228
if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
220-
printk(" not found (no reset ack).\n");
229+
pr_cont(" not found (no reset ack).\n");
221230
return -ENODEV;
222231
}
223232

@@ -288,7 +297,7 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
288297
start_page = 0x01;
289298
stop_page = (wordlength == 2) ? 0x40 : 0x20;
290299
} else {
291-
printk(" not found.\n");
300+
pr_cont(" not found.\n");
292301
return -ENXIO;
293302

294303
}
@@ -320,9 +329,9 @@ static int __init apne_probe1(struct net_device *dev, int ioaddr)
320329
for (i = 0; i < ETH_ALEN; i++)
321330
dev->dev_addr[i] = SA_prom[i];
322331

323-
printk(" %pM\n", dev->dev_addr);
332+
pr_cont(" %pM\n", dev->dev_addr);
324333

325-
printk("%s: %s found.\n", dev->name, name);
334+
netdev_info(dev, "%s found.\n", name);
326335

327336
ei_status.name = name;
328337
ei_status.tx_start_page = start_page;
@@ -352,10 +361,11 @@ static void
352361
apne_reset_8390(struct net_device *dev)
353362
{
354363
unsigned long reset_start_time = jiffies;
364+
struct ei_device *ei_local = netdev_priv(dev);
355365

356366
init_pcmcia();
357367

358-
if (ei_debug > 1) printk("resetting the 8390 t=%ld...", jiffies);
368+
netif_dbg(ei_local, hw, dev, "resetting the 8390 t=%ld...\n", jiffies);
359369

360370
outb(inb(NE_BASE + NE_RESET), NE_BASE + NE_RESET);
361371

@@ -365,8 +375,8 @@ apne_reset_8390(struct net_device *dev)
365375
/* This check _should_not_ be necessary, omit eventually. */
366376
while ((inb(NE_BASE+NE_EN0_ISR) & ENISR_RESET) == 0)
367377
if (time_after(jiffies, reset_start_time + 2*HZ/100)) {
368-
printk("%s: ne_reset_8390() did not complete.\n", dev->name);
369-
break;
378+
netdev_err(dev, "ne_reset_8390() did not complete.\n");
379+
break;
370380
}
371381
outb(ENISR_RESET, NE_BASE + NE_EN0_ISR); /* Ack intr. */
372382
}
@@ -386,9 +396,9 @@ apne_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr, int ring_pa
386396

387397
/* This *shouldn't* happen. If it does, it's the last thing you'll see */
388398
if (ei_status.dmaing) {
389-
printk("%s: DMAing conflict in ne_get_8390_hdr "
390-
"[DMAstat:%d][irqlock:%d][intr:%d].\n",
391-
dev->name, ei_status.dmaing, ei_status.irqlock, dev->irq);
399+
netdev_err(dev, "DMAing conflict in ne_get_8390_hdr "
400+
"[DMAstat:%d][irqlock:%d][intr:%d].\n",
401+
ei_status.dmaing, ei_status.irqlock, dev->irq);
392402
return;
393403
}
394404

@@ -433,9 +443,9 @@ apne_block_input(struct net_device *dev, int count, struct sk_buff *skb, int rin
433443

434444
/* This *shouldn't* happen. If it does, it's the last thing you'll see */
435445
if (ei_status.dmaing) {
436-
printk("%s: DMAing conflict in ne_block_input "
437-
"[DMAstat:%d][irqlock:%d][intr:%d].\n",
438-
dev->name, ei_status.dmaing, ei_status.irqlock, dev->irq);
446+
netdev_err(dev, "DMAing conflict in ne_block_input "
447+
"[DMAstat:%d][irqlock:%d][intr:%d].\n",
448+
ei_status.dmaing, ei_status.irqlock, dev->irq);
439449
return;
440450
}
441451
ei_status.dmaing |= 0x01;
@@ -481,9 +491,9 @@ apne_block_output(struct net_device *dev, int count,
481491

482492
/* This *shouldn't* happen. If it does, it's the last thing you'll see */
483493
if (ei_status.dmaing) {
484-
printk("%s: DMAing conflict in ne_block_output."
485-
"[DMAstat:%d][irqlock:%d][intr:%d]\n",
486-
dev->name, ei_status.dmaing, ei_status.irqlock, dev->irq);
494+
netdev_err(dev, "DMAing conflict in ne_block_output."
495+
"[DMAstat:%d][irqlock:%d][intr:%d]\n",
496+
ei_status.dmaing, ei_status.irqlock, dev->irq);
487497
return;
488498
}
489499
ei_status.dmaing |= 0x01;
@@ -513,7 +523,7 @@ apne_block_output(struct net_device *dev, int count,
513523

514524
while ((inb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0)
515525
if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
516-
printk("%s: timeout waiting for Tx RDC.\n", dev->name);
526+
netdev_warn(dev, "timeout waiting for Tx RDC.\n");
517527
apne_reset_8390(dev);
518528
NS8390_init(dev,1);
519529
break;
@@ -536,8 +546,8 @@ static irqreturn_t apne_interrupt(int irq, void *dev_id)
536546
pcmcia_ack_int(pcmcia_intreq);
537547
return IRQ_NONE;
538548
}
539-
if (ei_debug > 3)
540-
printk("pcmcia intreq = %x\n", pcmcia_intreq);
549+
if (apne_msg_enable & NETIF_MSG_INTR)
550+
pr_debug("pcmcia intreq = %x\n", pcmcia_intreq);
541551
pcmcia_disable_irq(); /* to get rid of the sti() within ei_interrupt */
542552
ei_interrupt(irq, dev_id);
543553
pcmcia_ack_int(pcmcia_get_intreq());

drivers/net/ethernet/8390/ax88796.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ static unsigned char version[] = "ax88796.c: Copyright 2005,2007 Simtec Electron
7878

7979
#define AX_GPOC_PPDSET BIT(6)
8080

81+
static u32 ax_msg_enable;
82+
8183
/* device private data */
8284

8385
struct ax_device {
@@ -147,8 +149,7 @@ static void ax_reset_8390(struct net_device *dev)
147149
unsigned long reset_start_time = jiffies;
148150
void __iomem *addr = (void __iomem *)dev->base_addr;
149151

150-
if (ei_debug > 1)
151-
netdev_dbg(dev, "resetting the 8390 t=%ld\n", jiffies);
152+
netif_dbg(ei_local, hw, dev, "resetting the 8390 t=%ld...\n", jiffies);
152153

153154
ei_outb(ei_inb(addr + NE_RESET), addr + NE_RESET);
154155

@@ -496,12 +497,28 @@ static int ax_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
496497
return phy_ethtool_sset(phy_dev, cmd);
497498
}
498499

500+
static u32 ax_get_msglevel(struct net_device *dev)
501+
{
502+
struct ei_device *ei_local = netdev_priv(dev);
503+
504+
return ei_local->msg_enable;
505+
}
506+
507+
static void ax_set_msglevel(struct net_device *dev, u32 v)
508+
{
509+
struct ei_device *ei_local = netdev_priv(dev);
510+
511+
ei_local->msg_enable = v;
512+
}
513+
499514
static const struct ethtool_ops ax_ethtool_ops = {
500515
.get_drvinfo = ax_get_drvinfo,
501516
.get_settings = ax_get_settings,
502517
.set_settings = ax_set_settings,
503518
.get_link = ethtool_op_get_link,
504519
.get_ts_info = ethtool_op_get_ts_info,
520+
.get_msglevel = ax_get_msglevel,
521+
.set_msglevel = ax_set_msglevel,
505522
};
506523

507524
#ifdef CONFIG_AX88796_93CX6
@@ -763,6 +780,7 @@ static int ax_init_dev(struct net_device *dev)
763780
ei_local->block_output = &ax_block_output;
764781
ei_local->get_8390_hdr = &ax_get_8390_hdr;
765782
ei_local->priv = 0;
783+
ei_local->msg_enable = ax_msg_enable;
766784

767785
dev->netdev_ops = &ax_netdev_ops;
768786
dev->ethtool_ops = &ax_ethtool_ops;

0 commit comments

Comments
 (0)