all devices don't have hex prefix, e.g. lirc module
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 10 Nov 2017 18:45:32 +0000 (19:45 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sat, 11 Nov 2017 10:40:54 +0000 (11:40 +0100)
gpio.pl

diff --git a/gpio.pl b/gpio.pl
index a681156..429982b 100755 (executable)
--- a/gpio.pl
+++ b/gpio.pl
@@ -83,8 +83,9 @@ my $device;
 open(my $fh, '<', $opt_read . '/sys/kernel/debug/pinctrl/pinctrl-handles');
 while(<$fh>) {
        chomp;
-       if ( m/device: [0-9a-f]+\.(\w+)/ ) {
+       if ( m/device: (\S+)/ ) {
                $device = $1;
+               $device =~ s/^[0-9a-f]*\.//; # remove hex address
        } elsif ( m/group: (\w+\d+)\s.+function: (\S+)/ ) {
                my ($pin, $function) = ($1,$2);
                $pin_function->{$pin} = "$device $function";