1 /* usbreset -- send a USB port reset to a USB device */
5 To install as suid binary use following commands:
8 cp usbreset /usr/local/bin/
9 sudo chown root /usr/local/bin/usbreset
10 sudo chmod 2755 /usr/local/bin/usbreset
14 http://marc.info/?l=linux-usb-users&m=116827193506484&w=2
16 and needs mounted usbfs filesystem
18 sudo mount -t usbfs none /proc/bus/usb
20 There is a way to suspend a USB device. In order to use it,
21 you must have a kernel with CONFIG_PM_SYSFS_DEPRECATED turned on. To
22 suspend a device, do (as root):
24 echo -n 2 >/sys/bus/usb/devices/.../power/state
26 where the "..." is the ID for your device. To unsuspend, do the same
27 thing but with a "0" instead of the "2" above.
29 Note that this mechanism is slated to be removed from the kernel within
30 the next year. Hopefully some other mechanism will take its place.
32 Here's a program to do it. You invoke it as either
34 usbreset /proc/bus/usb/BBB/DDD
38 depending on how your system is set up, where BBB and DDD are the bus and
39 device address numbers.
49 #include <sys/ioctl.h>
51 #include <linux/usbdevice_fs.h>
54 int main(int argc, char **argv)
61 fprintf(stderr, "Usage: usbreset device-filename\n");
66 fd = open(filename, O_WRONLY);
68 perror("Error opening output file");
72 printf("Resetting USB device %s\n", filename);
73 rc = ioctl(fd, USBDEVFS_RESET, 0);
75 perror("Error in ioctl");
78 printf("Reset successful\n");