summaryrefslogtreecommitdiffstats
path: root/file.hpp
diff options
context:
space:
mode:
authorMatt Spinler <spinler@us.ibm.com>2017-05-25 10:23:05 -0500
committerMatt Spinler <spinler@us.ibm.com>2017-05-30 15:25:31 -0500
commit36df1979f5c11d4e4dbe144b63f42390b6088f76 (patch)
tree42e97a07668e3f3ed7a4cc460e4888dd1e3d15bf /file.hpp
parent936a504319e01642fc5803c00ff4aa5baeafacef (diff)
downloadphosphor-gpio-monitor-36df1979f5c11d4e4dbe144b63f42390b6088f76.tar.gz
phosphor-gpio-monitor-36df1979f5c11d4e4dbe144b63f42390b6088f76.zip
Add GPIO class
This class is used for accessing a GPIO via the /dev/gpiochipX interface. It requests a GPIO line handle from the GPIO device to do the actual operation on. The GPIO number to use, for AST chips at least, is the actual GPIO number, such as GPIOA0 = 0 and GPIOA7 = 7. The class currently only supports writes. Change-Id: I1c2ae38c23c5db502d5f14bcf9aa2e35094f1e9b Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'file.hpp')
-rw-r--r--file.hpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/file.hpp b/file.hpp
index 9ba4cbb..ee8fd4b 100644
--- a/file.hpp
+++ b/file.hpp
@@ -15,7 +15,7 @@ class FileDescriptor
int fd = -1;
public:
- FileDescriptor() = delete;
+ FileDescriptor() = default;
FileDescriptor(const FileDescriptor&) = delete;
FileDescriptor& operator=(const FileDescriptor&) = delete;
FileDescriptor(FileDescriptor&&) = delete;
@@ -42,6 +42,16 @@ class FileDescriptor
{
return fd;
}
+
+ operator bool() const
+ {
+ return fd != -1;
+ }
+
+ void set(int descriptor)
+ {
+ fd = descriptor;
+ }
};
} // namespace gpio
OpenPOWER on IntegriCloud