From: Biju Das <biju.das.jz@bp.renesas.com>
To: Wolfram Sang <wsa@kernel.org>
Cc: Biju Das <biju.das.jz@bp.renesas.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Philipp Zabel <p.zabel@pengutronix.de>,
linux-i2c@vger.kernel.org,
Geert Uytterhoeven <geert+renesas@glider.be>,
Prabhakar Mahadev Lad <prabhakar.mahadev-lad.rj@bp.renesas.com>,
linux-renesas-soc@vger.kernel.org, Pavel Machek <pavel@denx.de>
Subject: [PATCH RESEND v2 3/3] i2c: rzv2m: Disable the operation of unit in case of error
Date: Fri, 26 May 2023 14:57:38 +0100 [thread overview]
Message-ID: <20230526135738.348294-4-biju.das.jz@bp.renesas.com> (raw)
In-Reply-To: <20230526135738.348294-1-biju.das.jz@bp.renesas.com>
The remove and suspend callbacks disable the operation of the unit.
Do the same in probe() in case of error.
While at it, introduce a helper function rzv2m_i2c_disable() for
disabling the operation of the unit and this function is shared
between probe error path, remove and suspend callbacks.
Reported-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
v1->v2:
* Introduced rzv2m_i2c_disable() and shared the code between
probe error path, remove and suspend callbacks.
* Updated commit description.
---
drivers/i2c/busses/i2c-rzv2m.c | 30 +++++++++++++++++++-----------
1 file changed, 19 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-rzv2m.c b/drivers/i2c/busses/i2c-rzv2m.c
index b97e29871558..7acde5133e51 100644
--- a/drivers/i2c/busses/i2c-rzv2m.c
+++ b/drivers/i2c/busses/i2c-rzv2m.c
@@ -389,6 +389,20 @@ static u32 rzv2m_i2c_func(struct i2c_adapter *adap)
I2C_FUNC_10BIT_ADDR;
}
+static int rzv2m_i2c_disable(struct device *dev, struct rzv2m_i2c_priv *priv)
+{
+ int ret;
+
+ ret = pm_runtime_resume_and_get(dev);
+ if (ret < 0)
+ return ret;
+
+ bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
+ pm_runtime_put(dev);
+
+ return 0;
+}
+
static const struct i2c_adapter_quirks rzv2m_i2c_quirks = {
.flags = I2C_AQ_NO_ZERO_LEN,
};
@@ -461,8 +475,10 @@ static int rzv2m_i2c_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, priv);
ret = i2c_add_numbered_adapter(adap);
- if (ret < 0)
+ if (ret < 0) {
+ rzv2m_i2c_disable(dev, priv);
pm_runtime_disable(dev);
+ }
return ret;
}
@@ -473,7 +489,7 @@ static int rzv2m_i2c_remove(struct platform_device *pdev)
struct device *dev = priv->adap.dev.parent;
i2c_del_adapter(&priv->adap);
- bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
+ rzv2m_i2c_disable(dev, priv);
pm_runtime_disable(dev);
return 0;
@@ -482,16 +498,8 @@ static int rzv2m_i2c_remove(struct platform_device *pdev)
static int rzv2m_i2c_suspend(struct device *dev)
{
struct rzv2m_i2c_priv *priv = dev_get_drvdata(dev);
- int ret;
-
- ret = pm_runtime_resume_and_get(dev);
- if (ret < 0)
- return ret;
-
- bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
- pm_runtime_put(dev);
- return 0;
+ return rzv2m_i2c_disable(dev, priv);
}
static int rzv2m_i2c_resume(struct device *dev)
--
2.25.1
next prev parent reply other threads:[~2023-05-26 13:58 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-26 13:57 [PATCH RESEND v2 0/3] RZ/V2M I2Cdriver clean ups Biju Das
2023-05-26 13:57 ` [PATCH RESEND v2 1/3] i2c: rzv2m: Drop extra space Biju Das
2023-06-05 9:17 ` Wolfram Sang
2023-05-26 13:57 ` [PATCH RESEND v2 2/3] i2c: rzv2m: Replace lowercase macros with static inline functions Biju Das
2023-06-05 9:19 ` Wolfram Sang
2023-05-26 13:57 ` Biju Das [this message]
2023-06-05 9:19 ` [PATCH RESEND v2 3/3] i2c: rzv2m: Disable the operation of unit in case of error Wolfram Sang
2023-06-05 9:32 ` Biju Das
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=20230526135738.348294-4-biju.das.jz@bp.renesas.com \
--to=biju.das.jz@bp.renesas.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=geert+renesas@glider.be \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=p.zabel@pengutronix.de \
--cc=pavel@denx.de \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=wsa@kernel.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).