]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
usb: gadget: g_dnl: Sync internal SN variable with env
authorSam Protsenko <semen.protsenko@linaro.org>
Fri, 1 Sep 2017 12:42:03 +0000 (15:42 +0300)
committerTom Rini <trini@konsulko.com>
Wed, 6 Sep 2017 00:17:08 +0000 (20:17 -0400)
Since commit 842778a09104 ("usb: gadget: g_dnl: only set iSerialNumber
if we have a serial#") "fastboot devices" stopped to show correct device
serial number for TI boards, showing this line instead:

    ???????????? fastboot

This is because serial# env variable could be set after g_dnl gadget was
initialized (e.g. by using env_set() in the board file).

To fix this, let's update internal serial number variable (g_dnl_serial)
when "serial#" env var is changed.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Cc: Felipe Balbi <felipe.balbi@linux.intel.com>
Tested-by: Heiko Schocher <hs@denx.de>
Acked-by: Ɓukasz Majewski <lukma@denx.de>
Reviewed-by: Marek Vasut <marex@denx.de>
drivers/usb/gadget/g_dnl.c
include/env_callback.h

index 0491a0eea941902bb6cf494dccb9e8f64d6eae20..039331a5afd9cadc2b9306da9af848b218e397d6 100644 (file)
@@ -19,6 +19,8 @@
 #include <dfu.h>
 #include <thor.h>
 
+#include <env_callback.h>
+
 #include "gadget_chips.h"
 #include "composite.c"
 
@@ -202,6 +204,19 @@ static int g_dnl_get_bcd_device_number(struct usb_composite_dev *cdev)
        return g_dnl_get_board_bcd_device_number(gcnum);
 }
 
+/**
+ * Update internal serial number variable when the "serial#" env var changes.
+ *
+ * Handle all cases, even when flags == H_PROGRAMMATIC or op == env_op_delete.
+ */
+static int on_serialno(const char *name, const char *value, enum env_op op,
+               int flags)
+{
+       g_dnl_set_serialnumber((char *)value);
+       return 0;
+}
+U_BOOT_ENV_CALLBACK(serialno, on_serialno);
+
 static int g_dnl_bind(struct usb_composite_dev *cdev)
 {
        struct usb_gadget *gadget = cdev->gadget;
index 90b95b5e6676087f00d234721c98c7e475cf4268..5c4a30c2deeed2fd810f6f7fbb6c7dfdd2aacde0 100644 (file)
@@ -72,6 +72,7 @@
        SILENT_CALLBACK \
        SPLASHIMAGE_CALLBACK \
        "stdin:console,stdout:console,stderr:console," \
+       "serial#:serialno," \
        CONFIG_ENV_CALLBACK_LIST_STATIC
 
 struct env_clbk_tbl {