From: "Łukasz Bartosik" <ukaszb@chromium.org>
To: Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-usb@vger.kernel.org, "Łukasz Bartosik" <ukaszb@chromium.org>
Subject: [PATCH v1 4/4] xhci: dbc: allow to set manufacturer name through sysfs
Date: Mon, 29 Sep 2025 09:02:06 +0000 [thread overview]
Message-ID: <20250929090206.423937-5-ukaszb@google.com> (raw)
In-Reply-To: <20250929090206.423937-1-ukaszb@google.com>
From: Łukasz Bartosik <ukaszb@chromium.org>
Add code which allows to set manufacturer name of a DbC
device through sysfs.
Signed-off-by: Łukasz Bartosik <ukaszb@chromium.org>
---
drivers/usb/host/xhci-dbgcap.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
index 31fa3c7c63e4..b52735c1474a 100644
--- a/drivers/usb/host/xhci-dbgcap.c
+++ b/drivers/usb/host/xhci-dbgcap.c
@@ -1200,6 +1200,35 @@ static ssize_t dbc_bcdDevice_store(struct device *dev,
return size;
}
+static ssize_t dbc_iManufacturer_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(dev_get_drvdata(dev));
+ struct xhci_dbc *dbc = xhci->dbc;
+
+ return sysfs_emit(buf, "%s\n", dbc->str.manufacturer);
+}
+
+static ssize_t dbc_iManufacturer_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t size)
+{
+ struct xhci_hcd *xhci = hcd_to_xhci(dev_get_drvdata(dev));
+ struct xhci_dbc *dbc = xhci->dbc;
+
+ if (dbc->state != DS_DISABLED)
+ return -EBUSY;
+
+ if (size > USB_MAX_STRING_LEN/2+1)
+ return -E2BIG;
+
+ memcpy(dbc->str.manufacturer, buf, size);
+ /* remove newline and terminate the string */
+ dbc->str.manufacturer[size-1] = '\0';
+
+ return size;
+}
static ssize_t dbc_iProduct_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -1347,6 +1376,7 @@ static DEVICE_ATTR_RW(dbc);
static DEVICE_ATTR_RW(dbc_idVendor);
static DEVICE_ATTR_RW(dbc_idProduct);
static DEVICE_ATTR_RW(dbc_bcdDevice);
+static DEVICE_ATTR_RW(dbc_iManufacturer);
static DEVICE_ATTR_RW(dbc_iProduct);
static DEVICE_ATTR_RW(dbc_iSerial);
static DEVICE_ATTR_RW(dbc_bInterfaceProtocol);
@@ -1357,6 +1387,7 @@ static struct attribute *dbc_dev_attrs[] = {
&dev_attr_dbc_idVendor.attr,
&dev_attr_dbc_idProduct.attr,
&dev_attr_dbc_bcdDevice.attr,
+ &dev_attr_dbc_iManufacturer.attr,
&dev_attr_dbc_iProduct.attr,
&dev_attr_dbc_iSerial.attr,
&dev_attr_dbc_bInterfaceProtocol.attr,
--
2.51.0.536.g15c5d4f767-goog
prev parent reply other threads:[~2025-09-29 9:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-29 9:02 [PATCH v1 0/4] Enable to set DbC strings through sysfs Łukasz Bartosik
2025-09-29 9:02 ` [PATCH v1 1/4] xhci: dbc: prepare to expose " Łukasz Bartosik
2025-09-29 9:02 ` [PATCH v1 2/4] xhci: dbc: allow to set serial number " Łukasz Bartosik
2025-09-29 12:59 ` Greg Kroah-Hartman
2025-09-29 13:00 ` Greg Kroah-Hartman
2025-10-01 8:28 ` Łukasz Bartosik
2025-09-29 9:02 ` [PATCH v1 3/4] xhci: dbc: allow to set product name " Łukasz Bartosik
2025-09-29 9:02 ` Łukasz Bartosik [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=20250929090206.423937-5-ukaszb@google.com \
--to=ukaszb@chromium.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.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