Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Nícolas F. R. A. Prado and committed by
Rob Herring
eb2139fc 0bb80ecc

+11 -8
+11 -8
scripts/dtc/dt-extract-compatibles
··· 49 49 else: 50 50 print(*compatibles, sep='\n') 51 51 52 + def files_to_parse(path_args): 53 + for f in path_args: 54 + if os.path.isdir(f): 55 + for filename in glob.iglob(f + "/**/*.c", recursive=True): 56 + yield filename 57 + else: 58 + yield f 59 + 52 60 show_filename = False 53 61 54 62 if __name__ == "__main__": ··· 67 59 68 60 show_filename = args.with_filename 69 61 70 - for f in args.cfile: 71 - if os.path.isdir(f): 72 - for filename in glob.iglob(f + "/**/*.c", recursive=True): 73 - compat_list = parse_compatibles(filename) 74 - print_compat(filename, compat_list) 75 - else: 76 - compat_list = parse_compatibles(f) 77 - print_compat(f, compat_list) 62 + for f in files_to_parse(args.cfile): 63 + compat_list = parse_compatibles(f) 64 + print_compat(f, compat_list)