Skip to content

Commit f0f1fd1

Browse files
krzkherbertx
authored andcommitted
crypto: drivers - Use str_enable_disable-like helpers
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>
1 parent af324dc commit f0f1fd1

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

drivers/crypto/bcm/cipher.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/kthread.h>
1616
#include <linux/rtnetlink.h>
1717
#include <linux/sched.h>
18+
#include <linux/string_choices.h>
1819
#include <linux/of.h>
1920
#include <linux/io.h>
2021
#include <linux/bitops.h>
@@ -2687,7 +2688,7 @@ static int aead_enqueue(struct aead_request *req, bool is_encrypt)
26872688
flow_log(" iv_ctr_len:%u\n", rctx->iv_ctr_len);
26882689
flow_dump(" iv: ", req->iv, rctx->iv_ctr_len);
26892690
flow_log(" authkeylen:%u\n", ctx->authkeylen);
2690-
flow_log(" is_esp: %s\n", ctx->is_esp ? "yes" : "no");
2691+
flow_log(" is_esp: %s\n", str_yes_no(ctx->is_esp));
26912692

26922693
if (ctx->max_payload == SPU_MAX_PAYLOAD_INF)
26932694
flow_log(" max_payload infinite");

drivers/crypto/bcm/spu2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include <linux/kernel.h>
1313
#include <linux/string.h>
14+
#include <linux/string_choices.h>
1415

1516
#include "util.h"
1617
#include "spu.h"
@@ -999,7 +1000,7 @@ u32 spu2_create_request(u8 *spu_hdr,
9991000
req_opts->is_inbound, req_opts->auth_first);
10001001
flow_log(" cipher alg:%u mode:%u type %u\n", cipher_parms->alg,
10011002
cipher_parms->mode, cipher_parms->type);
1002-
flow_log(" is_esp: %s\n", req_opts->is_esp ? "yes" : "no");
1003+
flow_log(" is_esp: %s\n", str_yes_no(req_opts->is_esp));
10031004
flow_log(" key: %d\n", cipher_parms->key_len);
10041005
flow_dump(" key: ", cipher_parms->key_buf, cipher_parms->key_len);
10051006
flow_log(" iv: %d\n", cipher_parms->iv_len);

drivers/crypto/caam/caamalg_qi2.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/dma-mapping.h>
2020
#include <linux/fsl/mc.h>
2121
#include <linux/kernel.h>
22+
#include <linux/string_choices.h>
2223
#include <soc/fsl/dpaa2-io.h>
2324
#include <soc/fsl/dpaa2-fd.h>
2425
#include <crypto/xts.h>
@@ -5175,7 +5176,7 @@ static int __cold dpaa2_dpseci_disable(struct dpaa2_caam_priv *priv)
51755176
return err;
51765177
}
51775178

5178-
dev_dbg(dev, "disable: %s\n", enabled ? "false" : "true");
5179+
dev_dbg(dev, "disable: %s\n", str_false_true(enabled));
51795180

51805181
for (i = 0; i < priv->num_pairs; i++) {
51815182
ppriv = per_cpu_ptr(priv->ppriv, i);

drivers/crypto/intel/qat/qat_common/adf_sysfs.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <linux/device.h>
44
#include <linux/errno.h>
55
#include <linux/pci.h>
6+
#include <linux/string_choices.h>
67
#include "adf_accel_devices.h"
78
#include "adf_cfg.h"
89
#include "adf_cfg_services.h"
@@ -19,14 +20,12 @@ static ssize_t state_show(struct device *dev, struct device_attribute *attr,
1920
char *buf)
2021
{
2122
struct adf_accel_dev *accel_dev;
22-
char *state;
2323

2424
accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
2525
if (!accel_dev)
2626
return -EINVAL;
2727

28-
state = adf_dev_started(accel_dev) ? "up" : "down";
29-
return sysfs_emit(buf, "%s\n", state);
28+
return sysfs_emit(buf, "%s\n", str_up_down(adf_dev_started(accel_dev)));
3029
}
3130

3231
static ssize_t state_store(struct device *dev, struct device_attribute *attr,
@@ -207,16 +206,13 @@ static DEVICE_ATTR_RW(pm_idle_enabled);
207206
static ssize_t auto_reset_show(struct device *dev, struct device_attribute *attr,
208207
char *buf)
209208
{
210-
char *auto_reset;
211209
struct adf_accel_dev *accel_dev;
212210

213211
accel_dev = adf_devmgr_pci_to_accel_dev(to_pci_dev(dev));
214212
if (!accel_dev)
215213
return -EINVAL;
216214

217-
auto_reset = accel_dev->autoreset_on_error ? "on" : "off";
218-
219-
return sysfs_emit(buf, "%s\n", auto_reset);
215+
return sysfs_emit(buf, "%s\n", str_on_off(accel_dev->autoreset_on_error));
220216
}
221217

222218
static ssize_t auto_reset_store(struct device *dev, struct device_attribute *attr,

drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/ctype.h>
1212
#include <linux/firmware.h>
13+
#include <linux/string_choices.h>
1314
#include "otx_cpt_common.h"
1415
#include "otx_cptpf_ucode.h"
1516
#include "otx_cptpf.h"
@@ -614,8 +615,8 @@ static void print_dbg_info(struct device *dev,
614615

615616
for (i = 0; i < OTX_CPT_MAX_ENGINE_GROUPS; i++) {
616617
grp = &eng_grps->grp[i];
617-
pr_debug("engine_group%d, state %s\n", i, grp->is_enabled ?
618-
"enabled" : "disabled");
618+
pr_debug("engine_group%d, state %s\n", i,
619+
str_enabled_disabled(grp->is_enabled));
619620
if (grp->is_enabled) {
620621
mirrored_grp = &eng_grps->grp[grp->mirror.idx];
621622
pr_debug("Ucode0 filename %s, version %s\n",

drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include <linux/ctype.h>
55
#include <linux/firmware.h>
6+
#include <linux/string_choices.h>
67
#include "otx2_cptpf_ucode.h"
78
#include "otx2_cpt_common.h"
89
#include "otx2_cptpf.h"
@@ -1835,7 +1836,7 @@ void otx2_cpt_print_uc_dbg_info(struct otx2_cptpf_dev *cptpf)
18351836
for (i = 0; i < OTX2_CPT_MAX_ENGINE_GROUPS; i++) {
18361837
grp = &eng_grps->grp[i];
18371838
pr_debug("engine_group%d, state %s", i,
1838-
grp->is_enabled ? "enabled" : "disabled");
1839+
str_enabled_disabled(grp->is_enabled));
18391840
if (grp->is_enabled) {
18401841
mirrored_grp = &eng_grps->grp[grp->mirror.idx];
18411842
pr_debug("Ucode0 filename %s, version %s",

0 commit comments

Comments
 (0)