U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <l.majewski@samsung.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v1 3/5] usb, g_dnl: make iSerialNumber board configurable
Date: Tue, 22 Oct 2013 15:34:43 +0200	[thread overview]
Message-ID: <20131022153443.0f0e9301@amdc308.digital.local> (raw)
In-Reply-To: <52667524.6020602@denx.de>

Hi Heiko,

> Hello Lukasz,
> 
> Am 22.10.2013 14:37, schrieb Lukasz Majewski:
> > Hi Heiko,
> >
> >> add the possibility to set the iSerialNumber board specific.
> >> Therefore the CONFIG_G_DNL_SERIAL_STRING is introduced, which
> >> defines the maximum length of the iSerialNumber string.
> >> The new function g_dnl_set_serialnumber() must called from
> >> g_dnl_bind_fixup(), to setup the iSerialNumber string.
> >>
> >> Signed-off-by: Heiko Schocher<hs@denx.de>
> >> Cc: Marek Vasut<marek.vasut@gmail.com>
> >> Cc: Lukasz Majewski<l.majewski@samsung.com>
> >> Cc: Kyungmin Park<kyungmin.park@samsung.com>
> >> ---
> >>   drivers/usb/gadget/g_dnl.c | 28 ++++++++++++++++++++++++++++
> >>   include/g_dnl.h            |  3 +++
> >>   2 files changed, 31 insertions(+)
> >>
> >> diff --git a/drivers/usb/gadget/g_dnl.c
> >> b/drivers/usb/gadget/g_dnl.c index 40868c0..5f09d66 100644
> >> --- a/drivers/usb/gadget/g_dnl.c
> >> +++ b/drivers/usb/gadget/g_dnl.c
> >> @@ -39,8 +39,21 @@
> >>
> >>   static const char shortname[] = "usb_dnl_";
> >>   static const char product[] = "USB download gadget";
> >> +#if defined(CONFIG_G_DNL_SERIAL_STRING)
> >
> > I don't like the #if defined preprocessor directives here. The
> > g_dnl.c code is a generic code, to "glue" all functions together.
> >
> >> +#define STRING_SERIAL  3
> >> +static char g_dnl_serial[CONFIG_G_DNL_SERIAL_STRING + 1];
> >> +#endif
> >>   static const char manufacturer[] = CONFIG_G_DNL_MANUFACTURER;
> >>
> >> +#if defined(CONFIG_G_DNL_SERIAL_STRING)
> >> +void g_dnl_set_serialnumber(char *s)
> >> +{
> >> +	memset(g_dnl_serial, 0, CONFIG_G_DNL_SERIAL_STRING + 1);
> >> +	if (strlen(s)<= CONFIG_G_DNL_SERIAL_STRING)
> >> +		strncpy(g_dnl_serial, s, strlen(s));
> >> +}
> >> +#endif
> >> +
> >>   static struct usb_device_descriptor device_desc = {
> >>   	.bLength = sizeof device_desc,
> >>   	.bDescriptorType = USB_DT_DEVICE,
> >> @@ -52,6 +65,9 @@ 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, +#if defined(CONFIG_G_DNL_SERIAL_STRING)
> >
> > I think that #if defined(CONFIG_G_DNL_SERIAL_STRING) can be easily
> > removed, since the iSerialNumber is a valid member of struct
> > usb_descriptor.
> >
> > In my opinion, instead of defining #ifdefs, we can define some
> > "default" iSerialNumber for all devices.
> 
> Ok! How would look like the default serial number?

Some devices have default serial number set to 0 or 0xFFFFFFFF. Maybe we
can start with the 0 value?

> 
> > Then this value can be overridden by board when needed by call to
> > g_dnl_set_serialnumber() function
> 
> Ok. Will change it in this direction, thanks for the review!

No problem. You are welcome.

> 
> bye,
> Heiko

-- 
Best regards,

Lukasz Majewski

Samsung R&D Institute Poland (SRPOL) | Linux Platform Group

  reply	other threads:[~2013-10-22 13:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-22 10:25 [U-Boot] [PATCH v1 0/5] arm, am33xx: update for the am33xx based siemens boards Heiko Schocher
2013-10-22 10:25 ` [U-Boot] [PATCH v1 1/5] bootcount: store bootcount var in environment Heiko Schocher
2013-10-24 11:31   ` Vaibhav Bedia
2013-10-22 10:25 ` [U-Boot] [PATCH v1 2/5] arm, am33x: make RTC32K OSC enable configurable Heiko Schocher
2013-10-22 10:25 ` [U-Boot] [PATCH v1 3/5] usb, g_dnl: make iSerialNumber board configurable Heiko Schocher
2013-10-22 12:37   ` Lukasz Majewski
2013-10-22 12:52     ` Heiko Schocher
2013-10-22 13:34       ` Lukasz Majewski [this message]
2013-10-22 10:25 ` [U-Boot] [PATCH v1 4/5] usb, g_dnl: make bcdDevice value configurable Heiko Schocher
2013-10-22 12:20   ` Lukasz Majewski
2013-10-22 10:25 ` [U-Boot] [PATCH v1 5/5] arm, am335x: update for the siemens boards Heiko Schocher

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=20131022153443.0f0e9301@amdc308.digital.local \
    --to=l.majewski@samsung.com \
    --cc=u-boot@lists.denx.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