/* pcd_ocd_modexit - module exit or init failure cleanup * * Specifically for each driver: * * call ops.mod_exit * reset instance address and ops table address in state machine to NULL * invalidate tag */ static void pcd_ocd_modexit (void) { struct otg_instance *otg = ocd_instance->otg; printk(KERN_INFO"%s\n", __FUNCTION__); if (otg) otg_exit(otg); if (pcd_ops.mod_exit) pcd_ops.mod_exit(); pcd_instance = otg_set_pcd_ops(NULL); PCD = otg_trace_invalidate_tag(PCD); if (ocd_ops.mod_exit) ocd_ops.mod_exit(); ocd_instance = otg_set_ocd_ops(NULL); OCD = otg_trace_invalidate_tag(OCD); }
/*! * mouse_cf_modinit() - module init * * This is called by the Linux kernel; either when the module is loaded * if compiled as a module, or during the system intialization if the * driver is linked into the kernel. * * This function will parse module parameters if required and then register * the mouse driver with the USB Device software. * */ static int mouse_cf_modinit (void) { int i; printk (KERN_INFO "%s: vendor_id: %04x product_id: %04x\n", __FUNCTION__, vendor_id, product_id); #if !defined(OTG_C99) mouse_cf_global_init(); mouse_cf_ops_init(); #endif /* defined(OTG_C99) */ MOUSE = otg_trace_obtain_tag(); TRACE_MSG2(MOUSE, "vendor_id: %04x product_id: %04x",vendor_id, product_id); //if (vendor_id) // mouse_composite_driver.idVendor = cpu_to_le16(vendor_id); //if (product_id) // mouse_composite_driver.idProduct = cpu_to_le16(product_id); // register as usb function driver TRACE_MSG0(MOUSE, "REGISTER COMPOSITE"); THROW_IF (usbd_register_composite_function (&mouse_composite_driver, "mouse-random-cf", NULL, mouse_arg_list, NULL), error); TRACE_MSG0(MOUSE, "REGISTER FINISHED"); CATCH(error) { otg_trace_invalidate_tag(MOUSE); return -EINVAL; } return 0; }
/*! * generic_cf_modexit() - module init * * This is called by the Linux kernel; when the module is being unloaded * if compiled as a module. This function is never called if the * driver is linked into the kernel. * * @param void * @return void */ static void generic_cf_modexit (void) { int i; otg_trace_invalidate_tag(GENERIC); for (i = 0; ; i++) { struct generic_config *config = generic_configs + i; BREAK_UNLESS(config->interface_names); //printk(KERN_INFO"%s: %s registered: %d\n", // __FUNCTION__, config->composite_driver.driver.name, config->registered); CONTINUE_UNLESS(config->registered); usbd_deregister_composite_function (&config->composite_driver); if (config->interface_list) LKFREE(config->interface_list); } if (generic_config.registered) usbd_deregister_composite_function (&generic_config.composite_driver); if (generic_config.interface_list) LKFREE(generic_config.interface_list); }
/*! * otg_pci_remove() - pci remove function */ void __devexit otg_pci_remove (struct pci_dev *pci_dev) { struct otg_dev *otg_dev = pci_get_drvdata(pci_dev); printk(KERN_INFO"%s:\n", __FUNCTION__); pci_set_drvdata(pci_dev, NULL); /* call subsidiary drivers remove functions */ if (otg_dev) { if (otg_devs == otg_dev) { otg_devs = otg_dev->next; } else { struct otg_dev *link; for (link = otg_devs; link; link = otg_dev->next) { if (link->next == otg_dev) { link->next = otg_dev->next; break; } } } free_irq(pci_dev->irq, otg_dev); otg_pci_free_dev(pci_dev, otg_dev); otg_trace_invalidate_tag(otg_dev->PCI); kfree(otg_dev); } pci_disable_device(pci_dev); }
/*! acm_l26_modexit - module cleanup * * This is called prior to the module being unloaded. */ static void acm_l26_modexit (void) { /* de-register as tty and usb drivers */ tty_l26_exit(); tty_if_exit(); otg_trace_invalidate_tag(TTY); }
/*! * zasevb_modexit() - This is used as module exit, and as cleanup if modinit fails. */ static void zasevb_modexit (void) { struct otg_instance *otg = ocd_instance->otg; //struct pcd_instance *pcd = (struct pcd_instance *)otg->pcd; //struct usbd_bus_instance *bus= pcd->bus; TRACE_MSG0(ZAS, "Modules exit!"); if (otg) otg_exit(otg); mxc_procfs_exit(); /* Disable GPT */ #if defined(CONFIG_OTG_GPTR) mxc_gptcr_mod_exit(); #endif /* defined(CONFIG_OTG_GPTR) */ #if defined(CONFIG_OTG_HRT) mxc_hrt_mod_exit(); #endif /* defined(CONFIG_OTG_GPTR) */ #ifdef OTG_USE_I2C TRACE_MSG0(ZAS, "0. I2C"); i2c_mod_exit(otg); #endif #if !defined(CONFIG_USB_HOST) if (pcd_ops.mod_exit) pcd_ops.mod_exit(otg); REMOVE_pcd_instance = otg_set_pcd_ops(otg, NULL); #else /* !defined(CONFIG_USB_HOST) */ printk(KERN_INFO"%s: PCD DRIVER N/A\n", __FUNCTION__); #endif /* !defined(CONFIG_USB_HOST) */ #if defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) if (hcd_ops.mod_exit) hcd_ops.mod_exit(otg); hcd_instance = otg_set_hcd_ops(otg, NULL); //HCD = otg_trace_invalidate_tag(HCD); #else /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */ printk(KERN_INFO"%s: HCD DRIVER N/A\n", __FUNCTION__); #endif /* defined(CONFIG_OTG_USB_HOST) || defined(CONFIG_OTG_USB_PERIPHERAL_OR_HOST)|| defined(CONFIG_OTG_DEVICE) */ if (tcd_ops.mod_exit) tcd_ops.mod_exit(otg); printk(KERN_INFO"%s: set_tcd_ops\n", __FUNCTION__); REMOVE_tcd_instance = otg_set_tcd_ops(otg, NULL); //REMOVE_TCD = otg_trace_invalidate_tag(REMOVE_TCD); if (ocd_ops.mod_exit) ocd_ops.mod_exit(otg); ocd_instance = otg_set_ocd_ops(otg, NULL); ZAS = otg_trace_invalidate_tag(ZAS); otg_destroy(otg); }
/*! mcpc_l26_modexit - module cleanup * * This is called prior to the module being unloaded. */ STATIC void mcpc_l26_modexit (void) { /* de-register as tty and usb drivers */ tty_l26_exit(); /* de-register as function driver via acm-fd */ atcom_if_exit(); obex_if_exit(); dun_if_exit(); otg_trace_invalidate_tag(TTY); }
/*! acm_l26_modinit - module init * * This is called immediately after the module is loaded or during * the kernel driver initialization if linked into the kernel. * */ static int acm_l26_modinit (void) { BOOL tty_l26 = FALSE, tty_if = FALSE; int minor_numbers=1; /* register tty and usb interface function drivers */ TTY = otg_trace_obtain_tag(); THROW_UNLESS(tty_l26 = BOOLEAN(!tty_l26_init(ACM_DRIVER_PROCFS_NAME, ACM_TTY_MINORS)), error); THROW_UNLESS(tty_if = BOOLEAN(!tty_if_init()), error); CATCH(error) { if (tty_l26) tty_l26_exit(); if (tty_if) tty_if_exit(); otg_trace_invalidate_tag(TTY); return -EINVAL; } return 0; }
/*! mcpc_l26_modinit - module init * * This is called immediately after the module is loaded or during * the kernel driver initialization if linked into the kernel. * */ STATIC int mcpc_l26_modinit (void) { BOOL tty_l26 = FALSE, dun_if = FALSE, obex_if = FALSE, atcom_if = FALSE; TTY = otg_trace_obtain_tag(); THROW_UNLESS (tty_l26 = BOOLEAN(!tty_l26_init("mcpc_if", 6)), error); THROW_UNLESS (tty_l26 = BOOLEAN(!dun_if_init()), error); THROW_UNLESS (tty_l26 = BOOLEAN(!obex_if_init()), error); THROW_UNLESS (tty_l26 = BOOLEAN(!atcom_if_init()), error); CATCH(error) { printk(KERN_ERR"%s: ERROR\n", __FUNCTION__); if (tty_l26) tty_l26_exit(); if (dun_if) dun_if_exit(); if (obex_if) obex_if_exit(); if (atcom_if) atcom_if_exit(); otg_trace_invalidate_tag(TTY); return -EINVAL; } return 0; }
/*! * mouse_cf_modexit() - module init * * This is called by the Linux kernel; when the module is being unloaded * if compiled as a module. This function is never called if the * driver is linked into the kernel. * * @param void * @return void */ static void mouse_cf_modexit (void) { usbd_deregister_composite_function (&mouse_composite_driver); otg_trace_invalidate_tag(MOUSE); }
/*! * inteltest_cl_device_request - called to process a request to endpoint or interface * @param function * @param request * @return non-zero for failure, will cause endpoint zero stall */ static int inteltest_cl_device_request (struct usbd_function_instance *function, struct usbd_device_request *request) { struct usbd_urb *urb; u16 wLength = le16_to_cpu(request->wLength); TRACE_MSG5(GCLASS, "bmRequestType: %02x bRequest: %02x wValue: %04x wIndex: %04x wLength: %04x", request->bmRequestType, request->bRequest, request->wValue, request->wIndex, request->wLength); /* XXX it should be this, need to verify */ RETURN_EINVAL_UNLESS(USB_REQ_RECIPIENT_DEVICE == (request->bmRequestType & USB_REQ_RECIPIENT_MASK)); switch (ctrl->bRequest) { switch (request->bmRequestType & USB_REQ_DIRECTION_MASK) { case USB_REQ_DEVICE2HOST: switch (request->bRequest) { case 0x5c: /* read test */ RETURN_EINVAL_UNLESS((urb = usbd_alloc_urb_ep0 (function, wLength, NULL))); RETURN_ZERO_UNLESS(rc || usbd_start_in_urb(urb)); break; } break; case USB_REQ_HOST2DEVICE: switch (request->bRequest) { case 0x5b: /* write test */ RETURN_EINVAL_UNLESS((urb = usbd_alloc_urb_ep0 (function, wLength, NULL))); RETURN_ZERO_UNLESS(rc || usbd_start_out_urb(urb)); break; } break; } return -EINVAL; } /* ********************************************************************************************* */ #if !defined(OTG_C99) /*! function_ops - operations table for the USB Device Core */ static struct usbd_function_operations inteltest_function_ops; /*! inteltest_class_driver - USB Device Core function driver definition */ struct usbd_class_driver inteltest_class_driver; #else /* defined(OTG_C99) */ /*! function_ops - operations table for the USB Device Core */ static struct usbd_function_operations inteltest_function_ops = { .device_request = inteltest_cl_device_request, /*!< called for each received device request */ }; /*! inteltest_class_driver - USB Device Core function driver definition */ struct usbd_class_driver inteltest_class_driver = { .driver.name = "inteltest-class", /*!< driver name */ .driver.fops = &inteltest_function_ops, /*!< operations table */ }; #endif /* defined(OTG_C99) */ /* USB Module init/exit ***************************************************** */ //#if OTG_EPILOGUE /*! * inteltest_cl_modexit() - module init * * This is called by the Linux kernel; when the module is being unloaded * if compiled as a module. This function is never called if the * driver is linked into the kernel. * @return none */ static void inteltest_cl_modexit (void) { usbd_deregister_class_function (&inteltest_class_driver); otg_trace_invalidate_tag(GCLASS); } module_exit (inteltest_cl_modexit); //#endif /*! * inteltest_cl_modinit() - module init * * This is called by the Linux kernel; either when the module is loaded * if compiled as a module, or during the system intialization if the * driver is linked into the kernel. * * This function will parse module parameters if required and then register * the inteltest driver with the USB Device software. * */ static int inteltest_cl_modinit (void) { #if !defined(OTG_C99) /*! function_ops - operations table for the USB Device Core */ ZERO(inteltest_function_ops); inteltest_function_ops.device_request=inteltest_cl_device_request; /*! called for each received device request */ /*! class_driver - USB Device Core function driver definition */ ZERO(inteltest_class_driver); inteltest_class_driver.driver.name = "inteltest-class"; /*! driver name */ inteltest_class_driver.driver.fops = &inteltest_function_ops; /*! operations table */ #endif /* defined(OTG_C99) */ GCLASS = otg_trace_obtain_tag(NULL, "inteltest-cf"); // register as usb function driver TRACE_MSG0(GCLASS, "REGISTER CLASS"); THROW_IF (usbd_register_class_function (&inteltest_class_driver, "inteltest-class", NULL), error); TRACE_MSG0(GCLASS, "REGISTER FINISHED"); CATCH(error) { inteltest_cl_modexit(); return -EINVAL; } return 0; }
/*! * generic_cf_register() * */ void generic_cf_register(struct generic_config *config, char *match) { char *cp, *sp, *lp; int i; char **interface_list = NULL; int interfaces = 0; //printk(KERN_INFO"%s: Driver: \"%s\" idVendor: %04x idProduct: %04x interface_names: \"%s\" match: \"%s\"\n", // __FUNCTION__, // config->composite_driver.driver.name, MODPARM(idVendor), MODPARM(idProduct), config->interface_names, // match ? match : ""); TRACE_MSG5(GENERIC, "Driver: \"%s\" idVendor: %04x idProduct: %04x interface_names: \"%s\" match: \"%s\"", config->composite_driver.driver.name, MODPARM(idVendor), MODPARM(idProduct), config->interface_names, match ? match : ""); RETURN_IF (match && strlen(match) && strcmp(match, config->composite_driver.driver.name)); //printk(KERN_INFO"%s: MATCHED\n", __FUNCTION__); /* decompose interface names to construct interface_list */ RETURN_UNLESS (config->interface_names && strlen(config->interface_names)); /* count interface names and allocate _interface_names array */ for (cp = sp = config->interface_names, interfaces = 0; cp && *cp; ) { for (; *cp && *cp == ':'; cp++); // skip white space sp = cp; // save start of token for (; *cp && *cp != ':'; cp++); // find end of token BREAK_IF (sp == cp); if (*cp) cp++; interfaces++; } THROW_UNLESS(interfaces, error); TRACE_MSG1(GENERIC, "interfaces: %d", interfaces); THROW_UNLESS((interface_list = (char **) CKMALLOC (sizeof (char *) * (interfaces + 1), GFP_KERNEL)), error); for (cp = sp = config->interface_names, interfaces = 0; cp && *cp; interfaces++) { for (; *cp && *cp == ':'; cp++); // skip white space sp = cp; // save start of token for (; *cp && *cp != ':'; cp++); // find end of token BREAK_IF (sp == cp); lp = cp; if (*cp) cp++; *lp = '\0'; lp = CKMALLOC(strlen(sp), GFP_KERNEL); strcpy(lp, sp); interface_list[interfaces] = lp; TRACE_MSG3(GENERIC, "INTERFACE[%2d] %x \"%s\"", interfaces, interface_list[interfaces], interface_list[interfaces]); } config->composite_driver.device_description = &config->device_description; config->composite_driver.configuration_description = &config->configuration_description; config->composite_driver.driver.fops = &generic_function_ops; config->interface_list = interface_list; THROW_IF (usbd_register_composite_function ( &config->composite_driver, config->composite_driver.driver.name, config->class_name, config->interface_list, NULL), error); config->registered++; TRACE_MSG0(GENERIC, "REGISTER FINISHED"); CATCH(error) { otg_trace_invalidate_tag(GENERIC); } }
/*! * generic_cl_modexit() - module init * * This is called by the Linux kernel; when the module is being unloaded * if compiled as a module. This function is never called if the * driver is linked into the kernel. * @return none */ static void generic_cl_modexit (void) { usbd_deregister_class_function (&generic_class_driver); otg_trace_invalidate_tag(GCLASS); }