From 0b7a7b97872b87dca012f30bfdee18c622f93a76 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 11 Jun 2003 08:28:55 +0000 Subject: [PATCH] Undid outb() fix by Jim Morris. Fixed faulty outb() calls. Armored outb() against future faulty calls. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1783 7894878c-1315-0410-8ee3-d5d059ff63e0 --- prog/detect/sensors-detect | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/prog/detect/sensors-detect b/prog/detect/sensors-detect index 810d2992..37ddff15 100755 --- a/prog/detect/sensors-detect +++ b/prog/detect/sensors-detect @@ -1330,7 +1330,15 @@ sub inb # Returns: -1 on failure, 0 on success. sub outb { - my $towrite = pack("C", $_[1] & 0x7f); + if ($_[1] > 0xff) + { + my ($package, $filename, $line, $sub) = caller(1); + print "\n*** Called outb with value=$_[1] from line $line\n", + "*** (in $sub). PLEASE REPORT!\n", + "*** Terminating.\n"; + exit(-1); + } + my $towrite = pack "C", $_[1]; sysseek IOPORTS, $_[0], 0 or return -1; my $nrchars = syswrite IOPORTS, $towrite, 1; return -1 if not defined $nrchars or $nrchars != 1; @@ -2186,7 +2194,7 @@ sub lm78_isa_detect inb ($addr + 7) != $val; $val = inb($addr + 5) & 0x7f; - outb($addr+5,~ $val); + outb($addr + 5, ~$val & 0xff); if ((inb ($addr+5) & 0x7f) != (~ $val & 0x7f)) { outb($addr+5,$val); return; @@ -2402,7 +2410,7 @@ sub w83781d_isa_detect inb ($addr + 7) != $val; $val = inb($addr + 5) & 0x7f; - outb($addr+5,~ $val); + outb($addr+5, ~$val & 0xff); if ((inb ($addr+5) & 0x7f) != (~ $val & 0x7f)) { outb($addr+5,$val); return; @@ -2757,7 +2765,7 @@ sub ite_isa_detect inb ($addr + 7) != $val; $val = inb($addr + 5) & 0x7f; - outb($addr+5,~ $val); + outb($addr+5, ~$val & 0xff); if ((inb ($addr+5) & 0x7f) != (~ $val & 0x7f)) { outb($addr+5,$val); return;