* [PATCH 1/2] i2c: cadence: Simplify using devm_clk_get_enabled()
2025-02-06 11:57 [PATCH 0/2] Simplify clock handling and fix probe error handling sequence Manikanta Guntupalli
@ 2025-02-06 11:57 ` Manikanta Guntupalli
2025-02-06 11:57 ` [PATCH 2/2] i2c: cadence: Move reset_control_assert after pm_runtime_set_suspended in probe error path Manikanta Guntupalli
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Manikanta Guntupalli @ 2025-02-06 11:57 UTC (permalink / raw)
To: git, michal.simek, andi.shyti, p.zabel, linux-arm-kernel,
linux-i2c, linux-kernel
Cc: radhey.shyam.pandey, srinivas.goud, shubhrajyoti.datta,
manikantaguntupalli09, Manikanta Guntupalli
From: Michal Simek <michal.simek@amd.com>
Clock handling can be very simplified with using devm_clk_get_enabled() as
was done by commit 8d2aaf4382b7 ("gpio: zynq: Simplify using
devm_clk_get_enabled()").
And also fix issue in connection to incorrect sequence when err_clk_dis
label is called.
When reset_control_deassert() fails it jumps to err_clk_dis label which
disables clock and also disable pm_runtime setup but nothing has been setup
at this time of failure because initialization is done below
reset_control_deassert() call.
Signed-off-by: Michal Simek <michal.simek@amd.com>
Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
---
drivers/i2c/busses/i2c-cadence.c | 17 ++++-------------
1 file changed, 4 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index b64026fbca66..51dc7728d133 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -1541,7 +1541,7 @@ static int cdns_i2c_probe(struct platform_device *pdev)
snprintf(id->adap.name, sizeof(id->adap.name),
"Cadence I2C at %08lx", (unsigned long)r_mem->start);
- id->clk = devm_clk_get(&pdev->dev, NULL);
+ id->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(id->clk))
return dev_err_probe(&pdev->dev, PTR_ERR(id->clk),
"input clock not found.\n");
@@ -1551,16 +1551,10 @@ static int cdns_i2c_probe(struct platform_device *pdev)
return dev_err_probe(&pdev->dev, PTR_ERR(id->reset),
"Failed to request reset.\n");
- ret = clk_prepare_enable(id->clk);
- if (ret)
- dev_err(&pdev->dev, "Unable to enable clock.\n");
-
ret = reset_control_deassert(id->reset);
- if (ret) {
- dev_err_probe(&pdev->dev, ret,
- "Failed to de-assert reset.\n");
- goto err_clk_dis;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret,
+ "Failed to de-assert reset.\n");
pm_runtime_set_autosuspend_delay(id->dev, CNDS_I2C_PM_TIMEOUT);
pm_runtime_use_autosuspend(id->dev);
@@ -1616,8 +1610,6 @@ static int cdns_i2c_probe(struct platform_device *pdev)
err_clk_notifier_unregister:
clk_notifier_unregister(id->clk, &id->clk_rate_change_nb);
reset_control_assert(id->reset);
-err_clk_dis:
- clk_disable_unprepare(id->clk);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
return ret;
@@ -1642,7 +1634,6 @@ static void cdns_i2c_remove(struct platform_device *pdev)
i2c_del_adapter(&id->adap);
clk_notifier_unregister(id->clk, &id->clk_rate_change_nb);
reset_control_assert(id->reset);
- clk_disable_unprepare(id->clk);
}
static struct platform_driver cdns_i2c_drv = {
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread* [PATCH 2/2] i2c: cadence: Move reset_control_assert after pm_runtime_set_suspended in probe error path
2025-02-06 11:57 [PATCH 0/2] Simplify clock handling and fix probe error handling sequence Manikanta Guntupalli
2025-02-06 11:57 ` [PATCH 1/2] i2c: cadence: Simplify using devm_clk_get_enabled() Manikanta Guntupalli
@ 2025-02-06 11:57 ` Manikanta Guntupalli
2025-02-06 12:28 ` [PATCH 0/2] Simplify clock handling and fix probe error handling sequence Michal Simek
2025-03-11 22:51 ` Andi Shyti
3 siblings, 0 replies; 5+ messages in thread
From: Manikanta Guntupalli @ 2025-02-06 11:57 UTC (permalink / raw)
To: git, michal.simek, andi.shyti, p.zabel, linux-arm-kernel,
linux-i2c, linux-kernel
Cc: radhey.shyam.pandey, srinivas.goud, shubhrajyoti.datta,
manikantaguntupalli09, Manikanta Guntupalli
Ensure reset_control_assert() is called after pm_runtime_set_suspended()
in the cdns_i2c_probe exit path to maintain proper power management
sequence in error cases.
Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@amd.com>
---
drivers/i2c/busses/i2c-cadence.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/i2c/busses/i2c-cadence.c b/drivers/i2c/busses/i2c-cadence.c
index 51dc7728d133..8df63aaf2a80 100644
--- a/drivers/i2c/busses/i2c-cadence.c
+++ b/drivers/i2c/busses/i2c-cadence.c
@@ -1609,9 +1609,9 @@ static int cdns_i2c_probe(struct platform_device *pdev)
err_clk_notifier_unregister:
clk_notifier_unregister(id->clk, &id->clk_rate_change_nb);
- reset_control_assert(id->reset);
pm_runtime_disable(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev);
+ reset_control_assert(id->reset);
return ret;
}
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Simplify clock handling and fix probe error handling sequence
2025-02-06 11:57 [PATCH 0/2] Simplify clock handling and fix probe error handling sequence Manikanta Guntupalli
2025-02-06 11:57 ` [PATCH 1/2] i2c: cadence: Simplify using devm_clk_get_enabled() Manikanta Guntupalli
2025-02-06 11:57 ` [PATCH 2/2] i2c: cadence: Move reset_control_assert after pm_runtime_set_suspended in probe error path Manikanta Guntupalli
@ 2025-02-06 12:28 ` Michal Simek
2025-03-11 22:51 ` Andi Shyti
3 siblings, 0 replies; 5+ messages in thread
From: Michal Simek @ 2025-02-06 12:28 UTC (permalink / raw)
To: Manikanta Guntupalli, git, andi.shyti, p.zabel, linux-arm-kernel,
linux-i2c, linux-kernel
Cc: radhey.shyam.pandey, srinivas.goud, shubhrajyoti.datta,
manikantaguntupalli09
On 2/6/25 12:57, Manikanta Guntupalli wrote:
> This series includes two patches that improve the Cadence I2C driver
> by simplifying clock handling and ensuring correct reset sequencing
> in the probe error path.
>
> Manikanta Guntupalli (1):
> i2c: cadence: Move reset_control_assert after pm_runtime_set_suspended
> in probe error path
>
> Michal Simek (1):
> i2c: cadence: Simplify using devm_clk_get_enabled()
>
> drivers/i2c/busses/i2c-cadence.c | 19 +++++--------------
> 1 file changed, 5 insertions(+), 14 deletions(-)
>
Looks good to me.
M
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] Simplify clock handling and fix probe error handling sequence
2025-02-06 11:57 [PATCH 0/2] Simplify clock handling and fix probe error handling sequence Manikanta Guntupalli
` (2 preceding siblings ...)
2025-02-06 12:28 ` [PATCH 0/2] Simplify clock handling and fix probe error handling sequence Michal Simek
@ 2025-03-11 22:51 ` Andi Shyti
3 siblings, 0 replies; 5+ messages in thread
From: Andi Shyti @ 2025-03-11 22:51 UTC (permalink / raw)
To: Manikanta Guntupalli
Cc: git, michal.simek, p.zabel, linux-arm-kernel, linux-i2c,
linux-kernel, radhey.shyam.pandey, srinivas.goud,
shubhrajyoti.datta, manikantaguntupalli09
Hi,
On Thu, Feb 06, 2025 at 05:27:06PM +0530, Manikanta Guntupalli wrote:
> This series includes two patches that improve the Cadence I2C driver
> by simplifying clock handling and ensuring correct reset sequencing
> in the probe error path.
>
> Manikanta Guntupalli (1):
> i2c: cadence: Move reset_control_assert after pm_runtime_set_suspended
> in probe error path
>
> Michal Simek (1):
> i2c: cadence: Simplify using devm_clk_get_enabled()
I was sure I did take this patch, but unfortunately I forgot it.
Feel free to ping me in such case.
Merged to i2c/i2c-host.
Thanks,
Andi
^ permalink raw reply [flat|nested] 5+ messages in thread