Add cmdline --of-name option
Add an option for passing hwmon instances via the open firmware
device path. This allows udev triggers based on the path.
Change-Id: Icffc9734208204a052dc2910500df88136590e7d
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/readd.cpp b/readd.cpp
index 1cc2894..8253d92 100644
--- a/readd.cpp
+++ b/readd.cpp
@@ -18,6 +18,7 @@
#include "argument.hpp"
#include "mainloop.hpp"
#include "config.h"
+#include "sysfs.hpp"
static void exit_with_error(const char* err, char** argv)
{
@@ -33,10 +34,20 @@
auto options = std::make_unique<ArgumentParser>(argc, argv);
// Parse out path argument.
- auto path = (*options)["path"];
+ auto path = (*options)["of-name"];
+ if (path != ArgumentParser::empty_string)
+ {
+ path = findHwmon(path);
+ }
+
if (path == ArgumentParser::empty_string)
{
- exit_with_error("Path not specified.", argv);
+ path = (*options)["path"];
+ }
+
+ if (path == ArgumentParser::empty_string)
+ {
+ exit_with_error("Path not specified or invalid.", argv);
}
// Finished getting options out, so cleanup the parser.