rocr: Make Open() and Close() virtual in Driver

Change-Id: Iac054c08383b080ca2b2ec6d65019bf2f083b763
This commit is contained in:
Tony Gutierrez
2024-11-08 16:40:21 -08:00
committed by David Yat Sin
parent 8bbc44d51b
commit 77fa5af618
7 changed files with 40 additions and 32 deletions
@@ -42,9 +42,6 @@
#include "core/inc/driver.h"
#include <fcntl.h>
#include <unistd.h>
#include "inc/hsa.h"
namespace rocr {
@@ -54,27 +51,5 @@ Driver::Driver(DriverType kernel_driver_type, std::string devnode_name)
: kernel_driver_type_(std::move(kernel_driver_type)),
devnode_name_(std::move(devnode_name)) {}
hsa_status_t Driver::Open()
{
fd_ = open(devnode_name_.c_str(), O_RDWR | O_CLOEXEC);
if (fd_ < 0) {
return HSA_STATUS_ERROR_OUT_OF_RESOURCES;
}
return HSA_STATUS_SUCCESS;
}
hsa_status_t Driver::Close()
{
int ret(0);
if (fd_ > 0) {
ret = close(fd_);
fd_ = -1;
}
if (ret) {
return HSA_STATUS_ERROR;
}
return HSA_STATUS_SUCCESS;
}
} // namespace core
} // namespace rocr