Skip to content

Commit acdbea5

Browse files
krzkVudentz
authored andcommitted
Bluetooth: 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 <[email protected]> Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent a720861 commit acdbea5

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

drivers/bluetooth/btintel.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <linux/module.h>
1010
#include <linux/firmware.h>
1111
#include <linux/regmap.h>
12+
#include <linux/string_choices.h>
1213
#include <linux/acpi.h>
1314
#include <acpi/acpi_bus.h>
1415
#include <linux/unaligned.h>
@@ -506,13 +507,13 @@ int btintel_version_info_tlv(struct hci_dev *hdev,
506507

507508
bt_dev_info(hdev, "Device revision is %u", version->dev_rev_id);
508509
bt_dev_info(hdev, "Secure boot is %s",
509-
version->secure_boot ? "enabled" : "disabled");
510+
str_enabled_disabled(version->secure_boot));
510511
bt_dev_info(hdev, "OTP lock is %s",
511-
version->otp_lock ? "enabled" : "disabled");
512+
str_enabled_disabled(version->otp_lock));
512513
bt_dev_info(hdev, "API lock is %s",
513-
version->api_lock ? "enabled" : "disabled");
514+
str_enabled_disabled(version->api_lock));
514515
bt_dev_info(hdev, "Debug lock is %s",
515-
version->debug_lock ? "enabled" : "disabled");
516+
str_enabled_disabled(version->debug_lock));
516517
bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
517518
version->min_fw_build_nn, version->min_fw_build_cw,
518519
2000 + version->min_fw_build_yy);
@@ -927,16 +928,16 @@ int btintel_read_boot_params(struct hci_dev *hdev,
927928
le16_to_cpu(params->dev_revid));
928929

929930
bt_dev_info(hdev, "Secure boot is %s",
930-
params->secure_boot ? "enabled" : "disabled");
931+
str_enabled_disabled(params->secure_boot));
931932

932933
bt_dev_info(hdev, "OTP lock is %s",
933-
params->otp_lock ? "enabled" : "disabled");
934+
str_enabled_disabled(params->otp_lock));
934935

935936
bt_dev_info(hdev, "API lock is %s",
936-
params->api_lock ? "enabled" : "disabled");
937+
str_enabled_disabled(params->api_lock));
937938

938939
bt_dev_info(hdev, "Debug lock is %s",
939-
params->debug_lock ? "enabled" : "disabled");
940+
str_enabled_disabled(params->debug_lock));
940941

941942
bt_dev_info(hdev, "Minimum firmware build %u week %u %u",
942943
params->min_fw_build_nn, params->min_fw_build_cw,

drivers/bluetooth/btmrvl_main.c

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

88
#include <linux/module.h>
99
#include <linux/of.h>
10+
#include <linux/string_choices.h>
1011
#include <net/bluetooth/bluetooth.h>
1112
#include <net/bluetooth/hci_core.h>
1213
#include <linux/mmc/sdio_func.h>
@@ -88,7 +89,7 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
8889
else
8990
adapter->psmode = 0;
9091
BT_DBG("PS Mode:%s",
91-
(adapter->psmode) ? "Enable" : "Disable");
92+
str_enable_disable(adapter->psmode));
9293
} else {
9394
BT_DBG("PS Mode command failed");
9495
}

drivers/bluetooth/hci_qca.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <linux/pwrseq/consumer.h>
3232
#include <linux/regulator/consumer.h>
3333
#include <linux/serdev.h>
34+
#include <linux/string_choices.h>
3435
#include <linux/mutex.h>
3536
#include <linux/unaligned.h>
3637

@@ -343,8 +344,8 @@ static void serial_clock_vote(unsigned long vote, struct hci_uart *hu)
343344
else
344345
__serial_clock_off(hu->tty);
345346

346-
BT_DBG("Vote serial clock %s(%s)", new_vote ? "true" : "false",
347-
vote ? "true" : "false");
347+
BT_DBG("Vote serial clock %s(%s)", str_true_false(new_vote),
348+
str_true_false(vote));
348349

349350
diff = jiffies_to_msecs(jiffies - qca->vote_last_jif);
350351

0 commit comments

Comments
 (0)