Skip to content

Commit 60ed96b

Browse files
author
Paolo Abeni
committed
Merge branch 'fix-ti-am65-cpsw-nuss-module-removal'
Nicolas Pitre says: ==================== fix ti-am65-cpsw-nuss module removal Fix issues preventing rmmod of ti-am65-cpsw-nuss from working properly. v3: - more patch submission minutiae v2: https://lore.kernel.org/netdev/[email protected]/T/ - conform to netdev patch submission customs - address patch review trivias v1: https://lore.kernel.org/netdev/[email protected]/T/ ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents 3dc6e99 + 03c96bc commit 60ed96b

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

drivers/net/ethernet/ti/am65-cpsw-nuss.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2744,10 +2744,9 @@ am65_cpsw_nuss_init_port_ndev(struct am65_cpsw_common *common, u32 port_idx)
27442744
return 0;
27452745

27462746
/* alloc netdev */
2747-
port->ndev = devm_alloc_etherdev_mqs(common->dev,
2748-
sizeof(struct am65_cpsw_ndev_priv),
2749-
AM65_CPSW_MAX_QUEUES,
2750-
AM65_CPSW_MAX_QUEUES);
2747+
port->ndev = alloc_etherdev_mqs(sizeof(struct am65_cpsw_ndev_priv),
2748+
AM65_CPSW_MAX_QUEUES,
2749+
AM65_CPSW_MAX_QUEUES);
27512750
if (!port->ndev) {
27522751
dev_err(dev, "error allocating slave net_device %u\n",
27532752
port->port_id);
@@ -2868,8 +2867,12 @@ static void am65_cpsw_nuss_cleanup_ndev(struct am65_cpsw_common *common)
28682867

28692868
for (i = 0; i < common->port_num; i++) {
28702869
port = &common->ports[i];
2871-
if (port->ndev && port->ndev->reg_state == NETREG_REGISTERED)
2870+
if (!port->ndev)
2871+
continue;
2872+
if (port->ndev->reg_state == NETREG_REGISTERED)
28722873
unregister_netdev(port->ndev);
2874+
free_netdev(port->ndev);
2875+
port->ndev = NULL;
28732876
}
28742877
}
28752878

@@ -3613,16 +3616,17 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
36133616

36143617
ret = am65_cpsw_nuss_init_ndevs(common);
36153618
if (ret)
3616-
goto err_free_phylink;
3619+
goto err_ndevs_clear;
36173620

36183621
ret = am65_cpsw_nuss_register_ndevs(common);
36193622
if (ret)
3620-
goto err_free_phylink;
3623+
goto err_ndevs_clear;
36213624

36223625
pm_runtime_put(dev);
36233626
return 0;
36243627

3625-
err_free_phylink:
3628+
err_ndevs_clear:
3629+
am65_cpsw_nuss_cleanup_ndev(common);
36263630
am65_cpsw_nuss_phylink_cleanup(common);
36273631
am65_cpts_release(common->cpts);
36283632
err_of_clear:
@@ -3652,13 +3656,13 @@ static void am65_cpsw_nuss_remove(struct platform_device *pdev)
36523656
return;
36533657
}
36543658

3655-
am65_cpsw_unregister_devlink(common);
36563659
am65_cpsw_unregister_notifiers(common);
36573660

36583661
/* must unregister ndevs here because DD release_driver routine calls
36593662
* dma_deconfigure(dev) before devres_release_all(dev)
36603663
*/
36613664
am65_cpsw_nuss_cleanup_ndev(common);
3665+
am65_cpsw_unregister_devlink(common);
36623666
am65_cpsw_nuss_phylink_cleanup(common);
36633667
am65_cpts_release(common->cpts);
36643668
am65_cpsw_disable_serdes_phy(common);

0 commit comments

Comments
 (0)