Changeset 5267

Show
Ignore:
Timestamp:
05/28/08 11:32:41 (6 months ago)
Author:
khali
Message:

More coding style cleanups. This time, most of them are to make function
calls look like function calls, but there are also a couple whitespace
fixes and needless parentheses removed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/branches/lm-sensors-3.0.0/prog/detect/sensors-detect

    r5266 r5267  
    21672167sub initialize_ioports 
    21682168{ 
    2169   sysopen (IOPORTS, "/dev/port", O_RDWR) 
     2169  sysopen(IOPORTS, "/dev/port", O_RDWR) 
    21702170    or die "/dev/port: $!\n"; 
    2171   binmode IOPORTS
     2171  binmode(IOPORTS)
    21722172} 
    21732173 
    21742174sub close_ioports 
    21752175{ 
    2176   close (IOPORTS) 
     2176  close(IOPORTS) 
    21772177    or print "Warning: $!\n"; 
    21782178} 
     
    21832183{ 
    21842184  my ($res, $nrchars); 
    2185   sysseek IOPORTS, $_[0], 0 or return -1; 
    2186   $nrchars = sysread IOPORTS, $res, 1
     2185  sysseek(IOPORTS, $_[0], 0) or return -1; 
     2186  $nrchars = sysread(IOPORTS, $res, 1)
    21872187  return -1 if not defined $nrchars or $nrchars != 1; 
    2188   $res = unpack "C", $res
     2188  $res = unpack("C", $res)
    21892189  return $res; 
    21902190} 
     
    21952195sub outb 
    21962196{ 
    2197   my $towrite = pack "C", $_[1]
    2198   sysseek IOPORTS, $_[0], 0 or return -1; 
    2199   my $nrchars = syswrite IOPORTS, $towrite, 1
     2197  my $towrite = pack("C", $_[1])
     2198  sysseek(IOPORTS, $_[0], 0) or return -1; 
     2199  my $nrchars = syswrite(IOPORTS, $towrite, 1)
    22002200  return -1 if not defined $nrchars or $nrchars != 1; 
    22012201  return 0; 
     
    22082208sub isa_read_byte 
    22092209{ 
    2210   outb $_[0], $_[2]
    2211   return inb $_[1]
     2210  outb($_[0], $_[2])
     2211  return inb($_[1])
    22122212} 
    22132213 
     
    22192219sub isa_write_byte 
    22202220{ 
    2221   outb $_[0], $_[2]
    2222   outb $_[1], $_[3]
     2221  outb($_[0], $_[2])
     2222  outb($_[1], $_[3])
    22232223} 
    22242224 
     
    22432243    } 
    22442244  } 
    2245   close INPUTFILE
     2245  close(INPUTFILE)
    22462246 
    22472247  my $use_udev = 0; 
     
    22562256      } 
    22572257    } 
    2258     close INPUTFILE
     2258    close(INPUTFILE)
    22592259  } 
    22602260 
     
    23422342  } 
    23432343  push @cpu, $entry if scalar keys(%{$entry}); # Last entry 
    2344   close INPUTFILE
     2344  close(INPUTFILE)
    23452345} 
    23462346 
     
    25252525sub adapter_pci_detection_sis_96x 
    25262526{ 
    2527   my $driver=""; 
     2527  my $driver = ""; 
    25282528 
    25292529  # first, determine which driver if any... 
     
    26762676{ 
    26772677  my $file = shift; 
    2678   my $funcs = pack "L", 0; # Allocate space 
    2679  
    2680   ioctl $file, IOCTL_I2C_FUNCS, $funcs or return -1; 
    2681   $funcs = unpack "L", $funcs
     2678  my $funcs = pack("L", 0); # Allocate space 
     2679 
     2680  ioctl($file, IOCTL_I2C_FUNCS, $funcs) or return -1; 
     2681  $funcs = unpack("L", $funcs)
    26822682 
    26832683  return $funcs; 
     
    26962696 
    26972697  $addr += 0; # Make sure it's a number not a string 
    2698   ioctl $file, IOCTL_I2C_SLAVE, $addr or return 0; 
     2698  ioctl($file, IOCTL_I2C_SLAVE, $addr) or return 0; 
    26992699  return 1; 
    27002700} 
     
    27162716{ 
    27172717  my ($file, $read_write, $command, $size, $data) = @_; 
    2718   my $data_array = pack "C32", @$data
    2719   my $ioctl_data = pack "C2x2Ip", ($read_write, $command, $size, $data_array); 
    2720   ioctl $file, IOCTL_I2C_SMBUS, $ioctl_data or return 0; 
    2721   @{$_[4]} = unpack "C32", $data_array
     2718  my $data_array = pack("C32", @$data)
     2719  my $ioctl_data = pack("C2x2Ip", $read_write, $command, $size, $data_array); 
     2720  ioctl($file, IOCTL_I2C_SMBUS, $ioctl_data) or return 0; 
     2721  @{$_[4]} = unpack("C32", $data_array)
    27222722  return 1; 
    27232723} 
     
    27302730  my ($file, $value) = @_; 
    27312731  my @data; 
    2732   i2c_smbus_access $file, $value, 0, SMBUS_QUICK, \@data 
     2732  i2c_smbus_access($file, $value, 0, SMBUS_QUICK, \@data) 
    27332733         or return -1; 
    27342734  return 0; 
     
    27412741  my ($file) = @_; 
    27422742  my @data; 
    2743   i2c_smbus_access $file, SMBUS_READ, 0, SMBUS_BYTE, \@data 
     2743  i2c_smbus_access($file, SMBUS_READ, 0, SMBUS_BYTE, \@data) 
    27442744         or return -1; 
    27452745  return $data[0]; 
     
    27592759    return $i2c_byte_cache[$command]; 
    27602760  } 
    2761   i2c_smbus_access $file, SMBUS_READ, $command, SMBUS_BYTE_DATA, \@data 
     2761  i2c_smbus_access($file, SMBUS_READ, $command, SMBUS_BYTE_DATA, \@data) 
    27622762         or return -1; 
    27632763  return ($i2c_byte_cache[$command] = $data[0]); 
     
    27772777  my ($file, $command) = @_; 
    27782778  my @data; 
    2779   i2c_smbus_access $file, SMBUS_READ, $command, SMBUS_WORD_DATA, \@data 
     2779  i2c_smbus_access($file, SMBUS_READ, $command, SMBUS_WORD_DATA, \@data) 
    27802780         or return -1; 
    27812781  return $data[0] + 256 * $data[1]; 
     
    29202920               if exists $detected_entry->{i2c_sub_addrs}; 
    29212921      if ($detected_entry->{i2c_devnr} == $datahash->{i2c_devnr} and 
    2922           any_list_match \@entry_addrs, \@hash_addrs) { 
     2922          any_list_match(\@entry_addrs, \@hash_addrs)) { 
    29232923        if ($detected_entry->{conf} >= $datahash->{conf}) { 
    29242924          $put_in_detected = 0; 
     
    29522952             if exists $detected_ref->[$i]->{i2c_sub_addrs}; 
    29532953        if ($detected_ref->[$i]->{i2c_devnr} == $datahash->{i2c_devnr} and 
    2954             any_list_match \@entry_addrs, \@hash_addrs) { 
     2954            any_list_match(\@entry_addrs, \@hash_addrs)) { 
    29552955          push @$misdetected_ref, $detected_ref->[$i] 
    29562956            unless $chipdriver eq $main_entry->{driver}; 
     
    29822982 
    29832983  # First determine where the hash has to be added. 
    2984   $isalias=0; 
     2984  $isalias = 0; 
    29852985  for ($i = 0; $i < @chips_detected; $i++) { 
    29862986    last if ($chips_detected[$i]->{driver} eq $chipdriver); 
     
    30093009        print("Can't open $dev_i2c$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"), 
    30103010        next; 
    3011       binmode FILE
    3012       i2c_set_slave_addr \*FILE, $new_misdetected_ref->[$i]->{i2c_addr} or 
     3011      binmode(FILE)
     3012      i2c_set_slave_addr(\*FILE, $new_misdetected_ref->[$i]->{i2c_addr}) or 
    30133013           print("Can't set I2C address for ", 
    30143014                 "$dev_i2c$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"), 
     
    30313031        print("Can't open $dev_i2c$new_detected_ref->[$i]->{i2c_devnr}?!?\n"), 
    30323032        next; 
    3033       binmode FILE
    3034       i2c_set_slave_addr \*FILE, $new_detected_ref->[$i]->{i2c_addr} or 
     3033      binmode(FILE)
     3034      i2c_set_slave_addr(\*FILE, $new_detected_ref->[$i]->{i2c_addr}) or 
    30353035           print("Can't set I2C address for ", 
    30363036                 "$dev_i2c$new_detected_ref->[$i]->{i2c_devnr}?!?\n"), 
     
    30403040        $new_detected_ref->[$i]->{isa_addr} = $datahash->{isa_addr}; 
    30413041        ($datahash) = splice (@$new_detected_ref, $i, 1); 
    3042         $isalias=1; 
     3042        $isalias = 1; 
    30433043        last; 
    30443044      } 
     
    31233123  open(local *FILE, "$dev_i2c$adapter_nr") or 
    31243124    (print "Can't open $dev_i2c$adapter_nr\n"), return; 
    3125   binmode FILE
     3125  binmode(FILE)
    31263126 
    31273127  # Can we probe this adapter? 
     
    31983198    $| = 1; 
    31993199    foreach $chip (@chip_ids) { 
    3200       if (exists $chip->{i2c_addrs} and contains $addr, @{$chip->{i2c_addrs}}) { 
     3200      if (exists $chip->{i2c_addrs} and contains($addr, @{$chip->{i2c_addrs}})) { 
    32013201        printf("\%-60s", sprintf("Probing for `\%s'... ", $chip->{name})); 
    32023202        if (($conf, @chips) = &{$chip->{i2c_detect}} (\*FILE, $addr)) { 
     
    32313231            $new_hash->{i2c_sub_addrs} = \@chips_copy; 
    32323232          } 
    3233           add_i2c_to_chips_detected $chip->{driver}, $new_hash
     3233          add_i2c_to_chips_detected($chip->{driver}, $new_hash)
    32343234        } else { 
    32353235          print "No\n"; 
     
    32583258                       chipname => $chip->{name} 
    32593259                     }; 
    3260       $new_hash = add_isa_to_chips_detected $chip->{alias_detect}, $chip->{driver}, 
    3261                                             $new_hash
     3260      $new_hash = add_isa_to_chips_detected($chip->{alias_detect}, $chip->{driver}, 
     3261                                            $new_hash)
    32623262      if ($new_hash) { 
    32633263        printf "    Alias of the chip on I2C bus `%s', address 0x%04x\n", 
     
    33783378                   chipname => $chip->{name} 
    33793379                 }; 
    3380   add_isa_to_chips_detected $chip->{alias_detect}, $chip->{driver}, 
    3381                                         $new_hash
     3380  add_isa_to_chips_detected($chip->{alias_detect}, $chip->{driver}, 
     3381                                        $new_hash)
    33823382} 
    33833383 
     
    35363536{ 
    35373537  my ($file, $addr) = @_; 
    3538   return if (i2c_smbus_read_byte_data($file, 0x58)) != 0xac; 
     3538  return if i2c_smbus_read_byte_data($file, 0x58) != 0xac; 
    35393539  return (8); 
    35403540} 
     
    35683568{ 
    35693569  my ($chip, $addr) = @_; 
    3570   my $val = inb ($addr + 1); 
    3571   return if inb ($addr + 2) != $val or inb ($addr + 3) != $val or 
    3572             inb ($addr + 7) != $val; 
     3570  my $val = inb($addr + 1); 
     3571  return if inb($addr + 2) != $val or inb($addr + 3) != $val or 
     3572            inb($addr + 7) != $val; 
    35733573 
    35743574  $val = inb($addr + 5); 
    35753575  outb($addr + 5, ~$val & 0x7f); 
    3576   if ((inb ($addr+5) & 0x7f) != (~ $val & 0x7f)) { 
     3576  if ((inb($addr+5) & 0x7f) != (~ $val & 0x7f)) { 
    35773577    outb($addr+5, $val); 
    35783578    return; 
    35793579  } 
    3580   my $readproc = sub { isa_read_byte $addr + 5, $addr + 6, @_ }; 
     3580  my $readproc = sub { isa_read_byte($addr + 5, $addr + 6, @_) }; 
    35813581  return unless (&$readproc(0x40) & 0x80) == 0x00; 
    35823582  my $reg = &$readproc(0x49); 
     
    36053605  my ($chip, $isa_addr, $file, $i2c_addr) = @_; 
    36063606  my $i; 
    3607   my $readproc = sub { isa_read_byte $isa_addr + 5, $isa_addr + 6, @_ }; 
     3607  my $readproc = sub { isa_read_byte($isa_addr + 5, $isa_addr + 6, @_) }; 
    36083608  return 0 unless &$readproc(0x48) == $i2c_addr; 
    36093609  for ($i = 0x2b; $i <= 0x3d; $i ++) { 
     
    44474447{ 
    44484448  my ($file, $addr) = @_; 
    4449   return if (i2c_smbus_read_byte_data($file, 0x3e)) != 0x02; 
     4449  return if i2c_smbus_read_byte_data($file, 0x3e) != 0x02; 
    44504450  return if (i2c_smbus_read_byte_data($file, 0x3f) & 0xfc) != 0x04; 
    44514451  return (7); 
     
    46204620  my ($chip, $isa_addr, $file, $i2c_addr) = @_; 
    46214621  my $i; 
    4622   my $readproc = sub { isa_read_byte $isa_addr + 5, $isa_addr + 6, @_ }; 
     4622  my $readproc = sub { isa_read_byte($isa_addr + 5, $isa_addr + 6, @_) }; 
    46234623  return 0 unless &$readproc(0x48) == $i2c_addr; 
    46244624  for ($i = 0x2b; $i <= 0x3d; $i ++) { 
     
    46354635  my ($chip, $addr) = @_; 
    46364636  my ($reg1, $reg2); 
    4637   my $val = inb ($addr + 1); 
    4638   return if inb ($addr + 2) != $val or inb ($addr + 3) != $val or 
    4639             inb ($addr + 7) != $val; 
     4637  my $val = inb($addr + 1); 
     4638  return if inb($addr + 2) != $val or inb($addr + 3) != $val or 
     4639            inb($addr + 7) != $val; 
    46404640 
    46414641  $val = inb($addr + 5); 
    46424642  outb($addr+5, ~$val & 0x7f); 
    4643   if ((inb ($addr+5) & 0x7f) != (~ $val & 0x7f)) { 
     4643  if ((inb($addr+5) & 0x7f) != (~ $val & 0x7f)) { 
    46444644    outb($addr+5, $val); 
    46454645    return; 
    46464646  } 
    46474647 
    4648   my $read_proc = sub { isa_read_byte $addr + 5, $addr + 6, @_ }; 
     4648  my $read_proc = sub { isa_read_byte($addr + 5, $addr + 6, @_) }; 
    46494649  $reg1 = &$read_proc(0x4e); 
    46504650  $reg2 = &$read_proc(0x4f); 
     
    48964896    # Low limits over high limits 
    48974897    if ($chip != 5) { # LM84 doesn't have low limits 
    4898       $llo-=256 if ($llo & 0x80); 
    4899       $rlo-=256 if ($rlo & 0x80); 
     4898      $llo -= 256 if ($llo & 0x80); 
     4899      $rlo -= 256 if ($rlo & 0x80); 
    49004900      return if ($llo > $lhi) or ($rlo > $rhi); 
    49014901    } 
     
    50085008  my ($chip, $isa_addr, $file, $i2c_addr) = @_; 
    50095009  my $i; 
    5010   my $readproc = sub { isa_read_byte $isa_addr + 5, $isa_addr + 6, @_ }; 
     5010  my $readproc = sub { isa_read_byte($isa_addr + 5, $isa_addr + 6, @_) }; 
    50115011  return 0 unless &$readproc(0x48) == $i2c_addr; 
    50125012  for ($i = 0x30; $i <= 0x45; $i++) { 
     
    53465346sub ipmi_kcs_detect 
    53475347{ 
    5348   return if inb (0x0ca3) == 0xff; 
     5348  return if inb(0x0ca3) == 0xff; 
    53495349  return (4); 
    53505350} 
     
    53525352sub ipmi_smic_detect 
    53535353{ 
    5354   return if inb (0x0cab) == 0xff; 
     5354  return if inb(0x0cab) == 0xff; 
    53555355  return (4); 
    53565356} 
     
    56425642      } 
    56435643      if (exists $detection->{isa_addr}) { 
    5644            $isa=1; 
     5644           $isa = 1; 
    56455645      } 
    56465646      if ($chip->{driver} eq "bmcsensors" || 
     
    56935693         } 
    56945694       } 
    5695        close INPUTFILE
     5695       close(INPUTFILE)
    56965696       #check return value from modprobe in case modprobe -l isn't supported 
    56975697       if ((($? >> 8) == 0) && ! $modulefound) { 
     
    57275727    $configfile = "# hwmon module options\n" unless defined $configfile; 
    57285728    $configfile .= "options $chip->{driver}"; 
    5729     $configfile .= sprintf " ignore=%d,0x%02x", shift @optionlist, 
    5730                                                shift @optionlist 
     5729    $configfile .= sprintf(" ignore=%d,0x%02x", shift @optionlist, 
     5730                                               shift @optionlist) 
    57315731                  if @optionlist; 
    5732     $configfile .= sprintf ",%d,0x%02x", shift @optionlist, shift @optionlist 
     5732    $configfile .= sprintf(",%d,0x%02x", shift @optionlist, shift @optionlist) 
    57335733                  while @optionlist; 
    5734     $configfile .= sprintf " probe=%d,0x%02x", shift @probelist, 
    5735                                               shift @probelist 
     5734    $configfile .= sprintf(" probe=%d,0x%02x", shift @probelist, 
     5735                                              shift @probelist) 
    57365736                  if @probelist; 
    5737     $configfile .= sprintf ",%d,0x%02x", shift @probelist, shift @probelist 
     5737    $configfile .= sprintf(",%d,0x%02x", shift @probelist, shift @probelist) 
    57385738                  while @probelist; 
    57395739    $configfile .= "\n"; 
     
    57605760 
    57615761  initialize_kernel_version(); 
    5762   initialize_conf
    5763   initialize_proc_pci
    5764   initialize_modules_list
     5762  initialize_conf()
     5763  initialize_proc_pci()
     5764  initialize_modules_list()
    57655765  # make sure any special case chips are added to the chip_ids list before 
    57665766  # making the support modules list 
    57675767  chip_special_cases(); 
    5768   initialize_modules_supported
     5768  initialize_modules_supported()
    57695769  initialize_cpu_list(); 
    57705770 
     
    57825782  print "We can start with probing for (PCI) I2C or SMBus adapters.\n"; 
    57835783  print "Do you want to probe now? (YES/no): "; 
    5784   @adapters = adapter_pci_detection 
     5784  @adapters = adapter_pci_detection() 
    57855785                        if ($did_adapter_detection = not <STDIN> =~ /\s*[Nn]/); 
    57865786  print "\n"; 
     
    57985798        print "Load `$adapter' (say NO if built into your kernel)? (YES/no): "; 
    57995799        unless (<STDIN> =~ /^\s*[Nn]/) { 
    5800           if (system ("modprobe", $adapter)) { 
     5800          if (system("modprobe", $adapter)) { 
    58015801            print "Loading failed... skipping.\n"; 
    58025802          } else { 
     
    58205820    if (<STDIN> =~ /^\s*n/i) { 
    58215821      print "Well, you will know best.\n"; 
    5822     } elsif (system "modprobe", "i2c-dev") { 
     5822    } elsif (system("modprobe", "i2c-dev")) { 
    58235823      print "Loading failed, expect problems later on.\n"; 
    58245824    } else { 
     
    58535853            "Addresses: "; 
    58545854      $inp2 = <STDIN>; 
    5855       chop $inp2
     5855      chop($inp2)
    58565856      @not_to_scan = parse_not_to_scan(0x03, 0x77, $inp2); 
    58575857    } 
    5858     scan_adapter $dev_nr, $adap, $i2c_adapters[$dev_nr]->{'driver'}, 
    5859                  \@not_to_scan  unless $inp =~ /^\s*[Nn]/; 
     5858    scan_adapter($dev_nr, $adap, $i2c_adapters[$dev_nr]->{'driver'}, 
     5859                 \@not_to_scan) unless $inp =~ /^\s*[Nn]/; 
    58605860  } 
    58615861  print "\n"; 
     
    59305930    if (@{$chip->{detected}}) { 
    59315931      print "  Detects correctly:\n"; 
    5932       print_chips_report $chip->{detected}
     5932      print_chips_report($chip->{detected})
    59335933    } 
    59345934    if (@{$chip->{misdetected}}) { 
    59355935      print "  Misdetects:\n"; 
    5936       print_chips_report $chip->{misdetected}
     5936      print_chips_report($chip->{misdetected})
    59375937    } 
    59385938  } 
     
    59495949    if (($have_modprobe_d and not m/^\s*n/i) or m/^\s*y/i) { 
    59505950      unless ($have_modprobe_d) { 
    5951         mkdir '/etc/modprobe.d', 0777 
     5951        mkdir('/etc/modprobe.d', 0777) 
    59525952          or die "Sorry, can't create /etc/modprobe.d ($!)"; 
    59535953      } 
     
    59745974  if (($have_sysconfig and not m/^\s*n/i) or m/^\s*y/i) { 
    59755975    unless ($have_sysconfig) { 
    5976       mkdir '/etc/sysconfig', 0777 
     5976      mkdir('/etc/sysconfig', 0777) 
    59775977        or die "Sorry, can't create /etc/sysconfig ($!)"; 
    59785978    }