summaryrefslogtreecommitdiff
path: root/drivers/usb/gadget/f_uac2.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2012-10-23 00:15:10 +0400
committerFelipe Balbi <balbi@ti.com>2012-10-31 17:11:47 +0400
commit1616e99d42a8b427b8dcada347ef0ee0df1a1b7b (patch)
tree2753f0d18e9458c126460a731b309df9e10bb17c /drivers/usb/gadget/f_uac2.c
parentb36c347966160ecfe420cd47a5a1f81ddaffc007 (diff)
downloadlinux-1616e99d42a8b427b8dcada347ef0ee0df1a1b7b.tar.xz
usb: gadget: let f_* use usb_string_ids_tab() where it makes sense
Instead of calling usb_string_id() multiple times I replace it with one usb_string_ids_tab(). The NULL pointer in struct usb_string with "" and are not overwritten in fail or unbind case. The conditional assignment remains because some gadgets recycle the string ID because the same descriptor (and string ID) is used if we have more than one config descriptor. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Felipe Balbi <balbi@ti.com>
Diffstat (limited to 'drivers/usb/gadget/f_uac2.c')
-rw-r--r--drivers/usb/gadget/f_uac2.c100
1 files changed, 16 insertions, 84 deletions
diff --git a/drivers/usb/gadget/f_uac2.c b/drivers/usb/gadget/f_uac2.c
index 2840f1819065..91396a1683eb 100644
--- a/drivers/usb/gadget/f_uac2.c
+++ b/drivers/usb/gadget/f_uac2.c
@@ -1312,7 +1312,7 @@ afunc_setup(struct usb_function *fn, const struct usb_ctrlrequest *cr)
static int audio_bind_config(struct usb_configuration *cfg)
{
- int id, res;
+ int res;
agdev_g = kzalloc(sizeof *agdev_g, GFP_KERNEL);
if (agdev_g == NULL) {
@@ -1320,89 +1320,21 @@ static int audio_bind_config(struct usb_configuration *cfg)
return -ENOMEM;
}
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_ASSOC].id = id;
- iad_desc.iFunction = id,
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_IF_CTRL].id = id;
- std_ac_if_desc.iInterface = id,
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_CLKSRC_IN].id = id;
- in_clk_src_desc.iClockSource = id,
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_CLKSRC_OUT].id = id;
- out_clk_src_desc.iClockSource = id,
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_USB_IT].id = id;
- usb_out_it_desc.iTerminal = id,
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_IO_IT].id = id;
- io_in_it_desc.iTerminal = id;
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_USB_OT].id = id;
- usb_in_ot_desc.iTerminal = id;
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_IO_OT].id = id;
- io_out_ot_desc.iTerminal = id;
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_AS_OUT_ALT0].id = id;
- std_as_out_if0_desc.iInterface = id;
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_AS_OUT_ALT1].id = id;
- std_as_out_if1_desc.iInterface = id;
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_AS_IN_ALT0].id = id;
- std_as_in_if0_desc.iInterface = id;
-
- id = usb_string_id(cfg->cdev);
- if (id < 0)
- return id;
-
- strings_fn[STR_AS_IN_ALT1].id = id;
- std_as_in_if1_desc.iInterface = id;
+ res = usb_string_ids_tab(cfg->cdev, strings_fn);
+ if (res)
+ return res;
+ iad_desc.iFunction = strings_fn[STR_ASSOC].id;
+ std_ac_if_desc.iInterface = strings_fn[STR_IF_CTRL].id;
+ in_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_IN].id;
+ out_clk_src_desc.iClockSource = strings_fn[STR_CLKSRC_OUT].id;
+ usb_out_it_desc.iTerminal = strings_fn[STR_USB_IT].id;
+ io_in_it_desc.iTerminal = strings_fn[STR_IO_IT].id;
+ usb_in_ot_desc.iTerminal = strings_fn[STR_USB_OT].id;
+ io_out_ot_desc.iTerminal = strings_fn[STR_IO_OT].id;
+ std_as_out_if0_desc.iInterface = strings_fn[STR_AS_OUT_ALT0].id;
+ std_as_out_if1_desc.iInterface = strings_fn[STR_AS_OUT_ALT1].id;
+ std_as_in_if0_desc.iInterface = strings_fn[STR_AS_IN_ALT0].id;
+ std_as_in_if1_desc.iInterface = strings_fn[STR_AS_IN_ALT1].id;
agdev_g->func.name = "uac2_func";
agdev_g->func.strings = fn_strings;