stmmac: Several PCI-related improvements
Subsystems (4)
v4 cover stmmac: Several PCI-related improvements
Resend of v4, rebased onto net-next due to a merge conflict.
Changes in v4:
- Add missing full stop. (Yanteng)
- Move forgotten unused-variable-removes to the appropriate places.
- Add applicable RB / TB tags
Changes in v3:
- Several formatting nits (Paolo)
- Split up patch into a patch series (Yanteng)
Philipp Stanner (3):
stmmac: loongson: Remove surplus loop
stmmac: Remove pcim_* functions for driver detach
stmmac: Replace deprecated PCI functions
.../ethernet/stmicro/stmmac/dwmac-loongson.c | 27 +++++-------------- .../net/ethernet/stmicro/stmmac/stmmac_pci.c | 24 +++++------------ 2 files changed, 12 insertions(+), 39 deletions(-)
Signature · 1 line
2.48.1
PATCH v4 1/3 stmmac: loongson: Remove surplus loop
loongson_dwmac_probe() contains a loop which doesn't have an effect, because it tries to call pcim_iomap_regions() with the same parameters several times. The break statement at the loop's end furthermore ensures that the loop only runs once anyways.
Remove the surplus loop.
--- .../net/ethernet/stmicro/stmmac/dwmac-loongson.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +4 -9
@@ -536,7 +536,7 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_idstruct stmmac_pci_info *info;struct stmmac_resources res;struct loongson_data *ld; -int ret, i; +int ret; plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL );if (!plat)
@@ -566,14 +566,9 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_idpci_set_master (pdev);/* Get the base address of device */ -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; - ret =pcim_iomap_regions (pdev,BIT (0 ),DRIVER_NAME ); -if (ret) - goto err_disable_device; -break ; - } + ret =pcim_iomap_regions (pdev,BIT (0 ),DRIVER_NAME ); +if (ret) + goto err_disable_device;memset (&res,0 ,sizeof (res)); res.addr =pcim_iomap_table (pdev)[0 ];
Signature · 1 line
2.48.1
PATCH v4 2/3 stmmac: Remove pcim_* functions for driver detach
In reply to Philipp StannerFunctions prefixed with "pcim_" are managed devres functions which perform automatic cleanup once the driver unloads. It is, thus, not necessary to call any cleanup functions in remove() callbacks.
Remove the pcim_ cleanup function calls in the remove() callbacks.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 8 -------- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 12 +----------- 2 files changed, 1 insertion(+), 19 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +0 -8
@@ -619,7 +619,6 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)struct net_device *ndev =dev_get_drvdata (&pdev->dev);struct stmmac_priv *priv =netdev_priv (ndev);struct loongson_data *ld; -int i; ld = priv->plat->bsp_priv;stmmac_dvr_remove (&pdev->dev);
@@ -630,13 +629,6 @@ static void loongson_dwmac_remove(struct pci_dev *pdev)if (ld->loongson_id ==DWMAC_CORE_LS_MULTICHAN )loongson_dwmac_msi_clear (pdev); -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; -pcim_iounmap_regions (pdev,BIT (i)); -break ; - } -pci_disable_device (pdev); }
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +1 -11
@@ -226,21 +226,11 @@ static int stmmac_pci_probe(struct pci_dev *pdev,* stmmac_pci_remove * * @pdev: platform device pointer -* Description: this function calls the main to free the net resources -* and releases the PCI resources. +* Description: this function calls the main to free the net resources. */ static void stmmac_pci_remove (struct pci_dev *pdev) { -int i; -stmmac_dvr_remove (&pdev->dev); - -for (i =0 ; i <PCI_STD_NUM_BARS ; i++) { -if (pci_resource_len (pdev, i) ==0 ) -continue ; -pcim_iounmap_regions (pdev,BIT (i)); -break ; - } }static int __maybe_unused stmmac_pci_suspend (struct device *dev)
Signature · 1 line
2.48.1
PATCH v4 3/3 stmmac: Replace deprecated PCI functions
In reply to Philipp StannerThe PCI functions
- pcim_iomap_regions() and
- pcim_iomap_table()
have been deprecated.
Replace them with their successor function, pcim_iomap_region().
Make variable declaration order at closeby places comply with reverse christmas tree order.
--- drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c | 8 +++----- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 12 +++++------- 2 files changed, 8 insertions(+), 12 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c +3 -5
@@ -533,8 +533,8 @@ static int loongson_dwmac_fix_reset(void *priv, void __iomem *ioaddr)static int loongson_dwmac_probe (struct pci_dev *pdev,const struct pci_device_id *id) {struct plat_stmmacenet_data *plat; +struct stmmac_resources res = {};struct stmmac_pci_info *info; -struct stmmac_resources res;struct loongson_data *ld;int ret;
@@ -566,13 +566,11 @@ static int loongson_dwmac_probe(struct pci_dev *pdev, const struct pci_device_idpci_set_master (pdev);/* Get the base address of device */ - ret =pcim_iomap_regions (pdev,BIT (0 ),DRIVER_NAME ); + res.addr =pcim_iomap_region (pdev,0 ,DRIVER_NAME ); + ret =PTR_ERR_OR_ZERO (res.addr);if (ret) goto err_disable_device; -memset (&res,0 ,sizeof (res)); - res.addr =pcim_iomap_table (pdev)[0 ]; - plat->bsp_priv = ld; plat->setup = loongson_dwmac_setup; plat->fix_soc_reset = loongson_dwmac_fix_reset;
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c +5 -7
@@ -155,9 +155,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev, {struct stmmac_pci_info *info = (struct stmmac_pci_info *)id->driver_data;struct plat_stmmacenet_data *plat; -struct stmmac_resources res; -int i; +struct stmmac_resources res = {};int ret; +int i; plat =devm_kzalloc (&pdev->dev,sizeof (*plat),GFP_KERNEL );if (!plat)
@@ -192,9 +192,9 @@ static int stmmac_pci_probe(struct pci_dev *pdev,for (i =0 ; i <PCI_STD_NUM_BARS ; i++) {if (pci_resource_len (pdev, i) ==0 )continue ; - ret =pcim_iomap_regions (pdev,BIT (i),pci_name (pdev)); -if (ret) -return ret; + res.addr =pcim_iomap_region (pdev, i,STMMAC_RESOURCE_NAME ); +if (IS_ERR (res.addr)) +return PTR_ERR (res.addr);break ; }
@@ -204,8 +204,6 @@ static int stmmac_pci_probe(struct pci_dev *pdev,if (ret)return ret; -memset (&res,0 ,sizeof (res)); - res.addr =pcim_iomap_table (pdev)[i]; res.wol_irq = pdev->irq; res.irq = pdev->irq;
Signature · 1 line
2.48.1
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Mon, 24 Mar 2025 10:29:26 +0100 you wrote:
Resend of v4, rebased onto net-next due to a merge conflict.
Changes in v4:
- Add missing full stop. (Yanteng)
- Move forgotten unused-variable-removes to the appropriate places.
- Add applicable RB / TB tags[...]
Here is the summary with links:
- [net-next,v4,1/3] stmmac: loongson: Remove surplus loop
https://git.kernel.org/netdev/net-next/c/9db2426a324e - [net-next,v4,2/3] stmmac: Remove pcim_* functions for driver detach https://git.kernel.org/netdev/net-next/c/d327a12e636e - [net-next,v4,3/3] stmmac: Replace deprecated PCI functions https://git.kernel.org/netdev/net-next/c/45b761689a28
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html