From: Elbert Mai <code@elbertmai.com>
To: gregkh@linuxfoundation.org, linux-usb@vger.kernel.org
Cc: Elbert Mai <code@elbertmai.com>
Subject: [PATCH] usb: Clarify expected behavior of dev_bin_attrs_are_visible()
Date: Tue, 5 Mar 2024 16:15:03 -0800 [thread overview]
Message-ID: <20240306001503.313028-1-code@elbertmai.com> (raw)
The commit "usb: Export BOS descriptor to sysfs" added a binary attribute
group to sysfs. It doesn't check if the descriptors attribute should be
visible, which is by design and not an oversight. Update a comment so that
it better explains this in the dev_bin_attrs_are_visible() function.
Signed-off-by: Elbert Mai <code@elbertmai.com>
---
I had mistakenly written the entry as if it went into stable/sysfs-bus-usb
instead of testing/sysfs-bus-usb, so the "..." shouldn't be there. I see
you have already moved and corrected the bos_descriptors documentation, so
it should be all OK now.
drivers/usb/core/sysfs.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
index 777526f59720..f98263e21c2a 100644
--- a/drivers/usb/core/sysfs.c
+++ b/drivers/usb/core/sysfs.c
@@ -929,8 +929,11 @@ static umode_t dev_bin_attrs_are_visible(struct kobject *kobj,
struct device *dev = kobj_to_dev(kobj);
struct usb_device *udev = to_usb_device(dev);
- /* All USB devices have a device descriptor, so the descriptors
- * attribute always exists. No need to check for its visibility.
+ /*
+ * There's no need to check if the descriptors attribute should
+ * be visible because all devices have a device descriptor. The
+ * bos_descriptors attribute should be visible if and only if
+ * the device has a BOS, so check if it exists here.
*/
if (a == &bin_attr_bos_descriptors) {
if (udev->bos == NULL)
--
2.34.1
reply other threads:[~2024-03-06 0:15 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20240306001503.313028-1-code@elbertmai.com \
--to=code@elbertmai.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
/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).