All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: oe-kbuild@lists.linux.dev
Cc: lkp@intel.com, Dan Carpenter <error27@gmail.com>
Subject: [android-common:android14-kiwi-6.1 180/180] drivers/i2c/busses/i2c-pxa.c:1364 i2c_pxa_init_recovery() warn: passing zero to 'PTR_ERR'
Date: Thu, 09 Jul 2026 13:59:34 +0800	[thread overview]
Message-ID: <202607091344.tyIUh9ZX-lkp@intel.com> (raw)

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
TO: cros-kernel-buildreports@googlegroups.com

tree:   https://android.googlesource.com/kernel/common android14-kiwi-6.1
head:   7b80053b707666e258e504127dd1bf5ac555f5e1
commit: b3fd9db79e30d5eb5f76ef1f5b7e4f444af574ea [180/180] Revert "i2c: pxa: move to generic GPIO recovery"
:::::: branch date: 2 days ago
:::::: commit date: 2 years, 7 months ago
config: i386-randconfig-141-20260708 (https://download.01.org/0day-ci/archive/20260709/202607091344.tyIUh9ZX-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9185-gbcc58b9c

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202607091344.tyIUh9ZX-lkp@intel.com/

smatch warnings:
drivers/i2c/busses/i2c-pxa.c:1364 i2c_pxa_init_recovery() warn: passing zero to 'PTR_ERR'
drivers/i2c/busses/i2c-pxa.c:1364 i2c_pxa_init_recovery() warn: passing zero to 'PTR_ERR'

vim +/PTR_ERR +1364 drivers/i2c/busses/i2c-pxa.c

7c9ec2c5251851 Russell King 2020-05-13  1335  
7c9ec2c5251851 Russell King 2020-05-13  1336  static int i2c_pxa_init_recovery(struct pxa_i2c *i2c)
7c9ec2c5251851 Russell King 2020-05-13  1337  {
7c9ec2c5251851 Russell King 2020-05-13  1338  	struct i2c_bus_recovery_info *bri = &i2c->recovery;
7c9ec2c5251851 Russell King 2020-05-13  1339  	struct device *dev = i2c->adap.dev.parent;
7c9ec2c5251851 Russell King 2020-05-13  1340  
7c9ec2c5251851 Russell King 2020-05-13  1341  	/*
7c9ec2c5251851 Russell King 2020-05-13  1342  	 * When slave mode is enabled, we are not the only master on the bus.
7c9ec2c5251851 Russell King 2020-05-13  1343  	 * Bus recovery can only be performed when we are the master, which
7c9ec2c5251851 Russell King 2020-05-13  1344  	 * we can't be certain of. Therefore, when slave mode is enabled, do
7c9ec2c5251851 Russell King 2020-05-13  1345  	 * not configure bus recovery.
7c9ec2c5251851 Russell King 2020-05-13  1346  	 */
7c9ec2c5251851 Russell King 2020-05-13  1347  	if (IS_ENABLED(CONFIG_I2C_PXA_SLAVE))
7c9ec2c5251851 Russell King 2020-05-13  1348  		return 0;
7c9ec2c5251851 Russell King 2020-05-13  1349  
b3fd9db79e30d5 Robert Marko 2023-11-10  1350  	i2c->pinctrl = devm_pinctrl_get(dev);
b3fd9db79e30d5 Robert Marko 2023-11-10  1351  	if (PTR_ERR(i2c->pinctrl) == -ENODEV)
b3fd9db79e30d5 Robert Marko 2023-11-10  1352  		i2c->pinctrl = NULL;
b3fd9db79e30d5 Robert Marko 2023-11-10  1353  	if (IS_ERR(i2c->pinctrl))
b3fd9db79e30d5 Robert Marko 2023-11-10  1354  		return PTR_ERR(i2c->pinctrl);
b3fd9db79e30d5 Robert Marko 2023-11-10  1355  
b3fd9db79e30d5 Robert Marko 2023-11-10  1356  	if (!i2c->pinctrl)
b3fd9db79e30d5 Robert Marko 2023-11-10  1357  		return 0;
b3fd9db79e30d5 Robert Marko 2023-11-10  1358  
b3fd9db79e30d5 Robert Marko 2023-11-10  1359  	i2c->pinctrl_default = pinctrl_lookup_state(i2c->pinctrl,
b3fd9db79e30d5 Robert Marko 2023-11-10  1360  						    PINCTRL_STATE_DEFAULT);
b3fd9db79e30d5 Robert Marko 2023-11-10  1361  	i2c->pinctrl_recovery = pinctrl_lookup_state(i2c->pinctrl, "recovery");
b3fd9db79e30d5 Robert Marko 2023-11-10  1362  
b3fd9db79e30d5 Robert Marko 2023-11-10  1363  	if (IS_ERR(i2c->pinctrl_default) || IS_ERR(i2c->pinctrl_recovery)) {
b3fd9db79e30d5 Robert Marko 2023-11-10 @1364  		dev_info(dev, "missing pinmux recovery information: %ld %ld\n",
b3fd9db79e30d5 Robert Marko 2023-11-10  1365  			 PTR_ERR(i2c->pinctrl_default),
b3fd9db79e30d5 Robert Marko 2023-11-10  1366  			 PTR_ERR(i2c->pinctrl_recovery));
b3fd9db79e30d5 Robert Marko 2023-11-10  1367  		return 0;
b3fd9db79e30d5 Robert Marko 2023-11-10  1368  	}
b3fd9db79e30d5 Robert Marko 2023-11-10  1369  
b3fd9db79e30d5 Robert Marko 2023-11-10  1370  	/*
b3fd9db79e30d5 Robert Marko 2023-11-10  1371  	 * Claiming GPIOs can influence the pinmux state, and may glitch the
b3fd9db79e30d5 Robert Marko 2023-11-10  1372  	 * I2C bus. Do this carefully.
b3fd9db79e30d5 Robert Marko 2023-11-10  1373  	 */
b3fd9db79e30d5 Robert Marko 2023-11-10  1374  	bri->scl_gpiod = devm_gpiod_get(dev, "scl", GPIOD_OUT_HIGH_OPEN_DRAIN);
b3fd9db79e30d5 Robert Marko 2023-11-10  1375  	if (bri->scl_gpiod == ERR_PTR(-EPROBE_DEFER))
b3fd9db79e30d5 Robert Marko 2023-11-10  1376  		return -EPROBE_DEFER;
b3fd9db79e30d5 Robert Marko 2023-11-10  1377  	if (IS_ERR(bri->scl_gpiod)) {
b3fd9db79e30d5 Robert Marko 2023-11-10  1378  		dev_info(dev, "missing scl gpio recovery information: %pe\n",
b3fd9db79e30d5 Robert Marko 2023-11-10  1379  			 bri->scl_gpiod);
b3fd9db79e30d5 Robert Marko 2023-11-10  1380  		return 0;
b3fd9db79e30d5 Robert Marko 2023-11-10  1381  	}
b3fd9db79e30d5 Robert Marko 2023-11-10  1382  
b3fd9db79e30d5 Robert Marko 2023-11-10  1383  	/*
b3fd9db79e30d5 Robert Marko 2023-11-10  1384  	 * We have SCL. Pull SCL low and wait a bit so that SDA glitches
b3fd9db79e30d5 Robert Marko 2023-11-10  1385  	 * have no effect.
b3fd9db79e30d5 Robert Marko 2023-11-10  1386  	 */
b3fd9db79e30d5 Robert Marko 2023-11-10  1387  	gpiod_direction_output(bri->scl_gpiod, 0);
b3fd9db79e30d5 Robert Marko 2023-11-10  1388  	udelay(10);
b3fd9db79e30d5 Robert Marko 2023-11-10  1389  	bri->sda_gpiod = devm_gpiod_get(dev, "sda", GPIOD_OUT_HIGH_OPEN_DRAIN);
b3fd9db79e30d5 Robert Marko 2023-11-10  1390  
b3fd9db79e30d5 Robert Marko 2023-11-10  1391  	/* Wait a bit in case of a SDA glitch, and then release SCL. */
b3fd9db79e30d5 Robert Marko 2023-11-10  1392  	udelay(10);
b3fd9db79e30d5 Robert Marko 2023-11-10  1393  	gpiod_direction_output(bri->scl_gpiod, 1);
b3fd9db79e30d5 Robert Marko 2023-11-10  1394  
b3fd9db79e30d5 Robert Marko 2023-11-10  1395  	if (bri->sda_gpiod == ERR_PTR(-EPROBE_DEFER))
b3fd9db79e30d5 Robert Marko 2023-11-10  1396  		return -EPROBE_DEFER;
b3fd9db79e30d5 Robert Marko 2023-11-10  1397  
b3fd9db79e30d5 Robert Marko 2023-11-10  1398  	if (IS_ERR(bri->sda_gpiod)) {
b3fd9db79e30d5 Robert Marko 2023-11-10  1399  		dev_info(dev, "missing sda gpio recovery information: %pe\n",
b3fd9db79e30d5 Robert Marko 2023-11-10  1400  			 bri->sda_gpiod);
7c9ec2c5251851 Russell King 2020-05-13  1401  		return 0;
7c9ec2c5251851 Russell King 2020-05-13  1402  	}
7c9ec2c5251851 Russell King 2020-05-13  1403  
7c9ec2c5251851 Russell King 2020-05-13  1404  	bri->prepare_recovery = i2c_pxa_prepare_recovery;
7c9ec2c5251851 Russell King 2020-05-13  1405  	bri->unprepare_recovery = i2c_pxa_unprepare_recovery;
b3fd9db79e30d5 Robert Marko 2023-11-10  1406  	bri->recover_bus = i2c_generic_scl_recovery;
7c9ec2c5251851 Russell King 2020-05-13  1407  
7c9ec2c5251851 Russell King 2020-05-13  1408  	i2c->adap.bus_recovery_info = bri;
7c9ec2c5251851 Russell King 2020-05-13  1409  
b3fd9db79e30d5 Robert Marko 2023-11-10  1410  	/*
b3fd9db79e30d5 Robert Marko 2023-11-10  1411  	 * Claiming GPIOs can change the pinmux state, which confuses the
b3fd9db79e30d5 Robert Marko 2023-11-10  1412  	 * pinctrl since pinctrl's idea of the current setting is unaffected
b3fd9db79e30d5 Robert Marko 2023-11-10  1413  	 * by the pinmux change caused by claiming the GPIO. Work around that
b3fd9db79e30d5 Robert Marko 2023-11-10  1414  	 * by switching pinctrl to the GPIO state here. We do it this way to
b3fd9db79e30d5 Robert Marko 2023-11-10  1415  	 * avoid glitching the I2C bus.
b3fd9db79e30d5 Robert Marko 2023-11-10  1416  	 */
b3fd9db79e30d5 Robert Marko 2023-11-10  1417  	pinctrl_select_state(i2c->pinctrl, i2c->pinctrl_recovery);
b3fd9db79e30d5 Robert Marko 2023-11-10  1418  
b3fd9db79e30d5 Robert Marko 2023-11-10  1419  	return pinctrl_select_state(i2c->pinctrl, i2c->pinctrl_default);
7c9ec2c5251851 Russell King 2020-05-13  1420  }
7c9ec2c5251851 Russell King 2020-05-13  1421  

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2026-07-09  6:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202607091344.tyIUh9ZX-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=error27@gmail.com \
    --cc=oe-kbuild@lists.linux.dev \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.