aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-sysfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r--drivers/pci/pci-sysfs.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 89a08ed39c94..afd2fbf7d797 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -21,6 +21,7 @@
21#include <linux/stat.h> 21#include <linux/stat.h>
22#include <linux/topology.h> 22#include <linux/topology.h>
23#include <linux/mm.h> 23#include <linux/mm.h>
24#include <linux/fs.h>
24#include <linux/capability.h> 25#include <linux/capability.h>
25#include <linux/pci-aspm.h> 26#include <linux/pci-aspm.h>
26#include <linux/slab.h> 27#include <linux/slab.h>
@@ -357,7 +358,8 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
357struct device_attribute vga_attr = __ATTR_RO(boot_vga); 358struct device_attribute vga_attr = __ATTR_RO(boot_vga);
358 359
359static ssize_t 360static ssize_t
360pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, 361pci_read_config(struct file *filp, struct kobject *kobj,
362 struct bin_attribute *bin_attr,
361 char *buf, loff_t off, size_t count) 363 char *buf, loff_t off, size_t count)
362{ 364{
363 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 365 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
@@ -366,7 +368,7 @@ pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr,
366 u8 *data = (u8*) buf; 368 u8 *data = (u8*) buf;
367 369
368 /* Several chips lock up trying to read undefined config space */ 370 /* Several chips lock up trying to read undefined config space */
369 if (capable(CAP_SYS_ADMIN)) { 371 if (cap_raised(filp->f_cred->cap_effective, CAP_SYS_ADMIN)) {
370 size = dev->cfg_size; 372 size = dev->cfg_size;
371 } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { 373 } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
372 size = 128; 374 size = 128;
@@ -430,7 +432,8 @@ pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr,
430} 432}
431 433
432static ssize_t 434static ssize_t
433pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, 435pci_write_config(struct file* filp, struct kobject *kobj,
436 struct bin_attribute *bin_attr,
434 char *buf, loff_t off, size_t count) 437 char *buf, loff_t off, size_t count)
435{ 438{
436 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 439 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
@@ -487,7 +490,8 @@ pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr,
487} 490}
488 491
489static ssize_t 492static ssize_t
490read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, 493read_vpd_attr(struct file *filp, struct kobject *kobj,
494 struct bin_attribute *bin_attr,
491 char *buf, loff_t off, size_t count) 495 char *buf, loff_t off, size_t count)
492{ 496{
493 struct pci_dev *dev = 497 struct pci_dev *dev =
@@ -502,7 +506,8 @@ read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr,
502} 506}
503 507
504static ssize_t 508static ssize_t
505write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, 509write_vpd_attr(struct file *filp, struct kobject *kobj,
510 struct bin_attribute *bin_attr,
506 char *buf, loff_t off, size_t count) 511 char *buf, loff_t off, size_t count)
507{ 512{
508 struct pci_dev *dev = 513 struct pci_dev *dev =
@@ -519,6 +524,7 @@ write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr,
519#ifdef HAVE_PCI_LEGACY 524#ifdef HAVE_PCI_LEGACY
520/** 525/**
521 * pci_read_legacy_io - read byte(s) from legacy I/O port space 526 * pci_read_legacy_io - read byte(s) from legacy I/O port space
527 * @filp: open sysfs file
522 * @kobj: kobject corresponding to file to read from 528 * @kobj: kobject corresponding to file to read from
523 * @bin_attr: struct bin_attribute for this file 529 * @bin_attr: struct bin_attribute for this file
524 * @buf: buffer to store results 530 * @buf: buffer to store results
@@ -529,7 +535,8 @@ write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr,
529 * callback routine (pci_legacy_read). 535 * callback routine (pci_legacy_read).
530 */ 536 */
531static ssize_t 537static ssize_t
532pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, 538pci_read_legacy_io(struct file *filp, struct kobject *kobj,
539 struct bin_attribute *bin_attr,
533 char *buf, loff_t off, size_t count) 540 char *buf, loff_t off, size_t count)
534{ 541{
535 struct pci_bus *bus = to_pci_bus(container_of(kobj, 542 struct pci_bus *bus = to_pci_bus(container_of(kobj,
@@ -545,6 +552,7 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr,
545 552
546/** 553/**
547 * pci_write_legacy_io - write byte(s) to legacy I/O port space 554 * pci_write_legacy_io - write byte(s) to legacy I/O port space
555 * @filp: open sysfs file
548 * @kobj: kobject corresponding to file to read from 556 * @kobj: kobject corresponding to file to read from
549 * @bin_attr: struct bin_attribute for this file 557 * @bin_attr: struct bin_attribute for this file
550 * @buf: buffer containing value to be written 558 * @buf: buffer containing value to be written
@@ -555,7 +563,8 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr,
555 * callback routine (pci_legacy_write). 563 * callback routine (pci_legacy_write).
556 */ 564 */
557static ssize_t 565static ssize_t
558pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, 566pci_write_legacy_io(struct file *filp, struct kobject *kobj,
567 struct bin_attribute *bin_attr,
559 char *buf, loff_t off, size_t count) 568 char *buf, loff_t off, size_t count)
560{ 569{
561 struct pci_bus *bus = to_pci_bus(container_of(kobj, 570 struct pci_bus *bus = to_pci_bus(container_of(kobj,
@@ -570,6 +579,7 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr,
570 579
571/** 580/**
572 * pci_mmap_legacy_mem - map legacy PCI memory into user memory space 581 * pci_mmap_legacy_mem - map legacy PCI memory into user memory space
582 * @filp: open sysfs file
573 * @kobj: kobject corresponding to device to be mapped 583 * @kobj: kobject corresponding to device to be mapped
574 * @attr: struct bin_attribute for this file 584 * @attr: struct bin_attribute for this file
575 * @vma: struct vm_area_struct passed to mmap 585 * @vma: struct vm_area_struct passed to mmap
@@ -579,7 +589,8 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr,
579 * memory space. 589 * memory space.
580 */ 590 */
581static int 591static int
582pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, 592pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
593 struct bin_attribute *attr,
583 struct vm_area_struct *vma) 594 struct vm_area_struct *vma)
584{ 595{
585 struct pci_bus *bus = to_pci_bus(container_of(kobj, 596 struct pci_bus *bus = to_pci_bus(container_of(kobj,
@@ -591,6 +602,7 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr,
591 602
592/** 603/**
593 * pci_mmap_legacy_io - map legacy PCI IO into user memory space 604 * pci_mmap_legacy_io - map legacy PCI IO into user memory space
605 * @filp: open sysfs file
594 * @kobj: kobject corresponding to device to be mapped 606 * @kobj: kobject corresponding to device to be mapped
595 * @attr: struct bin_attribute for this file 607 * @attr: struct bin_attribute for this file
596 * @vma: struct vm_area_struct passed to mmap 608 * @vma: struct vm_area_struct passed to mmap
@@ -600,7 +612,8 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr,
600 * memory space. Returns -ENOSYS if the operation isn't supported 612 * memory space. Returns -ENOSYS if the operation isn't supported
601 */ 613 */
602static int 614static int
603pci_mmap_legacy_io(struct kobject *kobj, struct bin_attribute *attr, 615pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
616 struct bin_attribute *attr,
604 struct vm_area_struct *vma) 617 struct vm_area_struct *vma)
605{ 618{
606 struct pci_bus *bus = to_pci_bus(container_of(kobj, 619 struct pci_bus *bus = to_pci_bus(container_of(kobj,
@@ -750,14 +763,16 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
750} 763}
751 764
752static int 765static int
753pci_mmap_resource_uc(struct kobject *kobj, struct bin_attribute *attr, 766pci_mmap_resource_uc(struct file *filp, struct kobject *kobj,
767 struct bin_attribute *attr,
754 struct vm_area_struct *vma) 768 struct vm_area_struct *vma)
755{ 769{
756 return pci_mmap_resource(kobj, attr, vma, 0); 770 return pci_mmap_resource(kobj, attr, vma, 0);
757} 771}
758 772
759static int 773static int
760pci_mmap_resource_wc(struct kobject *kobj, struct bin_attribute *attr, 774pci_mmap_resource_wc(struct file *filp, struct kobject *kobj,
775 struct bin_attribute *attr,
761 struct vm_area_struct *vma) 776 struct vm_area_struct *vma)
762{ 777{
763 return pci_mmap_resource(kobj, attr, vma, 1); 778 return pci_mmap_resource(kobj, attr, vma, 1);
@@ -861,6 +876,7 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }
861 876
862/** 877/**
863 * pci_write_rom - used to enable access to the PCI ROM display 878 * pci_write_rom - used to enable access to the PCI ROM display
879 * @filp: sysfs file
864 * @kobj: kernel object handle 880 * @kobj: kernel object handle
865 * @bin_attr: struct bin_attribute for this file 881 * @bin_attr: struct bin_attribute for this file
866 * @buf: user input 882 * @buf: user input
@@ -870,7 +886,8 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }
870 * writing anything except 0 enables it 886 * writing anything except 0 enables it
871 */ 887 */
872static ssize_t 888static ssize_t
873pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, 889pci_write_rom(struct file *filp, struct kobject *kobj,
890 struct bin_attribute *bin_attr,
874 char *buf, loff_t off, size_t count) 891 char *buf, loff_t off, size_t count)
875{ 892{
876 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); 893 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
@@ -885,6 +902,7 @@ pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr,
885 902
886/** 903/**
887 * pci_read_rom - read a PCI ROM 904 * pci_read_rom - read a PCI ROM
905 * @filp: sysfs file
888 * @kobj: kernel object handle 906 * @kobj: kernel object handle
889 * @bin_attr: struct bin_attribute for this file 907 * @bin_attr: struct bin_attribute for this file
890 * @buf: where to put the data we read from the ROM 908 * @buf: where to put the data we read from the ROM
@@ -895,7 +913,8 @@ pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr,
895 * device corresponding to @kobj. 913 * device corresponding to @kobj.
896 */ 914 */
897static ssize_t 915static ssize_t
898pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, 916pci_read_rom(struct file *filp, struct kobject *kobj,
917 struct bin_attribute *bin_attr,
899 char *buf, loff_t off, size_t count) 918 char *buf, loff_t off, size_t count)
900{ 919{
901 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); 920 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));