blob: a74baafac7dec8215b06bb0974e520d5007bfb7e [file] [log] [blame]
Brad Bishop26b815f2017-01-04 13:32:47 -05001#pragma once
Patrick Williams3667cf32015-10-20 22:39:11 -05002
3#include <fstream>
4#include <string>
5
Brad Bishopa9b5f052017-01-17 14:50:08 -05006inline std::string make_sysfs_path(const std::string& path,
7 const std::string& type,
8 const std::string& id,
9 const std::string& entry)
Patrick Williams3667cf32015-10-20 22:39:11 -050010{
11 using namespace std::literals;
12
13 return path + "/"s + type + id + "_"s + entry;
14}
15
Brad Bishop613a5b32017-01-05 20:58:13 -050016
17/** @brief Find hwmon instances
18 *
19 * Look for a matching hwmon instance given an
20 * open firmware device path.
21 *
22 * @param[in] ofNode- The open firmware device path.
23 *
24 * @returns[in] - The hwmon instance path or an empty
25 * string if no match is found.
26 */
27std::string findHwmon(const std::string& ofNode);
28
Brad Bishop4db64422017-02-16 11:33:32 -050029/** @brief Read an hwmon sysfs value.
30 *
31 * Calls exit(3) with bad status on failure.
32 *
33 * @param[in] root - The hwmon class root.
34 * @param[in] instance - The hwmon instance (ex. hwmon1).
35 * @param[in] type - The hwmon type (ex. temp).
36 * @param[in] id - The hwmon id (ex. 1).
37 * @param[in] sensor - The hwmon sensor (ex. input).
38 *
39 * @returns - The read value.
40 */
41int readSysfsWithCallout(const std::string& root,
42 const std::string& instance,
43 const std::string& type,
44 const std::string& id,
45 const std::string& sensor);
46
Brad Bishop03476f12016-12-19 13:09:12 -050047// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4