]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
USB: nop-usb-xceiv: behave when linked as a module
authorDavid Brownell <dbrownell@users.sourceforge.net>
Tue, 31 Mar 2009 19:28:31 +0000 (12:28 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 16 Jun 2009 04:44:40 +0000 (21:44 -0700)
The NOP OTG transceiver driver needs to be usable from modules.
Make sure its symbols are always accessible at both compile and
link time, and make sure the device instance is allocated from
the heap so that device lifetime rules are obeyed.

Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/otg/nop-usb-xceiv.c
include/linux/usb/otg.h

index c567168f89af54c63a1b1f386758088c99ec3de6..9ed5ea568679c3715eae4a03700d1ff8bd05e409 100644 (file)
@@ -22,8 +22,8 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  *
  * Current status:
- *     this is to add "nop" transceiver for all those phy which is
- *     autonomous such as isp1504 etc.
+ *     This provides a "nop" transceiver for PHYs which are
+ *     autonomous such as isp1504, isp1707, etc.
  */
 
 #include <linux/module.h>
@@ -36,30 +36,25 @@ struct nop_usb_xceiv {
        struct device           *dev;
 };
 
-static u64 nop_xceiv_dmamask = DMA_BIT_MASK(32);
-
-static struct platform_device nop_xceiv_device = {
-       .name           = "nop_usb_xceiv",
-       .id             = -1,
-       .dev = {
-               .dma_mask               = &nop_xceiv_dmamask,
-               .coherent_dma_mask      = DMA_BIT_MASK(32),
-               .platform_data          = NULL,
-       },
-};
+static struct platform_device *pd;
 
 void usb_nop_xceiv_register(void)
 {
-       if (platform_device_register(&nop_xceiv_device) < 0) {
+       if (pd)
+               return;
+       pd = platform_device_register_simple("nop_usb_xceiv", -1, NULL, 0);
+       if (!pd) {
                printk(KERN_ERR "Unable to register usb nop transceiver\n");
                return;
        }
 }
+EXPORT_SYMBOL(usb_nop_xceiv_register);
 
 void usb_nop_xceiv_unregister(void)
 {
-       platform_device_unregister(&nop_xceiv_device);
+       platform_device_unregister(pd);
 }
+EXPORT_SYMBOL(usb_nop_xceiv_unregister);
 
 static inline struct nop_usb_xceiv *xceiv_to_nop(struct otg_transceiver *x)
 {
index 1aaa826396a1462555925b871f22f95ff8870299..2443c0e7a80cd5e25ca77d217a0f5abbd2c1151e 100644 (file)
@@ -80,10 +80,10 @@ struct otg_transceiver {
 
 /* for board-specific init logic */
 extern int otg_set_transceiver(struct otg_transceiver *);
-#ifdef CONFIG_NOP_USB_XCEIV
+
+/* sometimes transceivers are accessed only through e.g. ULPI */
 extern void usb_nop_xceiv_register(void);
 extern void usb_nop_xceiv_unregister(void);
-#endif
 
 
 /* for usb host and peripheral controller drivers */