From 3bdc802dbf1b81bb8acdbe708b3a0174d3ceed56 Mon Sep 17 00:00:00 2001 From: Wanwei Jiang Date: Thu, 2 Feb 2023 15:49:10 +0800 Subject: [PATCH] init: initialize the building framework of androidu-5.15 for amlogic [1/1] PD#SWPL-109858 Problem: Initialize the building framework of androidu-5.15 for amlogic Solution: Initialize the building framework of androidu-5.15 for amlogic Verify: sc2 Change-Id: Icfbc29709af1545b802ed7794808a2ab560ed08a Signed-off-by: Wanwei Jiang --- .gitignore | 3 + Makefile | 43 ++- drivers/Kconfig | 61 +++ scripts/amlogic/licence_check.pl | 153 ++++++++ scripts/amlogic/licence_pre.pl | 53 +++ scripts/amlogic/merge_pre_check.pl | 429 ++++++++++++++++++++++ scripts/amlogic/pre-commit | 24 ++ scripts/amlogic/pre-commit-common_drivers | 24 ++ scripts/checkpatch.pl | 148 ++++---- scripts/kconfig/Makefile | 9 +- usr/include/Makefile | 4 + 11 files changed, 874 insertions(+), 77 deletions(-) create mode 100755 scripts/amlogic/licence_check.pl create mode 100755 scripts/amlogic/licence_pre.pl create mode 100755 scripts/amlogic/merge_pre_check.pl create mode 100755 scripts/amlogic/pre-commit create mode 100755 scripts/amlogic/pre-commit-common_drivers diff --git a/.gitignore b/.gitignore index 265959544978..0bbfe4cd37fc 100644 --- a/.gitignore +++ b/.gitignore @@ -162,3 +162,6 @@ x509.genkey # Documentation toolchain sphinx_*/ + +# amlogic drivers +/common_drivers/ diff --git a/Makefile b/Makefile index a4b02752f44a..32e28f343fb4 100644 --- a/Makefile +++ b/Makefile @@ -438,6 +438,14 @@ ifneq ($(SRCARCH),$(SUBARCH)) cross_compiling := 1 endif +# ifdef CONFIG_AMLOGIC_DRIVER +# config cannot be used here to mark AMLOGIC modifications +# If these three variables are not set externally, set their default values +export COMMON_DRIVERS_DIR ?= common_drivers +dtstree ?= $(COMMON_DRIVERS_DIR)/arch/$(SRCARCH)/boot/dts/ +export DTC_INCLUDE ?= $(srctree)/$(COMMON_DRIVERS_DIR)/include +# endif + KCONFIG_CONFIG ?= .config export KCONFIG_CONFIG @@ -689,10 +697,26 @@ ifdef need-config include include/config/auto.conf endif +ifdef CONFIG_AMLOGIC_DRIVER +USERINCLUDE += \ + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include \ + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include/uapi + +LINUXINCLUDE += \ + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include \ + -I$(srctree)/$(COMMON_DRIVERS_DIR)/include/uapi +KBUILD_CFLAGS += -Werror +KBUILD_AFLAGS += -Wno-unused-command-line-argument +endif + ifeq ($(KBUILD_EXTMOD),) # Objects we will link into vmlinux / subdirs we need to visit core-y := init/ usr/ arch/$(SRCARCH)/ drivers-y := drivers/ sound/ +ifdef CONFIG_AMLOGIC_IN_KERNEL_MODULES +drivers-y += $(COMMON_DRIVERS_DIR)/drivers/ $(COMMON_DRIVERS_DIR)/sound/ +drivers-y += $(COMMON_DRIVERS_DIR)/samples/ +endif drivers-$(CONFIG_SAMPLES) += samples/ drivers-$(CONFIG_NET) += net/ drivers-y += virt/ @@ -1220,6 +1244,9 @@ ifeq ($(KBUILD_EXTMOD),) endif $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi +ifdef CONFIG_AMLOGIC_DRIVER + $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)$(COMMON_DRIVERS_DIR)/include/uapi +endif ifeq ($(KBUILD_EXTMOD),) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ @@ -1482,10 +1509,22 @@ endif ifneq ($(dtstree),) %.dtb: include/config/kernel.release scripts_dtc - $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ +ifdef CONFIG_AMLOGIC_DRIVER + $(if $(wildcard $(srctree)/$(dtstree)/amlogic/$(addsuffix .dts,$(basename $@))),\ + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/amlogic/$@,\ + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@) +else + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@) +endif %.dtbo: include/config/kernel.release scripts_dtc - $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ +ifdef CONFIG_AMLOGIC_DRIVER + $(if $(wildcard $(srctree)/$(dtstree)/amlogic/$(addsuffix .dts,$(basename $@))),\ + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/amlogic/$@,\ + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@) +else + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@) +endif PHONY += dtbs dtbs_install dtbs_check dtbs: include/config/kernel.release scripts_dtc diff --git a/drivers/Kconfig b/drivers/Kconfig index 67f44716797e..b45de86239e1 100644 --- a/drivers/Kconfig +++ b/drivers/Kconfig @@ -238,4 +238,65 @@ source "drivers/interconnect/Kconfig" source "drivers/counter/Kconfig" source "drivers/most/Kconfig" + +config AMLOGIC_DRIVER + bool "Amlogic Peripheral drivers" + default n + help + this option is provided for control amlogic + drivers, if you want to use amlogic driver + please open it. + Note: All amlogic driver should be placed in + directory $(COMMON_DRIVERS_DIR)/drivers/ + +if AMLOGIC_DRIVER +config AMLOGIC_BREAK_GKI_20 + bool "Amlogic Break GKI 2.0" + default n + help + this option is provide for control Break GKI 2.0, + if you want to break gki2.0 rule, should enable it, + all break gki2.0 modify should be depends on this option + +config AMLOGIC_BREAK_GKI + bool "Amlogic Break GKI" + select AMLOGIC_BREAK_GKI_20 + default n + help + this option is provide for control Break GKI, + if you want to debug driver temporarily, should enable it, + export function or variable with this config, + and the driver Kconfig depends on this option + +config AMLOGIC_MODIFY + bool "Amlogic modify for kernel code" + default n + help + This option is set up for AMLOGIC modify of standard + kernel source code. All modify of kernel standard code + should be wrapped by this config + +config AMLOGIC_IN_KERNEL_MODULES + bool "Amlogic Drivers in build or extra build" + default n + help + this option is provided for control amlogic + drivers in build or extra build, if you want + to in build, should enable; if want to extra + build, should disable + +config AMLOGIC_KERNEL_VERSION + int "Amlogic Kernel Version" + default 14515 + help + kernel from android14-5.15 + so the default value is 14515 + the driver uses it to adapt different kernel versions + +if AMLOGIC_IN_KERNEL_MODULES +source "$(COMMON_DRIVERS_DIR)/drivers/Kconfig" +source "$(COMMON_DRIVERS_DIR)/sound/Kconfig" +source "$(COMMON_DRIVERS_DIR)/samples/Kconfig" +endif +endif endmenu diff --git a/scripts/amlogic/licence_check.pl b/scripts/amlogic/licence_check.pl new file mode 100755 index 000000000000..2163ce102ab6 --- /dev/null +++ b/scripts/amlogic/licence_check.pl @@ -0,0 +1,153 @@ +#!/usr/bin/perl -W +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +# +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. +# +use File::Basename; +use File::Find; + +$sc_dir = File::Spec->rel2abs(dirname( "$0") ) ; +$sc_dir =~ s/\/scripts\/amlogic//; +my $top = "$sc_dir"; + +my $nofix = 0; +my $failno = 0; +my $shname = $0; +#@ARGV=("../../include/linux/amlogic","../../drivers/amlogic" ) ; +my @path; +for(@ARGV) +{ + my $dir =$_; + if(/^\//) + { + } + elsif(/--nofix/) + { + $nofix = 1; + next; + } + else + { + $dir = File::Spec->rel2abs($dir); + #print "\n Real2abs Dir: --$dir-- \n"; + } + push(@path,$dir); +} + + +my $licence_start="// SPDX-License-Identifier: (GPL-2.0+ OR MIT)\n"; +my $licence_end= +"/* + * Copyright (c) 2019 Amlogic, Inc. All rights reserved. + */\n\n"; + +#print $licence; + +sub licence_process +{ + my ($file_name) = @_; + my $d = dirname($file_name); + my $f = basename($file_name); + #print "\n Abs <$d>, f_ $f"; + #print "\n Top: <$top> "; + + $licence_0=$licence_start.$licence_end; + my $count = 0; + my $text_0=""; + my $text_all=$licence_0; + open(my $f_in, '<', $file_name) or die "Can't Open $file_name: For Read \n"; + my ($left,$right, $lineno,$space) = (0, 0, 0,0); + while ($line = <$f_in>) + { + $text_0 .= $line; + #Empty Line or Line marked by // + if(($space==0) &&(($line =~/^\s*$/)|| + (($line =~/^\s*\/\//)&&($line !~ /\*\//)))) + { + #print "\n Line $lineno is empty."; + } + elsif(($space==0) &&($line =~ /^\s*\/\*/)) #Match /* + { + $left ++; + #print "\n L Matched: $lineno $line, $left "; #Match that /* and */ in the same line + if($line =~ /\*\//) + { + $right ++; + #print "\n L Matched: $lineno $line, $left "; + } + } + elsif(($space==0) &&($line =~ /\*\//)&& ($line !~ /\/\*/) ) #Match */ + { + $right ++; + #print "\n R Matched: $lineno $line, $right "; + if($left == $right) + { + $space = 1; + } + } + elsif($left==$right) #Content Lines + { + if(($line =~/^\s*$/)&& ($count==0)) + { + + } + else + { + #print $line; + $space = 1; + $count +=1; + $text_all .=$line; + } + } + $lineno++; + } + close($f_in); + + if($text_0 ne $text_all) + { + $failno ++; + if($nofix) + { + print "\n Licence_WARN: <"; + print File::Spec->abs2rel($file_name, $top).">\n";; + } + else + { + print "\n Licence_FIXED: <"; + print File::Spec->abs2rel($file_name, $top).">\n";; + open(my $f_out, '>', $file_name) + or die "Can't Open $file_name\n"; + print $f_out $text_all; + close $f_out; + } + } + $text_all=''; +} + + +my ($c_cnt, $h_cnt) = (0, 0); +sub process +{ + my $file = $File::Find::name; + if (-f $file) + { + if(($file =~ /.*\.[Cc]$/i) || ($file =~ /.*\.dtsi$/i) || ($file =~ /.*\.dts$/i)) + { + $c_cnt++; + $licence_start="// SPDX-License-Identifier: (GPL-2.0+ OR MIT)\n"; + licence_process($file); + } + if(($file =~ /.*\.[hH]$/i)) + { + $c_cnt++; + $licence_start="/* SPDX-License-Identifier: (GPL-2.0+ OR MIT) */\n"; + licence_process($file); + } + } +} + +for(@path) +{ + #print "\n Fine $_ \n"; + find(\&process, $_); +} diff --git a/scripts/amlogic/licence_pre.pl b/scripts/amlogic/licence_pre.pl new file mode 100755 index 000000000000..a364fbe60a84 --- /dev/null +++ b/scripts/amlogic/licence_pre.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl -W +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +# +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. +# +my $FILE; +$flist = " "; +open($FILE, '<&STDIN'); +while (<$FILE>) { + chomp; + my $line = $_; + my $new = ""; + if($line =~/^A\s+(.+\.[cChH])/) + { + $new = $1; + } + elsif(/^A\s+(.+\.dts*)/i) + { + $new = $1; + } + if( -e $new) + { + $flist = $flist.$new." "; + } + +} +close $FILE; + +if($flist =~/^\s*$/) +{ + #print "\n LicenceCheck exit:No *.[CcHh] added.\n\n"; + exit 0; +} +else +{ + print "\n Check :$flist\n"; +} + +$match = "Licence_WARN: <"; +$pl = "./scripts/amlogic/licence_check.pl"; +$out = 0; +$result_0 = `$pl --nofix $flist`; +if($result_0 =~/$match/) +{ + $out =1; + print $result_0; + print "\n Licence Check Error, please try to fix:\n $pl $flist\n\n" +} +else +{ + print "\n Licence Check OK\n\n" +} +exit $out; diff --git a/scripts/amlogic/merge_pre_check.pl b/scripts/amlogic/merge_pre_check.pl new file mode 100755 index 000000000000..a7ac27020c6e --- /dev/null +++ b/scripts/amlogic/merge_pre_check.pl @@ -0,0 +1,429 @@ +#!/usr/bin/perl -W +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +# +# Copyright (c) 2019 Amlogic, Inc. All rights reserved. +# +my $top = "."; +my $err_cnt = 0; +my $k_v = 4; +my $exit = 0; +my $git_format_link="http://wiki-china.amlogic.com/Platform/Bootloader/Bootloader_commit_message_format"; +my $config1 = "arch/arm64/configs/meson64_a64_smarthome_defconfig"; +my $skip = 0; +my $make_build_link = "https://confluence.amlogic.com/display/SW/5.+c2+bringup"; +my $make_defconfig_link = "https://confluence.amlogic.com/display/SW/1.+Quick+Start"; +my $env_common = "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"; +my $arm64_dts = "arch/arm64/boot/dts/amlogic/"; +my $arm_dts = "arch/arm/boot/dts/amlogic/"; + +#Check mesonxx_defconfig +sub check_defconfig +{ + my $arm64_config = `git diff --name-only arch/arm64/configs | grep -E *defconfig`; + my $is_common_drivers = `pwd | grep -E *common_drivers*`; + if (!$arm64_config || !$is_common_drivers) + { + return 0; + } + my $err = 0; + #print "2. Check meson_defconfig: "; + if( -e $config1) + { + `cd .. && mkdir -p out/kernel-5.15/common`; + `cd .. && export CROSS_COMPILE=/opt/gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu/bin/aarch64-none-linux-gnu-`; + `cd .. && cp -rf common_drivers/arch/arm64/configs/meson64_a64_smarthome_defconfig common/arch/arm64/configs/`; + `cd .. && make ARCH=arm64 -C ${PWD}/common/ O=${PWD}/out/kernel-5.15/common/ meson64_a64_smarthome_defconfig`; + `cd .. && make ARCH=arm64 -C ${PWD}/common/ O=${PWD}/out/kernel-5.15/common/ savedefconfig`; + `cd .. && rm -rf ../common/arch/arm64/configs/meson64_a64_smarthome_defconfig`; + `cd .. && rm -rf ../out/kernel-5.15/common/.config`; + my $diff = `diff ../out/kernel-5.15/common/defconfig arch/arm64/configs/meson64_a64_smarthome_defconfig`; + if(length($diff)) + { + $err_cnt += 1; + $err = 1; + $err_msg .= " $err_cnt: meson64_a64_smarthome_defconfig not generated by savedefconfig\n"; + } + } + + + if($err) + { + $err_msg .= " Please refer to:\n"; + $err_msg .= " $make_defconfig_link \n"; + $err_msg .= " $make_build_link\n"; + } + #print $err ? "fail\n" : "success\n"; +} + +sub dts_check +{ + my $is_common_drivers = `pwd | grep -E *common_drivers*`; + if (!$is_common_drivers) + { + return 0; + } + my @dts_path = @_; + my $dts_diff = ""; + my $diff = `git diff --name-only @dts_path | grep -E *dts\$`; + if (!$diff) + { + return 0; + } + my $all_dts = `find @dts_path -name "*dts"`; + my @diff_str = split /[\n]/, $diff; + my @all_dts_str = split /[\n]/, $all_dts; + my $diff_count = 0; + my $all_dts_count = 0; + my $count = 0; + my $t = 0; + my $q = 0; + my $temp = ""; + my @arry = (""); + my @arry1 = (""); + my @arry2 = (""); + for (@diff_str) + { + $re = $_; + if ($re=~m/^(.*?)\_/) + { + $dts_diff = $1; + $dts_diff =~ /@dts_path/; + $temp=$'; + $dts_diff = $dts_diff."_"; + } + if (!($_ =~ "pxp.dts")) + { + for (@diff_str) + { + if ($_ =~ $dts_diff) + { + $_ =~ /@dts_path/; + $arry1->[$diff_count] = $'; + $diff_count = $diff_count+1; + } + } + for (@all_dts_str) + { + if (!($_ =~ "pxp.dts")) + { + if ($_ =~ $dts_diff) + { + $all_dts_count=$all_dts_count+1; + $_ =~ /@dts_path/; + $arry->[$all_dts_count] = $'; + } + } + } + } + if ($diff_count != $all_dts_count) + { + $count=$count+1; + } + while ($q<$t) + { + if ($arry2->[$q] =~ $temp ) + { + $count=0; + } + $q=$q+1; + } + if ($count != 0) + { + $err_cnt += 1; + $err_msg .= " $err_cnt:You are modifying the board $temp DTS file in @dts_path \n"; + $err_msg .= " You have modified dts is "; + while($diff_count > 0) + { + $err_msg .= "$arry1->[$diff_count-1] "; + $diff_count=$diff_count-1; + } + $err_msg .= "\n"; + $err_msg .= " Please confirm should you modify other boards for $temp in @dts_path too? "; + + $err_msg .= "\n"; + $count = 0; + $diff_count = 0; + $all_dts_count = 0; + $arry2->[$t]=$temp; + $t=$t+1; + $q=0; + } + } +} + +sub check_dtsi +{ + my $file = `git diff --name-only | grep -E *dtsi\$`; + my $arm_dts_num = () = ($file =~ /arch\/arm\/boot\/dts\/amlogic/g); + my $arm64_dts_num = () = ($file =~ /arch\/arm64\/boot\/dts\/amlogic/g); + + if( $arm_dts_num != $arm64_dts_num ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: maybe should modify dtsi in both arm and arm64\n"; + } +} + +# check module_param number +sub check_module_param +{ + my $num = `git format-patch -1 --stdout | grep -c "module_param("`; + my $MAX_NUM = 5; + + if( $num > $MAX_NUM ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: the number of module_param too much\n"; + } +} + +my $MAX_LEN = 100; + +sub check_msg_common +{ + my $line = pop(@_); + my $lnum = pop(@_); + + if( (length($line) > ($MAX_LEN + 4) ) && ($lnum > 4) ) + { #Line over 100 characters is not allowed. + $line =~ s/^(\s){4}//; + $err_cnt += 1; + $err_msg .= " $err_cnt: Line over $MAX_LEN characters: <$line>\n"; + } + + if ( ($line =~ /\s+$/) && $line !~/^(\s){4}$/ ) + { #No space at the end of line + $err_cnt += 1; + $line =~ s/^(\s){4}//; + $err_msg .= " $err_cnt: No space at the end of line: <$line>\n"; + } +} + + +sub check_msg_49_2 +{ + my $msg = `git cat-file commit HEAD~0 | sed '1,/\^\$/d'`; + my @str = split /[\n][\n]/, $msg; + my $i = 0; + my $len = @str; + + if( $msg =~ /^Revert\s/ ) + { + return 0; + } + + if( $len != 6 ) + { + $err_cnt += 5; + $err_msg .= " module: message [n/m]\n\n"; + $err_msg .= " PD#SWPL-XXXX\n\n"; + $err_msg .= " Problem:\n detailed description\n\n"; + $err_msg .= " Solution:\n detailed description\n\n"; + $err_msg .= " Verify:\n detailed description\n\n"; + return -1; + } + + if( $msg !~ /Merge\s/ && $msg =~ /5\.15/ ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: this branch is 5.15, all changes here are for 5.15. No [5.15] in commit message please\n"; + } + + if( $str[$i] !~ /^([\w-]+:\s){1,2}.+(\s)\[[\d]+\/[\d]+\]$/ ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: module: message [n/m]\n"; + } + elsif( $str[$i] =~ /(kernel)/i ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: Should be no 'kernel' in kernel commit message\n"; + } + + if( $str[++ $i] !~ /^PD\#SWPL-.+(\d)$/ ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: PD#SWPL-XXXX\n"; + return -1; + + } + + if( $str[++ $i] !~ /^Problem:[\n].+/ ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: Problem:\n detailed description\n"; + return -1; + } + + $i += 1; + while( $str[$i] !~ /^Solution:[\n].+/ && $str[$i] !~ /^Change-Id:/ && $str[$i] !~ /^Verify:[\n].+/ && ($i + 1) < $len ) + { + $i = $i + 1; + } + + if( $str[$i] !~ /^Solution:[\n].+/ ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: Solution:\n detailed description\n"; + return -1; + } + + if( $str[$i] =~ /^Change-Id:/ ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: Verify:\n detailed description\n"; + return -1; + } + + while( $str[$i] !~ /^Verify:[\n].+/ && $str[$i] !~ /^Change-Id:/ && ($i + 1) < $len ) + { + $i += 1; + } + + if( $str[$i] !~ /^Verify:[\n].+/ ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: Verify:\n detailed description\n"; + } +} + +sub sync_arm64_arm_diff +{ + my $file = `git diff --name-only HEAD HEAD^`; + my $arm_dts_num = () = ($file =~ /arch\/arm\/boot\/dts\/amlogic/g); + my $arm64_dts_num = () = ($file =~ /arch\/arm64\/boot\/dts\/amlogic/g); + my $arm_config_num = () = ($file =~ /arch\/arm\/config/g); + my $arm64_config_num = () = ($file =~ /arch\/arm64\/config/g); + + if( $arm_config_num != $arm64_config_num ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: maybe should modify the config in both arm and arm64\n"; + } + if( $arm_dts_num != $arm64_dts_num ) + { + $err_cnt += 1; + $err_msg .= " $err_cnt: maybe should modify the dts in both arm and arm64\n"; + } +} + +sub check_nonascii_character +{ + my $add_msg = `git format-patch -1 --stdout | sed -e '/^-/d'`; + my @add_str = split /[\n][\n]/,, $add_msg; + my $i = 0; + my $len = @add_str; + for ($i = 0; $i < $len; $i = $i + 1) + { + if (!$add_str[$i] =~ m/[^\x00-\x7f]/) + { + $err_cnt += 1; + $err_msg .= " @add_str[$i]\n"; + } + } +} + + +sub check_commit_msg +{ + + my $lnum = 0; + my $err = 0; + my $result = 0; + my $commit; + my $FILE; + + open($FILE, '<&STDIN'); + + while (<$FILE>) { + chomp; + my $line = $_; + + + if( $line =~ /^commit\s([0-9a-z])+$/) + { + $lnum = 0; + $commit = $line; + $skip = 0; + } + $lnum ++; + + + if( ($lnum ==2) && ($line =~ /^Merge: /)) + { + #$skip =1; #Don't Check branch merge + } + if( ($lnum==2) && ($line !~ /^Author: .*\@amlogic\.com\>$/)) + { + #$skip =1; #Don't Check commit which is not from amlogic + } + + if( $err == 1) + { + $skip = 1; + $err = 0; + $result = 1; + } + if( $skip ==1) + { + next; + } + + check_msg_common($lnum, $line); + } + close $FILE; + if ($k_v >= 4) + { + check_msg_49_2; + } +} + +sub out_review +{ + my $out_msg = ""; + my $out_file = "../output/review.txt"; + + if ($err_cnt) + { + $out_msg = < $out_file" or die "Can't Open $out_file For Write \n"; + #print O $out_msg; + #close O; + $exit = 1; + print $out_msg; + print "Please refer to:\n $git_format_link\n"; + } + else + { + print ""; + } +} + +#start + +my $err_msg_p = "\nCommit Pre check failed. Total $err_cnt errors.\n"; + +#Check meson_defconfig +check_defconfig(); +dts_check($arm64_dts); +#dts_check($arm_dts); +#check_dtsi(); + +#check_module_param +check_module_param(); + +#Check commit message +#check_commit_msg(); + +#check config and dts in arm and arm64 +#sync_arm64_arm_diff(); +check_nonascii_character(); + +out_review(); +#out +exit $exit; diff --git a/scripts/amlogic/pre-commit b/scripts/amlogic/pre-commit new file mode 100755 index 000000000000..fba48e4904e0 --- /dev/null +++ b/scripts/amlogic/pre-commit @@ -0,0 +1,24 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +# +# pre-commit hook to run check-patch on the output and stop any commits +# that do not pass. Note, only for git-commit, and not for any of the +# other scenarios +# +# Copyright 2010 Ben Dooks, + +if git rev-parse --verify HEAD 2>/dev/null >/dev/null +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +git diff --cached --stat -p $against -- | ./scripts/checkpatch.pl --ignore GERRIT_CHANGE_ID,COMMIT_MESSAGE --strict --no-signoff - +if [ $? -ne 0 ] +then +exit 1; +fi + +git diff --name-status --cached $against -- | ./scripts/amlogic/licence_pre.pl - diff --git a/scripts/amlogic/pre-commit-common_drivers b/scripts/amlogic/pre-commit-common_drivers new file mode 100755 index 000000000000..fba48e4904e0 --- /dev/null +++ b/scripts/amlogic/pre-commit-common_drivers @@ -0,0 +1,24 @@ +#!/bin/sh +# SPDX-License-Identifier: (GPL-2.0+ OR MIT) +# +# pre-commit hook to run check-patch on the output and stop any commits +# that do not pass. Note, only for git-commit, and not for any of the +# other scenarios +# +# Copyright 2010 Ben Dooks, + +if git rev-parse --verify HEAD 2>/dev/null >/dev/null +then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +git diff --cached --stat -p $against -- | ./scripts/checkpatch.pl --ignore GERRIT_CHANGE_ID,COMMIT_MESSAGE --strict --no-signoff - +if [ $? -ne 0 ] +then +exit 1; +fi + +git diff --name-status --cached $against -- | ./scripts/amlogic/licence_pre.pl - diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 25fdb7fda112..54ab6dd32072 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -59,7 +59,7 @@ my $configuration_file = ".checkpatch.conf"; my $max_line_length = 100; my $ignore_perl_version = 0; my $minimum_perl_version = 5.10.0; -my $min_conf_desc_length = 4; +my $min_conf_desc_length = 2; my $spelling_file = "$D/spelling.txt"; my $codespell = 0; my $codespellfile = "/usr/share/codespell/dictionary.txt"; @@ -457,8 +457,8 @@ if ($tree) { } if (!defined $root) { - print "Must be run from the top-level dir. of a kernel tree\n"; - exit(2); + # print "Must be run from the top-level dir. of a kernel tree\n"; + # exit(2); } } @@ -1147,7 +1147,7 @@ sub is_maintained_obsolete { sub is_SPDX_License_valid { my ($license) = @_; - return 1 if (!$tree || which("python3") eq "" || !(-x "$root/scripts/spdxcheck.py") || !(-e "$gitroot")); + return 1 if (!$tree || which("python3") eq "" || !(-x "scripts/spdxcheck.py") || !(-e "$gitroot")); my $root_path = abs_path($root); my $status = `cd "$root_path"; echo "$license" | scripts/spdxcheck.py -`; @@ -2860,7 +2860,7 @@ sub process { $p1_prefix = $1; if (!$file && $tree && $p1_prefix ne '' && - -e "$root/$p1_prefix") { + -e "$p1_prefix") { WARN("PATCH_PREFIX", "patch prefix '$p1_prefix' exists, appears to be a -p0 patch\n"); } @@ -2884,10 +2884,10 @@ sub process { } if ($found_file) { - if (is_maintained_obsolete($realfile)) { - WARN("OBSOLETE", - "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy. No unnecessary modifications please.\n"); - } + # if (is_maintained_obsolete($realfile)) { + # WARN("OBSOLETE", + # "$realfile is marked as 'obsolete' in the MAINTAINERS hierarchy. No unnecessary modifications please.\n"); + # } if ($realfile =~ m@^(?:drivers/net/|net/|drivers/staging/)@) { $check = 1; } else { @@ -2902,8 +2902,8 @@ sub process { if (($last_binding_patch != -1) && ($last_binding_patch ^ $is_binding_patch)) { - WARN("DT_SPLIT_BINDING_PATCH", - "DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst\n"); + # WARN("DT_SPLIT_BINDING_PATCH", + # "DT binding docs and includes should be a separate patch. See: Documentation/devicetree/bindings/submitting-patches.rst\n"); } } @@ -2925,9 +2925,9 @@ sub process { $commit_log_lines++; #could be a $signature } } elsif ($has_commit_log && $commit_log_lines < 2) { - WARN("COMMIT_MESSAGE", - "Missing commit description - Add an appropriate one\n"); - $commit_log_lines = 2; #warn only once + # WARN("COMMIT_MESSAGE", + # "Missing commit description - Add an appropriate one\n"); + # $commit_log_lines = 2; #warn only once } # Check if the commit log has what seems like a diff which can confuse patch @@ -3065,8 +3065,8 @@ sub process { my ($email_name, $name_comment, $email_address, $comment) = parse_email($email); my $suggested_email = format_email(($email_name, $name_comment, $email_address, $comment)); if ($suggested_email eq "") { - ERROR("BAD_SIGN_OFF", - "Unrecognized email address: '$email'\n" . $herecurr); + # ERROR("BAD_SIGN_OFF", + # "Unrecognized email address: '$email'\n" . $herecurr); } else { my $dequoted = $suggested_email; $dequoted =~ s/^"//; @@ -3242,11 +3242,11 @@ sub process { # Check for Gerrit Change-Ids not in any patch context if ($realfile eq '' && !$has_patch_separator && $line =~ /^\s*change-id:/i) { - if (ERROR("GERRIT_CHANGE_ID", - "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) && - $fix) { - fix_delete_line($fixlinenr, $rawline); - } + # if (ERROR("GERRIT_CHANGE_ID", + # "Remove Gerrit Change-Id's before submitting upstream\n" . $herecurr) && + # $fix) { + # fix_delete_line($fixlinenr, $rawline); + # } } # Check if the commit log is in a possible stack dump @@ -3397,16 +3397,16 @@ sub process { } # Check for added, moved or deleted files - if (!$reported_maintainer_file && !$in_commit_log && - ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || - $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || - ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && - (defined($1) || defined($2))))) { - $is_patch = 1; - $reported_maintainer_file = 1; - WARN("FILE_PATH_CHANGES", - "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); - } + # if (!$reported_maintainer_file && !$in_commit_log && + # ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || + # $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || + # ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && + # (defined($1) || defined($2))))) { + # $is_patch = 1; + # $reported_maintainer_file = 1; + # WARN("FILE_PATH_CHANGES", + # "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); + # } # Check for adding new DT bindings not in schema format if (!$in_commit_log && @@ -3640,8 +3640,8 @@ sub process { if ($needs_help && $help_length < $min_conf_desc_length) { my $stat_real = get_stat_real($linenr, $ln - 1); - WARN("CONFIG_DESCRIPTION", - "please write a help paragraph that fully describes the config symbol\n" . "$here\n$stat_real\n"); + # WARN("CONFIG_DESCRIPTION", + # "please write a help paragraph that fully describes the config symbol\n" . "$here\n$stat_real\n"); } } @@ -3716,8 +3716,8 @@ sub process { $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/; `grep -Erq "$compat|$compat2|$compat3" $dt_path`; if ( $? >> 8 ) { - WARN("UNDOCUMENTED_DT_STRING", - "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); + # WARN("UNDOCUMENTED_DT_STRING", + # "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); } next if $compat !~ /^([a-zA-Z0-9\-]+)\,/; @@ -3760,10 +3760,10 @@ sub process { "Missing or malformed SPDX-License-Identifier tag in line $checklicenseline\n" . $herecurr); } elsif ($rawline =~ /(SPDX-License-Identifier: .*)/) { my $spdx_license = $1; - if (!is_SPDX_License_valid($spdx_license)) { - WARN("SPDX_LICENSE_TAG", - "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr); - } + # if (!is_SPDX_License_valid($spdx_license)) { + # WARN("SPDX_LICENSE_TAG", + # "'$spdx_license' is not supported in LICENSES/...\n" . $herecurr); + # } if ($realfile =~ m@^Documentation/devicetree/bindings/@ && $spdx_license !~ /GPL-2\.0(?:-only)? OR BSD-2-Clause/) { my $msg_level = \&WARN; @@ -3786,8 +3786,8 @@ sub process { # check for embedded filenames if ($rawline =~ /^\+.*\b\Q$realfile\E\b/) { - WARN("EMBEDDED_FILENAME", - "It's generally not useful to have the filename in the file\n" . $herecurr); + # WARN("EMBEDDED_FILENAME", + # "It's generally not useful to have the filename in the file\n" . $herecurr); } # check we are in a valid source file if not then ignore this hunk @@ -3950,34 +3950,34 @@ sub process { } # check multi-line statement indentation matches previous line - if ($perl_version_ok && - $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|(?:\*\s*)*$Lval\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) { - $prevline =~ /^\+(\t*)(.*)$/; - my $oldindent = $1; - my $rest = $2; + # if ($perl_version_ok && + # $prevline =~ /^\+([ \t]*)((?:$c90_Keywords(?:\s+if)\s*)|(?:$Declare\s*)?(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*|(?:\*\s*)*$Lval\s*=\s*$Ident\s*)\(.*(\&\&|\|\||,)\s*$/) { + # $prevline =~ /^\+(\t*)(.*)$/; + # my $oldindent = $1; + # my $rest = $2; - my $pos = pos_last_openparen($rest); - if ($pos >= 0) { - $line =~ /^(\+| )([ \t]*)/; - my $newindent = $2; + # my $pos = pos_last_openparen($rest); + # if ($pos >= 0) { + # $line =~ /^(\+| )([ \t]*)/; + # my $newindent = $2; - my $goodtabindent = $oldindent . - "\t" x ($pos / $tabsize) . - " " x ($pos % $tabsize); - my $goodspaceindent = $oldindent . " " x $pos; + # my $goodtabindent = $oldindent . + # "\t" x ($pos / $tabsize) . + # " " x ($pos % $tabsize); + # my $goodspaceindent = $oldindent . " " x $pos; - if ($newindent ne $goodtabindent && - $newindent ne $goodspaceindent) { + # if ($newindent ne $goodtabindent && + # $newindent ne $goodspaceindent) { - if (CHK("PARENTHESIS_ALIGNMENT", - "Alignment should match open parenthesis\n" . $hereprev) && - $fix && $line =~ /^\+/) { - $fixed[$fixlinenr] =~ - s/^\+[ \t]*/\+$goodtabindent/; - } - } - } - } + # if (CHK("PARENTHESIS_ALIGNMENT", + # "Alignment should match open parenthesis\n" . $hereprev) && + # $fix && $line =~ /^\+/) { + # $fixed[$fixlinenr] =~ + # s/^\+[ \t]*/\+$goodtabindent/; + # } + # } + # } + # } # check for space after cast like "(int) foo" or "(struct foo) bar" # avoid checking a few false positives: @@ -6910,8 +6910,8 @@ sub process { if (!defined($stat_real)) { $stat_real = get_stat_real($linenr, $lc); } - WARN("VSPRINTF_SPECIFIER_PX", - "Using vsprintf specifier '\%px' potentially exposes the kernel memory layout, if you don't really need the address please consider using '\%p'.\n" . "$here\n$stat_real\n"); + # WARN("VSPRINTF_SPECIFIER_PX", + # "Using vsprintf specifier '\%px' potentially exposes the kernel memory layout, if you don't really need the address please consider using '\%p'.\n" . "$here\n$stat_real\n"); } } if ($bad_specifier ne "") { @@ -7175,14 +7175,14 @@ sub process { } # checks for new __setup's - if ($rawline =~ /\b__setup\("([^"]*)"/) { - my $name = $1; + # if ($rawline =~ /\b__setup\("([^"]*)"/) { + # my $name = $1; - if (!grep(/$name/, @setup_docs)) { - CHK("UNDOCUMENTED_SETUP", - "__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.txt\n" . $herecurr); - } - } + # if (!grep(/$name/, @setup_docs)) { + # CHK("UNDOCUMENTED_SETUP", + # "__setup appears un-documented -- check Documentation/admin-guide/kernel-parameters.txt\n" . $herecurr); + # } + # } # check for pointless casting of alloc functions if ($line =~ /\*\s*\)\s*$allocFunctions\b/) { diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 5a215880b268..1aa948880a3d 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -91,7 +91,14 @@ else endif %_defconfig: $(obj)/conf - $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) +# config cannot be used here to mark AMLOGIC modifications +# support two config directory, arch/$(SRCARCH)/configs/ and $(COMMON_DRIVERS_DIR)/arch/$(SRCARCH)/configs/ + $(if $(wildcard $(srctree)/arch/$(SRCARCH)/configs/$@), \ + $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig), \ + $(Q)$< $(silent) --defconfig=$(COMMON_DRIVERS_DIR)/arch/$(SRCARCH)/configs/$@ $(Kconfig)) +# else +# $(Q)$< $(silent) --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) +# endif configfiles=$(wildcard $(srctree)/kernel/configs/$@ $(srctree)/arch/$(SRCARCH)/configs/$@) diff --git a/usr/include/Makefile b/usr/include/Makefile index 6111974688a8..b4f37a52aa73 100644 --- a/usr/include/Makefile +++ b/usr/include/Makefile @@ -8,6 +8,10 @@ # We cannot go as far as adding -Wpedantic since it emits too many warnings. UAPI_CFLAGS := -std=c90 -Wall -Werror=implicit-function-declaration +ifdef CONFIG_AMLOGIC_DRIVER +UAPI_CFLAGS += -Werror +endif + # In theory, we do not care -m32 or -m64 for header compile tests. # It is here just because CONFIG_CC_CAN_LINK is tested with -m32 or -m64. UAPI_CFLAGS += $(filter -m32 -m64 --target=%, $(KBUILD_CFLAGS))