usb: gadget: initialize serialnumber
Subsystems (2)
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
@@ -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
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
@@ -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
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.
Signed-off-by Marco Felsch <[email protected]>
Quoted 17 lines
--- scripts/get_maintainer.pl | 2 -- 1 file changed, 2 deletions(-)scripts/get_maintainer.pl +0
-2@@ -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 |
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.
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>
Quoted 15 lines
---
Changelogv2:
- adapt commit message
- usebarebox_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
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
-0dev_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 |
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.
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>Reviewed-by Ahmad Fatoum <[email protected]>Quoted 10 lines
---
Changelogv2:
- adapt commit message
- usebarebox_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@@ -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
-0dev_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 |
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.
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>Reviewed-by Ahmad Fatoum <[email protected]>Quoted 10 lines
---
Changelogv2:
- adapt commit message
- usebarebox_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@@ -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
-0dev_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 |
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.
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>Reviewed-by Ahmad Fatoum <[email protected]>Quoted 10 lines
---
Changelogv2:
- adapt commit message
- usebarebox_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@@ -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->serialnumberis 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
-0dev_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 |
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.
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>Reviewed-by Ahmad Fatoum <[email protected]>Quoted 15 lines
---
Changelogv2:
- adapt commit message
- usebarebox_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
-0drivers/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->serialnumberis 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
-0dev_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 |
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.
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>Reviewed-by Ahmad Fatoum <[email protected]>Quoted 10 lines
---
Changelogv2:
- adapt commit message
- usebarebox_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@@ -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->serialnumberis 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
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.
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>Reviewed-by Ahmad Fatoum <[email protected]>Quoted 10 lines
---
Changelogv2:
- adapt commit message
- usebarebox_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@@ -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->serialnumberis 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 |
Sascha Hauer
AppliedQuoted 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
Reported-by Andrey Zhizhikin <[email protected]>Signed-off-by Marco Felsch <[email protected]>---
Changelogv2:
- adapt commit message
- usebarebox_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@@ -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 |