2022-10-05 12:30:10

by Corentin LABBE

[permalink] [raw]
Subject: [PATCH 1/4] net: ethernet: xscale: fix space style issues

Fix all checkpatch issue about space/newlines.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 3b0c5f177447..71d36ff7cd1b 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -115,7 +115,6 @@
#define DEFAULT_RX_CNTRL0 RX_CNTRL0_RX_EN
#define DEFAULT_CORE_CNTRL CORE_MDC_EN

-
/* NPE message codes */
#define NPE_GETSTATUS 0x00
#define NPE_EDB_SETPORTADDRESS 0x01
@@ -141,7 +140,6 @@
#define NPE_NOTIFY_MAC_RECOVERY_DONE 0x16
#define NPE_MAC_RECOVERY_START 0x17

-
#ifdef __ARMEB__
typedef struct sk_buff buffer_t;
#define free_buffer dev_kfree_skb
@@ -247,7 +245,6 @@ struct desc {
#endif
};

-
#define rx_desc_phys(port, n) ((port)->desc_tab_phys + \
(n) * sizeof(struct desc))
#define rx_desc_ptr(port, n) (&(port)->desc_tab[n])
@@ -260,6 +257,7 @@ struct desc {
static inline void memcpy_swab32(u32 *dest, u32 *src, int cnt)
{
int i;
+
for (i = 0; i < cnt; i++)
dest[i] = swab32(src[i]);
}
@@ -566,7 +564,6 @@ static void ixp4xx_mdio_remove(void)
mdiobus_free(mdio_bus);
}

-
static void ixp4xx_adjust_link(struct net_device *dev)
{
struct port *port = netdev_priv(dev);
@@ -597,7 +594,6 @@ static void ixp4xx_adjust_link(struct net_device *dev)
dev->name, port->speed, port->duplex ? "full" : "half");
}

-
static inline void debug_pkt(struct net_device *dev, const char *func,
u8 *data, int len)
{
@@ -616,7 +612,6 @@ static inline void debug_pkt(struct net_device *dev, const char *func,
#endif
}

-
static inline void debug_desc(u32 phys, struct desc *desc)
{
#if DEBUG_DESC
@@ -661,7 +656,6 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
length and queues >= 32 don't support this check anyway. */
}

-
static inline void dma_unmap_tx(struct port *port, struct desc *desc)
{
#ifdef __ARMEB__
@@ -674,7 +668,6 @@ static inline void dma_unmap_tx(struct port *port, struct desc *desc)
#endif
}

-
static void eth_rx_irq(void *pdev)
{
struct net_device *dev = pdev;
@@ -792,7 +785,6 @@ static int eth_poll(struct napi_struct *napi, int budget)
return received; /* not all work done */
}

-
static void eth_txdone_irq(void *unused)
{
u32 phys;
@@ -932,7 +924,6 @@ static netdev_tx_t eth_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}

-
static void eth_set_mcast_list(struct net_device *dev)
{
struct port *port = netdev_priv(dev);
@@ -976,7 +967,6 @@ static void eth_set_mcast_list(struct net_device *dev)
&port->regs->rx_control[0]);
}

-
static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
{
if (!netif_running(dev))
@@ -1046,7 +1036,6 @@ static const struct ethtool_ops ixp4xx_ethtool_ops = {
.set_link_ksettings = phy_ethtool_set_link_ksettings,
};

-
static int request_queues(struct port *port)
{
int err;
@@ -1157,6 +1146,7 @@ static void destroy_queues(struct port *port)
for (i = 0; i < RX_DESCS; i++) {
struct desc *desc = rx_desc_ptr(port, i);
buffer_t *buff = port->rx_buff_tab[i];
+
if (buff) {
dma_unmap_single(&port->netdev->dev,
desc->data - NET_IP_ALIGN,
@@ -1167,6 +1157,7 @@ static void destroy_queues(struct port *port)
for (i = 0; i < TX_DESCS; i++) {
struct desc *desc = tx_desc_ptr(port, i);
buffer_t *buff = port->tx_buff_tab[i];
+
if (buff) {
dma_unmap_tx(port, desc);
free_buffer(buff);
@@ -1320,6 +1311,7 @@ static int eth_close(struct net_device *dev)
struct desc *desc;
u32 phys;
int n = queue_get_desc(port->plat->txreadyq, port, 1);
+
BUG_ON(n < 0);
desc = tx_desc_ptr(port, n);
phys = tx_desc_phys(port, n);
--
2.35.1


2022-10-05 12:30:50

by Corentin LABBE

[permalink] [raw]
Subject: [PATCH 4/4] net: ethernet: xscale: fix easy remaining style issues

Fix all easy remaining styles issues.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 11e5c00f638d..f3732b67cc44 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -356,8 +356,7 @@ static void ixp_tx_timestamp(struct port *port, struct sk_buff *skb)

regs = port->timesync_regs;

- /*
- * This really stinks, but we have to poll for the Tx time stamp.
+ /* This really stinks, but we have to poll for the Tx time stamp.
* Usually, the time stamp is ready after 4 to 6 microseconds.
*/
for (cnt = 0; cnt < 100; cnt++) {
@@ -653,7 +652,8 @@ static inline void queue_put_desc(unsigned int queue, u32 phys,
BUG_ON(phys & 0x1F);
qmgr_put_entry(queue, phys);
/* Don't check for queue overflow here, we've allocated sufficient
- length and queues >= 32 don't support this check anyway. */
+ * length and queues >= 32 don't support this check anyway.
+ */
}

static inline void dma_unmap_tx(struct port *port, struct desc *desc)
@@ -893,7 +893,8 @@ static netdev_tx_t eth_xmit(struct sk_buff *skb, struct net_device *dev)
port->tx_buff_tab[n] = mem;
#endif
desc->data = phys + offset;
- desc->buf_len = desc->pkt_len = len;
+ desc->buf_len = len;
+ desc->pkt_len = len;

/* NPE firmware pads short frames with zeros internally */
wmb();
@@ -941,7 +942,7 @@ static void eth_set_mcast_list(struct net_device *dev)
__raw_writel(allmulti[i], &port->regs->mcast_mask[i]);
}
__raw_writel(DEFAULT_RX_CNTRL0 | RX_CNTRL0_ADDR_FLTR_EN,
- &port->regs->rx_control[0]);
+ &port->regs->rx_control[0]);
return;
}

@@ -1321,7 +1322,8 @@ static int eth_close(struct net_device *dev)
BUG_ON(n < 0);
desc = tx_desc_ptr(port, n);
phys = tx_desc_phys(port, n);
- desc->buf_len = desc->pkt_len = 1;
+ desc->buf_len = 1;
+ desc->pkt_len = 1;
wmb();
queue_put_desc(TX_QUEUE(port->id), phys, desc);
}
--
2.35.1

2022-10-05 13:02:25

by Corentin LABBE

[permalink] [raw]
Subject: [PATCH 2/4] net: ethernet: xscale: fix printk issues

Fix all checkpatch issues about printk and co.
Some pr_xx are replaced by netdev_xxx when appropriate.
Furthermore, there are lot of typo on netdev_debug instead of
netdev_dbg; since this is ifdef-ed debug code, no need for a fixes tag.

Signed-off-by: Corentin Labbe <[email protected]>
---
drivers/net/ethernet/xscale/ixp4xx_eth.c | 95 ++++++++++++------------
1 file changed, 46 insertions(+), 49 deletions(-)

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 71d36ff7cd1b..b4539dd2cfe4 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -462,7 +462,7 @@ static int ixp4xx_mdio_cmd(struct mii_bus *bus, int phy_id, int location,
int cycles = 0;

if (__raw_readl(&mdio_regs->mdio_command[3]) & 0x80) {
- printk(KERN_ERR "%s: MII not ready to transmit\n", bus->name);
+ pr_err("%s: MII not ready to transmit\n", bus->name);
return -1;
}

@@ -482,14 +482,13 @@ static int ixp4xx_mdio_cmd(struct mii_bus *bus, int phy_id, int location,
}

if (cycles == MAX_MDIO_RETRIES) {
- printk(KERN_ERR "%s #%i: MII write failed\n", bus->name,
- phy_id);
+ pr_err("%s #%i: MII write failed\n", bus->name, phy_id);
return -1;
}

#if DEBUG_MDIO
- printk(KERN_DEBUG "%s #%i: mdio_%s() took %i cycles\n", bus->name,
- phy_id, write ? "write" : "read", cycles);
+ pr_debug("%s #%i: mdio_%s() took %i cycles\n", bus->name,
+ phy_id, write ? "write" : "read", cycles);
#endif

if (write)
@@ -497,8 +496,7 @@ static int ixp4xx_mdio_cmd(struct mii_bus *bus, int phy_id, int location,

if (__raw_readl(&mdio_regs->mdio_status[3]) & 0x80) {
#if DEBUG_MDIO
- printk(KERN_DEBUG "%s #%i: MII read failed\n", bus->name,
- phy_id);
+ pr_debug("%s #%i: MII read failed\n", bus->name, phy_id);
#endif
return 0xFFFF; /* don't return error */
}
@@ -516,8 +514,8 @@ static int ixp4xx_mdio_read(struct mii_bus *bus, int phy_id, int location)
ret = ixp4xx_mdio_cmd(bus, phy_id, location, 0, 0);
spin_unlock_irqrestore(&mdio_lock, flags);
#if DEBUG_MDIO
- printk(KERN_DEBUG "%s #%i: MII read [%i] -> 0x%X\n", bus->name,
- phy_id, location, ret);
+ pr_debug("%s #%i: MII read [%i] -> 0x%X\n", bus->name, phy_id,
+ location, ret);
#endif
return ret;
}
@@ -532,8 +530,8 @@ static int ixp4xx_mdio_write(struct mii_bus *bus, int phy_id, int location,
ret = ixp4xx_mdio_cmd(bus, phy_id, location, 1, val);
spin_unlock_irqrestore(&mdio_lock, flags);
#if DEBUG_MDIO
- printk(KERN_DEBUG "%s #%i: MII write [%i] <- 0x%X, err = %i\n",
- bus->name, phy_id, location, val, ret);
+ pr_debug("%s #%i: MII write [%i] <- 0x%X, err = %i\n", bus->name,
+ phy_id, location, val, ret);
#endif
return ret;
}
@@ -572,7 +570,7 @@ static void ixp4xx_adjust_link(struct net_device *dev)
if (!phydev->link) {
if (port->speed) {
port->speed = 0;
- printk(KERN_INFO "%s: link down\n", dev->name);
+ netdev_info(dev, "link down\n");
}
return;
}
@@ -590,8 +588,8 @@ static void ixp4xx_adjust_link(struct net_device *dev)
__raw_writel(DEFAULT_TX_CNTRL0 | TX_CNTRL0_HALFDUPLEX,
&port->regs->tx_control[0]);

- netdev_info(dev, "%s: link up, speed %u Mb/s, %s duplex\n",
- dev->name, port->speed, port->duplex ? "full" : "half");
+ netdev_info(dev, "link up, speed %u Mb/s, %s duplex\n",
+ port->speed, port->duplex ? "full" : "half");
}

static inline void debug_pkt(struct net_device *dev, const char *func,
@@ -600,30 +598,30 @@ static inline void debug_pkt(struct net_device *dev, const char *func,
#if DEBUG_PKT_BYTES
int i;

- netdev_debug(dev, "%s(%i) ", func, len);
+ netdev_dbg(dev, "%s(%i) ", func, len);
for (i = 0; i < len; i++) {
if (i >= DEBUG_PKT_BYTES)
break;
- printk("%s%02X",
- ((i == 6) || (i == 12) || (i >= 14)) ? " " : "",
- data[i]);
+ netdev_dbg(dev, "%s%02X",
+ ((i == 6) || (i == 12) || (i >= 14)) ? " " : "",
+ data[i]);
}
- printk("\n");
+ netdev_dbg(dev, "\n");
#endif
}

static inline void debug_desc(u32 phys, struct desc *desc)
{
#if DEBUG_DESC
- printk(KERN_DEBUG "%X: %X %3X %3X %08X %2X < %2X %4X %X"
- " %X %X %02X%02X%02X%02X%02X%02X < %02X%02X%02X%02X%02X%02X\n",
- phys, desc->next, desc->buf_len, desc->pkt_len,
- desc->data, desc->dest_id, desc->src_id, desc->flags,
- desc->qos, desc->padlen, desc->vlan_tci,
- desc->dst_mac_0, desc->dst_mac_1, desc->dst_mac_2,
- desc->dst_mac_3, desc->dst_mac_4, desc->dst_mac_5,
- desc->src_mac_0, desc->src_mac_1, desc->src_mac_2,
- desc->src_mac_3, desc->src_mac_4, desc->src_mac_5);
+ pr_debug("%X: %X %3X %3X %08X %2X < %2X %4X %X"
+ " %X %X %02X%02X%02X%02X%02X%02X < %02X%02X%02X%02X%02X%02X\n",
+ phys, desc->next, desc->buf_len, desc->pkt_len,
+ desc->data, desc->dest_id, desc->src_id, desc->flags,
+ desc->qos, desc->padlen, desc->vlan_tci,
+ desc->dst_mac_0, desc->dst_mac_1, desc->dst_mac_2,
+ desc->dst_mac_3, desc->dst_mac_4, desc->dst_mac_5,
+ desc->src_mac_0, desc->src_mac_1, desc->src_mac_2,
+ desc->src_mac_3, desc->src_mac_4, desc->src_mac_5);
#endif
}

@@ -674,7 +672,7 @@ static void eth_rx_irq(void *pdev)
struct port *port = netdev_priv(dev);

#if DEBUG_RX
- printk(KERN_DEBUG "%s: eth_rx_irq\n", dev->name);
+ netdev_dbg(dev, "%s\n", __func__);
#endif
qmgr_disable_irq(port->plat->rxq);
napi_schedule(&port->napi);
@@ -688,7 +686,7 @@ static int eth_poll(struct napi_struct *napi, int budget)
int received = 0;

#if DEBUG_RX
- netdev_debug(dev, "eth_poll\n");
+ netdev_dbg(dev, "%s\n", __func__);
#endif

while (received < budget) {
@@ -702,20 +700,21 @@ static int eth_poll(struct napi_struct *napi, int budget)

if ((n = queue_get_desc(rxq, port, 0)) < 0) {
#if DEBUG_RX
- netdev_debug(dev, "eth_poll napi_complete\n");
+ netdev_dbg(dev, "%s napi_complete\n", __func__);
#endif
napi_complete(napi);
qmgr_enable_irq(rxq);
if (!qmgr_stat_below_low_watermark(rxq) &&
napi_reschedule(napi)) { /* not empty again */
#if DEBUG_RX
- netdev_debug(dev, "eth_poll napi_reschedule succeeded\n");
+ netdev_dbg(dev, "%s napi_reschedule succeeded\n",
+ __func__);
#endif
qmgr_disable_irq(rxq);
continue;
}
#if DEBUG_RX
- netdev_debug(dev, "eth_poll all done\n");
+ netdev_dbg(dev, "%s all done\n", __func__);
#endif
return received; /* all work done */
}
@@ -760,7 +759,7 @@ static int eth_poll(struct napi_struct *napi, int budget)
skb_reserve(skb, NET_IP_ALIGN);
skb_put(skb, desc->pkt_len);

- debug_pkt(dev, "eth_poll", skb->data, skb->len);
+ debug_pkt(dev, __func__, skb->data, skb->len);

ixp_rx_timestamp(port, skb);
skb->protocol = eth_type_trans(skb, dev);
@@ -780,7 +779,7 @@ static int eth_poll(struct napi_struct *napi, int budget)
}

#if DEBUG_RX
- netdev_debug(dev, "eth_poll(): end, not all work done\n");
+ netdev_dbg(dev, "%s: end, not all work done\n", __func__);
#endif
return received; /* not all work done */
}
@@ -790,7 +789,7 @@ static void eth_txdone_irq(void *unused)
u32 phys;

#if DEBUG_TX
- printk(KERN_DEBUG DRV_NAME ": eth_txdone_irq\n");
+ pr_debug(DRV_NAME ": %s\n", __func__);
#endif
while ((phys = qmgr_get_entry(TXDONE_QUEUE)) != 0) {
u32 npe_id, n_desc;
@@ -814,8 +813,8 @@ static void eth_txdone_irq(void *unused)

dma_unmap_tx(port, desc);
#if DEBUG_TX
- printk(KERN_DEBUG "%s: eth_txdone_irq free %p\n",
- port->netdev->name, port->tx_buff_tab[n_desc]);
+ netdev_dbg(port->netdev, "%s free %p\n", __func__,
+ port->tx_buff_tab[n_desc]);
#endif
free_buffer_irq(port->tx_buff_tab[n_desc]);
port->tx_buff_tab[n_desc] = NULL;
@@ -825,8 +824,7 @@ static void eth_txdone_irq(void *unused)
queue_put_desc(port->plat->txreadyq, phys, desc);
if (start) { /* TX-ready queue was empty */
#if DEBUG_TX
- printk(KERN_DEBUG "%s: eth_txdone_irq xmit ready\n",
- port->netdev->name);
+ netdev_dbg(port->netdev, "%s xmit ready\n", __func__);
#endif
netif_wake_queue(port->netdev);
}
@@ -843,7 +841,7 @@ static netdev_tx_t eth_xmit(struct sk_buff *skb, struct net_device *dev)
struct desc *desc;

#if DEBUG_TX
- netdev_debug(dev, "eth_xmit\n");
+ netdev_dbg(dev, "%s\n", __func__);
#endif

if (unlikely(skb->len > MAX_MRU)) {
@@ -852,7 +850,7 @@ static netdev_tx_t eth_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK;
}

- debug_pkt(dev, "eth_xmit", skb->data, skb->len);
+ debug_pkt(dev, __func__, skb->data, skb->len);

len = skb->len;
#ifdef __ARMEB__
@@ -898,21 +896,21 @@ static netdev_tx_t eth_xmit(struct sk_buff *skb, struct net_device *dev)

if (qmgr_stat_below_low_watermark(txreadyq)) { /* empty */
#if DEBUG_TX
- netdev_debug(dev, "eth_xmit queue full\n");
+ netdev_dbg(dev, "%s queue full\n", __func__);
#endif
netif_stop_queue(dev);
/* we could miss TX ready interrupt */
/* really empty in fact */
if (!qmgr_stat_below_low_watermark(txreadyq)) {
#if DEBUG_TX
- netdev_debug(dev, "eth_xmit ready again\n");
+ netdev_dbg(dev, "%s ready again\n", __func__);
#endif
netif_wake_queue(dev);
}
}

#if DEBUG_TX
- netdev_debug(dev, "eth_xmit end\n");
+ netdev_dbg(dev, "%s end\n", __func__);
#endif

ixp_tx_timestamp(port, skb);
@@ -1077,8 +1075,7 @@ static int request_queues(struct port *port)
qmgr_release_queue(port->plat->rxq);
rel_rxfree:
qmgr_release_queue(RXFREE_QUEUE(port->id));
- printk(KERN_DEBUG "%s: unable to request hardware queues\n",
- port->netdev->name);
+ netdev_dbg(port->netdev, "unable to request hardware queues\n");
return err;
}

@@ -1327,7 +1324,7 @@ static int eth_close(struct net_device *dev)
" left in NPE\n", buffs);
#if DEBUG_CLOSE
if (!buffs)
- netdev_debug(dev, "draining RX queue took %i cycles\n", i);
+ netdev_dbg(dev, "draining RX queue took %i cycles\n", i);
#endif

buffs = TX_DESCS;
@@ -1347,7 +1344,7 @@ static int eth_close(struct net_device *dev)
"left in NPE\n", buffs);
#if DEBUG_CLOSE
if (!buffs)
- netdev_debug(dev, "draining TX queues took %i cycles\n", i);
+ netdev_dbg(dev, "draining TX queues took %i cycles\n", i);
#endif

msg.byte3 = 0;
--
2.35.1

2022-10-06 03:49:22

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH 1/4] net: ethernet: xscale: fix space style issues

On Wed, 5 Oct 2022 12:04:58 +0000 Corentin Labbe wrote:
> Fix all checkpatch issue about space/newlines.

We don't take checkpatch "cleanups", especially for fossils.

2022-10-06 05:09:00

by Corentin LABBE

[permalink] [raw]
Subject: Re: [PATCH 1/4] net: ethernet: xscale: fix space style issues

Le Wed, Oct 05, 2022 at 08:35:45PM -0700, Jakub Kicinski a ?crit :
> On Wed, 5 Oct 2022 12:04:58 +0000 Corentin Labbe wrote:
> > Fix all checkpatch issue about space/newlines.
>
> We don't take checkpatch "cleanups", especially for fossils.

Hello

The difference with classic checkpatch is that I have tested it.
And the patch #2 fixes the bad netdev_debug().

Regards

2022-10-06 15:18:31

by Jakub Kicinski

[permalink] [raw]
Subject: Re: [PATCH 1/4] net: ethernet: xscale: fix space style issues

On Thu, 6 Oct 2022 06:40:31 +0200 LABBE Corentin wrote:
> The difference with classic checkpatch is that I have tested it.

If you make some material changes to the driver I'd reconsider,
otherwise I'd strongly prefer to stick to the general policy.

> And the patch #2 fixes the bad netdev_debug().

Please isolate that from the noise and send it separately
(after net-next opens).