#include "cs89x0.h"
+#define cs89_dbg(val, level, fmt, ...) \
+do { \
+ if (val <= net_debug) \
+ pr_##level(fmt, ##__VA_ARGS__); \
+} while (0)
+
static char version[] __initdata =
- "v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton\n";
+ "v2.4.3-pre1 Russell Nelson <nelson@crynwr.com>, Andrew Morton";
#define DRV_NAME "cs89x0"
{
int i;
- if (net_debug > 3)
- printk("EEPROM data from %x for %x:\n", off, len);
+ cs89_dbg(3, info, "EEPROM data from %x for %x:\n", off, len);
for (i = 0; i < len; i++) {
if (wait_eeprom_ready(dev) < 0)
return -1;
if (wait_eeprom_ready(dev) < 0)
return -1;
buffer[i] = readreg(dev, PP_EEData);
- if (net_debug > 3)
- printk("%04x ", buffer[i]);
+ cs89_dbg(3, cont, "%04x ", buffer[i]);
}
- if (net_debug > 3)
- printk("\n");
+ cs89_dbg(3, cont, "\n");
return 0;
}
if (lp->chip_type != CS8900 && lp->chip_revision >= 'C')
lp->send_cmd = TX_NOW;
- if (net_debug)
- printk_once(version);
+ pr_info_once("%s\n", version);
pr_info("%s: cs89%c0%s rev %c found at %p ",
dev->name,
lp->adapter_cnf |= A_CNF_AUI | A_CNF_10B_T |
A_CNF_MEDIA_AUI | A_CNF_MEDIA_10B_T | A_CNF_MEDIA_AUTO;
- if (net_debug > 1)
- pr_info("%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n",
- dev->name, i, lp->adapter_cnf);
+ cs89_dbg(1, info, "%s: PP_LineCTL=0x%x, adapter_cnf=0x%x\n",
+ dev->name, i, lp->adapter_cnf);
/* IRQ. Other chips already probe, see below. */
if (lp->chip_type == CS8900)
lp->isa_config = readreg(dev, PP_CS8900_ISAINT) & INT_NO_MASK;
- printk("[Cirrus EEPROM] ");
+ pr_cont("[Cirrus EEPROM] ");
}
- printk("\n");
+ pr_cont("\n");
/* First check to see if an EEPROM is attached. */
dev->dev_addr[i * 2] = eeprom_buff[i];
dev->dev_addr[i * 2 + 1] = eeprom_buff[i] >> 8;
}
- if (net_debug > 1)
- pr_debug("%s: new adapter_cnf: 0x%x\n",
- dev->name, lp->adapter_cnf);
+ cs89_dbg(1, debug, "%s: new adapter_cnf: 0x%x\n",
+ dev->name, lp->adapter_cnf);
}
/* allow them to force multiple transceivers. If they force multiple, autosense */
lp->adapter_cnf |= A_CNF_MEDIA_10B_2;
}
- if (net_debug > 1)
- pr_debug("%s: after force 0x%x, adapter_cnf=0x%x\n",
- dev->name, lp->force, lp->adapter_cnf);
+ cs89_dbg(1, debug, "%s: after force 0x%x, adapter_cnf=0x%x\n",
+ dev->name, lp->force, lp->adapter_cnf);
/* FIXME: We don't let you set dc-dc polarity or low RX squelch from the command line: add it here */
dev->irq = i;
}
- printk(" IRQ %d", dev->irq);
+ pr_cont(" IRQ %d", dev->irq);
#if ALLOW_DMA
if (lp->use_dma) {
get_dma_channel(dev);
- printk(", DMA %d", dev->dma);
+ pr_cont(", DMA %d", dev->dma);
} else
#endif
- printk(", programmed I/O");
+ pr_cont(", programmed I/O");
/* print the ethernet address. */
- printk(", MAC %pM\n", dev->dev_addr);
+ pr_cont(", MAC %pM\n", dev->dev_addr);
dev->netdev_ops = &net_ops;
dev->watchdog_timeo = HZ;
- if (net_debug)
- printk("cs89x0_probe1() successful\n");
+ cs89_dbg(0, info, "cs89x0_probe1() successful\n");
retval = register_netdev(dev);
if (retval)
* will skip the test for the ADD_PORT.
*/
if (ioport & 1) {
- if (net_debug > 1)
- pr_info("%s: odd ioaddr 0x%lx\n", dev->name, ioport);
+ cs89_dbg(1, info, "%s: odd ioaddr 0x%lx\n", dev->name, ioport);
if ((ioport & 2) != 2) {
if ((ioread16(io_mem + ADD_PORT) & ADD_MASK) !=
ADD_SIG) {
io = dev->base_addr;
irq = dev->irq;
- if (net_debug)
- pr_info("cs89x0_probe(0x%x)\n", io);
+ cs89_dbg(0, info, "cs89x0_probe(0x%x)\n", io);
if (io > 0x1ff) { /* Check a single specified location. */
err = cs89x0_ioport_probe(dev, io, 0);
if (lp->use_dma) {
if ((lp->isa_config & ANY_ISA_DMA) == 0) {
- if (net_debug > 3)
- printk("set_dma_cfg(): no DMA\n");
+ cs89_dbg(3, err, "set_dma_cfg(): no DMA\n");
return;
}
if (lp->isa_config & ISA_RxDMA) {
lp->curr_rx_cfg |= RX_DMA_ONLY;
- if (net_debug > 3)
- printk("set_dma_cfg(): RX_DMA_ONLY\n");
+ cs89_dbg(3, info, "set_dma_cfg(): RX_DMA_ONLY\n");
} else {
lp->curr_rx_cfg |= AUTO_RX_DMA; /* not that we support it... */
- if (net_debug > 3)
- printk("set_dma_cfg(): AUTO_RX_DMA\n");
+ cs89_dbg(3, info, "set_dma_cfg(): AUTO_RX_DMA\n");
}
}
}
status = bp[0] + (bp[1] << 8);
length = bp[2] + (bp[3] << 8);
bp += 4;
- if (net_debug > 5) {
- printk("%s: receiving DMA packet at %lx, status %x, length %x\n",
- dev->name, (unsigned long)bp, status, length);
- }
+
+ cs89_dbg(5, debug, "%s: receiving DMA packet at %lx, status %x, length %x\n",
+ dev->name, (unsigned long)bp, status, length);
+
if ((status & RX_OK) == 0) {
count_rx_errors(status, dev);
goto skip_this_frame;
/* Malloc up new buffer. */
skb = netdev_alloc_skb(dev, length + 2);
if (skb == NULL) {
- if (net_debug) /* I don't think we want to do this to a stressed system */
- printk("%s: Memory squeeze, dropping packet\n",
- dev->name);
+ /* I don't think we want to do this to a stressed system */
+ cs89_dbg(0, err, "%s: Memory squeeze, dropping packet\n",
+ dev->name);
dev->stats.rx_dropped++;
/* AKPM: advance bp to the next frame */
bp -= lp->dmasize*1024;
lp->rx_dma_ptr = bp;
- if (net_debug > 3) {
- printk("%s: received %d byte DMA packet of type %x\n",
- dev->name, length,
- ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
- skb->data[ETH_ALEN + ETH_ALEN + 1]));
- }
+ cs89_dbg(3, info, "%s: received %d byte DMA packet of type %x\n",
+ dev->name, length,
+ ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+ skb->data[ETH_ALEN + ETH_ALEN + 1]));
+
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
dev->stats.rx_packets++;
int timenow = jiffies;
int fdx;
- if (net_debug > 1)
- printk("%s: Attempting TP\n", dev->name);
+ cs89_dbg(1, debug, "%s: Attempting TP\n", dev->name);
/* If connected to another full duplex capable 10-Base-T card
* the link pulses seem to be lost when the auto detect bit in
switch (lp->force & 0xf0) {
#if 0
case FORCE_AUTO:
- printk("%s: cs8900 doesn't autonegotiate\n", dev->name);
+ pr_info("%s: cs8900 doesn't autonegotiate\n",
+ dev->name);
return DETECTED_NONE;
#endif
/* CS8900 doesn't support AUTO, change to HALF*/
/* Write the contents of the packet */
writewords(lp, TX_FRAME_PORT, test_packet, (ETH_ZLEN + 1) >> 1);
- if (net_debug > 1)
- printk("Sending test packet ");
+ cs89_dbg(1, debug, "Sending test packet ");
/* wait a couple of jiffies for packet to be received */
for (timenow = jiffies; jiffies - timenow < 3;)
;
if ((readreg(dev, PP_TxEvent) & TX_SEND_OK_BITS) == TX_OK) {
- if (net_debug > 1)
- printk("succeeded\n");
+ cs89_dbg(1, cont, "succeeded\n");
return 1;
}
- if (net_debug > 1)
- printk("failed\n");
+ cs89_dbg(1, cont, "failed\n");
return 0;
}
{
struct net_local *lp = netdev_priv(dev);
- if (net_debug > 1)
- printk("%s: Attempting AUI\n", dev->name);
+ cs89_dbg(1, debug, "%s: Attempting AUI\n", dev->name);
control_dc_dc(dev, 0);
writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
{
struct net_local *lp = netdev_priv(dev);
- if (net_debug > 1)
- printk("%s: Attempting BNC\n", dev->name);
+ cs89_dbg(1, debug, "%s: Attempting BNC\n", dev->name);
control_dc_dc(dev, 1);
writereg(dev, PP_LineCTL, (lp->linectl & ~AUTO_AUI_10BASET) | AUI_ONLY);
dev->name, lp->dmasize);
goto release_irq;
}
- if (net_debug > 1) {
- printk("%s: dma %lx %lx\n",
- dev->name,
- (unsigned long)lp->dma_buff,
- (unsigned long)isa_virt_to_bus(lp->dma_buff));
- }
+ cs89_dbg(1, debug, "%s: dma %lx %lx\n",
+ dev->name,
+ (unsigned long)lp->dma_buff,
+ (unsigned long)isa_virt_to_bus(lp->dma_buff));
if ((unsigned long)lp->dma_buff >= MAX_DMA_ADDRESS ||
!dma_page_eq(lp->dma_buff,
lp->dma_buff + lp->dmasize * 1024 - 1)) {
#endif
));
netif_start_queue(dev);
- if (net_debug > 1)
- printk("cs89x0: net_open() succeeded\n");
+ cs89_dbg(1, debug, "net_open() succeeded\n");
return 0;
bad_out:
return ret;
{
/* If we get here, some higher level has decided we are broken.
There should really be a "kick me" function call instead. */
- if (net_debug > 0)
- printk("%s: transmit timed out, %s?\n",
- dev->name,
- tx_done(dev) ? "IRQ conflict" : "network cable problem");
+ cs89_dbg(0, err, "%s: transmit timed out, %s?\n",
+ dev->name,
+ tx_done(dev) ? "IRQ conflict" : "network cable problem");
/* Try to restart the adaptor. */
netif_wake_queue(dev);
}
struct net_local *lp = netdev_priv(dev);
unsigned long flags;
- if (net_debug > 3) {
- printk("%s: sent %d byte packet of type %x\n",
- dev->name, skb->len,
- ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
- skb->data[ETH_ALEN + ETH_ALEN + 1]));
- }
+ cs89_dbg(3, debug, "%s: sent %d byte packet of type %x\n",
+ dev->name, skb->len,
+ ((skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+ skb->data[ETH_ALEN + ETH_ALEN + 1]));
/* keep the upload from being interrupted, since we
* ask the chip to start transmitting before the
*/
spin_unlock_irqrestore(&lp->lock, flags);
- if (net_debug)
- printk("cs89x0: Tx buffer not free!\n");
+ cs89_dbg(0, err, "Tx buffer not free!\n");
return NETDEV_TX_BUSY;
}
/* Write the contents of the packet */
* vista, baby!
*/
while ((status = ioread16(lp->virt_addr + ISQ_PORT))) {
- if (net_debug > 4)
- printk("%s: event=%04x\n", dev->name, status);
+ cs89_dbg(4, debug, "%s: event=%04x\n", dev->name, status);
handled = 1;
switch (status & ISQ_EVENT_MASK) {
case ISQ_RECEIVER_EVENT:
netif_wake_queue(dev); /* Inform upper layers. */
}
if (status & TX_UNDERRUN) {
- if (net_debug > 0)
- printk("%s: transmit underrun\n",
- dev->name);
+ cs89_dbg(0, err, "%s: transmit underrun\n",
+ dev->name);
lp->send_underrun++;
if (lp->send_underrun == 3)
lp->send_cmd = TX_AFTER_381;
if (lp->use_dma && (status & RX_DMA)) {
int count = readreg(dev, PP_DmaFrameCnt);
while (count) {
- if (net_debug > 5)
- printk("%s: receiving %d DMA frames\n",
- dev->name, count);
- if (net_debug > 2 && count > 1)
- printk("%s: receiving %d DMA frames\n",
- dev->name, count);
+ cs89_dbg(5, debug,
+ "%s: receiving %d DMA frames\n",
+ dev->name, count);
+ if (count > 1)
+ cs89_dbg(2, debug,
+ "%s: receiving %d DMA frames\n",
+ dev->name, count);
dma_rx(dev);
if (--count == 0)
count = readreg(dev, PP_DmaFrameCnt);
- if (net_debug > 2 && count > 0)
- printk("%s: continuing with %d DMA frames\n",
- dev->name, count);
+ if (count > 0)
+ cs89_dbg(2, debug,
+ "%s: continuing with %d DMA frames\n",
+ dev->name, count);
}
}
#endif
if (length & 1)
skb->data[length-1] = ioread16(lp->virt_addr + RX_FRAME_PORT);
- if (net_debug > 3) {
- printk("%s: received %d byte packet of type %x\n",
- dev->name, length,
- (skb->data[ETH_ALEN + ETH_ALEN] << 8) |
- skb->data[ETH_ALEN + ETH_ALEN + 1]);
- }
+ cs89_dbg(3, debug, "%s: received %d byte packet of type %x\n",
+ dev->name, length,
+ (skb->data[ETH_ALEN + ETH_ALEN] << 8) |
+ skb->data[ETH_ALEN + ETH_ALEN + 1]);
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
memcpy(dev->dev_addr, addr->sa_data, dev->addr_len);
- if (net_debug)
- printk("%s: Setting MAC address to %pM\n",
- dev->name, dev->dev_addr);
+ cs89_dbg(0, debug, "%s: Setting MAC address to %pM\n",
+ dev->name, dev->dev_addr);
/* set the Ethernet address */
for (i = 0; i < ETH_ALEN / 2; i++)