From: Sergey Senozhatsky <sergey.senozhatsky at gmail.com>
To: powertop@lists.01.org
Subject: Re: [Powertop] [PATCH 1/1] tunables: check usb autosuspend support before add
Date: Sun, 24 Aug 2014 13:30:39 +0900 [thread overview]
Message-ID: <20140824043039.GA935@swordfish> (raw)
In-Reply-To: 1408850533-5008-2-git-send-email-nanleychery@gmail.com
[-- 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
>
next reply other threads:[~2014-08-24 4:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-24 4:30 Sergey Senozhatsky [this message]
-- strict thread matches above, loose matches on Subject: below --
2014-08-24 3:22 [Powertop] [PATCH 1/1] tunables: check usb autosuspend support before add Nanley Chery
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140824043039.GA935@swordfish \
--to=powertop@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.