Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 69AFBC07E9C for ; Mon, 5 Jul 2021 18:04:40 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DC7636141C for ; Mon, 5 Jul 2021 18:04:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DC7636141C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 168F482BFD; Mon, 5 Jul 2021 20:04:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 4B84F82BF4; Mon, 5 Jul 2021 20:04:31 +0200 (CEST) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 00B8082C09 for ; Mon, 5 Jul 2021 20:04:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=wlozano@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: wlozano) with ESMTPSA id 7A96F1F427F1 Subject: Re: [PATCH 3/8] dtoc: Allow multiple warnings for a driver To: Simon Glass , U-Boot Mailing List Cc: Johan Jonker References: <20210704181950.1917106-1-sjg@chromium.org> <20210704181950.1917106-4-sjg@chromium.org> From: Walter Lozano Message-ID: Date: Mon, 5 Jul 2021 15:04:21 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210704181950.1917106-4-sjg@chromium.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean Hi Simon, On 7/4/21 3:19 PM, Simon Glass wrote: > At present we show when a driver is missing but this is not always that > useful. There are various reasons way a driver may appear to be missing, Did you mean "why" instead of "way"? > such as a parse error in the source code or a missing field in the driver > declaration. > > Update the implementation to record all warnings for each driver, showing > only those which relate to drivers that are actually used. This avoids > spamming the user with warnings related to a driver for a different board. > > Signed-off-by: Simon Glass > --- > > tools/dtoc/src_scan.py | 24 ++++++++++++++++++++---- > 1 file changed, 20 insertions(+), 4 deletions(-) Reviewed-by: Walter Lozano Thank you, it is indeed something worth to be added! Walter > > diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py > index 1dbb56712a3..6c37a71e978 100644 > --- a/tools/dtoc/src_scan.py > +++ b/tools/dtoc/src_scan.py > @@ -13,6 +13,7 @@ U_BOOT_DRIVER(), UCLASS_DRIVER and all struct declarations in header files. > See doc/driver-model/of-plat.rst for more informaiton > """ > > +import collections > import os > import re > import sys > @@ -190,6 +191,9 @@ class Scanner: > value: Driver name declared with U_BOOT_DRIVER(driver_name) > _drivers_additional (list or str): List of additional drivers to use > during scanning > + _warnings: Dict of warnings found: > + key: Driver name > + value: Set of warnings > _of_match: Dict holding information about compatible strings > key: Name of struct udevice_id variable > value: Dict of compatible info in that variable: > @@ -217,6 +221,7 @@ class Scanner: > self._driver_aliases = {} > self._drivers_additional = drivers_additional or [] > self._missing_drivers = set() > + self._warnings = collections.defaultdict(set) > self._of_match = {} > self._compat_to_driver = {} > self._uclass = {} > @@ -267,7 +272,10 @@ class Scanner: > aliases_c.remove(compat_c) > return compat_c, aliases_c > > - self._missing_drivers.add(compat_list_c[0]) > + name = compat_list_c[0] > + self._missing_drivers.add(name) > + self._warnings[name].add( > + 'WARNING: the driver %s was not found in the driver list' % name) > > return compat_list_c[0], compat_list_c[1:] > > @@ -577,9 +585,17 @@ class Scanner: > > def show_warnings(self): > """Show any warnings that have been collected""" > - for name in sorted(list(self._missing_drivers)): > - print('WARNING: the driver %s was not found in the driver list' > - % name) > + used_drivers = [drv.name for drv in self._drivers.values() if drv.used] > + missing = self._missing_drivers > + for name in sorted(self._warnings.keys()): > + if name in missing or name in used_drivers: > + warns = sorted(list(self._warnings[name])) > + # For now there is only ever one warning > + print('%s: %s' % (name, warns[0])) > + indent = ' ' * len(name) > + if name in missing: > + missing.remove(name) > + print() > > def scan_driver(self, fname): > """Scan a driver file to build a list of driver names and aliases