-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathlinux_driver.cpp
More file actions
40 lines (32 loc) · 1.12 KB
/
linux_driver.cpp
File metadata and controls
40 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* 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);
}