Skip to contentSkip to conversation

usb: gadget: initialize serialnumber

PATCH Applied Marco Felsch 3 participants 11 messages Oct 26, 2023 – Nov 1, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 usb: gadget: initialize serialnumber

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +1 -1
index b58498680ad1..e7cfa0d5d836 100644
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");
 	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
 			     &gadget->serialnumber, NULL);
 
Signature · 1 line
2.39.2
#1 lore raw

PATCH v2 2/2 scripts: get_maintainers: drop --status enforcement

The status parameter is never used so drop it and stop bother the user of the script.

---
 scripts/get_maintainer.pl | 2 --
 1 file changed, 2 deletions(-)
scripts/get_maintainer.pl +0 -2
index 7c0d50333400..a19c0e7305d0 100755
@@ -2,8 +2,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 # Dummy get_maintainer.pl script for checkpatch.pl to use
 
-die "USAGE: get_maintainer.pl --status\n" unless grep /--status/, @ARGV;
-
 print <<'EOT'
 Sascha Hauer <[email protected]> (maintainer:BAREBOX)
 [email protected] (open list:BAREBOX)
Signature · 1 line
2.39.2
Acked-by on v2 2/2
#2 lore raw

Re: [PATCH v2 2/2] scripts: get_maintainers: drop --status enforcement

Quoted 4 lines · Marco Felsch

The status parameter is never used so drop it and stop bother the user of the script.

Quoted 17 lines
---
 scripts/get_maintainer.pl | 2 --
 1 file changed, 2 deletions(-)
scripts/get_maintainer.pl +0 -2
index 7c0d50333400..a19c0e7305d0 100755
@@ -2,8 +2,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 # Dummy get_maintainer.pl script for checkpatch.pl to use
 
-die "USAGE: get_maintainer.pl --status\n" unless grep /--status/, @ARGV;
-
 print <<'EOT'
 Sascha Hauer <[email protected]> (maintainer:BAREBOX)
 [email protected] (open list:BAREBOX)
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Reviewed-by on v2 1/2
#3 lore raw
In reply to Marco Felsch
Quoted 6 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 15 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +0 -0
index b58498680ad1..e7cfa0d5d836 100644

drivers/usb/gadget/udc/core.c int usb_add_gadget(struct usb_gadget *gadget) · line 1207

Quoted 5 lines
drivers/usb/gadget/udc/core.c +1 -1
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");

Nitpick: xstrdup(NULL) == NULL, so the ternary could be moved out the xstrdup.

Quoted 3 lines
drivers/usb/gadget/udc/core.c +0 -0
 	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
 			     &gadget->serialnumber, NULL);
 
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#4 lore raw
Quoted 20 lines · Ahmad Fatoum
Quoted 6 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 10 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/usb/gadget/udc/core.c int usb_add_gadget(struct usb_gadget *gadget) · line 1207

Quoted 10 lines
drivers/usb/gadget/udc/core.c +1 -1
index b58498680ad1..e7cfa0d5d836 100644
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");

Nitpick: xstrdup(NULL) == NULL, so the ternary could be moved out the xstrdup.

Thanks, didn't checked xstrdup(). @Sascha what's your preferred way?

Regards,
Marco

Quoted 12 lines
Quoted 4 lines
drivers/usb/gadget/udc/core.c +0 -0
 	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
 			     &gadget->serialnumber, NULL);
 
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#5 lore raw
In reply to Ahmad Fatoum
Quoted 20 lines · Ahmad Fatoum
Quoted 6 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 10 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/usb/gadget/udc/core.c int usb_add_gadget(struct usb_gadget *gadget) · line 1207

Quoted 10 lines
drivers/usb/gadget/udc/core.c +1 -1
index b58498680ad1..e7cfa0d5d836 100644
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");

Nitpick: xstrdup(NULL) == NULL, so the ternary could be moved out the xstrdup.

gadget->serialnumber is freed when the value of the variable is changed, so it must be an allocated string. gadget->serialnumber = "unset" would be wrong.

Sascha

Quoted 13 lines
Quoted 4 lines
drivers/usb/gadget/udc/core.c +0 -0
 	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
 			     &gadget->serialnumber, NULL);
 
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#6 lore raw
Quoted 34 lines · Sascha Hauer
Quoted 20 lines · Ahmad Fatoum
Quoted 6 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 10 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/usb/gadget/udc/core.c int usb_add_gadget(struct usb_gadget *gadget) · line 1207

Quoted 10 lines
drivers/usb/gadget/udc/core.c +1 -1
index b58498680ad1..e7cfa0d5d836 100644
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");

Nitpick: xstrdup(NULL) == NULL, so the ternary could be moved out the xstrdup.

Quoted 3 lines

gadget->serialnumber is freed when the value of the variable is changed, so it must be an allocated string. gadget->serialnumber = "unset" would be wrong.

I would have done the following:

	xstrdup(barebox_get_serial_number()) ? : xstrdup("unset");
Quoted 23 lines

Sascha

Quoted 13 lines
Quoted 4 lines
drivers/usb/gadget/udc/core.c +0 -0
 	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
 			     &gadget->serialnumber, NULL);
 
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#7 lore raw
Quoted 35 lines · Marco Felsch
Quoted 34 lines · Sascha Hauer
Quoted 32 lines · Ahmad Fatoum
Quoted 6 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 15 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +0 -0
index b58498680ad1..e7cfa0d5d836 100644

drivers/usb/gadget/udc/core.c int usb_add_gadget(struct usb_gadget *gadget) · line 1207

Quoted 5 lines
drivers/usb/gadget/udc/core.c +1 -1
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");

Nitpick: xstrdup(NULL) == NULL, so the ternary could be moved out the xstrdup.

Quoted 7 lines
Quoted 3 lines

gadget->serialnumber is freed when the value of the variable is changed, so it must be an allocated string. gadget->serialnumber = "unset" would be wrong.

I would have done the following:

	xstrdup(barebox_get_serial_number()) ? : xstrdup("unset");

Your original code looked better. This one looks like the ?: handles failures in xstrdup().

Sascha

Quoted 26 lines
Quoted 24 lines

Sascha

Quoted 13 lines
Quoted 4 lines
drivers/usb/gadget/udc/core.c +0 -0
 	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
 			     &gadget->serialnumber, NULL);
 
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#8 lore raw
Quoted 40 lines · Sascha Hauer
Quoted 39 lines · Marco Felsch
Quoted 37 lines · Sascha Hauer
Quoted 20 lines · Ahmad Fatoum
Quoted 6 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 10 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/usb/gadget/udc/core.c int usb_add_gadget(struct usb_gadget *gadget) · line 1207

Quoted 10 lines
drivers/usb/gadget/udc/core.c +1 -1
index b58498680ad1..e7cfa0d5d836 100644
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");

Nitpick: xstrdup(NULL) == NULL, so the ternary could be moved out the xstrdup.

gadget->serialnumber is freed when the value of the variable is changed, so it must be an allocated string. gadget->serialnumber = "unset" would be wrong.

Quoted 6 lines
Quoted 3 lines

I would have done the following:

	xstrdup(barebox_get_serial_number()) ? : xstrdup("unset");

Your original code looked better. This one looks like the ?: handles failures in xstrdup().

Right, thanks for the input.

Regards,
Marco

#9 lore raw
Quoted 41 lines · Marco Felsch
Quoted 40 lines · Sascha Hauer
Quoted 39 lines · Marco Felsch
Quoted 37 lines · Sascha Hauer
Quoted 20 lines · Ahmad Fatoum
Quoted 6 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 10 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 12 lines

drivers/usb/gadget/udc/core.c int usb_add_gadget(struct usb_gadget *gadget) · line 1207

Quoted 10 lines
drivers/usb/gadget/udc/core.c +1 -1
index b58498680ad1..e7cfa0d5d836 100644
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");

Nitpick: xstrdup(NULL) == NULL, so the ternary could be moved out the xstrdup.

gadget->serialnumber is freed when the value of the variable is changed, so it must be an allocated string. gadget->serialnumber = "unset" would be wrong.

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

I would have done the following:

	xstrdup(barebox_get_serial_number()) ? : xstrdup("unset");

Your original code looked better. This one looks like the ?: handles failures in xstrdup().

Right, thanks for the input.

Agreed with Sascha, I forgot it had to be an allocated string.

Quoted 4 lines

Regards,
Marco

Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Applied
#10 lore raw
In reply to Marco Felsch
Quoted 4 lines · Marco Felsch

Windows hosts do require the serial number to be set to any ascii string to enumerate correctly. Set the serial number if provided or to "unset" if not to provide a sane default which works for both hosts.

Quoted 9 lines

---
Changelog

v2:
- adapt commit message
- use barebox_get_serial_number() and "unset"

Applied, thanks

Sascha

Quoted 21 lines
 drivers/usb/gadget/udc/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/udc/core.c +1 -1
index b58498680ad1..e7cfa0d5d836 100644
@@ -1204,7 +1204,7 @@ int usb_add_gadget(struct usb_gadget *gadget)
 	gadget->productname = xstrdup(barebox_get_model());
 	dev_add_param_string(&gadget->dev, "productname", NULL, NULL,
 			     &gadget->productname, NULL);
-	gadget->serialnumber = xstrdup("");
+	gadget->serialnumber = xstrdup(barebox_get_serial_number() ? : "unset");
 	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
 			     &gadget->serialnumber, NULL);
 
Signature · 1 line
2.39.2
Signature · 4 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |