drivers/staging/comedi/comedi_fops.c:2380:8: error: 'PAGE_SHARED' undeclared; did you mean 'VM_SHARED'?

From: kbuild test robot
Date: Fri Feb 28 2020 - 15:16:16 EST


Hi Paul,

FYI, the error/warning still remains.

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 45d0b75b98bf1de4b3a5b09188c75f3bfa3152b0
commit: 5ba9aa56e6d3e8fddb954c2f818d1ce0525235bb Merge branch 'next/nommu' into for-next
date: 3 months ago
config: riscv-randconfig-a001-20200229 (attached as .config)
compiler: riscv64-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
git checkout 5ba9aa56e6d3e8fddb954c2f818d1ce0525235bb
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=riscv

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

All errors (new ones prefixed by >>):

drivers/staging/comedi/comedi_fops.c: In function 'comedi_mmap':
>> drivers/staging/comedi/comedi_fops.c:2380:8: error: 'PAGE_SHARED' undeclared (first use in this function); did you mean 'VM_SHARED'?
PAGE_SHARED);
^~~~~~~~~~~
VM_SHARED
drivers/staging/comedi/comedi_fops.c:2380:8: note: each undeclared identifier is reported only once for each function it appears in

vim +2380 drivers/staging/comedi/comedi_fops.c

ed9eccbe8970f6 David Schleef 2008-11-04 2296
ed9eccbe8970f6 David Schleef 2008-11-04 2297 static int comedi_mmap(struct file *file, struct vm_area_struct *vma)
ed9eccbe8970f6 David Schleef 2008-11-04 2298 {
20f083c07565cb Ian Abbott 2014-11-04 2299 struct comedi_file *cfp = file->private_data;
20f083c07565cb Ian Abbott 2014-11-04 2300 struct comedi_device *dev = cfp->dev;
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2301 struct comedi_subdevice *s;
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2302 struct comedi_async *async;
b34aa86f12e884 Ian Abbott 2014-04-10 2303 struct comedi_buf_map *bm = NULL;
e36472145aa706 Ian Abbott 2019-06-25 2304 struct comedi_buf_page *buf;
ed9eccbe8970f6 David Schleef 2008-11-04 2305 unsigned long start = vma->vm_start;
ed9eccbe8970f6 David Schleef 2008-11-04 2306 unsigned long size;
ed9eccbe8970f6 David Schleef 2008-11-04 2307 int n_pages;
ed9eccbe8970f6 David Schleef 2008-11-04 2308 int i;
e36472145aa706 Ian Abbott 2019-06-25 2309 int retval = 0;
3ffab428f40849 Bernd Porr 2011-11-08 2310
b34aa86f12e884 Ian Abbott 2014-04-10 2311 /*
b34aa86f12e884 Ian Abbott 2014-04-10 2312 * 'trylock' avoids circular dependency with current->mm->mmap_sem
b34aa86f12e884 Ian Abbott 2014-04-10 2313 * and down-reading &dev->attach_lock should normally succeed without
b34aa86f12e884 Ian Abbott 2014-04-10 2314 * contention unless the device is in the process of being attached
b34aa86f12e884 Ian Abbott 2014-04-10 2315 * or detached.
b34aa86f12e884 Ian Abbott 2014-04-10 2316 */
b34aa86f12e884 Ian Abbott 2014-04-10 2317 if (!down_read_trylock(&dev->attach_lock))
b34aa86f12e884 Ian Abbott 2014-04-10 2318 return -EAGAIN;
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2319
ed9eccbe8970f6 David Schleef 2008-11-04 2320 if (!dev->attached) {
272850f07c47ab H Hartley Sweeten 2013-11-26 2321 dev_dbg(dev->class_dev, "no driver attached\n");
ed9eccbe8970f6 David Schleef 2008-11-04 2322 retval = -ENODEV;
ed9eccbe8970f6 David Schleef 2008-11-04 2323 goto done;
ed9eccbe8970f6 David Schleef 2008-11-04 2324 }
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2325
476b847733636c Greg Kroah-Hartman 2008-11-13 2326 if (vma->vm_flags & VM_WRITE)
20f083c07565cb Ian Abbott 2014-11-04 2327 s = comedi_file_write_subdevice(file);
476b847733636c Greg Kroah-Hartman 2008-11-13 2328 else
20f083c07565cb Ian Abbott 2014-11-04 2329 s = comedi_file_read_subdevice(file);
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2330 if (!s) {
ed9eccbe8970f6 David Schleef 2008-11-04 2331 retval = -EINVAL;
ed9eccbe8970f6 David Schleef 2008-11-04 2332 goto done;
ed9eccbe8970f6 David Schleef 2008-11-04 2333 }
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2334
ed9eccbe8970f6 David Schleef 2008-11-04 2335 async = s->async;
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2336 if (!async) {
ed9eccbe8970f6 David Schleef 2008-11-04 2337 retval = -EINVAL;
ed9eccbe8970f6 David Schleef 2008-11-04 2338 goto done;
ed9eccbe8970f6 David Schleef 2008-11-04 2339 }
ed9eccbe8970f6 David Schleef 2008-11-04 2340
ed9eccbe8970f6 David Schleef 2008-11-04 2341 if (vma->vm_pgoff != 0) {
272850f07c47ab H Hartley Sweeten 2013-11-26 2342 dev_dbg(dev->class_dev, "mmap() offset must be 0.\n");
ed9eccbe8970f6 David Schleef 2008-11-04 2343 retval = -EINVAL;
ed9eccbe8970f6 David Schleef 2008-11-04 2344 goto done;
ed9eccbe8970f6 David Schleef 2008-11-04 2345 }
ed9eccbe8970f6 David Schleef 2008-11-04 2346
ed9eccbe8970f6 David Schleef 2008-11-04 2347 size = vma->vm_end - vma->vm_start;
ed9eccbe8970f6 David Schleef 2008-11-04 2348 if (size > async->prealloc_bufsz) {
ed9eccbe8970f6 David Schleef 2008-11-04 2349 retval = -EFAULT;
ed9eccbe8970f6 David Schleef 2008-11-04 2350 goto done;
ed9eccbe8970f6 David Schleef 2008-11-04 2351 }
44b8c793fc0d63 Sandhya Bankar 2016-03-06 2352 if (offset_in_page(size)) {
ed9eccbe8970f6 David Schleef 2008-11-04 2353 retval = -EFAULT;
ed9eccbe8970f6 David Schleef 2008-11-04 2354 goto done;
ed9eccbe8970f6 David Schleef 2008-11-04 2355 }
ed9eccbe8970f6 David Schleef 2008-11-04 2356
ec9d0754e0c640 sayli karnik 2016-09-20 2357 n_pages = vma_pages(vma);
b34aa86f12e884 Ian Abbott 2014-04-10 2358
b34aa86f12e884 Ian Abbott 2014-04-10 2359 /* get reference to current buf map (if any) */
b34aa86f12e884 Ian Abbott 2014-04-10 2360 bm = comedi_buf_map_from_subdev_get(s);
af93da31634d6d Ian Abbott 2013-11-08 2361 if (!bm || n_pages > bm->n_pages) {
af93da31634d6d Ian Abbott 2013-11-08 2362 retval = -EINVAL;
af93da31634d6d Ian Abbott 2013-11-08 2363 goto done;
af93da31634d6d Ian Abbott 2013-11-08 2364 }
e36472145aa706 Ian Abbott 2019-06-25 2365 if (bm->dma_dir != DMA_NONE) {
e36472145aa706 Ian Abbott 2019-06-25 2366 /*
e36472145aa706 Ian Abbott 2019-06-25 2367 * DMA buffer was allocated as a single block.
e36472145aa706 Ian Abbott 2019-06-25 2368 * Address is in page_list[0].
e36472145aa706 Ian Abbott 2019-06-25 2369 */
e36472145aa706 Ian Abbott 2019-06-25 2370 buf = &bm->page_list[0];
e36472145aa706 Ian Abbott 2019-06-25 2371 retval = dma_mmap_coherent(bm->dma_hw_dev, vma, buf->virt_addr,
e36472145aa706 Ian Abbott 2019-06-25 2372 buf->dma_addr, n_pages * PAGE_SIZE);
e36472145aa706 Ian Abbott 2019-06-25 2373 } else {
ed9eccbe8970f6 David Schleef 2008-11-04 2374 for (i = 0; i < n_pages; ++i) {
e36472145aa706 Ian Abbott 2019-06-25 2375 unsigned long pfn;
e36472145aa706 Ian Abbott 2019-06-25 2376
e36472145aa706 Ian Abbott 2019-06-25 2377 buf = &bm->page_list[i];
e36472145aa706 Ian Abbott 2019-06-25 2378 pfn = page_to_pfn(virt_to_page(buf->virt_addr));
e36472145aa706 Ian Abbott 2019-06-25 2379 retval = remap_pfn_range(vma, start, pfn, PAGE_SIZE,
e36472145aa706 Ian Abbott 2019-06-25 @2380 PAGE_SHARED);
e36472145aa706 Ian Abbott 2019-06-25 2381 if (retval)
e36472145aa706 Ian Abbott 2019-06-25 2382 break;
a52840a98bbb50 H Hartley Sweeten 2012-12-19 2383
ed9eccbe8970f6 David Schleef 2008-11-04 2384 start += PAGE_SIZE;
ed9eccbe8970f6 David Schleef 2008-11-04 2385 }
e36472145aa706 Ian Abbott 2019-06-25 2386 }
ed9eccbe8970f6 David Schleef 2008-11-04 2387
e36472145aa706 Ian Abbott 2019-06-25 2388 if (retval == 0) {
ed9eccbe8970f6 David Schleef 2008-11-04 2389 vma->vm_ops = &comedi_vm_ops;
af93da31634d6d Ian Abbott 2013-11-08 2390 vma->vm_private_data = bm;
ed9eccbe8970f6 David Schleef 2008-11-04 2391
af93da31634d6d Ian Abbott 2013-11-08 2392 vma->vm_ops->open(vma);
e36472145aa706 Ian Abbott 2019-06-25 2393 }
ed9eccbe8970f6 David Schleef 2008-11-04 2394
ed9eccbe8970f6 David Schleef 2008-11-04 2395 done:
b34aa86f12e884 Ian Abbott 2014-04-10 2396 up_read(&dev->attach_lock);
b34aa86f12e884 Ian Abbott 2014-04-10 2397 comedi_buf_map_put(bm); /* put reference to buf map - okay if NULL */
ed9eccbe8970f6 David Schleef 2008-11-04 2398 return retval;
ed9eccbe8970f6 David Schleef 2008-11-04 2399 }
ed9eccbe8970f6 David Schleef 2008-11-04 2400

:::::: The code at line 2380 was first introduced by commit
:::::: e36472145aa706c186a6bb4f6419c613b0b1305c staging: comedi: use dma_mmap_coherent for DMA-able buffer mmap

:::::: TO: Ian Abbott <abbotti@xxxxxxxxx>
:::::: CC: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

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

Attachment: .config.gz
Description: application/gzip