mirror of
https://github.com/torvalds/linux.git
synced 2024-12-13 22:53:20 +00:00
RDMA/bnxt_re: Get rid of custom module reference counting
Instead of manually messing with parent driver module reference counting rely on export symbol mechanism to ensure that proper probe/remove chain is performed. Link: https://lore.kernel.org/r/20210401065715.565226-4-leon@kernel.org Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Acked-By: Devesh Sharma <devesh.sharma@broadcom.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
This commit is contained in:
parent
bcf9ee0520
commit
1900357e75
@ -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 @@ fail:
|
||||
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user