[PATCH 6/8] i2c: nomadik: handle pm_runtime errors

Wolfram Sang wsa+renesas at sang-engineering.com
Sun Nov 8 23:15:29 PST 2026


On Mon, Nov 09, 2026 at 08:03:09AM +0100, Wolfram Sang wrote:
> 
> > -	pm_runtime_get_sync(&priv->adev->dev);
> > +	i = pm_runtime_get_sync(&priv->adev->dev);
> > +	if (i)
> > +		return i;
> 
> Testbots revealed a smatch warning:
> 
> drivers/i2c/busses/i2c-nomadik.c:737 nmk_i2c_xfer() warn: pm_runtime_get_sync() also returns 1 on success
> 
> I will fix it here.

Like this:

diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
index 104da275ff91..8cf1d443a25c 100644
--- a/drivers/i2c/busses/i2c-nomadik.c
+++ b/drivers/i2c/busses/i2c-nomadik.c
@@ -734,13 +734,13 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
 	struct nmk_i2c_dev *priv = i2c_get_adapdata(i2c_adap);
 
 	status = pm_runtime_get_sync(&priv->adev->dev);
-	if (status)
+	if (status < 0)
 		return status;
 
 	/* setup the i2c controller */
 	setup_i2c_controller(priv);
 
-	for (i = 0; i < num_msgs; i++) {
+	for (i = 0, status = 0; i < num_msgs; i++) {
 		priv->cli.slave_adr	= msgs[i].addr;
 		priv->cli.buffer		= msgs[i].buf;
 		priv->cli.count		= msgs[i].len;

Note that setting status = 0 is not really required as the I2C core will
ensure num_msgs to be > 0. But if people really hack around it, they
could circumvent that. And code checkers will recognize this path until
we fix the loophole.




More information about the linux-arm-kernel mailing list