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

USB: phy: 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-4-c8405df47c19@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Krzysztof Kozlowski and committed by
Greg Kroah-Hartman
2d913c1b 13b3af26

+6 -3
+2 -1
drivers/usb/phy/phy-fsl-usb.c
··· 12 12 #include <linux/kernel.h> 13 13 #include <linux/delay.h> 14 14 #include <linux/slab.h> 15 + #include <linux/string_choices.h> 15 16 #include <linux/proc_fs.h> 16 17 #include <linux/errno.h> 17 18 #include <linux/interrupt.h> ··· 530 529 if (!otg->gadget || !otg->gadget->dev.parent) 531 530 return -ENODEV; 532 531 533 - VDBG("gadget %s\n", on ? "on" : "off"); 532 + VDBG("gadget %s\n", str_on_off(on)); 534 533 dev = otg->gadget->dev.parent; 535 534 536 535 if (on) {
+2 -1
drivers/usb/phy/phy-mv-usb.c
··· 15 15 #include <linux/clk.h> 16 16 #include <linux/workqueue.h> 17 17 #include <linux/platform_device.h> 18 + #include <linux/string_choices.h> 18 19 19 20 #include <linux/usb.h> 20 21 #include <linux/usb/ch9.h> ··· 218 217 if (!otg->gadget) 219 218 return; 220 219 221 - dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off"); 220 + dev_info(mvotg->phy.dev, "gadget %s\n", str_on_off(on)); 222 221 223 222 if (on) 224 223 usb_gadget_vbus_connect(otg->gadget);
+2 -1
drivers/usb/phy/phy-tahvo.c
··· 18 18 #include <linux/extcon-provider.h> 19 19 #include <linux/kernel.h> 20 20 #include <linux/module.h> 21 + #include <linux/string_choices.h> 21 22 #include <linux/usb/otg.h> 22 23 #include <linux/mfd/retu.h> 23 24 #include <linux/usb/gadget.h> ··· 64 63 struct device_attribute *attr, char *buf) 65 64 { 66 65 struct tahvo_usb *tu = dev_get_drvdata(device); 67 - return sprintf(buf, "%s\n", tu->vbus_state ? "on" : "off"); 66 + return sprintf(buf, "%s\n", str_on_off(tu->vbus_state)); 68 67 } 69 68 static DEVICE_ATTR_RO(vbus); 70 69