Skip to content

Commit 5b6dc50

Browse files
krzkgregkh
authored andcommitted
USB: gadget: 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 2d913c1 commit 5b6dc50

File tree

11 files changed

+27
-17
lines changed

11 files changed

+27
-17
lines changed

drivers/usb/gadget/function/f_ecm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/module.h>
1414
#include <linux/device.h>
1515
#include <linux/etherdevice.h>
16+
#include <linux/string_choices.h>
1617

1718
#include "u_ether.h"
1819
#include "u_ether_configfs.h"
@@ -387,8 +388,7 @@ static void ecm_do_notify(struct f_ecm *ecm)
387388
event->wLength = 0;
388389
req->length = sizeof *event;
389390

390-
DBG(cdev, "notify connect %s\n",
391-
ecm->is_open ? "true" : "false");
391+
DBG(cdev, "notify connect %s\n", str_true_false(ecm->is_open));
392392
ecm->notify_state = ECM_NOTIFY_SPEED;
393393
break;
394394

drivers/usb/gadget/function/f_ncm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/device.h>
1818
#include <linux/etherdevice.h>
1919
#include <linux/crc32.h>
20+
#include <linux/string_choices.h>
2021

2122
#include <linux/usb/cdc.h>
2223

@@ -558,7 +559,7 @@ static void ncm_do_notify(struct f_ncm *ncm)
558559
req->length = sizeof *event;
559560

560561
DBG(cdev, "notify connect %s\n",
561-
ncm->is_open ? "true" : "false");
562+
str_true_false(ncm->is_open));
562563
ncm->notify_state = NCM_NOTIFY_NONE;
563564
break;
564565

drivers/usb/gadget/function/u_serial.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/tty.h>
2222
#include <linux/tty_flip.h>
2323
#include <linux/slab.h>
24+
#include <linux/string_choices.h>
2425
#include <linux/export.h>
2526
#include <linux/module.h>
2627
#include <linux/console.h>
@@ -1545,7 +1546,7 @@ static int __init userial_init(void)
15451546

15461547
pr_debug("%s: registered %d ttyGS* device%s\n", __func__,
15471548
MAX_U_SERIAL_PORTS,
1548-
(MAX_U_SERIAL_PORTS == 1) ? "" : "s");
1549+
str_plural(MAX_U_SERIAL_PORTS));
15491550

15501551
return status;
15511552
fail:

drivers/usb/gadget/legacy/inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <linux/uaccess.h>
2121
#include <linux/sched.h>
2222
#include <linux/slab.h>
23+
#include <linux/string_choices.h>
2324
#include <linux/poll.h>
2425
#include <linux/kthread.h>
2526
#include <linux/aio.h>
@@ -1182,7 +1183,7 @@ ep0_fasync (int f, struct file *fd, int on)
11821183
{
11831184
struct dev_data *dev = fd->private_data;
11841185
// caller must F_SETOWN before signal delivery happens
1185-
VDEBUG (dev, "%s %s\n", __func__, on ? "on" : "off");
1186+
VDEBUG(dev, "%s %s\n", __func__, str_on_off(on));
11861187
return fasync_helper (f, fd, on, &dev->fasync);
11871188
}
11881189

drivers/usb/gadget/udc/aspeed-vhub/hub.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/usb/gadget.h>
2323
#include <linux/of.h>
2424
#include <linux/regmap.h>
25+
#include <linux/string_choices.h>
2526
#include <linux/dma-mapping.h>
2627
#include <linux/bcd.h>
2728
#include <linux/version.h>
@@ -219,7 +220,7 @@ static int ast_vhub_hub_dev_feature(struct ast_vhub_ep *ep,
219220
if (wValue == USB_DEVICE_REMOTE_WAKEUP) {
220221
ep->vhub->wakeup_en = is_set;
221222
EPDBG(ep, "Hub remote wakeup %s\n",
222-
is_set ? "enabled" : "disabled");
223+
str_enabled_disabled(is_set));
223224
return std_req_complete;
224225
}
225226

drivers/usb/gadget/udc/at91_udc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/delay.h>
1717
#include <linux/ioport.h>
1818
#include <linux/slab.h>
19+
#include <linux/string_choices.h>
1920
#include <linux/errno.h>
2021
#include <linux/list.h>
2122
#include <linux/interrupt.h>
@@ -131,7 +132,7 @@ static void proc_ep_show(struct seq_file *s, struct at91_ep *ep)
131132
seq_printf(s, "csr %08x rxbytes=%d %s %s %s" EIGHTBITS "\n",
132133
csr,
133134
(csr & 0x07ff0000) >> 16,
134-
(csr & (1 << 15)) ? "enabled" : "disabled",
135+
str_enabled_disabled(csr & (1 << 15)),
135136
(csr & (1 << 11)) ? "DATA1" : "DATA0",
136137
types[(csr & 0x700) >> 8],
137138

drivers/usb/gadget/udc/cdns2/cdns2-gadget.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <linux/pm_runtime.h>
3030
#include <linux/interrupt.h>
3131
#include <linux/property.h>
32+
#include <linux/string_choices.h>
3233
#include <linux/dmapool.h>
3334
#include <linux/iopoll.h>
3435

@@ -2233,12 +2234,12 @@ static int cdns2_init_eps(struct cdns2_device *pdev)
22332234
dev_dbg(pdev->dev, "Init %s, SupType: CTRL: %s, INT: %s, "
22342235
"BULK: %s, ISOC %s, SupDir IN: %s, OUT: %s\n",
22352236
pep->name,
2236-
(pep->endpoint.caps.type_control) ? "yes" : "no",
2237-
(pep->endpoint.caps.type_int) ? "yes" : "no",
2238-
(pep->endpoint.caps.type_bulk) ? "yes" : "no",
2239-
(pep->endpoint.caps.type_iso) ? "yes" : "no",
2240-
(pep->endpoint.caps.dir_in) ? "yes" : "no",
2241-
(pep->endpoint.caps.dir_out) ? "yes" : "no");
2237+
str_yes_no(pep->endpoint.caps.type_control),
2238+
str_yes_no(pep->endpoint.caps.type_int),
2239+
str_yes_no(pep->endpoint.caps.type_bulk),
2240+
str_yes_no(pep->endpoint.caps.type_iso),
2241+
str_yes_no(pep->endpoint.caps.dir_in),
2242+
str_yes_no(pep->endpoint.caps.dir_out));
22422243

22432244
INIT_LIST_HEAD(&pep->pending_list);
22442245
INIT_LIST_HEAD(&pep->deferred_list);

drivers/usb/gadget/udc/dummy_hcd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/delay.h>
2929
#include <linux/ioport.h>
3030
#include <linux/slab.h>
31+
#include <linux/string_choices.h>
3132
#include <linux/errno.h>
3233
#include <linux/init.h>
3334
#include <linux/hrtimer.h>
@@ -625,7 +626,7 @@ static int dummy_enable(struct usb_ep *_ep,
625626
desc->bEndpointAddress & 0x0f,
626627
(desc->bEndpointAddress & USB_DIR_IN) ? "in" : "out",
627628
usb_ep_type_string(usb_endpoint_type(desc)),
628-
max, ep->stream_en ? "enabled" : "disabled");
629+
max, str_enabled_disabled(ep->stream_en));
629630

630631
/* at this point real hardware should be NAKing transfers
631632
* to that endpoint, until a buffer is queued to it.

drivers/usb/gadget/udc/fsl_udc_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/errno.h>
2323
#include <linux/err.h>
2424
#include <linux/slab.h>
25+
#include <linux/string_choices.h>
2526
#include <linux/init.h>
2627
#include <linux/list.h>
2728
#include <linux/interrupt.h>
@@ -1181,7 +1182,7 @@ static int fsl_vbus_session(struct usb_gadget *gadget, int is_active)
11811182

11821183
udc = container_of(gadget, struct fsl_udc, gadget);
11831184
spin_lock_irqsave(&udc->lock, flags);
1184-
dev_vdbg(&gadget->dev, "VBUS %s\n", is_active ? "on" : "off");
1185+
dev_vdbg(&gadget->dev, "VBUS %s\n", str_on_off(is_active));
11851186
udc->vbus_active = (is_active != 0);
11861187
if (can_pullup(udc))
11871188
fsl_writel((fsl_readl(&dr_regs->usbcmd) | USB_CMD_RUN_STOP),

drivers/usb/gadget/udc/omap_udc.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/errno.h>
1919
#include <linux/delay.h>
2020
#include <linux/slab.h>
21+
#include <linux/string_choices.h>
2122
#include <linux/timer.h>
2223
#include <linux/list.h>
2324
#include <linux/interrupt.h>
@@ -1252,7 +1253,7 @@ static int omap_vbus_session(struct usb_gadget *gadget, int is_active)
12521253

12531254
udc = container_of(gadget, struct omap_udc, gadget);
12541255
spin_lock_irqsave(&udc->lock, flags);
1255-
VDBG("VBUS %s\n", is_active ? "on" : "off");
1256+
VDBG("VBUS %s\n", str_on_off(is_active));
12561257
udc->vbus_active = (is_active != 0);
12571258
if (cpu_is_omap15xx()) {
12581259
/* "software" detect, ignored if !VBUS_MODE_1510 */

0 commit comments

Comments
 (0)