Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * drivers/pci/pci-sysfs.c |
| 3 | * |
| 4 | * (C) Copyright 2002-2004 Greg Kroah-Hartman <greg@kroah.com> |
| 5 | * (C) Copyright 2002-2004 IBM Corp. |
| 6 | * (C) Copyright 2003 Matthew Wilcox |
| 7 | * (C) Copyright 2003 Hewlett-Packard |
| 8 | * (C) Copyright 2004 Jon Smirl <jonsmirl@yahoo.com> |
| 9 | * (C) Copyright 2004 Silicon Graphics, Inc. Jesse Barnes <jbarnes@sgi.com> |
| 10 | * |
| 11 | * File attributes for PCI devices |
| 12 | * |
| 13 | * Modeled after usb's driverfs.c |
| 14 | * |
| 15 | */ |
| 16 | |
| 17 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <linux/kernel.h> |
| 19 | #include <linux/pci.h> |
| 20 | #include <linux/stat.h> |
| 21 | #include <linux/topology.h> |
| 22 | #include <linux/mm.h> |
Alexey Dobriyan | aa0ac36 | 2007-07-15 23:40:39 -0700 | [diff] [blame] | 23 | #include <linux/capability.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | #include "pci.h" |
| 25 | |
| 26 | static int sysfs_initialized; /* = 0 */ |
| 27 | |
| 28 | /* show configuration fields */ |
| 29 | #define pci_config_attr(field, format_string) \ |
| 30 | static ssize_t \ |
Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 31 | field##_show(struct device *dev, struct device_attribute *attr, char *buf) \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | { \ |
| 33 | struct pci_dev *pdev; \ |
| 34 | \ |
| 35 | pdev = to_pci_dev (dev); \ |
| 36 | return sprintf (buf, format_string, pdev->field); \ |
| 37 | } |
| 38 | |
| 39 | pci_config_attr(vendor, "0x%04x\n"); |
| 40 | pci_config_attr(device, "0x%04x\n"); |
| 41 | pci_config_attr(subsystem_vendor, "0x%04x\n"); |
| 42 | pci_config_attr(subsystem_device, "0x%04x\n"); |
| 43 | pci_config_attr(class, "0x%06x\n"); |
| 44 | pci_config_attr(irq, "%u\n"); |
| 45 | |
Doug Thompson | bdee9d9 | 2006-06-14 16:59:48 -0700 | [diff] [blame] | 46 | static ssize_t broken_parity_status_show(struct device *dev, |
| 47 | struct device_attribute *attr, |
| 48 | char *buf) |
| 49 | { |
| 50 | struct pci_dev *pdev = to_pci_dev(dev); |
| 51 | return sprintf (buf, "%u\n", pdev->broken_parity_status); |
| 52 | } |
| 53 | |
| 54 | static ssize_t broken_parity_status_store(struct device *dev, |
| 55 | struct device_attribute *attr, |
| 56 | const char *buf, size_t count) |
| 57 | { |
| 58 | struct pci_dev *pdev = to_pci_dev(dev); |
| 59 | ssize_t consumed = -EINVAL; |
| 60 | |
| 61 | if ((count > 0) && (*buf == '0' || *buf == '1')) { |
| 62 | pdev->broken_parity_status = *buf == '1' ? 1 : 0; |
| 63 | consumed = count; |
| 64 | } |
| 65 | return consumed; |
| 66 | } |
| 67 | |
Alan Cox | 4327edf | 2005-09-10 00:25:49 -0700 | [diff] [blame] | 68 | static ssize_t local_cpus_show(struct device *dev, |
| 69 | struct device_attribute *attr, char *buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | { |
Alan Cox | 4327edf | 2005-09-10 00:25:49 -0700 | [diff] [blame] | 71 | cpumask_t mask; |
| 72 | int len; |
| 73 | |
| 74 | mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); |
| 75 | len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); |
Mike Travis | 39106dc | 2008-04-08 11:43:03 -0700 | [diff] [blame^] | 76 | buf[len++] = '\n'; |
| 77 | buf[len] = '\0'; |
| 78 | return len; |
| 79 | } |
| 80 | |
| 81 | |
| 82 | static ssize_t local_cpulist_show(struct device *dev, |
| 83 | struct device_attribute *attr, char *buf) |
| 84 | { |
| 85 | cpumask_t mask; |
| 86 | int len; |
| 87 | |
| 88 | mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); |
| 89 | len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask); |
| 90 | buf[len++] = '\n'; |
| 91 | buf[len] = '\0'; |
| 92 | return len; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | /* show resources */ |
| 96 | static ssize_t |
Yani Ioannou | e404e27 | 2005-05-17 06:42:58 -0400 | [diff] [blame] | 97 | resource_show(struct device * dev, struct device_attribute *attr, char * buf) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | { |
| 99 | struct pci_dev * pci_dev = to_pci_dev(dev); |
| 100 | char * str = buf; |
| 101 | int i; |
| 102 | int max = 7; |
Greg Kroah-Hartman | e31dd6e | 2006-06-12 17:06:02 -0700 | [diff] [blame] | 103 | resource_size_t start, end; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | |
| 105 | if (pci_dev->subordinate) |
| 106 | max = DEVICE_COUNT_RESOURCE; |
| 107 | |
| 108 | for (i = 0; i < max; i++) { |
Michael Ellerman | 2311b1f | 2005-05-13 17:44:10 +1000 | [diff] [blame] | 109 | struct resource *res = &pci_dev->resource[i]; |
| 110 | pci_resource_to_user(pci_dev, i, res, &start, &end); |
| 111 | str += sprintf(str,"0x%016llx 0x%016llx 0x%016llx\n", |
| 112 | (unsigned long long)start, |
| 113 | (unsigned long long)end, |
| 114 | (unsigned long long)res->flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 115 | } |
| 116 | return (str - buf); |
| 117 | } |
| 118 | |
Greg Kroah-Hartman | 87c8a44 | 2005-06-19 12:21:43 +0200 | [diff] [blame] | 119 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) |
Greg KH | 9888549 | 2005-05-05 11:57:25 -0700 | [diff] [blame] | 120 | { |
| 121 | struct pci_dev *pci_dev = to_pci_dev(dev); |
| 122 | |
| 123 | return sprintf(buf, "pci:v%08Xd%08Xsv%08Xsd%08Xbc%02Xsc%02Xi%02x\n", |
| 124 | pci_dev->vendor, pci_dev->device, |
| 125 | pci_dev->subsystem_vendor, pci_dev->subsystem_device, |
| 126 | (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8), |
| 127 | (u8)(pci_dev->class)); |
| 128 | } |
Inaky Perez-Gonzalez | bae94d0 | 2006-11-22 12:40:31 -0800 | [diff] [blame] | 129 | |
| 130 | static ssize_t is_enabled_store(struct device *dev, |
| 131 | struct device_attribute *attr, const char *buf, |
| 132 | size_t count) |
Arjan van de Ven | 9f125d3 | 2006-04-29 10:59:08 +0200 | [diff] [blame] | 133 | { |
Inaky Perez-Gonzalez | bae94d0 | 2006-11-22 12:40:31 -0800 | [diff] [blame] | 134 | ssize_t result = -EINVAL; |
Arjan van de Ven | 9f125d3 | 2006-04-29 10:59:08 +0200 | [diff] [blame] | 135 | struct pci_dev *pdev = to_pci_dev(dev); |
| 136 | |
| 137 | /* this can crash the machine when done on the "wrong" device */ |
| 138 | if (!capable(CAP_SYS_ADMIN)) |
| 139 | return count; |
| 140 | |
Inaky Perez-Gonzalez | bae94d0 | 2006-11-22 12:40:31 -0800 | [diff] [blame] | 141 | if (*buf == '0') { |
| 142 | if (atomic_read(&pdev->enable_cnt) != 0) |
| 143 | pci_disable_device(pdev); |
| 144 | else |
| 145 | result = -EIO; |
| 146 | } else if (*buf == '1') |
| 147 | result = pci_enable_device(pdev); |
Arjan van de Ven | 9f125d3 | 2006-04-29 10:59:08 +0200 | [diff] [blame] | 148 | |
Inaky Perez-Gonzalez | bae94d0 | 2006-11-22 12:40:31 -0800 | [diff] [blame] | 149 | return result < 0 ? result : count; |
| 150 | } |
Arjan van de Ven | 9f125d3 | 2006-04-29 10:59:08 +0200 | [diff] [blame] | 151 | |
Inaky Perez-Gonzalez | bae94d0 | 2006-11-22 12:40:31 -0800 | [diff] [blame] | 152 | static ssize_t is_enabled_show(struct device *dev, |
| 153 | struct device_attribute *attr, char *buf) |
| 154 | { |
| 155 | struct pci_dev *pdev; |
| 156 | |
| 157 | pdev = to_pci_dev (dev); |
| 158 | return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt)); |
Arjan van de Ven | 9f125d3 | 2006-04-29 10:59:08 +0200 | [diff] [blame] | 159 | } |
| 160 | |
Brice Goglin | 81bb0e1 | 2007-01-28 10:53:40 +0100 | [diff] [blame] | 161 | #ifdef CONFIG_NUMA |
| 162 | static ssize_t |
| 163 | numa_node_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 164 | { |
| 165 | return sprintf (buf, "%d\n", dev->numa_node); |
| 166 | } |
| 167 | #endif |
| 168 | |
Brice Goglin | fe97064 | 2006-08-31 01:55:15 -0400 | [diff] [blame] | 169 | static ssize_t |
| 170 | msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 171 | { |
| 172 | struct pci_dev *pdev = to_pci_dev(dev); |
| 173 | |
| 174 | if (!pdev->subordinate) |
| 175 | return 0; |
| 176 | |
| 177 | return sprintf (buf, "%u\n", |
| 178 | !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI)); |
| 179 | } |
| 180 | |
| 181 | static ssize_t |
| 182 | msi_bus_store(struct device *dev, struct device_attribute *attr, |
| 183 | const char *buf, size_t count) |
| 184 | { |
| 185 | struct pci_dev *pdev = to_pci_dev(dev); |
| 186 | |
| 187 | /* bad things may happen if the no_msi flag is changed |
| 188 | * while some drivers are loaded */ |
| 189 | if (!capable(CAP_SYS_ADMIN)) |
| 190 | return count; |
| 191 | |
| 192 | if (!pdev->subordinate) |
| 193 | return count; |
| 194 | |
| 195 | if (*buf == '0') { |
| 196 | pdev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI; |
| 197 | dev_warn(&pdev->dev, "forced subordinate bus to not support MSI," |
| 198 | " bad things could happen.\n"); |
| 199 | } |
| 200 | |
| 201 | if (*buf == '1') { |
| 202 | pdev->subordinate->bus_flags &= ~PCI_BUS_FLAGS_NO_MSI; |
| 203 | dev_warn(&pdev->dev, "forced subordinate bus to support MSI," |
| 204 | " bad things could happen.\n"); |
| 205 | } |
| 206 | |
| 207 | return count; |
| 208 | } |
Greg KH | 9888549 | 2005-05-05 11:57:25 -0700 | [diff] [blame] | 209 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 210 | struct device_attribute pci_dev_attrs[] = { |
| 211 | __ATTR_RO(resource), |
| 212 | __ATTR_RO(vendor), |
| 213 | __ATTR_RO(device), |
| 214 | __ATTR_RO(subsystem_vendor), |
| 215 | __ATTR_RO(subsystem_device), |
| 216 | __ATTR_RO(class), |
| 217 | __ATTR_RO(irq), |
| 218 | __ATTR_RO(local_cpus), |
Mike Travis | 39106dc | 2008-04-08 11:43:03 -0700 | [diff] [blame^] | 219 | __ATTR_RO(local_cpulist), |
Greg KH | 9888549 | 2005-05-05 11:57:25 -0700 | [diff] [blame] | 220 | __ATTR_RO(modalias), |
Brice Goglin | 81bb0e1 | 2007-01-28 10:53:40 +0100 | [diff] [blame] | 221 | #ifdef CONFIG_NUMA |
| 222 | __ATTR_RO(numa_node), |
| 223 | #endif |
Arjan van de Ven | 9f125d3 | 2006-04-29 10:59:08 +0200 | [diff] [blame] | 224 | __ATTR(enable, 0600, is_enabled_show, is_enabled_store), |
Doug Thompson | bdee9d9 | 2006-06-14 16:59:48 -0700 | [diff] [blame] | 225 | __ATTR(broken_parity_status,(S_IRUGO|S_IWUSR), |
| 226 | broken_parity_status_show,broken_parity_status_store), |
Brice Goglin | fe97064 | 2006-08-31 01:55:15 -0400 | [diff] [blame] | 227 | __ATTR(msi_bus, 0644, msi_bus_show, msi_bus_store), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | __ATTR_NULL, |
| 229 | }; |
| 230 | |
| 231 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 232 | pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, |
| 233 | char *buf, loff_t off, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 234 | { |
| 235 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); |
| 236 | unsigned int size = 64; |
| 237 | loff_t init_off = off; |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 238 | u8 *data = (u8*) buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | |
| 240 | /* Several chips lock up trying to read undefined config space */ |
| 241 | if (capable(CAP_SYS_ADMIN)) { |
| 242 | size = dev->cfg_size; |
| 243 | } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) { |
| 244 | size = 128; |
| 245 | } |
| 246 | |
| 247 | if (off > size) |
| 248 | return 0; |
| 249 | if (off + count > size) { |
| 250 | size -= off; |
| 251 | count = size; |
| 252 | } else { |
| 253 | size = count; |
| 254 | } |
| 255 | |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 256 | if ((off & 1) && size) { |
| 257 | u8 val; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 258 | pci_user_read_config_byte(dev, off, &val); |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 259 | data[off - init_off] = val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | off++; |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 261 | size--; |
| 262 | } |
| 263 | |
| 264 | if ((off & 3) && size > 2) { |
| 265 | u16 val; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 266 | pci_user_read_config_word(dev, off, &val); |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 267 | data[off - init_off] = val & 0xff; |
| 268 | data[off - init_off + 1] = (val >> 8) & 0xff; |
| 269 | off += 2; |
| 270 | size -= 2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | } |
| 272 | |
| 273 | while (size > 3) { |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 274 | u32 val; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 275 | pci_user_read_config_dword(dev, off, &val); |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 276 | data[off - init_off] = val & 0xff; |
| 277 | data[off - init_off + 1] = (val >> 8) & 0xff; |
| 278 | data[off - init_off + 2] = (val >> 16) & 0xff; |
| 279 | data[off - init_off + 3] = (val >> 24) & 0xff; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | off += 4; |
| 281 | size -= 4; |
| 282 | } |
| 283 | |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 284 | if (size >= 2) { |
| 285 | u16 val; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 286 | pci_user_read_config_word(dev, off, &val); |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 287 | data[off - init_off] = val & 0xff; |
| 288 | data[off - init_off + 1] = (val >> 8) & 0xff; |
| 289 | off += 2; |
| 290 | size -= 2; |
| 291 | } |
| 292 | |
| 293 | if (size > 0) { |
| 294 | u8 val; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 295 | pci_user_read_config_byte(dev, off, &val); |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 296 | data[off - init_off] = val; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 297 | off++; |
| 298 | --size; |
| 299 | } |
| 300 | |
| 301 | return count; |
| 302 | } |
| 303 | |
| 304 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 305 | pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, |
| 306 | char *buf, loff_t off, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 307 | { |
| 308 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); |
| 309 | unsigned int size = count; |
| 310 | loff_t init_off = off; |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 311 | u8 *data = (u8*) buf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | |
| 313 | if (off > dev->cfg_size) |
| 314 | return 0; |
| 315 | if (off + count > dev->cfg_size) { |
| 316 | size = dev->cfg_size - off; |
| 317 | count = size; |
| 318 | } |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 319 | |
| 320 | if ((off & 1) && size) { |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 321 | pci_user_write_config_byte(dev, off, data[off - init_off]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | off++; |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 323 | size--; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | } |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 325 | |
| 326 | if ((off & 3) && size > 2) { |
| 327 | u16 val = data[off - init_off]; |
| 328 | val |= (u16) data[off - init_off + 1] << 8; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 329 | pci_user_write_config_word(dev, off, val); |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 330 | off += 2; |
| 331 | size -= 2; |
| 332 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | |
| 334 | while (size > 3) { |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 335 | u32 val = data[off - init_off]; |
| 336 | val |= (u32) data[off - init_off + 1] << 8; |
| 337 | val |= (u32) data[off - init_off + 2] << 16; |
| 338 | val |= (u32) data[off - init_off + 3] << 24; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 339 | pci_user_write_config_dword(dev, off, val); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | off += 4; |
| 341 | size -= 4; |
| 342 | } |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 343 | |
| 344 | if (size >= 2) { |
| 345 | u16 val = data[off - init_off]; |
| 346 | val |= (u16) data[off - init_off + 1] << 8; |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 347 | pci_user_write_config_word(dev, off, val); |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 348 | off += 2; |
| 349 | size -= 2; |
| 350 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
ssant@in.ibm.com | 4c0619a | 2005-04-08 14:53:31 +0900 | [diff] [blame] | 352 | if (size) { |
Brian King | e04b0ea | 2005-09-27 01:21:55 -0700 | [diff] [blame] | 353 | pci_user_write_config_byte(dev, off, data[off - init_off]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 354 | off++; |
| 355 | --size; |
| 356 | } |
| 357 | |
| 358 | return count; |
| 359 | } |
| 360 | |
| 361 | #ifdef HAVE_PCI_LEGACY |
| 362 | /** |
| 363 | * pci_read_legacy_io - read byte(s) from legacy I/O port space |
| 364 | * @kobj: kobject corresponding to file to read from |
| 365 | * @buf: buffer to store results |
| 366 | * @off: offset into legacy I/O port space |
| 367 | * @count: number of bytes to read |
| 368 | * |
| 369 | * Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific |
| 370 | * callback routine (pci_legacy_read). |
| 371 | */ |
| 372 | ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 373 | pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, |
| 374 | char *buf, loff_t off, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | { |
| 376 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
Greg Kroah-Hartman | fd7d1ce | 2007-05-22 22:47:54 -0400 | [diff] [blame] | 377 | struct device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 378 | kobj)); |
| 379 | |
| 380 | /* Only support 1, 2 or 4 byte accesses */ |
| 381 | if (count != 1 && count != 2 && count != 4) |
| 382 | return -EINVAL; |
| 383 | |
| 384 | return pci_legacy_read(bus, off, (u32 *)buf, count); |
| 385 | } |
| 386 | |
| 387 | /** |
| 388 | * pci_write_legacy_io - write byte(s) to legacy I/O port space |
| 389 | * @kobj: kobject corresponding to file to read from |
| 390 | * @buf: buffer containing value to be written |
| 391 | * @off: offset into legacy I/O port space |
| 392 | * @count: number of bytes to write |
| 393 | * |
| 394 | * Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific |
| 395 | * callback routine (pci_legacy_write). |
| 396 | */ |
| 397 | ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 398 | pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, |
| 399 | char *buf, loff_t off, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | { |
| 401 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
Greg Kroah-Hartman | fd7d1ce | 2007-05-22 22:47:54 -0400 | [diff] [blame] | 402 | struct device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 | kobj)); |
| 404 | /* Only support 1, 2 or 4 byte accesses */ |
| 405 | if (count != 1 && count != 2 && count != 4) |
| 406 | return -EINVAL; |
| 407 | |
| 408 | return pci_legacy_write(bus, off, *(u32 *)buf, count); |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * pci_mmap_legacy_mem - map legacy PCI memory into user memory space |
| 413 | * @kobj: kobject corresponding to device to be mapped |
| 414 | * @attr: struct bin_attribute for this file |
| 415 | * @vma: struct vm_area_struct passed to mmap |
| 416 | * |
| 417 | * Uses an arch specific callback, pci_mmap_legacy_page_range, to mmap |
| 418 | * legacy memory space (first meg of bus space) into application virtual |
| 419 | * memory space. |
| 420 | */ |
| 421 | int |
| 422 | pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, |
| 423 | struct vm_area_struct *vma) |
| 424 | { |
| 425 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
Greg Kroah-Hartman | fd7d1ce | 2007-05-22 22:47:54 -0400 | [diff] [blame] | 426 | struct device, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | kobj)); |
| 428 | |
| 429 | return pci_mmap_legacy_page_range(bus, vma); |
| 430 | } |
| 431 | #endif /* HAVE_PCI_LEGACY */ |
| 432 | |
| 433 | #ifdef HAVE_PCI_MMAP |
| 434 | /** |
| 435 | * pci_mmap_resource - map a PCI resource into user memory space |
| 436 | * @kobj: kobject for mapping |
| 437 | * @attr: struct bin_attribute for the file being mapped |
| 438 | * @vma: struct vm_area_struct passed into the mmap |
| 439 | * |
| 440 | * Use the regular PCI mapping routines to map a PCI resource into userspace. |
| 441 | * FIXME: write combining? maybe automatic for prefetchable regions? |
| 442 | */ |
| 443 | static int |
| 444 | pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, |
| 445 | struct vm_area_struct *vma) |
| 446 | { |
| 447 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, |
| 448 | struct device, kobj)); |
| 449 | struct resource *res = (struct resource *)attr->private; |
| 450 | enum pci_mmap_state mmap_type; |
Greg Kroah-Hartman | e31dd6e | 2006-06-12 17:06:02 -0700 | [diff] [blame] | 451 | resource_size_t start, end; |
Michael Ellerman | 2311b1f | 2005-05-13 17:44:10 +1000 | [diff] [blame] | 452 | int i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Michael Ellerman | 2311b1f | 2005-05-13 17:44:10 +1000 | [diff] [blame] | 454 | for (i = 0; i < PCI_ROM_RESOURCE; i++) |
| 455 | if (res == &pdev->resource[i]) |
| 456 | break; |
| 457 | if (i >= PCI_ROM_RESOURCE) |
| 458 | return -ENODEV; |
| 459 | |
| 460 | /* pci_mmap_page_range() expects the same kind of entry as coming |
| 461 | * from /proc/bus/pci/ which is a "user visible" value. If this is |
| 462 | * different from the resource itself, arch will do necessary fixup. |
| 463 | */ |
| 464 | pci_resource_to_user(pdev, i, res, &start, &end); |
| 465 | vma->vm_pgoff += start >> PAGE_SHIFT; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | mmap_type = res->flags & IORESOURCE_MEM ? pci_mmap_mem : pci_mmap_io; |
| 467 | |
| 468 | return pci_mmap_page_range(pdev, vma, mmap_type, 0); |
| 469 | } |
| 470 | |
| 471 | /** |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 472 | * pci_remove_resource_files - cleanup resource files |
| 473 | * @dev: dev to cleanup |
| 474 | * |
| 475 | * If we created resource files for @dev, remove them from sysfs and |
| 476 | * free their resources. |
| 477 | */ |
| 478 | static void |
| 479 | pci_remove_resource_files(struct pci_dev *pdev) |
| 480 | { |
| 481 | int i; |
| 482 | |
| 483 | for (i = 0; i < PCI_ROM_RESOURCE; i++) { |
| 484 | struct bin_attribute *res_attr; |
| 485 | |
| 486 | res_attr = pdev->res_attr[i]; |
| 487 | if (res_attr) { |
| 488 | sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); |
| 489 | kfree(res_attr); |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | /** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 495 | * pci_create_resource_files - create resource files in sysfs for @dev |
| 496 | * @dev: dev in question |
| 497 | * |
| 498 | * Walk the resources in @dev creating files for each resource available. |
| 499 | */ |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 500 | static int pci_create_resource_files(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 501 | { |
| 502 | int i; |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 503 | int retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | |
| 505 | /* Expose the PCI resources from this device as files */ |
| 506 | for (i = 0; i < PCI_ROM_RESOURCE; i++) { |
| 507 | struct bin_attribute *res_attr; |
| 508 | |
| 509 | /* skip empty resources */ |
| 510 | if (!pci_resource_len(pdev, i)) |
| 511 | continue; |
| 512 | |
Dmitry Torokhov | d48593b | 2005-04-29 00:58:46 -0500 | [diff] [blame] | 513 | /* allocate attribute structure, piggyback attribute name */ |
Pekka Enberg | 656da9d | 2005-09-22 00:48:11 -0700 | [diff] [blame] | 514 | res_attr = kzalloc(sizeof(*res_attr) + 10, GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 515 | if (res_attr) { |
Dmitry Torokhov | d48593b | 2005-04-29 00:58:46 -0500 | [diff] [blame] | 516 | char *res_attr_name = (char *)(res_attr + 1); |
| 517 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | pdev->res_attr[i] = res_attr; |
Dmitry Torokhov | d48593b | 2005-04-29 00:58:46 -0500 | [diff] [blame] | 519 | sprintf(res_attr_name, "resource%d", i); |
| 520 | res_attr->attr.name = res_attr_name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 521 | res_attr->attr.mode = S_IRUSR | S_IWUSR; |
Dmitry Torokhov | d48593b | 2005-04-29 00:58:46 -0500 | [diff] [blame] | 522 | res_attr->size = pci_resource_len(pdev, i); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | res_attr->mmap = pci_mmap_resource; |
| 524 | res_attr->private = &pdev->resource[i]; |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 525 | retval = sysfs_create_bin_file(&pdev->dev.kobj, res_attr); |
| 526 | if (retval) { |
| 527 | pci_remove_resource_files(pdev); |
| 528 | return retval; |
| 529 | } |
| 530 | } else { |
| 531 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 532 | } |
| 533 | } |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 534 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | } |
| 536 | #else /* !HAVE_PCI_MMAP */ |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 537 | static inline int pci_create_resource_files(struct pci_dev *dev) { return 0; } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | static inline void pci_remove_resource_files(struct pci_dev *dev) { return; } |
| 539 | #endif /* HAVE_PCI_MMAP */ |
| 540 | |
| 541 | /** |
| 542 | * pci_write_rom - used to enable access to the PCI ROM display |
| 543 | * @kobj: kernel object handle |
| 544 | * @buf: user input |
| 545 | * @off: file offset |
| 546 | * @count: number of byte in input |
| 547 | * |
| 548 | * writing anything except 0 enables it |
| 549 | */ |
| 550 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 551 | pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, |
| 552 | char *buf, loff_t off, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 553 | { |
| 554 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); |
| 555 | |
| 556 | if ((off == 0) && (*buf == '0') && (count == 2)) |
| 557 | pdev->rom_attr_enabled = 0; |
| 558 | else |
| 559 | pdev->rom_attr_enabled = 1; |
| 560 | |
| 561 | return count; |
| 562 | } |
| 563 | |
| 564 | /** |
| 565 | * pci_read_rom - read a PCI ROM |
| 566 | * @kobj: kernel object handle |
| 567 | * @buf: where to put the data we read from the ROM |
| 568 | * @off: file offset |
| 569 | * @count: number of bytes to read |
| 570 | * |
| 571 | * Put @count bytes starting at @off into @buf from the ROM in the PCI |
| 572 | * device corresponding to @kobj. |
| 573 | */ |
| 574 | static ssize_t |
Zhang Rui | 91a6902 | 2007-06-09 13:57:22 +0800 | [diff] [blame] | 575 | pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, |
| 576 | char *buf, loff_t off, size_t count) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 577 | { |
| 578 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); |
| 579 | void __iomem *rom; |
| 580 | size_t size; |
| 581 | |
| 582 | if (!pdev->rom_attr_enabled) |
| 583 | return -EINVAL; |
| 584 | |
| 585 | rom = pci_map_rom(pdev, &size); /* size starts out as PCI window size */ |
| 586 | if (!rom) |
| 587 | return 0; |
| 588 | |
| 589 | if (off >= size) |
| 590 | count = 0; |
| 591 | else { |
| 592 | if (off + count > size) |
| 593 | count = size - off; |
| 594 | |
| 595 | memcpy_fromio(buf, rom + off, count); |
| 596 | } |
| 597 | pci_unmap_rom(pdev, rom); |
| 598 | |
| 599 | return count; |
| 600 | } |
| 601 | |
| 602 | static struct bin_attribute pci_config_attr = { |
| 603 | .attr = { |
| 604 | .name = "config", |
| 605 | .mode = S_IRUGO | S_IWUSR, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | }, |
| 607 | .size = 256, |
| 608 | .read = pci_read_config, |
| 609 | .write = pci_write_config, |
| 610 | }; |
| 611 | |
| 612 | static struct bin_attribute pcie_config_attr = { |
| 613 | .attr = { |
| 614 | .name = "config", |
| 615 | .mode = S_IRUGO | S_IWUSR, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 616 | }, |
| 617 | .size = 4096, |
| 618 | .read = pci_read_config, |
| 619 | .write = pci_write_config, |
| 620 | }; |
| 621 | |
Michael Ellerman | a2cd52c | 2007-05-08 12:03:08 +1000 | [diff] [blame] | 622 | int __attribute__ ((weak)) pcibios_add_platform_entries(struct pci_dev *dev) |
Michael Ellerman | 575e334 | 2007-05-08 12:03:07 +1000 | [diff] [blame] | 623 | { |
Michael Ellerman | a2cd52c | 2007-05-08 12:03:08 +1000 | [diff] [blame] | 624 | return 0; |
Michael Ellerman | 575e334 | 2007-05-08 12:03:07 +1000 | [diff] [blame] | 625 | } |
| 626 | |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 627 | int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | { |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 629 | struct bin_attribute *rom_attr = NULL; |
| 630 | int retval; |
| 631 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 632 | if (!sysfs_initialized) |
| 633 | return -EACCES; |
| 634 | |
| 635 | if (pdev->cfg_size < 4096) |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 636 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 637 | else |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 638 | retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
| 639 | if (retval) |
| 640 | goto err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 641 | |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 642 | retval = pci_create_resource_files(pdev); |
| 643 | if (retval) |
| 644 | goto err_bin_file; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | |
| 646 | /* If the device has a ROM, try to expose it in sysfs. */ |
Jesse Barnes | 40ee9e9 | 2007-03-24 11:03:32 -0700 | [diff] [blame] | 647 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE) || |
| 648 | (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)) { |
Eric Sesterhenn | f5afe80 | 2006-02-28 15:34:49 +0100 | [diff] [blame] | 649 | rom_attr = kzalloc(sizeof(*rom_attr), GFP_ATOMIC); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | if (rom_attr) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 651 | pdev->rom_attr = rom_attr; |
| 652 | rom_attr->size = pci_resource_len(pdev, PCI_ROM_RESOURCE); |
| 653 | rom_attr->attr.name = "rom"; |
| 654 | rom_attr->attr.mode = S_IRUSR; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 655 | rom_attr->read = pci_read_rom; |
| 656 | rom_attr->write = pci_write_rom; |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 657 | retval = sysfs_create_bin_file(&pdev->dev.kobj, rom_attr); |
| 658 | if (retval) |
| 659 | goto err_rom; |
| 660 | } else { |
| 661 | retval = -ENOMEM; |
Michael Ellerman | 9890b12 | 2007-04-18 13:34:12 +1000 | [diff] [blame] | 662 | goto err_resource_files; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | } |
| 664 | } |
| 665 | /* add platform-specific attributes */ |
Michael Ellerman | a2cd52c | 2007-05-08 12:03:08 +1000 | [diff] [blame] | 666 | if (pcibios_add_platform_entries(pdev)) |
| 667 | goto err_rom_file; |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 668 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 669 | return 0; |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 670 | |
Michael Ellerman | a2cd52c | 2007-05-08 12:03:08 +1000 | [diff] [blame] | 671 | err_rom_file: |
| 672 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) |
| 673 | sysfs_remove_bin_file(&pdev->dev.kobj, rom_attr); |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 674 | err_rom: |
| 675 | kfree(rom_attr); |
Michael Ellerman | 9890b12 | 2007-04-18 13:34:12 +1000 | [diff] [blame] | 676 | err_resource_files: |
| 677 | pci_remove_resource_files(pdev); |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 678 | err_bin_file: |
| 679 | if (pdev->cfg_size < 4096) |
| 680 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); |
| 681 | else |
| 682 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
| 683 | err: |
| 684 | return retval; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 685 | } |
| 686 | |
| 687 | /** |
| 688 | * pci_remove_sysfs_dev_files - cleanup PCI specific sysfs files |
| 689 | * @pdev: device whose entries we should free |
| 690 | * |
| 691 | * Cleanup when @pdev is removed from sysfs. |
| 692 | */ |
| 693 | void pci_remove_sysfs_dev_files(struct pci_dev *pdev) |
| 694 | { |
David Miller | d67afe5 | 2006-11-10 12:27:48 -0800 | [diff] [blame] | 695 | if (!sysfs_initialized) |
| 696 | return; |
| 697 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 698 | if (pdev->cfg_size < 4096) |
| 699 | sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); |
| 700 | else |
| 701 | sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); |
| 702 | |
| 703 | pci_remove_resource_files(pdev); |
| 704 | |
| 705 | if (pci_resource_len(pdev, PCI_ROM_RESOURCE)) { |
| 706 | if (pdev->rom_attr) { |
| 707 | sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr); |
| 708 | kfree(pdev->rom_attr); |
| 709 | } |
| 710 | } |
| 711 | } |
| 712 | |
| 713 | static int __init pci_sysfs_init(void) |
| 714 | { |
| 715 | struct pci_dev *pdev = NULL; |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 716 | int retval; |
| 717 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | sysfs_initialized = 1; |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 719 | for_each_pci_dev(pdev) { |
| 720 | retval = pci_create_sysfs_dev_files(pdev); |
Julia Lawall | 151fc5d | 2007-11-20 08:41:16 +0100 | [diff] [blame] | 721 | if (retval) { |
| 722 | pci_dev_put(pdev); |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 723 | return retval; |
Julia Lawall | 151fc5d | 2007-11-20 08:41:16 +0100 | [diff] [blame] | 724 | } |
Greg Kroah-Hartman | b19441a | 2006-08-28 11:43:25 -0700 | [diff] [blame] | 725 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 726 | |
| 727 | return 0; |
| 728 | } |
| 729 | |
Jesse Barnes | 40ee9e9 | 2007-03-24 11:03:32 -0700 | [diff] [blame] | 730 | late_initcall(pci_sysfs_init); |