diff options
author | Harald Freudenberger <freude@linux.ibm.com> | 2020-07-27 15:49:34 +0300 |
---|---|---|
committer | Vasily Gorbik <gor@linux.ibm.com> | 2020-10-07 22:50:01 +0300 |
commit | 5caa2af97118308c79f29cc9876aec3ed504f9b0 (patch) | |
tree | 347518c4f2bfe103deed2365d5f7fa45eb2783f0 /drivers/s390 | |
parent | 0671cc1048744c9a6f1c896baa85966a5abc42a0 (diff) | |
download | linux-5caa2af97118308c79f29cc9876aec3ed504f9b0.tar.xz |
s390/ap: Support AP card SCLP config and deconfig operations
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>
Diffstat (limited to 'drivers/s390')
-rw-r--r-- | drivers/s390/crypto/ap_card.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/drivers/s390/crypto/ap_card.c b/drivers/s390/crypto/ap_card.c index bf1e964b0048..d98bdd28d23e 100644 --- a/drivers/s390/crypto/ap_card.c +++ b/drivers/s390/crypto/ap_card.c @@ -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, |