aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/pci
diff options
context:
space:
mode:
authorSebastian Ott <sebott@linux.vnet.ibm.com>2014-04-16 10:10:18 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2014-05-20 02:58:48 -0400
commitb346953ddac0d57d4852ddc2b5cd9e16c84ddd59 (patch)
treeab7011926812db2349f0bc2d78d1a4529019267e /arch/s390/pci
parentca25f564c484b4f32eec1e667926dcf87ec03234 (diff)
s390/pci: use macro for attribute creation
Introduce the zpci_attr macro to create read only sysfs attributes to avoid duplicate code. 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>
Diffstat (limited to 'arch/s390/pci')
-rw-r--r--arch/s390/pci/pci_sysfs.c55
1 files changed, 17 insertions, 38 deletions
diff --git a/arch/s390/pci/pci_sysfs.c b/arch/s390/pci/pci_sysfs.c
index ab4a91393005..ebe2c1648fb5 100644
--- a/arch/s390/pci/pci_sysfs.c
+++ b/arch/s390/pci/pci_sysfs.c
@@ -12,43 +12,22 @@
12#include <linux/stat.h> 12#include <linux/stat.h>
13#include <linux/pci.h> 13#include <linux/pci.h>
14 14
15static ssize_t show_fid(struct device *dev, struct device_attribute *attr, 15#define zpci_attr(name, fmt, member) \
16 char *buf) 16static ssize_t name##_show(struct device *dev, \
17{ 17 struct device_attribute *attr, char *buf) \
18 struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); 18{ \
19 19 struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); \
20 return sprintf(buf, "0x%08x\n", zdev->fid); 20 \
21} 21 return sprintf(buf, fmt, zdev->member); \
22static DEVICE_ATTR(function_id, S_IRUGO, show_fid, NULL); 22} \
23 23static DEVICE_ATTR_RO(name)
24static ssize_t show_fh(struct device *dev, struct device_attribute *attr, 24
25 char *buf) 25zpci_attr(function_id, "0x%08x\n", fid);
26{ 26zpci_attr(function_handle, "0x%08x\n", fh);
27 struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); 27zpci_attr(pchid, "0x%04x\n", pchid);
28 28zpci_attr(pfgid, "0x%02x\n", pfgid);
29 return sprintf(buf, "0x%08x\n", zdev->fh); 29
30} 30static ssize_t recover_store(struct device *dev, struct device_attribute *attr,
31static DEVICE_ATTR(function_handle, S_IRUGO, show_fh, NULL);
32
33static ssize_t show_pchid(struct device *dev, struct device_attribute *attr,
34 char *buf)
35{
36 struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
37
38 return sprintf(buf, "0x%04x\n", zdev->pchid);
39}
40static DEVICE_ATTR(pchid, S_IRUGO, show_pchid, NULL);
41
42static ssize_t show_pfgid(struct device *dev, struct device_attribute *attr,
43 char *buf)
44{
45 struct zpci_dev *zdev = get_zdev(to_pci_dev(dev));
46
47 return sprintf(buf, "0x%02x\n", zdev->pfgid);
48}
49static DEVICE_ATTR(pfgid, S_IRUGO, show_pfgid, NULL);
50
51static ssize_t store_recover(struct device *dev, struct device_attribute *attr,
52 const char *buf, size_t count) 31 const char *buf, size_t count)
53{ 32{
54 struct pci_dev *pdev = to_pci_dev(dev); 33 struct pci_dev *pdev = to_pci_dev(dev);
@@ -70,7 +49,7 @@ static ssize_t store_recover(struct device *dev, struct device_attribute *attr,
70 pci_rescan_bus(zdev->bus); 49 pci_rescan_bus(zdev->bus);
71 return count; 50 return count;
72} 51}
73static DEVICE_ATTR(recover, S_IWUSR, NULL, store_recover); 52static DEVICE_ATTR_WO(recover);
74 53
75static struct device_attribute *zpci_dev_attrs[] = { 54static struct device_attribute *zpci_dev_attrs[] = {
76 &dev_attr_function_id, 55 &dev_attr_function_id,