The feature 'isolate' isn't enabled for all 'uacce' versions. So need check whether this feature is enabled before read it value. Signed-off-by: Shen Yang shenyang39@huawei.com (cherry picked from commit 79f52670314c1137fe3170ce8950e88d8248cc5f)
61 lines
1.5 KiB
Diff
61 lines
1.5 KiB
Diff
From 3b86295963c24a1dc0ec0da9e1e7f16aced8f3a4 Mon Sep 17 00:00:00 2001
|
|
From: Yang Shen <shenyang39@huawei.com>
|
|
Date: Tue, 24 Aug 2021 11:24:25 +0800
|
|
Subject: [PATCH] uadk: 'access' the file 'isolate' before read it
|
|
|
|
The feature 'isolate' isn't enabled for all 'uacce' versions. So need check
|
|
whether this feature is enabled before read it value.
|
|
|
|
Signed-off-by: Yang Shen <shenyang39@huawei.com>
|
|
---
|
|
wd.c | 25 ++++++++++++++++++++++---
|
|
1 file changed, 22 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/uadk/wd.c b/uadk/wd.c
|
|
index 2d7fc49..bc347e7 100644
|
|
--- a/uadk/wd.c
|
|
+++ b/uadk/wd.c
|
|
@@ -104,17 +104,36 @@ static int get_str_attr(struct uacce_dev *dev, char *attr, char *buf,
|
|
return ret;
|
|
}
|
|
|
|
+static int access_attr(char *dev_root, char *attr, int mode)
|
|
+{
|
|
+ char attr_file[PATH_STR_SIZE];
|
|
+ ssize_t size;
|
|
+
|
|
+ if (!dev_root || !attr)
|
|
+ return -WD_EINVAL;
|
|
+
|
|
+ size = snprintf(attr_file, PATH_STR_SIZE, "%s/%s", dev_root, attr);
|
|
+ if (size < 0)
|
|
+ return -WD_EINVAL;
|
|
+
|
|
+ return access(attr_file, mode);
|
|
+}
|
|
+
|
|
static int get_dev_info(struct uacce_dev *dev)
|
|
{
|
|
int value = 0;
|
|
+ int ret;
|
|
|
|
get_int_attr(dev, "flags", &dev->flags);
|
|
get_str_attr(dev, "api", dev->api, WD_NAME_SIZE);
|
|
|
|
/* hardware err isolate flag */
|
|
- get_int_attr(dev, "isolate", &value);
|
|
- if (value == 1)
|
|
- return -ENODEV;
|
|
+ ret = access_attr(dev->dev_root, "isolate", F_OK);
|
|
+ if (!ret) {
|
|
+ get_int_attr(dev, "isolate", &value);
|
|
+ if (value == 1)
|
|
+ return -ENODEV;
|
|
+ }
|
|
|
|
get_str_attr(dev, "algorithms", dev->algs, MAX_ATTR_STR_SIZE);
|
|
get_int_attr(dev, "region_mmio_size", &value);
|
|
--
|
|
2.33.0
|
|
|