diff options
| author | Matt Spinler <spinler@us.ibm.com> | 2018-03-05 12:07:46 -0600 |
|---|---|---|
| committer | Matt Spinler <spinler@us.ibm.com> | 2018-03-07 13:16:15 -0600 |
| commit | 147b0337b36e58604fbdd517f71f97a4dae725c1 (patch) | |
| tree | 2a7c65ad82c18413816b4f9861bc110798070598 /readd.cpp | |
| parent | 626df17a5e2b7fecbdfa36045cdd19efda667f81 (diff) | |
| download | phosphor-hwmon-147b0337b36e58604fbdd517f71f97a4dae725c1.tar.gz phosphor-hwmon-147b0337b36e58604fbdd517f71f97a4dae725c1.zip | |
Find hwmon path based on input path type
If the input path starts with /devices, find the hwmon path
using the findHwmonFromDevPath function, otherwise use
findHwmonFromOFPath.
Also change the argument name to something more generic.
Did not change the argument's short name so the service
file isn't coupled to this change.
Tested: Tested with both paths.
Change-Id: I5feb8a897fc86117b102ce44584ed977282cb955
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Diffstat (limited to 'readd.cpp')
| -rw-r--r-- | readd.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -34,10 +34,19 @@ int main(int argc, char** argv) auto options = std::make_unique<ArgumentParser>(argc, argv); // Parse out path argument. - auto path = (*options)["of-name"]; + auto path = (*options)["dev-path"]; if (path != ArgumentParser::empty_string) { - path = sysfs::findHwmonFromOFPath(path); + // This path may either be a device path (starts with + // /devices), or an open firmware device tree path. + if (path.substr(0, 8) == "/devices") + { + path = sysfs::findHwmonFromDevPath(path); + } + else + { + path = sysfs::findHwmonFromOFPath(path); + } } if (path == ArgumentParser::empty_string) |

