Skip to content

Commit 92900c5

Browse files
committed
overlaycheck: Add a check for unusable fragments
Fragments marked as dormant that do not have a parameter to enable them are unusable. Add a check for that scenario. Running this check on our current Linux tree has detected a few real errors, and one case of fragments that haven't been used yet. Signed-off-by: Phil Elwell <[email protected]>
1 parent bd44dc5 commit 92900c5

File tree

1 file changed

+65
-3
lines changed

1 file changed

+65
-3
lines changed

overlaycheck/overlaycheck

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ foreach my $overlay (sort(keys(%$source)))
336336
{
337337
error(" Error ^ in overlay $overlay\n");
338338
}
339+
340+
dormant_checker($overlay);
341+
342+
my $checker = $overlay_checkers{$overlay};
343+
($checker->[0])->($overlay, $checker->[1], $source->{$overlay}) if ($checker);
339344
}
340345

341346
if ($try_all)
@@ -353,8 +358,6 @@ if ($try_all)
353358
next if (system("$DTMERGE $TMPDIR/$base.dtb $MERGED_DTB $TMPDIR/$overlay.dtbo >/dev/null 2>&1") == ((-2 & 0xff) << 8));
354359
error("Failed to merge $overlay with $base") if (system($DTMERGE, $verbose ? ('-d') : (), "$TMPDIR/$base.dtb", $MERGED_DTB, "$TMPDIR/$overlay.dtbo") != 0);
355360
}
356-
my $checker = $overlay_checkers{$overlay};
357-
($checker->[0])->($overlay, $checker->[1], $source->{$overlay}) if ($checker);
358361
}
359362
}
360363

@@ -826,7 +829,6 @@ sub get_params
826829
}
827830
}
828831

829-
#print(join("\n", @lines), "\n") if ($fail);
830832
return ($props, sort(@params));
831833
}
832834

@@ -869,6 +871,66 @@ sub container_checker
869871
}
870872
}
871873

874+
sub dormant_checker
875+
{
876+
my ($overlay) = @_;
877+
my $ph;
878+
my $fragnum;
879+
my %is_dormant;
880+
my %is_wakeable;
881+
my $in_overrides = 0;
882+
883+
die if (!open($ph, '-|', "ovmerge -N ${overlay}-overlay.dts"));
884+
while (my $line = <$ph>)
885+
{
886+
chomp($line);
887+
if ($in_overrides)
888+
{
889+
if ($line =~ /}/)
890+
{
891+
$in_overrides = 0;
892+
}
893+
elsif ($line =~ /^\s*([-\w]+) = (.*?;)$/)
894+
{
895+
my ($param, $rol) = ($1,$2);
896+
while ($rol =~ /\G<(&\w+|0)>, "([^"]+)"(?:, |;)/cg)
897+
{
898+
my ($ref, $override) = ($1, $2);
899+
if ($ref eq '0')
900+
{
901+
while ($override =~ /\G([-+=!])(\d+)/cg)
902+
{
903+
my ($type, $num) = ($1, $2);
904+
$is_wakeable{$num} = 1 if ($type ne '-');
905+
}
906+
}
907+
elsif ($override =~ /=$/)
908+
{
909+
$rol =~ /\G[^,;]+(?:, |;)/cg;
910+
}
911+
}
912+
}
913+
}
914+
elsif ($line =~ /\bfragment@(\d+)\s\{/)
915+
{
916+
$fragnum = $1;
917+
}
918+
elsif ($line =~ /\b__dormant__\b/)
919+
{
920+
$is_dormant{$fragnum} = 1;
921+
}
922+
elsif ($line =~ /\b__overrides__\b/)
923+
{
924+
$in_overrides = 1;
925+
}
926+
}
927+
928+
foreach my $frag (sort { $a <=> $b} keys(%is_dormant))
929+
{
930+
error("$overlay: fragment $frag is dormant and cannot be activated") if (!$is_wakeable{$frag});
931+
}
932+
}
933+
872934
sub error
873935
{
874936
print("* $_[0]\n");

0 commit comments

Comments
 (0)