From: Artem Shimko <a.shimko.dev@gmail.com>
To: p.zabel@pengutronix.de
Cc: a.shimko.dev@gmail.com, andi.shyti@kernel.org,
andriy.shevchenko@linux.intel.com, jsd@semihalf.com,
linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org,
mika.westerberg@linux.intel.com
Subject: [PATCH v2 3/3] i2c: designware-platdrv: streamline error handling
Date: Tue, 11 Nov 2025 14:45:59 +0300 [thread overview]
Message-ID: <20251111114559.3188740-3-a.shimko.dev@gmail.com> (raw)
In-Reply-To: <20251111114559.3188740-1-a.shimko.dev@gmail.com>
The probe function uses unnecessary goto statements and error variable
reassignments that complicate the code flow. The goto exit_probe pattern
adds indirection for simple error cleanup, while redundant error assignment
in lock support probe clutters the error handling.
Simplify the error paths by removing the goto exit_probe label and handling
PM runtime cleanup directly after i2c_dw_probe() failure. Additionally,
replace the error variable reassignment in i2c_dw_probe_lock_support() with
direct dev_err_probe() return. These changes make the error handling more
linear and readable while maintaining identical functionality.
Signed-off-by: Artem Shimko <a.shimko.dev@gmail.com>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index d334af1d7c6f..ab15a924dad5 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -256,10 +256,8 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
return ret;
ret = i2c_dw_probe_lock_support(dev);
- if (ret) {
- ret = dev_err_probe(device, ret, "failed to probe lock support\n");
- return ret;
- }
+ if (ret)
+ return dev_err_probe(device, ret, "failed to probe lock support\n");
i2c_dw_configure(dev);
@@ -314,14 +312,10 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
pm_runtime_enable(device);
ret = i2c_dw_probe(dev);
- if (ret)
- goto exit_probe;
-
- return ret;
-
-exit_probe:
- dw_i2c_plat_pm_cleanup(dev);
- i2c_dw_prepare_clk(dev, false);
+ if (ret) {
+ dw_i2c_plat_pm_cleanup(dev);
+ i2c_dw_prepare_clk(dev, false);
+ }
return ret;
}
--
2.43.0
prev parent reply other threads:[~2025-11-11 11:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-11 7:53 [PATCH RESEND] i2c: designware-platdrv: handle reset control deassert error Artem Shimko
2025-11-11 9:15 ` Philipp Zabel
2025-11-11 11:45 ` [PATCH v2 1/3] i2c: designware-platdrv: simplify reset control with devm variant Artem Shimko
2025-11-11 11:45 ` [PATCH v2 2/3] i2c: designware-platdrv: complete reset control devm conversion Artem Shimko
2025-11-11 12:43 ` Philipp Zabel
2025-11-11 14:09 ` [PATCH v3] i2c: designware-platdrv: simplify reset control and error handling Artem Shimko
2025-11-11 14:33 ` Philipp Zabel
2025-11-11 14:33 ` [PATCH v2 2/3] i2c: designware-platdrv: complete reset control devm conversion Philipp Zabel
2025-11-11 14:55 ` [PATCH v4] i2c: designware-platdrv: simplify reset control and error handling Artem Shimko
2026-01-20 13:55 ` Andi Shyti
2025-11-11 11:45 ` Artem Shimko [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251111114559.3188740-3-a.shimko.dev@gmail.com \
--to=a.shimko.dev@gmail.com \
--cc=andi.shyti@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=jsd@semihalf.com \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=p.zabel@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox