From patchwork Tue Oct 24 00:28:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suneel Garapati X-Patchwork-Id: 829745 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uuUVCZZ7"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3yLYzY5xkMz9sNc for ; Tue, 24 Oct 2017 11:28:56 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 2F40DC21DBA; Tue, 24 Oct 2017 00:28:50 +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=FREEMAIL_FROM, RCVD_IN_MSPIKE_H2, 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 BF5E0C21D19; Tue, 24 Oct 2017 00:28:47 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 9F9AFC21D19; Tue, 24 Oct 2017 00:28:45 +0000 (UTC) Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by lists.denx.de (Postfix) with ESMTPS id F19EBC21CEC for ; Tue, 24 Oct 2017 00:28:44 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id a8so18348312pfc.0 for ; Mon, 23 Oct 2017 17:28:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=SmnPZ53JlWsjXMYgvvLpe2WC8OW0GUCKMh3OBiUNE3E=; b=uuUVCZZ7MsTozU94HPKmYBx/1wlDLW2a15/v2po1ktie01Lq3xc2UIcr9VtGZVvmOF ZA/HTuuWbsh5Vbe7ibWo6gB39pZd9GOxGSDfMW3fta0LkW6RBr8BviD28zHJlZLNvSqH LzHVhA8E78mK9Si0p/nMLxSpb1lJbYSpiU0MdiQwDGmv8X0jCuafS7bfxN5aZWMcPwO8 Qhd23gjYURGtV7Pugn3hH+W0g8gWVGtszAFNl9V9RWSHihtPLDuG8ybuBlbOKA2FvcuG NM9g8+10uxfxon82K4KyGOqg++3uOEMYf8VR9dD0pxqAu3KJBiaVjIXr8F3n+0bDtzdJ TUiw== 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=SmnPZ53JlWsjXMYgvvLpe2WC8OW0GUCKMh3OBiUNE3E=; b=QXkVGCyk/4xTBlyK5PcNDxxSwPbBSDJXxgyeA+uxLqkAGHy/VTSzqJ9ClSQ1eIR00H bObrcGbbZiCiCc8T5EbBX5alfebvUjPIoMamvsn7toG3FWHwX7d7yqoNN2g79acAM+bw J1848gV5v/RPIXgpxtJvbi+0m0YaHuGtbyx8bi567mqZeXIPQt852shH/tGgGO5LQaN8 d3yTD2hXf9qsUE2Fa+EHGqU9CAx65icGIS52JMchyasjJTvTP7Mw99i+t6QBkicOtx7N RFiuAGQtJnYcBqHGwekXliXnPEtkcuBxwtbgy8aQvgPHMOI4Eo1VBNx7ruiK0C7AieR+ Xhtg== X-Gm-Message-State: AMCzsaXTWtJSdDry6/cMaI8nPxcoupooplnIyRNUvOdpQGsSr7ZRfMOm s9ztQznLcZY3yaDnpyHBMyA= X-Google-Smtp-Source: ABhQp+T6Ea5iJsYl9k1VHbU3+ZVvbc0aDZ6dvdb/q7bz4vRkpx/MdzlgCORRwAc/GNJDw0ftb5oCxw== X-Received: by 10.101.92.135 with SMTP id a7mr13262005pgt.263.1508804923103; Mon, 23 Oct 2017 17:28:43 -0700 (PDT) Received: from suneel.hsd1.ca.comcast.net ([2601:646:8e00:e521:2433:fbd6:1785:8438]) by smtp.gmail.com with ESMTPSA id h22sm13394148pfi.64.2017.10.23.17.28.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 23 Oct 2017 17:28:42 -0700 (PDT) From: Suneel Garapati To: Stefan Roese Date: Mon, 23 Oct 2017 17:28:40 -0700 Message-Id: <1508804920-25802-1-git-send-email-suneelglinux@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: Marek Vasut , u-boot@lists.denx.de, Michal Simek Subject: [U-Boot] [PATCH v7] cmd: usb: ignore blk, emulation devices in usb tree/info display 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" Usb tree/info commands iterate over all usb uclass devices recursively. Blk uclass devices based on struct blk_desc are created for mass storage device, treating them as usb uclass devices based on struct usb_device and referencing usb config interface descriptors cause crash. To fix, ignore blk and usb_emul uclass devices in usb_show_info and usb_tree_graph. Also avoid addition of preamble for blk uclass child devices, otherwise tree dump gets messed up. Signed-off-by: Suneel Garapati Reviewed-by: Bin Meng Tested-by: Bin Meng Reviewed-by: Simon Glass --- Changes v7: - modify commit description based on review comments Changes v6: - re-write commit message with detail Changes v5: - add usb_emul to ignore list in usb_show_info - modify description Changes v4: - do not set preamble if child is block device for mass storage Changes v3: - remove 'check on parent uclass' in description Changes v2: - remove check on parent uclass Changes v1: - add separate check on blk uclass - modify description - add separate check on parent uclass as usb cmd/usb.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cmd/usb.c b/cmd/usb.c index d95bcf5..907debe 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -349,6 +349,16 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre) printf(" %s", pre); #ifdef CONFIG_DM_USB has_child = device_has_active_children(dev->dev); + if (device_get_uclass_id(dev->dev) == UCLASS_MASS_STORAGE) { + struct udevice *child; + + for (device_find_first_child(dev->dev, &child); + child; + device_find_next_child(&child)) { + if (device_get_uclass_id(child) == UCLASS_BLK) + has_child = 0; + } + } #else /* check if the device has connected children */ int i; @@ -414,8 +424,12 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre) udev = dev_get_parent_priv(child); - /* Ignore emulators, we only want real devices */ - if (device_get_uclass_id(child) != UCLASS_USB_EMUL) { + /* + * Ignore emulators and block child devices, we only want + * real devices + */ + if ((device_get_uclass_id(child) != UCLASS_USB_EMUL) && + (device_get_uclass_id(child) != UCLASS_BLK)) { usb_show_tree_graph(udev, pre); pre[index] = 0; } @@ -605,7 +619,9 @@ static void usb_show_info(struct usb_device *udev) for (device_find_first_child(udev->dev, &child); child; device_find_next_child(&child)) { - if (device_active(child)) { + if (device_active(child) && + (device_get_uclass_id(child) != UCLASS_USB_EMUL) && + (device_get_uclass_id(child) != UCLASS_BLK)) { udev = dev_get_parent_priv(child); usb_show_info(udev); }