Re: [PATCH v2 net-next 4/9] net: ethernet: mtk_eth_soc: increase MAX_DEVS to 3

From: Russell King (Oracle)
Date: Thu Jul 13 2023 - 03:08:08 EST


On Thu, Jul 13, 2023 at 03:18:52AM +0100, Daniel Golle wrote:
> From: Lorenzo Bianconi <lorenzo@xxxxxxxxxx>
>
> This is a preliminary patch to add MT7988 SoC support since it runs 3
> macs instead of 2.
>
> Signed-off-by: Lorenzo Bianconi <lorenzo@xxxxxxxxxx>
> Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
> ---
> drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 +++++-
> drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++--
> 2 files changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> index 7014e0d108b27..7f191e4337dd8 100644
> --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
> @@ -4030,8 +4030,12 @@ static void mtk_sgmii_destroy(struct mtk_eth *eth)
> {
> int i;
>
> - for (i = 0; i < MTK_MAX_DEVS; i++)
> + for (i = 0; i < MTK_MAX_DEVS; i++) {
> + if (!eth->sgmii_pcs[i])
> + continue;
> +
> mtk_pcs_lynxi_destroy(eth->sgmii_pcs[i]);
> + }

Please instead arrange for mtk_pcs_lynxi_destroy() to be a no-op if it's
passed a NULL pointer, which makes it easier to use in error paths (it
means mtk_pcs_lynxi_destroy() can be called without checks - like
kfree() etc.)

Since error paths don't get often tested, we need to do as much as
possible to make error paths trivial.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!