Merge branch 'stable/for-jens-4.3' of git://git.kernel.org/pub/scm/linux/kernel/git...
[firefly-linux-kernel-4.4.55.git] / drivers / misc / cxl / sysfs.c
index 87cd747bb511c83f000023d4b1fc49714d3df598..25868c2ec03ea76287a8681b7d229cc7f223c8cc 100644 (file)
@@ -112,12 +112,38 @@ static ssize_t load_image_on_perst_store(struct device *device,
        return count;
 }
 
+static ssize_t perst_reloads_same_image_show(struct device *device,
+                                struct device_attribute *attr,
+                                char *buf)
+{
+       struct cxl *adapter = to_cxl_adapter(device);
+
+       return scnprintf(buf, PAGE_SIZE, "%i\n", adapter->perst_same_image);
+}
+
+static ssize_t perst_reloads_same_image_store(struct device *device,
+                                struct device_attribute *attr,
+                                const char *buf, size_t count)
+{
+       struct cxl *adapter = to_cxl_adapter(device);
+       int rc;
+       int val;
+
+       rc = sscanf(buf, "%i", &val);
+       if ((rc != 1) || !(val == 1 || val == 0))
+               return -EINVAL;
+
+       adapter->perst_same_image = (val == 1 ? true : false);
+       return count;
+}
+
 static struct device_attribute adapter_attrs[] = {
        __ATTR_RO(caia_version),
        __ATTR_RO(psl_revision),
        __ATTR_RO(base_image),
        __ATTR_RO(image_loaded),
        __ATTR_RW(load_image_on_perst),
+       __ATTR_RW(perst_reloads_same_image),
        __ATTR(reset, S_IWUSR, NULL, reset_adapter_store),
 };