diff options
author | Brandon Wyman <bjwyman@gmail.com> | 2017-04-10 17:48:02 -0500 |
---|---|---|
committer | Brandon Wyman <bjwyman@gmail.com> | 2017-05-22 14:35:51 -0500 |
commit | ce822444460a6aef6538c36b9c74023c33e2fcae (patch) | |
tree | 7301de7ecab9828785dd534b20325c9049de982a /utility.hpp | |
parent | 8798854f0aab767edb8798fb014de5b4b9f7fae2 (diff) | |
download | phosphor-fan-presence-ce822444460a6aef6538c36b9c74023c33e2fcae.tar.gz phosphor-fan-presence-ce822444460a6aef6538c36b9c74023c33e2fcae.zip |
Implement changes to read GPIO device for cooling type.
Change-Id: If40a54510fb05d67ee0bfdf24026c1d7470897ca
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Diffstat (limited to 'utility.hpp')
-rw-r--r-- | utility.hpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/utility.hpp b/utility.hpp index 05fe60c..880545a 100644 --- a/utility.hpp +++ b/utility.hpp @@ -2,6 +2,8 @@ #include <sdbusplus/bus.hpp> #include <unistd.h> +#include <fcntl.h> + namespace phosphor { @@ -31,6 +33,21 @@ class FileDescriptor } } + int operator()() + { + return fd; + } + + void open(const std::string& pathname, int flags) + { + fd = ::open(pathname.c_str(), flags); + if (-1 == fd) + { + throw std::runtime_error( + "Failed to open file device: " + pathname); + } + } + bool is_open() { return fd != -1; |