static int ohci_hcd_rt3xxx_drv_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); usb_hcd_rt3xxx_remove(hcd, pdev); #ifdef REMOVE if(!usb_find_device(0x0, 0x0)) // No any other USB host controller. try_sleep(); #endif return 0; }
static int rt3xxx_ehci_remove(struct platform_device *pdev) { struct usb_hcd *hcd = platform_get_drvdata(pdev); /* ehci_shutdown() is supposed to be called implicitly in ehci-hcd common code while removing module, but it isn't. */ ehci_shutdown(hcd); usb_remove_hcd(hcd); iounmap(hcd->regs); release_mem_region(hcd->rsrc_start, hcd->rsrc_len); usb_put_hcd(hcd); if(!usb_find_device(0x0, 0x0)) // No any other USB host controller. try_sleep(); return 0; }
static int rootplug_bprm_check_security (struct linux_binprm *bprm) { struct usb_device *dev; root_dbg("file %s, e_uid = %d, e_gid = %d\n", bprm->filename, bprm->cred->euid, bprm->cred->egid); if (bprm->cred->egid == 0) { dev = usb_find_device(vendor_id, product_id); if (!dev) { root_dbg("e_gid = 0, and device not found, " "task not allowed to run...\n"); return -EPERM; } usb_put_dev(dev); } return 0; }
static void PopulateListBox (int deviceId) { Device *device; char *string; char *tempString; int configNum; int interfaceNum; int endpointNum; int deviceNumber = (deviceId >> 8); int busNumber = (deviceId & 0x00ff); GtkTextIter begin; GtkTextIter end; device = usb_find_device (deviceNumber, busNumber); if (device == NULL) { printf ("Can't seem to find device info to display\n"); return; } /* clear the textbox */ gtk_text_buffer_get_start_iter(textDescriptionBuffer,&begin); gtk_text_buffer_get_end_iter(textDescriptionBuffer,&end); gtk_text_buffer_delete (textDescriptionBuffer, &begin, &end); /* freeze the display */ /* this keeps the annoying scroll from happening */ gtk_widget_freeze_child_notify(textDescriptionView); string = (char *)g_malloc (1000); /* add the name to the textbox if we have one*/ if (device->name != NULL) { gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, device->name,strlen(device->name)); } /* add the manufacturer if we have one */ if (device->manufacturer != NULL) { sprintf (string, "\nManufacturer: %s", device->manufacturer); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); } /* add the serial number if we have one */ if (device->serialNumber != NULL) { sprintf (string, "\nSerial Number: %s", device->serialNumber); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); } /* add speed */ switch (device->speed) { case 1 : tempString = "1.5Mb/s (low)"; break; case 12 : tempString = "12Mb/s (full)"; break; case 480 : tempString = "480Mb/s (high)"; break; /* planning ahead... */ default : tempString = "unknown"; break; } sprintf (string, "\nSpeed: %s", tempString); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); /* add ports if available */ if (device->maxChildren) { sprintf (string, "\nNumber of Ports: %i", device->maxChildren); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); } /* add the bandwidth info if available */ if (device->bandwidth != NULL) { sprintf (string, "\nBandwidth allocated: %i / %i (%i%%)", device->bandwidth->allocated, device->bandwidth->total, device->bandwidth->percent); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); sprintf (string, "\nTotal number of interrupt requests: %i", device->bandwidth->numInterruptRequests); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); sprintf (string, "\nTotal number of isochronous requests: %i", device->bandwidth->numIsocRequests); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); } /* add the USB version, device class, subclass, protocol, max packet size, and the number of configurations (if it is there) */ if (device->version) { sprintf (string, "\nUSB Version: %s\nDevice Class: %s\nDevice Subclass: %s\nDevice Protocol: %s\n" "Maximum Default Endpoint Size: %i\nNumber of Configurations: %i", device->version, device->class, device->subClass, device->protocol, device->maxPacketSize, device->numConfigs); gtk_text_buffer_insert_at_cursor(textDescriptionBuffer, string,strlen(string)); }