summaryrefslogtreecommitdiffstats
path: root/scripts/dtc
diff options
context:
space:
mode:
authorNĂ­colas F. R. A. Prado <nfraprado@collabora.com>2023-08-28 17:13:10 -0400
committerRob Herring <robh@kernel.org>2023-09-20 14:25:10 -0500
commiteb2139fc0da63b89a2ad565ecd8133a37e8b7c4f (patch)
treef39de520e80c9d29ec05e938e6ce9b0c928526e9 /scripts/dtc
parent0bb80ecc33a8fb5a682236443c1e740d5c917d1d (diff)
downloadlinux-stable-eb2139fc0da63b89a2ad565ecd8133a37e8b7c4f.tar.gz
linux-stable-eb2139fc0da63b89a2ad565ecd8133a37e8b7c4f.tar.bz2
linux-stable-eb2139fc0da63b89a2ad565ecd8133a37e8b7c4f.zip
dt: dt-extract-compatibles: Handle cfile arguments in generator function
Move the handling of the cfile arguments to a separate generator function to avoid redundancy. Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com> Link: https://lore.kernel.org/r/20230828211424.2964562-2-nfraprado@collabora.com Signed-off-by: Rob Herring <robh@kernel.org>
Diffstat (limited to 'scripts/dtc')
-rwxr-xr-xscripts/dtc/dt-extract-compatibles19
1 files 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)