mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-26 23:33:20 +08:00
In this Change: - Initialize local variables used in pci source. - Move setting of temperature handle's type to constructor of TemperatureImp class as temperature handle's type is used in init() of TemperatureImp class. - Allow only ENOENT errno at the end of FsAccess::listDirectory function. Because in this function all directory entries will be read in a loop. And loop will exit only after readdir() finished reading all entries in directory and thus readdir() will exit, when it fails reading any further entry. Thus system will return ENOENT for readdir. Change-Id: Ibd3ac3f841b114fd87edea1410750b33f3a14e5b Signed-off-by: Jitendra Sharma <jitendra.sharma@intel.com>
51 lines
1.3 KiB
C++
51 lines
1.3 KiB
C++
/*
|
|
* Copyright (C) 2020 Intel Corporation
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
*/
|
|
|
|
#include "level_zero/tools/source/sysman/temperature/temperature.h"
|
|
|
|
#include "level_zero/tools/source/sysman/temperature/temperature_imp.h"
|
|
|
|
namespace L0 {
|
|
|
|
TemperatureHandleContext::~TemperatureHandleContext() {
|
|
for (Temperature *pTemperature : handleList) {
|
|
delete pTemperature;
|
|
}
|
|
}
|
|
|
|
void TemperatureHandleContext::createHandle(zet_temp_sensors_t type) {
|
|
Temperature *pTemperature = new TemperatureImp(pOsSysman, type);
|
|
if (pTemperature->initSuccess == true) {
|
|
handleList.push_back(pTemperature);
|
|
} else {
|
|
delete pTemperature;
|
|
}
|
|
}
|
|
|
|
void TemperatureHandleContext::init() {
|
|
createHandle(ZET_TEMP_SENSORS_GLOBAL);
|
|
createHandle(ZET_TEMP_SENSORS_GPU);
|
|
}
|
|
|
|
ze_result_t TemperatureHandleContext::temperatureGet(uint32_t *pCount, zet_sysman_temp_handle_t *phTemperature) {
|
|
if (nullptr == phTemperature) {
|
|
*pCount = static_cast<uint32_t>(handleList.size());
|
|
return ZE_RESULT_SUCCESS;
|
|
}
|
|
uint32_t i = 0;
|
|
for (Temperature *temperature : handleList) {
|
|
if (i >= *pCount) {
|
|
break;
|
|
}
|
|
phTemperature[i++] = temperature->toHandle();
|
|
}
|
|
*pCount = i;
|
|
return ZE_RESULT_SUCCESS;
|
|
}
|
|
|
|
} // namespace L0
|