From patchwork Tue Feb 16 17:59:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 62073 Delivered-To: patch@linaro.org Received: by 10.112.43.199 with SMTP id y7csp1813783lbl; Tue, 16 Feb 2016 09:59:28 -0800 (PST) X-Received: by 10.194.58.12 with SMTP id m12mr26766989wjq.22.1455645567955; Tue, 16 Feb 2016 09:59:27 -0800 (PST) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id xb9si50453842wjc.63.2016.02.16.09.59.27; Tue, 16 Feb 2016 09:59:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E6132A74C3; Tue, 16 Feb 2016 18:59:26 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zBYfDkqDgKt5; Tue, 16 Feb 2016 18:59:26 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 60151A745C; Tue, 16 Feb 2016 18:59:26 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 63D2BA745C for ; Tue, 16 Feb 2016 18:59:24 +0100 (CET) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4kNUx4HgV42X for ; Tue, 16 Feb 2016 18:59:24 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-lb0-f170.google.com (mail-lb0-f170.google.com [209.85.217.170]) by theia.denx.de (Postfix) with ESMTPS id 1C9754BF63 for ; Tue, 16 Feb 2016 18:59:21 +0100 (CET) Received: by mail-lb0-f170.google.com with SMTP id of3so9854320lbc.1 for ; Tue, 16 Feb 2016 09:59:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=qW39CsvJntcDcL1SpYBHlJp2NBeao1jmrUF/VZzD678=; b=Av9AWrhFQD8ra5oUnBTE8Aw5jr1pf/w5pSe2Zs0aWgI9ceOfAOj7lVsCi37p4Lu09a 5X4DZc3HHB/uG9le8VHZgsnLyIJyXfUbpgmNrI3ZDGBXEHjB7jCnTV8bzlw/ldKP275A c19C/EX9P4KsHZh1+DBpcpMDAFcEIfbVeKjUQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=qW39CsvJntcDcL1SpYBHlJp2NBeao1jmrUF/VZzD678=; b=Qn1bWSugc4T5O5r4HgrCgwynXk4J6uod73gjGHR7y5jwVY6PVqKwzMSD7ErrM2hVl4 JLuBlwIOtz+LBtfGmnEVdD6WabsSD8clRMZMlf4D30mtlMK7WCBt71UA68mXbuWGg+Sg aMK0Fj5rqTSs9rTU0I/969dGoBrX7ZU7U5VjoNd9jHW1Ykr8xH1OvV0bD7L7caEdQOaz tgzFZA171ed7sC9cc4WvItsR8LLA0j+mepbJUFc44FvEvj0aVpvKqiVQt3S8BTyiEiWu WgUbUeNzRS7eWTHtqYgA06l1bx0PGZWZex7Ekb45wo+brTt6aAnwgHQfhDugdiegJ6eT 4lyw== X-Gm-Message-State: AG10YOSSTlwvjcOouO33vYZozf3UTDYFLWjUNQCExU0QLDYlhRgXByMDHaCGRJpZn3FR82/2 X-Received: by 10.112.89.36 with SMTP id bl4mr10130140lbb.37.1455645560817; Tue, 16 Feb 2016 09:59:20 -0800 (PST) Received: from localhost ([195.238.92.132]) by smtp.gmail.com with ESMTPSA id pq10sm4372798lbc.34.2016.02.16.09.59.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Feb 2016 09:59:20 -0800 (PST) From: Semen Protsenko To: U-Boot Mailing List Date: Tue, 16 Feb 2016 19:59:19 +0200 Message-Id: <1455645559-23552-1-git-send-email-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.7.0 Cc: Marek Vasut Subject: [U-Boot] [PATCH] usb: gadget: composite: Correct recovery path for register X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 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" From: Sam Protsenko In case when usb_composite_register() failed once (for whatever reason), it will fail further even if all conditions are correct. Example: => fastboot 2 Invalid Controller Index couldn't find an available UDC g_dnl_register: failed!, error: -19 exit not allowed from main input shell. => fastboot 0 g_dnl_register: failed!, error: -22 exit not allowed from main input shell. Despite that 0 is correct index for USB controller, "fastboot 0" command will fail, because "composite" structure wasn't cleared properly on previous fail (on "fastboot 2" command). This patch fixes that erroneous behavior, allowing us to use composite even after previous failure. Signed-off-by: Sam Protsenko --- drivers/usb/gadget/composite.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.7.0 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 60f9272..d0ee784 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1077,6 +1077,8 @@ static struct usb_gadget_driver composite_driver = { */ int usb_composite_register(struct usb_composite_driver *driver) { + int res; + if (!driver || !driver->dev || !driver->bind || composite) return -EINVAL; @@ -1084,7 +1086,11 @@ int usb_composite_register(struct usb_composite_driver *driver) driver->name = "composite"; composite = driver; - return usb_gadget_register_driver(&composite_driver); + res = usb_gadget_register_driver(&composite_driver); + if (res != 0) + composite = NULL; + + return res; } /**