diff mbox series

[rdma-next,v2,3/5] RDMA/bnxt_re: Get rid of custom module reference counting

Message ID 20210401065715.565226-4-leon@kernel.org
State New
Headers show
Series Get rid of custom made module dependency | expand

Commit Message

Leon Romanovsky April 1, 2021, 6:57 a.m. UTC
From: Leon Romanovsky <leonro@nvidia.com>

Instead of manually messing with parent driver module reference
counting rely on export symbol mechanism to ensure that proper
probe/remove chain is performed.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 drivers/infiniband/hw/bnxt_re/main.c | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

Comments

Devesh Sharma April 21, 2021, 5:52 p.m. UTC | #1
On Thu, Apr 1, 2021 at 12:27 PM Leon Romanovsky <leon@kernel.org> wrote:
>

> From: Leon Romanovsky <leonro@nvidia.com>

>

> Instead of manually messing with parent driver module reference

> counting rely on export symbol mechanism to ensure that proper

> probe/remove chain is performed.

>

> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

> ---

>  drivers/infiniband/hw/bnxt_re/main.c | 16 ++--------------

>  1 file changed, 2 insertions(+), 14 deletions(-)

>

> diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c

> index 140c54ee5916..8bfbf0231a9e 100644

> --- a/drivers/infiniband/hw/bnxt_re/main.c

> +++ b/drivers/infiniband/hw/bnxt_re/main.c

> @@ -601,13 +601,6 @@ static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev)

>         return container_of(ibdev, struct bnxt_re_dev, ibdev);

>  }

>

> -static void bnxt_re_dev_unprobe(struct net_device *netdev,

> -                               struct bnxt_en_dev *en_dev)

> -{

> -       dev_put(netdev);

> -       module_put(en_dev->pdev->driver->driver.owner);

> -}

> -

>  static struct bnxt_en_dev *bnxt_re_dev_probe(struct net_device *netdev)

>  {

>         struct bnxt_en_dev *en_dev;

> @@ -628,10 +621,6 @@ static struct bnxt_en_dev *bnxt_re_dev_probe(struct net_device *netdev)

>                 return ERR_PTR(-ENODEV);

>         }

>

> -       /* Bump net device reference count */

> -       if (!try_module_get(pdev->driver->driver.owner))

> -               return ERR_PTR(-ENODEV);

> -

>         dev_hold(netdev);

>

>         return en_dev;

> @@ -1558,13 +1547,12 @@ static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 wqe_mode)

>

>  static void bnxt_re_dev_unreg(struct bnxt_re_dev *rdev)

>  {

> -       struct bnxt_en_dev *en_dev = rdev->en_dev;

>         struct net_device *netdev = rdev->netdev;

>

>         bnxt_re_dev_remove(rdev);

>

>         if (netdev)

> -               bnxt_re_dev_unprobe(netdev, en_dev);

> +               dev_put(netdev);

>  }

>

>  static int bnxt_re_dev_reg(struct bnxt_re_dev **rdev, struct net_device *netdev)

> @@ -1586,7 +1574,7 @@ static int bnxt_re_dev_reg(struct bnxt_re_dev **rdev, struct net_device *netdev)

>         *rdev = bnxt_re_dev_add(netdev, en_dev);

>         if (!*rdev) {

>                 rc = -ENOMEM;

> -               bnxt_re_dev_unprobe(netdev, en_dev);

> +               dev_put(netdev);

>                 goto exit;

>         }

>  exit:


Acked-By: Devesh Sharma <devesh.sharma@broadcom.com>

> --

> 2.30.2

>



-- 
-Regards
Devesh
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/bnxt_re/main.c b/drivers/infiniband/hw/bnxt_re/main.c
index 140c54ee5916..8bfbf0231a9e 100644
--- a/drivers/infiniband/hw/bnxt_re/main.c
+++ b/drivers/infiniband/hw/bnxt_re/main.c
@@ -601,13 +601,6 @@  static struct bnxt_re_dev *bnxt_re_from_netdev(struct net_device *netdev)
 	return container_of(ibdev, struct bnxt_re_dev, ibdev);
 }
 
-static void bnxt_re_dev_unprobe(struct net_device *netdev,
-				struct bnxt_en_dev *en_dev)
-{
-	dev_put(netdev);
-	module_put(en_dev->pdev->driver->driver.owner);
-}
-
 static struct bnxt_en_dev *bnxt_re_dev_probe(struct net_device *netdev)
 {
 	struct bnxt_en_dev *en_dev;
@@ -628,10 +621,6 @@  static struct bnxt_en_dev *bnxt_re_dev_probe(struct net_device *netdev)
 		return ERR_PTR(-ENODEV);
 	}
 
-	/* Bump net device reference count */
-	if (!try_module_get(pdev->driver->driver.owner))
-		return ERR_PTR(-ENODEV);
-
 	dev_hold(netdev);
 
 	return en_dev;
@@ -1558,13 +1547,12 @@  static int bnxt_re_dev_init(struct bnxt_re_dev *rdev, u8 wqe_mode)
 
 static void bnxt_re_dev_unreg(struct bnxt_re_dev *rdev)
 {
-	struct bnxt_en_dev *en_dev = rdev->en_dev;
 	struct net_device *netdev = rdev->netdev;
 
 	bnxt_re_dev_remove(rdev);
 
 	if (netdev)
-		bnxt_re_dev_unprobe(netdev, en_dev);
+		dev_put(netdev);
 }
 
 static int bnxt_re_dev_reg(struct bnxt_re_dev **rdev, struct net_device *netdev)
@@ -1586,7 +1574,7 @@  static int bnxt_re_dev_reg(struct bnxt_re_dev **rdev, struct net_device *netdev)
 	*rdev = bnxt_re_dev_add(netdev, en_dev);
 	if (!*rdev) {
 		rc = -ENOMEM;
-		bnxt_re_dev_unprobe(netdev, en_dev);
+		dev_put(netdev);
 		goto exit;
 	}
 exit: