Re: [PATCH net-next v3 3/6] net: bcmasp: Add support for ASP2.0 Ethernet controller

From: Simon Horman
Date: Mon May 22 2023 - 07:35:35 EST


On Fri, May 19, 2023 at 02:19:41PM -0700, Justin Chen wrote:
> Add support for the Broadcom ASP 2.0 Ethernet controller which is first
> introduced with 72165. This controller features two distinct Ethernet
> ports that can be independently operated.
>
> This patch supports:
>
> - Wake-on-LAN using magic packets
> - basic ethtool operations (link, counters, message level)
> - MAC destination address filtering (promiscuous, ALL_MULTI, etc.)
>
> Signed-off-by: Florian Fainelli <florian.fainelli@xxxxxxxxxxxx>
> Signed-off-by: Justin Chen <justin.chen@xxxxxxxxxxxx>

...

> +static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev)
> +{
> + struct bcmasp_intf *intf = netdev_priv(dev);
> + struct device *kdev = &intf->parent->pdev->dev;
> + int spb_index, nr_frags, ret, i, j;
> + unsigned int total_bytes, size;
> + struct bcmasp_tx_cb *txcb;
> + dma_addr_t mapping, valid;
> + struct bcmasp_desc *desc;
> + bool csum_hw = false;
> + skb_frag_t *frag;

Hi Justin,

Please use reverse xmas tree order - lognest line to shortest - for local
variables, even in cases of assignment such as this one.

In this case I would suggest splitting the declarations and assignment
of kdev. Something line this:

struct bcmasp_intf *intf = netdev_priv(dev);
int spb_index, nr_frags, ret, i, j;
unsigned int total_bytes, size;
struct bcmasp_tx_cb *txcb;
dma_addr_t mapping, valid;
struct bcmasp_desc *desc;
bool csum_hw = false;
struct device *kdev;
skb_frag_t *frag;

kdev = &intf->parent->pdev->dev;

...