Skip to content

Commit c3cc5c5

Browse files
bijudaswsakernel
authored andcommitted
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 <[email protected]> Signed-off-by: Biju Das <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 252f211 commit c3cc5c5

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

drivers/i2c/busses/i2c-rzv2m.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,20 @@ static u32 rzv2m_i2c_func(struct i2c_adapter *adap)
389389
I2C_FUNC_10BIT_ADDR;
390390
}
391391

392+
static int rzv2m_i2c_disable(struct device *dev, struct rzv2m_i2c_priv *priv)
393+
{
394+
int ret;
395+
396+
ret = pm_runtime_resume_and_get(dev);
397+
if (ret < 0)
398+
return ret;
399+
400+
bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
401+
pm_runtime_put(dev);
402+
403+
return 0;
404+
}
405+
392406
static const struct i2c_adapter_quirks rzv2m_i2c_quirks = {
393407
.flags = I2C_AQ_NO_ZERO_LEN,
394408
};
@@ -461,8 +475,10 @@ static int rzv2m_i2c_probe(struct platform_device *pdev)
461475
platform_set_drvdata(pdev, priv);
462476

463477
ret = i2c_add_numbered_adapter(adap);
464-
if (ret < 0)
478+
if (ret < 0) {
479+
rzv2m_i2c_disable(dev, priv);
465480
pm_runtime_disable(dev);
481+
}
466482

467483
return ret;
468484
}
@@ -473,23 +489,15 @@ static void rzv2m_i2c_remove(struct platform_device *pdev)
473489
struct device *dev = priv->adap.dev.parent;
474490

475491
i2c_del_adapter(&priv->adap);
476-
bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
492+
rzv2m_i2c_disable(dev, priv);
477493
pm_runtime_disable(dev);
478494
}
479495

480496
static int rzv2m_i2c_suspend(struct device *dev)
481497
{
482498
struct rzv2m_i2c_priv *priv = dev_get_drvdata(dev);
483-
int ret;
484-
485-
ret = pm_runtime_resume_and_get(dev);
486-
if (ret < 0)
487-
return ret;
488-
489-
bit_clrl(priv->base + IICB0CTL0, IICB0IICE);
490-
pm_runtime_put(dev);
491499

492-
return 0;
500+
return rzv2m_i2c_disable(dev, priv);
493501
}
494502

495503
static int rzv2m_i2c_resume(struct device *dev)

0 commit comments

Comments
 (0)