diff options
Diffstat (limited to 'drivers/usb/gadget/dummy_hcd.c')
-rw-r--r-- | drivers/usb/gadget/dummy_hcd.c | 98 |
1 files changed, 41 insertions, 57 deletions
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index cbe44535c0f0..66293105d136 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -365,16 +365,14 @@ dummy_enable (struct usb_ep *_ep, const struct usb_endpoint_descriptor *desc) | |||
365 | case USB_SPEED_HIGH: | 365 | case USB_SPEED_HIGH: |
366 | if (max == 512) | 366 | if (max == 512) |
367 | break; | 367 | break; |
368 | /* conserve return statements */ | 368 | goto done; |
369 | default: | 369 | case USB_SPEED_FULL: |
370 | switch (max) { | 370 | if (max == 8 || max == 16 || max == 32 || max == 64) |
371 | case 8: case 16: case 32: case 64: | ||
372 | /* we'll fake any legal size */ | 371 | /* we'll fake any legal size */ |
373 | break; | 372 | break; |
374 | default: | 373 | /* save a return statement */ |
375 | case USB_SPEED_LOW: | 374 | default: |
376 | goto done; | 375 | goto done; |
377 | } | ||
378 | } | 376 | } |
379 | break; | 377 | break; |
380 | case USB_ENDPOINT_XFER_INT: | 378 | case USB_ENDPOINT_XFER_INT: |
@@ -894,13 +892,12 @@ static int dummy_udc_suspend (struct platform_device *pdev, pm_message_t state) | |||
894 | { | 892 | { |
895 | struct dummy *dum = platform_get_drvdata(pdev); | 893 | struct dummy *dum = platform_get_drvdata(pdev); |
896 | 894 | ||
897 | dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); | 895 | dev_dbg (&pdev->dev, "%s\n", __func__); |
898 | spin_lock_irq (&dum->lock); | 896 | spin_lock_irq (&dum->lock); |
899 | dum->udc_suspended = 1; | 897 | dum->udc_suspended = 1; |
900 | set_link_state (dum); | 898 | set_link_state (dum); |
901 | spin_unlock_irq (&dum->lock); | 899 | spin_unlock_irq (&dum->lock); |
902 | 900 | ||
903 | pdev->dev.power.power_state = state; | ||
904 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 901 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
905 | return 0; | 902 | return 0; |
906 | } | 903 | } |
@@ -909,13 +906,12 @@ static int dummy_udc_resume (struct platform_device *pdev) | |||
909 | { | 906 | { |
910 | struct dummy *dum = platform_get_drvdata(pdev); | 907 | struct dummy *dum = platform_get_drvdata(pdev); |
911 | 908 | ||
912 | dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); | 909 | dev_dbg (&pdev->dev, "%s\n", __func__); |
913 | spin_lock_irq (&dum->lock); | 910 | spin_lock_irq (&dum->lock); |
914 | dum->udc_suspended = 0; | 911 | dum->udc_suspended = 0; |
915 | set_link_state (dum); | 912 | set_link_state (dum); |
916 | spin_unlock_irq (&dum->lock); | 913 | spin_unlock_irq (&dum->lock); |
917 | 914 | ||
918 | pdev->dev.power.power_state = PMSG_ON; | ||
919 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 915 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
920 | return 0; | 916 | return 0; |
921 | } | 917 | } |
@@ -1711,7 +1707,7 @@ static int dummy_bus_suspend (struct usb_hcd *hcd) | |||
1711 | { | 1707 | { |
1712 | struct dummy *dum = hcd_to_dummy (hcd); | 1708 | struct dummy *dum = hcd_to_dummy (hcd); |
1713 | 1709 | ||
1714 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); | 1710 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); |
1715 | 1711 | ||
1716 | spin_lock_irq (&dum->lock); | 1712 | spin_lock_irq (&dum->lock); |
1717 | dum->rh_state = DUMMY_RH_SUSPENDED; | 1713 | dum->rh_state = DUMMY_RH_SUSPENDED; |
@@ -1726,7 +1722,7 @@ static int dummy_bus_resume (struct usb_hcd *hcd) | |||
1726 | struct dummy *dum = hcd_to_dummy (hcd); | 1722 | struct dummy *dum = hcd_to_dummy (hcd); |
1727 | int rc = 0; | 1723 | int rc = 0; |
1728 | 1724 | ||
1729 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __FUNCTION__); | 1725 | dev_dbg (&hcd->self.root_hub->dev, "%s\n", __func__); |
1730 | 1726 | ||
1731 | spin_lock_irq (&dum->lock); | 1727 | spin_lock_irq (&dum->lock); |
1732 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { | 1728 | if (!test_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags)) { |
@@ -1900,7 +1896,7 @@ static int dummy_hcd_suspend (struct platform_device *pdev, pm_message_t state) | |||
1900 | struct dummy *dum; | 1896 | struct dummy *dum; |
1901 | int rc = 0; | 1897 | int rc = 0; |
1902 | 1898 | ||
1903 | dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); | 1899 | dev_dbg (&pdev->dev, "%s\n", __func__); |
1904 | 1900 | ||
1905 | hcd = platform_get_drvdata (pdev); | 1901 | hcd = platform_get_drvdata (pdev); |
1906 | dum = hcd_to_dummy (hcd); | 1902 | dum = hcd_to_dummy (hcd); |
@@ -1916,7 +1912,7 @@ static int dummy_hcd_resume (struct platform_device *pdev) | |||
1916 | { | 1912 | { |
1917 | struct usb_hcd *hcd; | 1913 | struct usb_hcd *hcd; |
1918 | 1914 | ||
1919 | dev_dbg (&pdev->dev, "%s\n", __FUNCTION__); | 1915 | dev_dbg (&pdev->dev, "%s\n", __func__); |
1920 | 1916 | ||
1921 | hcd = platform_get_drvdata (pdev); | 1917 | hcd = platform_get_drvdata (pdev); |
1922 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | 1918 | set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); |
@@ -1937,69 +1933,57 @@ static struct platform_driver dummy_hcd_driver = { | |||
1937 | 1933 | ||
1938 | /*-------------------------------------------------------------------------*/ | 1934 | /*-------------------------------------------------------------------------*/ |
1939 | 1935 | ||
1940 | /* These don't need to do anything because the pdev structures are | 1936 | static struct platform_device *the_udc_pdev; |
1941 | * statically allocated. */ | 1937 | static struct platform_device *the_hcd_pdev; |
1942 | static void | ||
1943 | dummy_udc_release (struct device *dev) {} | ||
1944 | |||
1945 | static void | ||
1946 | dummy_hcd_release (struct device *dev) {} | ||
1947 | |||
1948 | static struct platform_device the_udc_pdev = { | ||
1949 | .name = (char *) gadget_name, | ||
1950 | .id = -1, | ||
1951 | .dev = { | ||
1952 | .release = dummy_udc_release, | ||
1953 | }, | ||
1954 | }; | ||
1955 | |||
1956 | static struct platform_device the_hcd_pdev = { | ||
1957 | .name = (char *) driver_name, | ||
1958 | .id = -1, | ||
1959 | .dev = { | ||
1960 | .release = dummy_hcd_release, | ||
1961 | }, | ||
1962 | }; | ||
1963 | 1938 | ||
1964 | static int __init init (void) | 1939 | static int __init init (void) |
1965 | { | 1940 | { |
1966 | int retval; | 1941 | int retval = -ENOMEM; |
1967 | 1942 | ||
1968 | if (usb_disabled ()) | 1943 | if (usb_disabled ()) |
1969 | return -ENODEV; | 1944 | return -ENODEV; |
1970 | 1945 | ||
1971 | retval = platform_driver_register (&dummy_hcd_driver); | 1946 | the_hcd_pdev = platform_device_alloc(driver_name, -1); |
1972 | if (retval < 0) | 1947 | if (!the_hcd_pdev) |
1973 | return retval; | 1948 | return retval; |
1949 | the_udc_pdev = platform_device_alloc(gadget_name, -1); | ||
1950 | if (!the_udc_pdev) | ||
1951 | goto err_alloc_udc; | ||
1974 | 1952 | ||
1975 | retval = platform_driver_register (&dummy_udc_driver); | 1953 | retval = platform_driver_register(&dummy_hcd_driver); |
1954 | if (retval < 0) | ||
1955 | goto err_register_hcd_driver; | ||
1956 | retval = platform_driver_register(&dummy_udc_driver); | ||
1976 | if (retval < 0) | 1957 | if (retval < 0) |
1977 | goto err_register_udc_driver; | 1958 | goto err_register_udc_driver; |
1978 | 1959 | ||
1979 | retval = platform_device_register (&the_hcd_pdev); | 1960 | retval = platform_device_add(the_hcd_pdev); |
1980 | if (retval < 0) | 1961 | if (retval < 0) |
1981 | goto err_register_hcd; | 1962 | goto err_add_hcd; |
1982 | 1963 | retval = platform_device_add(the_udc_pdev); | |
1983 | retval = platform_device_register (&the_udc_pdev); | ||
1984 | if (retval < 0) | 1964 | if (retval < 0) |
1985 | goto err_register_udc; | 1965 | goto err_add_udc; |
1986 | return retval; | 1966 | return retval; |
1987 | 1967 | ||
1988 | err_register_udc: | 1968 | err_add_udc: |
1989 | platform_device_unregister (&the_hcd_pdev); | 1969 | platform_device_del(the_hcd_pdev); |
1990 | err_register_hcd: | 1970 | err_add_hcd: |
1991 | platform_driver_unregister (&dummy_udc_driver); | 1971 | platform_driver_unregister(&dummy_udc_driver); |
1992 | err_register_udc_driver: | 1972 | err_register_udc_driver: |
1993 | platform_driver_unregister (&dummy_hcd_driver); | 1973 | platform_driver_unregister(&dummy_hcd_driver); |
1974 | err_register_hcd_driver: | ||
1975 | platform_device_put(the_udc_pdev); | ||
1976 | err_alloc_udc: | ||
1977 | platform_device_put(the_hcd_pdev); | ||
1994 | return retval; | 1978 | return retval; |
1995 | } | 1979 | } |
1996 | module_init (init); | 1980 | module_init (init); |
1997 | 1981 | ||
1998 | static void __exit cleanup (void) | 1982 | static void __exit cleanup (void) |
1999 | { | 1983 | { |
2000 | platform_device_unregister (&the_udc_pdev); | 1984 | platform_device_unregister(the_udc_pdev); |
2001 | platform_device_unregister (&the_hcd_pdev); | 1985 | platform_device_unregister(the_hcd_pdev); |
2002 | platform_driver_unregister (&dummy_udc_driver); | 1986 | platform_driver_unregister(&dummy_udc_driver); |
2003 | platform_driver_unregister (&dummy_hcd_driver); | 1987 | platform_driver_unregister(&dummy_hcd_driver); |
2004 | } | 1988 | } |
2005 | module_exit (cleanup); | 1989 | module_exit (cleanup); |