From: Dobrica Pavlinusic Date: Fri, 11 May 2018 07:36:19 +0000 (+0200) Subject: fix --pins usage and filtering of boards in same pins file X-Git-Url: http://git.rot13.org/?p=linux-gpio-pinout;a=commitdiff_plain;h=1fd28f9fb9b24ad4e1b21f3d504409e9defaabe6 fix --pins usage and filtering of boards in same pins file This allows us to have Raspberry Pi pin description in single file, by specifing common prefix for shared pins and more specific model filter to show just appropriate pins --- diff --git a/gpio.pl b/gpio.pl index 8c5a532..0e75092 100755 --- a/gpio.pl +++ b/gpio.pl @@ -47,10 +47,19 @@ sub slurp { } my $pins; +my $include = 0; my $model = slurp('/proc/device-tree/model'); $model =~ s/\x00$//; # strip kernel NULL warn "# model [$model]"; +if ( $opt_pins ) { + $model = $opt_pins; + $model =~ s/^.*\///; # strip dir + $model =~ s/\..+$//; # strip extension + $include = 1; + warn "# $opt_pins model [$model] $include"; +} +warn "# $opt_pins model [$model] $include"; OPEN_PINS_AGAIN: open(DATA, '<', $opt_pins) if $opt_pins; @@ -58,17 +67,16 @@ open(DATA, '<', $opt_pins) if $opt_pins; my @lines; my $line_i = 0; -my $include = 0; while() { chomp; if ( m/^#\s(.+)/ ) { - warn "MODEL [$1] == [$model] ?\n"; if ( $model =~ m/$1/ ) { $include = 1; } else { $include = 0; } - } elsif ( $include || $opt_pins ) { + warn "MODEL [$1] == [$model] include: $include\n"; + } elsif ( $include ) { push @{ $pins->{$1} }, $line_i while ( m/\t\s*(\w+\d+)/g ); push @lines, $_;