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

s390/pci: s390 specific PCI sysfs attributes

Add some s390 specific sysfs attributes to the PCI device directory.
The following attributes are introduced:
- function_id (PCI function ID)
- function_handle (PCI function handle)
- pchid (PCI channel ID)
- pfgid (PCI function group ID aka PCI root complex)

Signed-off-by: Jan Glauber <jang@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Jan Glauber and committed by
Martin Schwidefsky
1e8da956 7441b062

+97 -1
+4
arch/s390/include/asm/pci.h
··· 141 141 struct zpci_dev *get_zdev_by_fid(u32); 142 142 bool zpci_fid_present(u32); 143 143 144 + /* sysfs */ 145 + int zpci_sysfs_add_device(struct device *); 146 + void zpci_sysfs_remove_device(struct device *); 147 + 144 148 /* DMA */ 145 149 int zpci_dma_init(void); 146 150 void zpci_dma_exit(void);
+1 -1
arch/s390/pci/Makefile
··· 3 3 # 4 4 5 5 obj-$(CONFIG_PCI) += pci.o pci_dma.o pci_clp.o pci_msi.o \ 6 - pci_event.o 6 + pci_sysfs.o pci_event.o
+6
arch/s390/pci/pci.c
··· 628 628 dev_info(&pdev->dev, "Removing device %u\n", zdev->domain); 629 629 zdev->state = ZPCI_FN_STATE_CONFIGURED; 630 630 zpci_dma_exit_device(zdev); 631 + zpci_sysfs_remove_device(&pdev->dev); 631 632 zpci_unmap_resources(pdev); 632 633 list_del(&zdev->entry); /* can be called from init */ 633 634 zdev->pdev = NULL; ··· 675 674 { 676 675 zpci_remove_device(pdev); 677 676 pdev->sysdata = NULL; 677 + } 678 + 679 + int pcibios_add_platform_entries(struct pci_dev *pdev) 680 + { 681 + return zpci_sysfs_add_device(&pdev->dev); 678 682 } 679 683 680 684 int zpci_request_irq(unsigned int irq, irq_handler_t handler, void *data)
+86
arch/s390/pci/pci_sysfs.c
··· 1 + /* 2 + * Copyright IBM Corp. 2012 3 + * 4 + * Author(s): 5 + * Jan Glauber <jang@linux.vnet.ibm.com> 6 + */ 7 + 8 + #define COMPONENT "zPCI" 9 + #define pr_fmt(fmt) COMPONENT ": " fmt 10 + 11 + #include <linux/kernel.h> 12 + #include <linux/stat.h> 13 + #include <linux/pci.h> 14 + 15 + static ssize_t show_fid(struct device *dev, struct device_attribute *attr, 16 + char *buf) 17 + { 18 + struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev)); 19 + 20 + sprintf(buf, "0x%08x\n", zdev->fid); 21 + return strlen(buf); 22 + } 23 + static DEVICE_ATTR(function_id, S_IRUGO, show_fid, NULL); 24 + 25 + static ssize_t show_fh(struct device *dev, struct device_attribute *attr, 26 + char *buf) 27 + { 28 + struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev)); 29 + 30 + sprintf(buf, "0x%08x\n", zdev->fh); 31 + return strlen(buf); 32 + } 33 + static DEVICE_ATTR(function_handle, S_IRUGO, show_fh, NULL); 34 + 35 + static ssize_t show_pchid(struct device *dev, struct device_attribute *attr, 36 + char *buf) 37 + { 38 + struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev)); 39 + 40 + sprintf(buf, "0x%04x\n", zdev->pchid); 41 + return strlen(buf); 42 + } 43 + static DEVICE_ATTR(pchid, S_IRUGO, show_pchid, NULL); 44 + 45 + static ssize_t show_pfgid(struct device *dev, struct device_attribute *attr, 46 + char *buf) 47 + { 48 + struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev)); 49 + 50 + sprintf(buf, "0x%02x\n", zdev->pfgid); 51 + return strlen(buf); 52 + } 53 + static DEVICE_ATTR(pfgid, S_IRUGO, show_pfgid, NULL); 54 + 55 + static struct device_attribute *zpci_dev_attrs[] = { 56 + &dev_attr_function_id, 57 + &dev_attr_function_handle, 58 + &dev_attr_pchid, 59 + &dev_attr_pfgid, 60 + NULL, 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 + }