* [Accel-config] [PATCH v1 2/6] accel-config: Allow other functionality if mdev support unavailable
@ 2021-01-23 5:35 ramesh.thomas
0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2021-01-23 5:35 UTC (permalink / raw)
To: accel-config
[-- Attachment #1: Type: text/plain, Size: 1805 bytes --]
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
In older drivers mdev is not supported. To provide backward
compatibility disable mdev if not supported and allow other
functionality.
Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
accfg/lib/libaccfg.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index b1de896..69f0f71 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -568,7 +568,11 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
goto err_dev_path;
}
free(device->mdev_path);
- device->mdev_path = p;
+ if (access(p, R_OK)) {
+ free(p);
+ device->mdev_path = NULL;
+ } else
+ device->mdev_path = p;
device->device_buf = calloc(1, strlen(device->device_path) +
MAX_PARAM_LEN);
@@ -583,7 +587,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
if (rc < 0)
goto err_dev_path;
- if (add_device_mdevs(ctx, device))
+ if (device->mdev_path && add_device_mdevs(ctx, device))
goto err_dev_path;
list_add_tail(&ctx->devices, &device->list);
@@ -1012,6 +1016,9 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device,
unsigned int version;
int rc;
+ if (!device->mdev_path)
+ return -ENOENT;
+
if (type >= ACCFG_MDEV_TYPE_UNKNOWN || type < 0)
return -EINVAL;
@@ -1069,6 +1076,9 @@ ACCFG_EXPORT int accfg_remove_mdev(struct accfg_device *device, uuid_t uuid)
struct accfg_device_mdev *entry, *next;
int rc, all;
+ if (!device->mdev_path)
+ return -ENOENT;
+
/* remove all mdevs if null uuid is passed */
all = uuid_is_null(uuid);
list_for_each_safe(&device->mdev_list, entry, next, list) {
--
2.26.2
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-23 5:35 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-23 5:35 [Accel-config] [PATCH v1 2/6] accel-config: Allow other functionality if mdev support unavailable ramesh.thomas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.