Skip to contentSkip to conversation

accel-config: Skip writing driver_name attr if not present

PATCH In review Ramesh Thomas 2 participants 2 messages Mar 29, 2022

lore
Share & tools
lore

Ramesh Thomas

author
#0 lore raw

PATCH 1/1 accel-config: Skip writing driver_name attr if not present

Older drivers do not create driver_name attr. Skip writing driver_name instead of failing if not present.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
accfg/lib/libaccfg.c +5 -1
index b4a9725..6af5802 100644
@@ -2459,7 +2459,11 @@ ACCFG_EXPORT int accfg_wq_set_str_##field( \
 			return -errno; \
 		} \
 	} \
-	if (sysfs_write_attr(ctx, path, buf) < 0) { \
+	rc = sysfs_write_attr(ctx, path, buf); \
+	if (rc < 0) { \
+		/* Silently skip attrs not supported by driver */ \
+		if (rc == -ENOENT && !strcmp(#field, "driver_name")) \
+			return 0; \
 		err(ctx, "%s: write failed: %s\n", \
 				accfg_wq_get_devname(wq), \
 				strerror(errno)); \
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Ramesh Thomas

Older drivers do not create driver_name attr. Skip writing driver_name instead of failing if not present.

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 21 lines
---
  accfg/lib/libaccfg.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
accfg/lib/libaccfg.c +5 -1
index b4a9725..6af5802 100644
@@ -2459,7 +2459,11 @@ ACCFG_EXPORT int accfg_wq_set_str_##field( \
  			return -errno; \
  		} \
  	} \
-	if (sysfs_write_attr(ctx, path, buf) < 0) { \
+	rc = sysfs_write_attr(ctx, path, buf); \
+	if (rc < 0) { \
+		/* Silently skip attrs not supported by driver */ \
+		if (rc == -ENOENT && !strcmp(#field, "driver_name")) \
+			return 0; \
  		err(ctx, "%s: write failed: %s\n", \
  				accfg_wq_get_devname(wq), \
  				strerror(errno)); \