Re: [PATCH 4/4] i2c-mux-pca954x: Add regulator support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Patrick,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on robh/for-next linux/master linus/master v5.16-rc5]
[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]

url:    https://github.com/0day-ci/linux/commits/Patrick-Rudolph/dt-bindings-i2c-Update-PCA954x/20211214-175258
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: riscv-randconfig-r042-20211214 (https://download.01.org/0day-ci/archive/20211214/202112142101.s4i5cHhd-lkp@xxxxxxxxx/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project b6a2ddb6c8ac29412b1361810972e15221fa021c)
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 riscv cross compiling tool for clang build
        # apt-get install binutils-riscv64-linux-gnu
        # https://github.com/0day-ci/linux/commit/3498c52eb6aec09c78a3f07cdcb042897960f8ef
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Patrick-Rudolph/dt-bindings-i2c-Update-PCA954x/20211214-175258
        git checkout 3498c52eb6aec09c78a3f07cdcb042897960f8ef
        # save the config file to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash drivers/i2c/muxes/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/i2c/muxes/i2c-mux-pca954x.c:502:58: warning: variable 'ret' is uninitialized when used here [-Wuninitialized]
                   dev_warn(dev, "Failed to get regulator for vcc: %d\n", ret);
                                                                          ^~~
   include/linux/dev_printk.h:146:70: note: expanded from macro 'dev_warn'
           dev_printk_index_wrap(_dev_warn, KERN_WARNING, dev, dev_fmt(fmt), ##__VA_ARGS__)
                                                                               ^~~~~~~~~~~
   include/linux/dev_printk.h:110:23: note: expanded from macro 'dev_printk_index_wrap'
                   _p_func(dev, fmt, ##__VA_ARGS__);                       \
                                       ^~~~~~~~~~~
   drivers/i2c/muxes/i2c-mux-pca954x.c:483:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0
   1 warning generated.


vim +/ret +502 drivers/i2c/muxes/i2c-mux-pca954x.c

   470	
   471	/*
   472	 * I2C init/probing/exit functions
   473	 */
   474	static int pca954x_probe(struct i2c_client *client,
   475				 const struct i2c_device_id *id)
   476	{
   477		struct i2c_adapter *adap = client->adapter;
   478		struct device *dev = &client->dev;
   479		struct gpio_desc *gpio;
   480		struct i2c_mux_core *muxc;
   481		struct pca954x *data;
   482		int num;
   483		int ret;
   484	
   485		if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE))
   486			return -ENODEV;
   487	
   488		muxc = i2c_mux_alloc(adap, dev, PCA954X_MAX_NCHANS, sizeof(*data), 0,
   489				     pca954x_select_chan, pca954x_deselect_mux);
   490		if (!muxc)
   491			return -ENOMEM;
   492	
   493		data = i2c_mux_priv(muxc);
   494	
   495		i2c_set_clientdata(client, muxc);
   496		data->client = client;
   497	
   498		data->supply = devm_regulator_get(dev, "vcc");
   499		if (IS_ERR(data->supply)) {
   500			if ((PTR_ERR(data->supply) == -EPROBE_DEFER))
   501				return -EPROBE_DEFER;
 > 502			dev_warn(dev, "Failed to get regulator for vcc: %d\n", ret);
   503		} else {
   504			ret = regulator_enable(data->supply);
   505			if (ret) {
   506				dev_err(dev, "Failed to enable regulator vcc\n");
   507				return ret;
   508			}
   509		}
   510	
   511		/* Reset the mux if a reset GPIO is specified. */
   512		gpio = devm_gpiod_get_optional(dev, "reset", GPIOD_OUT_HIGH);
   513		if (IS_ERR(gpio)) {
   514			ret = PTR_ERR(gpio);
   515			goto fail_cleanup;
   516		}
   517		if (gpio) {
   518			udelay(1);
   519			gpiod_set_value_cansleep(gpio, 0);
   520			/* Give the chip some time to recover. */
   521			udelay(1);
   522		}
   523	
   524		data->chip = device_get_match_data(dev);
   525		if (!data->chip)
   526			data->chip = &chips[id->driver_data];
   527	
   528		if (data->chip->id.manufacturer_id != I2C_DEVICE_ID_NONE) {
   529			struct i2c_device_identity id;
   530	
   531			ret = i2c_get_device_id(client, &id);
   532			if (ret && ret != -EOPNOTSUPP)
   533				goto fail_cleanup;
   534	
   535			if (!ret &&
   536			    (id.manufacturer_id != data->chip->id.manufacturer_id ||
   537			     id.part_id != data->chip->id.part_id)) {
   538				dev_warn(dev, "unexpected device id %03x-%03x-%x\n",
   539					 id.manufacturer_id, id.part_id,
   540					 id.die_revision);
   541				ret = -ENODEV;
   542				goto fail_cleanup;
   543			}
   544		}
   545	
   546		data->idle_state = MUX_IDLE_AS_IS;
   547		if (device_property_read_u32(dev, "idle-state", &data->idle_state)) {
   548			if (device_property_read_bool(dev, "i2c-mux-idle-disconnect"))
   549				data->idle_state = MUX_IDLE_DISCONNECT;
   550		}
   551	
   552		/*
   553		 * Write the mux register at addr to verify
   554		 * that the mux is in fact present. This also
   555		 * initializes the mux to a channel
   556		 * or disconnected state.
   557		 */
   558		ret = pca954x_init(client, data);
   559		if (ret < 0) {
   560			dev_warn(dev, "probe failed\n");
   561			ret = -ENODEV;
   562			goto fail_cleanup;
   563		}
   564	
   565		ret = pca954x_irq_setup(muxc);
   566		if (ret)
   567			goto fail_cleanup;
   568	
   569		/* Now create an adapter for each channel */
   570		for (num = 0; num < data->chip->nchans; num++) {
   571			ret = i2c_mux_add_adapter(muxc, 0, num, 0);
   572			if (ret)
   573				goto fail_cleanup;
   574		}
   575	
   576		if (data->irq) {
   577			ret = devm_request_threaded_irq(dev, data->client->irq,
   578							NULL, pca954x_irq_handler,
   579							IRQF_ONESHOT | IRQF_SHARED,
   580							"pca954x", data);
   581			if (ret)
   582				goto fail_cleanup;
   583		}
   584	
   585		/*
   586		 * The attr probably isn't going to be needed in most cases,
   587		 * so don't fail completely on error.
   588		 */
   589		device_create_file(dev, &dev_attr_idle_state);
   590	
   591		dev_info(dev, "registered %d multiplexed busses for I2C %s %s\n",
   592			 num, data->chip->muxtype == pca954x_ismux
   593					? "mux" : "switch", client->name);
   594	
   595		return 0;
   596	
   597	fail_cleanup:
   598		pca954x_cleanup(muxc);
   599		return ret;
   600	}
   601	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux