9 #include <linux/slab.h>
10 #include <linux/module.h>
13 #include <linux/capability.h>
14 #include <asm/uaccess.h>
15 #include <asm/byteorder.h>
18 static int proc_initialized;
21 proc_bus_pci_lseek(
struct file *
file, loff_t off,
int whence)
32 new = file->
f_pos + off;
38 if (new < 0 || new > inode->
i_size)
47 proc_bus_pci_read(
struct file *file,
char __user *
buf,
size_t nbytes, loff_t *ppos)
49 const struct inode *
ino = file->
f_path.dentry->d_inode;
52 unsigned int pos = *ppos;
72 if (pos + nbytes > size)
81 if ((pos & 1) && cnt) {
83 pci_user_read_config_byte(dev, pos, &val);
90 if ((pos & 3) && cnt > 2) {
92 pci_user_read_config_word(dev, pos, &val);
101 pci_user_read_config_dword(dev, pos, &val);
110 pci_user_read_config_word(dev, pos, &val);
119 pci_user_read_config_byte(dev, pos, &val);
133 proc_bus_pci_write(
struct file *file,
const char __user *buf,
size_t nbytes, loff_t *ppos)
135 struct inode *ino = file->
f_path.dentry->d_inode;
146 if (pos + nbytes > size)
155 if ((pos & 1) && cnt) {
158 pci_user_write_config_byte(dev, pos, val);
164 if ((pos & 3) && cnt > 2) {
167 pci_user_write_config_word(dev, pos,
le16_to_cpu(val));
176 pci_user_write_config_dword(dev, pos,
le32_to_cpu(val));
185 pci_user_write_config_word(dev, pos,
le16_to_cpu(val));
194 pci_user_write_config_byte(dev, pos, val);
203 i_size_write(ino, dp->
size);
212 static long proc_bus_pci_ioctl(
struct file *file,
unsigned int cmd,
254 static int proc_bus_pci_mmap(
struct file *file,
struct vm_area_struct *vma)
256 struct inode *inode = file->
f_path.dentry->d_inode;
267 if (pci_mmap_fits(dev, i, vma, PCI_MMAP_PROCFS))
271 if (i >= PCI_ROM_RESOURCE)
283 static int proc_bus_pci_open(
struct inode *inode,
struct file *file)
298 static int proc_bus_pci_release(
struct inode *inode,
struct file *file)
309 .llseek = proc_bus_pci_lseek,
310 .read = proc_bus_pci_read,
311 .write = proc_bus_pci_write,
312 .unlocked_ioctl = proc_bus_pci_ioctl,
313 .compat_ioctl = proc_bus_pci_ioctl,
315 .open = proc_bus_pci_open,
316 .release = proc_bus_pci_release,
317 .mmap = proc_bus_pci_mmap,
318 #ifdef HAVE_ARCH_PCI_GET_UNMAPPED_AREA
319 .get_unmapped_area = get_pci_unmapped_area,
325 static void *pci_seq_start(
struct seq_file *
m, loff_t *pos)
337 static void *pci_seq_next(
struct seq_file *m,
void *
v, loff_t *pos)
346 static void pci_seq_stop(
struct seq_file *m,
void *
v)
354 static int show_device(
struct seq_file *m,
void *v)
376 (
unsigned long long)(start |
384 (
unsigned long long)(end - start) + 1 : 0);
394 .start = pci_seq_start,
395 .next = pci_seq_next,
396 .stop = pci_seq_stop,
408 if (!proc_initialized)
425 &proc_bus_pci_operations, dev);
453 static int proc_bus_pci_dev_open(
struct inode *inode,
struct file *file)
455 return seq_open(file, &proc_bus_pci_devices_op);
459 .open = proc_bus_pci_dev_open,
465 static int __init pci_proc_init(
void)
469 proc_create(
"devices", 0, proc_bus_pci_dir,
470 &proc_bus_pci_dev_operations);
471 proc_initialized = 1;