Skip to contentSkip to conversation

i2c: gpio: Use dev_err_probe()

PATCH New [email protected] 2 participants 3 messages Mar 22, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: gpio: Use dev_err_probe()

From: Ye Xingchen <[email protected]>

Replace the open-code with dev_err_probe() to simplify the code.

---
 drivers/i2c/busses/i2c-gpio.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i2c/busses/i2c-gpio.c +2 -2
index 1794c0399f22..a83f241d7b62 100644
@@ -355,8 +355,8 @@ static struct gpio_desc *i2c_gpio_get_desc(struct device *dev,
 	if (ret == -ENOENT)
 		retdesc = ERR_PTR(-EPROBE_DEFER);
 
-	if (PTR_ERR(retdesc) != -EPROBE_DEFER)
-		dev_err(dev, "error trying to get descriptor: %d\n", ret);
+	dev_err_probe(dev, PTR_ERR(retdesc),
+		      "error trying to get descriptor: %d\n");
 
 	return retdesc;
 }
Signature · 1 line
2.25.1
#1 lore raw
Thank you for the patch! Perhaps something to improve:

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on linus/master v6.3-rc3 next-20230322] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/ye-xingchen-zte-com-cn/i2c-gpio-Use-dev_err_probe/20230322-164142
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/202303221640559786295%40zte.com.cn
patch subject: [PATCH] i2c: gpio: Use dev_err_probe()
config: powerpc-allmodconfig (https://download.01.org/0day-ci/archive/20230322/[email protected]/config)
compiler: powerpc-linux-gcc (GCC) 12.1.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/6d20957af4d6ae04d7249889f6a52bb88a89ce29
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review ye-xingchen-zte-com-cn/i2c-gpio-Use-dev_err_probe/20230322-164142 git checkout 6d20957af4d6ae04d7249889f6a52bb88a89ce29
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=powerpc SHELL=/bin/bash drivers/i2c/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

drivers/i2c/busses/i2c-gpio.c: In function 'i2c_gpio_get_desc':

>> drivers/i2c/busses/i2c-gpio.c:359:57: warning: format '%d' expects a matching 'int' argument [-Wformat=]
     359 |                       "error trying to get descriptor: %d\n");
         |                                                        ~^
         |                                                         |
         |                                                         int

vim +359 drivers/i2c/busses/i2c-gpio.c

327
328 static struct gpio_desc *i2c_gpio_get_desc(struct device *dev,

   329						   const char *con_id,
   330						   unsigned int index,
   331						   enum gpiod_flags gflags)
   332	{
   333		struct gpio_desc *retdesc;
   334		int ret;
   335	
   336		retdesc = devm_gpiod_get(dev, con_id, gflags);
   337		if (!IS_ERR(retdesc)) {
   338			dev_dbg(dev, "got GPIO from name %s\n", con_id);
   339			return retdesc;
   340		}
   341	
   342		retdesc = devm_gpiod_get_index(dev, NULL, index, gflags);
   343		if (!IS_ERR(retdesc)) {
   344			dev_dbg(dev, "got GPIO from index %u\n", index);
   345			return retdesc;
   346		}
   347	
   348		ret = PTR_ERR(retdesc);
   349	
   350		/* FIXME: hack in the old code, is this really necessary? */
   351		if (ret == -EINVAL)
   352			retdesc = ERR_PTR(-EPROBE_DEFER);
   353	
   354		/* This happens if the GPIO driver is not yet probed, let's defer */
   355		if (ret == -ENOENT)
   356			retdesc = ERR_PTR(-EPROBE_DEFER);
   357	
   358		dev_err_probe(dev, PTR_ERR(retdesc),
 > 359			      "error trying to get descriptor: %d\n");

360
361 return retdesc;
362 }
363

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
#2 lore raw
In reply to [email protected]
Thank you for the patch! Perhaps something to improve:

Hi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on linus/master v6.3-rc3 next-20230322] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/ye-xingchen-zte-com-cn/i2c-gpio-Use-dev_err_probe/20230322-164142
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
patch link:    https://lore.kernel.org/r/202303221640559786295%40zte.com.cn
patch subject: [PATCH] i2c: gpio: Use dev_err_probe()
config: arm-randconfig-r046-20230322 (https://download.01.org/0day-ci/archive/20230322/[email protected]/config)
compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project 67409911353323ca5edf2049ef0df54132fa1ca7)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/intel-lab-lkp/linux/commit/6d20957af4d6ae04d7249889f6a52bb88a89ce29
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review ye-xingchen-zte-com-cn/i2c-gpio-Use-dev_err_probe/20230322-164142 git checkout 6d20957af4d6ae04d7249889f6a52bb88a89ce29
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/i2c/busses/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> drivers/i2c/busses/i2c-gpio.c:359:43: warning: more '%' conversions than data arguments [-Wformat-insufficient-args]
                         "error trying to get descriptor: %d\n");
                                                          ~^

1 warning generated.

vim +359 drivers/i2c/busses/i2c-gpio.c

327
328 static struct gpio_desc *i2c_gpio_get_desc(struct device *dev,

   329						   const char *con_id,
   330						   unsigned int index,
   331						   enum gpiod_flags gflags)
   332	{
   333		struct gpio_desc *retdesc;
   334		int ret;
   335	
   336		retdesc = devm_gpiod_get(dev, con_id, gflags);
   337		if (!IS_ERR(retdesc)) {
   338			dev_dbg(dev, "got GPIO from name %s\n", con_id);
   339			return retdesc;
   340		}
   341	
   342		retdesc = devm_gpiod_get_index(dev, NULL, index, gflags);
   343		if (!IS_ERR(retdesc)) {
   344			dev_dbg(dev, "got GPIO from index %u\n", index);
   345			return retdesc;
   346		}
   347	
   348		ret = PTR_ERR(retdesc);
   349	
   350		/* FIXME: hack in the old code, is this really necessary? */
   351		if (ret == -EINVAL)
   352			retdesc = ERR_PTR(-EPROBE_DEFER);
   353	
   354		/* This happens if the GPIO driver is not yet probed, let's defer */
   355		if (ret == -ENOENT)
   356			retdesc = ERR_PTR(-EPROBE_DEFER);
   357	
   358		dev_err_probe(dev, PTR_ERR(retdesc),
 > 359			      "error trying to get descriptor: %d\n");

360
361 return retdesc;
362 }
363

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests