Skip to content

Commit 789a171

Browse files
krzkgregkh
authored andcommitted
USB: host: 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]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent bd69354 commit 789a171

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

drivers/usb/host/oxu210hp-hcd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/ioport.h>
1616
#include <linux/sched.h>
1717
#include <linux/slab.h>
18+
#include <linux/string_choices.h>
1819
#include <linux/errno.h>
1920
#include <linux/timer.h>
2021
#include <linux/list.h>
@@ -2756,7 +2757,7 @@ static void ehci_port_power(struct oxu_hcd *oxu, int is_on)
27562757
if (!HCS_PPC(oxu->hcs_params))
27572758
return;
27582759

2759-
oxu_dbg(oxu, "...power%s ports...\n", is_on ? "up" : "down");
2760+
oxu_dbg(oxu, "...power%s ports...\n", str_up_down(is_on));
27602761
for (port = HCS_N_PORTS(oxu->hcs_params); port > 0; ) {
27612762
if (is_on)
27622763
oxu_hub_control(oxu_to_hcd(oxu), SetPortFeature,

drivers/usb/host/sl811-hcd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include <linux/usb/hcd.h>
4949
#include <linux/platform_device.h>
5050
#include <linux/prefetch.h>
51+
#include <linux/string_choices.h>
5152
#include <linux/debugfs.h>
5253
#include <linux/seq_file.h>
5354

@@ -98,7 +99,7 @@ static void port_power(struct sl811 *sl811, int is_on)
9899
if (sl811->board && sl811->board->port_power) {
99100
/* switch VBUS, at 500mA unless hub power budget gets set */
100101
dev_dbg(hcd->self.controller, "power %s\n",
101-
is_on ? "on" : "off");
102+
str_on_off(is_on));
102103
sl811->board->port_power(hcd->self.controller, is_on);
103104
}
104105

drivers/usb/host/xhci-ring.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <linux/jiffies.h>
5656
#include <linux/scatterlist.h>
5757
#include <linux/slab.h>
58+
#include <linux/string_choices.h>
5859
#include <linux/dma-mapping.h>
5960
#include "xhci.h"
6061
#include "xhci-trace.h"
@@ -3441,8 +3442,8 @@ static void check_interval(struct urb *urb, struct xhci_ep_ctx *ep_ctx)
34413442
if (xhci_interval != ep_interval) {
34423443
dev_dbg_ratelimited(&urb->dev->dev,
34433444
"Driver uses different interval (%d microframe%s) than xHCI (%d microframe%s)\n",
3444-
ep_interval, ep_interval == 1 ? "" : "s",
3445-
xhci_interval, xhci_interval == 1 ? "" : "s");
3445+
ep_interval, str_plural(ep_interval),
3446+
xhci_interval, str_plural(xhci_interval));
34463447
urb->interval = xhci_interval;
34473448
/* Convert back to frames for LS/FS devices */
34483449
if (urb->dev->speed == USB_SPEED_LOW ||

drivers/usb/host/xhci-tegra.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/regulator/consumer.h>
2727
#include <linux/reset.h>
2828
#include <linux/slab.h>
29+
#include <linux/string_choices.h>
2930
#include <linux/usb/otg.h>
3031
#include <linux/usb/phy.h>
3132
#include <linux/usb/role.h>
@@ -724,7 +725,7 @@ static void tegra_xusb_mbox_handle(struct tegra_xusb *tegra,
724725
if (err < 0) {
725726
dev_err(dev,
726727
"failed to %s LFPS detection on USB3#%u: %d\n",
727-
enable ? "enable" : "disable", port, err);
728+
str_enable_disable(enable), port, err);
728729
rsp.cmd = MBOX_CMD_NAK;
729730
} else {
730731
rsp.cmd = MBOX_CMD_ACK;
@@ -1349,7 +1350,7 @@ static void tegra_xhci_id_work(struct work_struct *work)
13491350
u32 status;
13501351
int ret;
13511352

1352-
dev_dbg(tegra->dev, "host mode %s\n", tegra->host_mode ? "on" : "off");
1353+
dev_dbg(tegra->dev, "host mode %s\n", str_on_off(tegra->host_mode));
13531354

13541355
mutex_lock(&tegra->lock);
13551356

drivers/usb/host/xhci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/module.h>
1818
#include <linux/moduleparam.h>
1919
#include <linux/slab.h>
20+
#include <linux/string_choices.h>
2021
#include <linux/dmi.h>
2122
#include <linux/dma-mapping.h>
2223

@@ -4523,7 +4524,7 @@ static int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
45234524
hlpm_addr = ports[port_num]->addr + PORTHLPMC;
45244525

45254526
xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n",
4526-
enable ? "enable" : "disable", port_num + 1);
4527+
str_enable_disable(enable), port_num + 1);
45274528

45284529
if (enable) {
45294530
/* Host supports BESL timeout instead of HIRD */

0 commit comments

Comments
 (0)