1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-16 00:00:02 +01:00
VILLASnode/common/lib/kernel/devices/linux_driver.cpp
Pascal Bauer 914ea0bac6 Refactor FPGA device and drivers
Signed-off-by: Pascal Bauer <pascal.bauer@rwth-aachen.de>
2024-10-31 12:18:20 +01:00

40 lines
1.1 KiB
C++

/* Implementation of driver interface for Linux/Unix based operation system drivers.
*
* Author: Pascal Bauer <pascal.bauer@rwth-aachen.de>
*
* SPDX-FileCopyrightText: 2023-2024 Pascal Bauer <pascal.bauer@rwth-aachen.de>
* SPDX-License-Identifier: Apache-2.0
*/
#include <villas/kernel/devices/linux_driver.hpp>
#include <villas/kernel/devices/device.hpp>
#include <villas/utils.hpp>
using villas::kernel::devices::Device, villas::kernel::devices::LinuxDriver;
using villas::utils::write_to_file;
void LinuxDriver::attach(const Device &device) const {
if (device.driver().has_value()) {
device.driver().value()->unbind(device);
}
this->override(device);
device.probe();
}
void LinuxDriver::bind(const Device &device) const {
write_to_file(device.name(), this->bind_path);
}
std::string LinuxDriver::name() const {
size_t pos = path.u8string().rfind('/');
return path.u8string().substr(pos + 1);
}
void LinuxDriver::override(const Device &device) const {
write_to_file(this->name(), device.override_path());
}
void LinuxDriver::unbind(const Device &device) const {
write_to_file(device.name(), this->unbind_path);
}