Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20250114-str-enable-disable-usb-v1-2-c8405df47c19@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Krzysztof Kozlowski and committed by
Greg Kroah-Hartman
789a1714 bd693544

+12 -7
+2 -1
drivers/usb/host/oxu210hp-hcd.c
··· 15 15 #include <linux/ioport.h> 16 16 #include <linux/sched.h> 17 17 #include <linux/slab.h> 18 + #include <linux/string_choices.h> 18 19 #include <linux/errno.h> 19 20 #include <linux/timer.h> 20 21 #include <linux/list.h> ··· 2757 2756 if (!HCS_PPC(oxu->hcs_params)) 2758 2757 return; 2759 2758 2760 - oxu_dbg(oxu, "...power%s ports...\n", is_on ? "up" : "down"); 2759 + oxu_dbg(oxu, "...power%s ports...\n", str_up_down(is_on)); 2761 2760 for (port = HCS_N_PORTS(oxu->hcs_params); port > 0; ) { 2762 2761 if (is_on) 2763 2762 oxu_hub_control(oxu_to_hcd(oxu), SetPortFeature,
+2 -1
drivers/usb/host/sl811-hcd.c
··· 48 48 #include <linux/usb/hcd.h> 49 49 #include <linux/platform_device.h> 50 50 #include <linux/prefetch.h> 51 + #include <linux/string_choices.h> 51 52 #include <linux/debugfs.h> 52 53 #include <linux/seq_file.h> 53 54 ··· 99 98 if (sl811->board && sl811->board->port_power) { 100 99 /* switch VBUS, at 500mA unless hub power budget gets set */ 101 100 dev_dbg(hcd->self.controller, "power %s\n", 102 - is_on ? "on" : "off"); 101 + str_on_off(is_on)); 103 102 sl811->board->port_power(hcd->self.controller, is_on); 104 103 } 105 104
+3 -2
drivers/usb/host/xhci-ring.c
··· 55 55 #include <linux/jiffies.h> 56 56 #include <linux/scatterlist.h> 57 57 #include <linux/slab.h> 58 + #include <linux/string_choices.h> 58 59 #include <linux/dma-mapping.h> 59 60 #include "xhci.h" 60 61 #include "xhci-trace.h" ··· 3442 3441 if (xhci_interval != ep_interval) { 3443 3442 dev_dbg_ratelimited(&urb->dev->dev, 3444 3443 "Driver uses different interval (%d microframe%s) than xHCI (%d microframe%s)\n", 3445 - ep_interval, ep_interval == 1 ? "" : "s", 3446 - xhci_interval, xhci_interval == 1 ? "" : "s"); 3444 + ep_interval, str_plural(ep_interval), 3445 + xhci_interval, str_plural(xhci_interval)); 3447 3446 urb->interval = xhci_interval; 3448 3447 /* Convert back to frames for LS/FS devices */ 3449 3448 if (urb->dev->speed == USB_SPEED_LOW ||
+3 -2
drivers/usb/host/xhci-tegra.c
··· 26 26 #include <linux/regulator/consumer.h> 27 27 #include <linux/reset.h> 28 28 #include <linux/slab.h> 29 + #include <linux/string_choices.h> 29 30 #include <linux/usb/otg.h> 30 31 #include <linux/usb/phy.h> 31 32 #include <linux/usb/role.h> ··· 725 724 if (err < 0) { 726 725 dev_err(dev, 727 726 "failed to %s LFPS detection on USB3#%u: %d\n", 728 - enable ? "enable" : "disable", port, err); 727 + str_enable_disable(enable), port, err); 729 728 rsp.cmd = MBOX_CMD_NAK; 730 729 } else { 731 730 rsp.cmd = MBOX_CMD_ACK; ··· 1350 1349 u32 status; 1351 1350 int ret; 1352 1351 1353 - dev_dbg(tegra->dev, "host mode %s\n", tegra->host_mode ? "on" : "off"); 1352 + dev_dbg(tegra->dev, "host mode %s\n", str_on_off(tegra->host_mode)); 1354 1353 1355 1354 mutex_lock(&tegra->lock); 1356 1355
+2 -1
drivers/usb/host/xhci.c
··· 17 17 #include <linux/module.h> 18 18 #include <linux/moduleparam.h> 19 19 #include <linux/slab.h> 20 + #include <linux/string_choices.h> 20 21 #include <linux/dmi.h> 21 22 #include <linux/dma-mapping.h> 22 23 ··· 4524 4523 hlpm_addr = ports[port_num]->addr + PORTHLPMC; 4525 4524 4526 4525 xhci_dbg(xhci, "%s port %d USB2 hardware LPM\n", 4527 - enable ? "enable" : "disable", port_num + 1); 4526 + str_enable_disable(enable), port_num + 1); 4528 4527 4529 4528 if (enable) { 4530 4529 /* Host supports BESL timeout instead of HIRD */