Re: [PATCH net-next 4/5] net: cortina: Add CS7542 CPU network datapath
From: Andrew Lunn
Date: Mon Nov 23 2026 - 17:24:57 EST
> +static bool internal_buf;
> +module_param(internal_buf, bool, 0444);
> +static int napi_budget = 16;
> +module_param(napi_budget, int, 0444);
No module parameters.
Also, this napi budget is lower than typical. Why?
> +
> +static inline u32 ni_rd(struct cs_ne *ne, u32 off)
> +{
> + return readl(ne->ni + off);
> +}
No inline functions in a .c file. Let the compiler decide.
> +static int cs_ne_open(struct net_device *ndev)
> +{
> + struct cs_ne_port *port = netdev_priv(ndev);
> + struct cs_ne *ne = port->ne;
> + unsigned long flags;
> + int ret;
> +
> + /* RTNL also protects the final probe activation. */
> + if (ne->rx_stopping)
> + return -ENODEV;
> + if (READ_ONCE(ne->txq.fault))
> + return -EIO;
> +
> + ret = phylink_of_phy_connect(port->phylink, port->np, 0);
> + if (ret) {
> + netdev_err(ndev, "phylink connect failed: %d\n", ret);
> + return ret;
> + }
> +
> + port->rd = ni_rd(ne, NI_CPUXRAM_CPU_CFG_RX(port->id)) & NI_XRAM_PTR_MASK;
> + napi_enable(&port->napi);
> + ret = request_irq(port->irq, cs_ne_rx_irq, 0, ndev->name, port);
> + if (ret) {
> + napi_disable(&port->napi);
> + phylink_disconnect_phy(port->phylink);
> + return ret;
> + }
> + spin_lock_bh(&ne->txq.lock);
> + if (ne->txq.fault) {
> + spin_unlock_bh(&ne->txq.lock);
> + free_irq(port->irq, port);
> + napi_disable(&port->napi);
> + phylink_disconnect_phy(port->phylink);
> + return -EIO;
Please put cleanup at the end and use goto statements. That is the
general pattern in the kernel when there is more than one thing to
cleanup.
> + }
> + WRITE_ONCE(port->opened, true);
> + ne->txq.stopping = false;
I've not looked at the details, but such flags are often not
needed. They generally indicate there is not a full understanding of
the driver API. Please review them, and see if they are really needed.
Andrew