s390/pci: add report_error attribute
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Fri, 27 Nov 2015 10:22:57 +0000 (11:22 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 15 Apr 2016 16:16:39 +0000 (18:16 +0200)
Provide an report_error attribute to send an adapter-error
notification associated with a PCI function.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/pci/pci_sysfs.c

index f37a580..ed484dc 100644 (file)
@@ -12,6 +12,8 @@
 #include <linux/stat.h>
 #include <linux/pci.h>
 
+#include <asm/sclp.h>
+
 #define zpci_attr(name, fmt, member)                                   \
 static ssize_t name##_show(struct device *dev,                         \
                           struct device_attribute *attr, char *buf)    \
@@ -77,8 +79,29 @@ static ssize_t util_string_read(struct file *filp, struct kobject *kobj,
                                       sizeof(zdev->util_str));
 }
 static BIN_ATTR_RO(util_string, CLP_UTIL_STR_LEN);
+
+static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
+                                 struct bin_attribute *attr, char *buf,
+                                 loff_t off, size_t count)
+{
+       struct zpci_report_error_header *report = (void *) buf;
+       struct device *dev = kobj_to_dev(kobj);
+       struct pci_dev *pdev = to_pci_dev(dev);
+       struct zpci_dev *zdev = to_zpci(pdev);
+       int ret;
+
+       if (off || (count < sizeof(*report)))
+               return -EINVAL;
+
+       ret = sclp_pci_report(report, zdev->fh, zdev->fid);
+
+       return ret ? ret : count;
+}
+static BIN_ATTR(report_error, S_IWUSR, NULL, report_error_write, PAGE_SIZE);
+
 static struct bin_attribute *zpci_bin_attrs[] = {
        &bin_attr_util_string,
+       &bin_attr_report_error,
        NULL,
 };