diff options
author | Bjorn Helgaas <bhelgaas@google.com> | 2016-01-20 12:48:25 -0500 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2016-01-20 12:48:25 -0500 |
commit | 9662e32c810ad3e6ce49832d5f585a54f8fbdbdb (patch) | |
tree | fd9fd3f8cd44e231b8dc71c2e360eb19963972d5 /drivers/pci/pci-sysfs.c | |
parent | 904f664b585cc9f3dc134a8c0dd08e9bce6c10bc (diff) | |
parent | bd7900825a3db4c4916fafb400c1f669120039d2 (diff) |
Merge branch 'pci/trivial' into next
* pci/trivial:
PCI: shpchp: Constify hpc_ops structure
PCI: Use kobj_to_dev() instead of open-coding it
PCI: Use to_pci_dev() instead of open-coding it
PCI: Fix all whitespace issues
PCI/MSI: Fix typos in <linux/msi.h>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 9cd27b703dd6..4ba61db43a6b 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -627,8 +627,7 @@ static ssize_t pci_read_config(struct file *filp, struct kobject *kobj, | |||
627 | struct bin_attribute *bin_attr, char *buf, | 627 | struct bin_attribute *bin_attr, char *buf, |
628 | loff_t off, size_t count) | 628 | loff_t off, size_t count) |
629 | { | 629 | { |
630 | struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device, | 630 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
631 | kobj)); | ||
632 | unsigned int size = 64; | 631 | unsigned int size = 64; |
633 | loff_t init_off = off; | 632 | loff_t init_off = off; |
634 | u8 *data = (u8 *) buf; | 633 | u8 *data = (u8 *) buf; |
@@ -704,8 +703,7 @@ static ssize_t pci_write_config(struct file *filp, struct kobject *kobj, | |||
704 | struct bin_attribute *bin_attr, char *buf, | 703 | struct bin_attribute *bin_attr, char *buf, |
705 | loff_t off, size_t count) | 704 | loff_t off, size_t count) |
706 | { | 705 | { |
707 | struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device, | 706 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
708 | kobj)); | ||
709 | unsigned int size = count; | 707 | unsigned int size = count; |
710 | loff_t init_off = off; | 708 | loff_t init_off = off; |
711 | u8 *data = (u8 *) buf; | 709 | u8 *data = (u8 *) buf; |
@@ -766,8 +764,7 @@ static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj, | |||
766 | struct bin_attribute *bin_attr, char *buf, | 764 | struct bin_attribute *bin_attr, char *buf, |
767 | loff_t off, size_t count) | 765 | loff_t off, size_t count) |
768 | { | 766 | { |
769 | struct pci_dev *dev = | 767 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
770 | to_pci_dev(container_of(kobj, struct device, kobj)); | ||
771 | 768 | ||
772 | if (off > bin_attr->size) | 769 | if (off > bin_attr->size) |
773 | count = 0; | 770 | count = 0; |
@@ -781,8 +778,7 @@ static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj, | |||
781 | struct bin_attribute *bin_attr, char *buf, | 778 | struct bin_attribute *bin_attr, char *buf, |
782 | loff_t off, size_t count) | 779 | loff_t off, size_t count) |
783 | { | 780 | { |
784 | struct pci_dev *dev = | 781 | struct pci_dev *dev = to_pci_dev(kobj_to_dev(kobj)); |
785 | to_pci_dev(container_of(kobj, struct device, kobj)); | ||
786 | 782 | ||
787 | if (off > bin_attr->size) | 783 | if (off > bin_attr->size) |
788 | count = 0; | 784 | count = 0; |
@@ -809,8 +805,7 @@ static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj, | |||
809 | struct bin_attribute *bin_attr, char *buf, | 805 | struct bin_attribute *bin_attr, char *buf, |
810 | loff_t off, size_t count) | 806 | loff_t off, size_t count) |
811 | { | 807 | { |
812 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 808 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
813 | kobj)); | ||
814 | 809 | ||
815 | /* Only support 1, 2 or 4 byte accesses */ | 810 | /* Only support 1, 2 or 4 byte accesses */ |
816 | if (count != 1 && count != 2 && count != 4) | 811 | if (count != 1 && count != 2 && count != 4) |
@@ -835,8 +830,7 @@ static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj, | |||
835 | struct bin_attribute *bin_attr, char *buf, | 830 | struct bin_attribute *bin_attr, char *buf, |
836 | loff_t off, size_t count) | 831 | loff_t off, size_t count) |
837 | { | 832 | { |
838 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 833 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
839 | kobj)); | ||
840 | 834 | ||
841 | /* Only support 1, 2 or 4 byte accesses */ | 835 | /* Only support 1, 2 or 4 byte accesses */ |
842 | if (count != 1 && count != 2 && count != 4) | 836 | if (count != 1 && count != 2 && count != 4) |
@@ -860,8 +854,7 @@ static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj, | |||
860 | struct bin_attribute *attr, | 854 | struct bin_attribute *attr, |
861 | struct vm_area_struct *vma) | 855 | struct vm_area_struct *vma) |
862 | { | 856 | { |
863 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 857 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
864 | kobj)); | ||
865 | 858 | ||
866 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem); | 859 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem); |
867 | } | 860 | } |
@@ -881,8 +874,7 @@ static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj, | |||
881 | struct bin_attribute *attr, | 874 | struct bin_attribute *attr, |
882 | struct vm_area_struct *vma) | 875 | struct vm_area_struct *vma) |
883 | { | 876 | { |
884 | struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device, | 877 | struct pci_bus *bus = to_pci_bus(kobj_to_dev(kobj)); |
885 | kobj)); | ||
886 | 878 | ||
887 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); | 879 | return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); |
888 | } | 880 | } |
@@ -997,8 +989,7 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma, | |||
997 | static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | 989 | static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, |
998 | struct vm_area_struct *vma, int write_combine) | 990 | struct vm_area_struct *vma, int write_combine) |
999 | { | 991 | { |
1000 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, | 992 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1001 | struct device, kobj)); | ||
1002 | struct resource *res = attr->private; | 993 | struct resource *res = attr->private; |
1003 | enum pci_mmap_state mmap_type; | 994 | enum pci_mmap_state mmap_type; |
1004 | resource_size_t start, end; | 995 | resource_size_t start, end; |
@@ -1051,8 +1042,7 @@ static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj, | |||
1051 | struct bin_attribute *attr, char *buf, | 1042 | struct bin_attribute *attr, char *buf, |
1052 | loff_t off, size_t count, bool write) | 1043 | loff_t off, size_t count, bool write) |
1053 | { | 1044 | { |
1054 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, | 1045 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1055 | struct device, kobj)); | ||
1056 | struct resource *res = attr->private; | 1046 | struct resource *res = attr->private; |
1057 | unsigned long port = off; | 1047 | unsigned long port = off; |
1058 | int i; | 1048 | int i; |
@@ -1222,7 +1212,7 @@ static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj, | |||
1222 | struct bin_attribute *bin_attr, char *buf, | 1212 | struct bin_attribute *bin_attr, char *buf, |
1223 | loff_t off, size_t count) | 1213 | loff_t off, size_t count) |
1224 | { | 1214 | { |
1225 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 1215 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1226 | 1216 | ||
1227 | if ((off == 0) && (*buf == '0') && (count == 2)) | 1217 | if ((off == 0) && (*buf == '0') && (count == 2)) |
1228 | pdev->rom_attr_enabled = 0; | 1218 | pdev->rom_attr_enabled = 0; |
@@ -1248,7 +1238,7 @@ static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj, | |||
1248 | struct bin_attribute *bin_attr, char *buf, | 1238 | struct bin_attribute *bin_attr, char *buf, |
1249 | loff_t off, size_t count) | 1239 | loff_t off, size_t count) |
1250 | { | 1240 | { |
1251 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 1241 | struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj)); |
1252 | void __iomem *rom; | 1242 | void __iomem *rom; |
1253 | size_t size; | 1243 | size_t size; |
1254 | 1244 | ||
@@ -1508,7 +1498,7 @@ static struct attribute *pci_dev_dev_attrs[] = { | |||
1508 | static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, | 1498 | static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, |
1509 | struct attribute *a, int n) | 1499 | struct attribute *a, int n) |
1510 | { | 1500 | { |
1511 | struct device *dev = container_of(kobj, struct device, kobj); | 1501 | struct device *dev = kobj_to_dev(kobj); |
1512 | struct pci_dev *pdev = to_pci_dev(dev); | 1502 | struct pci_dev *pdev = to_pci_dev(dev); |
1513 | 1503 | ||
1514 | if (a == &vga_attr.attr) | 1504 | if (a == &vga_attr.attr) |
@@ -1527,7 +1517,7 @@ static struct attribute *pci_dev_hp_attrs[] = { | |||
1527 | static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj, | 1517 | static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj, |
1528 | struct attribute *a, int n) | 1518 | struct attribute *a, int n) |
1529 | { | 1519 | { |
1530 | struct device *dev = container_of(kobj, struct device, kobj); | 1520 | struct device *dev = kobj_to_dev(kobj); |
1531 | struct pci_dev *pdev = to_pci_dev(dev); | 1521 | struct pci_dev *pdev = to_pci_dev(dev); |
1532 | 1522 | ||
1533 | if (pdev->is_virtfn) | 1523 | if (pdev->is_virtfn) |
@@ -1551,7 +1541,7 @@ static struct attribute *sriov_dev_attrs[] = { | |||
1551 | static umode_t sriov_attrs_are_visible(struct kobject *kobj, | 1541 | static umode_t sriov_attrs_are_visible(struct kobject *kobj, |
1552 | struct attribute *a, int n) | 1542 | struct attribute *a, int n) |
1553 | { | 1543 | { |
1554 | struct device *dev = container_of(kobj, struct device, kobj); | 1544 | struct device *dev = kobj_to_dev(kobj); |
1555 | 1545 | ||
1556 | if (!dev_is_pf(dev)) | 1546 | if (!dev_is_pf(dev)) |
1557 | return 0; | 1547 | return 0; |