2 * Copyright IBM Corp. 2012
5 * Jan Glauber <jang@linux.vnet.ibm.com>
8 #define COMPONENT "zPCI"
9 #define pr_fmt(fmt) COMPONENT ": " fmt
11 #include <linux/kernel.h>
12 #include <linux/stat.h>
13 #include <linux/pci.h>
15 static ssize_t show_fid(struct device *dev, struct device_attribute *attr,
18 struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
20 sprintf(buf, "0x%08x\n", zdev->fid);
23 static DEVICE_ATTR(function_id, S_IRUGO, show_fid, NULL);
25 static ssize_t show_fh(struct device *dev, struct device_attribute *attr,
28 struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
30 sprintf(buf, "0x%08x\n", zdev->fh);
33 static DEVICE_ATTR(function_handle, S_IRUGO, show_fh, NULL);
35 static ssize_t show_pchid(struct device *dev, struct device_attribute *attr,
38 struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
40 sprintf(buf, "0x%04x\n", zdev->pchid);
43 static DEVICE_ATTR(pchid, S_IRUGO, show_pchid, NULL);
45 static ssize_t show_pfgid(struct device *dev, struct device_attribute *attr,
48 struct zpci_dev *zdev = get_zdev(container_of(dev, struct pci_dev, dev));
50 sprintf(buf, "0x%02x\n", zdev->pfgid);
53 static DEVICE_ATTR(pfgid, S_IRUGO, show_pfgid, NULL);
55 static struct device_attribute *zpci_dev_attrs[] = {
56 &dev_attr_function_id,
57 &dev_attr_function_handle,
63 int zpci_sysfs_add_device(struct device *dev)
67 for (i = 0; zpci_dev_attrs[i]; i++) {
68 rc = device_create_file(dev, zpci_dev_attrs[i]);
76 device_remove_file(dev, zpci_dev_attrs[i]);
80 void zpci_sysfs_remove_device(struct device *dev)
84 for (i = 0; zpci_dev_attrs[i]; i++)
85 device_remove_file(dev, zpci_dev_attrs[i]);