Skip to content

Commit 5cf6c22

Browse files
author
Paolo Abeni
committed
Merge branch 'fix-cpts-release-action-in-am65-cpts-driver'
Siddharth Vadapalli says: ==================== Fix CPTS release action in am65-cpts driver Delete unreachable code in am65_cpsw_init_cpts() function, which was Reported-by: Leon Romanovsky <[email protected]> at: https://lore.kernel.org/r/Y8aHwSnVK9+sAb24@unreal Remove the devm action associated with am65_cpts_release() and invoke the function directly on the cleanup and exit paths. v4: https://lore.kernel.org/r/[email protected]/ v3: https://lore.kernel.org/r/[email protected]/ v2: https://lore.kernel.org/r/[email protected]/ v1: https://lore.kernel.org/r/[email protected]/ ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents d7bf56e + 4ad8766 commit 5cf6c22

File tree

3 files changed

+12
-15
lines changed

3 files changed

+12
-15
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,11 +1937,6 @@ static int am65_cpsw_init_cpts(struct am65_cpsw_common *common)
19371937
int ret = PTR_ERR(cpts);
19381938

19391939
of_node_put(node);
1940-
if (ret == -EOPNOTSUPP) {
1941-
dev_info(dev, "cpts disabled\n");
1942-
return 0;
1943-
}
1944-
19451940
dev_err(dev, "cpts create err %d\n", ret);
19461941
return ret;
19471942
}
@@ -2919,6 +2914,7 @@ static int am65_cpsw_nuss_probe(struct platform_device *pdev)
29192914

29202915
err_free_phylink:
29212916
am65_cpsw_nuss_phylink_cleanup(common);
2917+
am65_cpts_release(common->cpts);
29222918
err_of_clear:
29232919
of_platform_device_destroy(common->mdio_dev, NULL);
29242920
err_pm_clear:
@@ -2947,6 +2943,7 @@ static int am65_cpsw_nuss_remove(struct platform_device *pdev)
29472943
*/
29482944
am65_cpsw_nuss_cleanup_ndev(common);
29492945
am65_cpsw_nuss_phylink_cleanup(common);
2946+
am65_cpts_release(common->cpts);
29502947
am65_cpsw_disable_serdes_phy(common);
29512948

29522949
of_platform_device_destroy(common->mdio_dev, NULL);

drivers/net/ethernet/ti/am65-cpts.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,14 +1052,13 @@ static int am65_cpts_of_parse(struct am65_cpts *cpts, struct device_node *node)
10521052
return cpts_of_mux_clk_setup(cpts, node);
10531053
}
10541054

1055-
static void am65_cpts_release(void *data)
1055+
void am65_cpts_release(struct am65_cpts *cpts)
10561056
{
1057-
struct am65_cpts *cpts = data;
1058-
10591057
ptp_clock_unregister(cpts->ptp_clock);
10601058
am65_cpts_disable(cpts);
10611059
clk_disable_unprepare(cpts->refclk);
10621060
}
1061+
EXPORT_SYMBOL_GPL(am65_cpts_release);
10631062

10641063
struct am65_cpts *am65_cpts_create(struct device *dev, void __iomem *regs,
10651064
struct device_node *node)
@@ -1139,18 +1138,12 @@ struct am65_cpts *am65_cpts_create(struct device *dev, void __iomem *regs,
11391138
}
11401139
cpts->phc_index = ptp_clock_index(cpts->ptp_clock);
11411140

1142-
ret = devm_add_action_or_reset(dev, am65_cpts_release, cpts);
1143-
if (ret) {
1144-
dev_err(dev, "failed to add ptpclk reset action %d", ret);
1145-
return ERR_PTR(ret);
1146-
}
1147-
11481141
ret = devm_request_threaded_irq(dev, cpts->irq, NULL,
11491142
am65_cpts_interrupt,
11501143
IRQF_ONESHOT, dev_name(dev), cpts);
11511144
if (ret < 0) {
11521145
dev_err(cpts->dev, "error attaching irq %d\n", ret);
1153-
return ERR_PTR(ret);
1146+
goto reset_ptpclk;
11541147
}
11551148

11561149
dev_info(dev, "CPTS ver 0x%08x, freq:%u, add_val:%u pps:%d\n",
@@ -1159,6 +1152,8 @@ struct am65_cpts *am65_cpts_create(struct device *dev, void __iomem *regs,
11591152

11601153
return cpts;
11611154

1155+
reset_ptpclk:
1156+
am65_cpts_release(cpts);
11621157
refclk_disable:
11631158
clk_disable_unprepare(cpts->refclk);
11641159
return ERR_PTR(ret);

drivers/net/ethernet/ti/am65-cpts.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct am65_cpts_estf_cfg {
1818
};
1919

2020
#if IS_ENABLED(CONFIG_TI_K3_AM65_CPTS)
21+
void am65_cpts_release(struct am65_cpts *cpts);
2122
struct am65_cpts *am65_cpts_create(struct device *dev, void __iomem *regs,
2223
struct device_node *node);
2324
int am65_cpts_phc_index(struct am65_cpts *cpts);
@@ -31,6 +32,10 @@ void am65_cpts_estf_disable(struct am65_cpts *cpts, int idx);
3132
void am65_cpts_suspend(struct am65_cpts *cpts);
3233
void am65_cpts_resume(struct am65_cpts *cpts);
3334
#else
35+
static inline void am65_cpts_release(struct am65_cpts *cpts)
36+
{
37+
}
38+
3439
static inline struct am65_cpts *am65_cpts_create(struct device *dev,
3540
void __iomem *regs,
3641
struct device_node *node)

0 commit comments

Comments
 (0)