Commit 991cd262 authored by Andrzej Pietrasiewicz's avatar Andrzej Pietrasiewicz Committed by Felipe Balbi

usb: gadget: printer: move function-related unbind code to function's unbind

In order to factor out a reusable f_printer.c, the code related to the
function should be placed in functions related to the function.

printer_cfg_unbind() becomes empty, so it is removed.
Signed-off-by: default avatarAndrzej Pietrasiewicz <andrzej.p@samsung.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent cee5cbff
...@@ -1155,44 +1155,12 @@ static int __init printer_func_bind(struct usb_configuration *c, ...@@ -1155,44 +1155,12 @@ static int __init printer_func_bind(struct usb_configuration *c,
static void printer_func_unbind(struct usb_configuration *c, static void printer_func_unbind(struct usb_configuration *c,
struct usb_function *f) struct usb_function *f)
{
usb_free_all_descriptors(f);
}
static int printer_func_set_alt(struct usb_function *f,
unsigned intf, unsigned alt)
{
struct printer_dev *dev = container_of(f, struct printer_dev, function);
int ret = -ENOTSUPP;
if (!alt)
ret = set_interface(dev, intf);
return ret;
}
static void printer_func_disable(struct usb_function *f)
{
struct printer_dev *dev = container_of(f, struct printer_dev, function);
unsigned long flags;
DBG(dev, "%s\n", __func__);
spin_lock_irqsave(&dev->lock, flags);
printer_reset_interface(dev);
spin_unlock_irqrestore(&dev->lock, flags);
}
static void printer_cfg_unbind(struct usb_configuration *c)
{ {
struct printer_dev *dev; struct printer_dev *dev;
struct usb_request *req; struct usb_request *req;
dev = &usb_printer_gadget; dev = &usb_printer_gadget;
DBG(dev, "%s\n", __func__);
/* Remove sysfs files */
device_destroy(usb_gadget_class, g_printer_devno); device_destroy(usb_gadget_class, g_printer_devno);
/* Remove Character Device */ /* Remove Character Device */
...@@ -1226,11 +1194,35 @@ static void printer_cfg_unbind(struct usb_configuration *c) ...@@ -1226,11 +1194,35 @@ static void printer_cfg_unbind(struct usb_configuration *c)
list_del(&req->list); list_del(&req->list);
printer_req_free(dev->out_ep, req); printer_req_free(dev->out_ep, req);
} }
usb_free_all_descriptors(f);
}
static int printer_func_set_alt(struct usb_function *f,
unsigned intf, unsigned alt)
{
struct printer_dev *dev = container_of(f, struct printer_dev, function);
int ret = -ENOTSUPP;
if (!alt)
ret = set_interface(dev, intf);
return ret;
}
static void printer_func_disable(struct usb_function *f)
{
struct printer_dev *dev = container_of(f, struct printer_dev, function);
unsigned long flags;
DBG(dev, "%s\n", __func__);
spin_lock_irqsave(&dev->lock, flags);
printer_reset_interface(dev);
spin_unlock_irqrestore(&dev->lock, flags);
} }
static struct usb_configuration printer_cfg_driver = { static struct usb_configuration printer_cfg_driver = {
.label = "printer", .label = "printer",
.unbind = printer_cfg_unbind,
.bConfigurationValue = 1, .bConfigurationValue = 1,
.bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER, .bmAttributes = USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,
}; };
......
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