The attached patch doesn't suggest enabling USB suspend when a device is active
100% of the time, but autosuspend is already enabled.

-- 

  Felipe Sateler
diff -Nru ../powertop-1.10/urbnum.c ./urbnum.c
--- ../powertop-1.10/urbnum.c	2008-06-10 16:18:45.000000000 -0400
+++ ./urbnum.c	2008-06-28 18:47:10.000000000 -0400
@@ -40,6 +40,7 @@
 	char pathname[4096];
 	char human_name[4096];
 	uint64_t urbs, active, connected;
+	int autosuspend;
 	uint64_t previous_urbs, previous_active, previous_connected;
 	int controller;
 };
@@ -84,6 +85,13 @@
 			fgets(name, 4096, file);
 			ptr->connected = strtoull(name, NULL, 10);
 			fclose(file);
+			sprintf(fullpath, "%s/power/autosuspend", path);
+			file = fopen(fullpath, "r");
+			if (!file)
+				return;
+			fgets(name, 4096, file);
+			ptr->autosuspend = strtoull(name, NULL, 10);
+			fclose(file);
 
 			return;
 		}
@@ -201,7 +209,8 @@
 	total_active = 0;
 	dev = devices;
 	while (dev) {
-		if (dev->active-1 > dev->previous_active && !dev->controller) {
+		if (dev->active-1 > dev->previous_active
+				&& !dev->controller && dev->autosuspend < 0) {
 			if (total_active == pick) {
 				char usb_hint[8000];
 				sprintf(usb_hint, _("A USB device is active %4.1f%% of the time:\n%s"),
diff -Nru ../powertop-1.10/usb.patch ./usb.patch
--- ../powertop-1.10/usb.patch	1969-12-31 21:00:00.000000000 -0300
+++ ./usb.patch	2008-06-28 18:48:39.000000000 -0400
@@ -0,0 +1,35 @@
+diff -Nru ../powertop-1.10/urbnum.c ./urbnum.c
+--- ../powertop-1.10/urbnum.c	2008-06-10 16:18:45.000000000 -0400
++++ ./urbnum.c	2008-06-28 18:47:10.000000000 -0400
+@@ -40,6 +40,7 @@
+ 	char pathname[4096];
+ 	char human_name[4096];
+ 	uint64_t urbs, active, connected;
++	int autosuspend;
+ 	uint64_t previous_urbs, previous_active, previous_connected;
+ 	int controller;
+ };
+@@ -84,6 +85,13 @@
+ 			fgets(name, 4096, file);
+ 			ptr->connected = strtoull(name, NULL, 10);
+ 			fclose(file);
++			sprintf(fullpath, "%s/power/autosuspend", path);
++			file = fopen(fullpath, "r");
++			if (!file)
++				return;
++			fgets(name, 4096, file);
++			ptr->autosuspend = strtoull(name, NULL, 10);
++			fclose(file);
+ 
+ 			return;
+ 		}
+@@ -201,7 +209,8 @@
+ 	total_active = 0;
+ 	dev = devices;
+ 	while (dev) {
+-		if (dev->active-1 > dev->previous_active && !dev->controller) {
++		if (dev->active-1 > dev->previous_active
++				&& !dev->controller && dev->autosuspend < 0) {
+ 			if (total_active == pick) {
+ 				char usb_hint[8000];
+ 				sprintf(usb_hint, _("A USB device is active %4.1f%% of the time:\n%s"),

_______________________________________________
Power mailing list
[email protected]
http://www.bughost.org/mailman/listinfo/power

Reply via email to