phy: phy-snps-eusb2: fixes and cleanups
cover phy: phy-snps-eusb2: fixes and cleanups
Here are a couple of fixes and some related cleanups to the recently reworked and renamed phy-snps-eusb2 driver.
The clock and repeater imbalance fixes are not marked for stable as the first issue was introduced in the recent rework which is queued for 6.16-rc1.
The repeater imbalance has been there for a few years and could be backported even if this is now complicated by the rework/rename. Since it only affects a resource leak in an error path I decided to not mark this one for stable for now.
Ideally, these could go in along with the reworked driver for rc1.
Johan
Johan Hovold (7):
phy: phy-snps-eusb2: fix clock imbalance on phy_exit()
phy: phy-snps-eusb2: fix repeater imbalance on phy_init() failure
phy: phy-snps-eusb2: rename phy_init() clock error label
phy: phy-snps-eusb2: clean up error messages
phy: phy-snps-eusb2: fix optional phy lookup parameter
phy: phy-snps-eusb2: drop unnecessary loop index declarations
phy: phy-snps-eusb2: clean up id table sentinel
drivers/phy/phy-snps-eusb2.c | 39 +++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 18 deletions(-)
Signature · 1 line
2.49.0
PATCH 1/7 phy: phy-snps-eusb2: fix clock imbalance on phy_exit()
Make sure to disable all clocks enabled at phy_init() also on phy_exit().
--- drivers/phy/phy-snps-eusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-snps-eusb2.c +1 -1
@@ -504,7 +504,7 @@ static int snps_eusb2_hsphy_exit(struct phy *p) {struct snps_eusb2_hsphy *phy =phy_get_drvdata (p); -clk_disable_unprepare (phy->ref_clk); +clk_bulk_disable_unprepare (phy->data->num_clks, phy->clks);regulator_bulk_disable (ARRAY_SIZE (phy->vregs), phy->vregs);
Signature · 1 line
2.49.0
Re: [PATCH 1/7] phy: phy-snps-eusb2: fix clock imbalance on phy_exit()
Quoted 15 lines · Johan Hovold
Make sure to disable all clocks enabled at
phy_init()also onphy_exit().Fixes c4098f3e6134 ("phy: phy-snps-eusb2: add support for exynos2200")Cc Ivaylo Ivanov <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/phy-snps-eusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/phy/phy-snps-eusb2.c +0
-0
drivers/phy/phy-snps-eusb2.c static int snps_eusb2_hsphy_exit(struct phy *p) · line 507
Quoted 5 lines
drivers/phy/phy-snps-eusb2.c +1
-1@@ -504,7 +504,7 @@ static int snps_eusb2_hsphy_exit(struct phy *p) {struct snps_eusb2_hsphy *phy =phy_get_drvdata (p); -clk_disable_unprepare (phy->ref_clk); +clk_bulk_disable_unprepare (phy->data->num_clks, phy->clks);
This shouldn't affect functionality for Exynos 2200, as gates are not handled manually in the clocks driver.
Anyways, this is good to have for other/future supported SoCs.
Best regards,
Ivaylo
Quoted 3 lines
drivers/phy/phy-snps-eusb2.c +0
-0regulator_bulk_disable (ARRAY_SIZE (phy->vregs), phy->vregs);
Re: [PATCH 1/7] phy: phy-snps-eusb2: fix clock imbalance on phy_exit()
In reply to Johan HovoldQuoted 15 lines · Johan Hovold
Make sure to disable all clocks enabled at
phy_init()also onphy_exit().Fixes c4098f3e6134 ("phy: phy-snps-eusb2: add support for exynos2200")Cc Ivaylo Ivanov <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/phy-snps-eusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/phy/phy-snps-eusb2.c +0
-0
drivers/phy/phy-snps-eusb2.c static int snps_eusb2_hsphy_exit(struct phy *p) · line 510
Quoted 8 lines
drivers/phy/phy-snps-eusb2.c +1
-1@@ -504,7 +504,7 @@ static int snps_eusb2_hsphy_exit(struct phy *p) {struct snps_eusb2_hsphy *phy =phy_get_drvdata (p); -clk_disable_unprepare (phy->ref_clk); +clk_bulk_disable_unprepare (phy->data->num_clks, phy->clks);regulator_bulk_disable (ARRAY_SIZE (phy->vregs), phy->vregs);
PATCH 2/7 phy: phy-snps-eusb2: fix repeater imbalance on phy_init() failure
In reply to Johan HovoldMake sure to disable the repeater PHY also on phy_init() failure.
--- drivers/phy/phy-snps-eusb2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/phy/phy-snps-eusb2.c +3 -2
@@ -468,7 +468,7 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =clk_bulk_prepare_enable (phy->data->num_clks, phy->clks);if (ret) {dev_err (&p->dev,"failed to enable ref clock, %d\n" , ret); - goto disable_vreg; + goto exit_repeater; } ret =reset_control_assert (phy->phy_reset);
@@ -493,7 +493,8 @@ static int snps_eusb2_hsphy_init(struct phy *p) disable_ref_clk:clk_bulk_disable_unprepare (phy->data->num_clks, phy->clks); - +exit_repeater: +phy_exit (phy->repeater); disable_vreg:regulator_bulk_disable (ARRAY_SIZE (phy->vregs), phy->vregs);
Signature · 1 line
2.49.0
Re: [PATCH 2/7] phy: phy-snps-eusb2: fix repeater imbalance on phy_init() failure
Quoted 24 lines · Johan Hovold
Make sure to disable the repeater PHY also on
phy_init()failure.Fixes 3584f6392f09 ("phy: qcom: phy-qcom-snps-eusb2: Add support for eUSB2 repeater")Cc Abel Vesa <[email protected]>Cc Neil Armstrong <[email protected]>Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/phy-snps-eusb2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/phy/phy-snps-eusb2.c +1
-1@@ -468,7 +468,7 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =clk_bulk_prepare_enable (phy->data->num_clks, phy->clks);if (ret) {dev_err (&p->dev,"failed to enable ref clock, %d\n" , ret); - goto disable_vreg; + goto exit_repeater; } ret =reset_control_assert (phy->phy_reset);
drivers/phy/phy-snps-eusb2.c static int snps_eusb2_hsphy_init(struct phy *p) · line 500
Quoted 9 lines
drivers/phy/phy-snps-eusb2.c +2
-1@@ -493,7 +493,8 @@ static int snps_eusb2_hsphy_init(struct phy *p) disable_ref_clk:clk_bulk_disable_unprepare (phy->data->num_clks, phy->clks); - +exit_repeater: +phy_exit (phy->repeater); disable_vreg:regulator_bulk_disable (ARRAY_SIZE (phy->vregs), phy->vregs);
PATCH 3/7 phy: phy-snps-eusb2: rename phy_init() clock error label
In reply to Johan HovoldRename the clock error label which is now used to disable all clocks and not just the ref clock on phy_init() errors.
--- drivers/phy/phy-snps-eusb2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/phy/phy-snps-eusb2.c +4 -4
@@ -474,7 +474,7 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =reset_control_assert (phy->phy_reset);if (ret) {dev_err (&p->dev,"failed to assert phy_reset, %d\n" , ret); - goto disable_ref_clk; + goto disable_clks; }usleep_range (100 ,150 );
@@ -482,16 +482,16 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =reset_control_deassert (phy->phy_reset);if (ret) {dev_err (&p->dev,"failed to de-assert phy_reset, %d\n" , ret); - goto disable_ref_clk; + goto disable_clks; } ret = phy->data->phy_init (p);if (ret) - goto disable_ref_clk; + goto disable_clks;return 0 ; -disable_ref_clk: +disable_clks:clk_bulk_disable_unprepare (phy->data->num_clks, phy->clks); exit_repeater:phy_exit (phy->repeater);
Signature · 1 line
2.49.0
Re: [PATCH 3/7] phy: phy-snps-eusb2: rename phy_init() clock error label
Quoted 31 lines · Johan Hovold
Rename the clock error label which is now used to disable all clocks and not just the ref clock on
phy_init()errors.Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/phy-snps-eusb2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)drivers/phy/phy-snps-eusb2.c +2
-2@@ -474,7 +474,7 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =reset_control_assert (phy->phy_reset);if (ret) {dev_err (&p->dev,"failed to assert phy_reset, %d\n" , ret); - goto disable_ref_clk; + goto disable_clks; }usleep_range (100 ,150 );@@ -482,16 +482,16 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =reset_control_deassert (phy->phy_reset);if (ret) {dev_err (&p->dev,"failed to de-assert phy_reset, %d\n" , ret); - goto disable_ref_clk; + goto disable_clks; } ret = phy->data->phy_init (p);if (ret)
drivers/phy/phy-snps-eusb2.c static int snps_eusb2_hsphy_init(struct phy *p) · line 497
Quoted 10 lines
drivers/phy/phy-snps-eusb2.c +2
-2- goto disable_ref_clk; + goto disable_clks;return 0 ; -disable_ref_clk: +disable_clks:clk_bulk_disable_unprepare (phy->data->num_clks, phy->clks); exit_repeater:phy_exit (phy->repeater);
PATCH 4/7 phy: phy-snps-eusb2: clean up error messages
In reply to Johan HovoldClean up the error messages by using a consistent format with a colon followed by a space and an errno (or unsupported frequency).
--- drivers/phy/phy-snps-eusb2.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/phy/phy-snps-eusb2.c +7 -7
@@ -256,7 +256,7 @@ static int exynos_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) }if (!config) { -dev_err (&phy->phy->dev,"unsupported ref_clk_freq:%lu\n" , ref_clk_freq); +dev_err (&phy->phy->dev,"unsupported ref_clk_freq: %lu\n" , ref_clk_freq);return -EINVAL ; }
@@ -293,7 +293,7 @@ static int qcom_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) }if (!config) { -dev_err (&phy->phy->dev,"unsupported ref_clk_freq:%lu\n" , ref_clk_freq); +dev_err (&phy->phy->dev,"unsupported ref_clk_freq: %lu\n" , ref_clk_freq);return -EINVAL ; }
@@ -461,19 +461,19 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =phy_init (phy->repeater);if (ret) { -dev_err (&p->dev,"repeater init failed. %d\n" , ret); +dev_err (&p->dev,"repeater init failed: %d\n" , ret); goto disable_vreg; } ret =clk_bulk_prepare_enable (phy->data->num_clks, phy->clks);if (ret) { -dev_err (&p->dev,"failed to enable ref clock, %d\n" , ret); +dev_err (&p->dev,"failed to enable ref clock: %d\n" , ret); goto exit_repeater; } ret =reset_control_assert (phy->phy_reset);if (ret) { -dev_err (&p->dev,"failed to assert phy_reset, %d\n" , ret); +dev_err (&p->dev,"failed to assert phy_reset: %d\n" , ret); goto disable_clks; }
@@ -481,7 +481,7 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =reset_control_deassert (phy->phy_reset);if (ret) { -dev_err (&p->dev,"failed to de-assert phy_reset, %d\n" , ret); +dev_err (&p->dev,"failed to de-assert phy_reset: %d\n" , ret); goto disable_clks; }
@@ -588,7 +588,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev) generic_phy =devm_phy_create (dev,NULL , &snps_eusb2_hsphy_ops);if (IS_ERR (generic_phy)) { -dev_err (dev,"failed to create phy %d\n" , ret); +dev_err (dev,"failed to create phy: %d\n" , ret);return PTR_ERR (generic_phy); }
Signature · 1 line
2.49.0
Re: [PATCH 4/7] phy: phy-snps-eusb2: clean up error messages
Quoted 63 lines · Johan Hovold
Clean up the error messages by using a consistent format with a colon followed by a space and an errno (or unsupported frequency).
Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/phy-snps-eusb2.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/phy/phy-snps-eusb2.c +6
-6@@ -256,7 +256,7 @@ static int exynos_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) }if (!config) { -dev_err (&phy->phy->dev,"unsupported ref_clk_freq:%lu\n" , ref_clk_freq); +dev_err (&phy->phy->dev,"unsupported ref_clk_freq: %lu\n" , ref_clk_freq);return -EINVAL ; }@@ -293,7 +293,7 @@ static int qcom_eusb2_ref_clk_init(struct snps_eusb2_hsphy *phy) }if (!config) { -dev_err (&phy->phy->dev,"unsupported ref_clk_freq:%lu\n" , ref_clk_freq); +dev_err (&phy->phy->dev,"unsupported ref_clk_freq: %lu\n" , ref_clk_freq);return -EINVAL ; }@@ -461,19 +461,19 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =phy_init (phy->repeater);if (ret) { -dev_err (&p->dev,"repeater init failed. %d\n" , ret); +dev_err (&p->dev,"repeater init failed: %d\n" , ret); goto disable_vreg; } ret =clk_bulk_prepare_enable (phy->data->num_clks, phy->clks);if (ret) { -dev_err (&p->dev,"failed to enable ref clock, %d\n" , ret); +dev_err (&p->dev,"failed to enable ref clock: %d\n" , ret); goto exit_repeater; } ret =reset_control_assert (phy->phy_reset);if (ret) { -dev_err (&p->dev,"failed to assert phy_reset, %d\n" , ret); +dev_err (&p->dev,"failed to assert phy_reset: %d\n" , ret); goto disable_clks; }@@ -481,7 +481,7 @@ static int snps_eusb2_hsphy_init(struct phy *p) ret =reset_control_deassert (phy->phy_reset);if (ret) { -dev_err (&p->dev,"failed to de-assert phy_reset, %d\n" , ret); +dev_err (&p->dev,"failed to de-assert phy_reset: %d\n" , ret); goto disable_clks; }
drivers/phy/phy-snps-eusb2.c static int snps_eusb2_hsphy_probe(struct platform_device *pdev) · line 594
Quoted 8 lines
drivers/phy/phy-snps-eusb2.c +1
-1@@ -588,7 +588,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev) generic_phy =devm_phy_create (dev,NULL , &snps_eusb2_hsphy_ops);if (IS_ERR (generic_phy)) { -dev_err (dev,"failed to create phy %d\n" , ret); +dev_err (dev,"failed to create phy: %d\n" , ret);return PTR_ERR (generic_phy); }
PATCH 5/7 phy: phy-snps-eusb2: fix optional phy lookup parameter
In reply to Johan HovoldThe devm_of_phy_optional_get() takes an optional name argument as its third parameter and not an index like the recently replaced devm_of_phy_get_by_index().
Replace 0 with an explicit NULL for consistency and readability.
--- drivers/phy/phy-snps-eusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/phy/phy-snps-eusb2.c +1 -1
@@ -581,7 +581,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"failed to get regulator supplies\n" ); - phy->repeater =devm_of_phy_optional_get (dev, np,0 ); + phy->repeater =devm_of_phy_optional_get (dev, np,NULL );if (IS_ERR (phy->repeater))return dev_err_probe (dev,PTR_ERR (phy->repeater),"failed to get repeater\n" );
Signature · 1 line
2.49.0
Re: [PATCH 5/7] phy: phy-snps-eusb2: fix optional phy lookup parameter
Quoted 16 lines · Johan Hovold
The
devm_of_phy_optional_get()takes an optional name argument as its third parameter and not an index like the recently replaceddevm_of_phy_get_by_index().Replace 0 with an explicit NULL for consistency and readability.
Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/phy-snps-eusb2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/phy/phy-snps-eusb2.c +0
-0
drivers/phy/phy-snps-eusb2.c static int snps_eusb2_hsphy_probe(struct platform_device *pdev) · line 587
Quoted 8 lines
drivers/phy/phy-snps-eusb2.c +1
-1@@ -581,7 +581,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev)return dev_err_probe (dev, ret,"failed to get regulator supplies\n" ); - phy->repeater =devm_of_phy_optional_get (dev, np,0 ); + phy->repeater =devm_of_phy_optional_get (dev, np,NULL );if (IS_ERR (phy->repeater))return dev_err_probe (dev,PTR_ERR (phy->repeater),"failed to get repeater\n" );
PATCH 6/7 phy: phy-snps-eusb2: drop unnecessary loop index declarations
In reply to Johan HovoldThere is already a loop index variable declared at function scope so drop the unnecessary overloaded loop declarations.
--- drivers/phy/phy-snps-eusb2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/phy/phy-snps-eusb2.c +2 -2
@@ -552,7 +552,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev)if (!phy->clks)return -ENOMEM ; -for (int i =0 ; i < phy->data->num_clks; ++i) +for (i =0 ; i < phy->data->num_clks; ++i) phy->clks[i].id = phy->data->clk_names[i]; ret =devm_clk_bulk_get (dev, phy->data->num_clks, phy->clks);
@@ -561,7 +561,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev) "failed to get phy clock(s)\n"); phy->ref_clk =NULL ; -for (int i =0 ; i < phy->data->num_clks; ++i) { +for (i =0 ; i < phy->data->num_clks; ++i) {if (!strcmp (phy->clks[i].id,"ref" )) { phy->ref_clk = phy->clks[i].clk;break ;
Signature · 1 line
2.49.0
Re: [PATCH 6/7] phy: phy-snps-eusb2: drop unnecessary loop index declarations
Quoted 22 lines · Johan Hovold
There is already a loop index variable declared at function scope so drop the unnecessary overloaded loop declarations.
Signed-off-by Johan Hovold <[email protected]>--- drivers/phy/phy-snps-eusb2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/phy/phy-snps-eusb2.c +1
-1@@ -552,7 +552,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev)if (!phy->clks)return -ENOMEM ; -for (int i =0 ; i < phy->data->num_clks; ++i) +for (i =0 ; i < phy->data->num_clks; ++i) phy->clks[i].id = phy->data->clk_names[i]; ret =devm_clk_bulk_get (dev, phy->data->num_clks, phy->clks);
drivers/phy/phy-snps-eusb2.c static int snps_eusb2_hsphy_probe(struct platform_device *pdev) · line 567
Quoted 8 lines
drivers/phy/phy-snps-eusb2.c +1
-1@@ -561,7 +561,7 @@ static int snps_eusb2_hsphy_probe(struct platform_device *pdev) "failed to get phy clock(s)\n"); phy->ref_clk =NULL ; -for (int i =0 ; i < phy->data->num_clks; ++i) { +for (i =0 ; i < phy->data->num_clks; ++i) {if (!strcmp (phy->clks[i].id,"ref" )) { phy->ref_clk = phy->clks[i].clk;break ;
PATCH 7/7 phy: phy-snps-eusb2: clean up id table sentinel
In reply to Johan HovoldUse a more common format for the id table sentinel for consistency and symmetry.
--- drivers/phy/phy-snps-eusb2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/phy/phy-snps-eusb2.c +3 -1
@@ -611,7 +611,9 @@ static const struct of_device_id snps_eusb2_hsphy_of_match_table[] = { }, { .compatible = "samsung,exynos2200-eusb2-phy", .data = &exynos2200_snps_eusb2_phy, - }, { }, + }, { +/* sentinel */ + } };MODULE_DEVICE_TABLE (of, snps_eusb2_hsphy_of_match_table);
Signature · 1 line
2.49.0
Quoted 17 lines · Johan Hovold
Here are a couple of fixes and some related cleanups to the recently reworked and renamed phy-snps-eusb2 driver.
The clock and repeater imbalance fixes are not marked for stable as the first issue was introduced in the recent rework which is queued for 6.16-rc1.
The repeater imbalance has been there for a few years and could be backported even if this is now complicated by the rework/rename. Since it only affects a resource leak in an error path I decided to not mark this one for stable for now.
Ideally, these could go in along with the reworked driver for rc1.
Johan
Quoted 8 lines
Johan Hovold (7):
phy: phy-snps-eusb2: fix clock imbalance onphy_exit()
phy: phy-snps-eusb2: fix repeater imbalance onphy_init()failure
phy: phy-snps-eusb2: renamephy_init()clock error label
phy: phy-snps-eusb2: clean up error messages
phy: phy-snps-eusb2: fix optional phy lookup parameter
phy: phy-snps-eusb2: drop unnecessary loop index declarations
phy: phy-snps-eusb2: clean up id table sentinel
Really straightforward. So for the entire series:
Quoted 8 lines · Johan Hovold
Here are a couple of fixes and some related cleanups to the recently reworked and renamed phy-snps-eusb2 driver.
The clock and repeater imbalance fixes are not marked for stable as the first issue was introduced in the recent rework which is queued for 6.16-rc1.
[...]
Applied, thanks!
[1/7] phy: phy-snps-eusb2: fix clock imbalance on phy_exit()
commit: 641fa5b515a6900b1452cc92d30d1ab391e04414
[2/7] phy: phy-snps-eusb2: fix repeater imbalance on phy_init() failure
commit: 3232a6b0d834569f71aa898401288af6b4ab781d
[3/7] phy: phy-snps-eusb2: rename phy_init() clock error label
commit: 4f333990841e06059c3cd7251791017d4c9e9028
[4/7] phy: phy-snps-eusb2: clean up error messages
commit: b7996f8e9473cf8a594af1fa1bb799f8f28c0670
[5/7] phy: phy-snps-eusb2: fix optional phy lookup parameter
commit: f21b9bea6bc29de88b885cecd5e4f0ada60d4700
[6/7] phy: phy-snps-eusb2: drop unnecessary loop index declarations
commit: d2d0ae723ba3fca2c54dfbc758b368d3009e79a7
[7/7] phy: phy-snps-eusb2: clean up id table sentinel
commit: 47311eaa0a3be575f7835d99e3767f5ee5940b45Best regards,
Signature · 1 line
~Vinod