diff options
author | Biju Das <biju.das.jz@bp.renesas.com> | 2023-05-26 16:57:38 +0300 |
---|---|---|
committer | Wolfram Sang <wsa@kernel.org> | 2023-06-05 13:03:35 +0300 |
commit | c3cc5c59cb16dbf14d8c52ac4df6650438613b5b (patch) | |
tree | 5ad40cdc8f2074b79280656d19f81b3037a03dab /drivers/i2c | |
parent | 252f211bd0328c6a3d7d30eaf4d59a8363f3d578 (diff) | |
download | linux-c3cc5c59cb16dbf14d8c52ac4df6650438613b5b.tar.xz |
i2c: rzv2m: Disable the operation of unit in case of error
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>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-rzv2m.c | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/drivers/i2c/busses/i2c-rzv2m.c b/drivers/i2c/busses/i2c-rzv2m.c index f4b805eae0f6..b0bfc96b9ede 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,23 +489,15 @@ static void 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); } 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) |