Linux USB
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: "Łukasz Bartosik" <ukaszb@chromium.org>
Cc: Mathias Nyman <mathias.nyman@intel.com>, linux-usb@vger.kernel.org
Subject: Re: [PATCH v1 2/4] xhci: dbc: allow to set serial number through sysfs
Date: Mon, 29 Sep 2025 15:00:44 +0200	[thread overview]
Message-ID: <2025092924-nebulizer-overexert-4cfb@gregkh> (raw)
In-Reply-To: <20250929090206.423937-3-ukaszb@google.com>

On Mon, Sep 29, 2025 at 09:02:04AM +0000, Łukasz Bartosik wrote:
> From: Łukasz Bartosik <ukaszb@chromium.org>
> 
> Add code which allows to set serial number of a DbC
> device through sysfs.
> 
> Signed-off-by: Łukasz Bartosik <ukaszb@chromium.org>
> ---
>  drivers/usb/host/xhci-dbgcap.c | 32 ++++++++++++++++++++++++++++++++
>  1 file changed, 32 insertions(+)
> 
> diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c
> index c2fecaffd6f3..5cc201afe8f4 100644
> --- a/drivers/usb/host/xhci-dbgcap.c
> +++ b/drivers/usb/host/xhci-dbgcap.c
> @@ -1200,6 +1200,36 @@ static ssize_t dbc_bcdDevice_store(struct device *dev,
>  	return size;
>  }
>  
> +static ssize_t dbc_iSerial_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.serial);
> +}
> +
> +static ssize_t dbc_iSerial_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.serial, buf, size);
> +	/* remove newline and terminate the string */
> +	dbc->str.serial[size-1] = '\0';

What if there is not a newline?

  parent reply	other threads:[~2025-09-29 13:00 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 [this message]
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 ` [PATCH v1 4/4] xhci: dbc: allow to set manufacturer " Łukasz Bartosik

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=2025092924-nebulizer-overexert-4cfb@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mathias.nyman@intel.com \
    --cc=ukaszb@chromium.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