All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] usb: gadget: g_dnl: hold maximum string descriptor
@ 2017-02-22 15:12 Felipe Balbi
  2017-02-22 15:12 ` [U-Boot] [PATCH 2/3] usb: gadget: g_dnl: only set iSerialNumber if we have a serial# Felipe Balbi
  2017-02-22 15:12 ` [U-Boot] [PATCH 3/3] usb: gadget: g_dnl: don't set iProduct nor iSerialNumber Felipe Balbi
  0 siblings, 2 replies; 3+ messages in thread
From: Felipe Balbi @ 2017-02-22 15:12 UTC (permalink / raw)
  To: u-boot

A USB String descriptor can be up to 255 characters long and it's not
NULL terminated according to the USB spec. This means our
MAX_STRING_SERIAL should be 256 (to cope with NULL terminator).

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---

No access to a board right now, compile tested only

 drivers/usb/gadget/g_dnl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 4ba7c1da7cb0..fcedb554c4c6 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -36,7 +36,7 @@
 #define STRING_USBDOWN 2
 /* Index of String serial */
 #define STRING_SERIAL  3
-#define MAX_STRING_SERIAL	32
+#define MAX_STRING_SERIAL	256
 /* Number of supported configurations */
 #define CONFIGURATION_NUMBER 1
 
-- 
2.11.0.295.gd7dffce1ce

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 2/3] usb: gadget: g_dnl: only set iSerialNumber if we have a serial#
  2017-02-22 15:12 [U-Boot] [PATCH 1/3] usb: gadget: g_dnl: hold maximum string descriptor Felipe Balbi
@ 2017-02-22 15:12 ` Felipe Balbi
  2017-02-22 15:12 ` [U-Boot] [PATCH 3/3] usb: gadget: g_dnl: don't set iProduct nor iSerialNumber Felipe Balbi
  1 sibling, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2017-02-22 15:12 UTC (permalink / raw)
  To: u-boot

We don't want to claim that we support a serial number string and
later return nothing. Because of that, if g_dnl_serial is an empty
string, let's skip setting iSerialNumber to a valid number.

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---

No access to a board right now, compile tested only

 drivers/usb/gadget/g_dnl.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index fcedb554c4c6..4cc4438fdb4a 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -224,12 +224,14 @@ static int g_dnl_bind(struct usb_composite_dev *cdev)
 	g_dnl_string_defs[1].id = id;
 	device_desc.iProduct = id;
 
-	id = usb_string_id(cdev);
-	if (id < 0)
-		return id;
+	if (strlen(g_dnl_serial)) {
+		id = usb_string_id(cdev);
+		if (id < 0)
+			return id;
 
-	g_dnl_string_defs[2].id = id;
-	device_desc.iSerialNumber = id;
+		g_dnl_string_defs[2].id = id;
+		device_desc.iSerialNumber = id;
+	}
 
 	g_dnl_bind_fixup(&device_desc, cdev->driver->name);
 	ret = g_dnl_config_register(cdev);
-- 
2.11.0.295.gd7dffce1ce

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH 3/3] usb: gadget: g_dnl: don't set iProduct nor iSerialNumber
  2017-02-22 15:12 [U-Boot] [PATCH 1/3] usb: gadget: g_dnl: hold maximum string descriptor Felipe Balbi
  2017-02-22 15:12 ` [U-Boot] [PATCH 2/3] usb: gadget: g_dnl: only set iSerialNumber if we have a serial# Felipe Balbi
@ 2017-02-22 15:12 ` Felipe Balbi
  1 sibling, 0 replies; 3+ messages in thread
From: Felipe Balbi @ 2017-02-22 15:12 UTC (permalink / raw)
  To: u-boot

Both these numbers are calculated in runtime and dynamically assigned
to the device descriptor during bind().

Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
---

No access to a board right now, compile tested only

 drivers/usb/gadget/g_dnl.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 4cc4438fdb4a..d4bee9b03e4f 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -62,8 +62,8 @@ static struct usb_device_descriptor device_desc = {
 
 	.idVendor = __constant_cpu_to_le16(CONFIG_G_DNL_VENDOR_NUM),
 	.idProduct = __constant_cpu_to_le16(CONFIG_G_DNL_PRODUCT_NUM),
-	.iProduct = STRING_PRODUCT,
-	.iSerialNumber = STRING_SERIAL,
+	/* .iProduct = DYNAMIC */
+	/* .iSerialNumber = DYNAMIC */
 	.bNumConfigurations = 1,
 };
 
-- 
2.11.0.295.gd7dffce1ce

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-02-22 15:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-22 15:12 [U-Boot] [PATCH 1/3] usb: gadget: g_dnl: hold maximum string descriptor Felipe Balbi
2017-02-22 15:12 ` [U-Boot] [PATCH 2/3] usb: gadget: g_dnl: only set iSerialNumber if we have a serial# Felipe Balbi
2017-02-22 15:12 ` [U-Boot] [PATCH 3/3] usb: gadget: g_dnl: don't set iProduct nor iSerialNumber Felipe Balbi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.