Skip to content

Commit

Permalink
usb: gadget: f_ncm: use usb_gstrings_attach
Browse files Browse the repository at this point in the history
Trivial patch making use of the new usb_gstrings_attach
interface.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
  • Loading branch information
Andrzej Pietrasiewicz authored and Felipe Balbi committed Jun 10, 2013
1 parent dd67a17 commit 8feffd0
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions drivers/usb/gadget/f_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,7 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
{
struct usb_composite_dev *cdev = c->cdev;
struct f_ncm *ncm = func_to_ncm(f);
struct usb_string *us;
int status;
struct usb_ep *ep;
struct f_ncm_opts *ncm_opts;
Expand All @@ -1180,20 +1181,15 @@ static int ncm_bind(struct usb_configuration *c, struct usb_function *f)
return status;
ncm_opts->bound = true;
}
if (ncm_string_defs[0].id == 0) {
status = usb_string_ids_tab(c->cdev, ncm_string_defs);
if (status < 0)
return status;
ncm_control_intf.iInterface =
ncm_string_defs[STRING_CTRL_IDX].id;

status = ncm_string_defs[STRING_DATA_IDX].id;
ncm_data_nop_intf.iInterface = status;
ncm_data_intf.iInterface = status;

ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id;
ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id;
}
us = usb_gstrings_attach(cdev, ncm_strings,
ARRAY_SIZE(ncm_string_defs));
if (IS_ERR(us))
return PTR_ERR(us);
ncm_control_intf.iInterface = us[STRING_CTRL_IDX].id;
ncm_data_nop_intf.iInterface = us[STRING_DATA_IDX].id;
ncm_data_intf.iInterface = us[STRING_DATA_IDX].id;
ecm_desc.iMACAddress = us[STRING_MAC_IDX].id;
ncm_iad_desc.iFunction = us[STRING_IAD_IDX].id;

/* allocate instance-specific interface IDs */
status = usb_interface_id(c, f);
Expand Down Expand Up @@ -1335,7 +1331,6 @@ static void ncm_unbind(struct usb_configuration *c, struct usb_function *f)

DBG(c->cdev, "ncm unbind\n");

ncm_string_defs[0].id = 0;
usb_free_all_descriptors(f);

kfree(ncm->notify_req->buf);
Expand Down Expand Up @@ -1370,7 +1365,6 @@ struct usb_function *ncm_alloc(struct usb_function_instance *fi)
ncm->port.is_fixed = true;

ncm->port.func.name = "cdc_network";
ncm->port.func.strings = ncm_strings;
/* descriptors are per-instance copies */
ncm->port.func.bind = ncm_bind;
ncm->port.func.unbind = ncm_unbind;
Expand Down

0 comments on commit 8feffd0

Please sign in to comment.