From: "Cabiddu, Giovanni" <giovanni.cabiddu@intel.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Boris Brezillon <bbrezillon@kernel.org>,
"Arnaud Ebalard" <arno@natisbad.org>,
Srujana Challa <schalla@marvell.com>,
<linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<qat-linux@intel.com>
Subject: Re: [PATCH] crypto: Use str_enable_disable-like helpers
Date: Tue, 14 Jan 2025 11:50:46 +0000 [thread overview]
Message-ID: <Z4ZPlu6iqCFWmWDm@gcabiddu-mobl.ger.corp.intel.com> (raw)
In-Reply-To: <20250114105603.273161-1-krzysztof.kozlowski@linaro.org>
On Tue, Jan 14, 2025 at 11:56:03AM +0100, Krzysztof Kozlowski wrote:
> 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>
For QAT:
Acked-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> ---
> drivers/crypto/bcm/cipher.c | 3 ++-
> drivers/crypto/bcm/spu2.c | 3 ++-
> drivers/crypto/intel/qat/qat_common/adf_sysfs.c | 10 +++-------
> drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c | 5 +++--
> drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c | 3 ++-
> 5 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c
> index 9e6798efbfb7..66accd8e08f6 100644
> --- a/drivers/crypto/bcm/cipher.c
> +++ b/drivers/crypto/bcm/cipher.c
> @@ -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");
> diff --git a/drivers/crypto/bcm/spu2.c b/drivers/crypto/bcm/spu2.c
> index 3fdc64b5a65e..ce322cf1baa5 100644
> --- a/drivers/crypto/bcm/spu2.c
> +++ b/drivers/crypto/bcm/spu2.c
> @@ -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);
> diff --git a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
> index 4fcd61ff70d1..84450bffacb6 100644
> --- a/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
> +++ b/drivers/crypto/intel/qat/qat_common/adf_sysfs.c
> @@ -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,
> diff --git a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c
> index c4250e5fcf8f..2c08e928e44e 100644
> --- a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c
> +++ b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c
> @@ -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",
> diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c
> index 5c9484646172..881fce53e369 100644
> --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c
> +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c
> @@ -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",
> --
> 2.43.0
>
prev parent reply other threads:[~2025-01-14 11:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 10:56 Krzysztof Kozlowski
2025-01-14 11:50 ` Cabiddu, Giovanni [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z4ZPlu6iqCFWmWDm@gcabiddu-mobl.ger.corp.intel.com \
--to=giovanni.cabiddu@intel.com \
--cc=arno@natisbad.org \
--cc=bbrezillon@kernel.org \
--cc=davem@davemloft.net \
--cc=herbert@gondor.apana.org.au \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qat-linux@intel.com \
--cc=schalla@marvell.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®