Commit 0dc7d2b3 authored by Joe Perches's avatar Joe Perches Committed by David S. Miller

drivers/net/ks*: Use netdev_<level>, netif_<level> and pr_<level>

I'm not sure this is correct.

It changes logging macros from:
	dev_<level>(&ks->spidev->dev,
to
	netdev_<level>(ks->netdev,

Comments?

Use netdev_<level>
Use netif_<level>
Use pr_<level>
Add #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
Add missing line to message in ks8851_remove
Change kmalloc/memset(,0) to kzalloc
Remove ks_<level> macros
Consolidation code into set_media_state
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ca509101
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
* The Micrel KS8842 behind the timberdale FPGA * The Micrel KS8842 behind the timberdale FPGA
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -525,8 +527,7 @@ static int ks8842_open(struct net_device *netdev) ...@@ -525,8 +527,7 @@ static int ks8842_open(struct net_device *netdev)
err = request_irq(adapter->irq, ks8842_irq, IRQF_SHARED, DRV_NAME, err = request_irq(adapter->irq, ks8842_irq, IRQF_SHARED, DRV_NAME,
adapter); adapter);
if (err) { if (err) {
printk(KERN_ERR "Failed to request IRQ: %d: %d\n", pr_err("Failed to request IRQ: %d: %d\n", adapter->irq, err);
adapter->irq, err);
return err; return err;
} }
...@@ -668,8 +669,7 @@ static int __devinit ks8842_probe(struct platform_device *pdev) ...@@ -668,8 +669,7 @@ static int __devinit ks8842_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, netdev); platform_set_drvdata(pdev, netdev);
printk(KERN_INFO DRV_NAME pr_info("Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
" Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
(id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7); (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
return 0; return 0;
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
* published by the Free Software Foundation. * published by the Free Software Foundation.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define DEBUG #define DEBUG
#include <linux/module.h> #include <linux/module.h>
...@@ -125,11 +127,6 @@ struct ks8851_net { ...@@ -125,11 +127,6 @@ struct ks8851_net {
static int msg_enable; static int msg_enable;
#define ks_info(_ks, _msg...) dev_info(&(_ks)->spidev->dev, _msg)
#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->spidev->dev, _msg)
#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->spidev->dev, _msg)
#define ks_err(_ks, _msg...) dev_err(&(_ks)->spidev->dev, _msg)
/* shift for byte-enable data */ /* shift for byte-enable data */
#define BYTE_EN(_x) ((_x) << 2) #define BYTE_EN(_x) ((_x) << 2)
...@@ -167,7 +164,7 @@ static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val) ...@@ -167,7 +164,7 @@ static void ks8851_wrreg16(struct ks8851_net *ks, unsigned reg, unsigned val)
ret = spi_sync(ks->spidev, msg); ret = spi_sync(ks->spidev, msg);
if (ret < 0) if (ret < 0)
ks_err(ks, "spi_sync() failed\n"); netdev_err(ks->netdev, "spi_sync() failed\n");
} }
/** /**
...@@ -197,7 +194,7 @@ static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val) ...@@ -197,7 +194,7 @@ static void ks8851_wrreg8(struct ks8851_net *ks, unsigned reg, unsigned val)
ret = spi_sync(ks->spidev, msg); ret = spi_sync(ks->spidev, msg);
if (ret < 0) if (ret < 0)
ks_err(ks, "spi_sync() failed\n"); netdev_err(ks->netdev, "spi_sync() failed\n");
} }
/** /**
...@@ -263,7 +260,7 @@ static void ks8851_rdreg(struct ks8851_net *ks, unsigned op, ...@@ -263,7 +260,7 @@ static void ks8851_rdreg(struct ks8851_net *ks, unsigned op,
ret = spi_sync(ks->spidev, msg); ret = spi_sync(ks->spidev, msg);
if (ret < 0) if (ret < 0)
ks_err(ks, "read: spi_sync() failed\n"); netdev_err(ks->netdev, "read: spi_sync() failed\n");
else if (ks8851_rx_1msg(ks)) else if (ks8851_rx_1msg(ks))
memcpy(rxb, trx + 2, rxl); memcpy(rxb, trx + 2, rxl);
else else
...@@ -417,8 +414,8 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len) ...@@ -417,8 +414,8 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len)
u8 txb[1]; u8 txb[1];
int ret; int ret;
if (netif_msg_rx_status(ks)) netif_dbg(ks, rx_status, ks->netdev,
ks_dbg(ks, "%s: %d@%p\n", __func__, len, buff); "%s: %d@%p\n", __func__, len, buff);
/* set the operation we're issuing */ /* set the operation we're issuing */
txb[0] = KS_SPIOP_RXFIFO; txb[0] = KS_SPIOP_RXFIFO;
...@@ -434,7 +431,7 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len) ...@@ -434,7 +431,7 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len)
ret = spi_sync(ks->spidev, msg); ret = spi_sync(ks->spidev, msg);
if (ret < 0) if (ret < 0)
ks_err(ks, "%s: spi_sync() failed\n", __func__); netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
} }
/** /**
...@@ -446,7 +443,8 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len) ...@@ -446,7 +443,8 @@ static void ks8851_rdfifo(struct ks8851_net *ks, u8 *buff, unsigned len)
*/ */
static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt) static void ks8851_dbg_dumpkkt(struct ks8851_net *ks, u8 *rxpkt)
{ {
ks_dbg(ks, "pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n", netdev_dbg(ks->netdev,
"pkt %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n",
rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7], rxpkt[4], rxpkt[5], rxpkt[6], rxpkt[7],
rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11], rxpkt[8], rxpkt[9], rxpkt[10], rxpkt[11],
rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]); rxpkt[12], rxpkt[13], rxpkt[14], rxpkt[15]);
...@@ -471,8 +469,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) ...@@ -471,8 +469,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
rxfc = ks8851_rdreg8(ks, KS_RXFC); rxfc = ks8851_rdreg8(ks, KS_RXFC);
if (netif_msg_rx_status(ks)) netif_dbg(ks, rx_status, ks->netdev,
ks_dbg(ks, "%s: %d packets\n", __func__, rxfc); "%s: %d packets\n", __func__, rxfc);
/* Currently we're issuing a read per packet, but we could possibly /* Currently we're issuing a read per packet, but we could possibly
* improve the code by issuing a single read, getting the receive * improve the code by issuing a single read, getting the receive
...@@ -489,9 +487,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks) ...@@ -489,9 +487,8 @@ static void ks8851_rx_pkts(struct ks8851_net *ks)
rxstat = rxh & 0xffff; rxstat = rxh & 0xffff;
rxlen = rxh >> 16; rxlen = rxh >> 16;
if (netif_msg_rx_status(ks)) netif_dbg(ks, rx_status, ks->netdev,
ks_dbg(ks, "rx: stat 0x%04x, len 0x%04x\n", "rx: stat 0x%04x, len 0x%04x\n", rxstat, rxlen);
rxstat, rxlen);
/* the length of the packet includes the 32bit CRC */ /* the length of the packet includes the 32bit CRC */
...@@ -553,9 +550,8 @@ static void ks8851_irq_work(struct work_struct *work) ...@@ -553,9 +550,8 @@ static void ks8851_irq_work(struct work_struct *work)
status = ks8851_rdreg16(ks, KS_ISR); status = ks8851_rdreg16(ks, KS_ISR);
if (netif_msg_intr(ks)) netif_dbg(ks, intr, ks->netdev,
dev_dbg(&ks->spidev->dev, "%s: status 0x%04x\n", "%s: status 0x%04x\n", __func__, status);
__func__, status);
if (status & IRQ_LCI) { if (status & IRQ_LCI) {
/* should do something about checking link status */ /* should do something about checking link status */
...@@ -582,8 +578,8 @@ static void ks8851_irq_work(struct work_struct *work) ...@@ -582,8 +578,8 @@ static void ks8851_irq_work(struct work_struct *work)
* system */ * system */
ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR); ks->tx_space = ks8851_rdreg16(ks, KS_TXMIR);
if (netif_msg_intr(ks)) netif_dbg(ks, intr, ks->netdev,
ks_dbg(ks, "%s: txspace %d\n", __func__, ks->tx_space); "%s: txspace %d\n", __func__, ks->tx_space);
} }
if (status & IRQ_RXI) if (status & IRQ_RXI)
...@@ -659,8 +655,7 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq) ...@@ -659,8 +655,7 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq)
unsigned fid = 0; unsigned fid = 0;
int ret; int ret;
if (netif_msg_tx_queued(ks)) netif_dbg(ks, tx_queued, ks->netdev, "%s: skb %p, %d@%p, irq %d\n",
dev_dbg(&ks->spidev->dev, "%s: skb %p, %d@%p, irq %d\n",
__func__, txp, txp->len, txp->data, irq); __func__, txp, txp->len, txp->data, irq);
fid = ks->fid++; fid = ks->fid++;
...@@ -685,7 +680,7 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq) ...@@ -685,7 +680,7 @@ static void ks8851_wrpkt(struct ks8851_net *ks, struct sk_buff *txp, bool irq)
ret = spi_sync(ks->spidev, msg); ret = spi_sync(ks->spidev, msg);
if (ret < 0) if (ret < 0)
ks_err(ks, "%s: spi_sync() failed\n", __func__); netdev_err(ks->netdev, "%s: spi_sync() failed\n", __func__);
} }
/** /**
...@@ -744,8 +739,7 @@ static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode) ...@@ -744,8 +739,7 @@ static void ks8851_set_powermode(struct ks8851_net *ks, unsigned pwrmode)
{ {
unsigned pmecr; unsigned pmecr;
if (netif_msg_hw(ks)) netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);
ks_dbg(ks, "setting power mode %d\n", pwrmode);
pmecr = ks8851_rdreg16(ks, KS_PMECR); pmecr = ks8851_rdreg16(ks, KS_PMECR);
pmecr &= ~PMECR_PM_MASK; pmecr &= ~PMECR_PM_MASK;
...@@ -769,8 +763,7 @@ static int ks8851_net_open(struct net_device *dev) ...@@ -769,8 +763,7 @@ static int ks8851_net_open(struct net_device *dev)
* else at the moment */ * else at the moment */
mutex_lock(&ks->lock); mutex_lock(&ks->lock);
if (netif_msg_ifup(ks)) netif_dbg(ks, ifup, ks->netdev, "opening\n");
ks_dbg(ks, "opening %s\n", dev->name);
/* bring chip out of any power saving mode it was in */ /* bring chip out of any power saving mode it was in */
ks8851_set_powermode(ks, PMECR_PM_NORMAL); ks8851_set_powermode(ks, PMECR_PM_NORMAL);
...@@ -826,8 +819,7 @@ static int ks8851_net_open(struct net_device *dev) ...@@ -826,8 +819,7 @@ static int ks8851_net_open(struct net_device *dev)
netif_start_queue(ks->netdev); netif_start_queue(ks->netdev);
if (netif_msg_ifup(ks)) netif_dbg(ks, ifup, ks->netdev, "network device up\n");
ks_dbg(ks, "network device %s up\n", dev->name);
mutex_unlock(&ks->lock); mutex_unlock(&ks->lock);
return 0; return 0;
...@@ -845,8 +837,7 @@ static int ks8851_net_stop(struct net_device *dev) ...@@ -845,8 +837,7 @@ static int ks8851_net_stop(struct net_device *dev)
{ {
struct ks8851_net *ks = netdev_priv(dev); struct ks8851_net *ks = netdev_priv(dev);
if (netif_msg_ifdown(ks)) netif_info(ks, ifdown, dev, "shutting down\n");
ks_info(ks, "%s: shutting down\n", dev->name);
netif_stop_queue(dev); netif_stop_queue(dev);
...@@ -874,8 +865,8 @@ static int ks8851_net_stop(struct net_device *dev) ...@@ -874,8 +865,8 @@ static int ks8851_net_stop(struct net_device *dev)
while (!skb_queue_empty(&ks->txq)) { while (!skb_queue_empty(&ks->txq)) {
struct sk_buff *txb = skb_dequeue(&ks->txq); struct sk_buff *txb = skb_dequeue(&ks->txq);
if (netif_msg_ifdown(ks)) netif_dbg(ks, ifdown, ks->netdev,
ks_dbg(ks, "%s: freeing txb %p\n", __func__, txb); "%s: freeing txb %p\n", __func__, txb);
dev_kfree_skb(txb); dev_kfree_skb(txb);
} }
...@@ -904,9 +895,8 @@ static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb, ...@@ -904,9 +895,8 @@ static netdev_tx_t ks8851_start_xmit(struct sk_buff *skb,
unsigned needed = calc_txlen(skb->len); unsigned needed = calc_txlen(skb->len);
netdev_tx_t ret = NETDEV_TX_OK; netdev_tx_t ret = NETDEV_TX_OK;
if (netif_msg_tx_queued(ks)) netif_dbg(ks, tx_queued, ks->netdev,
ks_dbg(ks, "%s: skb %p, %d@%p\n", __func__, "%s: skb %p, %d@%p\n", __func__, skb, skb->len, skb->data);
skb, skb->len, skb->data);
spin_lock(&ks->statelock); spin_lock(&ks->statelock);
...@@ -1186,17 +1176,17 @@ static int ks8851_read_selftest(struct ks8851_net *ks) ...@@ -1186,17 +1176,17 @@ static int ks8851_read_selftest(struct ks8851_net *ks)
rd = ks8851_rdreg16(ks, KS_MBIR); rd = ks8851_rdreg16(ks, KS_MBIR);
if ((rd & both_done) != both_done) { if ((rd & both_done) != both_done) {
ks_warn(ks, "Memory selftest not finished\n"); netdev_warn(ks->netdev, "Memory selftest not finished\n");
return 0; return 0;
} }
if (rd & MBIR_TXMBFA) { if (rd & MBIR_TXMBFA) {
ks_err(ks, "TX memory selftest fail\n"); netdev_err(ks->netdev, "TX memory selftest fail\n");
ret |= 1; ret |= 1;
} }
if (rd & MBIR_RXMBFA) { if (rd & MBIR_RXMBFA) {
ks_err(ks, "RX memory selftest fail\n"); netdev_err(ks->netdev, "RX memory selftest fail\n");
ret |= 2; ret |= 2;
} }
...@@ -1294,7 +1284,7 @@ static int __devinit ks8851_probe(struct spi_device *spi) ...@@ -1294,7 +1284,7 @@ static int __devinit ks8851_probe(struct spi_device *spi)
goto err_netdev; goto err_netdev;
} }
dev_info(&spi->dev, "revision %d, MAC %pM, IRQ %d\n", netdev_info(ndev, "revision %d, MAC %pM, IRQ %d\n",
CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)), CIDER_REV_GET(ks8851_rdreg16(ks, KS_CIDER)),
ndev->dev_addr, ndev->irq); ndev->dev_addr, ndev->irq);
...@@ -1315,7 +1305,7 @@ static int __devexit ks8851_remove(struct spi_device *spi) ...@@ -1315,7 +1305,7 @@ static int __devexit ks8851_remove(struct spi_device *spi)
struct ks8851_net *priv = dev_get_drvdata(&spi->dev); struct ks8851_net *priv = dev_get_drvdata(&spi->dev);
if (netif_msg_drv(priv)) if (netif_msg_drv(priv))
dev_info(&spi->dev, "remove"); dev_info(&spi->dev, "remove\n");
unregister_netdev(priv->netdev); unregister_netdev(priv->netdev);
free_irq(spi->irq, priv); free_irq(spi->irq, priv);
......
...@@ -21,6 +21,8 @@ ...@@ -21,6 +21,8 @@
* KS8851 16bit MLL chip from Micrel Inc. * KS8851 16bit MLL chip from Micrel Inc.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h> #include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/netdevice.h> #include <linux/netdevice.h>
...@@ -458,11 +460,6 @@ struct ks_net { ...@@ -458,11 +460,6 @@ struct ks_net {
static int msg_enable; static int msg_enable;
#define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg)
#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg)
#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg)
#define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg)
#define BE3 0x8000 /* Byte Enable 3 */ #define BE3 0x8000 /* Byte Enable 3 */
#define BE2 0x4000 /* Byte Enable 2 */ #define BE2 0x4000 /* Byte Enable 2 */
#define BE1 0x2000 /* Byte Enable 1 */ #define BE1 0x2000 /* Byte Enable 1 */
...@@ -624,8 +621,7 @@ static void ks_set_powermode(struct ks_net *ks, unsigned pwrmode) ...@@ -624,8 +621,7 @@ static void ks_set_powermode(struct ks_net *ks, unsigned pwrmode)
{ {
unsigned pmecr; unsigned pmecr;
if (netif_msg_hw(ks)) netif_dbg(ks, hw, ks->netdev, "setting power mode %d\n", pwrmode);
ks_dbg(ks, "setting power mode %d\n", pwrmode);
ks_rdreg16(ks, KS_GRR); ks_rdreg16(ks, KS_GRR);
pmecr = ks_rdreg16(ks, KS_PMECR); pmecr = ks_rdreg16(ks, KS_PMECR);
...@@ -809,7 +805,7 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev) ...@@ -809,7 +805,7 @@ static void ks_rcv(struct ks_net *ks, struct net_device *netdev)
skb->protocol = eth_type_trans(skb, netdev); skb->protocol = eth_type_trans(skb, netdev);
netif_rx(skb); netif_rx(skb);
} else { } else {
printk(KERN_ERR "%s: err:skb alloc\n", __func__); pr_err("%s: err:skb alloc\n", __func__);
ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF)); ks_wrreg16(ks, KS_RXQCR, (ks->rc_rxqcr | RXQCR_RRXEF));
if (skb) if (skb)
dev_kfree_skb_irq(skb); dev_kfree_skb_irq(skb);
...@@ -836,9 +832,8 @@ static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks) ...@@ -836,9 +832,8 @@ static void ks_update_link_status(struct net_device *netdev, struct ks_net *ks)
netif_carrier_off(netdev); netif_carrier_off(netdev);
link_up_status = false; link_up_status = false;
} }
if (netif_msg_link(ks)) netif_dbg(ks, link, ks->netdev,
ks_dbg(ks, "%s: %s\n", "%s: %s\n", __func__, link_up_status ? "UP" : "DOWN");
__func__, link_up_status ? "UP" : "DOWN");
} }
/** /**
...@@ -908,15 +903,13 @@ static int ks_net_open(struct net_device *netdev) ...@@ -908,15 +903,13 @@ static int ks_net_open(struct net_device *netdev)
* else at the moment. * else at the moment.
*/ */
if (netif_msg_ifup(ks)) netif_dbg(ks, ifup, ks->netdev, "%s - entry\n", __func__);
ks_dbg(ks, "%s - entry\n", __func__);
/* reset the HW */ /* reset the HW */
err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev); err = request_irq(ks->irq, ks_irq, KS_INT_FLAGS, DRV_NAME, netdev);
if (err) { if (err) {
printk(KERN_ERR "Failed to request IRQ: %d: %d\n", pr_err("Failed to request IRQ: %d: %d\n", ks->irq, err);
ks->irq, err);
return err; return err;
} }
...@@ -929,8 +922,7 @@ static int ks_net_open(struct net_device *netdev) ...@@ -929,8 +922,7 @@ static int ks_net_open(struct net_device *netdev)
ks_enable_qmu(ks); ks_enable_qmu(ks);
netif_start_queue(ks->netdev); netif_start_queue(ks->netdev);
if (netif_msg_ifup(ks)) netif_dbg(ks, ifup, ks->netdev, "network device up\n");
ks_dbg(ks, "network device %s up\n", netdev->name);
return 0; return 0;
} }
...@@ -947,8 +939,7 @@ static int ks_net_stop(struct net_device *netdev) ...@@ -947,8 +939,7 @@ static int ks_net_stop(struct net_device *netdev)
{ {
struct ks_net *ks = netdev_priv(netdev); struct ks_net *ks = netdev_priv(netdev);
if (netif_msg_ifdown(ks)) netif_info(ks, ifdown, netdev, "shutting down\n");
ks_info(ks, "%s: shutting down\n", netdev->name);
netif_stop_queue(netdev); netif_stop_queue(netdev);
...@@ -1429,21 +1420,21 @@ static int ks_read_selftest(struct ks_net *ks) ...@@ -1429,21 +1420,21 @@ static int ks_read_selftest(struct ks_net *ks)
rd = ks_rdreg16(ks, KS_MBIR); rd = ks_rdreg16(ks, KS_MBIR);
if ((rd & both_done) != both_done) { if ((rd & both_done) != both_done) {
ks_warn(ks, "Memory selftest not finished\n"); netdev_warn(ks->netdev, "Memory selftest not finished\n");
return 0; return 0;
} }
if (rd & MBIR_TXMBFA) { if (rd & MBIR_TXMBFA) {
ks_err(ks, "TX memory selftest fails\n"); netdev_err(ks->netdev, "TX memory selftest fails\n");
ret |= 1; ret |= 1;
} }
if (rd & MBIR_RXMBFA) { if (rd & MBIR_RXMBFA) {
ks_err(ks, "RX memory selftest fails\n"); netdev_err(ks->netdev, "RX memory selftest fails\n");
ret |= 2; ret |= 2;
} }
ks_info(ks, "the selftest passes\n"); netdev_info(ks->netdev, "the selftest passes\n");
return ret; return ret;
} }
...@@ -1514,7 +1505,7 @@ static int ks_hw_init(struct ks_net *ks) ...@@ -1514,7 +1505,7 @@ static int ks_hw_init(struct ks_net *ks)
ks->frame_head_info = (struct type_frame_head *) \ ks->frame_head_info = (struct type_frame_head *) \
kmalloc(MHEADER_SIZE, GFP_KERNEL); kmalloc(MHEADER_SIZE, GFP_KERNEL);
if (!ks->frame_head_info) { if (!ks->frame_head_info) {
printk(KERN_ERR "Error: Fail to allocate frame memory\n"); pr_err("Error: Fail to allocate frame memory\n");
return false; return false;
} }
...@@ -1580,7 +1571,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev) ...@@ -1580,7 +1571,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
ks->mii.mdio_read = ks_phy_read; ks->mii.mdio_read = ks_phy_read;
ks->mii.mdio_write = ks_phy_write; ks->mii.mdio_write = ks_phy_write;
ks_info(ks, "message enable is %d\n", msg_enable); netdev_info(netdev, "message enable is %d\n", msg_enable);
/* set the default message enable */ /* set the default message enable */
ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV | ks->msg_enable = netif_msg_init(msg_enable, (NETIF_MSG_DRV |
NETIF_MSG_PROBE | NETIF_MSG_PROBE |
...@@ -1589,13 +1580,13 @@ static int __devinit ks8851_probe(struct platform_device *pdev) ...@@ -1589,13 +1580,13 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
/* simple check for a valid chip being connected to the bus */ /* simple check for a valid chip being connected to the bus */
if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) { if ((ks_rdreg16(ks, KS_CIDER) & ~CIDER_REV_MASK) != CIDER_ID) {
ks_err(ks, "failed to read device ID\n"); netdev_err(netdev, "failed to read device ID\n");
err = -ENODEV; err = -ENODEV;
goto err_register; goto err_register;
} }
if (ks_read_selftest(ks)) { if (ks_read_selftest(ks)) {
ks_err(ks, "failed to read device ID\n"); netdev_err(netdev, "failed to read device ID\n");
err = -ENODEV; err = -ENODEV;
goto err_register; goto err_register;
} }
...@@ -1626,8 +1617,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev) ...@@ -1626,8 +1617,7 @@ static int __devinit ks8851_probe(struct platform_device *pdev)
id = ks_rdreg16(ks, KS_CIDER); id = ks_rdreg16(ks, KS_CIDER);
printk(KERN_INFO DRV_NAME netdev_info(netdev, "Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
" Found chip, family: 0x%x, id: 0x%x, rev: 0x%x\n",
(id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7); (id >> 8) & 0xff, (id >> 4) & 0xf, (id >> 1) & 0x7);
return 0; return 0;
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
...@@ -1483,11 +1485,6 @@ struct dev_priv { ...@@ -1483,11 +1485,6 @@ struct dev_priv {
int promiscuous; int promiscuous;
}; };
#define ks_info(_ks, _msg...) dev_info(&(_ks)->pdev->dev, _msg)
#define ks_warn(_ks, _msg...) dev_warn(&(_ks)->pdev->dev, _msg)
#define ks_dbg(_ks, _msg...) dev_dbg(&(_ks)->pdev->dev, _msg)
#define ks_err(_ks, _msg...) dev_err(&(_ks)->pdev->dev, _msg)
#define DRV_NAME "KSZ884X PCI" #define DRV_NAME "KSZ884X PCI"
#define DEVICE_NAME "KSZ884x PCI" #define DEVICE_NAME "KSZ884x PCI"
#define DRV_VERSION "1.0.0" #define DRV_VERSION "1.0.0"
...@@ -3834,7 +3831,7 @@ static void ksz_check_desc_num(struct ksz_desc_info *info) ...@@ -3834,7 +3831,7 @@ static void ksz_check_desc_num(struct ksz_desc_info *info)
alloc >>= 1; alloc >>= 1;
} }
if (alloc != 1 || shift < MIN_DESC_SHIFT) { if (alloc != 1 || shift < MIN_DESC_SHIFT) {
printk(KERN_ALERT "Hardware descriptor numbers not right!\n"); pr_alert("Hardware descriptor numbers not right!\n");
while (alloc) { while (alloc) {
shift++; shift++;
alloc >>= 1; alloc >>= 1;
...@@ -4545,8 +4542,7 @@ static int ksz_alloc_mem(struct dev_info *adapter) ...@@ -4545,8 +4542,7 @@ static int ksz_alloc_mem(struct dev_info *adapter)
(((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) / (((sizeof(struct ksz_hw_desc) + DESC_ALIGNMENT - 1) /
DESC_ALIGNMENT) * DESC_ALIGNMENT); DESC_ALIGNMENT) * DESC_ALIGNMENT);
if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc)) if (hw->rx_desc_info.size != sizeof(struct ksz_hw_desc))
printk(KERN_ALERT pr_alert("Hardware descriptor size not right!\n");
"Hardware descriptor size not right!\n");
ksz_check_desc_num(&hw->rx_desc_info); ksz_check_desc_num(&hw->rx_desc_info);
ksz_check_desc_num(&hw->tx_desc_info); ksz_check_desc_num(&hw->tx_desc_info);
...@@ -5319,10 +5315,10 @@ static irqreturn_t netdev_intr(int irq, void *dev_id) ...@@ -5319,10 +5315,10 @@ static irqreturn_t netdev_intr(int irq, void *dev_id)
u32 data; u32 data;
hw->intr_mask &= ~KS884X_INT_TX_STOPPED; hw->intr_mask &= ~KS884X_INT_TX_STOPPED;
printk(KERN_INFO "Tx stopped\n"); pr_info("Tx stopped\n");
data = readl(hw->io + KS_DMA_TX_CTRL); data = readl(hw->io + KS_DMA_TX_CTRL);
if (!(data & DMA_TX_ENABLE)) if (!(data & DMA_TX_ENABLE))
printk(KERN_INFO "Tx disabled\n"); pr_info("Tx disabled\n");
break; break;
} }
} while (0); } while (0);
...@@ -5495,6 +5491,18 @@ static int prepare_hardware(struct net_device *dev) ...@@ -5495,6 +5491,18 @@ static int prepare_hardware(struct net_device *dev)
return 0; return 0;
} }
static void set_media_state(struct net_device *dev, int media_state)
{
struct dev_priv *priv = netdev_priv(dev);
if (media_state == priv->media_state)
netif_carrier_on(dev);
else
netif_carrier_off(dev);
netif_info(priv, link, dev, "link %s\n",
media_state == priv->media_state ? "on" : "off");
}
/** /**
* netdev_open - open network device * netdev_open - open network device
* @dev: Network device. * @dev: Network device.
...@@ -5584,15 +5592,7 @@ static int netdev_open(struct net_device *dev) ...@@ -5584,15 +5592,7 @@ static int netdev_open(struct net_device *dev)
priv->media_state = port->linked->state; priv->media_state = port->linked->state;
if (media_connected == priv->media_state) set_media_state(dev, media_connected);
netif_carrier_on(dev);
else
netif_carrier_off(dev);
if (netif_msg_link(priv))
printk(KERN_INFO "%s link %s\n", dev->name,
(media_connected == priv->media_state ?
"on" : "off"));
netif_start_queue(dev); netif_start_queue(dev);
return 0; return 0;
...@@ -6682,16 +6682,8 @@ static void update_link(struct net_device *dev, struct dev_priv *priv, ...@@ -6682,16 +6682,8 @@ static void update_link(struct net_device *dev, struct dev_priv *priv,
{ {
if (priv->media_state != port->linked->state) { if (priv->media_state != port->linked->state) {
priv->media_state = port->linked->state; priv->media_state = port->linked->state;
if (netif_running(dev)) { if (netif_running(dev))
if (media_connected == priv->media_state) set_media_state(dev, media_connected);
netif_carrier_on(dev);
else
netif_carrier_off(dev);
if (netif_msg_link(priv))
printk(KERN_INFO "%s link %s\n", dev->name,
(media_connected == priv->media_state ?
"on" : "off"));
}
} }
} }
...@@ -6985,7 +6977,7 @@ static int __init pcidev_init(struct pci_dev *pdev, ...@@ -6985,7 +6977,7 @@ static int __init pcidev_init(struct pci_dev *pdev,
int pi; int pi;
int port_count; int port_count;
int result; int result;
char banner[80]; char banner[sizeof(version)];
struct ksz_switch *sw = NULL; struct ksz_switch *sw = NULL;
result = pci_enable_device(pdev); result = pci_enable_device(pdev);
...@@ -7009,10 +7001,9 @@ static int __init pcidev_init(struct pci_dev *pdev, ...@@ -7009,10 +7001,9 @@ static int __init pcidev_init(struct pci_dev *pdev,
result = -ENOMEM; result = -ENOMEM;
info = kmalloc(sizeof(struct platform_info), GFP_KERNEL); info = kzalloc(sizeof(struct platform_info), GFP_KERNEL);
if (!info) if (!info)
goto pcidev_init_dev_err; goto pcidev_init_dev_err;
memset(info, 0, sizeof(struct platform_info));
hw_priv = &info->dev_info; hw_priv = &info->dev_info;
hw_priv->pdev = pdev; hw_priv->pdev = pdev;
...@@ -7026,15 +7017,15 @@ static int __init pcidev_init(struct pci_dev *pdev, ...@@ -7026,15 +7017,15 @@ static int __init pcidev_init(struct pci_dev *pdev,
cnt = hw_init(hw); cnt = hw_init(hw);
if (!cnt) { if (!cnt) {
if (msg_enable & NETIF_MSG_PROBE) if (msg_enable & NETIF_MSG_PROBE)
printk(KERN_ALERT "chip not detected\n"); pr_alert("chip not detected\n");
result = -ENODEV; result = -ENODEV;
goto pcidev_init_alloc_err; goto pcidev_init_alloc_err;
} }
sprintf(banner, "%s\n", version); snprintf(banner, sizeof(banner), "%s", version);
banner[13] = cnt + '0'; banner[13] = cnt + '0'; /* Replace x in "Micrel KSZ884x" */
ks_info(hw_priv, "%s", banner); dev_info(&hw_priv->pdev->dev, "%s\n", banner);
ks_dbg(hw_priv, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq); dev_dbg(&hw_priv->pdev->dev, "Mem = %p; IRQ = %d\n", hw->io, pdev->irq);
/* Assume device is KSZ8841. */ /* Assume device is KSZ8841. */
hw->dev_count = 1; hw->dev_count = 1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment