s390/ap: Support AP card SCLP config and deconfig operations
authorHarald Freudenberger <freude@linux.ibm.com>
Mon, 27 Jul 2020 12:49:34 +0000 (14:49 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Wed, 7 Oct 2020 19:50:01 +0000 (21:50 +0200)
Support SCLP AP adapter config and deconfig operations:
The sysfs deconfig attribute /sys/devices/ap/cardxx/deconfig
for each AP card is now read-write. Writing in a '1' triggers
a synchronous SCLP request to configure the adapter, writing
in a '0' sends a synchronous SCLP deconfigure request.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
drivers/s390/crypto/ap_card.c

index bf1e964b00484a69c489d8f5d5fd9c90bf093957..d98bdd28d23edd6417171e822c4c91a6282d3cc5 100644 (file)
@@ -12,6 +12,7 @@
 #include <linux/init.h>
 #include <linux/slab.h>
 #include <asm/facility.h>
+#include <asm/sclp.h>
 
 #include "ap_bus.h"
 
@@ -147,7 +148,29 @@ static ssize_t config_show(struct device *dev,
        return scnprintf(buf, PAGE_SIZE, "%d\n", ac->config ? 1 : 0);
 }
 
-static DEVICE_ATTR_RO(config);
+static ssize_t config_store(struct device *dev,
+                           struct device_attribute *attr,
+                           const char *buf, size_t count)
+{
+       int rc = 0, cfg;
+       struct ap_card *ac = to_ap_card(dev);
+
+       if (sscanf(buf, "%d\n", &cfg) != 1 || cfg < 0 || cfg > 1)
+               return -EINVAL;
+
+       if (cfg && !ac->config)
+               rc = sclp_ap_configure(ac->id);
+       else if (!cfg && ac->config)
+               rc = sclp_ap_deconfigure(ac->id);
+       if (rc)
+               return rc;
+
+       ac->config = cfg ? true : false;
+
+       return count;
+}
+
+static DEVICE_ATTR_RW(config);
 
 static struct attribute *ap_card_dev_attrs[] = {
        &dev_attr_hwtype.attr,