overlay: Rename devicePath as busPath
It's the path to the sysfs directory representing an i2c bus, not a
device on that bus; let's name it to reflect that.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I1525f45cc2fd4a9690dc261fbe93ea734952057e
diff --git a/include/devices.hpp b/include/devices.hpp
index af89f16..4ac57ea 100644
--- a/include/devices.hpp
+++ b/include/devices.hpp
@@ -31,13 +31,13 @@
struct ExportTemplate
{
- ExportTemplate(const char* params, const char* dev, const char* constructor,
+ ExportTemplate(const char* params, const char* bus, const char* constructor,
const char* destructor, bool createsHWMon) :
parameters(params),
- devicePath(dev), add(constructor), remove(destructor),
+ busPath(bus), add(constructor), remove(destructor),
createsHWMon(createsHWMon){};
const char* parameters;
- const char* devicePath;
+ const char* busPath;
const char* add;
const char* remove;
bool createsHWMon;
diff --git a/src/overlay.cpp b/src/overlay.cpp
index defa5ad..9bb53e7 100644
--- a/src/overlay.cpp
+++ b/src/overlay.cpp
@@ -114,7 +114,7 @@
}
}
-static int deleteDevice(const std::string& devicePath,
+static int deleteDevice(const std::string& busPath,
const std::shared_ptr<uint64_t>& address,
const std::string& destructor)
{
@@ -122,7 +122,7 @@
{
return -1;
}
- std::filesystem::path deviceDestructor(devicePath);
+ std::filesystem::path deviceDestructor(busPath);
deviceDestructor /= destructor;
std::ofstream deviceFile(deviceDestructor);
if (!deviceFile.good())
@@ -135,11 +135,11 @@
return 0;
}
-static int createDevice(const std::string& devicePath,
+static int createDevice(const std::string& busPath,
const std::string& parameters,
const std::string& constructor)
{
- std::filesystem::path deviceConstructor(devicePath);
+ std::filesystem::path deviceConstructor(busPath);
deviceConstructor /= constructor;
std::ofstream deviceFile(deviceConstructor);
if (!deviceFile.good())
@@ -153,7 +153,7 @@
return 0;
}
-static bool deviceIsCreated(const std::string& devicePath,
+static bool deviceIsCreated(const std::string& busPath,
const std::shared_ptr<uint64_t>& bus,
const std::shared_ptr<uint64_t>& address,
const bool retrying)
@@ -169,10 +169,10 @@
std::string busStr = std::to_string(*bus);
std::error_code ec;
- auto path = std::filesystem::recursive_directory_iterator(devicePath, ec);
+ auto path = std::filesystem::recursive_directory_iterator(busPath, ec);
if (ec)
{
- std::cerr << "Unable to open path " << devicePath << "\n";
+ std::cerr << "Unable to open path " << busPath << "\n";
return false;
}
for (; path != std::filesystem::recursive_directory_iterator(); path++)
@@ -212,7 +212,7 @@
if (retrying)
{
std::error_code ec;
- std::filesystem::path hwmonDir(devicePath);
+ std::filesystem::path hwmonDir(busPath);
hwmonDir /= directoryName;
hwmonDir /= "hwmon";
return std::filesystem::is_directory(hwmonDir, ec);
@@ -224,7 +224,7 @@
return false;
}
-static int buildDevice(const std::string& devicePath,
+static int buildDevice(const std::string& busPath,
const std::string& parameters,
const std::shared_ptr<uint64_t>& bus,
const std::shared_ptr<uint64_t>& address,
@@ -238,15 +238,15 @@
return -1;
}
- if (!deviceIsCreated(devicePath, bus, address, false))
+ if (!deviceIsCreated(busPath, bus, address, false))
{
- createDevice(devicePath, parameters, constructor);
+ createDevice(busPath, parameters, constructor);
tryAgain = true;
}
- else if (createsHWMon && !deviceIsCreated(devicePath, bus, address, true))
+ else if (createsHWMon && !deviceIsCreated(busPath, bus, address, true))
{
// device is present, hwmon subdir missing
- deleteDevice(devicePath, address, destructor);
+ deleteDevice(busPath, address, destructor);
tryAgain = true;
}
@@ -255,7 +255,7 @@
std::shared_ptr<boost::asio::steady_timer> createTimer =
std::make_shared<boost::asio::steady_timer>(io);
createTimer->expires_after(std::chrono::milliseconds(500));
- createTimer->async_wait([createTimer, devicePath, parameters, bus,
+ createTimer->async_wait([createTimer, busPath, parameters, bus,
address, constructor, destructor, createsHWMon,
retries](const boost::system::error_code& ec) {
if (ec)
@@ -263,7 +263,7 @@
std::cerr << "Timer error: " << ec << "\n";
return -2;
}
- return buildDevice(devicePath, parameters, bus, address,
+ return buildDevice(busPath, parameters, bus, address,
constructor, destructor, createsHWMon,
retries - 1);
});
@@ -277,7 +277,7 @@
{
std::string parameters = exportTemplate.parameters;
- std::string devicePath = exportTemplate.devicePath;
+ std::string busPath = exportTemplate.busPath;
std::string constructor = exportTemplate.add;
std::string destructor = exportTemplate.remove;
bool createsHWMon = exportTemplate.createsHWMon;
@@ -320,11 +320,11 @@
}
boost::replace_all(parameters, templateChar + keyPair.key(),
subsituteString);
- boost::replace_all(devicePath, templateChar + keyPair.key(),
+ boost::replace_all(busPath, templateChar + keyPair.key(),
subsituteString);
}
- int err = buildDevice(devicePath, parameters, bus, address, constructor,
+ int err = buildDevice(busPath, parameters, bus, address, constructor,
destructor, createsHWMon);
if (!err && boost::ends_with(type, "Mux") && bus && address && channels)