Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: stmmac: clean up stmmac_reset()

stmmac_reset() takes the stmmac_priv and an ioaddr. It has one call
site, which passes the priv pointer, and dereferences priv for the
ioaddr.

stmmac_reset() then checks whether priv is NULL. If it was, the caller
would have oopsed. Remove the checks for NULL, and move the dereference
for ioaddr into stmmac_reset().

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Link: https://patch.msgid.link/E1vImWF-0000000DrIr-1fmn@rmk-PC.armlinux.org.uk
Signed-off-by: Paolo Abeni <pabeni@redhat.com>

authored by

Russell King (Oracle) and committed by
Paolo Abeni
d0af55df 9f07af1d

+5 -7
+3 -5
drivers/net/ethernet/stmicro/stmmac/hwif.c
··· 103 103 return 0; 104 104 } 105 105 106 - int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr) 106 + int stmmac_reset(struct stmmac_priv *priv) 107 107 { 108 - struct plat_stmmacenet_data *plat = priv ? priv->plat : NULL; 109 - 110 - if (!priv) 111 - return -EINVAL; 108 + struct plat_stmmacenet_data *plat = priv->plat; 109 + void __iomem *ioaddr = priv->ioaddr; 112 110 113 111 if (plat && plat->fix_soc_reset) 114 112 return plat->fix_soc_reset(priv, ioaddr);
+1 -1
drivers/net/ethernet/stmicro/stmmac/hwif.h
··· 698 698 #define GMAC_VERSION 0x00000020 /* GMAC CORE Version */ 699 699 #define GMAC4_VERSION 0x00000110 /* GMAC4+ CORE Version */ 700 700 701 - int stmmac_reset(struct stmmac_priv *priv, void __iomem *ioaddr); 701 + int stmmac_reset(struct stmmac_priv *priv); 702 702 int stmmac_hwif_init(struct stmmac_priv *priv); 703 703 704 704 #endif /* __STMMAC_HWIF_H__ */
+1 -1
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 3162 3162 if (ret) 3163 3163 return ret; 3164 3164 3165 - ret = stmmac_reset(priv, priv->ioaddr); 3165 + ret = stmmac_reset(priv); 3166 3166 if (ret) { 3167 3167 netdev_err(priv->dev, "Failed to reset the dma\n"); 3168 3168 return ret;