diff options
| author | Tom Rini <trini@konsulko.com> | 2021-01-11 13:55:03 -0500 |
|---|---|---|
| committer | Tom Rini <trini@konsulko.com> | 2021-01-11 13:55:03 -0500 |
| commit | d71be1990218957b9f05dbf13a72859a2abe06d7 (patch) | |
| tree | 99858dc9988f7f7b4c0ab1d8d45738e3abdf38c8 /scripts/checkpatch.pl | |
| parent | c4fddedc48f336eabc4ce3f74940e6aa372de18c (diff) | |
| parent | bc0b99bd8b19599f670f42401de655fa9b44cd94 (diff) | |
| download | u-boot-d71be1990218957b9f05dbf13a72859a2abe06d7.tar.gz u-boot-d71be1990218957b9f05dbf13a72859a2abe06d7.tar.xz u-boot-d71be1990218957b9f05dbf13a72859a2abe06d7.zip | |
Merge branch 'next'
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 4ed7e124c9..01ab570a16 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2320,6 +2320,23 @@ sub get_raw_comment { return $comment; } +# Args: +# line: Patch line to check +# auto: Auto variable name, e.g. "per_child_auto" +# suffix: Suffix to expect on member, e.g. "_priv" +# warning: Warning name, e.g. "PRIV_AUTO" +sub u_boot_struct_name { + my ($line, $auto, $suffix, $warning) = @_; + + # Use _priv as a suffix for the device-private data struct + if ($line =~ /^\+\s*\.${auto}\s*=\s*sizeof\(struct\((\w+)\).*/) { + my $struct_name = $1; + if ($struct_name !~ /^\w+${suffix}/) { + WARN($warning, "struct \'$struct_name\' should have a ${suffix} suffix"); + } + } +} + # Checks specific to U-Boot sub u_boot_line { my ($realfile, $line, $rawline, $herecurr) = @_; @@ -2371,6 +2388,27 @@ sub u_boot_line { ERROR("CONFIG_IS_ENABLED_CONFIG", "CONFIG_IS_ENABLED() takes values without the CONFIG_ prefix\n" . $herecurr); } + + # Use _priv as a suffix for the device-private data struct + if ($line =~ /^\+\s*\.priv_auto\s*=\s*sizeof\(struct\((\w+)\).*/) { + my $struct_name = $1; + if ($struct_name !~ /^\w+_priv/) { + WARN("PRIV_AUTO", "struct \'$struct_name\' should have a _priv suffix"); + } + } + + # Check struct names for the 'auto' members of struct driver + u_boot_struct_name($line, "priv_auto", "_priv", "PRIV_AUTO"); + u_boot_struct_name($line, "plat_auto", "_plat", "PLAT_AUTO"); + u_boot_struct_name($line, "per_child_auto", "_priv", "CHILD_PRIV_AUTO"); + u_boot_struct_name($line, "per_child_plat_auto", "_plat", + "CHILD_PLAT_AUTO"); + + # Now the ones for struct uclass, skipping those in common with above + u_boot_struct_name($line, "per_device_auto", "_priv", + "DEVICE_PRIV_AUTO"); + u_boot_struct_name($line, "per_device_plat_auto", "_plat", + "DEVICE_PLAT_AUTO"); } sub process { |
