From patchwork Mon Aug 28 21:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 717939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 00FBEC83F17 for ; Mon, 28 Aug 2023 21:15:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233595AbjH1VOs (ORCPT ); Mon, 28 Aug 2023 17:14:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbjH1VOe (ORCPT ); Mon, 28 Aug 2023 17:14:34 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84511C3; Mon, 28 Aug 2023 14:14:32 -0700 (PDT) Received: from notapiano.myfiosgateway.com (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id C09E166071C7; Mon, 28 Aug 2023 22:14:29 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693257271; bh=z6VcAPJB2wzNAu89McnlY95dVXFDs/OIGdTL7JnPRB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMpynwLUhWpxC9zt87DMRf+/cOWkS7TxKvY8xxkT3Rc7jiscnNIOCObEfWqDDeiV3 CDHbA85yGrR1X7Q1S0Ce+CnHGFTJBMAUgCMRV8qXT6fgPEqiQeNC1DV3u+xZnx6JKN /IP/zAVJj/LVs8UjmyEppHOPGLUq9aU07kPHXxq569kUcgbbNABV8JShJI/dwTNfXU T69lu7TQVbPwsGRnOEE74iJUQnus/Ge/H2uXZj0PbS/tOGL1zmJstI9WSJuDFInGiJ TBFpxgp/aH6lsFY33xbpEULkeza0HzT8Vqvjj4C9G8iv8LpkKSwFp+CrCdSkq6kZZT Y3k62HKoNs8Eg== From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= To: Rob Herring , Frank Rowand , Shuah Khan Cc: Mark Brown , kernelci@lists.linux.dev, kernel@collabora.com, Guenter Roeck , Bjorn Andersson , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4g?= =?utf-8?b?UHJhZG8=?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 1/3] dt: dt-extract-compatibles: Handle cfile arguments in generator function Date: Mon, 28 Aug 2023 17:13:10 -0400 Message-ID: <20230828211424.2964562-2-nfraprado@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828211424.2964562-1-nfraprado@collabora.com> References: <20230828211424.2964562-1-nfraprado@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move the handling of the cfile arguments to a separate generator function to avoid redundancy. Signed-off-by: NĂ­colas F. R. A. Prado --- (no changes since v2) Changes in v2: - Added this commit scripts/dtc/dt-extract-compatibles | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/scripts/dtc/dt-extract-compatibles b/scripts/dtc/dt-extract-compatibles index 9df9f1face83..2b6d228602e8 100755 --- a/scripts/dtc/dt-extract-compatibles +++ b/scripts/dtc/dt-extract-compatibles @@ -49,6 +49,14 @@ def print_compat(filename, compatibles): else: print(*compatibles, sep='\n') +def files_to_parse(path_args): + for f in path_args: + if os.path.isdir(f): + for filename in glob.iglob(f + "/**/*.c", recursive=True): + yield filename + else: + yield f + show_filename = False if __name__ == "__main__": @@ -59,11 +67,6 @@ if __name__ == "__main__": show_filename = args.with_filename - for f in args.cfile: - if os.path.isdir(f): - for filename in glob.iglob(f + "/**/*.c", recursive=True): - compat_list = parse_compatibles(filename) - print_compat(filename, compat_list) - else: - compat_list = parse_compatibles(f) - print_compat(f, compat_list) + for f in files_to_parse(args.cfile): + compat_list = parse_compatibles(f) + print_compat(f, compat_list) From patchwork Mon Aug 28 21:13:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= X-Patchwork-Id: 717938 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26C31C83F19 for ; Mon, 28 Aug 2023 21:15:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233581AbjH1VOt (ORCPT ); Mon, 28 Aug 2023 17:14:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233506AbjH1VOh (ORCPT ); Mon, 28 Aug 2023 17:14:37 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87E67C3; Mon, 28 Aug 2023 14:14:34 -0700 (PDT) Received: from notapiano.myfiosgateway.com (zone.collabora.co.uk [167.235.23.81]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: nfraprado) by madras.collabora.co.uk (Postfix) with ESMTPSA id C504F6607236; Mon, 28 Aug 2023 22:14:31 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1693257273; bh=HrjOwWou5bAWqPfAighj4CIIJaWFRIbl2UCKh60cGsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SkRu8AMjrjJsiCpKZt3Ni7d7AjsF8JlblFWZRUq0e4IX99Grkm3SYeE7GgLiDiuMY Oq4K82i5vsdQes+sNT2OWAC0rnd1C/lQF3iketax1JyvtQNghfd93l2l5HWMu9V6Cb 5+CICrRcZ+nZOl1nQR1CVz1gGKb2TLCqgWCPnK9e/Z3QTkSqrk64Ayt6+gs4qL8uvP aQlZ68kztotwO+h1YyRsAMSoACl7UkTSE38qLmepHEus7OLnNS5zLq/Aq8QLXOopRZ ixtkubp4CKNshsBQjxuVm8x5RquJ6BsUobfCPxPiaHmwTZvDK0B15uGrxdRoPL/+io hlLocXHj5u3LQ== From: =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= To: Rob Herring , Frank Rowand , Shuah Khan Cc: Mark Brown , kernelci@lists.linux.dev, kernel@collabora.com, Guenter Roeck , Bjorn Andersson , =?utf-8?b?TsOtY29sYXMgRi4gUi4gQS4g?= =?utf-8?b?UHJhZG8=?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 2/3] dt: dt-extract-compatibles: Add flag for driver matching compatibles Date: Mon, 28 Aug 2023 17:13:11 -0400 Message-ID: <20230828211424.2964562-3-nfraprado@collabora.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230828211424.2964562-1-nfraprado@collabora.com> References: <20230828211424.2964562-1-nfraprado@collabora.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add a new flag, '--driver-match', to the dt-extract-compatibles script that causes it to only print out compatibles that are expected to match a driver. This output can then be used by tests to detect device probe failures. In order to filter the compatibles down to only ones that will match to a driver, the following is considered: - A compatible needs to show up in a driver's of_match_table for it to be matched to a driver - Compatibles that are used in both of_match_table and OF_DECLARE type macros can't be expected to match to a driver and so are ignored. One exception is CLK_OF_DECLARE_DRIVER, since it indicates that a driver will also later probe, so compatibles in this macro are not ignored. Signed-off-by: NĂ­colas F. R. A. Prado --- (no changes since v2) Changes in v2: - Added this commit scripts/dtc/dt-extract-compatibles | 57 +++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 9 deletions(-) diff --git a/scripts/dtc/dt-extract-compatibles b/scripts/dtc/dt-extract-compatibles index 2b6d228602e8..bd07477dd144 100755 --- a/scripts/dtc/dt-extract-compatibles +++ b/scripts/dtc/dt-extract-compatibles @@ -7,11 +7,15 @@ import re import argparse -def parse_of_declare_macros(data): +def parse_of_declare_macros(data, include_driver_macros=True): """ Find all compatible strings in OF_DECLARE() style macros """ compat_list = [] # CPU_METHOD_OF_DECLARE does not have a compatible string - for m in re.finditer(r'(?