From patchwork Mon Sep 17 14:34:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: rajagopal.venkat@linaro.org X-Patchwork-Id: 11461 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id D0FD923EB4 for ; Mon, 17 Sep 2012 14:36:22 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 19F0DA18DB6 for ; Mon, 17 Sep 2012 14:36:21 +0000 (UTC) Received: by ieak11 with SMTP id k11so9283829iea.11 for ; Mon, 17 Sep 2012 07:36:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=deNVkSFRoiSeIauNkInK8izECe5xlt9UzNqgvG0TJNQ=; b=cYTOIAJXON1iuGSjTGwB3P2cLP/GQQ7RWFzuGIj4JMinUyUmu474HugbftPyokmSY+ 1ZlmwcabjvQLwjy8o/L2YK143RhZHNFBsYu40E0X8VMvqengD42a4jtzUSbghIhnB1Wj oW4NNYWTP0osFvoqD5aCaTfiSky+W7BcKfS0ySaWAyQ6FZQDCc0KRudV1uqWipGdAVbO I99gjLSrWgspIHYfe7Wnm0xSiaG5gwYLbC4PyVsXUIQzqr6SPxPNzZX4RvFStbnV7Wn5 9Xz8H0u7KQnu4aAGw0JIVTcASFgZ3kOVeJ9EfnPD1z2I43G2jFNCaCRlqO4MeBSvDkAd i15Q== Received: by 10.42.109.194 with SMTP id m2mr8987216icp.48.1347892581064; Mon, 17 Sep 2012 07:36:21 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp319218igc; Mon, 17 Sep 2012 07:36:20 -0700 (PDT) Received: by 10.68.226.167 with SMTP id rt7mr22785443pbc.146.1347892579573; Mon, 17 Sep 2012 07:36:19 -0700 (PDT) Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by mx.google.com with ESMTPS id gh6si15849989pbc.177.2012.09.17.07.36.18 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 07:36:19 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) client-ip=209.85.160.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.50 is neither permitted nor denied by best guess record for domain of rajagopal.venkat@linaro.org) smtp.mail=rajagopal.venkat@linaro.org Received: by pbcmd12 with SMTP id md12so10449068pbc.37 for ; Mon, 17 Sep 2012 07:36:18 -0700 (PDT) Received: by 10.68.237.3 with SMTP id uy3mr23001682pbc.30.1347892578575; Mon, 17 Sep 2012 07:36:18 -0700 (PDT) Received: from localhost.localdomain ([101.62.98.60]) by mx.google.com with ESMTPS id ty1sm7025415pbc.76.2012.09.17.07.36.14 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 17 Sep 2012 07:36:17 -0700 (PDT) From: Rajagopal Venkat To: powertop@lists.01.org Cc: patches@linaro.org, linaro-dev@lists.linaro.org, rajagopal.venkat@linaro.org Subject: [Powertop][PATCH 1/2] Updates to support Android platform Date: Mon, 17 Sep 2012 20:04:08 +0530 Message-Id: <1347892449-10484-1-git-send-email-rajagopal.venkat@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmxraLBESvwBgc4a+L0xOclcky8iUVJjrq+QPuQD15xawy+34eGTxrBOcncrryxS/4a7TWx This patch adds following minor changes to prepare powertop to support Android platform. - add missing HAVE_CONFIG_H conditional check. - remove un-used ethtool_cmd_speed_set and ethtool_cmd_speed functions. - minimize dependency on exception handling in catch blocks. These changes will not affect powertop functionality. Signed-off-by: Rajagopal Venkat --- src/devices/ahci.cpp | 4 ++-- src/devices/alsa.cpp | 4 ++-- src/devices/network.cpp | 16 ---------------- src/lib.cpp | 2 +- src/main.cpp | 2 ++ src/process/do_process.cpp | 4 ++-- 6 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/devices/ahci.cpp b/src/devices/ahci.cpp index 1fe39c7..67ce06e 100644 --- a/src/devices/ahci.cpp +++ b/src/devices/ahci.cpp @@ -170,7 +170,7 @@ void ahci::start_measurement(void) file.close(); } catch (std::ios_base::failure &c) { - fprintf(stderr, "%s\n", c.what()); + fprintf(stderr, "Failed to start measurement for ahci device\n"); } } @@ -203,7 +203,7 @@ void ahci::end_measurement(void) file.close(); } catch (std::ios_base::failure &c) { - fprintf(stderr, "%s\n", c.what()); + fprintf(stderr, "Failed to end measurement for ahci device\n"); } if (end_active < start_active) end_active = start_active; diff --git a/src/devices/alsa.cpp b/src/devices/alsa.cpp index 4f5d3f9..a67780c 100644 --- a/src/devices/alsa.cpp +++ b/src/devices/alsa.cpp @@ -104,7 +104,7 @@ void alsa::start_measurement(void) file.close(); } catch (std::ios_base::failure &c) { - fprintf(stderr, "%s\n", c.what()); + fprintf(stderr, "Failed to start measurement for alsa device\n"); } } @@ -130,7 +130,7 @@ void alsa::end_measurement(void) file.close(); } catch (std::ios_base::failure &c) { - fprintf(stderr, "%s\n", c.what()); + fprintf(stderr, "Failed to end measurement for alsa device\n"); } p = (end_active - start_active) / (0.001 + end_active + end_inactive - start_active - start_inactive) * 100.0; diff --git a/src/devices/network.cpp b/src/devices/network.cpp index b8a5c9c..ed9d7aa 100644 --- a/src/devices/network.cpp +++ b/src/devices/network.cpp @@ -55,22 +55,6 @@ extern "C" { static map nics; -#ifdef DISABLE_TRYCATCH - -static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep, - __u32 speed) -{ - - ep->speed = (__u16)speed; - ep->speed_hi = (__u16)(speed >> 16); -} - -static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep) -{ - return (ep->speed_hi << 16) | ep->speed; -} - -#endif static void do_proc_net_dev(void) { diff --git a/src/lib.cpp b/src/lib.cpp index 9838c0b..776a67b 100644 --- a/src/lib.cpp +++ b/src/lib.cpp @@ -259,7 +259,7 @@ void format_watts(double W, char *buffer, unsigned int len) if (W < 0.0001) sprintf(buffer, _(" 0 mW")); - while (mbstowcs(NULL,buffer,0) < len) + while (mbstowcs(NULL,buffer,len) < len) strcat(buffer, " "); } diff --git a/src/main.cpp b/src/main.cpp index 1815075..dc49dba 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -42,7 +42,9 @@ #include "perf/perf.h" #include "perf/perf_bundle.h" #include "lib.h" +#ifdef HAVE_CONFIG_H #include "../config.h" +#endif #include "devices/device.h" diff --git a/src/process/do_process.cpp b/src/process/do_process.cpp index eaef7f1..c9d6b0b 100644 --- a/src/process/do_process.cpp +++ b/src/process/do_process.cpp @@ -869,7 +869,7 @@ void process_update_display(void) if (!show_power) strcpy(power, " "); sprintf(name, "%s", all_power[i]->type()); - while (mbstowcs(NULL,name,0) < 14) strcat(name, " "); + while (mbstowcs(NULL,name,20) < 14) strcat(name, " "); if (all_power[i]->events() == 0 && all_power[i]->usage() == 0 && all_power[i]->Witts() == 0) @@ -882,7 +882,7 @@ void process_update_display(void) else sprintf(usage, "%5i%s", (int)all_power[i]->usage(), all_power[i]->usage_units()); } - while (mbstowcs(NULL,usage,0) < 14) strcat(usage, " "); + while (mbstowcs(NULL,usage,20) < 14) strcat(usage, " "); sprintf(events, "%5.1f", all_power[i]->events()); if (!all_power[i]->show_events()) events[0] = 0;