From 701109ad7aaf9900352a8cd192ba9029b7225b98 Mon Sep 17 00:00:00 2001 From: Sneh Shah Date: Thu, 29 Apr 2021 16:00:40 +0530 Subject: [PATCH 1/2] net: stmmac: Return from smmu platform remove and depopulate pdev Return from smmu pdev remove and depopulate pdev. Change-Id: I82ab6a8feebdc2eafa45019b5d3d754c6af99308 Signed-off-by: Sneh Shah --- drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index a7ef075dc115..87509204b9ca 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -1704,6 +1704,11 @@ static int qcom_ethqos_remove(struct platform_device *pdev) struct qcom_ethqos *ethqos; int ret; + if (of_device_is_compatible(pdev->dev.of_node, "qcom,emac-smmu-embedded")) { + of_platform_depopulate(&pdev->dev); + return 0; + } + ethqos = get_stmmac_bsp_priv(&pdev->dev); if (!ethqos) return -ENODEV; @@ -1720,6 +1725,9 @@ static int qcom_ethqos_remove(struct platform_device *pdev) emac_emb_smmu_exit(); ethqos_disable_regulators(ethqos); + platform_set_drvdata(pdev, NULL); + of_platform_depopulate(&pdev->dev); + return ret; } From 15a7538044dfc514e30d81e1155a2d71290752fd Mon Sep 17 00:00:00 2001 From: Sneh Shah Date: Thu, 29 Apr 2021 16:08:34 +0530 Subject: [PATCH 2/2] net: stmmac: cleanup and free the nodes and gpios setup in probe Cleanup debugfs, dev nodes and gpios on driver removal. Change-Id: Icd18103ef0d968edb9f2ab254321a14323dd1c5a Signed-off-by: Sneh Shah --- .../stmicro/stmmac/dwmac-qcom-ethqos.c | 19 +++++++++++++++++++ .../stmicro/stmmac/dwmac-qcom-ethqos.h | 1 + .../ethernet/stmicro/stmmac/dwmac-qcom-pps.c | 14 ++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c index 87509204b9ca..c6a3f12b595f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c @@ -1522,6 +1522,20 @@ fail: return -ENOMEM; } +static int ethqos_cleanup_debugfs(struct qcom_ethqos *ethqos) +{ + if (!ethqos) { + ETHQOSERR("Null Param"); + return -ENODEV; + } + + debugfs_remove_recursive(ethqos->debugfs_dir); + ethqos->debugfs_dir = NULL; + + ETHQOSDBG("debugfs Deleted Successfully"); + return 0; +} + static int qcom_ethqos_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -1722,6 +1736,11 @@ static int qcom_ethqos_remove(struct platform_device *pdev) if (phy_intr_en) cancel_work_sync(ðqos->emac_phy_work); + if (ethqos->emac_ver == EMAC_HW_v2_3_2_RG) + ethqos_remove_pps_dev(ethqos); + + ethqos_cleanup_debugfs(ethqos); + ethqos_free_gpios(ethqos); emac_emb_smmu_exit(); ethqos_disable_regulators(ethqos); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h index b3ef4ff72b65..ede766232674 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.h @@ -247,6 +247,7 @@ int create_pps_interrupt_device_node(dev_t *pps_dev_t, struct cdev **pps_cdev, struct class **pps_class, char *pps_dev_node_name); +int ethqos_remove_pps_dev(struct qcom_ethqos *ethqos); bool qcom_ethqos_is_phy_link_up(struct qcom_ethqos *ethqos); void *qcom_ethqos_get_priv(struct qcom_ethqos *ethqos); diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-pps.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-pps.c index 9914399eb383..b62a23702a1b 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-pps.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-pps.c @@ -453,3 +453,17 @@ fail_alloc_cdev: alloc_chrdev1_region_fail: return ret; } + +int ethqos_remove_pps_dev(struct qcom_ethqos *ethqos) +{ + device_destroy(ethqos->avb_class_a_class, ethqos->avb_class_a_dev_t); + class_destroy(ethqos->avb_class_a_class); + cdev_del(ethqos->avb_class_a_cdev); + unregister_chrdev_region(ethqos->avb_class_a_dev_t, 1); + + device_destroy(ethqos->avb_class_b_class, ethqos->avb_class_b_dev_t); + class_destroy(ethqos->avb_class_b_class); + cdev_del(ethqos->avb_class_b_cdev); + unregister_chrdev_region(ethqos->avb_class_b_dev_t, 1); + return 0; +}