mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: Marco Felsch <m.felsch@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/2] usb: gadget: initialize serialnumber
Date: Fri, 27 Oct 2023 10:00:34 +0200	[thread overview]
Message-ID: <20231027080034.GZ3359458@pengutronix.de> (raw)
In-Reply-To: <ebc7664f-65ed-964a-437c-20c4dab5b2e6@pengutronix.de>

On Thu, Oct 26, 2023 at 11:32:10PM +0200, Ahmad Fatoum wrote:
> On 26.10.23 16:43, Marco Felsch wrote:
> > 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 <andrey.zhizhikin@leica-geosystems.com>
> > Signed-off-by: Marco Felsch <m.felsch@pengutronix.de>
> 
> Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> 
> > ---
> > 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(-)
> > 
> > diff --git a/drivers/usb/gadget/udc/core.c b/drivers/usb/gadget/udc/core.c
> > index b58498680ad1..e7cfa0d5d836 100644
> > --- a/drivers/usb/gadget/udc/core.c
> > +++ b/drivers/usb/gadget/udc/core.c
> > @@ -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

> 
> >  	dev_add_param_string(&gadget->dev, "serialnumber", NULL, NULL,
> >  			     &gadget->serialnumber, NULL);
> >  
> 
> -- 
> 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 |
> 
> 
> 

-- 
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 |



  parent reply	other threads:[~2023-10-27  8:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-26 14:43 Marco Felsch
2023-10-26 14:43 ` [PATCH v2 2/2] scripts: get_maintainers: drop --status enforcement Marco Felsch
2023-10-26 21:31   ` Ahmad Fatoum
2023-10-26 21:32 ` [PATCH v2 1/2] usb: gadget: initialize serialnumber Ahmad Fatoum
2023-10-27  5:28   ` Marco Felsch
2023-10-27  8:00   ` Sascha Hauer [this message]
2023-10-27  8:09     ` Marco Felsch
2023-10-27  8:17       ` Sascha Hauer
2023-10-27  8:19         ` Marco Felsch
2023-11-01  7:24           ` Ahmad Fatoum
2023-11-01  8:50 ` 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=20231027080034.GZ3359458@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=m.felsch@pengutronix.de \
    /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