From: ramesh.thomas at intel.com
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH v3 01/14] accel-config: Add mdev path to device context
Date: Sat, 05 Dec 2020 15:20:13 -0500 [thread overview]
Message-ID: <20201205202025.315186-2-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20201205202025.315186-1-ramesh.thomas@intel.com
[-- Attachment #1: Type: text/plain, Size: 2259 bytes --]
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
/sys/class/mdev_bus/<bdf> is used often to access mdevs associated
with the device. Generate and store in device so it need not be
constructed everytime.
Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
accfg/lib/libaccfg.c | 17 +++++++++++++++++
accfg/lib/private.h | 1 +
2 files changed, 18 insertions(+)
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index 3b53be3..8b35602 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -194,6 +194,7 @@ static void free_device(struct accfg_device *device, struct list_head *head)
list_del_from(head, &device->list);
free(device->device_path);
free(device->device_buf);
+ free(device->mdev_path);
free(device);
}
@@ -413,6 +414,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
char *path;
int dfd;
int rc;
+ char *p;
path = calloc(1, strlen(ctl_base) + MAX_PARAM_LEN);
if (!path) {
@@ -470,6 +472,20 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
goto err_dev_path;
}
+ device->mdev_path = strdup(device->device_path);
+ if (!device->mdev_path) {
+ err(ctx, "strdup of device_path failed\n");
+ goto err_dev_path;
+ }
+
+ if (asprintf(&p, "%s/%s", MDEV_BUS,
+ basename(dirname(device->mdev_path))) < 0) {
+ err(ctx, "device mdev_path allocation failed\n");
+ goto err_dev_path;
+ }
+ free(device->mdev_path);
+ device->mdev_path = p;
+
device->device_buf = calloc(1, strlen(device->device_path) +
MAX_PARAM_LEN);
if (!device->device_buf) {
@@ -490,6 +506,7 @@ static void *add_device(void *parent, int id, const char *ctl_base, char *dev_pr
err_dev_path:
err_read:
free(device->device_buf);
+ free(device->mdev_path);
free(device);
err_device:
free(path);
diff --git a/accfg/lib/private.h b/accfg/lib/private.h
index f38ff23..365d484 100644
--- a/accfg/lib/private.h
+++ b/accfg/lib/private.h
@@ -30,6 +30,7 @@ struct accfg_device {
struct list_node list;
int group_init;
char *device_path;
+ char *mdev_path;
char *device_buf;
char *device_type_str;
enum accfg_device_type type;
--
2.26.2
reply other threads:[~2020-12-05 20:20 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=20201205202025.315186-2-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.