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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT 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 F363BC07E95 for ; Sun, 4 Jul 2021 18:21:16 +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 4D0FA613CB for ; Sun, 4 Jul 2021 18:21:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4D0FA613CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org 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 E4ED282BFD; Sun, 4 Jul 2021 20:20:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="aJtpeA/q"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D1E3F82BD1; Sun, 4 Jul 2021 20:20:11 +0200 (CEST) Received: from mail-oo1-xc29.google.com (mail-oo1-xc29.google.com [IPv6:2607:f8b0:4864:20::c29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 01A6B82B4E for ; Sun, 4 Jul 2021 20:20:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oo1-xc29.google.com with SMTP id r14-20020a4ad4ce0000b029024b4146e2f5so3917594oos.1 for ; Sun, 04 Jul 2021 11:20:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SXw4qK6FTjobjCBjPT/SvpsYt69YJ8s7t1wQWkV37rc=; b=aJtpeA/qeJqmKplWhkWiob+X/zfDDiI7lZ0NvROWD94OoyjNdJzow3nE2xwlgDHWZi GHsPUFJiMEKu/spEPluMwd/RBLtpUiXofYBkH1aj+fdfu8bSnhDsoB8gd2EqtVksthpN u60xW9YaoFewYEANonirvFq5n2jKjzj1YcRHM= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=SXw4qK6FTjobjCBjPT/SvpsYt69YJ8s7t1wQWkV37rc=; b=sln0wx+dffZotZWmxK1UM3IdtxNfyu7P8enUFrZbPW7ZlrSPKpthf6wDKmdLfv73Ax zmuMtxJLL9ZslE1UaP2FkEu6atl/UBagl0qsXQGB+5Gr22HOvG+3mboolEoYsP4j3Kht ZkKX/YNHZlULkii8uZhltbOBrvpTlAd+FUYaGAmIIny1ElU4SE90WGKS9kp6gkcHWqFj hcUxSaaTajfiVg0a5yAWrVvxhvtWuIV/s+E6w2N8vBD9wqzpVtdCbZofCorkHu/pkw8Y 3YsnrDp3DKR8RXbPtQMi6qiDVTUPAD//e3qjcxMngfimZCH4+J0GQyjvBIOoU2pHOUp3 AwMA== X-Gm-Message-State: AOAM533jgA6cOPZNj6gszXmh2SIh0BT6tMeXVyxuHHit5yFI4hPVwgJ7 AIsV6kTI3wvbvICnYUelLSdlee2xZ3gvqRNY X-Google-Smtp-Source: ABdhPJzjy/mHKqSD7OwVcA4lLcBf+jnHO91jVMardKiee8/PYkgCBiKDGemSJy9ruxLooKojbSEbQw== X-Received: by 2002:a4a:5b41:: with SMTP id g62mr7703441oob.74.1625422805257; Sun, 04 Jul 2021 11:20:05 -0700 (PDT) Received: from kiwi.bld.corp.google.com (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id z2sm2092953otm.2.2021.07.04.11.20.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jul 2021 11:20:04 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Johan Jonker , Simon Glass Subject: [PATCH 7/8] dtoc: Detect drivers which do not parse correctly Date: Sun, 4 Jul 2021 12:19:49 -0600 Message-Id: <20210704181950.1917106-8-sjg@chromium.org> X-Mailer: git-send-email 2.32.0.93.g670b81a890-goog In-Reply-To: <20210704181950.1917106-1-sjg@chromium.org> References: <20210704181950.1917106-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 At present if a driver is missing a uclass or compatible stirng, this is silently ignored. This makes sense in most cases, particularly for the compatible string, since it is not required except when the driver is used with of-platdata. But it is also not very helpful. When there is some sort of problem with a driver, the missing compatible string (for example) may be the cause. Add a warning in this case, showing it only for drivers which are used by the build. Signed-off-by: Simon Glass --- tools/dtoc/src_scan.py | 7 ++++++- tools/dtoc/test_src_scan.py | 38 +++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/tools/dtoc/src_scan.py b/tools/dtoc/src_scan.py index 847677757d9..3bef59d616e 100644 --- a/tools/dtoc/src_scan.py +++ b/tools/dtoc/src_scan.py @@ -546,7 +546,12 @@ class Scanner: # The driver does not have a uclass or compat string. # The first is required but the second is not, so just # ignore this. - pass + if not driver.uclass_id: + warn = 'Missing .uclass' + else: + warn = 'Missing .compatible' + self._warnings[driver.name].add('%s in %s' % + (warn, fname)) driver = None ids_name = None compat = None diff --git a/tools/dtoc/test_src_scan.py b/tools/dtoc/test_src_scan.py index 62500e80fe7..f03cf8ed7c7 100644 --- a/tools/dtoc/test_src_scan.py +++ b/tools/dtoc/test_src_scan.py @@ -581,3 +581,41 @@ rockchip_rk3288_grf: WARNING: the driver rockchip_rk3288_grf was not found in th ''', stdout.getvalue()) self.assertIn('tegra_i2c_ids', stdout.getvalue()) + + def scan_uclass_warning(self): + """Test a missing .uclass in the driver""" + buff = ''' +static const struct udevice_id tegra_i2c_ids[] = { + { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 }, + { } +}; + +U_BOOT_DRIVER(i2c_tegra) = { + .name = "i2c_tegra", + .of_match = tegra_i2c_ids, +}; +''' + scan = src_scan.Scanner(None, None) + scan._parse_driver('file.c', buff) + self.assertEqual( + {'i2c_tegra': {'Missing .uclass in file.c'}}, + scan._warnings) + + def scan_compat_warning(self): + """Test a missing .compatible in the driver""" + buff = ''' +static const struct udevice_id tegra_i2c_ids[] = { + { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 }, + { } +}; + +U_BOOT_DRIVER(i2c_tegra) = { + .name = "i2c_tegra", + .id = UCLASS_I2C, +}; +''' + scan = src_scan.Scanner(None, None) + scan._parse_driver('file.c', buff) + self.assertEqual( + {'i2c_tegra': {'Missing .compatible in file.c'}}, + scan._warnings) -- 2.32.0.93.g670b81a890-goog