Re: PII Temperature

M. Patrick Goda (mpg@t6-serv.lanl.gov)
Tue, 4 Nov 1997 07:55:29 -0700


Here is a message a friend of mine came across in regards to this
issue. We have a PII box and this seems to work fine:

Patrick

---------------------------------------------------------------------
M. Patrick Goda W: (505)667-5386
Los Alamos National Laboratory H: (505)989-4506
Theoretical Astrophysics, T-6 MS B288 mpg@nea.lanl.gov
Los Alamos, NM 87545 http://qso.lanl.gov/~mpg
---------------------------------------------------------------------
Snappy Quote: "abcdefghijklmnopqrstuvwxyz"*
*some assembly required
---------------------------------------------------------------------

-----------------------------------------------------------------------

> I've written a driver for the National Semiconductor LM78
> Microprocessor System Hardware Monitor that's found on some
> motherboards. It's available from:

> http://cesdis.gsfc.nasa.gov/beowulf/software/lm78-0.1.tar.gz

I tried it out, and it works fine on an ASUS P2L97 (at least the
temperature and fan speed seems reasonable). Thanks.

Following is a diff for the 2.1 series kernels.

Mike

diff -c lm78-orig/lm78.c lm78/lm78.c
*** lm78-orig/lm78.c Fri Oct 31 12:56:30 1997
--- lm78/lm78.c Sat Nov 1 15:36:46 1997
***************
*** 20,25 ****
--- 20,26 ----
#include <linux/sysctl.h>
#include <linux/ioport.h>
#include <asm/io.h>
+ #include <asm/uaccess.h>

#include <lm78.h>

***************
*** 291,302 ****
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
int *data, *newdata, len, ret;

if (!table->data || !table->maxlen) return -ENOTDIR;

data = (int *) table->data;
/*--- read -----------------------------------------------------*/
! if (oldval && oldlenp && get_user(oldlenp)) {
LM78_get_limit(table->ctl_name, &data[0], &data[1]);
return 0;
}
--- 292,306 ----
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
int *data, *newdata, len, ret;
+ int tmp;

if (!table->data || !table->maxlen) return -ENOTDIR;

data = (int *) table->data;
/*--- read -----------------------------------------------------*/
! if (get_user(tmp, oldlenp))
! return -EFAULT;
! if (oldval && oldlenp && tmp) {
LM78_get_limit(table->ctl_name, &data[0], &data[1]);
return 0;
}
***************
*** 305,312 ****
newdata = (int *) newval;
len = newlen/sizeof(int);
if (len < 2) return -EINVAL;
! data[0] = get_user(&newdata[0]);
! data[1] = get_user(&newdata[1]);
ret = LM78_set_limit(table->ctl_name, data[0], data[1]);
return 1;
}
--- 309,318 ----
newdata = (int *) newval;
len = newlen/sizeof(int);
if (len < 2) return -EINVAL;
! if (get_user(data[0], &newdata[0]))
! return -EFAULT;
! if (get_user(data[1], &newdata[1]))
! return -EFAULT;
ret = LM78_set_limit(table->ctl_name, data[0], data[1]);
return 1;
}
***************
*** 359,371 ****
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
int *data, reg;

if (!table->data || !table->maxlen) return -ENOTDIR;

reg = table->ctl_name;
data = (int *) table->data;
/*--- read -----------------------------------------------------*/
! if (oldval && oldlenp && get_user(oldlenp)) {
*data = LM78_get_reading(reg);
return 0; /* Use auto-magic read */
}
--- 365,380 ----
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
int *data, reg;
+ int tmp;

if (!table->data || !table->maxlen) return -ENOTDIR;

reg = table->ctl_name;
data = (int *) table->data;
/*--- read -----------------------------------------------------*/
! if (get_user(tmp, oldlenp))
! return -EFAULT;
! if (oldval && oldlenp && tmp) {
*data = LM78_get_reading(reg);
return 0; /* Use auto-magic read */
}
***************
*** 420,429 ****
int sysctl_ints(ctl_table *table, int *name, int nlen,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
if (!table->data || !table->maxlen) return -ENOTDIR;

/*--- read -----------------------------------------------------*/
! if (oldval && oldlenp && get_user(oldlenp)) {
lm78_print_ints();
return 0;
}
--- 429,441 ----
int sysctl_ints(ctl_table *table, int *name, int nlen,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
+ int tmp;
if (!table->data || !table->maxlen) return -ENOTDIR;

/*--- read -----------------------------------------------------*/
! if (get_user(tmp, oldlenp))
! return -EFAULT;
! if (oldval && oldlenp && tmp) {
lm78_print_ints();
return 0;
}
***************
*** 457,466 ****
int sysctl_reset(ctl_table *table, int *name, int nlen,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
if (!table->data || !table->maxlen) return -ENOTDIR;

/*--- read -----------------------------------------------------*/
! if (oldval && oldlenp && get_user(oldlenp)) {
*((int *)table->data) = 0;
return 0;
}
--- 469,481 ----
int sysctl_reset(ctl_table *table, int *name, int nlen,
void *oldval, size_t *oldlenp,
void *newval, size_t newlen, void **context) {
+ int tmp;
if (!table->data || !table->maxlen) return -ENOTDIR;

/*--- read -----------------------------------------------------*/
! if (get_user(tmp, oldlenp))
! return -EFAULT;
! if (oldval && oldlenp && tmp) {
*((int *)table->data) = 0;
return 0;
}
***************
*** 544,575 ****

/* This procedure stolen from kernel/sysctl.c */
int proc_dointvec(ctl_table *table, int write, struct file *filp,
! void *buffer, size_t *lenp) {
int *i, vleft, first=1, len, left, neg, val;
#define TMPBUFLEN 20
char buf[TMPBUFLEN], *p;
!
if (!table->data || !table->maxlen || !*lenp ||
(filp->f_pos && !write)) {
*lenp = 0;
return 0;
}
!
i = (int *) table->data;
vleft = table->maxlen / sizeof(int);
left = *lenp;
!
for (; left && vleft--; i++, first=0) {
if (write) {
! while (left && isspace(get_user((char *) buffer)))
! left--, ((char *) buffer)++;
if (!left)
break;
neg = 0;
len = left;
if (len > TMPBUFLEN-1)
len = TMPBUFLEN-1;
! memcpy_fromfs(buf, buffer, len);
buf[len] = 0;
p = buf;
if (*p == '-' && left > 1) {
--- 559,599 ----

/* This procedure stolen from kernel/sysctl.c */
int proc_dointvec(ctl_table *table, int write, struct file *filp,
! void *buffer, size_t *lenp)
! {
int *i, vleft, first=1, len, left, neg, val;
#define TMPBUFLEN 20
char buf[TMPBUFLEN], *p;
!
if (!table->data || !table->maxlen || !*lenp ||
(filp->f_pos && !write)) {
*lenp = 0;
return 0;
}
!
i = (int *) table->data;
vleft = table->maxlen / sizeof(int);
left = *lenp;
!
for (; left && vleft--; i++, first=0) {
if (write) {
! while (left) {
! char c;
! if(get_user(c,(char *) buffer))
! return -EFAULT;
! if (!isspace(c))
! break;
! left--;
! ((char *) buffer)++;
! }
if (!left)
break;
neg = 0;
len = left;
if (len > TMPBUFLEN-1)
len = TMPBUFLEN-1;
! if(copy_from_user(buf, buffer, len))
! return -EFAULT;
buf[len] = 0;
p = buf;
if (*p == '-' && left > 1) {
***************
*** 595,614 ****
len = strlen(buf);
if (len > left)
len = left;
! memcpy_tofs(buffer, buf, len);
left -= len;
buffer += len;
}
}
!
if (!write && !first && left) {
! put_user('\n', (char *) buffer);
left--, buffer++;
}
if (write) {
p = (char *) buffer;
! while (left && isspace(get_user(p++)))
left--;
}
if (write && first)
return -EINVAL;
--- 619,646 ----
len = strlen(buf);
if (len > left)
len = left;
! if(copy_to_user(buffer, buf, len))
! return -EFAULT;
left -= len;
buffer += len;
}
}
!
if (!write && !first && left) {
! if(put_user('\n', (char *) buffer))
! return -EFAULT;
left--, buffer++;
}
if (write) {
p = (char *) buffer;
! while (left) {
! char c;
! if(get_user(c, p++))
! return -EFAULT;
! if (!isspace(c))
! break;
left--;
+ }
}
if (write && first)
return -EINVAL;
***************
*** 629,642 ****
}

if (write) {
len = 0;
p = buffer;
while (len < *lenp &&
! (c = get_user(p++)) != 0 && c != '\n')
! len++;
if (len >= table->maxlen)
len = table->maxlen-1;
! memcpy_fromfs(table->data, buffer, len);
((char *) table->data)[len] = 0;
filp->f_pos += *lenp;
} else {
--- 661,681 ----
}

if (write) {
+ int tmp;
len = 0;
p = buffer;
+ if (get_user(tmp, p++))
+ return -EFAULT;
while (len < *lenp &&
! (c = tmp) != 0 && c != '\n') {
! len++;
! if (get_user(tmp, p++))
! return -EFAULT;
! }
if (len >= table->maxlen)
len = table->maxlen-1;
! if (copy_from_user(table->data, buffer, len))
! return -EFAULT;;
((char *) table->data)[len] = 0;
filp->f_pos += *lenp;
} else {
***************
*** 645,654 ****
len = table->maxlen;
if (len > *lenp)
len = *lenp;
! if (len)
! memcpy_tofs(buffer, table->data, len);
if (len < *lenp) {
! put_user('\n', ((char *) buffer) + len);
len++;
}
*lenp = len;
--- 684,696 ----
len = table->maxlen;
if (len > *lenp)
len = *lenp;
! if (len) {
! if (copy_to_user(buffer, table->data, len))
! return -EFAULT;
! }
if (len < *lenp) {
! if (put_user('\n', ((char *) buffer) + len))
! return -EFAULT;
len++;
}
*lenp = len;

--
Michael S. Warren			Email:	mswarren@lanl.gov
Theoretical Astrophysics, T-6		URL:	http://qso.lanl.gov/~msw/
Mail Stop B288				Phone:	(505) 665-5023
Los Alamos National Laboratory		FAX:	(505) 665-3003
Los Alamos, NM 87545

--