Commit ae2dd0de authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi

usb: gadget: printer: standardize printer_do_config

Follow the convention of distributing source code between
<something>_do_config() and <something>_bind_config().
Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 406be2cc
...@@ -1170,7 +1170,8 @@ static struct usb_configuration printer_cfg_driver = { ...@@ -1170,7 +1170,8 @@ static struct usb_configuration printer_cfg_driver = {
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
}; };
static int __init printer_do_config(struct usb_configuration *c) static int f_printer_bind_config(struct usb_configuration *c, char *pnp_str,
unsigned q_len)
{ {
struct usb_gadget *gadget = c->cdev->gadget; struct usb_gadget *gadget = c->cdev->gadget;
struct printer_dev *dev; struct printer_dev *dev;
...@@ -1180,8 +1181,6 @@ static int __init printer_do_config(struct usb_configuration *c) ...@@ -1180,8 +1181,6 @@ static int __init printer_do_config(struct usb_configuration *c)
u32 i; u32 i;
struct usb_request *req; struct usb_request *req;
usb_ep_autoconfig_reset(gadget);
dev = &usb_printer_gadget; dev = &usb_printer_gadget;
dev->function.name = shortname; dev->function.name = shortname;
...@@ -1219,21 +1218,13 @@ static int __init printer_do_config(struct usb_configuration *c) ...@@ -1219,21 +1218,13 @@ static int __init printer_do_config(struct usb_configuration *c)
goto fail; goto fail;
} }
if (iPNPstring) if (pnp_str)
strlcpy(&pnp_string[2], iPNPstring, (sizeof pnp_string)-2); strlcpy(&pnp_string[2], pnp_str, sizeof(pnp_string) - 2);
len = strlen(pnp_string); len = strlen(pnp_string);
pnp_string[0] = (len >> 8) & 0xFF; pnp_string[0] = (len >> 8) & 0xFF;
pnp_string[1] = len & 0xFF; pnp_string[1] = len & 0xFF;
usb_gadget_set_selfpowered(gadget);
if (gadget_is_otg(gadget)) {
otg_descriptor.bmAttributes |= USB_OTG_HNP;
printer_cfg_driver.descriptors = otg_desc;
printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
spin_lock_init(&dev->lock); spin_lock_init(&dev->lock);
mutex_init(&dev->lock_printer_io); mutex_init(&dev->lock_printer_io);
INIT_LIST_HEAD(&dev->tx_reqs_active); INIT_LIST_HEAD(&dev->tx_reqs_active);
...@@ -1250,14 +1241,14 @@ static int __init printer_do_config(struct usb_configuration *c) ...@@ -1250,14 +1241,14 @@ static int __init printer_do_config(struct usb_configuration *c)
dev->current_rx_buf = NULL; dev->current_rx_buf = NULL;
status = -ENOMEM; status = -ENOMEM;
for (i = 0; i < QLEN; i++) { for (i = 0; i < q_len; i++) {
req = printer_req_alloc(dev->in_ep, USB_BUFSIZE, GFP_KERNEL); req = printer_req_alloc(dev->in_ep, USB_BUFSIZE, GFP_KERNEL);
if (!req) if (!req)
goto fail; goto fail;
list_add(&req->list, &dev->tx_reqs); list_add(&req->list, &dev->tx_reqs);
} }
for (i = 0; i < QLEN; i++) { for (i = 0; i < q_len; i++) {
req = printer_req_alloc(dev->out_ep, USB_BUFSIZE, GFP_KERNEL); req = printer_req_alloc(dev->out_ep, USB_BUFSIZE, GFP_KERNEL);
if (!req) if (!req)
goto fail; goto fail;
...@@ -1276,6 +1267,24 @@ static int __init printer_do_config(struct usb_configuration *c) ...@@ -1276,6 +1267,24 @@ static int __init printer_do_config(struct usb_configuration *c)
return status; return status;
} }
static int __init printer_do_config(struct usb_configuration *c)
{
struct usb_gadget *gadget = c->cdev->gadget;
usb_ep_autoconfig_reset(gadget);
usb_gadget_set_selfpowered(gadget);
if (gadget_is_otg(gadget)) {
otg_descriptor.bmAttributes |= USB_OTG_HNP;
printer_cfg_driver.descriptors = otg_desc;
printer_cfg_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
}
return f_printer_bind_config(c, iPNPstring, QLEN);
}
static int __init printer_bind(struct usb_composite_dev *cdev) static int __init printer_bind(struct usb_composite_dev *cdev)
{ {
int ret; int ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment