Skip to content

Commit 2d913c1

Browse files
krzkgregkh
authored andcommitted
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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 13b3af2 commit 2d913c1

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

drivers/usb/phy/phy-fsl-usb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/kernel.h>
1313
#include <linux/delay.h>
1414
#include <linux/slab.h>
15+
#include <linux/string_choices.h>
1516
#include <linux/proc_fs.h>
1617
#include <linux/errno.h>
1718
#include <linux/interrupt.h>
@@ -529,7 +530,7 @@ int fsl_otg_start_gadget(struct otg_fsm *fsm, int on)
529530
if (!otg->gadget || !otg->gadget->dev.parent)
530531
return -ENODEV;
531532

532-
VDBG("gadget %s\n", on ? "on" : "off");
533+
VDBG("gadget %s\n", str_on_off(on));
533534
dev = otg->gadget->dev.parent;
534535

535536
if (on) {

drivers/usb/phy/phy-mv-usb.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/clk.h>
1616
#include <linux/workqueue.h>
1717
#include <linux/platform_device.h>
18+
#include <linux/string_choices.h>
1819

1920
#include <linux/usb.h>
2021
#include <linux/usb/ch9.h>
@@ -217,7 +218,7 @@ static void mv_otg_start_periphrals(struct mv_otg *mvotg, int on)
217218
if (!otg->gadget)
218219
return;
219220

220-
dev_info(mvotg->phy.dev, "gadget %s\n", on ? "on" : "off");
221+
dev_info(mvotg->phy.dev, "gadget %s\n", str_on_off(on));
221222

222223
if (on)
223224
usb_gadget_vbus_connect(otg->gadget);

drivers/usb/phy/phy-tahvo.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/extcon-provider.h>
1919
#include <linux/kernel.h>
2020
#include <linux/module.h>
21+
#include <linux/string_choices.h>
2122
#include <linux/usb/otg.h>
2223
#include <linux/mfd/retu.h>
2324
#include <linux/usb/gadget.h>
@@ -63,7 +64,7 @@ static ssize_t vbus_show(struct device *device,
6364
struct device_attribute *attr, char *buf)
6465
{
6566
struct tahvo_usb *tu = dev_get_drvdata(device);
66-
return sprintf(buf, "%s\n", tu->vbus_state ? "on" : "off");
67+
return sprintf(buf, "%s\n", str_on_off(tu->vbus_state));
6768
}
6869
static DEVICE_ATTR_RO(vbus);
6970

0 commit comments

Comments
 (0)