param_doc 982 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #! /usr/bin/perl -w
  2. use strict;
  3. #
  4. # Extract parameter documentation from *.ko files.
  5. # Assumes that parameter description include the default
  6. # value in the format we use in our DEF_PARM() macro
  7. #
  8. @ARGV || die "Usage: $0 module.ko....\n";
  9. my $modinfo = '/sbin/modinfo';
  10. my @mod_params;
  11. foreach my $file (glob "@ARGV") {
  12. undef @mod_params;
  13. print "$file:\n";
  14. open(F, "$modinfo '$file' |") || die;
  15. while(<F>) {
  16. chomp;
  17. next unless s/^parm:\s*//;
  18. my ($name, $description) = split(/:/, $_, 2);
  19. # Extract type
  20. $description =~ s/\s*\(([^)]+)\)$//;
  21. my $type = $1;
  22. # Extract default value
  23. $description =~ s/\s*\[default\s+([^]]+)\]$//;
  24. my $default = $1;
  25. push(@mod_params, {
  26. NAME => $name,
  27. TYPE => $type,
  28. DEFVAL => $default,
  29. DESC => $description,
  30. });
  31. }
  32. # Print sorted list
  33. foreach my $p (sort { $a->{NAME} cmp $b->{NAME} } @mod_params) {
  34. printf "\t%-8s %-22s = %-20s %s\n", $p->{TYPE}, $p->{NAME}, $p->{DEFVAL}, $p->{DESC};
  35. }
  36. close F || die;
  37. }