Commit 06644aaf authored by Felipe Balbi's avatar Felipe Balbi

usb: gadget: dummy: implement ->udc_set_speed()

Move the code which was part of pullup() to the newly introduced
method.
Signed-off-by: default avatarFelipe Balbi <felipe.balbi@linux.intel.com>
parent 7d8d0639
...@@ -888,22 +888,6 @@ static int dummy_pullup(struct usb_gadget *_gadget, int value) ...@@ -888,22 +888,6 @@ static int dummy_pullup(struct usb_gadget *_gadget, int value)
unsigned long flags; unsigned long flags;
dum = gadget_dev_to_dummy(&_gadget->dev); dum = gadget_dev_to_dummy(&_gadget->dev);
if (value && dum->driver) {
if (mod_data.is_super_speed)
dum->gadget.speed = dum->driver->max_speed;
else if (mod_data.is_high_speed)
dum->gadget.speed = min_t(u8, USB_SPEED_HIGH,
dum->driver->max_speed);
else
dum->gadget.speed = USB_SPEED_FULL;
dummy_udc_update_ep0(dum);
if (dum->gadget.speed < dum->driver->max_speed)
dev_dbg(udc_dev(dum), "This device can perform faster"
" if you connect it to a %s port...\n",
usb_speed_string(dum->driver->max_speed));
}
dum_hcd = gadget_to_dummy_hcd(_gadget); dum_hcd = gadget_to_dummy_hcd(_gadget);
spin_lock_irqsave(&dum->lock, flags); spin_lock_irqsave(&dum->lock, flags);
...@@ -915,6 +899,28 @@ static int dummy_pullup(struct usb_gadget *_gadget, int value) ...@@ -915,6 +899,28 @@ static int dummy_pullup(struct usb_gadget *_gadget, int value)
return 0; return 0;
} }
static void dummy_udc_set_speed(struct usb_gadget *_gadget,
enum usb_device_speed speed)
{
struct dummy *dum;
dum = gadget_dev_to_dummy(&_gadget->dev);
if (mod_data.is_super_speed)
dum->gadget.speed = min_t(u8, USB_SPEED_SUPER, speed);
else if (mod_data.is_high_speed)
dum->gadget.speed = min_t(u8, USB_SPEED_HIGH, speed);
else
dum->gadget.speed = USB_SPEED_FULL;
dummy_udc_update_ep0(dum);
if (dum->gadget.speed < speed)
dev_dbg(udc_dev(dum), "This device can perform faster"
" if you connect it to a %s port...\n",
usb_speed_string(speed));
}
static int dummy_udc_start(struct usb_gadget *g, static int dummy_udc_start(struct usb_gadget *g,
struct usb_gadget_driver *driver); struct usb_gadget_driver *driver);
static int dummy_udc_stop(struct usb_gadget *g); static int dummy_udc_stop(struct usb_gadget *g);
...@@ -926,6 +932,7 @@ static const struct usb_gadget_ops dummy_ops = { ...@@ -926,6 +932,7 @@ static const struct usb_gadget_ops dummy_ops = {
.pullup = dummy_pullup, .pullup = dummy_pullup,
.udc_start = dummy_udc_start, .udc_start = dummy_udc_start,
.udc_stop = dummy_udc_stop, .udc_stop = dummy_udc_stop,
.udc_set_speed = dummy_udc_set_speed,
}; };
/*-------------------------------------------------------------------------*/ /*-------------------------------------------------------------------------*/
......
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