diff options
author | Matt Spinler <spinler@us.ibm.com> | 2017-11-29 15:18:05 -0600 |
---|---|---|
committer | Matt Spinler <spinler@us.ibm.com> | 2017-11-29 15:26:51 -0600 |
commit | fee106b9bf94e9a393c7c44b53b7cc5d9f89b439 (patch) | |
tree | bc98557a70c36d365dd6868bf4df95942cfb54ae | |
parent | 67ce4a46999012eba2a0015a51619f474967d21c (diff) | |
download | phosphor-hwmon-fee106b9bf94e9a393c7c44b53b7cc5d9f89b439.tar.gz phosphor-hwmon-fee106b9bf94e9a393c7c44b53b7cc5d9f89b439.zip |
Support reading 64 bit integers
Some sysfs *_input values may be bigger than 32 bits,
for example power values reported in microwatts. As such,
read an int64_t value out of sysfs instead of just a uint32_t.
The D-Bus property that will hold the value is also the same
type, an int64_t.
Resolves openbmc/openbmc#2686
Change-Id: I4376de120825b73580d18d339fe76be454eeb18d
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
-rw-r--r-- | mainloop.cpp | 6 | ||||
-rw-r--r-- | sysfs.cpp | 4 | ||||
-rw-r--r-- | sysfs.hpp | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/mainloop.cpp b/mainloop.cpp index 61de673..2aa9e0f 100644 --- a/mainloop.cpp +++ b/mainloop.cpp @@ -154,7 +154,7 @@ auto getAttributes(const std::string& type, Attributes& attributes) return true; } -int adjustValue(const SensorSet::key_type& sensor, int value) +int64_t adjustValue(const SensorSet::key_type& sensor, int64_t value) { const auto& it = sensorAdjusts.find(sensor); if (it != sensorAdjusts.end()) @@ -179,7 +179,7 @@ auto addValue(const SensorSet::key_type& sensor, auto& obj = std::get<Object>(info); auto& objPath = std::get<std::string>(info); - auto val = 0; + int64_t val = 0; try { // Retry for up to a second if device is busy @@ -405,7 +405,7 @@ void MainLoop::run() if (attrs.find(hwmon::entry::input) != attrs.end()) { // Read value from sensor. - int value; + int64_t value; try { // Retry for up to a second if device is busy @@ -254,14 +254,14 @@ HwmonIO::HwmonIO(const std::string& path) : p(path) } -uint32_t HwmonIO::read( +int64_t HwmonIO::read( const std::string& type, const std::string& id, const std::string& sensor, size_t retries, std::chrono::milliseconds delay) const { - uint32_t val; + int64_t val; std::ifstream ifs; auto fullPath = sysfs::make_sysfs_path( p, type, id, sensor); @@ -107,7 +107,7 @@ class HwmonIO * * @return val - The read value. */ - uint32_t read( + int64_t read( const std::string& type, const std::string& id, const std::string& sensor, |