Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 338634
b: refs/heads/master
c: 1616e99
h: refs/heads/master
v: v3
  • Loading branch information
Sebastian Andrzej Siewior authored and Felipe Balbi committed Oct 31, 2012
1 parent b4426a0 commit 79532ef
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 234 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b36c347966160ecfe420cd47a5a1f81ddaffc007
refs/heads/master: 1616e99d42a8b427b8dcada347ef0ee0df1a1b7b
27 changes: 8 additions & 19 deletions trunk/drivers/usb/gadget/f_acm.c
Original file line number Diff line number Diff line change
Expand Up @@ -705,6 +705,7 @@ acm_unbind(struct usb_configuration *c, struct usb_function *f)
{
struct f_acm *acm = func_to_acm(f);

acm_string_defs[0].id = 0;
usb_free_all_descriptors(f);
gs_free_req(acm->notify, acm->notify_req);
kfree(acm);
Expand Down Expand Up @@ -742,27 +743,15 @@ int acm_bind_config(struct usb_configuration *c, u8 port_num)
*/

/* maybe allocate device-global string IDs, and patch descriptors */
if (acm_string_defs[ACM_CTRL_IDX].id == 0) {
status = usb_string_id(c->cdev);
if (acm_string_defs[0].id == 0) {
status = usb_string_ids_tab(c->cdev, acm_string_defs);
if (status < 0)
return status;
acm_string_defs[ACM_CTRL_IDX].id = status;

acm_control_interface_desc.iInterface = status;

status = usb_string_id(c->cdev);
if (status < 0)
return status;
acm_string_defs[ACM_DATA_IDX].id = status;

acm_data_interface_desc.iInterface = status;

status = usb_string_id(c->cdev);
if (status < 0)
return status;
acm_string_defs[ACM_IAD_IDX].id = status;

acm_iad_descriptor.iFunction = status;
acm_control_interface_desc.iInterface =
acm_string_defs[ACM_CTRL_IDX].id;
acm_data_interface_desc.iInterface =
acm_string_defs[ACM_DATA_IDX].id;
acm_iad_descriptor.iFunction = acm_string_defs[ACM_IAD_IDX].id;
}

/* allocate and initialize one new instance */
Expand Down
42 changes: 9 additions & 33 deletions trunk/drivers/usb/gadget/f_ecm.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static struct usb_descriptor_header *ecm_ss_function[] = {

static struct usb_string ecm_string_defs[] = {
[0].s = "CDC Ethernet Control Model (ECM)",
[1].s = NULL /* DYNAMIC */,
[1].s = "",
[2].s = "CDC Ethernet Data",
[3].s = "CDC ECM",
{ } /* end of list */
Expand Down Expand Up @@ -803,12 +803,11 @@ ecm_unbind(struct usb_configuration *c, struct usb_function *f)

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

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

kfree(ecm->notify_req->buf);
usb_ep_free_request(ecm->notify, ecm->notify_req);

ecm_string_defs[1].s = NULL;
kfree(ecm);
}

Expand All @@ -833,36 +832,15 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
return -EINVAL;

/* maybe allocate device-global string IDs */
if (ecm_string_defs[0].id == 0) {

/* control interface label */
status = usb_string_id(c->cdev);
if (status < 0)
status = usb_string_ids_tab(c->cdev, ecm_string_defs);
if (status)
return status;
ecm_string_defs[0].id = status;
ecm_control_intf.iInterface = status;

/* data interface label */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
ecm_string_defs[2].id = status;
ecm_data_intf.iInterface = status;

/* MAC address */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
ecm_string_defs[1].id = status;
ecm_desc.iMACAddress = status;

/* IAD label */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
ecm_string_defs[3].id = status;
ecm_iad_descriptor.iFunction = status;
ecm_control_intf.iInterface = ecm_string_defs[0].id;
ecm_data_intf.iInterface = ecm_string_defs[2].id;
ecm_desc.iMACAddress = ecm_string_defs[1].id;
ecm_iad_descriptor.iFunction = ecm_string_defs[3].id;
}

/* allocate and initialize one new instance */
Expand All @@ -887,9 +865,7 @@ ecm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
ecm->port.func.disable = ecm_disable;

status = usb_add_function(c, &ecm->port.func);
if (status) {
ecm_string_defs[1].s = NULL;
if (status)
kfree(ecm);
}
return status;
}
40 changes: 10 additions & 30 deletions trunk/drivers/usb/gadget/f_ncm.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ static struct usb_descriptor_header *ncm_hs_function[] __initdata = {

static struct usb_string ncm_string_defs[] = {
[STRING_CTRL_IDX].s = "CDC Network Control Model (NCM)",
[STRING_MAC_IDX].s = NULL /* DYNAMIC */,
[STRING_MAC_IDX].s = "",
[STRING_DATA_IDX].s = "CDC Network Data",
[STRING_IAD_IDX].s = "CDC NCM",
{ } /* end of list */
Expand Down Expand Up @@ -1262,12 +1262,12 @@ 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);
usb_ep_free_request(ncm->notify, ncm->notify_req);

ncm_string_defs[1].s = NULL;
kfree(ncm);
}

Expand All @@ -1291,37 +1291,19 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
if (!can_support_ecm(c->cdev->gadget) || !ethaddr)
return -EINVAL;

/* maybe allocate device-global string IDs */
if (ncm_string_defs[0].id == 0) {

/* control interface label */
status = usb_string_id(c->cdev);
status = usb_string_ids_tab(c->cdev, ncm_string_defs);
if (status < 0)
return status;
ncm_string_defs[STRING_CTRL_IDX].id = status;
ncm_control_intf.iInterface = status;
ncm_control_intf.iInterface =
ncm_string_defs[STRING_CTRL_IDX].id;

/* data interface label */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
ncm_string_defs[STRING_DATA_IDX].id = status;
status = ncm_string_defs[STRING_DATA_IDX].id;
ncm_data_nop_intf.iInterface = status;
ncm_data_intf.iInterface = status;

/* MAC address */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
ncm_string_defs[STRING_MAC_IDX].id = status;
ecm_desc.iMACAddress = status;

/* IAD */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
ncm_string_defs[STRING_IAD_IDX].id = status;
ncm_iad_desc.iFunction = status;
ecm_desc.iMACAddress = ncm_string_defs[STRING_MAC_IDX].id;
ncm_iad_desc.iFunction = ncm_string_defs[STRING_IAD_IDX].id;
}

/* allocate and initialize one new instance */
Expand All @@ -1331,7 +1313,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])

/* export host's Ethernet address in CDC format */
snprintf(ncm->ethaddr, sizeof ncm->ethaddr, "%pm", ethaddr);
ncm_string_defs[1].s = ncm->ethaddr;
ncm_string_defs[STRING_MAC_IDX].s = ncm->ethaddr;

spin_lock_init(&ncm->lock);
ncm_reset_values(ncm);
Expand All @@ -1351,9 +1333,7 @@ int __init ncm_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
ncm->port.unwrap = ncm_unwrap_ntb;

status = usb_add_function(c, &ncm->port.func);
if (status) {
ncm_string_defs[1].s = NULL;
if (status)
kfree(ncm);
}
return status;
}
19 changes: 7 additions & 12 deletions trunk/drivers/usb/gadget/f_obex.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ obex_bind(struct usb_configuration *c, struct usb_function *f)
static void
obex_unbind(struct usb_configuration *c, struct usb_function *f)
{
obex_string_defs[OBEX_CTRL_IDX].id = 0;
usb_free_all_descriptors(f);
kfree(func_to_obex(f));
}
Expand Down Expand Up @@ -418,22 +419,16 @@ int __init obex_bind_config(struct usb_configuration *c, u8 port_num)
if (!can_support_obex(c))
return -EINVAL;

/* maybe allocate device-global string IDs, and patch descriptors */
if (obex_string_defs[OBEX_CTRL_IDX].id == 0) {
status = usb_string_id(c->cdev);
status = usb_string_ids_tab(c->cdev, obex_string_defs);
if (status < 0)
return status;
obex_string_defs[OBEX_CTRL_IDX].id = status;
obex_control_intf.iInterface =
obex_string_defs[OBEX_CTRL_IDX].id;

obex_control_intf.iInterface = status;

status = usb_string_id(c->cdev);
if (status < 0)
return status;
obex_string_defs[OBEX_DATA_IDX].id = status;

obex_data_nop_intf.iInterface =
obex_data_intf.iInterface = status;
status = obex_string_defs[OBEX_DATA_IDX].id;
obex_data_nop_intf.iInterface = status;
obex_data_intf.iInterface = status;
}

/* allocate and initialize one new instance */
Expand Down
27 changes: 6 additions & 21 deletions trunk/drivers/usb/gadget/f_rndis.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,8 +795,8 @@ rndis_unbind(struct usb_configuration *c, struct usb_function *f)

rndis_deregister(rndis->config);
rndis_exit();
rndis_string_defs[0].id = 0;

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

kfree(rndis->notify_req->buf);
Expand All @@ -822,34 +822,19 @@ rndis_bind_config_vendor(struct usb_configuration *c, u8 ethaddr[ETH_ALEN],
if (!can_support_rndis(c) || !ethaddr)
return -EINVAL;

/* maybe allocate device-global string IDs */
if (rndis_string_defs[0].id == 0) {

/* ... and setup RNDIS itself */
status = rndis_init();
if (status < 0)
return status;

/* control interface label */
status = usb_string_id(c->cdev);
if (status < 0)
status = usb_string_ids_tab(c->cdev, rndis_string_defs);
if (status)
return status;
rndis_string_defs[0].id = status;
rndis_control_intf.iInterface = status;

/* data interface label */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
rndis_string_defs[1].id = status;
rndis_data_intf.iInterface = status;

/* IAD iFunction label */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
rndis_string_defs[2].id = status;
rndis_iad_descriptor.iFunction = status;
rndis_control_intf.iInterface = rndis_string_defs[0].id;
rndis_data_intf.iInterface = rndis_string_defs[1].id;
rndis_iad_descriptor.iFunction = rndis_string_defs[2].id;
}

/* allocate and initialize one new instance */
Expand Down
23 changes: 6 additions & 17 deletions trunk/drivers/usb/gadget/f_subset.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static struct usb_descriptor_header *ss_eth_function[] = {

static struct usb_string geth_string_defs[] = {
[0].s = "CDC Ethernet Subset/SAFE",
[1].s = NULL /* DYNAMIC */,
[1].s = "",
{ } /* end of list */
};

Expand Down Expand Up @@ -363,8 +363,8 @@ geth_bind(struct usb_configuration *c, struct usb_function *f)
static void
geth_unbind(struct usb_configuration *c, struct usb_function *f)
{
geth_string_defs[0].id = 0;
usb_free_all_descriptors(f);
geth_string_defs[1].s = NULL;
kfree(func_to_geth(f));
}

Expand All @@ -390,20 +390,11 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])

/* maybe allocate device-global string IDs */
if (geth_string_defs[0].id == 0) {

/* interface label */
status = usb_string_id(c->cdev);
if (status < 0)
return status;
geth_string_defs[0].id = status;
subset_data_intf.iInterface = status;

/* MAC address */
status = usb_string_id(c->cdev);
status = usb_string_ids_tab(c->cdev, geth_string_defs);
if (status < 0)
return status;
geth_string_defs[1].id = status;
ether_desc.iMACAddress = status;
subset_data_intf.iInterface = geth_string_defs[0].id;
ether_desc.iMACAddress = geth_string_defs[1].id;
}

/* allocate and initialize one new instance */
Expand All @@ -425,9 +416,7 @@ int geth_bind_config(struct usb_configuration *c, u8 ethaddr[ETH_ALEN])
geth->port.func.disable = geth_disable;

status = usb_add_function(c, &geth->port.func);
if (status) {
geth_string_defs[1].s = NULL;
if (status)
kfree(geth);
}
return status;
}
Loading

0 comments on commit 79532ef

Please sign in to comment.