^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) #!/usr/bin/env perl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) # Copyright 2016 by Frank Rowand
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) # Copyright 2016 by Gaurav Minocha
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) use strict 'refs';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) use strict subs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) use Getopt::Long;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) $VUFX = "160610a";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) $script_name = $0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) $script_name =~ s|^.*/||;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) # ----- constants for print_flags()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) # Position in string $pr_flags. Range of 0..($num_pr_flags - 1).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) $pr_flag_pos_mcompatible = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) $pr_flag_pos_driver = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) $pr_flag_pos_mdriver = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) $pr_flag_pos_config = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) $pr_flag_pos_mconfig = 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) $pr_flag_pos_node_not_enabled = 5;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) $pr_flag_pos_white_list = 6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) $pr_flag_pos_hard_coded = 7;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) $pr_flag_pos_config_hard_coded = 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) $pr_flag_pos_config_none = 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) $pr_flag_pos_config_m = 10;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) $pr_flag_pos_config_y = 11;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) $pr_flag_pos_config_test_fail = 12;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) $num_pr_flags = $pr_flag_pos_config_test_fail + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) # flags in @pr_flag_value must be unique values to allow simple regular
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) # expessions to work for --include_flags and --exclude_flags.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) # Convention: use upper case letters for potential issues or problems.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) @pr_flag_value = ('M', 'd', 'D', 'c', 'C', 'E', 'W', 'H', 'x', 'n', 'm', 'y', 'F');
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) @pr_flag_help = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) "multiple compatibles found for this node",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) "driver found for this compatible",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) "multiple drivers found for this compatible",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) "kernel config found for this driver",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) "multiple config options found for this driver",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) "node is not enabled",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) "compatible is white listed",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) "matching driver and/or kernel config is hard coded",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) "kernel config hard coded in Makefile",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) "one or more kernel config file options is not set",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) "one or more kernel config file options is set to 'm'",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) "one or more kernel config file options is set to 'y'",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) "one of more kernel config file options fails to have correct value"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) # -----
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) %driver_config = (); # driver config array, indexed by driver source file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) %driver_count = (); # driver_cnt, indexed by compatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) %compat_driver = (); # compatible driver array, indexed by compatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) %existing_config = (); # existing config symbols present in given config file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) # expected values are: "y", "m", a decimal number, a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) # hex number, or a string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) # ----- magic compatibles, do not have a driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) # Will not search for drivers for these compatibles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) %compat_white_list = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 'none' => '1',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 'pci' => '1',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 'simple-bus' => '1',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) # Will not search for drivers for these compatibles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) # These compatibles have a very large number of false positives.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) # 'hardcoded_no_driver' is a magic value. Other code knows this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) # magic value. Do not use 'no_driver' here!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) # Revisit each 'hardcoded_no_driver' to see how the compatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) # is used. Are there drivers that can be provided?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) %driver_hard_code_list = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) 'cache' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) 'eeprom' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) 'gpio' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) 'gpio-keys' => ['drivers/input/keyboard/gpio_keys.c'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) 'i2c-gpio' => ['drivers/i2c/busses/i2c-gpio.c'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) 'isa' => ['arch/mips/mti-malta/malta-dt.c',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) 'arch/x86/kernel/devicetree.c'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) 'led' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) 'm25p32' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 'm25p64' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 'm25p80' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 'mtd-ram' => ['drivers/mtd/maps/physmap_of.c'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 'pwm-backlight' => ['drivers/video/backlight/pwm_bl.c'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 'spidev' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 'syscon' => ['drivers/mfd/syscon.c'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 'tlv320aic23' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 'wm8731' => ['hardcoded_no_driver'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) # Use these config options instead of searching makefiles
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) %driver_config_hard_code_list = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) # this one needed even if %driver_hard_code_list is empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 'no_driver' => ['no_config'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 'hardcoded_no_driver' => ['no_config'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) # drivers/usb/host/ehci-ppc-of.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) # drivers/usb/host/ehci-xilinx-of.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) # are included from:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) # drivers/usb/host/ehci-hcd.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) # thus the search of Makefile for the included .c files is incorrect
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) # ehci-hcd.c wraps the includes with ifdef CONFIG_USB_EHCI_HCD_..._OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) # similar model for ohci-hcd.c (but no ohci-xilinx-of.c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) #
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) # similarly, uhci-hcd.c includes uhci-platform.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 'drivers/usb/host/ehci-ppc-of.c' => ['CONFIG_USB_EHCI_HCD',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 'CONFIG_USB_EHCI_HCD_PPC_OF'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 'drivers/usb/host/ohci-ppc-of.c' => ['CONFIG_USB_OHCI_HCD',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 'CONFIG_USB_OHCI_HCD_PPC_OF'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 'drivers/usb/host/ehci-xilinx-of.c' => ['CONFIG_USB_EHCI_HCD',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 'CONFIG_USB_EHCI_HCD_XILINX'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 'drivers/usb/host/uhci-platform.c' => ['CONFIG_USB_UHCI_HCD',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 'CONFIG_USB_UHCI_PLATFORM'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) # scan_makefile will find only one of these config options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) # ifneq ($(CONFIG_SOC_IMX6)$(CONFIG_SOC_LS1021A),)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 'arch/arm/mach-imx/platsmp.c' => ['CONFIG_SOC_IMX6 && CONFIG_SMP',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 'CONFIG_SOC_LS1021A && CONFIG_SMP'],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) # 'virt/kvm/arm/.*' are controlled by makefiles in other directories,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) # using relative paths, such as 'KVM := ../../../virt/kvm'. Do not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) # add complexity to find_kconfig() to deal with this. There is a long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) # term intent to change the kvm related makefiles to the normal kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) # style. After that is done, this entry can be removed from the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) # black_list_driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) @black_list_driver = (
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) # kvm no longer a problem after commit 503a62862e8f in 4.7-rc1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) # 'virt/kvm/arm/.*',
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) );
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) sub usage()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) print
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) Usage: $script_name [options] device-tree...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) device_tree is: dts_file | dtb_file | proc_device-tree
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) Valid options:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) -c FILE Read kernel config options from FILE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) --config FILE synonym for 'c'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) --config-format config file friendly output format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) --exclude-flag FLAG exclude entries with a matching flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) -h Display this message and exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) --help synonym for 'h'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) --black-list-driver use driver black list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) --white-list-config use config white list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) --white-list-driver use driver white list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) --include-flag FLAG include only entries with a matching flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) --include-suspect include only entries with an uppercase flag
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) --short-name do not show the path portion of the node name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) --show-lists report of white and black lists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) --version Display program version and exit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) Report driver source files that match the compatibles in the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) tree file and the kernel config options that enable the driver source
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) files.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) This program must be run in the root directory of a Linux kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) source tree.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) The default format is a report that is intended to be easily human
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) scannable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) An alternate format can be selected by --config-format. This will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) create output that can easily be edited to create a fragment that can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) be appended to the existing kernel config file. Each entry consists of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) multiple lines. The first line reports flags, the node path, compatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) value, driver file matching the compatible, configuration options, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) current values of the configuration options. For each configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) option, the following lines report the current value and the value that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) is required for the driver file to be included in the kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) If a large number of drivers or config options is listed for a node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) and the '$pr_flag_value[$pr_flag_pos_hard_coded]' flag is set consider using --white-list-config and/or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) --white-list-driver. If the white list option suppresses the correct
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) entry please report that as a bug.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) CAUTION:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) This program uses heuristics to guess which driver(s) support each
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) compatible string and which config option(s) enables the driver(s).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) Do not believe that the reported information is fully correct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) This program is intended to aid the process of determining the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) proper kernel configuration for a device tree, but this is not
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) a fully automated process -- human involvement may still be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) required!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) The driver match heuristic used is to search for source files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) containing the compatible string enclosed in quotes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) This program might not be able to find all drivers matching a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) compatible string.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) Some makefiles are overly clever. This program was not made
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) complex enough to handle them. If no config option is listed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) for a driver, look at the makefile for the driver source file.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) Even if a config option is listed for a driver, some other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) available config options may not be listed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) FLAG values:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) for ($k = 0; $k < $num_pr_flags; $k++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) printf " %s %s\n", $pr_flag_value[$k], $pr_flag_help[$k];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) print
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) Upper case letters indicate potential issues or problems.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) The flag:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) $k = $pr_flag_pos_hard_coded;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) printf " %s %s\n", $pr_flag_value[$k], $pr_flag_help[$k];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) print
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) will be set if the config or driver is in the white lists, even if
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) --white-list-config and --white-list-driver are not specified.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) This is a hint that 1) many of these reported lines are likely to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) be incorrect, and 2) using those options will reduce the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) drivers and/or config options reported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) --white-list-config and --white-list-driver may not be accurate if this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) program is not well maintained. Use them with appropriate skepticism.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) Use the --show-lists option to report the values in the list.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) Return value:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 0 if no error
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 1 error processing command line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 2 unable to open or read kernel config file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 3 unable to open or process input device tree file(s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) EXAMPLES:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) dt_to_config arch/arm/boot/dts/my_dts_file.dts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) Basic report.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) dt_to_config \\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) --config \${KBUILD_OUTPUT}/.config \\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) arch/\${ARCH}/boot/dts/my_dts_file.dts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) Full report, with config file issues noted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) dt_to_config --include-suspect \\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) --config \${KBUILD_OUTPUT}/.config \\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) arch/\${ARCH}/boot/dts/my_dts_file.dts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) Report of node / compatible string / driver tuples that should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) be further investigated. A node may have multiple compatible
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) strings. A compatible string may be matched by multiple drivers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) A driver may have config file issues noted. The compatible string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) and/or driver may be in the white lists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) dt_to_config --include-suspect --config-format \\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) --config ${KBUILD_OUTPUT}/.config \\
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) arch/\${ARCH}/boot/dts/my_dts_file.dts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) Report of node / compatible string / driver tuples that should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) be further investigated. The report can be edited to uncomment
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) the config options to select the desired tuple for a given node.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) A node may have multiple compatible strings. A compatible string
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) may be matched by multiple drivers. A driver may have config file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) issues noted. The compatible string and/or driver may be in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) white lists.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) sub set_flag()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) # pr_flags_ref is a reference to $pr_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) my $pr_flags_ref = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) my $pos = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) substr $$pr_flags_ref, $pos, 1, $pr_flag_value[$pos];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) return $pr_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) sub print_flags()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) # return 1 if anything printed, else 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) # some fields of pn_arg_ref might not be used in this function, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) # extract all of them anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) my $pn_arg_ref = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) my $compat = $pn_arg_ref->{compat};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) my $compatible_cnt = $pn_arg_ref->{compatible_cnt};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) my $config = $pn_arg_ref->{config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) my $config_cnt = $pn_arg_ref->{config_cnt};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) my $driver = $pn_arg_ref->{driver};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) my $driver_cnt = $pn_arg_ref->{driver_cnt};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) my $full_node = $pn_arg_ref->{full_node};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) my $node = $pn_arg_ref->{node};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) my $node_enabled = $pn_arg_ref->{node_enabled};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) my $white_list = $pn_arg_ref->{white_list};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) my $pr_flags = '-' x $num_pr_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) # ----- set flags in $pr_flags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) if ($compatible_cnt > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) &set_flag(\$pr_flags, $pr_flag_pos_mcompatible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) if ($config_cnt > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) &set_flag(\$pr_flags, $pr_flag_pos_mconfig);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if ($driver_cnt >= 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) &set_flag(\$pr_flags, $pr_flag_pos_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) if ($driver_cnt > 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) &set_flag(\$pr_flags, $pr_flag_pos_mdriver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) # These strings are the same way the linux kernel tests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) # The ePapr lists of values is slightly different.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) if (!(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) ($node_enabled eq "") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) ($node_enabled eq "ok") ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) ($node_enabled eq "okay")
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) )) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) &set_flag(\$pr_flags, $pr_flag_pos_node_not_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) if ($white_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) &set_flag(\$pr_flags, $pr_flag_pos_white_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) if (exists($driver_hard_code_list{$compat}) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) (exists($driver_config_hard_code_list{$driver}) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) ($driver ne "no_driver"))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) &set_flag(\$pr_flags, $pr_flag_pos_hard_coded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) my @configs = split(' && ', $config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) for $configs (@configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) $not = $configs =~ /^!/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) $configs =~ s/^!//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) if (($configs ne "no_config") && ($configs ne "no_makefile")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) &set_flag(\$pr_flags, $pr_flag_pos_config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) if (($config_cnt >= 1) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) ($configs !~ /CONFIG_/) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) (($configs ne "no_config") && ($configs ne "no_makefile"))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) &set_flag(\$pr_flags, $pr_flag_pos_config_hard_coded);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) my $existing_config = $existing_config{$configs};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) if ($existing_config eq "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) &set_flag(\$pr_flags, $pr_flag_pos_config_m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) # Possible fail, depends on whether built in or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) # module is desired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) &set_flag(\$pr_flags, $pr_flag_pos_config_test_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) } elsif ($existing_config eq "y") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) &set_flag(\$pr_flags, $pr_flag_pos_config_y);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) if ($not) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) &set_flag(\$pr_flags, $pr_flag_pos_config_test_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) } elsif (($config_file) && ($configs =~ /CONFIG_/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) &set_flag(\$pr_flags, $pr_flag_pos_config_none);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (!$not) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) &set_flag(\$pr_flags, $pr_flag_pos_config_test_fail);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) # ----- include / exclude filters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) if ($include_flag_pattern && ($pr_flags !~ m/$include_flag_pattern/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) if ($exclude_flag_pattern && ($pr_flags =~ m/$exclude_flag_pattern/)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) if ($config_format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) print "# ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) print "$pr_flags : ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) sub print_node()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) # return number of lines printed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) # some fields of pn_arg_ref might not be used in this function, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) # extract all of them anyway.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) my $pn_arg_ref = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) my $compat = $pn_arg_ref->{compat};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) my $compatible_cnt = $pn_arg_ref->{compatible_cnt};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) my $config = $pn_arg_ref->{config};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) my $config_cnt = $pn_arg_ref->{config_cnt};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) my $driver = $pn_arg_ref->{driver};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) my $driver_cnt = $pn_arg_ref->{driver_cnt};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) my $full_node = $pn_arg_ref->{full_node};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) my $node = $pn_arg_ref->{node};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) my $node_enabled = $pn_arg_ref->{node_enabled};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) my $white_list = $pn_arg_ref->{white_list};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) my $separator;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if (! &print_flags($pn_arg_ref)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) if ($short_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) print "$node";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) print "$full_node";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) print " : $compat : $driver : $config : ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) my @configs = split(' && ', $config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) if ($config_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) for $configs (@configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) $configs =~ s/^!//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) my $existing_config = $existing_config{$configs};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) if (!$existing_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) # check for /-m/, /-y/, or /-objs/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) if ($configs !~ /CONFIG_/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) $existing_config = "x";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) if ($existing_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) print "$separator", "$existing_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) $separator = ", ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) print "$separator", "n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) $separator = ", ";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) print "none";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) if ($config_format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) for $configs (@configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) $not = $configs =~ /^!/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) $configs =~ s/^!//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) my $existing_config = $existing_config{$configs};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) if ($not) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) if ($configs !~ /CONFIG_/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) print "# $configs\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) } elsif ($existing_config eq "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) print "# $configs is m\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) print "# $configs=n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) } elsif ($existing_config eq "y") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) print "# $configs is set\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) print "# $configs=n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) print "# $configs is not set\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) print "# $configs=n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) if ($configs !~ /CONFIG_/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) print "# $configs\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) } elsif ($existing_config eq "m") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) print "# $configs is m\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) print "# $configs=y\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) } elsif ($existing_config eq "y") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) print "# $configs is set\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) print "# $configs=y\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) print "# $configs is not set\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) print "# $configs=y\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) sub scan_makefile
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) my $pn_arg_ref = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) my $driver = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) # ----- Find Kconfig symbols that enable driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) my ($dir, $base) = $driver =~ m{(.*)/(.*).c};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) my $makefile = $dir . "/Makefile";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) if (! -r $makefile) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) $makefile = $dir . "/Kbuild";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) if (! -r $makefile) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) my $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) $config = 'no_makefile';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) push @{ $driver_config{$driver} }, $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) if (!open(MAKEFILE_FILE, "<", "$makefile")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) my @config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) my @if_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) my @make_var;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) NEXT_LINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) while ($next_line = <MAKEFILE_FILE>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) my $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) my $if_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) my $ifdef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) my $ifeq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) my $ifndef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) my $ifneq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) my $ifdef_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) my $ifeq_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) my $ifndef_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) my $ifneq_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) chomp($next_line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) $line = $line . $next_line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) if ($next_line =~ /\\$/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) $line =~ s/\\$/ /;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) next NEXT_LINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) if ($line =~ /^\s*#/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) $line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) next NEXT_LINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) # ----- condition ... else ... endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) if ($line =~ /^([ ]\s*|)else\b/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) $if_config = "!" . pop @if_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) $if_config =~ s/^!!//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) push @if_config, $if_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) $line =~ s/^([ ]\s*|)else\b//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) ($null, $ifeq_config, $ifeq_config_val ) = $line =~ /^([ ]\s*|)ifeq\b.*\b(CONFIG_[A-Za-z0-9_]*)(.*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) ($null, $ifneq_config, $ifneq_config_val) = $line =~ /^([ ]\s*|)ifneq\b.*\b(CONFIG_[A-Za-z0-9_]*)(.*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) ($null, $ifdef_config) = $line =~ /^([ ]\s*|)ifdef\b.*\b(CONFIG_[A-Za-z0-9_]*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) ($null, $ifndef_config) = $line =~ /^([ ]\s*|)ifndef\b.*\b(CONFIG_[A-Za-z0-9_]*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) ($null, $ifeq) = $line =~ /^([ ]\s*|)ifeq\b\s*(.*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) ($null, $ifneq) = $line =~ /^([ ]\s*|)ifneq\b\s*(.*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) ($null, $ifdef) = $line =~ /^([ ]\s*|)ifdef\b\s*(.*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) ($null, $ifndef) = $line =~ /^([ ]\s*|)ifndef\b\s*(.*)/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) # Order of tests is important. Prefer "CONFIG_*" regex match over
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) # less specific regex match.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) if ($ifdef_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) $if_config = $ifdef_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) } elsif ($ifeq_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) if ($ifeq_config_val =~ /y/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) $if_config = $ifeq_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) $if_config = "!" . $ifeq_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) } elsif ($ifndef_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) $if_config = "!" . $ifndef_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) } elsif ($ifneq_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) if ($ifneq_config_val =~ /y/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) $if_config = "!" . $ifneq_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) $if_config = $ifneq_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) } elsif ($ifdef) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) $if_config = $ifdef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) } elsif ($ifeq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) $if_config = $ifeq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) } elsif ($ifndef) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) $if_config = "!" . $ifndef;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) } elsif ($ifneq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) $if_config = "!" . $ifneq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) $if_config = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) $if_config =~ s/^!!//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) if ($if_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) push @if_config, $if_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) $line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) next NEXT_LINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if ($line =~ /^([ ]\s*|)endif\b/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) pop @if_config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) $line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) next NEXT_LINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) # ----- simple CONFIG_* = *.[co] or xxx [+:?]*= *.[co]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) # Most makefiles select on *.o, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) # arch/powerpc/boot/Makefile selects on *.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) ($config) = $line =~ /(CONFIG_[A-Za-z0-9_]+).*\b$base.[co]\b/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) # ----- match a make variable instead of *.[co]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) # Recursively expanded variables are not handled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) if (!$config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) my $make_var;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) ($make_var) = $line =~ /\s*(\S+?)\s*[+:\?]*=.*\b$base.[co]\b/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) if ($make_var) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) if ($make_var =~ /[a-zA-Z0-9]+-[ym]/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) $config = $make_var;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) } elsif ($make_var =~ /[a-zA-Z0-9]+-objs/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) $config = $make_var;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) push @make_var, $make_var;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) if (!$config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) for $make_var (@make_var) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) ($config) = $line =~ /(CONFIG_[A-Za-z0-9_]+).*\b$make_var\b/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) last if ($config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) if (!$config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) for $make_var (@make_var) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) ($config) = $line =~ /\s*(\S+?)\s*[+:\?]*=.*\b$make_var\b/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) last if ($config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) # ----- next if no config found
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) if (!$config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) $line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) next NEXT_LINE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) for $if_config (@if_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) $config = $if_config . " && " . $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) push @{ $driver_config{$driver} }, $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) $line = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) close(MAKEFILE_FILE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) sub find_kconfig
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) my $pn_arg_ref = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) my $driver = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) my $lines_printed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) my @configs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) if (!@{ $driver_config{$driver} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) &scan_makefile($pn_arg_ref, $driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) if (!@{ $driver_config{$driver} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) push @{ $driver_config{$driver} }, "no_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) @configs = @{ $driver_config{$driver} };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) $$pn_arg_ref{config_cnt} = $#configs + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) for my $config (@configs) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) $$pn_arg_ref{config} = $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) $lines_printed += &print_node($pn_arg_ref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) return $lines_printed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) sub handle_compatible()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) my $full_node = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) my $node = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) my $compatible = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) my $node_enabled = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) my $compat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) my $lines_printed = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) my %pn_arg = ();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) return if (!$node or !$compatible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) # Do not process compatible property of root node,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) # it is used to match board, not to bind a driver.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) return if ($node eq "/");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) $pn_arg{full_node} = $full_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) $pn_arg{node} = $node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) $pn_arg{node_enabled} = $node_enabled;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) my @compatibles = split('", "', $compatible);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) $compatibles[0] =~ s/^"//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) $compatibles[$#compatibles] =~ s/"$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) $pn_arg{compatible_cnt} = $#compatibles + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) COMPAT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) for $compat (@compatibles) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) $pn_arg{compat} = $compat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) $pn_arg{driver_cnt} = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) $pn_arg{white_list} = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) if (exists($compat_white_list{$compat})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) $pn_arg{white_list} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) $pn_arg{driver} = "no_driver";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) $pn_arg{config_cnt} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) $pn_arg{config} = "no_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) $lines_printed += &print_node(\%pn_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) next COMPAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) # ----- if compat previously seen, use cached info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) if (exists($compat_driver{$compat})) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) for my $driver (@{ $compat_driver{$compat} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) $pn_arg{driver} = $driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) $pn_arg{driver_cnt} = $driver_count{$compat};
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) $pn_arg{config_cnt} = $#{ $driver_config{$driver}} + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) for my $config (@{ $driver_config{$driver} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) $pn_arg{config} = $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) $lines_printed += &print_node(\%pn_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) if (!@{ $driver_config{$driver} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) # no config cached yet
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) # $driver in %driver_hard_code_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) # but not %driver_config_hard_code_list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) $lines_printed += &find_kconfig(\%pn_arg, $driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) next COMPAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) # ----- Find drivers (source files that contain compatible)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) # this will miss arch/sparc/include/asm/parport.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) # It is better to move the compatible out of the .h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) # than to add *.h. to the files list, because *.h generates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) # a lot of false negatives.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) my $files = '"*.c"';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) my $drivers = `git grep -l '"$compat"' -- $files`;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) chomp($drivers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) if ($drivers eq "") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) $pn_arg{driver} = "no_driver";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) $pn_arg{config_cnt} = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) $pn_arg{config} = "no_config";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) push @{ $compat_driver{$compat} }, "no_driver";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) $lines_printed += &print_node(\%pn_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) next COMPAT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) my @drivers = split("\n", $drivers);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) $driver_count{$compat} = $#drivers + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) $pn_arg{driver_cnt} = $#drivers + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) DRIVER:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) for my $driver (@drivers) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) push @{ $compat_driver{$compat} }, $driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) $pn_arg{driver} = $driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) # ----- if driver previously seen, use cached info
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) $pn_arg{config_cnt} = $#{ $driver_config{$driver} } + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) for my $config (@{ $driver_config{$driver} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) $pn_arg{config} = $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) $lines_printed += &print_node(\%pn_arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) if (@{ $driver_config{$driver} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) next DRIVER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) if ($black_list_driver) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) for $black (@black_list_driver) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) next DRIVER if ($driver =~ /^$black$/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) # ----- Find Kconfig symbols that enable driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) $lines_printed += &find_kconfig(\%pn_arg, $driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) # White space (line) between nodes for readability.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) # Each node may report several compatibles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) # For each compatible, multiple drivers may be reported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) # For each driver, multiple CONFIG_ options may be reported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) if ($lines_printed) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) sub read_dts()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) my $file = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) my $compatible = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) my $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) my $node = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) my $node_enabled = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) if (! -r $file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) print STDERR "file '$file' is not readable or does not exist\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) exit 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) if (!open(DT_FILE, "-|", "$dtx_diff $file")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) print STDERR "shell command failed:\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) print STDERR " $dtx_diff $file\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) exit 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) FILE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) while ($line = <DT_FILE>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) chomp($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) if ($line =~ /{/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) &handle_compatible($full_node, $node, $compatible,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) $node_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) while ($end_node_count-- > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) pop @full_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) $end_node_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) $full_node = @full_node[-1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) $node = $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) $node =~ s/^\s*(.*)\s+\{.*/$1/;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) $node =~ s/.*: //;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) if ($node eq '/' ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) $full_node = '/';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) } elsif ($full_node ne '/') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) $full_node = $full_node . '/' . $node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) $full_node = '/' . $node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) push @full_node, $full_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) $compatible = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) $node_enabled = "";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) next FILE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) if ($line =~ /}/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) $end_node_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) if ($line =~ /(\s+|^)status =/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) $node_enabled = $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) $node_enabled =~ s/^\t*//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) $node_enabled =~ s/^status = "//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) $node_enabled =~ s/";$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) next FILE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) if ($line =~ /(\s+|^)compatible =/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) # Extract all compatible entries for this device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) # White space matching here and in handle_compatible() is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) # precise, because input format is the output of dtc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) # which is invoked by dtx_diff.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) $compatible = $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) $compatible =~ s/^\t*//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) $compatible =~ s/^compatible = //;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) $compatible =~ s/;$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) &handle_compatible($full_node, $node, $compatible, $node_enabled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) close(DT_FILE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) sub read_config_file()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) if (! -r $config_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) print STDERR "file '$config_file' is not readable or does not exist\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) exit 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) if (!open(CONFIG_FILE, "<", "$config_file")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) print STDERR "open $config_file failed\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) exit 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) my @line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) LINE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) while ($line = <CONFIG_FILE>) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) chomp($line);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) next LINE if ($line =~ /^\s*#/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) next LINE if ($line =~ /^\s*$/);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) @line = split /=/, $line;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) $existing_config{@line[0]} = @line[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) close(CONFIG_FILE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) sub cmd_line_err()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) my $msg = shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) print STDERR " ERROR processing command line options\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) print STDERR " $msg\n" if ($msg ne "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) print STDERR " For help, type '$script_name --help'\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) # -----------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) # program entry point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) Getopt::Long::Configure("no_ignore_case", "bundling");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) if (!GetOptions(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) "c=s" => \$config_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) "config=s" => \$config_file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) "config-format" => \$config_format,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992) "exclude-flag=s" => \@exclude_flag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) "h" => \$help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) "help" => \$help,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) "black-list-driver" => \$black_list_driver,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) "white-list-config" => \$white_list_config,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) "white-list-driver" => \$white_list_driver,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) "include-flag=s" => \@include_flag,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) "include-suspect" => \$include_suspect,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) "short-name" => \$short_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) "show-lists" => \$show_lists,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) "version" => \$version,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) )) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) &cmd_line_err();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) exit 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) my $exit_after_messages = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) if ($version) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) print STDERR "\n$script_name $VUFX\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) $exit_after_messages = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) if ($help) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) &usage;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) $exit_after_messages = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) if ($show_lists) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) print "These compatibles are hard coded to have no driver.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) for my $compat (sort keys %compat_white_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) print " $compat\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) print "\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) print "The driver for these compatibles is hard coded (white list).\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) my $max_compat_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) for my $compat (sort keys %driver_hard_code_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) if (length $compat > $max_compat_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) $max_compat_len = length $compat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) for my $compat (sort keys %driver_hard_code_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) if (($driver ne "hardcoded_no_driver") && ($driver ne "no_driver")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) my $first = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) for my $driver (@{ $driver_hard_code_list{$compat} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) if ($first) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) print " $compat";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) print " " x ($max_compat_len - length $compat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) $first = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) print " ", " " x $max_compat_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) print " $driver\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) print "\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) print "The configuration option for these drivers is hard coded (white list).\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) my $max_driver_len = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) for my $driver (sort keys %driver_config_hard_code_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) if (length $driver > $max_driver_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) $max_driver_len = length $driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) for my $driver (sort keys %driver_config_hard_code_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) if (($driver ne "hardcoded_no_driver") && ($driver ne "no_driver")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) my $first = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) for my $config (@{ $driver_config_hard_code_list{$driver} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) if ($first) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) print " $driver";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) print " " x ($max_driver_len - length $driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) $first = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) print " ", " " x $max_driver_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) print " $config\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) print "\n\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) print "These drivers are black listed.\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) for my $driver (@black_list_driver) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) print " $driver\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) print "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) $exit_after_messages = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) if ($exit_after_messages) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) exit 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) $exclude_flag_pattern = "[";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) for my $exclude_flag (@exclude_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) $exclude_flag_pattern = $exclude_flag_pattern . $exclude_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) $exclude_flag_pattern = $exclude_flag_pattern . "]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) # clean up if empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) $exclude_flag_pattern =~ s/^\[\]$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) $include_flag_pattern = "[";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) for my $include_flag (@include_flag) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) $include_flag_pattern = $include_flag_pattern . $include_flag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) $include_flag_pattern = $include_flag_pattern . "]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) # clean up if empty
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) $include_flag_pattern =~ s/^\[\]$//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) if ($exclude_flag_pattern) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) my $found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) for $pr_flag_value (@pr_flag_value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) if ($exclude_flag_pattern =~ m/$pr_flag_value/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) $found = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) if (!$found) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) &cmd_line_err("invalid value for FLAG in --exclude-flag\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) if ($include_flag_pattern) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) my $found = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) for $pr_flag_value (@pr_flag_value) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) if ($include_flag_pattern =~ m/$pr_flag_value/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) $found = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) if (!$found) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) &cmd_line_err("invalid value for FLAG in --include-flag\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) if ($include_suspect) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) $include_flag_pattern =~ s/\[//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) $include_flag_pattern =~ s/\]//;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) $include_flag_pattern = "[" . $include_flag_pattern . "A-Z]";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) if ($exclude_flag_pattern =~ m/$include_flag_pattern/) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) &cmd_line_err("the same flag appears in both --exclude-flag and --include-flag or --include-suspect\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) # ($#ARGV < 0) is valid for --help, --version
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) if ($#ARGV < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) &cmd_line_err("device-tree... is required");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) exit 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) if ($config_file) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) &read_config_file();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) # avoid pushing duplicates for this value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) $driver = "hardcoded_no_driver";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) for $config ( @{ $driver_config_hard_code_list{$driver} } ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) push @{ $driver_config{$driver} }, $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) if ($white_list_driver) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) for my $compat (keys %driver_hard_code_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) for my $driver (@{ $driver_hard_code_list{$compat} }) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) push @{ $compat_driver{$compat} }, $driver;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) if ($driver ne "hardcoded_no_driver") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) $driver_count{$compat} = scalar @{ $compat_driver{$compat} };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) if ($white_list_config) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) for my $driver (keys %driver_config_hard_code_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) if ($driver ne "hardcoded_no_driver") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) for $config ( @{ $driver_config_hard_code_list{$driver} } ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) push @{ $driver_config{$driver} }, $config;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) if (-x "scripts/dtc/dtx_diff") {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) $dtx_diff = "scripts/dtc/dtx_diff";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) print STDERR "$script_name must be run from the root directory of a Linux kernel tree\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) print STDERR "\n";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) exit 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) for $file (@ARGV) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) &read_dts($file);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) }