]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
s390/qeth: Make hw_trap sysfs attribute idempotent
authorAswin Karuvally <aswin@linux.ibm.com>
Fri, 18 Jul 2025 14:17:11 +0000 (16:17 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 22 Jul 2025 00:46:13 +0000 (17:46 -0700)
Update qeth driver to allow writing an existing value to the "hw_trap"
sysfs attribute. Attempting such a write earlier resulted in -EINVAL.
In other words, make the sysfs attribute idempotent.

After:
    $ cat hw_trap
    disarm
    $ echo disarm > hw_trap
    $

Suggested-by: Alexandra Winter <wintera@linux.ibm.com>
Signed-off-by: Aswin Karuvally <aswin@linux.ibm.com>
Reviewed-by: Alexandra Winter <wintera@linux.ibm.com>
Signed-off-by: Alexandra Winter <wintera@linux.ibm.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20250718141711.1141049-1-wintera@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/s390/net/qeth_core_sys.c

index eea93f8f106f5fa8b0851107f383f0ff6b72b10e..c0e4883be6d0ba362feeda345f7620ad418155cc 100644 (file)
@@ -518,28 +518,32 @@ static ssize_t qeth_hw_trap_store(struct device *dev,
        if (qeth_card_hw_is_reachable(card))
                state = 1;
 
-       if (sysfs_streq(buf, "arm") && !card->info.hwtrap) {
-               if (state) {
+       if (sysfs_streq(buf, "arm")) {
+               if (state && !card->info.hwtrap) {
                        if (qeth_is_diagass_supported(card,
                            QETH_DIAGS_CMD_TRAP)) {
                                rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM);
                                if (!rc)
                                        card->info.hwtrap = 1;
-                       } else
+                       } else {
                                rc = -EINVAL;
-               } else
+                       }
+               } else {
                        card->info.hwtrap = 1;
-       } else if (sysfs_streq(buf, "disarm") && card->info.hwtrap) {
-               if (state) {
+               }
+       } else if (sysfs_streq(buf, "disarm")) {
+               if (state && card->info.hwtrap) {
                        rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM);
                        if (!rc)
                                card->info.hwtrap = 0;
-               } else
+               } else {
                        card->info.hwtrap = 0;
-       } else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap)
+               }
+       } else if (sysfs_streq(buf, "trap") && state && card->info.hwtrap) {
                rc = qeth_hw_trap(card, QETH_DIAGS_TRAP_CAPTURE);
-       else
+       } else {
                rc = -EINVAL;
+       }
 
        mutex_unlock(&card->conf_mutex);
        return rc ? rc : count;