All of lore.kernel.org
 help / color / mirror / Atom feed
From: ramesh.thomas at intel.com
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH v1 2/6] accel-config: Allow other functionality if mdev support unavailable
Date: Sat, 23 Jan 2021 00:35:38 -0500	[thread overview]
Message-ID: <20210123053542.615622-3-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20210123053542.615622-1-ramesh.thomas@intel.com

[-- 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

                 reply	other threads:[~2021-01-23  5:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210123053542.615622-3-ramesh.thomas@intel.com \
    --to=accel-config@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.