From: Stephen Hemminger <stephen@networkplumber.org>
To: liwencheng <liwencheng@phytium.com.cn>
Cc: dev@dpdk.org
Subject: Re: [PATCH v4 1/4] usertools/dpdk-devbind: add bind/unbind for platform device
Date: Mon, 7 Apr 2025 08:13:23 -0700 [thread overview]
Message-ID: <20250407081323.757a7d5b@hermes.local> (raw)
In-Reply-To: <1743577112-119739-1-git-send-email-liwencheng@phytium.com.cn>
On Wed, 2 Apr 2025 06:58:32 +0000
liwencheng <liwencheng@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.
prev parent reply other threads:[~2025-04-07 15:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-02 6:58 liwencheng
2025-04-02 23:28 ` Stephen Hemminger
2025-04-03 1:42 ` Stephen Hemminger
2025-04-07 6:36 ` [PATCH v5 0/4] liwencheng
2025-04-07 18:22 ` Stephen Hemminger
2025-04-07 6:37 ` [PATCH v5 1/4] usertools/dpdk-devbind: add platform devices support liwencheng
2025-04-07 15:13 ` Stephen Hemminger [this message]
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=20250407081323.757a7d5b@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=liwencheng@phytium.com.cn \
/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;
as well as URLs for NNTP newsgroup(s).