[wsa:renesas/topic/i2c-core-dma-rfc-v4 6/6] drivers//i2c/i2c-dev.c:284:23: error: 'I2C_M_SAFE_DMA' undeclared

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git renesas/topic/i2c-core-dma-rfc-v4
head:   e5923c5b3755a942ffc365b4a47baac43533c7e3
commit: e5923c5b3755a942ffc365b4a47baac43533c7e3 [6/6] i2c: dev: mark RDWR buffers as DMA_SAFE
config: x86_64-randconfig-x016-201733 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        git checkout e5923c5b3755a942ffc365b4a47baac43533c7e3
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   drivers//i2c/i2c-dev.c: In function 'i2cdev_ioctl_rdwr':
>> drivers//i2c/i2c-dev.c:284:23: error: 'I2C_M_SAFE_DMA' undeclared (first use in this function)
      rdwr_pa[i].flags |= I2C_M_SAFE_DMA;
                          ^~~~~~~~~~~~~~
   drivers//i2c/i2c-dev.c:284:23: note: each undeclared identifier is reported only once for each function it appears in

vim +/I2C_M_SAFE_DMA +284 drivers//i2c/i2c-dev.c

   239	
   240	static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
   241			unsigned long arg)
   242	{
   243		struct i2c_rdwr_ioctl_data rdwr_arg;
   244		struct i2c_msg *rdwr_pa;
   245		u8 __user **data_ptrs;
   246		int i, res;
   247	
   248		if (copy_from_user(&rdwr_arg,
   249				   (struct i2c_rdwr_ioctl_data __user *)arg,
   250				   sizeof(rdwr_arg)))
   251			return -EFAULT;
   252	
   253		/* Put an arbitrary limit on the number of messages that can
   254		 * be sent at once */
   255		if (rdwr_arg.nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
   256			return -EINVAL;
   257	
   258		rdwr_pa = memdup_user(rdwr_arg.msgs,
   259				      rdwr_arg.nmsgs * sizeof(struct i2c_msg));
   260		if (IS_ERR(rdwr_pa))
   261			return PTR_ERR(rdwr_pa);
   262	
   263		data_ptrs = kmalloc(rdwr_arg.nmsgs * sizeof(u8 __user *), GFP_KERNEL);
   264		if (data_ptrs == NULL) {
   265			kfree(rdwr_pa);
   266			return -ENOMEM;
   267		}
   268	
   269		res = 0;
   270		for (i = 0; i < rdwr_arg.nmsgs; i++) {
   271			/* Limit the size of the message to a sane amount */
   272			if (rdwr_pa[i].len > 8192) {
   273				res = -EINVAL;
   274				break;
   275			}
   276	
   277			data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
   278			rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
   279			if (IS_ERR(rdwr_pa[i].buf)) {
   280				res = PTR_ERR(rdwr_pa[i].buf);
   281				break;
   282			}
   283			/* memdup_user allocates with GFP_KERNEL, so DMA is ok */
 > 284			rdwr_pa[i].flags |= I2C_M_SAFE_DMA;
   285	
   286			/*
   287			 * If the message length is received from the slave (similar
   288			 * to SMBus block read), we must ensure that the buffer will
   289			 * be large enough to cope with a message length of
   290			 * I2C_SMBUS_BLOCK_MAX as this is the maximum underlying bus
   291			 * drivers allow. The first byte in the buffer must be
   292			 * pre-filled with the number of extra bytes, which must be
   293			 * at least one to hold the message length, but can be
   294			 * greater (for example to account for a checksum byte at
   295			 * the end of the message.)
   296			 */
   297			if (rdwr_pa[i].flags & I2C_M_RECV_LEN) {
   298				if (!(rdwr_pa[i].flags & I2C_M_RD) ||
   299				    rdwr_pa[i].buf[0] < 1 ||
   300				    rdwr_pa[i].len < rdwr_pa[i].buf[0] +
   301						     I2C_SMBUS_BLOCK_MAX) {
   302					res = -EINVAL;
   303					break;
   304				}
   305	
   306				rdwr_pa[i].len = rdwr_pa[i].buf[0];
   307			}
   308		}
   309		if (res < 0) {
   310			int j;
   311			for (j = 0; j < i; ++j)
   312				kfree(rdwr_pa[j].buf);
   313			kfree(data_ptrs);
   314			kfree(rdwr_pa);
   315			return res;
   316		}
   317	
   318		res = i2c_transfer(client->adapter, rdwr_pa, rdwr_arg.nmsgs);
   319		while (i-- > 0) {
   320			if (res >= 0 && (rdwr_pa[i].flags & I2C_M_RD)) {
   321				if (copy_to_user(data_ptrs[i], rdwr_pa[i].buf,
   322						 rdwr_pa[i].len))
   323					res = -EFAULT;
   324			}
   325			kfree(rdwr_pa[i].buf);
   326		}
   327		kfree(data_ptrs);
   328		kfree(rdwr_pa);
   329		return res;
   330	}
   331	

---
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]     [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