diff options
author | Russell King <rmk@dyn-67.arm.linux.org.uk> | 2005-11-09 17:32:44 -0500 |
---|---|---|
committer | Russell King <rmk+kernel@arm.linux.org.uk> | 2005-11-09 17:32:44 -0500 |
commit | 3ae5eaec1d2d9c0cf53745352e7d4b152810ba24 (patch) | |
tree | d8825be54cefb6ad6707478d719c8e30605bee7b /drivers/usb/gadget/dummy_hcd.c | |
parent | 00d3dcdd96646be6059cc21f2efa94c4edc1eda5 (diff) |
[DRIVER MODEL] Convert platform drivers to use struct platform_driver
This allows us to eliminate the casts in the drivers, and eventually
remove the use of the device_driver function pointer methods for
platform device drivers.
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/gadget/dummy_hcd.c')
-rw-r--r-- | drivers/usb/gadget/dummy_hcd.c | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/drivers/usb/gadget/dummy_hcd.c b/drivers/usb/gadget/dummy_hcd.c index 975ace3f5b1e..6b93dbbf3246 100644 --- a/drivers/usb/gadget/dummy_hcd.c +++ b/drivers/usb/gadget/dummy_hcd.c | |||
@@ -897,7 +897,7 @@ dummy_gadget_release (struct device *dev) | |||
897 | #endif | 897 | #endif |
898 | } | 898 | } |
899 | 899 | ||
900 | static int dummy_udc_probe (struct device *dev) | 900 | static int dummy_udc_probe (struct platform_device *dev) |
901 | { | 901 | { |
902 | struct dummy *dum = the_controller; | 902 | struct dummy *dum = the_controller; |
903 | int rc; | 903 | int rc; |
@@ -910,7 +910,7 @@ static int dummy_udc_probe (struct device *dev) | |||
910 | dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0); | 910 | dum->gadget.is_otg = (dummy_to_hcd(dum)->self.otg_port != 0); |
911 | 911 | ||
912 | strcpy (dum->gadget.dev.bus_id, "gadget"); | 912 | strcpy (dum->gadget.dev.bus_id, "gadget"); |
913 | dum->gadget.dev.parent = dev; | 913 | dum->gadget.dev.parent = &dev->dev; |
914 | dum->gadget.dev.release = dummy_gadget_release; | 914 | dum->gadget.dev.release = dummy_gadget_release; |
915 | rc = device_register (&dum->gadget.dev); | 915 | rc = device_register (&dum->gadget.dev); |
916 | if (rc < 0) | 916 | if (rc < 0) |
@@ -920,26 +920,26 @@ static int dummy_udc_probe (struct device *dev) | |||
920 | usb_bus_get (&dummy_to_hcd (dum)->self); | 920 | usb_bus_get (&dummy_to_hcd (dum)->self); |
921 | #endif | 921 | #endif |
922 | 922 | ||
923 | dev_set_drvdata (dev, dum); | 923 | platform_set_drvdata (dev, dum); |
924 | device_create_file (&dum->gadget.dev, &dev_attr_function); | 924 | device_create_file (&dum->gadget.dev, &dev_attr_function); |
925 | return rc; | 925 | return rc; |
926 | } | 926 | } |
927 | 927 | ||
928 | static int dummy_udc_remove (struct device *dev) | 928 | static int dummy_udc_remove (struct platform_device *dev) |
929 | { | 929 | { |
930 | struct dummy *dum = dev_get_drvdata (dev); | 930 | struct dummy *dum = platform_get_drvdata (dev); |
931 | 931 | ||
932 | dev_set_drvdata (dev, NULL); | 932 | platform_set_drvdata (dev, NULL); |
933 | device_remove_file (&dum->gadget.dev, &dev_attr_function); | 933 | device_remove_file (&dum->gadget.dev, &dev_attr_function); |
934 | device_unregister (&dum->gadget.dev); | 934 | device_unregister (&dum->gadget.dev); |
935 | return 0; | 935 | return 0; |
936 | } | 936 | } |
937 | 937 | ||
938 | static int dummy_udc_suspend (struct device *dev, pm_message_t state) | 938 | static int dummy_udc_suspend (struct platform_device *dev, pm_message_t state) |
939 | { | 939 | { |
940 | struct dummy *dum = dev_get_drvdata(dev); | 940 | struct dummy *dum = platform_get_drvdata(dev); |
941 | 941 | ||
942 | dev_dbg (dev, "%s\n", __FUNCTION__); | 942 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
943 | spin_lock_irq (&dum->lock); | 943 | spin_lock_irq (&dum->lock); |
944 | dum->udc_suspended = 1; | 944 | dum->udc_suspended = 1; |
945 | set_link_state (dum); | 945 | set_link_state (dum); |
@@ -950,29 +950,30 @@ static int dummy_udc_suspend (struct device *dev, pm_message_t state) | |||
950 | return 0; | 950 | return 0; |
951 | } | 951 | } |
952 | 952 | ||
953 | static int dummy_udc_resume (struct device *dev) | 953 | static int dummy_udc_resume (struct platform_device *dev) |
954 | { | 954 | { |
955 | struct dummy *dum = dev_get_drvdata(dev); | 955 | struct dummy *dum = platform_get_drvdata(dev); |
956 | 956 | ||
957 | dev_dbg (dev, "%s\n", __FUNCTION__); | 957 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
958 | spin_lock_irq (&dum->lock); | 958 | spin_lock_irq (&dum->lock); |
959 | dum->udc_suspended = 0; | 959 | dum->udc_suspended = 0; |
960 | set_link_state (dum); | 960 | set_link_state (dum); |
961 | spin_unlock_irq (&dum->lock); | 961 | spin_unlock_irq (&dum->lock); |
962 | 962 | ||
963 | dev->power.power_state = PMSG_ON; | 963 | dev->dev.power.power_state = PMSG_ON; |
964 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); | 964 | usb_hcd_poll_rh_status (dummy_to_hcd (dum)); |
965 | return 0; | 965 | return 0; |
966 | } | 966 | } |
967 | 967 | ||
968 | static struct device_driver dummy_udc_driver = { | 968 | static struct platform_driver dummy_udc_driver = { |
969 | .name = (char *) gadget_name, | ||
970 | .owner = THIS_MODULE, | ||
971 | .bus = &platform_bus_type, | ||
972 | .probe = dummy_udc_probe, | 969 | .probe = dummy_udc_probe, |
973 | .remove = dummy_udc_remove, | 970 | .remove = dummy_udc_remove, |
974 | .suspend = dummy_udc_suspend, | 971 | .suspend = dummy_udc_suspend, |
975 | .resume = dummy_udc_resume, | 972 | .resume = dummy_udc_resume, |
973 | .driver = { | ||
974 | .name = (char *) gadget_name, | ||
975 | .owner = THIS_MODULE, | ||
976 | }, | ||
976 | }; | 977 | }; |
977 | 978 | ||
978 | /*-------------------------------------------------------------------------*/ | 979 | /*-------------------------------------------------------------------------*/ |
@@ -1899,14 +1900,14 @@ static const struct hc_driver dummy_hcd = { | |||
1899 | .bus_resume = dummy_bus_resume, | 1900 | .bus_resume = dummy_bus_resume, |
1900 | }; | 1901 | }; |
1901 | 1902 | ||
1902 | static int dummy_hcd_probe (struct device *dev) | 1903 | static int dummy_hcd_probe (struct platform_device *dev) |
1903 | { | 1904 | { |
1904 | struct usb_hcd *hcd; | 1905 | struct usb_hcd *hcd; |
1905 | int retval; | 1906 | int retval; |
1906 | 1907 | ||
1907 | dev_info (dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); | 1908 | dev_info (dev, "%s, driver " DRIVER_VERSION "\n", driver_desc); |
1908 | 1909 | ||
1909 | hcd = usb_create_hcd (&dummy_hcd, dev, dev->bus_id); | 1910 | hcd = usb_create_hcd (&dummy_hcd, &dev->dev, dev->dev.bus_id); |
1910 | if (!hcd) | 1911 | if (!hcd) |
1911 | return -ENOMEM; | 1912 | return -ENOMEM; |
1912 | the_controller = hcd_to_dummy (hcd); | 1913 | the_controller = hcd_to_dummy (hcd); |
@@ -1919,48 +1920,49 @@ static int dummy_hcd_probe (struct device *dev) | |||
1919 | return retval; | 1920 | return retval; |
1920 | } | 1921 | } |
1921 | 1922 | ||
1922 | static int dummy_hcd_remove (struct device *dev) | 1923 | static int dummy_hcd_remove (struct platform_device *dev) |
1923 | { | 1924 | { |
1924 | struct usb_hcd *hcd; | 1925 | struct usb_hcd *hcd; |
1925 | 1926 | ||
1926 | hcd = dev_get_drvdata (dev); | 1927 | hcd = platform_get_drvdata (dev); |
1927 | usb_remove_hcd (hcd); | 1928 | usb_remove_hcd (hcd); |
1928 | usb_put_hcd (hcd); | 1929 | usb_put_hcd (hcd); |
1929 | the_controller = NULL; | 1930 | the_controller = NULL; |
1930 | return 0; | 1931 | return 0; |
1931 | } | 1932 | } |
1932 | 1933 | ||
1933 | static int dummy_hcd_suspend (struct device *dev, pm_message_t state) | 1934 | static int dummy_hcd_suspend (struct platform_device *dev, pm_message_t state) |
1934 | { | 1935 | { |
1935 | struct usb_hcd *hcd; | 1936 | struct usb_hcd *hcd; |
1936 | 1937 | ||
1937 | dev_dbg (dev, "%s\n", __FUNCTION__); | 1938 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
1938 | hcd = dev_get_drvdata (dev); | 1939 | hcd = platform_get_drvdata (dev); |
1939 | 1940 | ||
1940 | hcd->state = HC_STATE_SUSPENDED; | 1941 | hcd->state = HC_STATE_SUSPENDED; |
1941 | return 0; | 1942 | return 0; |
1942 | } | 1943 | } |
1943 | 1944 | ||
1944 | static int dummy_hcd_resume (struct device *dev) | 1945 | static int dummy_hcd_resume (struct platform_device *dev) |
1945 | { | 1946 | { |
1946 | struct usb_hcd *hcd; | 1947 | struct usb_hcd *hcd; |
1947 | 1948 | ||
1948 | dev_dbg (dev, "%s\n", __FUNCTION__); | 1949 | dev_dbg (&dev->dev, "%s\n", __FUNCTION__); |
1949 | hcd = dev_get_drvdata (dev); | 1950 | hcd = platform_get_drvdata (dev); |
1950 | hcd->state = HC_STATE_RUNNING; | 1951 | hcd->state = HC_STATE_RUNNING; |
1951 | 1952 | ||
1952 | usb_hcd_poll_rh_status (hcd); | 1953 | usb_hcd_poll_rh_status (hcd); |
1953 | return 0; | 1954 | return 0; |
1954 | } | 1955 | } |
1955 | 1956 | ||
1956 | static struct device_driver dummy_hcd_driver = { | 1957 | static struct platform_driver dummy_hcd_driver = { |
1957 | .name = (char *) driver_name, | ||
1958 | .owner = THIS_MODULE, | ||
1959 | .bus = &platform_bus_type, | ||
1960 | .probe = dummy_hcd_probe, | 1958 | .probe = dummy_hcd_probe, |
1961 | .remove = dummy_hcd_remove, | 1959 | .remove = dummy_hcd_remove, |
1962 | .suspend = dummy_hcd_suspend, | 1960 | .suspend = dummy_hcd_suspend, |
1963 | .resume = dummy_hcd_resume, | 1961 | .resume = dummy_hcd_resume, |
1962 | .driver = { | ||
1963 | .name = (char *) driver_name, | ||
1964 | .owner = THIS_MODULE, | ||
1965 | }, | ||
1964 | }; | 1966 | }; |
1965 | 1967 | ||
1966 | /*-------------------------------------------------------------------------*/ | 1968 | /*-------------------------------------------------------------------------*/ |
@@ -1996,11 +1998,11 @@ static int __init init (void) | |||
1996 | if (usb_disabled ()) | 1998 | if (usb_disabled ()) |
1997 | return -ENODEV; | 1999 | return -ENODEV; |
1998 | 2000 | ||
1999 | retval = driver_register (&dummy_hcd_driver); | 2001 | retval = platform_driver_register (&dummy_hcd_driver); |
2000 | if (retval < 0) | 2002 | if (retval < 0) |
2001 | return retval; | 2003 | return retval; |
2002 | 2004 | ||
2003 | retval = driver_register (&dummy_udc_driver); | 2005 | retval = platform_driver_register (&dummy_udc_driver); |
2004 | if (retval < 0) | 2006 | if (retval < 0) |
2005 | goto err_register_udc_driver; | 2007 | goto err_register_udc_driver; |
2006 | 2008 | ||
@@ -2016,9 +2018,9 @@ static int __init init (void) | |||
2016 | err_register_udc: | 2018 | err_register_udc: |
2017 | platform_device_unregister (&the_hcd_pdev); | 2019 | platform_device_unregister (&the_hcd_pdev); |
2018 | err_register_hcd: | 2020 | err_register_hcd: |
2019 | driver_unregister (&dummy_udc_driver); | 2021 | platform_driver_unregister (&dummy_udc_driver); |
2020 | err_register_udc_driver: | 2022 | err_register_udc_driver: |
2021 | driver_unregister (&dummy_hcd_driver); | 2023 | platform_driver_unregister (&dummy_hcd_driver); |
2022 | return retval; | 2024 | return retval; |
2023 | } | 2025 | } |
2024 | module_init (init); | 2026 | module_init (init); |
@@ -2027,7 +2029,7 @@ static void __exit cleanup (void) | |||
2027 | { | 2029 | { |
2028 | platform_device_unregister (&the_udc_pdev); | 2030 | platform_device_unregister (&the_udc_pdev); |
2029 | platform_device_unregister (&the_hcd_pdev); | 2031 | platform_device_unregister (&the_hcd_pdev); |
2030 | driver_unregister (&dummy_udc_driver); | 2032 | platform_driver_unregister (&dummy_udc_driver); |
2031 | driver_unregister (&dummy_hcd_driver); | 2033 | platform_driver_unregister (&dummy_hcd_driver); |
2032 | } | 2034 | } |
2033 | module_exit (cleanup); | 2035 | module_exit (cleanup); |