diff options
author | Sebastian Ott <sebott@linux.vnet.ibm.com> | 2014-04-16 10:10:18 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2014-05-20 02:58:48 -0400 |
commit | b346953ddac0d57d4852ddc2b5cd9e16c84ddd59 (patch) | |
tree | ab7011926812db2349f0bc2d78d1a4529019267e /arch/s390/pci | |
parent | ca25f564c484b4f32eec1e667926dcf87ec03234 (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.c | 55 |
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 | ||
15 | static ssize_t show_fid(struct device *dev, struct device_attribute *attr, | 15 | #define zpci_attr(name, fmt, member) \ |
16 | char *buf) | 16 | static 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); \ |
22 | static DEVICE_ATTR(function_id, S_IRUGO, show_fid, NULL); | 22 | } \ |
23 | 23 | static DEVICE_ATTR_RO(name) | |
24 | static ssize_t show_fh(struct device *dev, struct device_attribute *attr, | 24 | |
25 | char *buf) | 25 | zpci_attr(function_id, "0x%08x\n", fid); |
26 | { | 26 | zpci_attr(function_handle, "0x%08x\n", fh); |
27 | struct zpci_dev *zdev = get_zdev(to_pci_dev(dev)); | 27 | zpci_attr(pchid, "0x%04x\n", pchid); |
28 | 28 | zpci_attr(pfgid, "0x%02x\n", pfgid); | |
29 | return sprintf(buf, "0x%08x\n", zdev->fh); | 29 | |
30 | } | 30 | static ssize_t recover_store(struct device *dev, struct device_attribute *attr, |
31 | static DEVICE_ATTR(function_handle, S_IRUGO, show_fh, NULL); | ||
32 | |||
33 | static 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 | } | ||
40 | static DEVICE_ATTR(pchid, S_IRUGO, show_pchid, NULL); | ||
41 | |||
42 | static 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 | } | ||
49 | static DEVICE_ATTR(pfgid, S_IRUGO, show_pfgid, NULL); | ||
50 | |||
51 | static 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 | } |
73 | static DEVICE_ATTR(recover, S_IWUSR, NULL, store_recover); | 52 | static DEVICE_ATTR_WO(recover); |
74 | 53 | ||
75 | static struct device_attribute *zpci_dev_attrs[] = { | 54 | static struct device_attribute *zpci_dev_attrs[] = { |
76 | &dev_attr_function_id, | 55 | &dev_attr_function_id, |