All of lore.kernel.org
 help / color / mirror / Atom feed
* [Powertop] [PATCH 1/1] tunables: check usb autosuspend support before add
@ 2014-08-24  3:22 Nanley Chery
  0 siblings, 0 replies; 2+ messages in thread
From: Nanley Chery @ 2014-08-24  3:22 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1531 bytes --]

Some usb devices do not have drivers that support autosuspend.
These drivers should not be added to the list of tunables, because
toggling their good/bad value does nothing.

Signed-off-by: Nanley Chery <nanleychery(a)gmail.com>
---
 src/tuning/tuningusb.cpp | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp
index 27a6dca..ee86335 100644
--- a/src/tuning/tuningusb.cpp
+++ b/src/tuning/tuningusb.cpp
@@ -28,6 +28,7 @@
 #include "unistd.h"
 #include "tuningusb.h"
 #include <string.h>
+#include <dirent.h>
 #include <utility>
 #include <iostream>
 #include <fstream>
@@ -126,6 +127,25 @@ static void add_usb_callback(const char *d_name)
 	if (access(filename, R_OK)!=0)
 		return;
 
+	/* every interface of this device should support autosuspend */
+	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
+	DIR *dir = opendir(filename);
+	if (!dir)
+		return;
+	while (1) {
+		struct dirent *entry = readdir(dir);
+		if (!entry)
+			break;
+		if (entry->d_name[0] == '.')
+			continue;
+		sprintf(filename, "/sys/bus/usb/devices/%s/%s/supports_autosuspend", d_name, entry->d_name);
+		bool intf_path_found;
+		bool intf_supports_auto = read_sysfs(filename, &intf_path_found);
+		if (intf_path_found && !intf_supports_auto)
+			return;
+	}
+	closedir(dir);
+
 	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
 	usb = new class usb_tunable(filename, d_name);
 	all_tunables.push_back(usb);
-- 
2.0.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Powertop] [PATCH 1/1] tunables: check usb autosuspend support before add
@ 2014-08-24  4:30 Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2014-08-24  4:30 UTC (permalink / raw)
  To: powertop

[-- Attachment #1: Type: text/plain, Size: 1669 bytes --]

On (08/23/14 23:22), Nanley Chery wrote:
> ---
>  src/tuning/tuningusb.cpp | 20 ++++++++++++++++++++
>  1 file changed, 20 insertions(+)
> 
> diff --git a/src/tuning/tuningusb.cpp b/src/tuning/tuningusb.cpp
> index 27a6dca..ee86335 100644
> --- a/src/tuning/tuningusb.cpp
> +++ b/src/tuning/tuningusb.cpp
> @@ -28,6 +28,7 @@
>  #include "unistd.h"
>  #include "tuningusb.h"
>  #include <string.h>
> +#include <dirent.h>
>  #include <utility>
>  #include <iostream>
>  #include <fstream>
> @@ -126,6 +127,25 @@ static void add_usb_callback(const char *d_name)
>  	if (access(filename, R_OK)!=0)
>  		return;
>  
> +	/* every interface of this device should support autosuspend */
> +	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
> +	DIR *dir = opendir(filename);
> +	if (!dir)
> +		return;
> +	while (1) {
> +		struct dirent *entry = readdir(dir);
> +		if (!entry)
> +			break;
> +		if (entry->d_name[0] == '.')
> +			continue;
> +		sprintf(filename, "/sys/bus/usb/devices/%s/%s/supports_autosuspend", d_name, entry->d_name);
> +		bool intf_path_found;
> +		bool intf_supports_auto = read_sysfs(filename, &intf_path_found);
> +		if (intf_path_found && !intf_supports_auto)

			return; with dir open?

please consider to use process_directory() from lib.cpp

	-ss

> +	}
> +	closedir(dir);
> +
>  	sprintf(filename, "/sys/bus/usb/devices/%s", d_name);
>  	usb = new class usb_tunable(filename, d_name);
>  	all_tunables.push_back(usb);
> -- 
> 2.0.4
> 
> _______________________________________________
> PowerTop mailing list
> PowerTop(a)lists.01.org
> https://lists.01.org/mailman/listinfo/powertop
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-08-24  4:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-24  4:30 [Powertop] [PATCH 1/1] tunables: check usb autosuspend support before add Sergey Senozhatsky
  -- strict thread matches above, loose matches on Subject: below --
2014-08-24  3:22 Nanley Chery

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.