enc28j60: Convert HW related printk() to dev_printk()

The debug prints of hardware status and operations will look better
if SPI device name is printed. The benefit of that is a possibility
to distinguish the actual hardware when more than one is installed
on the system.

Convert appropriate printk(KERN_DEBUG) to dev_print(KERN_DEBUG, &spi->dev).

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Andy Shevchenko 2019-03-19 20:49:25 +02:00 committed by David S. Miller
parent e303b6afef
commit 6eae14104f

View File

@ -88,6 +88,7 @@ static struct {
static int
spi_read_buf(struct enc28j60_net *priv, int len, u8 *data)
{
struct device *dev = &priv->spi->dev;
u8 *rx_buf = priv->spi_transfer_buf + 4;
u8 *tx_buf = priv->spi_transfer_buf;
struct spi_transfer tx = {
@ -113,7 +114,7 @@ spi_read_buf(struct enc28j60_net *priv, int len, u8 *data)
ret = msg.status;
}
if (ret && netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n",
__func__, ret);
return ret;
@ -125,6 +126,7 @@ spi_read_buf(struct enc28j60_net *priv, int len, u8 *data)
static int spi_write_buf(struct enc28j60_net *priv, int len,
const u8 *data)
{
struct device *dev = &priv->spi->dev;
int ret;
if (len > SPI_TRANSFER_BUF_LEN - 1 || len <= 0)
@ -134,7 +136,7 @@ static int spi_write_buf(struct enc28j60_net *priv, int len,
memcpy(&priv->spi_transfer_buf[1], data, len);
ret = spi_write(priv->spi, priv->spi_transfer_buf, len + 1);
if (ret && netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n",
__func__, ret);
}
return ret;
@ -146,6 +148,7 @@ static int spi_write_buf(struct enc28j60_net *priv, int len,
static u8 spi_read_op(struct enc28j60_net *priv, u8 op,
u8 addr)
{
struct device *dev = &priv->spi->dev;
u8 tx_buf[2];
u8 rx_buf[4];
u8 val = 0;
@ -159,7 +162,7 @@ static u8 spi_read_op(struct enc28j60_net *priv, u8 op,
tx_buf[0] = op | (addr & ADDR_MASK);
ret = spi_write_then_read(priv->spi, tx_buf, 1, rx_buf, slen);
if (ret)
printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n",
__func__, ret);
else
val = rx_buf[slen - 1];
@ -173,13 +176,14 @@ static u8 spi_read_op(struct enc28j60_net *priv, u8 op,
static int spi_write_op(struct enc28j60_net *priv, u8 op,
u8 addr, u8 val)
{
struct device *dev = &priv->spi->dev;
int ret;
priv->spi_transfer_buf[0] = op | (addr & ADDR_MASK);
priv->spi_transfer_buf[1] = val;
ret = spi_write(priv->spi, priv->spi_transfer_buf, 2);
if (ret && netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() failed: ret = %d\n",
dev_printk(KERN_DEBUG, dev, "%s() failed: ret = %d\n",
__func__, ret);
return ret;
}
@ -370,11 +374,14 @@ static void enc28j60_mem_read(struct enc28j60_net *priv,
nolock_regw_write(priv, ERDPTL, addr);
#ifdef CONFIG_ENC28J60_WRITEVERIFY
if (netif_msg_drv(priv)) {
struct device *dev = &priv->spi->dev;
u16 reg;
reg = nolock_regw_read(priv, ERDPTL);
if (reg != addr)
printk(KERN_DEBUG DRV_NAME ": %s() error writing ERDPT "
"(0x%04x - 0x%04x)\n", __func__, reg, addr);
dev_printk(KERN_DEBUG, dev,
"%s() error writing ERDPT (0x%04x - 0x%04x)\n",
__func__, reg, addr);
}
#endif
spi_read_buf(priv, len, data);
@ -387,6 +394,8 @@ static void enc28j60_mem_read(struct enc28j60_net *priv,
static void
enc28j60_packet_write(struct enc28j60_net *priv, int len, const u8 *data)
{
struct device *dev = &priv->spi->dev;
mutex_lock(&priv->lock);
/* Set the write pointer to start of transmit buffer area */
nolock_regw_write(priv, EWRPTL, TXSTART_INIT);
@ -395,8 +404,8 @@ enc28j60_packet_write(struct enc28j60_net *priv, int len, const u8 *data)
u16 reg;
reg = nolock_regw_read(priv, EWRPTL);
if (reg != TXSTART_INIT)
printk(KERN_DEBUG DRV_NAME
": %s() ERWPT:0x%04x != 0x%04x\n",
dev_printk(KERN_DEBUG, dev,
"%s() ERWPT:0x%04x != 0x%04x\n",
__func__, reg, TXSTART_INIT);
}
#endif
@ -405,14 +414,14 @@ enc28j60_packet_write(struct enc28j60_net *priv, int len, const u8 *data)
/* write per-packet control byte */
spi_write_op(priv, ENC28J60_WRITE_BUF_MEM, 0, 0x00);
if (netif_msg_hw(priv))
printk(KERN_DEBUG DRV_NAME
": %s() after control byte ERWPT:0x%04x\n",
dev_printk(KERN_DEBUG, dev,
"%s() after control byte ERWPT:0x%04x\n",
__func__, nolock_regw_read(priv, EWRPTL));
/* copy the packet into the transmit buffer */
spi_write_buf(priv, len, data);
if (netif_msg_hw(priv))
printk(KERN_DEBUG DRV_NAME
": %s() after write packet ERWPT:0x%04x, len=%d\n",
dev_printk(KERN_DEBUG, dev,
"%s() after write packet ERWPT:0x%04x, len=%d\n",
__func__, nolock_regw_read(priv, EWRPTL), len);
mutex_unlock(&priv->lock);
}
@ -506,9 +515,9 @@ static int enc28j60_set_hw_macaddr(struct net_device *ndev)
ret = 0;
} else {
if (netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME
": %s() Hardware must be disabled to set "
"Mac address\n", __func__);
dev_printk(KERN_DEBUG, dev,
"%s() Hardware must be disabled to set Mac address\n",
__func__);
ret = -EBUSY;
}
mutex_unlock(&priv->lock);
@ -536,8 +545,11 @@ static int enc28j60_set_mac_address(struct net_device *dev, void *addr)
*/
static void enc28j60_dump_regs(struct enc28j60_net *priv, const char *msg)
{
struct device *dev = &priv->spi->dev;
mutex_lock(&priv->lock);
printk(KERN_DEBUG DRV_NAME " %s\n"
dev_printk(KERN_DEBUG, dev,
" %s\n"
"HwRevID: 0x%02x\n"
"Cntrl: ECON1 ECON2 ESTAT EIR EIE\n"
" 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n"
@ -659,7 +671,7 @@ static int enc28j60_hw_init(struct enc28j60_net *priv)
u8 reg;
if (netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() - %s\n", __func__,
dev_printk(KERN_DEBUG, dev, "%s() - %s\n", __func__,
priv->full_duplex ? "FullDuplex" : "HalfDuplex");
mutex_lock(&priv->lock);
@ -689,7 +701,7 @@ static int enc28j60_hw_init(struct enc28j60_net *priv)
dev_info(dev, "chip RevID: 0x%02x\n", reg);
if (reg == 0x00 || reg == 0xff) {
if (netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": %s() Invalid RevId %d\n",
dev_printk(KERN_DEBUG, dev, "%s() Invalid RevId %d\n",
__func__, reg);
return 0;
}
@ -750,9 +762,11 @@ static int enc28j60_hw_init(struct enc28j60_net *priv)
static void enc28j60_hw_enable(struct enc28j60_net *priv)
{
struct device *dev = &priv->spi->dev;
/* enable interrupts */
if (netif_msg_hw(priv))
printk(KERN_DEBUG DRV_NAME ": %s() enabling interrupts.\n",
dev_printk(KERN_DEBUG, dev, "%s() enabling interrupts.\n",
__func__);
enc28j60_phy_write(priv, PHIE, PHIE_PGEIE | PHIE_PLNKIE);
@ -809,11 +823,12 @@ enc28j60_setlink(struct net_device *ndev, u8 autoneg, u16 speed, u8 duplex)
*/
static void enc28j60_read_tsv(struct enc28j60_net *priv, u8 tsv[TSV_SIZE])
{
struct device *dev = &priv->spi->dev;
int endptr;
endptr = locked_regw_read(priv, ETXNDL);
if (netif_msg_hw(priv))
printk(KERN_DEBUG DRV_NAME ": reading TSV at addr:0x%04x\n",
dev_printk(KERN_DEBUG, dev, "reading TSV at addr:0x%04x\n",
endptr + 1);
enc28j60_mem_read(priv, endptr + 1, TSV_SIZE, tsv);
}
@ -821,9 +836,10 @@ static void enc28j60_read_tsv(struct enc28j60_net *priv, u8 tsv[TSV_SIZE])
static void enc28j60_dump_tsv(struct enc28j60_net *priv, const char *msg,
u8 tsv[TSV_SIZE])
{
struct device *dev = &priv->spi->dev;
u16 tmp1, tmp2;
printk(KERN_DEBUG DRV_NAME ": %s - TSV:\n", msg);
dev_printk(KERN_DEBUG, dev, "%s - TSV:\n", msg);
tmp1 = tsv[1];
tmp1 <<= 8;
tmp1 |= tsv[0];
@ -832,26 +848,28 @@ static void enc28j60_dump_tsv(struct enc28j60_net *priv, const char *msg,
tmp2 <<= 8;
tmp2 |= tsv[4];
printk(KERN_DEBUG DRV_NAME ": ByteCount: %d, CollisionCount: %d,"
" TotByteOnWire: %d\n", tmp1, tsv[2] & 0x0f, tmp2);
printk(KERN_DEBUG DRV_NAME ": TxDone: %d, CRCErr:%d, LenChkErr: %d,"
" LenOutOfRange: %d\n", TSV_GETBIT(tsv, TSV_TXDONE),
dev_printk(KERN_DEBUG, dev,
"ByteCount: %d, CollisionCount: %d, TotByteOnWire: %d\n",
tmp1, tsv[2] & 0x0f, tmp2);
dev_printk(KERN_DEBUG, dev,
"TxDone: %d, CRCErr:%d, LenChkErr: %d, LenOutOfRange: %d\n",
TSV_GETBIT(tsv, TSV_TXDONE),
TSV_GETBIT(tsv, TSV_TXCRCERROR),
TSV_GETBIT(tsv, TSV_TXLENCHKERROR),
TSV_GETBIT(tsv, TSV_TXLENOUTOFRANGE));
printk(KERN_DEBUG DRV_NAME ": Multicast: %d, Broadcast: %d, "
"PacketDefer: %d, ExDefer: %d\n",
dev_printk(KERN_DEBUG, dev,
"Multicast: %d, Broadcast: %d, PacketDefer: %d, ExDefer: %d\n",
TSV_GETBIT(tsv, TSV_TXMULTICAST),
TSV_GETBIT(tsv, TSV_TXBROADCAST),
TSV_GETBIT(tsv, TSV_TXPACKETDEFER),
TSV_GETBIT(tsv, TSV_TXEXDEFER));
printk(KERN_DEBUG DRV_NAME ": ExCollision: %d, LateCollision: %d, "
"Giant: %d, Underrun: %d\n",
dev_printk(KERN_DEBUG, dev,
"ExCollision: %d, LateCollision: %d, Giant: %d, Underrun: %d\n",
TSV_GETBIT(tsv, TSV_TXEXCOLLISION),
TSV_GETBIT(tsv, TSV_TXLATECOLLISION),
TSV_GETBIT(tsv, TSV_TXGIANT), TSV_GETBIT(tsv, TSV_TXUNDERRUN));
printk(KERN_DEBUG DRV_NAME ": ControlFrame: %d, PauseFrame: %d, "
"BackPressApp: %d, VLanTagFrame: %d\n",
dev_printk(KERN_DEBUG, dev,
"ControlFrame: %d, PauseFrame: %d, BackPressApp: %d, VLanTagFrame: %d\n",
TSV_GETBIT(tsv, TSV_TXCONTROLFRAME),
TSV_GETBIT(tsv, TSV_TXPAUSEFRAME),
TSV_GETBIT(tsv, TSV_BACKPRESSUREAPP),
@ -864,23 +882,25 @@ static void enc28j60_dump_tsv(struct enc28j60_net *priv, const char *msg,
static void enc28j60_dump_rsv(struct enc28j60_net *priv, const char *msg,
u16 pk_ptr, int len, u16 sts)
{
printk(KERN_DEBUG DRV_NAME ": %s - NextPk: 0x%04x - RSV:\n",
msg, pk_ptr);
printk(KERN_DEBUG DRV_NAME ": ByteCount: %d, DribbleNibble: %d\n", len,
RSV_GETBIT(sts, RSV_DRIBBLENIBBLE));
printk(KERN_DEBUG DRV_NAME ": RxOK: %d, CRCErr:%d, LenChkErr: %d,"
" LenOutOfRange: %d\n", RSV_GETBIT(sts, RSV_RXOK),
struct device *dev = &priv->spi->dev;
dev_printk(KERN_DEBUG, dev, "%s - NextPk: 0x%04x - RSV:\n", msg, pk_ptr);
dev_printk(KERN_DEBUG, dev, "ByteCount: %d, DribbleNibble: %d\n",
len, RSV_GETBIT(sts, RSV_DRIBBLENIBBLE));
dev_printk(KERN_DEBUG, dev,
"RxOK: %d, CRCErr:%d, LenChkErr: %d, LenOutOfRange: %d\n",
RSV_GETBIT(sts, RSV_RXOK),
RSV_GETBIT(sts, RSV_CRCERROR),
RSV_GETBIT(sts, RSV_LENCHECKERR),
RSV_GETBIT(sts, RSV_LENOUTOFRANGE));
printk(KERN_DEBUG DRV_NAME ": Multicast: %d, Broadcast: %d, "
"LongDropEvent: %d, CarrierEvent: %d\n",
dev_printk(KERN_DEBUG, dev,
"Multicast: %d, Broadcast: %d, LongDropEvent: %d, CarrierEvent: %d\n",
RSV_GETBIT(sts, RSV_RXMULTICAST),
RSV_GETBIT(sts, RSV_RXBROADCAST),
RSV_GETBIT(sts, RSV_RXLONGEVDROPEV),
RSV_GETBIT(sts, RSV_CARRIEREV));
printk(KERN_DEBUG DRV_NAME ": ControlFrame: %d, PauseFrame: %d,"
" UnknownOp: %d, VLanTagFrame: %d\n",
dev_printk(KERN_DEBUG, dev,
"ControlFrame: %d, PauseFrame: %d, UnknownOp: %d, VLanTagFrame: %d\n",
RSV_GETBIT(sts, RSV_RXCONTROLFRAME),
RSV_GETBIT(sts, RSV_RXPAUSEFRAME),
RSV_GETBIT(sts, RSV_RXUNKNOWNOPCODE),
@ -902,6 +922,7 @@ static void dump_packet(const char *msg, int len, const char *data)
static void enc28j60_hw_rx(struct net_device *ndev)
{
struct enc28j60_net *priv = netdev_priv(ndev);
struct device *dev = &priv->spi->dev;
struct sk_buff *skb = NULL;
u16 erxrdpt, next_packet, rxstat;
u8 rsv[RSV_SIZE];
@ -983,7 +1004,7 @@ static void enc28j60_hw_rx(struct net_device *ndev)
*/
erxrdpt = erxrdpt_workaround(next_packet, RXSTART_INIT, RXEND_INIT);
if (netif_msg_hw(priv))
printk(KERN_DEBUG DRV_NAME ": %s() ERXRDPT:0x%04x\n",
dev_printk(KERN_DEBUG, dev, "%s() ERXRDPT:0x%04x\n",
__func__, erxrdpt);
mutex_lock(&priv->lock);
@ -993,9 +1014,9 @@ static void enc28j60_hw_rx(struct net_device *ndev)
u16 reg;
reg = nolock_regw_read(priv, ERXRDPTL);
if (reg != erxrdpt)
printk(KERN_DEBUG DRV_NAME ": %s() ERXRDPT verify "
"error (0x%04x - 0x%04x)\n", __func__,
reg, erxrdpt);
dev_printk(KERN_DEBUG, dev,
"%s() ERXRDPT verify error (0x%04x - 0x%04x)\n",
__func__, reg, erxrdpt);
}
#endif
priv->next_pk_ptr = next_packet;
@ -1042,13 +1063,14 @@ static int enc28j60_get_free_rxfifo(struct enc28j60_net *priv)
static void enc28j60_check_link_status(struct net_device *ndev)
{
struct enc28j60_net *priv = netdev_priv(ndev);
struct device *dev = &priv->spi->dev;
u16 reg;
int duplex;
reg = enc28j60_phy_read(priv, PHSTAT2);
if (netif_msg_hw(priv))
printk(KERN_DEBUG DRV_NAME ": %s() PHSTAT1: %04x, "
"PHSTAT2: %04x\n", __func__,
dev_printk(KERN_DEBUG, dev,
"%s() PHSTAT1: %04x, PHSTAT2: %04x\n", __func__,
enc28j60_phy_read(priv, PHSTAT1), reg);
duplex = reg & PHSTAT2_DPXSTAT;
@ -1244,6 +1266,7 @@ static void enc28j60_hw_tx(struct enc28j60_net *priv)
#ifdef CONFIG_ENC28J60_WRITEVERIFY
/* readback and verify written data */
if (netif_msg_drv(priv)) {
struct device *dev = &priv->spi->dev;
int test_len, k;
u8 test_buf[64]; /* limit the test to the first 64 bytes */
int okflag;
@ -1257,16 +1280,14 @@ static void enc28j60_hw_tx(struct enc28j60_net *priv)
okflag = 1;
for (k = 0; k < test_len; k++) {
if (priv->tx_skb->data[k] != test_buf[k]) {
printk(KERN_DEBUG DRV_NAME
": Error, %d location differ: "
"0x%02x-0x%02x\n", k,
priv->tx_skb->data[k], test_buf[k]);
dev_printk(KERN_DEBUG, dev,
"Error, %d location differ: 0x%02x-0x%02x\n",
k, priv->tx_skb->data[k], test_buf[k]);
okflag = 0;
}
}
if (!okflag)
printk(KERN_DEBUG DRV_NAME ": Tx write buffer, "
"verify ERROR!\n");
dev_printk(KERN_DEBUG, dev, "Tx write buffer, verify ERROR!\n");
}
#endif
/* set TX request flag */
@ -1417,20 +1438,21 @@ static void enc28j60_setrx_work_handler(struct work_struct *work)
{
struct enc28j60_net *priv =
container_of(work, struct enc28j60_net, setrx_work);
struct device *dev = &priv->spi->dev;
if (priv->rxfilter == RXFILTER_PROMISC) {
if (netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": promiscuous mode\n");
dev_printk(KERN_DEBUG, dev, "promiscuous mode\n");
locked_regb_write(priv, ERXFCON, 0x00);
} else if (priv->rxfilter == RXFILTER_MULTI) {
if (netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": multicast mode\n");
dev_printk(KERN_DEBUG, dev, "multicast mode\n");
locked_regb_write(priv, ERXFCON,
ERXFCON_UCEN | ERXFCON_CRCEN |
ERXFCON_BCEN | ERXFCON_MCEN);
} else {
if (netif_msg_drv(priv))
printk(KERN_DEBUG DRV_NAME ": normal mode\n");
dev_printk(KERN_DEBUG, dev, "normal mode\n");
locked_regb_write(priv, ERXFCON,
ERXFCON_UCEN | ERXFCON_CRCEN |
ERXFCON_BCEN);