X-Git-Url: http://git.archive.openwrt.org/?a=blobdiff_plain;f=convert-modeswitch.pl;h=b1530bd7b529bacbdcf0ff5811c9f6af62a92084;hb=f40f84c27534159066c94dadc0c08e0b255c3e26;hp=97f1d7b9f764066e66ffbd0528e119a0742d9432;hpb=ed61a16faf025671d9ff751b827980cc44f9f088;p=project%2Fusbmode.git diff --git a/convert-modeswitch.pl b/convert-modeswitch.pl old mode 100644 new mode 100755 index 97f1d7b..b1530bd --- a/convert-modeswitch.pl +++ b/convert-modeswitch.pl @@ -9,7 +9,7 @@ sub add_message { my $msg = shift; my $val = $messages{$msg}; - $val or do { + defined($val) or do { $val = $msg_ctr++; $messages{$msg} = $val; }; @@ -46,9 +46,15 @@ sub add_mode { return $_[1]; } +sub add_modeval { + return unless ($_[1] && $_[1] =~ /^\d+$/); + $_[0]->{"ModeValue"} = $_[1]; +} + my $hex_option = [ undef, \&add_hex ]; my $msg_option = [ undef, \&add_message ]; my $mode_option = [ "Mode", \&add_mode ]; +my $value_mode_option = [ "Mode", \&add_mode, \&add_modeval ]; my %options = ( TargetVendor => $hex_option, TargetProductList => [ "TargetProduct", sub { return [ map(hex,split(/,/, $_[0])) ]; } ], @@ -59,7 +65,13 @@ my %options = ( MessageContent3 => $msg_option, WaitBefore => [ ], DetachStorageOnly => [ ], + MBIM => $mode_option, HuaweiMode => $mode_option, + HuaweiNewMode => $mode_option, + QuantaMode => $mode_option, + BlackberryMode => $mode_option, + PantechMode => $value_mode_option, + OptionMode => $mode_option, SierraMode => $mode_option, SonyMode => $mode_option, QisdaMode => $mode_option, @@ -68,6 +80,7 @@ my %options = ( SequansMode => $mode_option, MobileActionMode => $mode_option, CiscoMode => $mode_option, + StandardEject => $mode_option, NoDriverLoading => [], MessageEndpoint => $hex_option, ReleaseDelay => [], @@ -110,6 +123,7 @@ sub parse_file($) { next; }; + $opt->[2] and &{$opt->[2]}($dev, $val, $var); $opt->[1] and $val = &{$opt->[1]}($val, $var); $opt->[0] and $var = $opt->[0]; $dev->{$var} = $val; @@ -204,6 +218,7 @@ foreach my $devid (sort keys %devices) { dev_opt($cur->{TargetClass}, "t_class", "int", \$sep); dev_opt($cur->{DetachStorageOnly}, "detach_storage", "bool", \$sep); dev_opt($cur->{Mode}, "mode", "string", \$sep); + dev_opt($cur->{ModeValue}, "modeval", "int", \$sep); dev_opt($cur->{NoDriverLoading}, "no_driver", "bool", \$sep); dev_opt($cur->{MessageEndpoint}, "msg_endpoint", "int", \$sep); my $msg = [