Skip to content

Commit

Permalink
8390 : Replace ei_debug with msg_enable/NETIF_MSG_* feature
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Matthew Whitehead authored and David S. Miller committed Dec 11, 2013
1 parent 7e98056 commit c45f812
Show file tree
Hide file tree
Showing 16 changed files with 426 additions and 302 deletions.
7 changes: 1 addition & 6 deletions drivers/net/ethernet/8390/8390.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ struct e8390_pkt_hdr {
unsigned short count; /* header + packet length in bytes */
};

#ifdef notdef
extern int ei_debug;
#else
#define ei_debug 1
#endif

#ifdef CONFIG_NET_POLL_CONTROLLER
void ei_poll(struct net_device *dev);
void eip_poll(struct net_device *dev);
Expand Down Expand Up @@ -99,6 +93,7 @@ struct ei_device {
u32 *reg_offset; /* Register mapping table */
spinlock_t page_lock; /* Page register locks */
unsigned long priv; /* Private field to store bus IDs etc. */
u32 msg_enable; /* debug message level */
#ifdef AX88796_PLATFORM
unsigned char rxcr_base; /* default value for RXCR */
#endif
Expand Down
62 changes: 36 additions & 26 deletions drivers/net/ethernet/8390/apne.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ static const char version[] =

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

static u32 apne_msg_enable;
module_param_named(msg_enable, apne_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH));
MODULE_PARM_DESC(msg_enable, "Debug message level (see linux/netdevice.h for bitmap)");

struct net_device * __init apne_probe(int unit)
{
struct net_device *dev;
struct ei_device *ei_local;

#ifndef MANUAL_CONFIG
char tuple[8];
#endif
Expand All @@ -133,11 +139,11 @@ struct net_device * __init apne_probe(int unit)
if ( !(AMIGAHW_PRESENT(PCMCIA)) )
return ERR_PTR(-ENODEV);

printk("Looking for PCMCIA ethernet card : ");
pr_info("Looking for PCMCIA ethernet card : ");

/* check if a card is inserted */
if (!(PCMCIA_INSERTED)) {
printk("NO PCMCIA card inserted\n");
pr_cont("NO PCMCIA card inserted\n");
return ERR_PTR(-ENODEV);
}

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

/* disable pcmcia irq for readtuple */
pcmcia_disable_irq();

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

printk("ethernet PCMCIA card inserted\n");
pr_cont("ethernet PCMCIA card inserted\n");

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

if (ei_debug && version_printed++ == 0)
printk(version);
if ((apne_msg_enable & NETIF_MSG_DRV) && (version_printed++ == 0))
netdev_info(dev, version);

printk("PCMCIA NE*000 ethercard probe");
netdev_info(dev, "PCMCIA NE*000 ethercard probe");

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

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

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

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

printk(" %pM\n", dev->dev_addr);
pr_cont(" %pM\n", dev->dev_addr);

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

ei_status.name = name;
ei_status.tx_start_page = start_page;
Expand Down Expand Up @@ -352,10 +361,11 @@ static void
apne_reset_8390(struct net_device *dev)
{
unsigned long reset_start_time = jiffies;
struct ei_device *ei_local = netdev_priv(dev);

init_pcmcia();

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

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

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

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

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

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

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

while ((inb(NE_BASE + NE_EN0_ISR) & ENISR_RDC) == 0)
if (time_after(jiffies, dma_start + 2*HZ/100)) { /* 20ms */
printk("%s: timeout waiting for Tx RDC.\n", dev->name);
netdev_warn(dev, "timeout waiting for Tx RDC.\n");
apne_reset_8390(dev);
NS8390_init(dev,1);
break;
Expand All @@ -536,8 +546,8 @@ static irqreturn_t apne_interrupt(int irq, void *dev_id)
pcmcia_ack_int(pcmcia_intreq);
return IRQ_NONE;
}
if (ei_debug > 3)
printk("pcmcia intreq = %x\n", pcmcia_intreq);
if (apne_msg_enable & NETIF_MSG_INTR)
pr_debug("pcmcia intreq = %x\n", pcmcia_intreq);
pcmcia_disable_irq(); /* to get rid of the sti() within ei_interrupt */
ei_interrupt(irq, dev_id);
pcmcia_ack_int(pcmcia_get_intreq());
Expand Down
22 changes: 20 additions & 2 deletions drivers/net/ethernet/8390/ax88796.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static unsigned char version[] = "ax88796.c: Copyright 2005,2007 Simtec Electron

#define AX_GPOC_PPDSET BIT(6)

static u32 ax_msg_enable;

/* device private data */

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

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

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

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

static u32 ax_get_msglevel(struct net_device *dev)
{
struct ei_device *ei_local = netdev_priv(dev);

return ei_local->msg_enable;
}

static void ax_set_msglevel(struct net_device *dev, u32 v)
{
struct ei_device *ei_local = netdev_priv(dev);

ei_local->msg_enable = v;
}

static const struct ethtool_ops ax_ethtool_ops = {
.get_drvinfo = ax_get_drvinfo,
.get_settings = ax_get_settings,
.set_settings = ax_set_settings,
.get_link = ethtool_op_get_link,
.get_ts_info = ethtool_op_get_ts_info,
.get_msglevel = ax_get_msglevel,
.set_msglevel = ax_set_msglevel,
};

#ifdef CONFIG_AX88796_93CX6
Expand Down Expand Up @@ -763,6 +780,7 @@ static int ax_init_dev(struct net_device *dev)
ei_local->block_output = &ax_block_output;
ei_local->get_8390_hdr = &ax_get_8390_hdr;
ei_local->priv = 0;
ei_local->msg_enable = ax_msg_enable;

dev->netdev_ops = &ax_netdev_ops;
dev->ethtool_ops = &ax_ethtool_ops;
Expand Down
Loading

0 comments on commit c45f812

Please sign in to comment.