Lines Matching +full:cmd +full:- +full:cnt +full:- +full:name
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (c) 1997--1999 Martin Mares <mj@ucw.cz>
25 return fixed_size_llseek(file, off, whence, dev->cfg_size); in proc_bus_pci_lseek()
33 unsigned int cnt, size; in proc_bus_pci_read() local
42 size = dev->cfg_size; in proc_bus_pci_read()
43 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) in proc_bus_pci_read()
53 nbytes = size - pos; in proc_bus_pci_read()
54 cnt = nbytes; in proc_bus_pci_read()
56 if (!access_ok(buf, cnt)) in proc_bus_pci_read()
57 return -EINVAL; in proc_bus_pci_read()
61 if ((pos & 1) && cnt) { in proc_bus_pci_read()
67 cnt--; in proc_bus_pci_read()
70 if ((pos & 3) && cnt > 2) { in proc_bus_pci_read()
76 cnt -= 2; in proc_bus_pci_read()
79 while (cnt >= 4) { in proc_bus_pci_read()
85 cnt -= 4; in proc_bus_pci_read()
89 if (cnt >= 2) { in proc_bus_pci_read()
95 cnt -= 2; in proc_bus_pci_read()
98 if (cnt) { in proc_bus_pci_read()
117 int size = dev->cfg_size; in proc_bus_pci_write()
118 int cnt, ret; in proc_bus_pci_write() local
129 nbytes = size - pos; in proc_bus_pci_write()
130 cnt = nbytes; in proc_bus_pci_write()
132 if (!access_ok(buf, cnt)) in proc_bus_pci_write()
133 return -EINVAL; in proc_bus_pci_write()
137 if ((pos & 1) && cnt) { in proc_bus_pci_write()
143 cnt--; in proc_bus_pci_write()
146 if ((pos & 3) && cnt > 2) { in proc_bus_pci_write()
152 cnt -= 2; in proc_bus_pci_write()
155 while (cnt >= 4) { in proc_bus_pci_write()
161 cnt -= 4; in proc_bus_pci_write()
164 if (cnt >= 2) { in proc_bus_pci_write()
170 cnt -= 2; in proc_bus_pci_write()
173 if (cnt) { in proc_bus_pci_write()
183 i_size_write(ino, dev->cfg_size); in proc_bus_pci_write()
194 static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, in proc_bus_pci_ioctl() argument
199 struct pci_filp_private *fpriv = file->private_data; in proc_bus_pci_ioctl()
207 switch (cmd) { in proc_bus_pci_ioctl()
209 ret = pci_domain_nr(dev->bus); in proc_bus_pci_ioctl()
215 return -EINVAL; in proc_bus_pci_ioctl()
216 fpriv->mmap_state = pci_mmap_io; in proc_bus_pci_ioctl()
220 fpriv->mmap_state = pci_mmap_mem; in proc_bus_pci_ioctl()
226 fpriv->write_combine = 1; in proc_bus_pci_ioctl()
228 fpriv->write_combine = 0; in proc_bus_pci_ioctl()
235 ret = -EINVAL; in proc_bus_pci_ioctl()
246 struct pci_filp_private *fpriv = file->private_data; in proc_bus_pci_mmap()
252 return -EPERM; in proc_bus_pci_mmap()
254 if (fpriv->mmap_state == pci_mmap_io) { in proc_bus_pci_mmap()
256 return -EINVAL; in proc_bus_pci_mmap()
262 if (dev->resource[i].flags & res_bit && in proc_bus_pci_mmap()
268 return -ENODEV; in proc_bus_pci_mmap()
270 if (fpriv->mmap_state == pci_mmap_mem && in proc_bus_pci_mmap()
271 fpriv->write_combine) { in proc_bus_pci_mmap()
272 if (dev->resource[i].flags & IORESOURCE_PREFETCH) in proc_bus_pci_mmap()
275 return -EINVAL; in proc_bus_pci_mmap()
278 if (dev->resource[i].flags & IORESOURCE_MEM && in proc_bus_pci_mmap()
279 iomem_is_exclusive(dev->resource[i].start)) in proc_bus_pci_mmap()
280 return -EINVAL; in proc_bus_pci_mmap()
282 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); in proc_bus_pci_mmap()
285 vma->vm_pgoff -= start >> PAGE_SHIFT; in proc_bus_pci_mmap()
287 fpriv->mmap_state, write_combine); in proc_bus_pci_mmap()
299 return -ENOMEM; in proc_bus_pci_open()
301 fpriv->mmap_state = pci_mmap_io; in proc_bus_pci_open()
302 fpriv->write_combine = 0; in proc_bus_pci_open()
304 file->private_data = fpriv; in proc_bus_pci_open()
305 file->f_mapping = iomem_get_mapping(); in proc_bus_pci_open()
312 kfree(file->private_data); in proc_bus_pci_release()
313 file->private_data = NULL; in proc_bus_pci_release()
344 if (!n--) in pci_seq_start()
378 dev->bus->number, in show_device()
379 dev->devfn, in show_device()
380 dev->vendor, in show_device()
381 dev->device, in show_device()
382 dev->irq); in show_device()
387 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); in show_device()
390 (dev->resource[i].flags & PCI_REGION_FLAG_MASK))); in show_device()
394 pci_resource_to_user(dev, i, &dev->resource[i], &start, &end); in show_device()
396 dev->resource[i].start < dev->resource[i].end ? in show_device()
397 (unsigned long long)(end - start) + 1 : 0); in show_device()
401 seq_puts(m, drv->name); in show_device()
417 struct pci_bus *bus = dev->bus; in pci_proc_attach_device()
419 char name[16]; in pci_proc_attach_device() local
422 return -EACCES; in pci_proc_attach_device()
424 if (!bus->procdir) { in pci_proc_attach_device()
426 sprintf(name, "%04x:%02x", pci_domain_nr(bus), in pci_proc_attach_device()
427 bus->number); in pci_proc_attach_device()
429 sprintf(name, "%02x", bus->number); in pci_proc_attach_device()
431 bus->procdir = proc_mkdir(name, proc_bus_pci_dir); in pci_proc_attach_device()
432 if (!bus->procdir) in pci_proc_attach_device()
433 return -ENOMEM; in pci_proc_attach_device()
436 sprintf(name, "%02x.%x", PCI_SLOT(dev->devfn), PCI_FUNC(dev->devfn)); in pci_proc_attach_device()
437 e = proc_create_data(name, S_IFREG | S_IRUGO | S_IWUSR, bus->procdir, in pci_proc_attach_device()
440 return -ENOMEM; in pci_proc_attach_device()
441 proc_set_size(e, dev->cfg_size); in pci_proc_attach_device()
442 dev->procent = e; in pci_proc_attach_device()
449 proc_remove(dev->procent); in pci_proc_detach_device()
450 dev->procent = NULL; in pci_proc_detach_device()
456 proc_remove(bus->procdir); in pci_proc_detach_bus()