Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/pci: use pdev->dev.groups for attribute creation

Let the driver core handle attribute creation by putting all s390
specific pci attributes in an attribute group which is referenced
by pdev->dev.groups in pcibios_add_device.

Link: https://lkml.kernel.org/r/alpine.LFD.2.11.1404141101500.1529@denkbrett
Reviewed-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Sebastian Ott and committed by
Martin Schwidefsky
93065d04 b346953d

+16 -40
+2 -4
arch/s390/include/asm/pci.h
··· 120 120 return (zdev->fh & (1UL << 31)) ? true : false; 121 121 } 122 122 123 + extern const struct attribute_group *zpci_attr_groups[]; 124 + 123 125 /* ----------------------------------------------------------------------------- 124 126 Prototypes 125 127 ----------------------------------------------------------------------------- */ ··· 167 165 /* Helpers */ 168 166 struct zpci_dev *get_zdev(struct pci_dev *); 169 167 struct zpci_dev *get_zdev_by_fid(u32); 170 - 171 - /* sysfs */ 172 - int zpci_sysfs_add_device(struct device *); 173 - void zpci_sysfs_remove_device(struct device *); 174 168 175 169 /* DMA */ 176 170 int zpci_dma_init(void);
+1 -5
arch/s390/pci/pci.c
··· 530 530 } 531 531 } 532 532 533 - int pcibios_add_platform_entries(struct pci_dev *pdev) 534 - { 535 - return zpci_sysfs_add_device(&pdev->dev); 536 - } 537 - 538 533 static int __init zpci_irq_init(void) 539 534 { 540 535 int rc; ··· 666 671 int i; 667 672 668 673 zdev->pdev = pdev; 674 + pdev->dev.groups = zpci_attr_groups; 669 675 zpci_map_resources(zdev); 670 676 671 677 for (i = 0; i < PCI_BAR_COUNT; i++) {
+13 -31
arch/s390/pci/pci_sysfs.c
··· 51 51 } 52 52 static DEVICE_ATTR_WO(recover); 53 53 54 - static struct device_attribute *zpci_dev_attrs[] = { 55 - &dev_attr_function_id, 56 - &dev_attr_function_handle, 57 - &dev_attr_pchid, 58 - &dev_attr_pfgid, 59 - &dev_attr_recover, 54 + static struct attribute *zpci_dev_attrs[] = { 55 + &dev_attr_function_id.attr, 56 + &dev_attr_function_handle.attr, 57 + &dev_attr_pchid.attr, 58 + &dev_attr_pfgid.attr, 59 + &dev_attr_recover.attr, 60 60 NULL, 61 61 }; 62 - 63 - int zpci_sysfs_add_device(struct device *dev) 64 - { 65 - int i, rc = 0; 66 - 67 - for (i = 0; zpci_dev_attrs[i]; i++) { 68 - rc = device_create_file(dev, zpci_dev_attrs[i]); 69 - if (rc) 70 - goto error; 71 - } 72 - return 0; 73 - 74 - error: 75 - while (--i >= 0) 76 - device_remove_file(dev, zpci_dev_attrs[i]); 77 - return rc; 78 - } 79 - 80 - void zpci_sysfs_remove_device(struct device *dev) 81 - { 82 - int i; 83 - 84 - for (i = 0; zpci_dev_attrs[i]; i++) 85 - device_remove_file(dev, zpci_dev_attrs[i]); 86 - } 62 + static struct attribute_group zpci_attr_group = { 63 + .attrs = zpci_dev_attrs, 64 + }; 65 + const struct attribute_group *zpci_attr_groups[] = { 66 + &zpci_attr_group, 67 + NULL, 68 + };