summaryrefslogtreecommitdiff
path: root/drivers/dahdi/xpp/param_doc
blob: 5848728108c6e8306d9547b82b7c5a1b55beef1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#! /usr/bin/perl -w
use strict;
#
# Extract parameter documentation from *.ko files.
# Assumes that parameter description include the default
# value in the format we use in our DEF_PARM() macro
#

@ARGV || die "Usage: $0 module.ko....\n";

my $modinfo = '/sbin/modinfo';
my @mod_params;

foreach my $file (glob "@ARGV") {
	undef @mod_params;
	print "$file:\n";
	open(F, "$modinfo '$file' |") || die;
	while(<F>) {
		chomp;
		next unless s/^parm:\s*//;
		my ($name, $description) = split(/:/, $_, 2);
		# Extract type
		$description =~ s/\s*\(([^)]+)\)$//;
		my $type = $1;
		# Extract default value
		$description =~ s/\s*\[default\s+([^]]+)\]$//;
		my $default = $1;
		push(@mod_params, {
			NAME	=> $name,
			TYPE	=> $type,
			DEFVAL	=> $default,
			DESC	=> $description,
			});
	}
	# Print sorted list
	foreach my $p (sort { $a->{NAME} cmp $b->{NAME} } @mod_params) {
		printf "\t%-8s %-22s = %-20s %s\n", $p->{TYPE}, $p->{NAME}, $p->{DEFVAL}, $p->{DESC};
	}
	close F || die;
}