enc28j60: Use device_get_mac_address()
Subsystems (2)
PATCH v2 1/13 enc28j60: Use device_get_mac_address()
Replace the DT-specific of_get_mac_address() function with device_get_mac_address, which works on both DT and ACPI platforms. This change makes it easier to add ACPI support.
--- drivers/net/ethernet/microchip/enc28j60.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +3 -4
@@ -18,6 +18,7 @@#include <linux/types.h> #include <linux/fcntl.h> #include <linux/interrupt.h> +#include <linux/property.h> #include <linux/string.h> #include <linux/errno.h> #include <linux/init.h>
@@ -28,7 +29,6 @@#include <linux/skbuff.h> #include <linux/delay.h> #include <linux/spi/spi.h> -#include <linux/of_net.h> #include "enc28j60_hw.h"
@@ -1552,9 +1552,9 @@ static const struct net_device_ops enc28j60_netdev_ops = {static int enc28j60_probe (struct spi_device *spi) { +unsigned char macaddr[ETH_ALEN ];struct net_device *dev;struct enc28j60_net *priv; -const void *macaddr;int ret =0 ;if (netif_msg_drv (&debug))
@@ -1587,8 +1587,7 @@ static int enc28j60_probe(struct spi_device *spi) goto error_irq; } - macaddr =of_get_mac_address (spi->dev.of_node); -if (macaddr) +if (device_get_mac_address (&spi->dev, macaddr,sizeof (macaddr)))ether_addr_copy (dev->dev_addr, macaddr);else eth_hw_addr_random (dev);
Signature · 1 line
2.20.1
PATCH v2 2/13 enc28j60: Remove duplicate messaging
The ->probe() and ->remove() stages can be easily debugged with initcall_debug or function tracer. There is no need to repeat the same explicitly in the driver.
--- drivers/net/ethernet/microchip/enc28j60.c | 20 -------------------- 1 file changed, 20 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +0 -20
@@ -186,9 +186,6 @@ static int spi_write_op(struct enc28j60_net *priv, u8 op,static void enc28j60_soft_reset (struct enc28j60_net *priv) { -if (netif_msg_hw (priv)) - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); -spi_write_op (priv,ENC28J60_SOFT_RESET ,0 ,ENC28J60_SOFT_RESET );/* Errata workaround #1, CLKRDY check is unreliable, * delay at least 1 mS instead */
@@ -1124,8 +1121,6 @@ static void enc28j60_irq_work_handler(struct work_struct *work)struct net_device *ndev = priv->netdev;int intflags, loop; -if (netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__);/* disable further interrupts */ locked_reg_bfclr (priv,EIE ,EIE_INTIE );
@@ -1228,8 +1223,6 @@ static void enc28j60_irq_work_handler(struct work_struct *work)/* re-enable interrupts */ locked_reg_bfset (priv,EIE ,EIE_INTIE ); -if (netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME ": %s() exit\n", __func__); }/*
@@ -1287,9 +1280,6 @@ static netdev_tx_t enc28j60_send_packet(struct sk_buff *skb, {struct enc28j60_net *priv =netdev_priv (dev); -if (netif_msg_tx_queued (priv)) - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); -/* If some error occurs while trying to transmit this * packet, you should return '1' from this function. * In such a case you _may not_ do anything to the
@@ -1356,9 +1346,6 @@ static int enc28j60_net_open(struct net_device *dev) {struct enc28j60_net *priv =netdev_priv (dev); -if (netif_msg_drv (priv)) - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); -if (!is_valid_ether_addr (dev->dev_addr)) {if (netif_msg_ifup (priv)) dev_err(&dev->dev, "invalid MAC address %pM\n",
@@ -1392,9 +1379,6 @@ static int enc28j60_net_close(struct net_device *dev) {struct enc28j60_net *priv =netdev_priv (dev); -if (netif_msg_drv (priv)) - printk(KERN_DEBUG DRV_NAME ": %s() enter\n", __func__); -enc28j60_hw_disable (priv);enc28j60_lowpower (priv, true);netif_stop_queue (dev);
@@ -1619,7 +1603,6 @@ static int enc28j60_probe(struct spi_device *spi) " failed (ret = %d)\n", ret); goto error_register; } -dev_info (&dev->dev,DRV_NAME " driver registered\n" );return 0 ;
@@ -1635,9 +1618,6 @@ static int enc28j60_remove(struct spi_device *spi) {struct enc28j60_net *priv =spi_get_drvdata (spi); -if (netif_msg_drv (priv)) - printk(KERN_DEBUG DRV_NAME ": remove\n"); -unregister_netdev (priv->netdev);free_irq (spi->irq, priv);free_netdev (priv->netdev);
Signature · 1 line
2.20.1
PATCH v2 3/13 enc28j60: Replace dev_*(&netdev->dev, ...) with netdev_*()
In reply to Andy ShevchenkoReplace open coded netdev_<level>() macros.
--- drivers/net/ethernet/microchip/enc28j60.c | 42 ++++++++++------------- 1 file changed, 18 insertions(+), 24 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +18 -24
@@ -790,14 +790,12 @@ enc28j60_setlink(struct net_device *ndev, u8 autoneg, u16 speed, u8 duplex) priv->full_duplex = (duplex ==DUPLEX_FULL ); else {if (netif_msg_link (priv)) -dev_warn (&ndev->dev, -"unsupported link setting\n" ); +netdev_warn (ndev,"unsupported link setting\n" ); ret = -EOPNOTSUPP ; } }else {if (netif_msg_link (priv)) -dev_warn (&ndev->dev,"Warning: hw must be disabled " -"to set link mode\n" ); +netdev_warn (ndev,"Warning: hw must be disabled to set link mode\n" ); ret = -EBUSY ; }return ret;
@@ -912,9 +910,8 @@ static void enc28j60_hw_rx(struct net_device *ndev)if (unlikely (priv->next_pk_ptr >RXEND_INIT )) {if (netif_msg_rx_err (priv)) -dev_err (&ndev->dev, -"%s() Invalid packet address!! 0x%04x\n" , - __func__, priv->next_pk_ptr); +netdev_err (ndev,"%s() Invalid packet address!! 0x%04x\n" , + __func__, priv->next_pk_ptr);/* packet address corrupted: reset RX logic */ mutex_lock (&priv->lock);nolock_reg_bfclr (priv,ECON1 ,ECON1_RXEN );
@@ -947,7 +944,7 @@ static void enc28j60_hw_rx(struct net_device *ndev)if (!RSV_GETBIT (rxstat,RSV_RXOK ) || len >MAX_FRAMELEN ) {if (netif_msg_rx_err (priv)) -dev_err (&ndev->dev,"Rx Error (%04x)\n" , rxstat); +netdev_err (ndev,"Rx Error (%04x)\n" , rxstat); ndev->stats.rx_errors++;if (RSV_GETBIT (rxstat,RSV_CRCERROR )) ndev->stats.rx_crc_errors++;
@@ -959,8 +956,7 @@ static void enc28j60_hw_rx(struct net_device *ndev) skb =netdev_alloc_skb (ndev, len +NET_IP_ALIGN );if (!skb) {if (netif_msg_rx_err (priv)) -dev_err (&ndev->dev, -"out of memory for Rx'd frame\n" ); +netdev_err (ndev,"out of memory for Rx'd frame\n" ); ndev->stats.rx_dropped++; }else {skb_reserve (skb,NET_IP_ALIGN );
@@ -1056,11 +1052,11 @@ static void enc28j60_check_link_status(struct net_device *ndev)if (reg &PHSTAT2_LSTAT ) {netif_carrier_on (ndev);if (netif_msg_ifup (priv)) -dev_info (&ndev->dev,"link up - %s\n" , - duplex ?"Full duplex" :"Half duplex" ); +netdev_info (ndev,"link up - %s\n" , + duplex ?"Full duplex" :"Half duplex" ); }else {if (netif_msg_ifdown (priv)) -dev_info (&ndev->dev,"link down\n" ); +netdev_info (ndev,"link down\n" );netif_carrier_off (ndev); } }
@@ -1156,8 +1152,7 @@ static void enc28j60_irq_work_handler(struct work_struct *work) priv->tx_retry_count =0 ;if (locked_regb_read (priv,ESTAT ) &ESTAT_TXABRT ) {if (netif_msg_tx_err (priv)) -dev_err (&ndev->dev, -"Tx Error (aborted)\n" ); +netdev_err (ndev,"Tx Error (aborted)\n" ); err = true; }if (netif_msg_tx_done (priv)) {
@@ -1327,7 +1322,7 @@ static void enc28j60_tx_timeout(struct net_device *ndev)struct enc28j60_net *priv =netdev_priv (ndev);if (netif_msg_timer (priv)) -dev_err (&ndev->dev,DRV_NAME " tx timeout\n" ); +netdev_err (ndev,"tx timeout\n" ); ndev->stats.tx_errors++;/* can't restart safely under softirq */
@@ -1348,8 +1343,7 @@ static int enc28j60_net_open(struct net_device *dev)if (!is_valid_ether_addr (dev->dev_addr)) {if (netif_msg_ifup (priv)) -dev_err (&dev->dev,"invalid MAC address %pM\n" , - dev->dev_addr); +netdev_err (dev,"invalid MAC address %pM\n" , dev->dev_addr);return -EADDRNOTAVAIL ; }/* Reset the hardware here (and take it out of low power mode) */
@@ -1357,7 +1351,7 @@ static int enc28j60_net_open(struct net_device *dev)enc28j60_hw_disable (priv);if (!enc28j60_hw_init (priv)) {if (netif_msg_ifup (priv)) -dev_err (&dev->dev,"hw_reset() failed\n" ); +netdev_err (dev,"hw_reset() failed\n" );return -EINVAL ; }/* Update the MAC address (in case user has changed it) */
@@ -1399,16 +1393,16 @@ static void enc28j60_set_multicast_list(struct net_device *dev)if (dev->flags &IFF_PROMISC ) {if (netif_msg_link (priv)) -dev_info (&dev->dev,"promiscuous mode\n" ); +netdev_info (dev,"promiscuous mode\n" ); priv->rxfilter =RXFILTER_PROMISC ; }else if ((dev->flags &IFF_ALLMULTI ) || !netdev_mc_empty (dev)) {if (netif_msg_link (priv)) -dev_info (&dev->dev,"%smulticast mode\n" , - (dev->flags &IFF_ALLMULTI ) ?"all-" :"" ); +netdev_info (dev,"%smulticast mode\n" , + (dev->flags &IFF_ALLMULTI ) ?"all-" :"" ); priv->rxfilter =RXFILTER_MULTI ; }else {if (netif_msg_link (priv)) -dev_info (&dev->dev,"normal mode\n" ); +netdev_info (dev,"normal mode\n" ); priv->rxfilter =RXFILTER_NORMAL ; }
@@ -1452,7 +1446,7 @@ static void enc28j60_restart_work_handler(struct work_struct *work)enc28j60_net_close (ndev); ret =enc28j60_net_open (ndev);if (unlikely (ret)) { -dev_info (&ndev->dev," could not restart %d\n" , ret); +netdev_info (ndev,"could not restart %d\n" , ret);dev_close (ndev); } }
Signature · 1 line
2.20.1
PATCH v2 4/13 enc28j60: Drop driver name duplication from messages
In reply to Andy ShevchenkoWhen dev_<level>() macros are used against SPI device, the driver's name is printed as well. No need to duplicate this explicitly.
--- drivers/net/ethernet/microchip/enc28j60.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +6 -7
@@ -1536,8 +1536,7 @@ static int enc28j60_probe(struct spi_device *spi)int ret =0 ;if (netif_msg_drv (&debug)) -dev_info (&spi->dev,DRV_NAME " Ethernet driver %s loaded\n" , -DRV_VERSION ); +dev_info (&spi->dev,"Ethernet driver %s loaded\n" ,DRV_VERSION ); dev =alloc_etherdev (sizeof (struct enc28j60_net ));if (!dev) {
@@ -1560,7 +1559,7 @@ static int enc28j60_probe(struct spi_device *spi)if (!enc28j60_chipset_init (dev)) {if (netif_msg_probe (priv)) -dev_info (&spi->dev,DRV_NAME " chip not found\n" ); +dev_info (&spi->dev,"chip not found\n" ); ret = -EIO ; goto error_irq; }
@@ -1577,8 +1576,8 @@ static int enc28j60_probe(struct spi_device *spi) ret =request_irq (spi->irq, enc28j60_irq,0 ,DRV_NAME , priv);if (ret <0 ) {if (netif_msg_probe (priv)) -dev_err (&spi->dev,DRV_NAME ": request irq %d failed " -"(ret = %d)\n" , spi->irq, ret); +dev_err (&spi->dev,"request irq %d failed (ret = %d)\n" , + spi->irq, ret); goto error_irq; }
@@ -1593,8 +1592,8 @@ static int enc28j60_probe(struct spi_device *spi) ret =register_netdev (dev);if (ret) {if (netif_msg_probe (priv)) -dev_err (&spi->dev,"register netdev " DRV_NAME -" failed (ret = %d)\n" , ret); +dev_err (&spi->dev,"register netdev failed (ret = %d)\n" , + ret); goto error_register; }
Signature · 1 line
2.20.1
PATCH v2 5/13 enc28j60: Switch to use module_spi_driver() macro
In reply to Andy ShevchenkoEliminate some boilerplate code by using module_spi_driver() instead of ->init() / ->exit(), moving the salient bits from ->init() into ->probe().
--- drivers/net/ethernet/microchip/enc28j60.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +2 -19
@@ -417,11 +417,9 @@ enc28j60_packet_write(struct enc28j60_net *priv, int len, const u8 *data)mutex_unlock (&priv->lock); } -static unsigned long msec20_to_jiffies; -static int poll_ready (struct enc28j60_net *priv,u8 reg,u8 mask,u8 val) { -unsigned long timeout = jiffies + msec20_to_jiffies; +unsigned long timeout = jiffies +msecs_to_jiffies (20 );/* 20 msec timeout read */ while ((nolock_regb_read (priv, reg) & mask) != val) {
@@ -1632,22 +1630,7 @@ static struct spi_driver enc28j60_driver = { .probe = enc28j60_probe, .remove = enc28j60_remove, }; - -static int __init enc28j60_init (void ) -{ - msec20_to_jiffies =msecs_to_jiffies (20 ); - -return spi_register_driver (&enc28j60_driver); -} - -module_init (enc28j60_init); - -static void __exit enc28j60_exit(void) -{ -spi_unregister_driver (&enc28j60_driver); -} - -module_exit (enc28j60_exit); +module_spi_driver (enc28j60_driver);MODULE_DESCRIPTION (DRV_NAME " ethernet driver" );MODULE_AUTHOR ("Claudio Lanconelli <[email protected]>" );
Signature · 1 line
2.20.1
PATCH v2 6/13 enc28j60: Use ether_addr_copy() in enc28j60_set_mac_address()
In reply to Andy ShevchenkoUse ether_addr_copy() instead of memcpy() to copy the mac address.
--- drivers/net/ethernet/microchip/enc28j60.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/microchip/enc28j60.c +1 -1
@@ -527,7 +527,7 @@ static int enc28j60_set_mac_address(struct net_device *dev, void *addr)if (!is_valid_ether_addr (address->sa_data))return -EADDRNOTAVAIL ; -memcpy (dev->dev_addr, address->sa_data, dev->addr_len); +ether_addr_copy (dev->dev_addr, address->sa_data);return enc28j60_set_hw_macaddr (dev); }
Signature · 1 line
2.20.1
PATCH v2 7/13 enc28j60: Switch to dev_<level> from pr_<level>
In reply to Andy ShevchenkoInstead of using open coded printk(KERN_<LEVEL>) switch the driver to use dev_<level> macros.
Note, the device name will be printed in full, which is beneficial when more than one card installed on the system.
--- drivers/net/ethernet/microchip/enc28j60.c | 29 +++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +17 -12
@@ -419,14 +419,14 @@ enc28j60_packet_write(struct enc28j60_net *priv, int len, const u8 *data)static int poll_ready (struct enc28j60_net *priv,u8 reg,u8 mask,u8 val) { +struct device *dev = &priv->spi->dev;unsigned long timeout = jiffies +msecs_to_jiffies (20 );/* 20 msec timeout read */ while ((nolock_regb_read (priv, reg) & mask) != val) {if (time_after (jiffies, timeout)) {if (netif_msg_drv (priv)) -dev_dbg (&priv->spi->dev, -"reg %02x ready timeout!\n" , reg); +dev_dbg (dev,"reg %02x ready timeout!\n" , reg);return -ETIMEDOUT ; }cpu_relax ();
@@ -489,13 +489,13 @@ static int enc28j60_set_hw_macaddr(struct net_device *ndev) {int ret;struct enc28j60_net *priv =netdev_priv (ndev); +struct device *dev = &priv->spi->dev;mutex_lock (&priv->lock);if (!priv->hw_enable) {if (netif_msg_drv (priv)) - printk(KERN_INFO DRV_NAME -": %s: Setting MAC address to %pM\n" , - ndev->name, ndev->dev_addr); +dev_info (dev,"%s: Setting MAC address to %pM\n" , + ndev->name, ndev->dev_addr);/* NOTE: MAC address in ENC28J60 is byte-backward */ nolock_regb_write (priv,MAADR5 , ndev->dev_addr[0 ]);nolock_regb_write (priv,MAADR4 , ndev->dev_addr[1 ]);
@@ -594,12 +594,13 @@ static u16 rx_packet_start(u16 ptr)static void nolock_rxfifo_init (struct enc28j60_net *priv,u16 start,u16 end) { +struct device *dev = &priv->spi->dev;u16 erxrdpt;if (start >0x1FFF || end >0x1FFF || start > end) {if (netif_msg_drv (priv)) - printk(KERN_ERR DRV_NAME ": %s(%d, %d) RXFIFO " -"bad parameters!\n" , __func__, start, end); +dev_err (dev,"%s(%d, %d) RXFIFO bad parameters!\n" , + __func__, start, end);return ; }/* set receive buffer start + end */
@@ -612,10 +613,12 @@ static void nolock_rxfifo_init(struct enc28j60_net *priv, u16 start, u16 end)static void nolock_txfifo_init (struct enc28j60_net *priv,u16 start,u16 end) { +struct device *dev = &priv->spi->dev; +if (start >0x1FFF || end >0x1FFF || start > end) {if (netif_msg_drv (priv)) - printk(KERN_ERR DRV_NAME ": %s(%d, %d) TXFIFO " -"bad parameters!\n" , __func__, start, end); +dev_err (dev,"%s(%d, %d) TXFIFO bad parameters!\n" , + __func__, start, end);return ; }/* set transmit buffer start + end */
@@ -630,9 +633,10 @@ static void nolock_txfifo_init(struct enc28j60_net *priv, u16 start, u16 end)*/ static void enc28j60_lowpower (struct enc28j60_net *priv,bool is_low) { +struct device *dev = &priv->spi->dev; +if (netif_msg_drv (priv)) -dev_dbg (&priv->spi->dev,"%s power...\n" , - is_low ?"low" :"high" ); +dev_dbg (dev,"%s power...\n" , is_low ?"low" :"high" );mutex_lock (&priv->lock);if (is_low) {
@@ -651,6 +655,7 @@ static void enc28j60_lowpower(struct enc28j60_net *priv, bool is_low)static int enc28j60_hw_init (struct enc28j60_net *priv) { +struct device *dev = &priv->spi->dev;u8 reg;if (netif_msg_drv (priv))
@@ -681,7 +686,7 @@ static int enc28j60_hw_init(struct enc28j60_net *priv)*/ reg =locked_regb_read (priv,EREVID );if (netif_msg_drv (priv)) - printk(KERN_INFO DRV_NAME ": chip RevID: 0x%02x\n", reg); +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",
Signature · 1 line
2.20.1
PATCH v2 8/13 enc28j60: Convert HW related printk() to dev_printk()
In reply to Andy ShevchenkoThe 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).
--- drivers/net/ethernet/microchip/enc28j60.c | 260 ++++++++++++---------- 1 file changed, 141 insertions(+), 119 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +141 -119
@@ -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,8 +114,8 @@ 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", - __func__, ret); +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,8 +136,8 @@ 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", - __func__, ret); +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,8 +162,8 @@ 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", - __func__, ret); +dev_printk (KERN_DEBUG , dev,"%s() failed: ret = %d\n" , + __func__, ret);else val = rx_buf[slen -1 ];
@@ -173,14 +176,15 @@ 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", - __func__, ret); +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,9 +404,9 @@ 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" , - __func__, reg, TXSTART_INIT); +dev_printk (KERN_DEBUG , dev, +"%s() ERWPT:0x%04x != 0x%04x\n" , + __func__, reg, TXSTART_INIT); }#endif /* Set the TXND pointer to correspond to the packet size given */
@@ -405,15 +414,15 @@ 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" , - __func__,nolock_regw_read (priv,EWRPTL )); +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" , - __func__,nolock_regw_read (priv,EWRPTL ), len); +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,33 +545,36 @@ 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" -"HwRevID: 0x%02x\n" -"Cntrl: ECON1 ECON2 ESTAT EIR EIE\n" -" 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x\n" -"MAC : MACON1 MACON3 MACON4\n" -" 0x%02x 0x%02x 0x%02x\n" -"Rx : ERXST ERXND ERXWRPT ERXRDPT ERXFCON EPKTCNT MAMXFL\n" -" 0x%04x 0x%04x 0x%04x 0x%04x " -"0x%02x 0x%02x 0x%04x\n" -"Tx : ETXST ETXND MACLCON1 MACLCON2 MAPHSUP\n" -" 0x%04x 0x%04x 0x%02x 0x%02x 0x%02x\n" , - msg,nolock_regb_read (priv,EREVID ), -nolock_regb_read (priv,ECON1 ),nolock_regb_read (priv,ECON2 ), -nolock_regb_read (priv,ESTAT ),nolock_regb_read (priv,EIR ), -nolock_regb_read (priv,EIE ),nolock_regb_read (priv,MACON1 ), -nolock_regb_read (priv,MACON3 ),nolock_regb_read (priv,MACON4 ), -nolock_regw_read (priv,ERXSTL ),nolock_regw_read (priv,ERXNDL ), -nolock_regw_read (priv,ERXWRPTL ), -nolock_regw_read (priv,ERXRDPTL ), -nolock_regb_read (priv,ERXFCON ), -nolock_regb_read (priv,EPKTCNT ), -nolock_regw_read (priv,MAMXFLL ),nolock_regw_read (priv,ETXSTL ), -nolock_regw_read (priv,ETXNDL ), -nolock_regb_read (priv,MACLCON1 ), -nolock_regb_read (priv,MACLCON2 ), - nolock_regb_read(priv, MAPHSUP)); +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" +"MAC : MACON1 MACON3 MACON4\n" +" 0x%02x 0x%02x 0x%02x\n" +"Rx : ERXST ERXND ERXWRPT ERXRDPT ERXFCON EPKTCNT MAMXFL\n" +" 0x%04x 0x%04x 0x%04x 0x%04x " +"0x%02x 0x%02x 0x%04x\n" +"Tx : ETXST ETXND MACLCON1 MACLCON2 MAPHSUP\n" +" 0x%04x 0x%04x 0x%02x 0x%02x 0x%02x\n" , + msg,nolock_regb_read (priv,EREVID ), +nolock_regb_read (priv,ECON1 ),nolock_regb_read (priv,ECON2 ), +nolock_regb_read (priv,ESTAT ),nolock_regb_read (priv,EIR ), +nolock_regb_read (priv,EIE ),nolock_regb_read (priv,MACON1 ), +nolock_regb_read (priv,MACON3 ),nolock_regb_read (priv,MACON4 ), +nolock_regw_read (priv,ERXSTL ),nolock_regw_read (priv,ERXNDL ), +nolock_regw_read (priv,ERXWRPTL ), +nolock_regw_read (priv,ERXRDPTL ), +nolock_regb_read (priv,ERXFCON ), +nolock_regb_read (priv,EPKTCNT ), +nolock_regw_read (priv,MAMXFLL ),nolock_regw_read (priv,ETXSTL ), +nolock_regw_read (priv,ETXNDL ), +nolock_regb_read (priv,MACLCON1 ), +nolock_regb_read (priv,MACLCON2 ), +nolock_regb_read (priv,MAPHSUP ));mutex_unlock (&priv->lock); }
@@ -659,8 +671,8 @@ 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__, - priv->full_duplex ?"FullDuplex" :"HalfDuplex" ); +dev_printk (KERN_DEBUG , dev,"%s() - %s\n" , __func__, + priv->full_duplex ?"FullDuplex" :"HalfDuplex" );mutex_lock (&priv->lock);/* first reset the chip */
@@ -689,8 +701,8 @@ 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", - __func__, reg); +dev_printk (KERN_DEBUG , dev,"%s() Invalid RevId %d\n" , + __func__, reg);return 0 ; }
@@ -750,10 +762,12 @@ 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", - __func__); +dev_printk (KERN_DEBUG , dev,"%s() enabling interrupts.\n" , + __func__);enc28j60_phy_write (priv,PHIE ,PHIE_PGEIE |PHIE_PLNKIE );
@@ -809,21 +823,23 @@ 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", - endptr +1 ); +dev_printk (KERN_DEBUG , dev,"reading TSV at addr:0x%04x\n" , + endptr +1 );enc28j60_mem_read (priv, endptr +1 ,TSV_SIZE , tsv); }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,30 +848,32 @@ 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 ), -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" , -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" , -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" , -TSV_GETBIT (tsv,TSV_TXCONTROLFRAME ), -TSV_GETBIT (tsv,TSV_TXPAUSEFRAME ), -TSV_GETBIT (tsv,TSV_BACKPRESSUREAPP ), - TSV_GETBIT(tsv, TSV_TXVLANTAGFRAME)); +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 )); +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 )); +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 )); +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 ), +TSV_GETBIT (tsv,TSV_TXVLANTAGFRAME )); }/*
@@ -864,27 +882,29 @@ 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 ), -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" , -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" , -RSV_GETBIT (sts,RSV_RXCONTROLFRAME ), -RSV_GETBIT (sts,RSV_RXPAUSEFRAME ), -RSV_GETBIT (sts,RSV_RXUNKNOWNOPCODE ), - RSV_GETBIT(sts, RSV_RXTYPEVLAN)); +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 )); +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 )); +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 ), +RSV_GETBIT (sts,RSV_RXTYPEVLAN )); }static void dump_packet (const char *msg,int len,const char *data)
@@ -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,8 +1004,8 @@ 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", - __func__, erxrdpt); +dev_printk (KERN_DEBUG , dev,"%s() ERXRDPT:0x%04x\n" , + __func__, erxrdpt);mutex_lock (&priv->lock);nolock_regw_write (priv,ERXRDPTL , erxrdpt);
@@ -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,14 +1063,15 @@ 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__, -enc28j60_phy_read (priv,PHSTAT1 ), reg); +dev_printk (KERN_DEBUG , dev, +"%s() PHSTAT1: %04x, PHSTAT2: %04x\n" , __func__, +enc28j60_phy_read (priv,PHSTAT1 ), reg); duplex = reg &PHSTAT2_DPXSTAT ;if (reg &PHSTAT2_LSTAT ) {
@@ -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 );
Signature · 1 line
2.20.1
PATCH v2 9/13 enc28j60: Convert printk() to netdev_printk()
In reply to Andy ShevchenkoThe debug prints of network operations will look better if network 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 netdev_print(KERN_DEBUG, ndev).
--- drivers/net/ethernet/microchip/enc28j60.c | 51 ++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +27 -24
@@ -929,8 +929,8 @@ static void enc28j60_hw_rx(struct net_device *ndev)int len;if (netif_msg_rx_status (priv)) - printk(KERN_DEBUG DRV_NAME ": RX pk_addr:0x%04x\n", - priv->next_pk_ptr); +netdev_printk (KERN_DEBUG , ndev,"RX pk_addr:0x%04x\n" , + priv->next_pk_ptr);if (unlikely (priv->next_pk_ptr >RXEND_INIT )) {if (netif_msg_rx_err (priv))
@@ -1030,6 +1030,7 @@ static void enc28j60_hw_rx(struct net_device *ndev)*/ static int enc28j60_get_free_rxfifo (struct enc28j60_net *priv) { +struct net_device *ndev = priv->netdev;int epkcnt, erxst, erxnd, erxwr, erxrd;int free_space;
@@ -1052,8 +1053,8 @@ static int enc28j60_get_free_rxfifo(struct enc28j60_net *priv) }mutex_unlock (&priv->lock);if (netif_msg_rx_status (priv)) - printk(KERN_DEBUG DRV_NAME ": %s() free_space = %d\n", - __func__, free_space); +netdev_printk (KERN_DEBUG , ndev,"%s() free_space = %d\n" , + __func__, free_space);return free_space; }
@@ -1120,13 +1121,14 @@ static int enc28j60_rx_interrupt(struct net_device *ndev) pk_counter =locked_regb_read (priv,EPKTCNT );if (pk_counter &&netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME ": intRX, pk_cnt: %d\n", pk_counter); +netdev_printk (KERN_DEBUG , ndev,"intRX, pk_cnt: %d\n" , + pk_counter);if (pk_counter > priv->max_pk_counter) {/* update statistics */ priv->max_pk_counter = pk_counter;if (netif_msg_rx_status (priv) && priv->max_pk_counter >1 ) - printk(KERN_DEBUG DRV_NAME ": RX max_pk_cnt: %d\n", - priv->max_pk_counter); +netdev_printk (KERN_DEBUG , ndev,"RX max_pk_cnt: %d\n" , + priv->max_pk_counter); } ret = pk_counter;while (pk_counter-- >0 )
@@ -1152,16 +1154,16 @@ static void enc28j60_irq_work_handler(struct work_struct *work)if ((intflags &EIR_DMAIF ) !=0 ) { loop++;if (netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME -": intDMA(%d)\n" , loop); +netdev_printk (KERN_DEBUG , ndev,"intDMA(%d)\n" , + loop);locked_reg_bfclr (priv,EIR ,EIR_DMAIF ); }/* LINK changed handler */ if ((intflags &EIR_LINKIF ) !=0 ) { loop++;if (netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME -": intLINK(%d)\n" , loop); +netdev_printk (KERN_DEBUG , ndev,"intLINK(%d)\n" , + loop);enc28j60_check_link_status (ndev);/* read PHIR to clear the flag */ enc28j60_phy_read (priv,PHIR );
@@ -1172,8 +1174,8 @@ static void enc28j60_irq_work_handler(struct work_struct *work)bool err = false; loop++;if (netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME -": intTX(%d)\n" , loop); +netdev_printk (KERN_DEBUG , ndev,"intTX(%d)\n" , + loop); priv->tx_retry_count =0 ;if (locked_regb_read (priv,ESTAT ) &ESTAT_TXABRT ) {if (netif_msg_tx_err (priv))
@@ -1194,8 +1196,8 @@ static void enc28j60_irq_work_handler(struct work_struct *work) loop++;if (netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME -": intTXErr(%d)\n" , loop); +netdev_printk (KERN_DEBUG , ndev,"intTXErr(%d)\n" , + loop);locked_reg_bfclr (priv,ECON1 ,ECON1_TXRTS );enc28j60_read_tsv (priv, tsv);if (netif_msg_tx_err (priv))
@@ -1209,9 +1211,9 @@ static void enc28j60_irq_work_handler(struct work_struct *work)/* Transmit Late collision check for retransmit */ if (TSV_GETBIT (tsv,TSV_TXLATECOLLISION )) {if (netif_msg_tx_err (priv)) - printk(KERN_DEBUG DRV_NAME -": LateCollision TXErr (%d)\n" , - priv->tx_retry_count); +netdev_printk (KERN_DEBUG , ndev, +"LateCollision TXErr (%d)\n" , + priv->tx_retry_count);if (priv->tx_retry_count++ <MAX_TX_RETRYCOUNT )locked_reg_bfset (priv,ECON1 ,ECON1_TXRTS );
@@ -1225,13 +1227,12 @@ static void enc28j60_irq_work_handler(struct work_struct *work)if ((intflags &EIR_RXERIF ) !=0 ) { loop++;if (netif_msg_intr (priv)) - printk(KERN_DEBUG DRV_NAME -": intRXErr(%d)\n" , loop); +netdev_printk (KERN_DEBUG , ndev,"intRXErr(%d)\n" , + loop);/* Check free FIFO space to flag RX overrun */ if (enc28j60_get_free_rxfifo (priv) <=0 ) {if (netif_msg_rx_err (priv)) - printk(KERN_DEBUG DRV_NAME -": RX Overrun\n" ); +netdev_printk (KERN_DEBUG , ndev,"RX Overrun\n" ); ndev->stats.rx_dropped++; }locked_reg_bfclr (priv,EIR ,EIR_RXERIF );
@@ -1252,11 +1253,13 @@ static void enc28j60_irq_work_handler(struct work_struct *work)*/ static void enc28j60_hw_tx (struct enc28j60_net *priv) { +struct net_device *ndev = priv->netdev; +BUG_ON (!priv->tx_skb);if (netif_msg_tx_queued (priv)) - printk(KERN_DEBUG DRV_NAME -": Tx Packet Len:%d\n" , priv->tx_skb->len); +netdev_printk (KERN_DEBUG , ndev,"Tx Packet Len:%d\n" , + priv->tx_skb->len);if (netif_msg_pktdata (priv)) dump_packet(__func__,
Signature · 1 line
2.20.1
PATCH v2 10/13 enc28j60: Remove linux/init.h
In reply to Andy ShevchenkoThere is no need to include linux/init.h when at the same time we include linux/module.h.
Remove redundant inclusion.
--- drivers/net/ethernet/microchip/enc28j60.c | 1 - 1 file changed, 1 deletion(-)
drivers/net/ethernet/microchip/enc28j60.c +0 -1
@@ -21,7 +21,6 @@#include <linux/property.h> #include <linux/string.h> #include <linux/errno.h> -#include <linux/init.h> #include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/ethtool.h>
Signature · 1 line
2.20.1
PATCH v2 11/13 enc28j60: Amend comments by fixing typos, adding periods, etc
In reply to Andy ShevchenkoAmend comments in the code:
- adding periods to the multi-line comments
- fixing typos
- capitalize first word in the sentences
- etc
--- drivers/net/ethernet/microchip/enc28j60.c | 31 ++++++++++++----------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +16 -15
@@ -40,7 +40,8 @@ (NETIF_MSG_PROBE |NETIF_MSG_IFUP |NETIF_MSG_IFDOWN |NETIF_MSG_LINK )/* Buffer size required for the largest SPI transfer (i.e., reading a - * frame). */ +* frame). + */#define SPI_TRANSFER_BUF_LEN (4 + MAX_FRAMELEN)#define TX_TIMEOUT (4 * HZ)
@@ -82,7 +83,7 @@ static struct {/* * SPI read buffer -* wait for the SPI transfer and copy received data to destination +* Wait for the SPI transfer and copy received data to destination. */ static int spi_read_buf (struct enc28j60_net *priv,int len,u8 *data)
@@ -191,7 +192,7 @@ static void enc28j60_soft_reset(struct enc28j60_net *priv) {spi_write_op (priv,ENC28J60_SOFT_RESET ,0 ,ENC28J60_SOFT_RESET );/* Errata workaround #1, CLKRDY check is unreliable, -* delay at least 1 mS instead */ +* delay at least 1 ms instead */ udelay (2000 ); }
@@ -203,7 +204,7 @@ static void enc28j60_set_bank(struct enc28j60_net *priv, u8 addr)u8 b = (addr &BANK_MASK ) >>5 ;/* These registers (EIE, EIR, ESTAT, ECON2, ECON1) -* are present in all banks, no need to switch bank +* are present in all banks, no need to switch bank. */ if (addr >=EIE && addr <=ECON1 )return ;
@@ -364,7 +365,7 @@ static void locked_regw_write(struct enc28j60_net *priv,/* * Buffer memory read -* Select the starting address and execute a SPI buffer read +* Select the starting address and execute a SPI buffer read. */ static void enc28j60_mem_read (struct enc28j60_net *priv,u16 addr,int len,u8 *data)
@@ -452,7 +453,7 @@ static int wait_phy_ready(struct enc28j60_net *priv)/* * PHY register read -* PHY registers are not accessed directly, but through the MII +* PHY registers are not accessed directly, but through the MII. */ static u16 enc28j60_phy_read (struct enc28j60_net *priv,u8 address) {
@@ -639,8 +640,8 @@ static void nolock_txfifo_init(struct enc28j60_net *priv, u16 start, u16 end)/* * Low power mode shrinks power consumption about 100x, so we'd like -* the chip to be in that mode whenever it's inactive. (However, we -* can't stay in lowpower mode during suspend with WOL active.) +* the chip to be in that mode whenever it's inactive. (However, we +* can't stay in low power mode during suspend with WOL active.) */ static void enc28j60_lowpower (struct enc28j60_net *priv,bool is_low) {
@@ -693,7 +694,7 @@ static int enc28j60_hw_init(struct enc28j60_net *priv)/* * Check the RevID. * If it's 0x00 or 0xFF probably the enc28j60 is not mounted or -* damaged +* damaged. */ reg =locked_regb_read (priv,EREVID );if (netif_msg_drv (priv))
@@ -734,7 +735,7 @@ static int enc28j60_hw_init(struct enc28j60_net *priv)/* * MACLCON1 (default) * MACLCON2 (default) -* Set the maximum packet size which the controller will accept +* Set the maximum packet size which the controller will accept. */ locked_regw_write (priv,MAMXFLL ,MAX_FRAMELEN );
@@ -785,7 +786,7 @@ static void enc28j60_hw_enable(struct enc28j60_net *priv)static void enc28j60_hw_disable (struct enc28j60_net *priv) {mutex_lock (&priv->lock); -/* disable interrutps and packet reception */ +/* disable interrupts and packet reception */ nolock_regb_write (priv,EIE ,0x00 );nolock_reg_bfclr (priv,ECON1 ,ECON1_RXEN ); priv->hw_enable = false;
@@ -999,7 +1000,7 @@ static void enc28j60_hw_rx(struct net_device *ndev)/* * Move the RX read pointer to the start of the next * received packet. -* This frees the memory we just read out +* This frees the memory we just read out. */ erxrdpt =erxrdpt_workaround (next_packet,RXSTART_INIT ,RXEND_INIT );if (netif_msg_hw (priv))
@@ -1107,8 +1108,8 @@ static void enc28j60_tx_clear(struct net_device *ndev, bool err)/* * RX handler -* ignore PKTIF because is unreliable! (look at the errata datasheet) -* check EPKTCNT is the suggested workaround. +* Ignore PKTIF because is unreliable! (Look at the errata datasheet) +* Check EPKTCNT is the suggested workaround. * We don't need to clear interrupt flag, automatically done when * enc28j60_hw_rx() decrements the packet counter. * Returns how many packet processed.
@@ -1305,7 +1306,7 @@ static netdev_tx_t enc28j60_send_packet(struct sk_buff *skb,* packet, you should return '1' from this function. * In such a case you _may not_ do anything to the * SKB, it is still owned by the network queueing -* layer when an error is returned. This means you +* layer when an error is returned. This means you * may not modify any SKB fields, you may not free * the SKB, etc. */
Signature · 1 line
2.20.1
PATCH v2 12/13 enc28j60: Fix indentation splats
In reply to Andy ShevchenkoFix few indentation splats. No functional change intended.
--- drivers/net/ethernet/microchip/enc28j60.c | 58 ++++++++--------------- 1 file changed, 21 insertions(+), 37 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +21 -37
@@ -44,7 +44,7 @@*/ #define SPI_TRANSFER_BUF_LEN (4 + MAX_FRAMELEN) -#define TX_TIMEOUT (4 * HZ) +#define TX_TIMEOUT (4 * HZ)/* Max TX retries in case of collision as suggested by errata datasheet */ #define MAX_TX_RETRYCOUNT 16
@@ -123,8 +123,7 @@ spi_read_buf(struct enc28j60_net *priv, int len, u8 *data)/* * SPI write buffer */ -static int spi_write_buf (struct enc28j60_net *priv,int len, -const u8 *data) +static int spi_write_buf (struct enc28j60_net *priv,int len,const u8 *data) {struct device *dev = &priv->spi->dev;int ret;
@@ -145,8 +144,7 @@ static int spi_write_buf(struct enc28j60_net *priv, int len,/* * basic SPI read operation */ -static u8 spi_read_op (struct enc28j60_net *priv,u8 op, -u8 addr) +static u8 spi_read_op (struct enc28j60_net *priv,u8 op,u8 addr) {struct device *dev = &priv->spi->dev;u8 tx_buf[2 ];
@@ -173,8 +171,7 @@ static u8 spi_read_op(struct enc28j60_net *priv, u8 op,/* * basic SPI write operation */ -static int spi_write_op (struct enc28j60_net *priv,u8 op, -u8 addr,u8 val) +static int spi_write_op (struct enc28j60_net *priv,u8 op,u8 addr,u8 val) {struct device *dev = &priv->spi->dev;int ret;
@@ -243,15 +240,13 @@ static void enc28j60_set_bank(struct enc28j60_net *priv, u8 addr)/* * Register bit field Set */ -static void nolock_reg_bfset (struct enc28j60_net *priv, -u8 addr,u8 mask) +static void nolock_reg_bfset (struct enc28j60_net *priv,u8 addr,u8 mask) {enc28j60_set_bank (priv, addr);spi_write_op (priv,ENC28J60_BIT_FIELD_SET , addr, mask); } -static void locked_reg_bfset (struct enc28j60_net *priv, -u8 addr,u8 mask) +static void locked_reg_bfset (struct enc28j60_net *priv,u8 addr,u8 mask) {mutex_lock (&priv->lock);nolock_reg_bfset (priv, addr, mask);
@@ -261,15 +256,13 @@ static void locked_reg_bfset(struct enc28j60_net *priv,/* * Register bit field Clear */ -static void nolock_reg_bfclr (struct enc28j60_net *priv, -u8 addr,u8 mask) +static void nolock_reg_bfclr (struct enc28j60_net *priv,u8 addr,u8 mask) {enc28j60_set_bank (priv, addr);spi_write_op (priv,ENC28J60_BIT_FIELD_CLR , addr, mask); } -static void locked_reg_bfclr (struct enc28j60_net *priv, -u8 addr,u8 mask) +static void locked_reg_bfclr (struct enc28j60_net *priv,u8 addr,u8 mask) {mutex_lock (&priv->lock);nolock_reg_bfclr (priv, addr, mask);
@@ -279,15 +272,13 @@ static void locked_reg_bfclr(struct enc28j60_net *priv,/* * Register byte read */ -static int nolock_regb_read (struct enc28j60_net *priv, -u8 address) +static int nolock_regb_read (struct enc28j60_net *priv,u8 address) {enc28j60_set_bank (priv, address);return spi_read_op (priv,ENC28J60_READ_CTRL_REG , address); } -static int locked_regb_read (struct enc28j60_net *priv, -u8 address) +static int locked_regb_read (struct enc28j60_net *priv,u8 address) {int ret;
@@ -301,8 +292,7 @@ static int locked_regb_read(struct enc28j60_net *priv,/* * Register word read */ -static int nolock_regw_read (struct enc28j60_net *priv, -u8 address) +static int nolock_regw_read (struct enc28j60_net *priv,u8 address) {int rl, rh;
@@ -313,8 +303,7 @@ static int nolock_regw_read(struct enc28j60_net *priv,return (rh <<8 ) | rl; } -static int locked_regw_read (struct enc28j60_net *priv, -u8 address) +static int locked_regw_read (struct enc28j60_net *priv,u8 address) {int ret;
@@ -328,15 +317,13 @@ static int locked_regw_read(struct enc28j60_net *priv,/* * Register byte write */ -static void nolock_regb_write (struct enc28j60_net *priv, -u8 address,u8 data) +static void nolock_regb_write (struct enc28j60_net *priv,u8 address,u8 data) {enc28j60_set_bank (priv, address);spi_write_op (priv,ENC28J60_WRITE_CTRL_REG , address, data); } -static void locked_regb_write (struct enc28j60_net *priv, -u8 address,u8 data) +static void locked_regb_write (struct enc28j60_net *priv,u8 address,u8 data) {mutex_lock (&priv->lock);nolock_regb_write (priv, address, data);
@@ -346,8 +333,7 @@ static void locked_regb_write(struct enc28j60_net *priv,/* * Register word write */ -static void nolock_regw_write (struct enc28j60_net *priv, -u8 address,u16 data) +static void nolock_regw_write (struct enc28j60_net *priv,u8 address,u16 data) {enc28j60_set_bank (priv, address);spi_write_op (priv,ENC28J60_WRITE_CTRL_REG , address, (u8 ) data);
@@ -355,8 +341,7 @@ static void nolock_regw_write(struct enc28j60_net *priv, (u8) (data >> 8)); } -static void locked_regw_write (struct enc28j60_net *priv, -u8 address,u16 data) +static void locked_regw_write (struct enc28j60_net *priv,u8 address,u16 data) {mutex_lock (&priv->lock);nolock_regw_write (priv, address, data);
@@ -367,8 +352,8 @@ static void locked_regw_write(struct enc28j60_net *priv,* Buffer memory read * Select the starting address and execute a SPI buffer read. */ -static void enc28j60_mem_read (struct enc28j60_net *priv, -u16 addr,int len,u8 *data) +static void enc28j60_mem_read (struct enc28j60_net *priv,u16 addr,int len, +u8 *data) {mutex_lock (&priv->lock);nolock_regw_write (priv,ERDPTL , addr);
@@ -469,7 +454,7 @@ static u16 enc28j60_phy_read(struct enc28j60_net *priv, u8 address)/* quit reading */ nolock_regb_write (priv,MICMD ,0x00 );/* return the data */ - ret =nolock_regw_read (priv,MIRDL ); + ret =nolock_regw_read (priv,MIRDL );mutex_unlock (&priv->lock);return ret;
@@ -834,7 +819,7 @@ 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 ]) +u8 tsv[TSV_SIZE ]) {struct device *dev = &priv->spi->dev;u16 tmp1, tmp2;
@@ -1575,8 +1560,7 @@ static int enc28j60_probe(struct spi_device *spi) priv->netdev = dev;/* priv to netdev reference */ priv->spi = spi;/* priv to spi reference */ - priv->msg_enable =netif_msg_init (debug.msg_enable, -ENC28J60_MSG_DEFAULT ); + priv->msg_enable =netif_msg_init (debug.msg_enable,ENC28J60_MSG_DEFAULT );mutex_init (&priv->lock);INIT_WORK (&priv->tx_work, enc28j60_tx_work_handler);INIT_WORK (&priv->setrx_work, enc28j60_setrx_work_handler);
Signature · 1 line
2.20.1
PATCH v2 13/13 enc28j60: Convert to use SPDX identifier
In reply to Andy ShevchenkoReduce size of duplicated comments by switching to use SPDX identifier.
No functional change.
--- drivers/net/ethernet/microchip/enc28j60.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/net/ethernet/microchip/enc28j60.c +1 -5
@@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Microchip ENC28J60 ethernet driver (MAC + PHY) *
@@ -5,11 +6,6 @@* Author: Claudio Lanconelli <[email protected]> * based on enc28j60.c written by David Anders for 2.4 kernel version * -* This program is free software; you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* * $Id: enc28j60.c,v 1.22 2007/12/20 10:47:01 claudio Exp $ */
Signature · 1 line
2.20.1
David Miller
maintainerEspecially for a patch series this big, you must provide an appropriate cover posting explaining at a high level what this series is doing, how it is doing it, and why it is doing it that way.
Thank you.
Quoted 4 lines · David Miller
Especially for a patch series this big, you must provide an appropriate cover posting explaining at a high level what this series is doing, how it is doing it, and why it is doing it that way.
Should I resend with cover letter or send a cover letter separately?
Signature · 2 lines
With Best Regards, Andy Shevchenko
David Miller
maintainerFrom: Andy Shevchenko <[email protected]>
Date: Tue, 19 Mar 2019 12:17:53 +0200
Quoted 7 lines · David Miller
Quoted 4 lines
Especially for a patch series this big, you must provide an appropriate cover posting explaining at a high level what this series is doing, how it is doing it, and why it is doing it that way.
Should I resend with cover letter or send a cover letter separately?
Always resend.
Quoted 5 lines · David Miller
From: Andy Shevchenko <[email protected]>
Date: Tue, 19 Mar 2019 12:17:53 +0200Quoted 2 lines · David Miller
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Especially for a patch series this big, you must provide an appropriate cover posting explaining at a high level what this series is doing, how it is doing it, and why it is doing it that way.
Should I resend with cover letter or send a cover letter separately?
Always resend.
Done!
Signature · 2 lines
With Best Regards, Andy Shevchenko