From 165fe5ce9cf87667f31cafe2f5451ec12d93aae5 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Mon, 1 Dec 2008 15:35:10 +0000 Subject: [PATCH] Simplify the generation of module options. git-svn-id: http://lm-sensors.org/svn/lm-sensors/branches/lm-sensors-3.0.0@5491 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/sensors-detect | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 46bb7221..caa336ee 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -4794,7 +4794,7 @@ sub print_chips_report sub generate_modprobes { - my ($chip, $detection, @optionlist, $adap); + my ($chip, $detection, $adap); my ($isa, $ipmi); my ($modprobes, $configfile); @@ -4820,27 +4820,22 @@ sub generate_modprobes # directly, so module options are no longer needed. unless (kernel_version_at_least(2, 6, 28)) { foreach $chip (@chips_detected) { - @optionlist = (); + my @optionlist = (); foreach $detection (@{$chip->{detected}}) { - if (exists $detection->{i2c_addr} and - exists $detection->{isa_addr} and - $i2c_adapters[$detection->{i2c_devnr}]->{used}) { - push @optionlist, - $detection->{i2c_devnr}, - $detection->{i2c_addr}; - } + next unless exists $detection->{i2c_addr} + && exists $detection->{isa_addr} + && $i2c_adapters[$detection->{i2c_devnr}]->{used}; + + push @optionlist, sprintf("%d,0x%02x", + $detection->{i2c_devnr}, + $detection->{i2c_addr}); } next if not @optionlist; $configfile = "# hwmon module options\n" unless defined $configfile; - $configfile .= "options $chip->{driver}"; - $configfile .= sprintf(" ignore=%d,0x%02x", - shift @optionlist, - shift @optionlist); - $configfile .= sprintf(",%d,0x%02x", shift @optionlist, - shift @optionlist) while @optionlist; - $configfile .= "\n"; + $configfile .= "options $chip->{driver} ignore=". + (join ",", @optionlist)."\n"; } }