From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
Long Li <longli@microsoft.com>, Wei Hu <weh@microsoft.com>
Subject: [PATCH 4/9] bus/vmbus: use common sysfs routines
Date: Fri, 11 Sep 2026 23:30:23 -0700 [thread overview]
Message-ID: <20260912063319.4117869-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20260912063319.4117869-1-stephen@networkplumber.org>
Replace the open coded read in vmbus_uio_sysfs_read() with the EAL
routine. The range check and the -ERANGE return are unchanged.
Two things do change. On an open failure the helper now returns -EIO
rather than -errno; both callers only pass it to strerror(-err) in a
log message, so this is message text only. And subchannel_id and
monitor_id were read with fscanf("%u") and are now converted with
base 0, so a value with a leading zero would parse as octal. Neither
attribute is printed with leading zeros by the kernel.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
drivers/bus/vmbus/linux/vmbus_uio.c | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/drivers/bus/vmbus/linux/vmbus_uio.c b/drivers/bus/vmbus/linux/vmbus_uio.c
index fbafc5027d..50e58f9b65 100644
--- a/drivers/bus/vmbus/linux/vmbus_uio.c
+++ b/drivers/bus/vmbus/linux/vmbus_uio.c
@@ -18,6 +18,7 @@
#include <rte_malloc.h>
#include <rte_bus_vmbus.h>
#include <rte_string_fns.h>
+#include <rte_sysfs.h>
#include "private.h"
@@ -334,27 +335,12 @@ int vmbus_uio_map_rings(struct vmbus_channel *chan)
static int vmbus_uio_sysfs_read(const char *dir, const char *name,
unsigned long *val, unsigned long max_range)
{
- char path[PATH_MAX];
- FILE *f;
- int ret;
-
- snprintf(path, sizeof(path), "%s/%s", dir, name);
- f = fopen(path, "r");
- if (!f) {
- VMBUS_LOG(ERR, "can't open %s:%s",
- path, strerror(errno));
- return -errno;
+ if (rte_sysfs_parse_uint(val, "%s/%s", dir, name) < 0) {
+ VMBUS_LOG(ERR, "can't read %s/%s", dir, name);
+ return -EIO;
}
- if (fscanf(f, "%lu", val) != 1)
- ret = -EIO;
- else if (*val > max_range)
- ret = -ERANGE;
- else
- ret = 0;
- fclose(f);
-
- return ret;
+ return *val > max_range ? -ERANGE : 0;
}
static bool vmbus_uio_ring_present(const struct rte_vmbus_device *dev,
--
2.53.0
next prev parent reply other threads:[~2026-09-12 6:34 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-12 6:30 [PATCH 0/9] consolidate sysfs access Stephen Hemminger
2026-09-12 6:30 ` [PATCH 1/9] eal: add common sysfs value routines Stephen Hemminger
2026-09-12 6:30 ` [PATCH 2/9] dma/idxd: use common sysfs routines Stephen Hemminger
2026-09-12 6:30 ` [PATCH 3/9] common/ionic: " Stephen Hemminger
2026-09-12 6:30 ` Stephen Hemminger [this message]
2026-09-12 6:30 ` [PATCH 5/9] power: " Stephen Hemminger
2026-09-12 6:30 ` [PATCH 6/9] drivers/bus: remove duplicate sysfs string helpers Stephen Hemminger
2026-09-12 6:30 ` [PATCH 7/9] common/mlx5: use common sysfs routines Stephen Hemminger
2026-09-12 6:30 ` [PATCH 8/9] net/mlx5: " Stephen Hemminger
2026-09-12 6:30 ` [PATCH 9/9] net/mana: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 0/9] consolidate sysfs access Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 1/9] eal: add common sysfs value routines Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 2/9] dma/idxd: use common sysfs routines Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 3/9] common/ionic: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 4/9] bus/vmbus: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 5/9] power: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 6/9] drivers/bus: remove duplicate sysfs string helpers Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 7/9] common/mlx5: use common sysfs routines Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 8/9] net/mlx5: " Stephen Hemminger
2026-09-12 17:02 ` [PATCH v2 9/9] net/mana: " Stephen Hemminger
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=20260912063319.4117869-5-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=longli@microsoft.com \
--cc=weh@microsoft.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox