]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
crypto: drivers - Use str_enable_disable-like helpers
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 14 Jan 2025 19:05:01 +0000 (20:05 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 9 Feb 2025 10:08:11 +0000 (18:08 +0800)
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read.  Ternary
   operator has three arguments and with wrapping might lead to quite
   long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
   file.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com> # QAT
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/bcm/cipher.c
drivers/crypto/bcm/spu2.c
drivers/crypto/caam/caamalg_qi2.c
drivers/crypto/intel/qat/qat_common/adf_sysfs.c
drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c
drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c

index 9e6798efbfb769676b9026e168e246f6d5fb5071..66accd8e08f626b08dd045e5af48d2d44e21c803 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/kthread.h>
 #include <linux/rtnetlink.h>
 #include <linux/sched.h>
+#include <linux/string_choices.h>
 #include <linux/of.h>
 #include <linux/io.h>
 #include <linux/bitops.h>
@@ -2687,7 +2688,7 @@ static int aead_enqueue(struct aead_request *req, bool is_encrypt)
        flow_log("  iv_ctr_len:%u\n", rctx->iv_ctr_len);
        flow_dump("  iv: ", req->iv, rctx->iv_ctr_len);
        flow_log("  authkeylen:%u\n", ctx->authkeylen);
-       flow_log("  is_esp: %s\n", ctx->is_esp ? "yes" : "no");
+       flow_log("  is_esp: %s\n", str_yes_no(ctx->is_esp));
 
        if (ctx->max_payload == SPU_MAX_PAYLOAD_INF)
                flow_log("  max_payload infinite");
index 3fdc64b5a65e7e9d27ac9d274f55e3d15f2b6822..ce322cf1baa5e0ccf3a68b8fca4c94bd6d9d7fd1 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <linux/kernel.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 
 #include "util.h"
 #include "spu.h"
@@ -999,7 +1000,7 @@ u32 spu2_create_request(u8 *spu_hdr,
                 req_opts->is_inbound, req_opts->auth_first);
        flow_log("  cipher alg:%u mode:%u type %u\n", cipher_parms->alg,
                 cipher_parms->mode, cipher_parms->type);
-       flow_log("  is_esp: %s\n", req_opts->is_esp ? "yes" : "no");
+       flow_log("  is_esp: %s\n", str_yes_no(req_opts->is_esp));
        flow_log("    key: %d\n", cipher_parms->key_len);
        flow_dump("    key: ", cipher_parms->key_buf, cipher_parms->key_len);
        flow_log("    iv: %d\n", cipher_parms->iv_len);
index e809d030ab1135ad43887a99c0e115f58ae9f7b1..107ccb2ade4205cb841eaf505ca7c70b5192b844 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/dma-mapping.h>
 #include <linux/fsl/mc.h>
 #include <linux/kernel.h>
+#include <linux/string_choices.h>
 #include <soc/fsl/dpaa2-io.h>
 #include <soc/fsl/dpaa2-fd.h>
 #include <crypto/xts.h>
@@ -5175,7 +5176,7 @@ static int __cold dpaa2_dpseci_disable(struct dpaa2_caam_priv *priv)
                return err;
        }
 
-       dev_dbg(dev, "disable: %s\n", enabled ? "false" : "true");
+       dev_dbg(dev, "disable: %s\n", str_false_true(enabled));
 
        for (i = 0; i < priv->num_pairs; i++) {
                ppriv = per_cpu_ptr(priv->ppriv, i);
index 4fcd61ff70d129e5a3d7ed3b785a7f6ea9169c3f..84450bffacb6d2eb14b73cfa44b0ddbf419dabc4 100644 (file)
@@ -3,6 +3,7 @@
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/pci.h>
+#include <linux/string_choices.h>
 #include "adf_accel_devices.h"
 #include "adf_cfg.h"
 #include "adf_cfg_services.h"
@@ -19,14 +20,12 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
                          char *buf)
 {
        struct adf_accel_dev *accel_dev;
-       char *state;
 
        accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
        if (!accel_dev)
                return -EINVAL;
 
-       state = adf_dev_started(accel_dev) ? "up" : "down";
-       return sysfs_emit(buf, "%s\n", state);
+       return sysfs_emit(buf, "%s\n", str_up_down(adf_dev_started(accel_dev)));
 }
 
 static ssize_t state_store(struct device *dev, struct device_attribute *attr,
@@ -207,16 +206,13 @@ static DEVICE_ATTR_RW(pm_idle_enabled);
 static ssize_t auto_reset_show(struct device *dev, struct device_attribute *attr,
                               char *buf)
 {
-       char *auto_reset;
        struct adf_accel_dev *accel_dev;
 
        accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
        if (!accel_dev)
                return -EINVAL;
 
-       auto_reset = accel_dev->autoreset_on_error ? "on" : "off";
-
-       return sysfs_emit(buf, "%s\n", auto_reset);
+       return sysfs_emit(buf, "%s\n", str_on_off(accel_dev->autoreset_on_error));
 }
 
 static ssize_t auto_reset_store(struct device *dev, struct device_attribute *attr,
index c4250e5fcf8f7bad435bbc6ffbd7138eebb39750..2c08e928e44ebc7968a736f73b709938dc4e73c4 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/ctype.h>
 #include <linux/firmware.h>
+#include <linux/string_choices.h>
 #include "otx_cpt_common.h"
 #include "otx_cptpf_ucode.h"
 #include "otx_cptpf.h"
@@ -614,8 +615,8 @@ static void print_dbg_info(struct device *dev,
 
        for (i = 0; i < OTX_CPT_MAX_ENGINE_GROUPS; i++) {
                grp = &eng_grps->grp[i];
-               pr_debug("engine_group%d, state %s\n", i, grp->is_enabled ?
-                        "enabled" : "disabled");
+               pr_debug("engine_group%d, state %s\n", i,
+                        str_enabled_disabled(grp->is_enabled));
                if (grp->is_enabled) {
                        mirrored_grp = &eng_grps->grp[grp->mirror.idx];
                        pr_debug("Ucode0 filename %s, version %s\n",
index 5c94846461725d4e4f56dbeb32b71f53a1acfc5c..881fce53e3692474d7f25a6fc4b5827aa33caf37 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <linux/ctype.h>
 #include <linux/firmware.h>
+#include <linux/string_choices.h>
 #include "otx2_cptpf_ucode.h"
 #include "otx2_cpt_common.h"
 #include "otx2_cptpf.h"
@@ -1835,7 +1836,7 @@ void otx2_cpt_print_uc_dbg_info(struct otx2_cptpf_dev *cptpf)
        for (i = 0; i < OTX2_CPT_MAX_ENGINE_GROUPS; i++) {
                grp = &eng_grps->grp[i];
                pr_debug("engine_group%d, state %s", i,
-                        grp->is_enabled ? "enabled" : "disabled");
+                        str_enabled_disabled(grp->is_enabled));
                if (grp->is_enabled) {
                        mirrored_grp = &eng_grps->grp[grp->mirror.idx];
                        pr_debug("Ucode0 filename %s, version %s",