proc.c (dca3a783400a18e2bf4503b1d4a85c4d0ca1a7e4) | proc.c (d9dda78bad879595d8c4220a067fc029d6484a16) |
---|---|
1/* 2 * Procfs interface for the PCI bus. 3 * 4 * Copyright (c) 1997--1999 Martin Mares <mj@ucw.cz> 5 */ 6 7#include <linux/init.h> 8#include <linux/pci.h> --- 32 unchanged lines hidden (view full) --- 41 file->f_pos = new; 42 mutex_unlock(&inode->i_mutex); 43 return new; 44} 45 46static ssize_t 47proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 48{ | 1/* 2 * Procfs interface for the PCI bus. 3 * 4 * Copyright (c) 1997--1999 Martin Mares <mj@ucw.cz> 5 */ 6 7#include <linux/init.h> 8#include <linux/pci.h> --- 32 unchanged lines hidden (view full) --- 41 file->f_pos = new; 42 mutex_unlock(&inode->i_mutex); 43 return new; 44} 45 46static ssize_t 47proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 48{ |
49 const struct inode *ino = file_inode(file); 50 const struct proc_dir_entry *dp = PDE(ino); 51 struct pci_dev *dev = dp->data; | 49 struct pci_dev *dev = PDE_DATA(file_inode(file)); |
52 unsigned int pos = *ppos; 53 unsigned int cnt, size; 54 55 /* 56 * Normal users can read only the standardized portion of the 57 * configuration space as several chips lock up when trying to read 58 * undefined locations (think of Intel PIIX4 as a typical example). 59 */ 60 61 if (capable(CAP_SYS_ADMIN)) | 50 unsigned int pos = *ppos; 51 unsigned int cnt, size; 52 53 /* 54 * Normal users can read only the standardized portion of the 55 * configuration space as several chips lock up when trying to read 56 * undefined locations (think of Intel PIIX4 as a typical example). 57 */ 58 59 if (capable(CAP_SYS_ADMIN)) |
62 size = dp->size; | 60 size = dev->cfg_size; |
63 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 64 size = 128; 65 else 66 size = 64; 67 68 if (pos >= size) 69 return 0; 70 if (nbytes >= size) --- 57 unchanged lines hidden (view full) --- 128 *ppos = pos; 129 return nbytes; 130} 131 132static ssize_t 133proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos) 134{ 135 struct inode *ino = file_inode(file); | 61 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) 62 size = 128; 63 else 64 size = 64; 65 66 if (pos >= size) 67 return 0; 68 if (nbytes >= size) --- 57 unchanged lines hidden (view full) --- 126 *ppos = pos; 127 return nbytes; 128} 129 130static ssize_t 131proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos) 132{ 133 struct inode *ino = file_inode(file); |
136 const struct proc_dir_entry *dp = PDE(ino); 137 struct pci_dev *dev = dp->data; | 134 struct pci_dev *dev = PDE_DATA(ino); |
138 int pos = *ppos; | 135 int pos = *ppos; |
139 int size = dp->size; | 136 int size = dev->cfg_size; |
140 int cnt; 141 142 if (pos >= size) 143 return 0; 144 if (nbytes >= size) 145 nbytes = size; 146 if (pos + nbytes > size) 147 nbytes = size - pos; --- 47 unchanged lines hidden (view full) --- 195 buf++; 196 pos++; 197 cnt--; 198 } 199 200 pci_config_pm_runtime_put(dev); 201 202 *ppos = pos; | 137 int cnt; 138 139 if (pos >= size) 140 return 0; 141 if (nbytes >= size) 142 nbytes = size; 143 if (pos + nbytes > size) 144 nbytes = size - pos; --- 47 unchanged lines hidden (view full) --- 192 buf++; 193 pos++; 194 cnt--; 195 } 196 197 pci_config_pm_runtime_put(dev); 198 199 *ppos = pos; |
203 i_size_write(ino, dp->size); | 200 i_size_write(ino, dev->cfg_size); |
204 return nbytes; 205} 206 207struct pci_filp_private { 208 enum pci_mmap_state mmap_state; 209 int write_combine; 210}; 211 212static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, 213 unsigned long arg) 214{ | 201 return nbytes; 202} 203 204struct pci_filp_private { 205 enum pci_mmap_state mmap_state; 206 int write_combine; 207}; 208 209static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, 210 unsigned long arg) 211{ |
215 const struct proc_dir_entry *dp = PDE(file_inode(file)); 216 struct pci_dev *dev = dp->data; | 212 struct pci_dev *dev = PDE_DATA(file_inode(file)); |
217#ifdef HAVE_PCI_MMAP 218 struct pci_filp_private *fpriv = file->private_data; 219#endif /* HAVE_PCI_MMAP */ 220 int ret = 0; 221 222 switch (cmd) { 223 case PCIIOC_CONTROLLER: 224 ret = pci_domain_nr(dev->bus); --- 23 unchanged lines hidden (view full) --- 248 }; 249 250 return ret; 251} 252 253#ifdef HAVE_PCI_MMAP 254static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) 255{ | 213#ifdef HAVE_PCI_MMAP 214 struct pci_filp_private *fpriv = file->private_data; 215#endif /* HAVE_PCI_MMAP */ 216 int ret = 0; 217 218 switch (cmd) { 219 case PCIIOC_CONTROLLER: 220 ret = pci_domain_nr(dev->bus); --- 23 unchanged lines hidden (view full) --- 244 }; 245 246 return ret; 247} 248 249#ifdef HAVE_PCI_MMAP 250static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) 251{ |
256 struct inode *inode = file_inode(file); 257 const struct proc_dir_entry *dp = PDE(inode); 258 struct pci_dev *dev = dp->data; | 252 struct pci_dev *dev = PDE_DATA(file_inode(file)); |
259 struct pci_filp_private *fpriv = file->private_data; 260 int i, ret; 261 262 if (!capable(CAP_SYS_RAWIO)) 263 return -EPERM; 264 265 /* Make sure the caller is mapping a real resource for this device */ 266 for (i = 0; i < PCI_ROM_RESOURCE; i++) { --- 213 unchanged lines hidden --- | 253 struct pci_filp_private *fpriv = file->private_data; 254 int i, ret; 255 256 if (!capable(CAP_SYS_RAWIO)) 257 return -EPERM; 258 259 /* Make sure the caller is mapping a real resource for this device */ 260 for (i = 0; i < PCI_ROM_RESOURCE; i++) { --- 213 unchanged lines hidden --- |