[Fix] Reduce the maximum device nodes
authorDongju Chae <dongju.chae@samsung.com>
Mon, 12 Apr 2021 10:45:02 +0000 (19:45 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Tue, 13 Apr 2021 00:07:20 +0000 (09:07 +0900)
This patch fixes the routine checking device node availability.
The maximum device nodes is uncessarily too large (i.e., 255).

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
src/core/npu/NPUdrvAPI_triv2.cc

index 1193114..ce20b96 100644 (file)
@@ -13,7 +13,8 @@
 #include "NPUdrvAPI.h"
 #include <npubinfmt.h>
 
-constexpr int max_num_devs = ((1<<CHAR_BIT) - 1);
+/* Only 2 devices are supported for now. 8 will be enough value even in future */
+constexpr int max_num_devs = 8;
 constexpr size_t default_buf_size = (256 * PAGE_SIZE);
 
 const std::string TrinityVision2API::dev_node_base = "triv2";
@@ -114,7 +115,7 @@ TrinityVision2API::getNumDevices ()
   for (int i = 0; i < max_num_devs; ++i) {
     path = "/dev/" + TrinityVision2API::dev_node_base + "-" + std::to_string(i);
     ret = stat (path.c_str(), &sb);
-    if (!ret && S_ISCHR (sb.st_mode)) {
+    if (ret == 0 && S_ISCHR (sb.st_mode)) {
       cnt++;
       TrinityVision2API::dev_bitset.set(i);
     }