diff options
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
| -rw-r--r-- | drivers/pci/pci-sysfs.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 6ca0061137a6..a15f94072a6f 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
| @@ -29,7 +29,7 @@ static int sysfs_initialized; /* = 0 */ | |||
| 29 | /* show configuration fields */ | 29 | /* show configuration fields */ |
| 30 | #define pci_config_attr(field, format_string) \ | 30 | #define pci_config_attr(field, format_string) \ |
| 31 | static ssize_t \ | 31 | static ssize_t \ |
| 32 | field##_show(struct device *dev, char *buf) \ | 32 | field##_show(struct device *dev, struct device_attribute *attr, char *buf) \ |
| 33 | { \ | 33 | { \ |
| 34 | struct pci_dev *pdev; \ | 34 | struct pci_dev *pdev; \ |
| 35 | \ | 35 | \ |
| @@ -44,7 +44,7 @@ pci_config_attr(subsystem_device, "0x%04x\n"); | |||
| 44 | pci_config_attr(class, "0x%06x\n"); | 44 | pci_config_attr(class, "0x%06x\n"); |
| 45 | pci_config_attr(irq, "%u\n"); | 45 | pci_config_attr(irq, "%u\n"); |
| 46 | 46 | ||
| 47 | static ssize_t local_cpus_show(struct device *dev, char *buf) | 47 | static ssize_t local_cpus_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 48 | { | 48 | { |
| 49 | cpumask_t mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); | 49 | cpumask_t mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); |
| 50 | int len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); | 50 | int len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); |
| @@ -54,7 +54,7 @@ static ssize_t local_cpus_show(struct device *dev, char *buf) | |||
| 54 | 54 | ||
| 55 | /* show resources */ | 55 | /* show resources */ |
| 56 | static ssize_t | 56 | static ssize_t |
| 57 | resource_show(struct device * dev, char * buf) | 57 | resource_show(struct device * dev, struct device_attribute *attr, char * buf) |
| 58 | { | 58 | { |
| 59 | struct pci_dev * pci_dev = to_pci_dev(dev); | 59 | struct pci_dev * pci_dev = to_pci_dev(dev); |
| 60 | char * str = buf; | 60 | char * str = buf; |
| @@ -73,7 +73,7 @@ resource_show(struct device * dev, char * buf) | |||
| 73 | return (str - buf); | 73 | return (str - buf); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | static ssize_t modalias_show(struct device *dev, char *buf) | 76 | static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf) |
| 77 | { | 77 | { |
| 78 | struct pci_dev *pci_dev = to_pci_dev(dev); | 78 | struct pci_dev *pci_dev = to_pci_dev(dev); |
| 79 | 79 | ||
| @@ -339,16 +339,17 @@ pci_create_resource_files(struct pci_dev *pdev) | |||
| 339 | if (!pci_resource_len(pdev, i)) | 339 | if (!pci_resource_len(pdev, i)) |
| 340 | continue; | 340 | continue; |
| 341 | 341 | ||
| 342 | res_attr = kmalloc(sizeof(*res_attr) + 10, GFP_ATOMIC); | 342 | /* allocate attribute structure, piggyback attribute name */ |
| 343 | res_attr = kcalloc(1, sizeof(*res_attr) + 10, GFP_ATOMIC); | ||
| 343 | if (res_attr) { | 344 | if (res_attr) { |
| 344 | memset(res_attr, 0, sizeof(*res_attr) + 10); | 345 | char *res_attr_name = (char *)(res_attr + 1); |
| 346 | |||
| 345 | pdev->res_attr[i] = res_attr; | 347 | pdev->res_attr[i] = res_attr; |
| 346 | /* Allocated above after the res_attr struct */ | 348 | sprintf(res_attr_name, "resource%d", i); |
| 347 | res_attr->attr.name = (char *)(res_attr + 1); | 349 | res_attr->attr.name = res_attr_name; |
| 348 | sprintf(res_attr->attr.name, "resource%d", i); | ||
| 349 | res_attr->size = pci_resource_len(pdev, i); | ||
| 350 | res_attr->attr.mode = S_IRUSR | S_IWUSR; | 350 | res_attr->attr.mode = S_IRUSR | S_IWUSR; |
| 351 | res_attr->attr.owner = THIS_MODULE; | 351 | res_attr->attr.owner = THIS_MODULE; |
| 352 | res_attr->size = pci_resource_len(pdev, i); | ||
| 352 | res_attr->mmap = pci_mmap_resource; | 353 | res_attr->mmap = pci_mmap_resource; |
| 353 | res_attr->private = &pdev->resource[i]; | 354 | res_attr->private = &pdev->resource[i]; |
| 354 | sysfs_create_bin_file(&pdev->dev.kobj, res_attr); | 355 | sysfs_create_bin_file(&pdev->dev.kobj, res_attr); |
