#!/usr/bin/env perl
# SPDX-License-Identifier: GPL-2.0-only
# Copyright 2016 by Frank Rowand
# Copyright 2016 by Gaurav Minocha
#
use strict 'refs';
use strict subs;
use Getopt::Long;
$VUFX = "160610a";
$script_name = $0;
$script_name =~ s|^.*/||;
# ----- constants for print_flags()
# Position in string $pr_flags. Range of 0..($num_pr_flags - 1).
$pr_flag_pos_mcompatible = 0;
$pr_flag_pos_driver = 1;
$pr_flag_pos_mdriver = 2;
$pr_flag_pos_config = 3;
$pr_flag_pos_mconfig = 4;
$pr_flag_pos_node_not_enabled = 5;
$pr_flag_pos_white_list = 6;
$pr_flag_pos_hard_coded = 7;
$pr_flag_pos_config_hard_coded = 8;
$pr_flag_pos_config_none = 9;
$pr_flag_pos_config_m = 10;
$pr_flag_pos_config_y = 11;
$pr_flag_pos_config_test_fail = 12;
$num_pr_flags = $pr_flag_pos_config_test_fail + 1;
# flags in @pr_flag_value must be unique values to allow simple regular
# expessions to work for --include_flags and --exclude_flags.
# Convention: use upper case letters for potential issues or problems.
@pr_flag_value = ('M', 'd', 'D', 'c', 'C', 'E', 'W', 'H', 'x', 'n', 'm', 'y', 'F');
@pr_flag_help = (
"multiple compatibles found for this node",
"driver found for this compatible",
"multiple drivers found for this compatible",
"kernel config found for this driver",
"multiple config options found for this driver",
"node is not enabled",
"compatible is white listed",
"matching driver and/or kernel config is hard coded",
"kernel config hard coded in Makefile",
"one or more kernel config file options is not set",
"one or more kernel config file options is set to 'm'",
"one or more kernel config file options is set to 'y'",
"one of more kernel config file options fails to have correct value"
);
# -----
%driver_config = (); # driver config array, indexed by driver source file
%driver_count = (); # driver_cnt, indexed by compatible
%compat_driver = (); # compatible driver array, indexed by compatible
%existing_config = (); # existing config symbols present in given config file
# expected values are: "y", "m", a decimal number, a
# hex number, or a string
# ----- magic compatibles, do not have a driver
#
# Will not search for drivers for these compatibles.
%compat_white_list = (
'none' => '1',
'pci' => '1',
'simple-bus' => '1',
);
# Will not search for drivers for these compatibles.
#
# These compatibles have a very large number of false positives.
#
# 'hardcoded_no_driver' is a magic value. Other code knows this
# magic value. Do not use 'no_driver' here!
#
# Revisit each 'hardcoded_no_driver' to see how the compatible
# is used. Are there drivers that can be provided?
%driver_hard_code_list = (
'cache' => ['hardcoded_no_driver'],
'eeprom' => ['hardcoded_no_driver'],
'gpio' => ['hardcoded_no_driver'],
'gpio-keys' => ['drivers/input/keyboard/gpio_keys.c'],
'i2c-gpio' => ['drivers/i2c/busses/i2c-gpio.c'],
'isa' => ['arch/mips/mti-malta/malta-dt.c',
'arch/x86/kernel/devicetree.c'],
'led' => ['hardcoded_no_driver'],
'm25p32' => ['hardcoded_no_driver'],
'm25p64' => ['hardcoded_no_driver'],
'm25p80' => ['hardcoded_no_driver'],
'mtd-ram' => ['drivers/mtd/maps/physmap_of.c'],
'pwm-backlight' => ['drivers/video/backlight/pwm_bl.c'],
'spidev' => ['hardcoded_no_driver'],
'syscon' => ['drivers/mfd/syscon.c'],
'tlv320aic23' => ['hardcoded_no_driver'],
'wm8731' => ['hardcoded_no_driver'],
);
# Use these config options instead of searching makefiles
%driver_config_hard_code_list = (
# this one needed even if %driver_hard_code_list is empty
'no_driver' => ['no_config'],
'hardcoded_no_driver' => ['no_config'],
# drivers/usb/host/ehci-ppc-of.c
# drivers/usb/host/ehci-xilinx-of.c
# are included from:
# drivers/usb/host/ehci-hcd.c
# thus the search of Makefile for the included .c files is incorrect
# ehci-hcd.c wraps the includes with ifdef CONFIG_USB_EHCI_HCD_..._OF
#
# similar model for ohci-hcd.c (but no ohci-xilinx-of.c)
#
# similarly, uhci-hcd.c includes uhci-platform.c
'drivers/usb/host/ehci-ppc-of.c' => ['CONFIG_USB_EHCI_HCD',
'CONFIG_USB_EHCI_HCD_PPC_OF'],
'drivers/usb/host/ohci-ppc-of.c' => ['CONFIG_USB_OHCI_HCD',
'CONFIG_USB_OHCI_HCD_PPC_OF'],
'drivers/usb/host/ehci-xilinx-of.c' => ['CONFIG_USB_EHCI_HCD',
'CONFIG_USB_EHCI_HCD_XILINX'],
'drivers/usb/host/uhci-platform.c' => ['CONFIG_USB_UHCI_HCD',
'CONFIG_USB_UHCI_PLATFORM'],
# scan_makefile will find only one of these config options:
# ifneq ($(CONFIG_SOC_IMX6)$(CONFIG_SOC_LS1021A),)
'arch/arm/mach-imx/platsmp.c' => ['CONFIG_SOC_IMX6 && CONFIG_SMP',
'CONFIG_SOC_LS1021A && CONFIG_SMP'],
);
# 'virt/kvm/arm/.*' are controlled by makefiles in other directories,
# using relative paths, such as 'KVM := ../../../virt/kvm'. Do not
# add complexity to find_kconfig() to deal with this. There is a long
# term intent to change the kvm related makefiles to the normal kernel
# style. After that is done, this entry can be removed from the
# black_list_driver.
@black_list_driver = (
# kvm no longer a problem after commit 503a62862e8f in 4.7-rc1
# 'virt/kvm/arm/.*',
);
<