aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/proc.c')
-rw-r--r--drivers/pci/proc.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
index 0b009470e6db..08126087ec31 100644
--- a/drivers/pci/proc.c
+++ b/drivers/pci/proc.c
@@ -46,9 +46,7 @@ proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
46static ssize_t 46static ssize_t
47proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) 47proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
48{ 48{
49 const struct inode *ino = file_inode(file); 49 struct pci_dev *dev = PDE_DATA(file_inode(file));
50 const struct proc_dir_entry *dp = PDE(ino);
51 struct pci_dev *dev = dp->data;
52 unsigned int pos = *ppos; 50 unsigned int pos = *ppos;
53 unsigned int cnt, size; 51 unsigned int cnt, size;
54 52
@@ -59,7 +57,7 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
59 */ 57 */
60 58
61 if (capable(CAP_SYS_ADMIN)) 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) 61 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
64 size = 128; 62 size = 128;
65 else 63 else
@@ -133,10 +131,9 @@ static ssize_t
133proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos) 131proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos)
134{ 132{
135 struct inode *ino = file_inode(file); 133 struct inode *ino = file_inode(file);
136 const struct proc_dir_entry *dp = PDE(ino); 134 struct pci_dev *dev = PDE_DATA(ino);
137 struct pci_dev *dev = dp->data;
138 int pos = *ppos; 135 int pos = *ppos;
139 int size = dp->size; 136 int size = dev->cfg_size;
140 int cnt; 137 int cnt;
141 138
142 if (pos >= size) 139 if (pos >= size)
@@ -200,7 +197,7 @@ proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, lof
200 pci_config_pm_runtime_put(dev); 197 pci_config_pm_runtime_put(dev);
201 198
202 *ppos = pos; 199 *ppos = pos;
203 i_size_write(ino, dp->size); 200 i_size_write(ino, dev->cfg_size);
204 return nbytes; 201 return nbytes;
205} 202}
206 203
@@ -212,8 +209,7 @@ struct pci_filp_private {
212static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd, 209static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
213 unsigned long arg) 210 unsigned long arg)
214{ 211{
215 const struct proc_dir_entry *dp = PDE(file_inode(file)); 212 struct pci_dev *dev = PDE_DATA(file_inode(file));
216 struct pci_dev *dev = dp->data;
217#ifdef HAVE_PCI_MMAP 213#ifdef HAVE_PCI_MMAP
218 struct pci_filp_private *fpriv = file->private_data; 214 struct pci_filp_private *fpriv = file->private_data;
219#endif /* HAVE_PCI_MMAP */ 215#endif /* HAVE_PCI_MMAP */
@@ -253,9 +249,7 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
253#ifdef HAVE_PCI_MMAP 249#ifdef HAVE_PCI_MMAP
254static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma) 250static int proc_bus_pci_mmap(struct file *file, struct vm_area_struct *vma)
255{ 251{
256 struct inode *inode = file_inode(file); 252 struct pci_dev *dev = PDE_DATA(file_inode(file));
257 const struct proc_dir_entry *dp = PDE(inode);
258 struct pci_dev *dev = dp->data;
259 struct pci_filp_private *fpriv = file->private_data; 253 struct pci_filp_private *fpriv = file->private_data;
260 int i, ret; 254 int i, ret;
261 255
@@ -425,7 +419,7 @@ int pci_proc_attach_device(struct pci_dev *dev)
425 &proc_bus_pci_operations, dev); 419 &proc_bus_pci_operations, dev);
426 if (!e) 420 if (!e)
427 return -ENOMEM; 421 return -ENOMEM;
428 e->size = dev->cfg_size; 422 proc_set_size(e, dev->cfg_size);
429 dev->procent = e; 423 dev->procent = e;
430 424
431 return 0; 425 return 0;
@@ -433,20 +427,14 @@ int pci_proc_attach_device(struct pci_dev *dev)
433 427
434int pci_proc_detach_device(struct pci_dev *dev) 428int pci_proc_detach_device(struct pci_dev *dev)
435{ 429{
436 struct proc_dir_entry *e; 430 proc_remove(dev->procent);
437 431 dev->procent = NULL;
438 if ((e = dev->procent)) {
439 remove_proc_entry(e->name, dev->bus->procdir);
440 dev->procent = NULL;
441 }
442 return 0; 432 return 0;
443} 433}
444 434
445int pci_proc_detach_bus(struct pci_bus* bus) 435int pci_proc_detach_bus(struct pci_bus* bus)
446{ 436{
447 struct proc_dir_entry *de = bus->procdir; 437 proc_remove(bus->procdir);
448 if (de)
449 remove_proc_entry(de->name, proc_bus_pci_dir);
450 return 0; 438 return 0;
451} 439}
452 440