All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH v3 3/3] accel-config: Reset cmd_status during device init
@ 2021-07-14 17:17 ramesh.thomas
  0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2021-07-14 17:17 UTC (permalink / raw)
  To: accel-config

[-- Attachment #1: Type: text/plain, Size: 1400 bytes --]

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Initialize cmd_status at device init to avoid getting stale value
during error checks.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index 03dfc92..a430bed 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -152,6 +152,23 @@ static inline bool is_mdev_registered(struct accfg_device *device)
 	return device->mdev_path && !access(device->mdev_path, R_OK);
 }
 
+static int accfg_set_param(struct accfg_ctx *ctx, int dfd, char *name,
+		void *buf, int len)
+{
+	int fd = openat(dfd, name, O_RDWR);
+	int n;
+
+	if (fd == -1)
+		return -errno;
+
+	n = write(fd, buf, len);
+	close(fd);
+	if (n != len)
+		return -errno;
+
+	return 0;
+}
+
 static long accfg_get_param_long(struct accfg_ctx *ctx, int dfd, char *name)
 {
 	int fd = openat(dfd, name, O_RDONLY);
@@ -587,6 +604,12 @@ static void *add_device(void *parent, int id, const char *ctl_base,
 		return NULL;
 	}
 
+	if (accfg_set_param(ctx, dfd, "cmd_status", "1", 1)) {
+		err(ctx, "Failed resetting cmd status\n");
+		close(dfd);
+		goto err_device;
+	}
+
 	device = calloc(1, sizeof(*device));
 	if (!device) {
 		err(ctx, "allocation of device failed\n");
-- 
2.26.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-14 17:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-14 17:17 [Accel-config] [PATCH v3 3/3] accel-config: Reset cmd_status during device init 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.