summaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci-sysfs.c
diff options
context:
space:
mode:
authorRyan Desfosses <ryan@desfo.org>2014-04-18 20:13:49 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-06-10 22:20:19 -0400
commit3c78bc61f5ef3bc87e7f94f67ec737d2273f120b (patch)
tree490efb8676389718e78a4d6775ad668538ecaf4f /drivers/pci/pci-sysfs.c
parentb7fe943421396b61b9f7a97c2554ed999e0f3658 (diff)
PCI: Whitespace cleanup
Fix various whitespace errors. No functional change. [bhelgaas: fix other similar problems] Signed-off-by: Ryan Desfosses <ryan@desfo.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r--drivers/pci/pci-sysfs.c289
1 files changed, 131 insertions, 158 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 84c350994b06..41d8d0307347 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -41,8 +41,8 @@ field##_show(struct device *dev, struct device_attribute *attr, char *buf) \
41{ \ 41{ \
42 struct pci_dev *pdev; \ 42 struct pci_dev *pdev; \
43 \ 43 \
44 pdev = to_pci_dev (dev); \ 44 pdev = to_pci_dev(dev); \
45 return sprintf (buf, format_string, pdev->field); \ 45 return sprintf(buf, format_string, pdev->field); \
46} \ 46} \
47static DEVICE_ATTR_RO(field) 47static DEVICE_ATTR_RO(field)
48 48
@@ -58,7 +58,7 @@ static ssize_t broken_parity_status_show(struct device *dev,
58 char *buf) 58 char *buf)
59{ 59{
60 struct pci_dev *pdev = to_pci_dev(dev); 60 struct pci_dev *pdev = to_pci_dev(dev);
61 return sprintf (buf, "%u\n", pdev->broken_parity_status); 61 return sprintf(buf, "%u\n", pdev->broken_parity_status);
62} 62}
63 63
64static ssize_t broken_parity_status_store(struct device *dev, 64static ssize_t broken_parity_status_store(struct device *dev,
@@ -77,10 +77,8 @@ static ssize_t broken_parity_status_store(struct device *dev,
77} 77}
78static DEVICE_ATTR_RW(broken_parity_status); 78static DEVICE_ATTR_RW(broken_parity_status);
79 79
80static ssize_t pci_dev_show_local_cpu(struct device *dev, 80static ssize_t pci_dev_show_local_cpu(struct device *dev, int type,
81 int type, 81 struct device_attribute *attr, char *buf)
82 struct device_attribute *attr,
83 char *buf)
84{ 82{
85 const struct cpumask *mask; 83 const struct cpumask *mask;
86 int len; 84 int len;
@@ -101,14 +99,14 @@ static ssize_t pci_dev_show_local_cpu(struct device *dev,
101} 99}
102 100
103static ssize_t local_cpus_show(struct device *dev, 101static ssize_t local_cpus_show(struct device *dev,
104 struct device_attribute *attr, char *buf) 102 struct device_attribute *attr, char *buf)
105{ 103{
106 return pci_dev_show_local_cpu(dev, 1, attr, buf); 104 return pci_dev_show_local_cpu(dev, 1, attr, buf);
107} 105}
108static DEVICE_ATTR_RO(local_cpus); 106static DEVICE_ATTR_RO(local_cpus);
109 107
110static ssize_t local_cpulist_show(struct device *dev, 108static ssize_t local_cpulist_show(struct device *dev,
111 struct device_attribute *attr, char *buf) 109 struct device_attribute *attr, char *buf)
112{ 110{
113 return pci_dev_show_local_cpu(dev, 0, attr, buf); 111 return pci_dev_show_local_cpu(dev, 0, attr, buf);
114} 112}
@@ -117,8 +115,7 @@ static DEVICE_ATTR_RO(local_cpulist);
117/* 115/*
118 * PCI Bus Class Devices 116 * PCI Bus Class Devices
119 */ 117 */
120static ssize_t pci_bus_show_cpuaffinity(struct device *dev, 118static ssize_t pci_bus_show_cpuaffinity(struct device *dev, int type,
121 int type,
122 struct device_attribute *attr, 119 struct device_attribute *attr,
123 char *buf) 120 char *buf)
124{ 121{
@@ -149,11 +146,11 @@ static ssize_t cpulistaffinity_show(struct device *dev,
149static DEVICE_ATTR_RO(cpulistaffinity); 146static DEVICE_ATTR_RO(cpulistaffinity);
150 147
151/* show resources */ 148/* show resources */
152static ssize_t 149static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
153resource_show(struct device * dev, struct device_attribute *attr, char * buf) 150 char *buf)
154{ 151{
155 struct pci_dev * pci_dev = to_pci_dev(dev); 152 struct pci_dev *pci_dev = to_pci_dev(dev);
156 char * str = buf; 153 char *str = buf;
157 int i; 154 int i;
158 int max; 155 int max;
159 resource_size_t start, end; 156 resource_size_t start, end;
@@ -166,7 +163,7 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
166 for (i = 0; i < max; i++) { 163 for (i = 0; i < max; i++) {
167 struct resource *res = &pci_dev->resource[i]; 164 struct resource *res = &pci_dev->resource[i];
168 pci_resource_to_user(pci_dev, i, res, &start, &end); 165 pci_resource_to_user(pci_dev, i, res, &start, &end);
169 str += sprintf(str,"0x%016llx 0x%016llx 0x%016llx\n", 166 str += sprintf(str, "0x%016llx 0x%016llx 0x%016llx\n",
170 (unsigned long long)start, 167 (unsigned long long)start,
171 (unsigned long long)end, 168 (unsigned long long)end,
172 (unsigned long long)res->flags); 169 (unsigned long long)res->flags);
@@ -175,7 +172,8 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
175} 172}
176static DEVICE_ATTR_RO(resource); 173static DEVICE_ATTR_RO(resource);
177 174
178static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) 175static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
176 char *buf)
179{ 177{
180 struct pci_dev *pci_dev = to_pci_dev(dev); 178 struct pci_dev *pci_dev = to_pci_dev(dev);
181 179
@@ -187,9 +185,8 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
187} 185}
188static DEVICE_ATTR_RO(modalias); 186static DEVICE_ATTR_RO(modalias);
189 187
190static ssize_t enabled_store(struct device *dev, 188static ssize_t enabled_store(struct device *dev, struct device_attribute *attr,
191 struct device_attribute *attr, const char *buf, 189 const char *buf, size_t count)
192 size_t count)
193{ 190{
194 struct pci_dev *pdev = to_pci_dev(dev); 191 struct pci_dev *pdev = to_pci_dev(dev);
195 unsigned long val; 192 unsigned long val;
@@ -213,57 +210,56 @@ static ssize_t enabled_store(struct device *dev,
213 return result < 0 ? result : count; 210 return result < 0 ? result : count;
214} 211}
215 212
216static ssize_t enabled_show(struct device *dev, 213static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
217 struct device_attribute *attr, char *buf) 214 char *buf)
218{ 215{
219 struct pci_dev *pdev; 216 struct pci_dev *pdev;
220 217
221 pdev = to_pci_dev (dev); 218 pdev = to_pci_dev(dev);
222 return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt)); 219 return sprintf(buf, "%u\n", atomic_read(&pdev->enable_cnt));
223} 220}
224static DEVICE_ATTR_RW(enabled); 221static DEVICE_ATTR_RW(enabled);
225 222
226#ifdef CONFIG_NUMA 223#ifdef CONFIG_NUMA
227static ssize_t 224static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr,
228numa_node_show(struct device *dev, struct device_attribute *attr, char *buf) 225 char *buf)
229{ 226{
230 return sprintf (buf, "%d\n", dev->numa_node); 227 return sprintf(buf, "%d\n", dev->numa_node);
231} 228}
232static DEVICE_ATTR_RO(numa_node); 229static DEVICE_ATTR_RO(numa_node);
233#endif 230#endif
234 231
235static ssize_t 232static ssize_t dma_mask_bits_show(struct device *dev,
236dma_mask_bits_show(struct device *dev, struct device_attribute *attr, char *buf) 233 struct device_attribute *attr, char *buf)
237{ 234{
238 struct pci_dev *pdev = to_pci_dev(dev); 235 struct pci_dev *pdev = to_pci_dev(dev);
239 236
240 return sprintf (buf, "%d\n", fls64(pdev->dma_mask)); 237 return sprintf(buf, "%d\n", fls64(pdev->dma_mask));
241} 238}
242static DEVICE_ATTR_RO(dma_mask_bits); 239static DEVICE_ATTR_RO(dma_mask_bits);
243 240
244static ssize_t 241static ssize_t consistent_dma_mask_bits_show(struct device *dev,
245consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr, 242 struct device_attribute *attr,
246 char *buf) 243 char *buf)
247{ 244{
248 return sprintf (buf, "%d\n", fls64(dev->coherent_dma_mask)); 245 return sprintf(buf, "%d\n", fls64(dev->coherent_dma_mask));
249} 246}
250static DEVICE_ATTR_RO(consistent_dma_mask_bits); 247static DEVICE_ATTR_RO(consistent_dma_mask_bits);
251 248
252static ssize_t 249static ssize_t msi_bus_show(struct device *dev, struct device_attribute *attr,
253msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf) 250 char *buf)
254{ 251{
255 struct pci_dev *pdev = to_pci_dev(dev); 252 struct pci_dev *pdev = to_pci_dev(dev);
256 253
257 if (!pdev->subordinate) 254 if (!pdev->subordinate)
258 return 0; 255 return 0;
259 256
260 return sprintf (buf, "%u\n", 257 return sprintf(buf, "%u\n",
261 !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI)); 258 !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI));
262} 259}
263 260
264static ssize_t 261static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
265msi_bus_store(struct device *dev, struct device_attribute *attr, 262 const char *buf, size_t count)
266 const char *buf, size_t count)
267{ 263{
268 struct pci_dev *pdev = to_pci_dev(dev); 264 struct pci_dev *pdev = to_pci_dev(dev);
269 unsigned long val; 265 unsigned long val;
@@ -331,9 +327,9 @@ const struct attribute_group *pci_bus_groups[] = {
331 NULL, 327 NULL,
332}; 328};
333 329
334static ssize_t 330static ssize_t dev_rescan_store(struct device *dev,
335dev_rescan_store(struct device *dev, struct device_attribute *attr, 331 struct device_attribute *attr, const char *buf,
336 const char *buf, size_t count) 332 size_t count)
337{ 333{
338 unsigned long val; 334 unsigned long val;
339 struct pci_dev *pdev = to_pci_dev(dev); 335 struct pci_dev *pdev = to_pci_dev(dev);
@@ -352,9 +348,8 @@ static struct device_attribute dev_rescan_attr = __ATTR(rescan,
352 (S_IWUSR|S_IWGRP), 348 (S_IWUSR|S_IWGRP),
353 NULL, dev_rescan_store); 349 NULL, dev_rescan_store);
354 350
355static ssize_t 351static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
356remove_store(struct device *dev, struct device_attribute *attr, 352 const char *buf, size_t count)
357 const char *buf, size_t count)
358{ 353{
359 unsigned long val; 354 unsigned long val;
360 355
@@ -369,9 +364,9 @@ static struct device_attribute dev_remove_attr = __ATTR(remove,
369 (S_IWUSR|S_IWGRP), 364 (S_IWUSR|S_IWGRP),
370 NULL, remove_store); 365 NULL, remove_store);
371 366
372static ssize_t 367static ssize_t dev_bus_rescan_store(struct device *dev,
373dev_bus_rescan_store(struct device *dev, struct device_attribute *attr, 368 struct device_attribute *attr,
374 const char *buf, size_t count) 369 const char *buf, size_t count)
375{ 370{
376 unsigned long val; 371 unsigned long val;
377 struct pci_bus *bus = to_pci_bus(dev); 372 struct pci_bus *bus = to_pci_bus(dev);
@@ -412,7 +407,7 @@ static ssize_t d3cold_allowed_show(struct device *dev,
412 struct device_attribute *attr, char *buf) 407 struct device_attribute *attr, char *buf)
413{ 408{
414 struct pci_dev *pdev = to_pci_dev(dev); 409 struct pci_dev *pdev = to_pci_dev(dev);
415 return sprintf (buf, "%u\n", pdev->d3cold_allowed); 410 return sprintf(buf, "%u\n", pdev->d3cold_allowed);
416} 411}
417static DEVICE_ATTR_RW(d3cold_allowed); 412static DEVICE_ATTR_RW(d3cold_allowed);
418#endif 413#endif
@@ -607,8 +602,8 @@ const struct attribute_group *pcibus_groups[] = {
607 NULL, 602 NULL,
608}; 603};
609 604
610static ssize_t 605static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
611boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf) 606 char *buf)
612{ 607{
613 struct pci_dev *pdev = to_pci_dev(dev); 608 struct pci_dev *pdev = to_pci_dev(dev);
614 struct pci_dev *vga_dev = vga_default_device(); 609 struct pci_dev *vga_dev = vga_default_device();
@@ -622,22 +617,21 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
622} 617}
623static struct device_attribute vga_attr = __ATTR_RO(boot_vga); 618static struct device_attribute vga_attr = __ATTR_RO(boot_vga);
624 619
625static ssize_t 620static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
626pci_read_config(struct file *filp, struct kobject *kobj, 621 struct bin_attribute *bin_attr, char *buf,
627 struct bin_attribute *bin_attr, 622 loff_t off, size_t count)
628 char *buf, loff_t off, size_t count)
629{ 623{
630 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 624 struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device,
625 kobj));
631 unsigned int size = 64; 626 unsigned int size = 64;
632 loff_t init_off = off; 627 loff_t init_off = off;
633 u8 *data = (u8*) buf; 628 u8 *data = (u8 *) buf;
634 629
635 /* Several chips lock up trying to read undefined config space */ 630 /* Several chips lock up trying to read undefined config space */
636 if (security_capable(filp->f_cred, &init_user_ns, CAP_SYS_ADMIN) == 0) { 631 if (security_capable(filp->f_cred, &init_user_ns, CAP_SYS_ADMIN) == 0)
637 size = dev->cfg_size; 632 size = dev->cfg_size;
638 } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { 633 else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
639 size = 128; 634 size = 128;
640 }
641 635
642 if (off > size) 636 if (off > size)
643 return 0; 637 return 0;
@@ -700,15 +694,15 @@ pci_read_config(struct file *filp, struct kobject *kobj,
700 return count; 694 return count;
701} 695}
702 696
703static ssize_t 697static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
704pci_write_config(struct file* filp, struct kobject *kobj, 698 struct bin_attribute *bin_attr, char *buf,
705 struct bin_attribute *bin_attr, 699 loff_t off, size_t count)
706 char *buf, loff_t off, size_t count)
707{ 700{
708 struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); 701 struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device,
702 kobj));
709 unsigned int size = count; 703 unsigned int size = count;
710 loff_t init_off = off; 704 loff_t init_off = off;
711 u8 *data = (u8*) buf; 705 u8 *data = (u8 *) buf;
712 706
713 if (off > dev->cfg_size) 707 if (off > dev->cfg_size)
714 return 0; 708 return 0;
@@ -728,10 +722,10 @@ pci_write_config(struct file* filp, struct kobject *kobj,
728 if ((off & 3) && size > 2) { 722 if ((off & 3) && size > 2) {
729 u16 val = data[off - init_off]; 723 u16 val = data[off - init_off];
730 val |= (u16) data[off - init_off + 1] << 8; 724 val |= (u16) data[off - init_off + 1] << 8;
731 pci_user_write_config_word(dev, off, val); 725 pci_user_write_config_word(dev, off, val);
732 off += 2; 726 off += 2;
733 size -= 2; 727 size -= 2;
734 } 728 }
735 729
736 while (size > 3) { 730 while (size > 3) {
737 u32 val = data[off - init_off]; 731 u32 val = data[off - init_off];
@@ -762,10 +756,9 @@ pci_write_config(struct file* filp, struct kobject *kobj,
762 return count; 756 return count;
763} 757}
764 758
765static ssize_t 759static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj,
766read_vpd_attr(struct file *filp, struct kobject *kobj, 760 struct bin_attribute *bin_attr, char *buf,
767 struct bin_attribute *bin_attr, 761 loff_t off, size_t count)
768 char *buf, loff_t off, size_t count)
769{ 762{
770 struct pci_dev *dev = 763 struct pci_dev *dev =
771 to_pci_dev(container_of(kobj, struct device, kobj)); 764 to_pci_dev(container_of(kobj, struct device, kobj));
@@ -778,10 +771,9 @@ read_vpd_attr(struct file *filp, struct kobject *kobj,
778 return pci_read_vpd(dev, off, count, buf); 771 return pci_read_vpd(dev, off, count, buf);
779} 772}
780 773
781static ssize_t 774static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj,
782write_vpd_attr(struct file *filp, struct kobject *kobj, 775 struct bin_attribute *bin_attr, char *buf,
783 struct bin_attribute *bin_attr, 776 loff_t off, size_t count)
784 char *buf, loff_t off, size_t count)
785{ 777{
786 struct pci_dev *dev = 778 struct pci_dev *dev =
787 to_pci_dev(container_of(kobj, struct device, kobj)); 779 to_pci_dev(container_of(kobj, struct device, kobj));
@@ -807,20 +799,18 @@ write_vpd_attr(struct file *filp, struct kobject *kobj,
807 * Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific 799 * Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific
808 * callback routine (pci_legacy_read). 800 * callback routine (pci_legacy_read).
809 */ 801 */
810static ssize_t 802static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj,
811pci_read_legacy_io(struct file *filp, struct kobject *kobj, 803 struct bin_attribute *bin_attr, char *buf,
812 struct bin_attribute *bin_attr, 804 loff_t off, size_t count)
813 char *buf, loff_t off, size_t count)
814{ 805{
815 struct pci_bus *bus = to_pci_bus(container_of(kobj, 806 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
816 struct device,
817 kobj)); 807 kobj));
818 808
819 /* Only support 1, 2 or 4 byte accesses */ 809 /* Only support 1, 2 or 4 byte accesses */
820 if (count != 1 && count != 2 && count != 4) 810 if (count != 1 && count != 2 && count != 4)
821 return -EINVAL; 811 return -EINVAL;
822 812
823 return pci_legacy_read(bus, off, (u32 *)buf, count); 813 return pci_legacy_read(bus, off, (u32 *)buf, count);
824} 814}
825 815
826/** 816/**
@@ -835,19 +825,18 @@ pci_read_legacy_io(struct file *filp, struct kobject *kobj,
835 * Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific 825 * Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific
836 * callback routine (pci_legacy_write). 826 * callback routine (pci_legacy_write).
837 */ 827 */
838static ssize_t 828static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,
839pci_write_legacy_io(struct file *filp, struct kobject *kobj, 829 struct bin_attribute *bin_attr, char *buf,
840 struct bin_attribute *bin_attr, 830 loff_t off, size_t count)
841 char *buf, loff_t off, size_t count)
842{ 831{
843 struct pci_bus *bus = to_pci_bus(container_of(kobj, 832 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
844 struct device,
845 kobj)); 833 kobj));
846 /* Only support 1, 2 or 4 byte accesses */
847 if (count != 1 && count != 2 && count != 4)
848 return -EINVAL;
849 834
850 return pci_legacy_write(bus, off, *(u32 *)buf, count); 835 /* Only support 1, 2 or 4 byte accesses */
836 if (count != 1 && count != 2 && count != 4)
837 return -EINVAL;
838
839 return pci_legacy_write(bus, off, *(u32 *)buf, count);
851} 840}
852 841
853/** 842/**
@@ -861,16 +850,14 @@ pci_write_legacy_io(struct file *filp, struct kobject *kobj,
861 * legacy memory space (first meg of bus space) into application virtual 850 * legacy memory space (first meg of bus space) into application virtual
862 * memory space. 851 * memory space.
863 */ 852 */
864static int 853static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
865pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj, 854 struct bin_attribute *attr,
866 struct bin_attribute *attr, 855 struct vm_area_struct *vma)
867 struct vm_area_struct *vma)
868{ 856{
869 struct pci_bus *bus = to_pci_bus(container_of(kobj, 857 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
870 struct device,
871 kobj)); 858 kobj));
872 859
873 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem); 860 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem);
874} 861}
875 862
876/** 863/**
@@ -884,16 +871,14 @@ pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
884 * legacy IO space (first meg of bus space) into application virtual 871 * legacy IO space (first meg of bus space) into application virtual
885 * memory space. Returns -ENOSYS if the operation isn't supported 872 * memory space. Returns -ENOSYS if the operation isn't supported
886 */ 873 */
887static int 874static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
888pci_mmap_legacy_io(struct file *filp, struct kobject *kobj, 875 struct bin_attribute *attr,
889 struct bin_attribute *attr, 876 struct vm_area_struct *vma)
890 struct vm_area_struct *vma)
891{ 877{
892 struct pci_bus *bus = to_pci_bus(container_of(kobj, 878 struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
893 struct device,
894 kobj)); 879 kobj));
895 880
896 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io); 881 return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io);
897} 882}
898 883
899/** 884/**
@@ -903,10 +888,9 @@ pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
903 * 888 *
904 * Stub implementation. Can be overridden by arch if necessary. 889 * Stub implementation. Can be overridden by arch if necessary.
905 */ 890 */
906void __weak 891void __weak pci_adjust_legacy_attr(struct pci_bus *b,
907pci_adjust_legacy_attr(struct pci_bus *b, enum pci_mmap_state mmap_type) 892 enum pci_mmap_state mmap_type)
908{ 893{
909 return;
910} 894}
911 895
912/** 896/**
@@ -1005,9 +989,8 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,
1005 * 989 *
1006 * Use the regular PCI mapping routines to map a PCI resource into userspace. 990 * Use the regular PCI mapping routines to map a PCI resource into userspace.
1007 */ 991 */
1008static int 992static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
1009pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, 993 struct vm_area_struct *vma, int write_combine)
1010 struct vm_area_struct *vma, int write_combine)
1011{ 994{
1012 struct pci_dev *pdev = to_pci_dev(container_of(kobj, 995 struct pci_dev *pdev = to_pci_dev(container_of(kobj,
1013 struct device, kobj)); 996 struct device, kobj));
@@ -1046,26 +1029,23 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
1046 return pci_mmap_page_range(pdev, vma, mmap_type, write_combine); 1029 return pci_mmap_page_range(pdev, vma, mmap_type, write_combine);
1047} 1030}
1048 1031
1049static int 1032static int pci_mmap_resource_uc(struct file *filp, struct kobject *kobj,
1050pci_mmap_resource_uc(struct file *filp, struct kobject *kobj, 1033 struct bin_attribute *attr,
1051 struct bin_attribute *attr, 1034 struct vm_area_struct *vma)
1052 struct vm_area_struct *vma)
1053{ 1035{
1054 return pci_mmap_resource(kobj, attr, vma, 0); 1036 return pci_mmap_resource(kobj, attr, vma, 0);
1055} 1037}
1056 1038
1057static int 1039static int pci_mmap_resource_wc(struct file *filp, struct kobject *kobj,
1058pci_mmap_resource_wc(struct file *filp, struct kobject *kobj, 1040 struct bin_attribute *attr,
1059 struct bin_attribute *attr, 1041 struct vm_area_struct *vma)
1060 struct vm_area_struct *vma)
1061{ 1042{
1062 return pci_mmap_resource(kobj, attr, vma, 1); 1043 return pci_mmap_resource(kobj, attr, vma, 1);
1063} 1044}
1064 1045
1065static ssize_t 1046static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
1066pci_resource_io(struct file *filp, struct kobject *kobj, 1047 struct bin_attribute *attr, char *buf,
1067 struct bin_attribute *attr, char *buf, 1048 loff_t off, size_t count, bool write)
1068 loff_t off, size_t count, bool write)
1069{ 1049{
1070 struct pci_dev *pdev = to_pci_dev(container_of(kobj, 1050 struct pci_dev *pdev = to_pci_dev(container_of(kobj,
1071 struct device, kobj)); 1051 struct device, kobj));
@@ -1110,18 +1090,16 @@ pci_resource_io(struct file *filp, struct kobject *kobj,
1110 return -EINVAL; 1090 return -EINVAL;
1111} 1091}
1112 1092
1113static ssize_t 1093static ssize_t pci_read_resource_io(struct file *filp, struct kobject *kobj,
1114pci_read_resource_io(struct file *filp, struct kobject *kobj, 1094 struct bin_attribute *attr, char *buf,
1115 struct bin_attribute *attr, char *buf, 1095 loff_t off, size_t count)
1116 loff_t off, size_t count)
1117{ 1096{
1118 return pci_resource_io(filp, kobj, attr, buf, off, count, false); 1097 return pci_resource_io(filp, kobj, attr, buf, off, count, false);
1119} 1098}
1120 1099
1121static ssize_t 1100static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,
1122pci_write_resource_io(struct file *filp, struct kobject *kobj, 1101 struct bin_attribute *attr, char *buf,
1123 struct bin_attribute *attr, char *buf, 1102 loff_t off, size_t count)
1124 loff_t off, size_t count)
1125{ 1103{
1126 return pci_resource_io(filp, kobj, attr, buf, off, count, true); 1104 return pci_resource_io(filp, kobj, attr, buf, off, count, true);
1127} 1105}
@@ -1133,8 +1111,7 @@ pci_write_resource_io(struct file *filp, struct kobject *kobj,
1133 * If we created resource files for @pdev, remove them from sysfs and 1111 * If we created resource files for @pdev, remove them from sysfs and
1134 * free their resources. 1112 * free their resources.
1135 */ 1113 */
1136static void 1114static void pci_remove_resource_files(struct pci_dev *pdev)
1137pci_remove_resource_files(struct pci_dev *pdev)
1138{ 1115{
1139 int i; 1116 int i;
1140 1117
@@ -1237,10 +1214,9 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }
1237 * 1214 *
1238 * writing anything except 0 enables it 1215 * writing anything except 0 enables it
1239 */ 1216 */
1240static ssize_t 1217static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
1241pci_write_rom(struct file *filp, struct kobject *kobj, 1218 struct bin_attribute *bin_attr, char *buf,
1242 struct bin_attribute *bin_attr, 1219 loff_t off, size_t count)
1243 char *buf, loff_t off, size_t count)
1244{ 1220{
1245 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); 1221 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
1246 1222
@@ -1264,10 +1240,9 @@ pci_write_rom(struct file *filp, struct kobject *kobj,
1264 * Put @count bytes starting at @off into @buf from the ROM in the PCI 1240 * Put @count bytes starting at @off into @buf from the ROM in the PCI
1265 * device corresponding to @kobj. 1241 * device corresponding to @kobj.
1266 */ 1242 */
1267static ssize_t 1243static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,
1268pci_read_rom(struct file *filp, struct kobject *kobj, 1244 struct bin_attribute *bin_attr, char *buf,
1269 struct bin_attribute *bin_attr, 1245 loff_t off, size_t count)
1270 char *buf, loff_t off, size_t count)
1271{ 1246{
1272 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); 1247 struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
1273 void __iomem *rom; 1248 void __iomem *rom;
@@ -1313,9 +1288,8 @@ static struct bin_attribute pcie_config_attr = {
1313 .write = pci_write_config, 1288 .write = pci_write_config,
1314}; 1289};
1315 1290
1316static ssize_t reset_store(struct device *dev, 1291static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
1317 struct device_attribute *attr, const char *buf, 1292 const char *buf, size_t count)
1318 size_t count)
1319{ 1293{
1320 struct pci_dev *pdev = to_pci_dev(dev); 1294 struct pci_dev *pdev = to_pci_dev(dev);
1321 unsigned long val; 1295 unsigned long val;
@@ -1382,7 +1356,7 @@ error:
1382 return retval; 1356 return retval;
1383} 1357}
1384 1358
1385int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) 1359int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
1386{ 1360{
1387 int retval; 1361 int retval;
1388 int rom_size = 0; 1362 int rom_size = 0;
@@ -1520,7 +1494,6 @@ static int __init pci_sysfs_init(void)
1520 1494
1521 return 0; 1495 return 0;
1522} 1496}
1523
1524late_initcall(pci_sysfs_init); 1497late_initcall(pci_sysfs_init);
1525 1498
1526static struct attribute *pci_dev_dev_attrs[] = { 1499static struct attribute *pci_dev_dev_attrs[] = {
@@ -1529,7 +1502,7 @@ static struct attribute *pci_dev_dev_attrs[] = {
1529}; 1502};
1530 1503
1531static umode_t pci_dev_attrs_are_visible(struct kobject *kobj, 1504static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
1532 struct attribute *a, int n) 1505 struct attribute *a, int n)
1533{ 1506{
1534 struct device *dev = container_of(kobj, struct device, kobj); 1507 struct device *dev = container_of(kobj, struct device, kobj);
1535 struct pci_dev *pdev = to_pci_dev(dev); 1508 struct pci_dev *pdev = to_pci_dev(dev);
@@ -1548,7 +1521,7 @@ static struct attribute *pci_dev_hp_attrs[] = {
1548}; 1521};
1549 1522
1550static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj, 1523static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj,
1551 struct attribute *a, int n) 1524 struct attribute *a, int n)
1552{ 1525{
1553 struct device *dev = container_of(kobj, struct device, kobj); 1526 struct device *dev = container_of(kobj, struct device, kobj);
1554 struct pci_dev *pdev = to_pci_dev(dev); 1527 struct pci_dev *pdev = to_pci_dev(dev);
@@ -1572,7 +1545,7 @@ static struct attribute *sriov_dev_attrs[] = {
1572}; 1545};
1573 1546
1574static umode_t sriov_attrs_are_visible(struct kobject *kobj, 1547static umode_t sriov_attrs_are_visible(struct kobject *kobj,
1575 struct attribute *a, int n) 1548 struct attribute *a, int n)
1576{ 1549{
1577 struct device *dev = container_of(kobj, struct device, kobj); 1550 struct device *dev = container_of(kobj, struct device, kobj);
1578 1551