diff options
author | Sebastian Andrzej Siewior <sebastian@breakpoint.cc> | 2012-02-04 12:55:23 -0500 |
---|---|---|
committer | Felipe Balbi <balbi@ti.com> | 2012-05-04 08:53:00 -0400 |
commit | f3d8bf34c2c925867322197096ed501ceab8085a (patch) | |
tree | fad86a1e7b10b10de99971156384f94b0a9edfbd | |
parent | 955846a60a9db884d6a5b644876a96b806a48a8d (diff) |
usb: gadget: at91_udc: convert to new style start/stop interface
This patches converts the driver into the new style start/stop interface.
As a result the driver no longer uses the static global controller
variable in start/stop functions. I kept the controller variable since it
makes the init code a little simpler.
Compile tested only.
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
Signed-off-by: Felipe Balbi <balbi@ti.com>
-rw-r--r-- | drivers/usb/gadget/at91_udc.c | 60 |
1 files changed, 14 insertions, 46 deletions
diff --git a/drivers/usb/gadget/at91_udc.c b/drivers/usb/gadget/at91_udc.c index 86cc9097a5cf..43943aa965dc 100644 --- a/drivers/usb/gadget/at91_udc.c +++ b/drivers/usb/gadget/at91_udc.c | |||
@@ -977,18 +977,18 @@ static int at91_set_selfpowered(struct usb_gadget *gadget, int is_on) | |||
977 | return 0; | 977 | return 0; |
978 | } | 978 | } |
979 | 979 | ||
980 | static int at91_start(struct usb_gadget_driver *driver, | 980 | static int at91_start(struct usb_gadget *gadget, |
981 | int (*bind)(struct usb_gadget *)); | 981 | struct usb_gadget_driver *driver); |
982 | static int at91_stop(struct usb_gadget_driver *driver); | 982 | static int at91_stop(struct usb_gadget *gadget, |
983 | 983 | struct usb_gadget_driver *driver); | |
984 | static const struct usb_gadget_ops at91_udc_ops = { | 984 | static const struct usb_gadget_ops at91_udc_ops = { |
985 | .get_frame = at91_get_frame, | 985 | .get_frame = at91_get_frame, |
986 | .wakeup = at91_wakeup, | 986 | .wakeup = at91_wakeup, |
987 | .set_selfpowered = at91_set_selfpowered, | 987 | .set_selfpowered = at91_set_selfpowered, |
988 | .vbus_session = at91_vbus_session, | 988 | .vbus_session = at91_vbus_session, |
989 | .pullup = at91_pullup, | 989 | .pullup = at91_pullup, |
990 | .start = at91_start, | 990 | .udc_start = at91_start, |
991 | .stop = at91_stop, | 991 | .udc_stop = at91_stop, |
992 | 992 | ||
993 | /* | 993 | /* |
994 | * VBUS-powered devices may also also want to support bigger | 994 | * VBUS-powered devices may also also want to support bigger |
@@ -1626,66 +1626,34 @@ static void at91_vbus_timer(unsigned long data) | |||
1626 | schedule_work(&udc->vbus_timer_work); | 1626 | schedule_work(&udc->vbus_timer_work); |
1627 | } | 1627 | } |
1628 | 1628 | ||
1629 | static int at91_start(struct usb_gadget_driver *driver, | 1629 | static int at91_start(struct usb_gadget *gadget, |
1630 | int (*bind)(struct usb_gadget *)) | 1630 | struct usb_gadget_driver *driver) |
1631 | { | 1631 | { |
1632 | struct at91_udc *udc = &controller; | 1632 | struct at91_udc *udc; |
1633 | int retval; | ||
1634 | unsigned long flags; | ||
1635 | |||
1636 | if (!driver | ||
1637 | || driver->max_speed < USB_SPEED_FULL | ||
1638 | || !bind | ||
1639 | || !driver->setup) { | ||
1640 | DBG("bad parameter.\n"); | ||
1641 | return -EINVAL; | ||
1642 | } | ||
1643 | |||
1644 | if (udc->driver) { | ||
1645 | DBG("UDC already has a gadget driver\n"); | ||
1646 | return -EBUSY; | ||
1647 | } | ||
1648 | 1633 | ||
1634 | udc = container_of(gadget, struct at91_udc, gadget); | ||
1649 | udc->driver = driver; | 1635 | udc->driver = driver; |
1650 | udc->gadget.dev.driver = &driver->driver; | 1636 | udc->gadget.dev.driver = &driver->driver; |
1651 | dev_set_drvdata(&udc->gadget.dev, &driver->driver); | 1637 | dev_set_drvdata(&udc->gadget.dev, &driver->driver); |
1652 | udc->enabled = 1; | 1638 | udc->enabled = 1; |
1653 | udc->selfpowered = 1; | 1639 | udc->selfpowered = 1; |
1654 | 1640 | ||
1655 | retval = bind(&udc->gadget); | ||
1656 | if (retval) { | ||
1657 | DBG("bind() returned %d\n", retval); | ||
1658 | udc->driver = NULL; | ||
1659 | udc->gadget.dev.driver = NULL; | ||
1660 | dev_set_drvdata(&udc->gadget.dev, NULL); | ||
1661 | udc->enabled = 0; | ||
1662 | udc->selfpowered = 0; | ||
1663 | return retval; | ||
1664 | } | ||
1665 | |||
1666 | spin_lock_irqsave(&udc->lock, flags); | ||
1667 | pullup(udc, 1); | ||
1668 | spin_unlock_irqrestore(&udc->lock, flags); | ||
1669 | |||
1670 | DBG("bound to %s\n", driver->driver.name); | 1641 | DBG("bound to %s\n", driver->driver.name); |
1671 | return 0; | 1642 | return 0; |
1672 | } | 1643 | } |
1673 | 1644 | ||
1674 | static int at91_stop(struct usb_gadget_driver *driver) | 1645 | static int at91_stop(struct usb_gadget *gadget, |
1646 | struct usb_gadget_driver *driver) | ||
1675 | { | 1647 | { |
1676 | struct at91_udc *udc = &controller; | 1648 | struct at91_udc *udc; |
1677 | unsigned long flags; | 1649 | unsigned long flags; |
1678 | 1650 | ||
1679 | if (!driver || driver != udc->driver || !driver->unbind) | 1651 | udc = container_of(gadget, struct at91_udc, gadget); |
1680 | return -EINVAL; | ||
1681 | |||
1682 | spin_lock_irqsave(&udc->lock, flags); | 1652 | spin_lock_irqsave(&udc->lock, flags); |
1683 | udc->enabled = 0; | 1653 | udc->enabled = 0; |
1684 | at91_udp_write(udc, AT91_UDP_IDR, ~0); | 1654 | at91_udp_write(udc, AT91_UDP_IDR, ~0); |
1685 | pullup(udc, 0); | ||
1686 | spin_unlock_irqrestore(&udc->lock, flags); | 1655 | spin_unlock_irqrestore(&udc->lock, flags); |
1687 | 1656 | ||
1688 | driver->unbind(&udc->gadget); | ||
1689 | udc->gadget.dev.driver = NULL; | 1657 | udc->gadget.dev.driver = NULL; |
1690 | dev_set_drvdata(&udc->gadget.dev, NULL); | 1658 | dev_set_drvdata(&udc->gadget.dev, NULL); |
1691 | udc->driver = NULL; | 1659 | udc->driver = NULL; |