From patchwork Wed Dec 23 15:11:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1420187 X-Patchwork-Delegate: sjg@chromium.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=EQ5rDogu; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D1GvJ3SkLz9sTX for ; Thu, 24 Dec 2020 02:14:04 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69329827DE; Wed, 23 Dec 2020 16:12:42 +0100 (CET) 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="EQ5rDogu"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EEC9982A38; Wed, 23 Dec 2020 16:12:06 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) (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 1BD9382A64 for ; Wed, 23 Dec 2020 16:11:55 +0100 (CET) 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-il1-x12b.google.com with SMTP id g1so15324088ilk.7 for ; Wed, 23 Dec 2020 07:11:55 -0800 (PST) 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=RE/OElOg3ggBrM4OeBB6dxFDR7K3EJxhQLta9I0Z0fE=; b=EQ5rDogujBaFDTkHSQAb4FZg38suNzHkD4rx9qoQlvoceRuQM52bzLQy/QJxdSNxgk WuOORC6IzlvQebyhcegIrkxQE1GO1wJq+wFc7NcL6nRu4Sk56SqFdvLnvKW3MazkcFpj kYOFqLlDEMLbpnWRCbYcPUsMvwJ3zHv+qrQPI= 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=RE/OElOg3ggBrM4OeBB6dxFDR7K3EJxhQLta9I0Z0fE=; b=T878Tle9frrI8uQla5qUpqtfZgWiKCs+jQZwH83L+8qNKnI1b5tnMCJuKuDWeIaXIh vlJDdpFhS01hwox28dYo43YYFXNrhGujUNqX9nJDqW6CV3eWc0/sXg6E/goCBXtbYsJO bqyir4kRNjGA7DE2JVqTMmHptzJPRzOFPdMCDAF7qmPvUisp3SdyV7S05dnsyn/8hdBy 45OWPIf6nmnsUNclPOtuyqIemXpgr5BvWEEOIrgeIQRZc4SzapOaIupSF/yLQFe6I22U M+VaA7LwMZhu1//E29PyTV+TOPrSLYji3fRloEui/9gDZsJcP/r3SftKGrgodVB5ReAl bArw== X-Gm-Message-State: AOAM532zpus9v6KP9F/XKvcau/XekYCqo0bcW2J2+CVwrC2iAIGzG+QU 62lUwsJyeQOc8Qj6GPOKd8uXeEPpRlx93ZcT X-Google-Smtp-Source: ABdhPJyO1qgQthXo491qBiQn95uu1GtCL/cC/6lCPtvDuHRtpp7k/Lnxdh6tfEWed8M7n5Bxg7rMXw== X-Received: by 2002:a92:bb84:: with SMTP id x4mr25774514ilk.298.1608736313715; Wed, 23 Dec 2020 07:11:53 -0800 (PST) Received: from localhost.localdomain (c-67-190-101-114.hsd1.co.comcast.net. [67.190.101.114]) by smtp.gmail.com with ESMTPSA id c15sm16935667ils.87.2020.12.23.07.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Dec 2020 07:11:53 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass Subject: [PATCH v2 13/21] dtoc: Allow use of the of_match_ptr() macro Date: Wed, 23 Dec 2020 08:11:25 -0700 Message-Id: <20201223151133.2205985-6-sjg@chromium.org> X-Mailer: git-send-email 2.29.2.729.g45daf8777d-goog In-Reply-To: <20201223151133.2205985-1-sjg@chromium.org> References: <20201223151133.2205985-1-sjg@chromium.org> MIME-Version: 1.0 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.102.3 at phobos.denx.de X-Virus-Status: Clean Update the regex for the of_match member to allow of_match_ptr() so it matches both: .of_match = apl_hostbridge_ids, and .of_match = of_match_ptr(apl_hostbridge_ids), Without this, dtoc emits warnings and cannot find the drivers. Signed-off-by: Simon Glass --- (no changes since v1) tools/dtoc/dtb_platdata.py | 5 +++-- tools/dtoc/test_dtoc.py | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/tools/dtoc/dtb_platdata.py b/tools/dtoc/dtb_platdata.py index 51c4d1cae00..9c2bd18f5a4 100644 --- a/tools/dtoc/dtb_platdata.py +++ b/tools/dtoc/dtb_platdata.py @@ -408,7 +408,8 @@ class DtbPlatdata(): re_ids = re.compile(r'struct udevice_id (.*)\[\]\s*=') # Matches the references to the udevice_id list - re_of_match = re.compile(r'\.of_match\s*=\s*([a-z0-9_]+),') + re_of_match = re.compile( + r'\.of_match\s*=\s*(of_match_ptr\()?([a-z0-9_]+)(\))?,') # Matches the header/size information for priv re_priv = re.compile(r'^\s*DM_PRIV\((.*)\)$') @@ -431,7 +432,7 @@ class DtbPlatdata(): if id_m: uclass_id = id_m.group(1) elif id_of_match: - compat = id_of_match.group(1) + compat = id_of_match.group(2) elif '};' in line: if uclass_id and compat: if compat not in of_match: diff --git a/tools/dtoc/test_dtoc.py b/tools/dtoc/test_dtoc.py index 89192797781..1fd981f51e1 100755 --- a/tools/dtoc/test_dtoc.py +++ b/tools/dtoc/test_dtoc.py @@ -1009,3 +1009,23 @@ U_BOOT_DRIVER(i2c_tegra) = { self.assertIn( "file.c: Unknown compatible var 'tegra_i2c_ids' (found: tegra_i2c_ids2)", str(e.exception)) + + def testOfmatch(self): + """Test detection of of_match_ptr() member""" + 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, + .of_match = of_match_ptr(tegra_i2c_ids), +}; +''' + dpd = dtb_platdata.DtbPlatdata(None, False, False) + dpd._parse_driver('file.c', buff) + self.assertIn('i2c_tegra', dpd._drivers) + drv = dpd._drivers['i2c_tegra'] + self.assertEqual('i2c_tegra', drv.name)