diff options
author | Jon Medhurst <tixy@linaro.org> | 2014-04-10 09:02:02 +0100 |
---|---|---|
committer | Jon Medhurst <tixy@linaro.org> | 2014-04-10 12:11:17 +0100 |
commit | 15ce78dafc08b1c5c3ec8f42070ae37160b5154c (patch) | |
tree | cdb25c6758ac3fe5ac6f9e151642a4779e2fc742 /tools/gator/daemon/Hwmon.cpp | |
parent | 34d9769988397a1edf93ad1966c167591ab29e79 (diff) |
gator: Version 5.18
Signed-off-by: Jon Medhurst <tixy@linaro.org>
Diffstat (limited to 'tools/gator/daemon/Hwmon.cpp')
-rw-r--r-- | tools/gator/daemon/Hwmon.cpp | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/tools/gator/daemon/Hwmon.cpp b/tools/gator/daemon/Hwmon.cpp index 1d7c0da9cc83..778f30755dfe 100644 --- a/tools/gator/daemon/Hwmon.cpp +++ b/tools/gator/daemon/Hwmon.cpp @@ -1,5 +1,5 @@ /** - * Copyright (C) ARM Limited 2013. All rights reserved. + * Copyright (C) ARM Limited 2013-2014. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -17,7 +17,7 @@ class HwmonCounter { public: - HwmonCounter(HwmonCounter *next, int key, const sensors_chip_name *chip, const sensors_feature *feature); + HwmonCounter(HwmonCounter *next, const sensors_chip_name *chip, const sensors_feature *feature); ~HwmonCounter(); HwmonCounter *getNext() const { return next; } @@ -69,7 +69,7 @@ private: HwmonCounter &operator=(const HwmonCounter &); }; -HwmonCounter::HwmonCounter(HwmonCounter *next, int key, const sensors_chip_name *chip, const sensors_feature *feature) : next(next), key(key), polled(false), readable(false), enabled(false), duplicate(false), chip(chip), feature(feature) { +HwmonCounter::HwmonCounter(HwmonCounter *next, const sensors_chip_name *chip, const sensors_feature *feature) : next(next), key(getEventKey()), polled(false), readable(false), enabled(false), duplicate(false), chip(chip), feature(feature) { int len = sensors_snprintf_chip_name(NULL, 0, chip) + 1; char *chip_name = new char[len]; @@ -205,6 +205,23 @@ bool HwmonCounter::canRead() { } Hwmon::Hwmon() : counters(NULL) { +} + +Hwmon::~Hwmon() { + while (counters != NULL) { + HwmonCounter * counter = counters; + counters = counter->getNext(); + delete counter; + } + sensors_cleanup(); +} + +void Hwmon::setup() { + // hwmon does not currently work with perf + if (gSessionData->perf.isSetup()) { + return; + } + int err = sensors_init(NULL); if (err) { logg->logMessage("Failed to initialize libsensors! (%d)", err); @@ -218,20 +235,11 @@ Hwmon::Hwmon() : counters(NULL) { int feature_nr = 0; const sensors_feature *feature; while ((feature = sensors_get_features(chip, &feature_nr))) { - counters = new HwmonCounter(counters, getEventKey(), chip, feature); + counters = new HwmonCounter(counters, chip, feature); } } } -Hwmon::~Hwmon() { - while (counters != NULL) { - HwmonCounter * counter = counters; - counters = counter->getNext(); - delete counter; - } - sensors_cleanup(); -} - HwmonCounter *Hwmon::findCounter(const Counter &counter) const { for (HwmonCounter * hwmonCounter = counters; hwmonCounter != NULL; hwmonCounter = hwmonCounter->getNext()) { if (hwmonCounter->canRead() && strcmp(hwmonCounter->getName(), counter.getType()) == 0) { @@ -271,14 +279,18 @@ void Hwmon::setupCounter(Counter &counter) { counter.setKey(hwmonCounter->getKey()); } -void Hwmon::writeCounters(mxml_node_t *root) const { +int Hwmon::writeCounters(mxml_node_t *root) const { + int count = 0; for (HwmonCounter * counter = counters; counter != NULL; counter = counter->getNext()) { if (!counter->canRead()) { continue; } mxml_node_t *node = mxmlNewElement(root, "counter"); mxmlElementSetAttr(node, "name", counter->getName()); + ++count; } + + return count; } void Hwmon::writeEvents(mxml_node_t *root) const { |