mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Jules Maselbas <jmaselbas@kalray.eu>
To: Barebox List <barebox@lists.infradead.org>
Cc: Jules Maselbas <jmaselbas@kalray.eu>
Subject: [PATCH] USB: gadget: Add serialnumber device parameter
Date: Thu, 16 Jul 2020 15:28:30 +0200	[thread overview]
Message-ID: <20200716132830.16453-1-jmaselbas@kalray.eu> (raw)

This add the device parameter usbgadget.serialnumber

Signed-off-by: Jules Maselbas <jmaselbas@kalray.eu>
---
 drivers/usb/gadget/multi.c    | 2 ++
 drivers/usb/gadget/udc-core.c | 3 +++
 include/usb/gadget.h          | 1 +
 3 files changed, 6 insertions(+)

diff --git a/drivers/usb/gadget/multi.c b/drivers/usb/gadget/multi.c
index 445cc3242..95f5b90c8 100644
--- a/drivers/usb/gadget/multi.c
+++ b/drivers/usb/gadget/multi.c
@@ -179,8 +179,10 @@ static int multi_bind(struct usb_composite_dev *cdev)
 
 	strings_dev[USB_GADGET_MANUFACTURER_IDX].s = gadget->manufacturer;
 	strings_dev[USB_GADGET_PRODUCT_IDX].s = gadget->productname;
+	strings_dev[USB_GADGET_SERIAL_IDX].s = gadget->serialnumber;
 
 	device_desc.iProduct = strings_dev[USB_GADGET_PRODUCT_IDX].id;
+	device_desc.iSerialNumber = strings_dev[USB_GADGET_SERIAL_IDX].id;
 
 	config.label          = strings_dev[STRING_DESCRIPTION_IDX].s;
 	config.iConfiguration = strings_dev[STRING_DESCRIPTION_IDX].id;
diff --git a/drivers/usb/gadget/udc-core.c b/drivers/usb/gadget/udc-core.c
index 126d76e8b..2516676f8 100644
--- a/drivers/usb/gadget/udc-core.c
+++ b/drivers/usb/gadget/udc-core.c
@@ -212,6 +212,9 @@ int usb_add_gadget_udc_release(struct device_d *parent, struct usb_gadget *gadge
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			&gadget->productname, NULL);
+	gadget->serialnumber = xstrdup("");
+	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
+			&gadget->serialnumber, NULL);
 
 	dev_set_name(&udc->dev, "udc");
 	udc->dev.id = DEVICE_ID_DYNAMIC;
diff --git a/include/usb/gadget.h b/include/usb/gadget.h
index afa11b2d9..3e1d7153d 100644
--- a/include/usb/gadget.h
+++ b/include/usb/gadget.h
@@ -561,6 +561,7 @@ struct usb_gadget {
 	uint32_t			product_id;
 	char				*manufacturer;
 	char				*productname;
+	char				*serialnumber;
 };
 #define work_to_gadget(w)	(container_of((w), struct usb_gadget, work))
 
-- 
2.17.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2020-07-16 13:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 13:28 Jules Maselbas [this message]
2020-08-03 21:41 ` Sascha Hauer

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=20200716132830.16453-1-jmaselbas@kalray.eu \
    --to=jmaselbas@kalray.eu \
    --cc=barebox@lists.infradead.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