From: ulf.hansson@linaro.org (Ulf Hansson)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/10] i2c: designware-platdrv: Return error in ->probe() when clk ungate fails
Date: Tue, 14 Jun 2016 17:07:19 +0200 [thread overview]
Message-ID: <1465916848-8207-2-git-send-email-ulf.hansson@linaro.org> (raw)
In-Reply-To: <1465916848-8207-1-git-send-email-ulf.hansson@linaro.org>
The error code received from clk_prepare_enable() becomes ignored when
i2c_dw_plat_prepare_clk() is called in ->probe().
Fix this by invoking clk_prepare_enable() in ->probe() instead of
i2c_dw_plat_prepare_clk(), as it allows the error code to be properly
propagated.
A side-effect from this change, makes the i2c_dw_plat_prepare_clk() used
only when CONFIG_PM is set. Avoid the compiler warning by moving the
function within the corresponding #ifdef.
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
drivers/i2c/busses/i2c-designware-platdrv.c | 30 ++++++++++++++++-------------
1 file changed, 17 insertions(+), 13 deletions(-)
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c
index d656657..e39962b 100644
--- a/drivers/i2c/busses/i2c-designware-platdrv.c
+++ b/drivers/i2c/busses/i2c-designware-platdrv.c
@@ -136,18 +136,6 @@ static inline int dw_i2c_acpi_configure(struct platform_device *pdev)
}
#endif
-static int i2c_dw_plat_prepare_clk(struct dw_i2c_dev *i_dev, bool prepare)
-{
- if (IS_ERR(i_dev->clk))
- return PTR_ERR(i_dev->clk);
-
- if (prepare)
- return clk_prepare_enable(i_dev->clk);
-
- clk_disable_unprepare(i_dev->clk);
- return 0;
-}
-
static int dw_i2c_plat_probe(struct platform_device *pdev)
{
struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -220,7 +208,11 @@ static int dw_i2c_plat_probe(struct platform_device *pdev)
DW_IC_CON_RESTART_EN | DW_IC_CON_SPEED_FAST;
dev->clk = devm_clk_get(&pdev->dev, NULL);
- if (!i2c_dw_plat_prepare_clk(dev, true)) {
+ if (!IS_ERR(dev->clk)) {
+ r = clk_prepare_enable(dev->clk);
+ if (r)
+ return r;
+
dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz;
if (!dev->sda_hold_time && ht)
@@ -302,6 +294,18 @@ static void dw_i2c_plat_complete(struct device *dev)
#endif
#ifdef CONFIG_PM
+static int i2c_dw_plat_prepare_clk(struct dw_i2c_dev *i_dev, bool prepare)
+{
+ if (IS_ERR(i_dev->clk))
+ return PTR_ERR(i_dev->clk);
+
+ if (prepare)
+ return clk_prepare_enable(i_dev->clk);
+
+ clk_disable_unprepare(i_dev->clk);
+ return 0;
+}
+
static int dw_i2c_plat_suspend(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
--
1.9.1
next prev parent reply other threads:[~2016-06-14 15:07 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-14 15:07 [PATCH 00/10] i2c: designware-platdrv: Some improvments related to PM Ulf Hansson
2016-06-14 15:07 ` Ulf Hansson [this message]
2016-06-15 7:04 ` [PATCH 01/10] i2c: designware-platdrv: Return error in ->probe() when clk ungate fails Jarkko Nikula
2016-06-14 15:07 ` [PATCH 02/10] i2c: designware-platdrv: Gate clk in error path in ->probe() Ulf Hansson
2016-06-14 15:22 ` Andy Shevchenko
2016-06-15 7:16 ` Ulf Hansson
2016-06-15 12:07 ` Jarkko Nikula
2016-06-20 4:41 ` Ulf Hansson
2016-06-14 15:07 ` [PATCH 03/10] i2c: designware-platdrv: Unconditionally enable runtime PM Ulf Hansson
2016-06-15 12:47 ` Jarkko Nikula
2016-06-20 5:15 ` Ulf Hansson
2016-06-14 15:07 ` [PATCH 04/10] i2c: designware-platdrv: Disable autosuspend in error path in ->probe() Ulf Hansson
2016-06-14 15:07 ` [PATCH 05/10] i2c: designware-platdrv: Fix clk gating in ->remove() Ulf Hansson
2016-06-14 15:07 ` [PATCH 06/10] i2c: designware-platdrv: Update runtime PM last busy mark in ->probe() Ulf Hansson
2016-06-15 13:22 ` Jarkko Nikula
2016-06-14 15:07 ` [PATCH 07/10] i2c: designware-platdrv: Re-init the HW when resuming Ulf Hansson
2016-06-14 15:07 ` [PATCH 08/10] i2c: designware-platdrv: Check return value from clk_prepare_enable() Ulf Hansson
2016-06-14 15:07 ` [PATCH 09/10] i2c: designware-platdrv: Simplify code by using dev_get_drvdata() Ulf Hansson
2016-06-15 11:24 ` Jarkko Nikula
2016-06-14 15:07 ` [PATCH 10/10] i2c: designware-platdrv: Rework system PM support Ulf Hansson
2016-06-14 15:35 ` Andy Shevchenko
2016-06-15 7:52 ` Ulf Hansson
2016-06-14 15:39 ` [PATCH 00/10] i2c: designware-platdrv: Some improvments related to PM Andy Shevchenko
2016-06-15 8:16 ` Ulf Hansson
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=1465916848-8207-2-git-send-email-ulf.hansson@linaro.org \
--to=ulf.hansson@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).