From patchwork Fri Sep 1 12:00:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 111481 Delivered-To: patch@linaro.org Received: by 10.140.95.112 with SMTP id h103csp929000qge; Fri, 1 Sep 2017 05:01:12 -0700 (PDT) X-Received: by 10.80.146.21 with SMTP id i21mr1492168eda.22.1504267272125; Fri, 01 Sep 2017 05:01:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504267272; cv=none; d=google.com; s=arc-20160816; b=rkVfJr9E2QnIxXESfb3EP5LgT1VnBG8N654Y/zRMxYoH4oKjzR/4U+pz0S/r6qr5ty z1FjM28Ks5/avM4Ymfio34Qy56iBd+kQG6D3Mm/TG2cJ1befWWyHXHSX2voPcxwvagsE HhmB9WvyPFbHOwfndvtVpTUyfprfYuGgfA5LuWBtjAww/v25jqTbeUVMtgIG3qtxPGez 7ASK/mcW+l4PDMNAD2Gd582VdcjG1O0vpS+7fdW4ujmcvTVMdH9ul7TyZMJoXzt4i4+o XOO8YeigXcoJwWO0O4sleosDTE/k21xJ+b+ER9UNsVZcMHKPPj2RdzM2x5Pb1aG6F5QD Updg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from :dkim-signature:arc-authentication-results; bh=pKP0L9tCb8S/ALsmJ342uT2FtpasGnxR8zciMaih5DE=; b=ZBYjRLiERoN88wTYeiLfyr8UE2RDsD2SDkoUcyMcFrNCSaDS5OaL/xq5oEk2RE/5Qd 1Vkg7MoRtoHpZiw7IUcc0+TGq4x3kJsb+EUJ/n+7SgCWIJDbz+otYelv5189ozGTOwMW uDO7PM4ylJIYO0BoZ+BrIGlWP40wWLOEWvMOhKPjo/g8ufLBp+De8haXMlejZTPs3o8y RxbV94TV+Xa4XffpZR8wBnvTLh1H5cMDWK9bwDpFTsWazyNKJa+tuNEMLYgDV2h2wwbZ 5kiYe/PlaGxHBSHaBwQ3C3ieOcXMrFOBYaJJJQNjg7ebMNe3xpKx9grxv2jGKNxwNdf5 0jVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bCaEYXH4; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id d92si2398959edc.370.2017.09.01.05.01.11; Fri, 01 Sep 2017 05:01:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=bCaEYXH4; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.denx.de (Postfix, from userid 105) id BA573C21E8E; Fri, 1 Sep 2017 12:01:08 +0000 (UTC) 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, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 06BD1C21EBB; Fri, 1 Sep 2017 12:01:06 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 57D71C21ECF; Fri, 1 Sep 2017 12:01:04 +0000 (UTC) Received: from mail-lf0-f44.google.com (mail-lf0-f44.google.com [209.85.215.44]) by lists.denx.de (Postfix) with ESMTPS id 2D0E0C21EBB for ; Fri, 1 Sep 2017 12:00:38 +0000 (UTC) Received: by mail-lf0-f44.google.com with SMTP id y128so8382822lfd.4 for ; Fri, 01 Sep 2017 05:00:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=ACaYDubvK1bA9OKRJwtth3yw+ietN3n8n7tdgUbzylo=; b=bCaEYXH475ln7X0NNm3ArKnHkbK5CEO4v6Us9xj198ZxPpAbHBHQyir+HDmktfHYTS Bzp4bXHRIRTE6nHzwjVRnnSWQlnPk+zNk9x2tKXCWZvgZQB3r0MoZeLEUA9/EAqtrWbv 3ClxfPLraXMJV1R1FRgzDhfFwGeUNx+MzvCgc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=ACaYDubvK1bA9OKRJwtth3yw+ietN3n8n7tdgUbzylo=; b=GzPlthdBC7LGfayFe7PX0SmfWBQ8JMMb4zNzcHx/dxoI+lt+jTSdPjGNer1Y1JQehi GL9D9Frh2wttwqQVkJisBJ54JcoNWJyNAlxJ0RyMfqLaAf2FYs2ChzqzYSHT8U2kEz6D tJJNUzreYCmASaWePGRBxTlT79YjbY+NFPa061ef4wad8rIUg03DaQvVa4+BRQHWNBIT bNbJu7ND1jeWB5aMVFTjWz4dyQxYXvNnGlXxe7+WmtqWk5+DjYL011umBWks6jwNMvDR CwRBjAVDHM5LAee849FhkzYjYBCp91VLc06LFCu6caPJfrBqAcXUgemuLG0s8kM91qy6 175A== X-Gm-Message-State: AHPjjUhRXDuDFbkghipsaO137oZFXvt/JU2P/shO0x7Y0zJNknRmmIq7 6Cr875kRPMyjG74KZp5gJQ== X-Google-Smtp-Source: ADKCNb64W0JmeYfXbtyu+pyJDQsW9+dfWbCnwR70GiqscK+1XkBzElQn0CMUKe59INNhWhRnaPNtZA== X-Received: by 10.46.0.163 with SMTP id e35mr698089lji.114.1504267237250; Fri, 01 Sep 2017 05:00:37 -0700 (PDT) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id n76sm121530lja.79.2017.09.01.05.00.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 01 Sep 2017 05:00:36 -0700 (PDT) From: Sam Protsenko To: u-boot@lists.denx.de Date: Fri, 1 Sep 2017 15:00:35 +0300 Message-Id: <20170901120035.21024-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.14.1 Cc: Marek Vasut , Tom Rini , Praneeth Bajjuri Subject: [U-Boot] [PATCH v2 1/1] usb: gadget: g_dnl: Sync internal SN variable with env X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Cc: Felipe Balbi --- drivers/usb/gadget/g_dnl.c | 24 ++++++++++++++++++++++++ include/env_callback.h | 1 + 2 files changed, 25 insertions(+) diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c index 0491a0eea9..1a9f075485 100644 --- a/drivers/usb/gadget/g_dnl.c +++ b/drivers/usb/gadget/g_dnl.c @@ -19,6 +19,8 @@ #include #include +#include + #include "gadget_chips.h" #include "composite.c" @@ -202,6 +204,28 @@ 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, including when flags == H_PROGRAMMATIC. + */ +static int on_serialno(const char *name, const char *value, enum env_op op, + int flags) +{ + switch (op) { + case env_op_create: + /* Fall through */ + case env_op_overwrite: + g_dnl_set_serialnumber((char *)value); + break; + default: + break; + } + + 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; diff --git a/include/env_callback.h b/include/env_callback.h index 90b95b5e66..5c4a30c2de 100644 --- a/include/env_callback.h +++ b/include/env_callback.h @@ -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 {