diff mbox series

[RESEND,v2,3/3] i2c: rzv2m: Disable the operation of unit in case of error

Message ID 20230526135738.348294-4-biju.das.jz@bp.renesas.com
State Accepted
Headers show
Series RZ/V2M I2Cdriver clean ups | expand

Commit Message

Biju Das May 26, 2023, 1:57 p.m. UTC
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(-)

Comments

Wolfram Sang June 5, 2023, 9:19 a.m. UTC | #1
On Fri, May 26, 2023 at 02:57:38PM +0100, Biju Das wrote:
> 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>

Applied to for-next, thanks!

Do you maybe want to add yourself as a MAINTAINER for this driver?
Biju Das June 5, 2023, 9:32 a.m. UTC | #2
Hi Wolfram Sang,

Thanks for the feedback.

> Subject: Re: [PATCH RESEND v2 3/3] i2c: rzv2m: Disable the operation of
> unit in case of error
> 
> On Fri, May 26, 2023 at 02:57:38PM +0100, Biju Das wrote:
> > 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>
> 
> Applied to for-next, thanks!
> 
> Do you maybe want to add yourself as a MAINTAINER for this driver?

Agreed. But Fabrizio is going to maintain this driver. So will update
MAINTAINER entries for this driver with Fabrizio's name/e-mail address.

Cheers,
Biju
diff mbox series

Patch

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)