[{"id":1761637,"web_url":"http://patchwork.ozlabs.org/comment/1761637/","msgid":"<CAKaJLVv0BuFS5hjaA4W-zKXBfLsnQUL4_-KW8Cv8menM6itD+Q@mail.gmail.com>","list_archive_url":null,"date":"2017-09-01T12:14:39","subject":"Re: [U-Boot] [PATCH v2 1/1] usb: gadget: g_dnl: Sync internal SN\n\tvariable with env","submitter":{"id":68333,"url":"http://patchwork.ozlabs.org/api/people/68333/","name":"Sam Protsenko","email":"semen.protsenko@linaro.org"},"content":"On 1 September 2017 at 15:00, Sam Protsenko <semen.protsenko@linaro.org> wrote:\n> Since commit 842778a09104 (\"usb: gadget: g_dnl: only set iSerialNumber\n> if we have a serial#\") \"fastboot devices\" stopped to show correct device\n> serial number for TI boards, showing this line instead:\n>\n>     ????????????        fastboot\n>\n> This is because serial# env variable could be set after g_dnl gadget was\n> initialized (e.g. by using env_set() in the board file).\n>\n> To fix this, let's update internal serial number variable (g_dnl_serial)\n> when \"serial#\" env var is changed.\n>\n> Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>\n> Cc: Felipe Balbi <felipe.balbi@linux.intel.com>\n> ---\n>  drivers/usb/gadget/g_dnl.c | 24 ++++++++++++++++++++++++\n>  include/env_callback.h     |  1 +\n>  2 files changed, 25 insertions(+)\n>\n> diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c\n> index 0491a0eea9..1a9f075485 100644\n> --- a/drivers/usb/gadget/g_dnl.c\n> +++ b/drivers/usb/gadget/g_dnl.c\n> @@ -19,6 +19,8 @@\n>  #include <dfu.h>\n>  #include <thor.h>\n>\n> +#include <env_callback.h>\n> +\n>  #include \"gadget_chips.h\"\n>  #include \"composite.c\"\n>\n> @@ -202,6 +204,28 @@ static int g_dnl_get_bcd_device_number(struct usb_composite_dev *cdev)\n>         return g_dnl_get_board_bcd_device_number(gcnum);\n>  }\n>\n> +/**\n> + * Update internal serial number variable when the \"serial#\" env var changes.\n> + *\n> + * Handle all cases, including when flags == H_PROGRAMMATIC.\n> + */\n> +static int on_serialno(const char *name, const char *value, enum env_op op,\n> +               int flags)\n> +{\n> +       switch (op) {\n> +       case env_op_create:\n> +               /* Fall through */\n> +       case env_op_overwrite:\n> +               g_dnl_set_serialnumber((char *)value);\n> +               break;\n> +       default:\n> +               break;\n> +       }\n> +\n> +       return 0;\n> +}\n> +U_BOOT_ENV_CALLBACK(serialno, on_serialno);\n> +\n>  static int g_dnl_bind(struct usb_composite_dev *cdev)\n>  {\n>         struct usb_gadget *gadget = cdev->gadget;\n> diff --git a/include/env_callback.h b/include/env_callback.h\n> index 90b95b5e66..5c4a30c2de 100644\n> --- a/include/env_callback.h\n> +++ b/include/env_callback.h\n> @@ -72,6 +72,7 @@\n>         SILENT_CALLBACK \\\n>         SPLASHIMAGE_CALLBACK \\\n>         \"stdin:console,stdout:console,stderr:console,\" \\\n> +       \"serial#:serialno,\" \\\n>         CONFIG_ENV_CALLBACK_LIST_STATIC\n>\n>  struct env_clbk_tbl {\n> --\n> 2.14.1\n>\n\nPlease ignore this patch. It doesn't handle the env_op_delete event.\nWill send v3 soon.","headers":{"Return-Path":"<u-boot-bounces@lists.denx.de>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@bilbo.ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=lists.denx.de\n\t(client-ip=81.169.180.215; helo=lists.denx.de;\n\tenvelope-from=u-boot-bounces@lists.denx.de;\n\treceiver=<UNKNOWN>)","ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=linaro.org header.i=@linaro.org\n\theader.b=\"D4LFho9U\"; dkim-atps=neutral"],"Received":["from lists.denx.de (dione.denx.de [81.169.180.215])\n\tby ozlabs.org (Postfix) with ESMTP id 3xkJ8b5wfdz9sPk\n\tfor <incoming@patchwork.ozlabs.org>;\n\tFri,  1 Sep 2017 22:14:55 +1000 (AEST)","by lists.denx.de (Postfix, from userid 105)\n\tid 7F42CC21F2D; Fri,  1 Sep 2017 12:14:48 +0000 (UTC)","from lists.denx.de (localhost [IPv6:::1])\n\tby lists.denx.de (Postfix) with ESMTP id 1B80FC21C72;\n\tFri,  1 Sep 2017 12:14:46 +0000 (UTC)","by lists.denx.de (Postfix, from userid 105)\n\tid B186CC21C72; Fri,  1 Sep 2017 12:14:43 +0000 (UTC)","from mail-io0-f171.google.com (mail-io0-f171.google.com\n\t[209.85.223.171])\n\tby lists.denx.de (Postfix) with ESMTPS id 6BE8DC21C2F\n\tfor <u-boot@lists.denx.de>; Fri,  1 Sep 2017 12:14:41 +0000 (UTC)","by mail-io0-f171.google.com with SMTP id d78so22130ioe.4\n\tfor <u-boot@lists.denx.de>; Fri, 01 Sep 2017 05:14:41 -0700 (PDT)","by 10.107.26.213 with HTTP; Fri, 1 Sep 2017 05:14:39 -0700 (PDT)"],"X-Spam-Checker-Version":"SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de","X-Spam-Level":"","X-Spam-Status":"No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,\n\tRCVD_IN_MSPIKE_H2,\n\tT_DKIM_INVALID autolearn=unavailable autolearn_force=no\n\tversion=3.4.0","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google;\n\th=mime-version:in-reply-to:references:from:date:message-id:subject:to\n\t:cc; bh=hpZbj88Zir9OoZKcAao9kwzOFn6eC8V6ACJ1a+J8nuQ=;\n\tb=D4LFho9UxGzEkb6NtaK2cCPs4Q55TP6GQyoTu8A1kXA4nrwpU08tVNsUBR2PyLNMqc\n\t8e97JrjwkU4Lj4Okuq6S0+98OsuTucaSj6iAb8oJmV64lUS9fMVMasSdhi81vf5B0krz\n\tB5p0qW0ZX5owVtGBMGKERbpkZUPUi386WK5ag=","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:mime-version:in-reply-to:references:from:date\n\t:message-id:subject:to:cc;\n\tbh=hpZbj88Zir9OoZKcAao9kwzOFn6eC8V6ACJ1a+J8nuQ=;\n\tb=gqsWWNoa3XCXAu+tbkfM7GWfSKdkQoO2SQPaUor49BGxbogshiZ7yv7advqw79zXYZ\n\tiUl5o62uVvvEJa7fLYIS9wthXpim4CHQe1+8xgUtIJ9oTnsqzD3cKtKgmlWFl2aydOOr\n\thDRoCatYseY5Ix1bt640JrnghROabK71g/Gvea+l44l5e7cRbFBqdcq0OMftL1mZS1sR\n\txi0O2YDI0TZArYa/dRHvBx3zxuo9/mRzqzBu6ZQpByae9+I1K0ilqKFW77Bfb1Wb2L05\n\t4bPouTvj15GgG3f+d5ksnj+LEUCABQ7yGcII84YmTtxlBWnvgpCk/yDQC2ItGabR0h8v\n\tbfzg==","X-Gm-Message-State":"AHPjjUimqIUiqxVHdd6OvENNQQc8eBsDpKLYy4SNFJMeDe/47VDlBeGM\n\tC6MyNGZZmC2sWs81DgPeDvnl0/hsupNL1t8=","X-Google-Smtp-Source":"ADKCNb5YlUDMtjuL6aDhIPOLQYJCj+cQhWKJbtm5p7/gGBnrdFIO1XVw7VrV2S8UxMM2mvX5gIGNaXpNO3T1NZrS4+Y=","X-Received":"by 10.107.57.136 with SMTP id g130mr1379358ioa.353.1504268079924;\n\tFri, 01 Sep 2017 05:14:39 -0700 (PDT)","MIME-Version":"1.0","In-Reply-To":"<20170901120035.21024-1-semen.protsenko@linaro.org>","References":"<20170901120035.21024-1-semen.protsenko@linaro.org>","From":"Sam Protsenko <semen.protsenko@linaro.org>","Date":"Fri, 1 Sep 2017 15:14:39 +0300","Message-ID":"<CAKaJLVv0BuFS5hjaA4W-zKXBfLsnQUL4_-KW8Cv8menM6itD+Q@mail.gmail.com>","To":"U-Boot Mailing List <u-boot@lists.denx.de>","Cc":"Marek Vasut <marex@denx.de>, Tom Rini <trini@konsulko.com>,\n\tPraneeth Bajjuri <praneeth@ti.com>","Subject":"Re: [U-Boot] [PATCH v2 1/1] usb: gadget: g_dnl: Sync internal SN\n\tvariable with env","X-BeenThere":"u-boot@lists.denx.de","X-Mailman-Version":"2.1.18","Precedence":"list","List-Id":"U-Boot discussion <u-boot.lists.denx.de>","List-Unsubscribe":"<https://lists.denx.de/options/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=unsubscribe>","List-Archive":"<http://lists.denx.de/pipermail/u-boot/>","List-Post":"<mailto:u-boot@lists.denx.de>","List-Help":"<mailto:u-boot-request@lists.denx.de?subject=help>","List-Subscribe":"<https://lists.denx.de/listinfo/u-boot>,\n\t<mailto:u-boot-request@lists.denx.de?subject=subscribe>","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"u-boot-bounces@lists.denx.de","Sender":"\"U-Boot\" <u-boot-bounces@lists.denx.de>"}}]