summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-07-28 22:24:03 -0400
committerPatrick Williams <patrick@stwcx.xyz>2017-08-02 20:18:19 +0000
commit2e9788d72b27f372a0f3f214db08983656caec6b (patch)
treeaf7c3703a7a1aab232e0916ce171b7c4828ec5d3
parentd37c0f850a4cf5ccbfcce22006398797ed42179d (diff)
downloadphosphor-fan-presence-2e9788d72b27f372a0f3f214db08983656caec6b.zip
phosphor-fan-presence-2e9788d72b27f372a0f3f214db08983656caec6b.tar.gz
presence: Un-hardcode input device path
Allow a device path to be configured. Change-Id: I2eabd71747b124eae96738d1332f58b96ece6dc9 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
-rw-r--r--presence/example/example.yaml3
-rw-r--r--presence/gpio.cpp4
-rw-r--r--presence/gpio.hpp6
-rwxr-xr-xpresence/pfpgen.py1
-rw-r--r--presence/templates/gpio.mako.hpp2
5 files changed, 12 insertions, 4 deletions
diff --git a/presence/example/example.yaml b/presence/example/example.yaml
index 140e1ec..69a322b 100644
--- a/presence/example/example.yaml
+++ b/presence/example/example.yaml
@@ -37,6 +37,7 @@
- type: gpio
key: 123
physpath: /sys/devices/foo/bar
+ devpath: /dev/input/by-path/platform-gpio-keys-event
- name: Example Fan2
description: >
@@ -58,6 +59,7 @@
- type: gpio
key: 124
physpath: /sys/devices/foo/bar
+ devpath: /dev/input/by-path/platform-gpio-keys-polled-event
- type: tach
sensors:
- fan2
@@ -75,6 +77,7 @@
- type: gpio
key: 125
physpath: /sys/devices/foo/bar
+ devpath: /dev/input/by-path/platform-gpio-keys-polled-event
- type: tach
sensors:
- fan3
diff --git a/presence/gpio.cpp b/presence/gpio.cpp
index 28db46e..2a0a4c0 100644
--- a/presence/gpio.cpp
+++ b/presence/gpio.cpp
@@ -31,10 +31,10 @@ namespace presence
Gpio::Gpio(
const std::string& physDevice,
+ const std::string& device,
unsigned int physPin) :
currentState(false),
- evdevfd(open("/dev/input/by-path/platform-gpio-keys-event",
- O_RDONLY | O_NONBLOCK)),
+ evdevfd(open(device.c_str(), O_RDONLY | O_NONBLOCK)),
evdev(evdevpp::evdev::newFromFD(evdevfd())),
phys(physDevice),
pin(physPin),
diff --git a/presence/gpio.hpp b/presence/gpio.hpp
index e516e0f..978fdd9 100644
--- a/presence/gpio.hpp
+++ b/presence/gpio.hpp
@@ -41,9 +41,13 @@ class Gpio : public PresenceSensor
* @brief Construct a gpio sensor.
*
* @param[in] physDevice - The physical gpio device path.
+ * @param[in] device - The gpio-keys input device.
* @param[in] physPin - The physical gpio pin number.
*/
- Gpio(const std::string& physDevice, unsigned int physPin);
+ Gpio(
+ const std::string& physDevice,
+ const std::string& device,
+ unsigned int physPin);
/**
* @brief start
diff --git a/presence/pfpgen.py b/presence/pfpgen.py
index 00ba900..187be32 100755
--- a/presence/pfpgen.py
+++ b/presence/pfpgen.py
@@ -139,6 +139,7 @@ class Gpio(Sensor, Renderer):
def __init__(self, *a, **kw):
self.key = kw.pop('key')
self.physpath = kw.pop('physpath')
+ self.devpath = kw.pop('devpath')
kw['name'] = 'gpio-{}'.format(self.key)
super(Gpio, self).__init__(**kw)
diff --git a/presence/templates/gpio.mako.hpp b/presence/templates/gpio.mako.hpp
index fb1f46f..d2a25d8 100644
--- a/presence/templates/gpio.mako.hpp
+++ b/presence/templates/gpio.mako.hpp
@@ -1,2 +1,2 @@
std::make_unique<PolicyAccess<Gpio, ConfigPolicy>>(
-${indent(1)}${g.policy}, "${g.physpath}"s, ${g.key})\
+${indent(1)}${g.policy}, "${g.physpath}"s, "${g.devpath}"s, ${g.key})\
OpenPOWER on IntegriCloud