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/argument.cpp b/argument.cpp
index 4cab8a8..170bb8f 100644
--- a/argument.cpp
+++ b/argument.cpp
@@ -62,17 +62,19 @@
std::cerr << "Options:\n";
std::cerr << " --help print this menu\n";
std::cerr << " --path=<path> sysfs location to monitor\n";
+ std::cerr << " --of-name=<path> open firmware device name to monitor\n";
std::cerr << std::flush;
}
const option ArgumentParser::options[] =
{
{ "path", required_argument, NULL, 'p' },
+ { "of-name", required_argument, NULL, 'o' },
{ "help", no_argument, NULL, 'h' },
{ 0, 0, 0, 0},
};
-const char* ArgumentParser::optionstr = "p:?h";
+const char* ArgumentParser::optionstr = "o:p:?h";
const std::string ArgumentParser::true_string = "true";
const std::string ArgumentParser::empty_string = "";
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.