> -----Original Message-----
> From: Stephen Hemminger <[email protected]>
> Sent: Tuesday, September 15, 2026 1:36 AM
> To: [email protected]
> Cc: Stephen Hemminger <[email protected]>; Long Li
> <[email protected]>; Wei Hu <[email protected]>
> Subject: [EXTERNAL] [PATCH v3 4/9] bus/vmbus: use common sysfs routines
> 
> 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 <[email protected]>

Reviewed-by: Wei Hu <[email protected]>

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

Reply via email to