Re: [PATCH v2] i2c:amd I2C Driver based on PCI Interface for upcoming, platform

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

 



Hi Nehal-bakulchandra,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on wsa/i2c/for-next]
[also build test WARNING on v4.18 next-20180822]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Shah-Nehal-bakulchandra/i2c-amd-I2C-Driver-based-on-PCI-Interface-for-upcoming-platform/20180823-232746
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next
config: i386-allyesconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/i2c//busses/i2c-amd-pci-mp2.c: In function 'amd_mp2_read':
   drivers/i2c//busses/i2c-amd-pci-mp2.c:120:82: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
      dev_dbg(ndev_dev(privdata), "%s buf: %llx\n", __func__,
                                                                                     ^
   drivers/i2c//busses/i2c-amd-pci-mp2.c: In function 'amd_mp2_debugfs_read':
>> drivers/i2c//busses/i2c-amd-pci-mp2.c:325:66: warning: comparison of distinct pointer types lacks a cast
     buf_size = min(count, 0x800ul);
                                                                     ^ 
   drivers/i2c//busses/i2c-amd-pci-mp2.c: In function 'amd_mp2_pci_init':
   drivers/i2c//busses/i2c-amd-pci-mp2.c:473:53: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 4 has type 'resource_size_t {aka unsigned int}' [-Wformat=]
     dev_dbg(ndev_dev(privdata), "Base addr:%llx size:%llx\n", base, size);
                                                        ^~~~~~~~~~~~~~~~~~~         
   drivers/i2c//busses/i2c-amd-pci-mp2.c:473:53: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 5 has type 'resource_size_t {aka unsigned int}' [-Wformat=]
smatch warnings:
drivers/i2c/busses/i2c-amd-pci-mp2.c:93 amd_mp2_connect() warn: inconsistent returns 'spin_lock:&privdata->lock'.
  Locked on:   line 90
  Unlocked on: line 93
drivers/i2c/busses/i2c-amd-pci-mp2.c:93 amd_mp2_connect() warn: inconsistent returns 'irqsave:flags'.
  Locked on:   line 90
  Unlocked on: line 93
drivers/i2c/busses/i2c-amd-pci-mp2.c:120 amd_mp2_read() warn: argument 5 to %llx specifier is cast from pointer
drivers/i2c/busses/i2c-amd-pci-mp2.c:527 amd_mp2_pci_probe() error: potential null dereference 'privdata'.  (kzalloc returns null)
drivers/i2c/busses/i2c-amd-pci-mp2.c:529 amd_mp2_pci_probe() warn: variable dereferenced before check 'privdata' (see line 527)

# https://github.com/0day-ci/linux/commit/da2ae4a10759e5b6bfc7fb3afd91d08e66cf19c0
git remote add linux-review https://github.com/0day-ci/linux
git remote update linux-review
git checkout da2ae4a10759e5b6bfc7fb3afd91d08e66cf19c0
vim +93 drivers/i2c/busses/i2c-amd-pci-mp2.c

da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   67  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   68  int amd_mp2_connect(struct pci_dev *dev,
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   69  		    struct i2c_connect_config connect_cfg)
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   70  {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   71  	struct amd_mp2_dev *privdata = pci_get_drvdata(dev);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   72  	union i2c_cmd_base i2c_cmd_base;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   73  	unsigned  long  flags;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   74  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   75  	raw_spin_lock_irqsave(&privdata->lock, flags);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   76  	dev_dbg(ndev_dev(privdata), "%s addr: %x id: %d\n", __func__,
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   77  		connect_cfg.dev_addr, connect_cfg.bus_id);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   78  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   79  	i2c_cmd_base.ul = 0;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   80  	i2c_cmd_base.s.i2c_cmd = i2c_enable;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   81  	i2c_cmd_base.s.bus_id = connect_cfg.bus_id;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   82  	i2c_cmd_base.s.i2c_speed = connect_cfg.i2c_speed;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   83  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   84  	if (i2c_cmd_base.s.bus_id == i2c_bus_1) {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   85  		writel(i2c_cmd_base.ul, privdata->mmio + AMD_C2P_MSG1);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   86  	} else if (i2c_cmd_base.s.bus_id == i2c_bus_0) {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   87  		writel(i2c_cmd_base.ul, privdata->mmio + AMD_C2P_MSG0);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   88  	} else {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   89  		dev_err(ndev_dev(privdata), "%s Invalid bus id\n", __func__);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   90  		return -EINVAL;
                                                                 ^^^^^^^^^^^^^
Need to unlock.

da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   91  	}
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   92  	raw_spin_unlock_irqrestore(&privdata->lock, flags);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  @93  	return 0;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   94  }
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   95  EXPORT_SYMBOL_GPL(amd_mp2_connect);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   96  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   97  int amd_mp2_read(struct pci_dev *dev, struct i2c_read_config read_cfg)
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   98  {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23   99  	struct amd_mp2_dev *privdata = pci_get_drvdata(dev);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  100  	union i2c_cmd_base i2c_cmd_base;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  101  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  102  	dev_dbg(ndev_dev(privdata), "%s addr: %x id: %d\n", __func__,
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  103  		read_cfg.dev_addr, read_cfg.bus_id);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  104  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  105  	privdata->requested = true;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  106  	i2c_cmd_base.ul = 0;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  107  	i2c_cmd_base.s.i2c_cmd = i2c_read;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  108  	i2c_cmd_base.s.dev_addr = read_cfg.dev_addr;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  109  	i2c_cmd_base.s.length = read_cfg.length;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  110  	i2c_cmd_base.s.bus_id = read_cfg.bus_id;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  111  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  112  	if (read_cfg.length <= 32) {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  113  		i2c_cmd_base.s.mem_type = use_c2pmsg;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  114  		privdata->eventval.buf = (u32 *)read_cfg.buf;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  115  		if (!privdata->eventval.buf) {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  116  			dev_err(ndev_dev(privdata), "%s no mem for buf received\n",
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  117  				__func__);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  118  			return -ENOMEM;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  119  		}
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23 @120  		dev_dbg(ndev_dev(privdata), "%s buf: %llx\n", __func__,
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  121  			(u64)privdata->eventval.buf);
                                                                             ^^^^^^^^^^^^^^^^^^^^^^
This is a pointer so we want to hide that in the dmesg unless people
have enough privileges or whatever.

da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  122  	} else {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  123  		i2c_cmd_base.s.mem_type = use_dram;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  124  		privdata->read_cfg.phy_addr = read_cfg.phy_addr;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  125  		privdata->read_cfg.buf = read_cfg.buf;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  126  		write64((u64)privdata->read_cfg.phy_addr,
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  127  			privdata->mmio + AMD_C2P_MSG2);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  128  	}
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  129  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  130  	switch (read_cfg.i2c_speed) {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  131  	case 0:
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  132  		i2c_cmd_base.s.i2c_speed = speed100k;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  133  		break;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  134  	case 1:
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  135  		i2c_cmd_base.s.i2c_speed = speed400k;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  136  		break;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  137  	case 2:
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  138  		i2c_cmd_base.s.i2c_speed = speed1000k;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  139  		break;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  140  	case 3:
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  141  		i2c_cmd_base.s.i2c_speed = speed1400k;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  142  		break;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  143  	case 4:
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  144  		i2c_cmd_base.s.i2c_speed = speed3400k;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  145  		break;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  146  	default:
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  147  		dev_err(ndev_dev(privdata), "Invalid ConnectionSpeed\n");
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  148  	}
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  149  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  150  	if (i2c_cmd_base.s.bus_id == i2c_bus_1) {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  151  		writel(i2c_cmd_base.ul, privdata->mmio + AMD_C2P_MSG1);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  152  	} else if (i2c_cmd_base.s.bus_id == i2c_bus_0) {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  153  		writel(i2c_cmd_base.ul, privdata->mmio + AMD_C2P_MSG0);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  154  	} else {
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  155  		dev_err(ndev_dev(privdata), "%s Invalid bus id\n", __func__);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  156  		return -EINVAL;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  157  	}
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  158  
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  159  	return 0;
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  160  }
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  161  EXPORT_SYMBOL_GPL(amd_mp2_read);
da2ae4a1 Nehal-bakulchandra Shah 2018-08-23  162  

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux