/* * * usbd_proc_write - implement proc file system write. * @file * @buf * @count * @pos * * Proc file system write function, used to signal monitor actions complete. * (Hotplug script (or whatever) writes to the file to signal the completion * of the script.) An ugly hack. */ static ssize_t usbd_proc_write (struct file *file, const char *buf, size_t count, loff_t * pos) { struct usb_device_instance *device; size_t n = count; char command[64]; char *cp = command; int i = 0; MOD_INC_USE_COUNT; //printk(KERN_DEBUG "%s: count=%u\n",__FUNCTION__,count); while ((n > 0) && (i < 64)) { // Not too efficient, but it shouldn't matter if (copy_from_user (cp++, buf + (count - n), 1)) { count = -EFAULT; break; } *cp = '\0'; i++; n -= 1; //printk(KERN_DEBUG "%s: %u/%u %02x\n",__FUNCTION__,count-n,count,c); } if (!strncmp (command, "plug", 4)) { udc_connect (); } else if (!strncmp (command, "unplug", 6)) { udc_disconnect (); if ((device = device_array[0])) { usbd_device_event (device, DEVICE_RESET, 0); } } MOD_DEC_USE_COUNT; return (count); }
/* bi_modexit - decommission bus interface driver */ void __exit bi_modexit(void) { struct usb_bus_instance *bus; struct usb_device_instance *device; struct bi_data *data; dbgENTER(dbgflg_usbdbi_init,1); if ((device = device_array[0])) { // XXX moved to usbd_deregister_device() //device->status = USBD_CLOSING; udc_disconnect(); udc_disable(); // XXX XXX if (dbgflg_usbdbi_tick > 0) { ticker_killoff(); } bus = device->bus; data = bus->privdata; // XXX usbd_device_event(device, DEVICE_RESET, 0); usbd_device_event(device, DEVICE_POWER_INTERRUPTION, 0); usbd_device_event(device, DEVICE_HUB_RESET, 0); dbg_init(1,"DEVICE_DESTROY"); usbd_device_event(device, DEVICE_DESTROY, 0); dbg_init(1,"DISABLE ENDPOINTS"); bi_disable_endpoints(device); dbg_init(1,"UDC_DISABLE"); //udc_disable(); dbg_init(1,"BI_UDC_EXIT"); bi_udc_exit(); device_array[0] = NULL; bus->privdata = NULL; #ifdef CONFIG_PM dbg_init(1,"PM_UNREGISTER(pm_dev#%p)",pm_dev); if (pm_dev) { pm_unregister(pm_dev); } #endif dbg_init(1,"DEREGISTER DEVICE"); usbd_deregister_device(device); bus->device = NULL; dbg_init(1,"kfree(data#%p)",data); if (data) { kfree(data); } if (bus->serial_number_str) { kfree(bus->serial_number_str); } dbg_init(1,"DEREGISTER BUS"); usbd_deregister_bus(bus); } else { dbg_init(0,"device is NULL"); } dbg_init(1,"BI_EXIT"); bi_exit(); dbgLEAVE(dbgflg_usbdbi_init,1); }