[PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach

Philipp Stanner posted 4 patches 9 months, 3 weeks ago
There is a newer version of this series
[PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
Posted by Philipp Stanner 9 months, 3 weeks ago
Functions 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.

Signed-off-by: Philipp Stanner <phasta@kernel.org>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c |  7 -------
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c     | 10 ----------
 2 files changed, 17 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index e3cacd085b3f..f3ea6016be68 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -614,13 +614,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);
 }
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 352b01678c22..91ff6c15f977 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -227,20 +227,10 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
  *
  * @pdev: platform device pointer
  * Description: this function calls the main to free the net resources
- * and releases the PCI 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)
-- 
2.48.1
Re: [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
Posted by Yanteng Si 9 months, 3 weeks ago
在 2/24/25 9:53 PM, Philipp Stanner 写道:
> Functions 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.
>
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> ---
>   drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c |  7 -------
>   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c     | 10 ----------
>   2 files changed, 17 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> index e3cacd085b3f..f3ea6016be68 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> @@ -614,13 +614,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);
>   }
>   
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> index 352b01678c22..91ff6c15f977 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> @@ -227,20 +227,10 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
>    *
>    * @pdev: platform device pointer

>    * Description: this function calls the main to free the net resources

There is a missing full stop. You commented on the next email,

and it seems that you are already preparing for v4.  With this


Reviewed-by: Yanteng Si <si.yanteng@linux.dev>

Thanks,
Yanteng

> - * and releases the PCI 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)
Re: [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
Posted by Huacai Chen 9 months, 3 weeks ago
On Tue, Feb 25, 2025 at 5:11 PM Yanteng Si <si.yanteng@linux.dev> wrote:
>
>
> 在 2/24/25 9:53 PM, Philipp Stanner 写道:
> > Functions 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.
> >
> > Signed-off-by: Philipp Stanner <phasta@kernel.org>
> > ---
> >   drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c |  7 -------
> >   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c     | 10 ----------
> >   2 files changed, 17 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > index e3cacd085b3f..f3ea6016be68 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
> > @@ -614,13 +614,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);
> >   }
> >
> > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > index 352b01678c22..91ff6c15f977 100644
> > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
> > @@ -227,20 +227,10 @@ static int stmmac_pci_probe(struct pci_dev *pdev,
> >    *
> >    * @pdev: platform device pointer
>
> >    * Description: this function calls the main to free the net resources
>
> There is a missing full stop. You commented on the next email,
>
> and it seems that you are already preparing for v4.  With this
>
>
> Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Reviewed-by: Huacai Chen <chenhuacai@loongson.cn>

>
> Thanks,
> Yanteng
>
> > - * and releases the PCI 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)
Re: [PATCH net-next v3 3/4] stmmac: Remove pcim_* functions for driver detach
Posted by Andrew Lunn 9 months, 3 weeks ago
On Mon, Feb 24, 2025 at 02:53:21PM +0100, Philipp Stanner wrote:
> Functions 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.
> 
> Signed-off-by: Philipp Stanner <phasta@kernel.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew