diff options
Diffstat (limited to 'drivers/pci/slot.c')
-rw-r--r-- | drivers/pci/slot.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c index 8c02b6c53bdb..659eaa0fc48f 100644 --- a/drivers/pci/slot.c +++ b/drivers/pci/slot.c | |||
@@ -6,6 +6,7 @@ | |||
6 | */ | 6 | */ |
7 | 7 | ||
8 | #include <linux/kobject.h> | 8 | #include <linux/kobject.h> |
9 | #include <linux/slab.h> | ||
9 | #include <linux/pci.h> | 10 | #include <linux/pci.h> |
10 | #include <linux/err.h> | 11 | #include <linux/err.h> |
11 | #include "pci.h" | 12 | #include "pci.h" |
@@ -29,7 +30,7 @@ static ssize_t pci_slot_attr_store(struct kobject *kobj, | |||
29 | return attribute->store ? attribute->store(slot, buf, len) : -EIO; | 30 | return attribute->store ? attribute->store(slot, buf, len) : -EIO; |
30 | } | 31 | } |
31 | 32 | ||
32 | static struct sysfs_ops pci_slot_sysfs_ops = { | 33 | static const struct sysfs_ops pci_slot_sysfs_ops = { |
33 | .show = pci_slot_attr_show, | 34 | .show = pci_slot_attr_show, |
34 | .store = pci_slot_attr_store, | 35 | .store = pci_slot_attr_store, |
35 | }; | 36 | }; |
@@ -47,6 +48,55 @@ static ssize_t address_read_file(struct pci_slot *slot, char *buf) | |||
47 | slot->number); | 48 | slot->number); |
48 | } | 49 | } |
49 | 50 | ||
51 | /* these strings match up with the values in pci_bus_speed */ | ||
52 | static char *pci_bus_speed_strings[] = { | ||
53 | "33 MHz PCI", /* 0x00 */ | ||
54 | "66 MHz PCI", /* 0x01 */ | ||
55 | "66 MHz PCI-X", /* 0x02 */ | ||
56 | "100 MHz PCI-X", /* 0x03 */ | ||
57 | "133 MHz PCI-X", /* 0x04 */ | ||
58 | NULL, /* 0x05 */ | ||
59 | NULL, /* 0x06 */ | ||
60 | NULL, /* 0x07 */ | ||
61 | NULL, /* 0x08 */ | ||
62 | "66 MHz PCI-X 266", /* 0x09 */ | ||
63 | "100 MHz PCI-X 266", /* 0x0a */ | ||
64 | "133 MHz PCI-X 266", /* 0x0b */ | ||
65 | "Unknown AGP", /* 0x0c */ | ||
66 | "1x AGP", /* 0x0d */ | ||
67 | "2x AGP", /* 0x0e */ | ||
68 | "4x AGP", /* 0x0f */ | ||
69 | "8x AGP", /* 0x10 */ | ||
70 | "66 MHz PCI-X 533", /* 0x11 */ | ||
71 | "100 MHz PCI-X 533", /* 0x12 */ | ||
72 | "133 MHz PCI-X 533", /* 0x13 */ | ||
73 | "2.5 GT/s PCIe", /* 0x14 */ | ||
74 | "5.0 GT/s PCIe", /* 0x15 */ | ||
75 | "8.0 GT/s PCIe", /* 0x16 */ | ||
76 | }; | ||
77 | |||
78 | static ssize_t bus_speed_read(enum pci_bus_speed speed, char *buf) | ||
79 | { | ||
80 | const char *speed_string; | ||
81 | |||
82 | if (speed < ARRAY_SIZE(pci_bus_speed_strings)) | ||
83 | speed_string = pci_bus_speed_strings[speed]; | ||
84 | else | ||
85 | speed_string = "Unknown"; | ||
86 | |||
87 | return sprintf(buf, "%s\n", speed_string); | ||
88 | } | ||
89 | |||
90 | static ssize_t max_speed_read_file(struct pci_slot *slot, char *buf) | ||
91 | { | ||
92 | return bus_speed_read(slot->bus->max_bus_speed, buf); | ||
93 | } | ||
94 | |||
95 | static ssize_t cur_speed_read_file(struct pci_slot *slot, char *buf) | ||
96 | { | ||
97 | return bus_speed_read(slot->bus->cur_bus_speed, buf); | ||
98 | } | ||
99 | |||
50 | static void pci_slot_release(struct kobject *kobj) | 100 | static void pci_slot_release(struct kobject *kobj) |
51 | { | 101 | { |
52 | struct pci_dev *dev; | 102 | struct pci_dev *dev; |
@@ -66,9 +116,15 @@ static void pci_slot_release(struct kobject *kobj) | |||
66 | 116 | ||
67 | static struct pci_slot_attribute pci_slot_attr_address = | 117 | static struct pci_slot_attribute pci_slot_attr_address = |
68 | __ATTR(address, (S_IFREG | S_IRUGO), address_read_file, NULL); | 118 | __ATTR(address, (S_IFREG | S_IRUGO), address_read_file, NULL); |
119 | static struct pci_slot_attribute pci_slot_attr_max_speed = | ||
120 | __ATTR(max_bus_speed, (S_IFREG | S_IRUGO), max_speed_read_file, NULL); | ||
121 | static struct pci_slot_attribute pci_slot_attr_cur_speed = | ||
122 | __ATTR(cur_bus_speed, (S_IFREG | S_IRUGO), cur_speed_read_file, NULL); | ||
69 | 123 | ||
70 | static struct attribute *pci_slot_default_attrs[] = { | 124 | static struct attribute *pci_slot_default_attrs[] = { |
71 | &pci_slot_attr_address.attr, | 125 | &pci_slot_attr_address.attr, |
126 | &pci_slot_attr_max_speed.attr, | ||
127 | &pci_slot_attr_cur_speed.attr, | ||
72 | NULL, | 128 | NULL, |
73 | }; | 129 | }; |
74 | 130 | ||