i2c: omap: 2 Fixes
Subsystems (5)
cover i2c: omap: 2 Fixes
This small serie is a follow-up of [1].
For an unkwown reason I don't feel really confident with these patches. Maybe because one is really old and the other one is related to pm, which ordering is sometimes tricky (from my PoV at least).
They are compile tested only.
So review with care ;-)
[1]: https://lore.kernel.org/all/vhhxtsspywvuzkfgbn52hysghd6tdxhk32wv3wcnlqwhskto3f@h2bbhek3s4s3/
Christophe JAILLET (2):
i2c: omap: Handle omap_i2c_init() errors in omap_i2c_probe()
i2c: omap: Fix an error handling path in omap_i2c_probe()
drivers/i2c/busses/i2c-omap.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 1 line
2.50.0
PATCH 1/2 i2c: omap: Handle omap_i2c_init() errors in omap_i2c_probe()
omap_i2c_init() can fail. Handle this error in omap_i2c_probe().
---
Compile tested only.
--- drivers/i2c/busses/i2c-omap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/i2c/busses/i2c-omap.c +6 -1
@@ -1472,7 +1472,11 @@ omap_i2c_probe(struct platform_device *pdev) }/* reset ASAP, clearing any IRQs */ -omap_i2c_init (omap); + r =omap_i2c_init (omap); +if (r) { +dev_err (omap->dev,"failure to initialize i2c: %d\n" , r); + goto err_mux_state_deselect; + }if (omap->rev <OMAP_I2C_OMAP1_REV_2 ) r = devm_request_irq(&pdev->dev, omap->irq, omap_i2c_omap1_isr,
@@ -1515,6 +1519,7 @@ omap_i2c_probe(struct platform_device *pdev) err_unuse_clocks:omap_i2c_write_reg (omap,OMAP_I2C_CON_REG ,0 ); +err_mux_state_deselect:if (omap->mux_state)mux_state_deselect (omap->mux_state); err_put_pm:
Signature · 1 line
2.50.0
Aaro Koskinen
maintainerRe: [PATCH 1/2] i2c: omap: Handle omap_i2c_init() errors in omap_i2c_probe()
Hi,
Quoted 15 lines · Christophe JAILLET
omap_i2c_init()can fail. Handle this error inomap_i2c_probe().Fixes 010d442c4a29 ("i2c: New bus driver for TI OMAP boards")Signed-off-by Christophe JAILLET <[email protected]>---
Compile tested only.--- drivers/i2c/busses/i2c-omap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-omap.c +0
-0
drivers/i2c/busses/i2c-omap.c omap_i2c_probe(struct platform_device *pdev) · line 1477
Quoted 7 lines
drivers/i2c/busses/i2c-omap.c +3
-1@@ -1472,7 +1472,11 @@ omap_i2c_probe(struct platform_device *pdev) }/* reset ASAP, clearing any IRQs */ -omap_i2c_init (omap); + r =omap_i2c_init (omap); +if (r) { +dev_err (omap->dev,"failure to initialize i2c: %d\n" , r);
Error paths in omap_i2c_init already print a message and error code, so this is log is redundant.
A.
Quoted 17 lines
drivers/i2c/busses/i2c-omap.c +3
-0+ goto err_mux_state_deselect; + }if (omap->rev <OMAP_I2C_OMAP1_REV_2 ) r = devm_request_irq(&pdev->dev, omap->irq, omap_i2c_omap1_isr,@@ -1515,6 +1519,7 @@ omap_i2c_probe(struct platform_device *pdev) err_unuse_clocks:omap_i2c_write_reg (omap,OMAP_I2C_CON_REG ,0 ); +err_mux_state_deselect:if (omap->mux_state)mux_state_deselect (omap->mux_state); err_put_pm:Signature · 1 line
2.50.0
Andi Shyti
maintainerRe: [PATCH 1/2] i2c: omap: Handle omap_i2c_init() errors in omap_i2c_probe()
Hi Aaro,
Quoted 7 lines
Quoted 7 lines
drivers/i2c/busses/i2c-omap.c +0
-0@@ -1472,7 +1472,11 @@ omap_i2c_probe(struct platform_device *pdev) }
Quoted 8 lines
drivers/i2c/busses/i2c-omap.c omap_i2c_probe(struct platform_device *pdev) · line 1477
Quoted 5 lines
drivers/i2c/busses/i2c-omap.c +3
-1/* reset ASAP, clearing any IRQs */ -omap_i2c_init (omap); + r =omap_i2c_init (omap); +if (r) { +dev_err (omap->dev,"failure to initialize i2c: %d\n" , r);Error paths in
omap_i2c_initalready print a message and error code, so this is log is redundant.
Good point! I will take care of it, no need to send a v2.
Thanks,
Andi
Andreas Kemnade
maintainerRe: [PATCH 1/2] i2c: omap: Handle omap_i2c_init() errors in omap_i2c_probe()
In reply to Aaro KoskinenAm Wed, 9 Jul 2025 21:25:28 +0300
schrieb Aaro Koskinen <[email protected]>:
Quoted 20 lines
Hi,
Quoted 17 lines · Christophe JAILLET
omap_i2c_init()can fail. Handle this error inomap_i2c_probe().Fixes 010d442c4a29 ("i2c: New bus driver for TI OMAP boards")Signed-off-by Christophe JAILLET <[email protected]>---
Compile tested only.--- drivers/i2c/busses/i2c-omap.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)drivers/i2c/busses/i2c-omap.c +0
-0@@ -1472,7 +1472,11 @@ omap_i2c_probe(struct platform_device *pdev) }
Quoted 9 lines
drivers/i2c/busses/i2c-omap.c omap_i2c_probe(struct platform_device *pdev) · line 1477
Quoted 5 lines
drivers/i2c/busses/i2c-omap.c +3
-1/* reset ASAP, clearing any IRQs */ -omap_i2c_init (omap); + r =omap_i2c_init (omap); +if (r) { +dev_err (omap->dev,"failure to initialize i2c: %d\n" , r);Error paths in
omap_i2c_initalready print a message and error code, so this is log is redundant.
And I have never seen these in normal operation, so adding that error check should be safe.
Regards,
Andreas
PATCH 2/2 i2c: omap: Fix an error handling path in omap_i2c_probe()
In reply to Christophe JAILLETIf an error occurs after pm_runtime_use_autosuspend(), a corresponding pm_runtime_dont_use_autosuspend() should be called.
In case of error in pm_runtime_resume_and_get(), it is not the case because the error handling path is wrongly ordered.
Fix it.
---
Compile tested only.
--- drivers/i2c/busses/i2c-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/i2c/busses/i2c-omap.c +1 -1
@@ -1523,9 +1523,9 @@ omap_i2c_probe(struct platform_device *pdev)if (omap->mux_state)mux_state_deselect (omap->mux_state); err_put_pm: -pm_runtime_dont_use_autosuspend (omap->dev);pm_runtime_put_sync (omap->dev); err_disable_pm: +pm_runtime_dont_use_autosuspend (omap->dev);pm_runtime_disable (&pdev->dev);return r;
Signature · 1 line
2.50.0
Re: [PATCH 2/2] i2c: omap: Fix an error handling path in omap_i2c_probe()
Am Sat, 5 Jul 2025 09:57:38 +0200
schrieb Christophe JAILLET <[email protected]>:
Quoted 9 lines
If an error occurs after
pm_runtime_use_autosuspend(), a correspondingpm_runtime_dont_use_autosuspend()should be called.In case of error in
pm_runtime_resume_and_get(), it is not the case because the error handling path is wrongly ordered.
Fix it.Fixes 780f62974125 ("i2c: omap: fix reference leak when pm_runtime_get_sync fails")Signed-off-by Christophe JAILLET <[email protected]>
Quoted 21 lines
---
Compile tested only.--- drivers/i2c/busses/i2c-omap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/i2c/busses/i2c-omap.c +1
-1@@ -1523,9 +1523,9 @@ omap_i2c_probe(struct platform_device *pdev)if (omap->mux_state)mux_state_deselect (omap->mux_state); err_put_pm: -pm_runtime_dont_use_autosuspend (omap->dev);pm_runtime_put_sync (omap->dev); err_disable_pm: +pm_runtime_dont_use_autosuspend (omap->dev);pm_runtime_disable (&pdev->dev);return r;
Andi Shyti
maintainerHi Christophe,
Quoted 3 lines
Christophe JAILLET (2):
i2c: omap: Handleomap_i2c_init()errors inomap_i2c_probe()
i2c: omap: Fix an error handling path inomap_i2c_probe()
they both make sense to me. It would be nice to have a comment on the first patch from the Omap guys who have been very silent whenever I asked for help on reviews.
I will apply them and if any concerns comes, we have time until the pull request to revert.
Thanks,
Andi