[PATCH v4 1/4] usertools/dpdk-devbind: add bind/unbind for platform device

Stephen Hemminger stephen at networkplumber.org
Mon Apr 7 17:13:23 CEST 2025


On Wed,  2 Apr 2025 06:58:32 +0000
liwencheng <liwencheng at phytium.com.cn> wrote:

>  
> +def unbind_platform_one(dev_name):
> +    filename = "/sys/bus/platform/devices/%s/driver" % dev_name
> +
> +    if exists(filename):
> +        try:
> +            f = open(os.path.join(filename, "unbind"), "w")
> +        except OSError as err:
> +            sys.exit("Error: unbind failed for %s - Cannot open %s: %s" %
> +                     (dev_name, os.path.join(filename, "unbind"), err))
> +        f.write(dev_name)
> +        f.close()
> +        filename = "/sys/bus/platform/devices/%s/driver_override" % dev_name
> +        try:
> +            f = open(filename, "w")
> +        except OSError as err:
> +            sys.exit("Error: unbind failed for %s - Cannot open %s: %s" %
> +                     (dev_name, filename, err))
> +        f.write("")
> +        f.close()
> +        print("Successfully unbind platform device %s" % dev_name)
> +

Although other parts of devbind don't use it, the current preferred Python
style is to use f' strings.

Also if you use a "with" block, then the close function is automatic.

Lastly, when I looked at adding vmbus support, it was rejected in favor
the more complete driverctl utility. So at least in theory, this patch
should be rejected, and the functionality moved to driverctl.


More information about the dev mailing list