mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-30 05:48:07 +00:00
add hack to support eeproms in 2.6 kernels
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2162 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
parent
49f4d2fe55
commit
01c921f51d
4
CHANGES
4
CHANGES
@ -18,7 +18,9 @@ ask CVS about it:
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
2.8.3 (2004????)
|
2.8.3 (2004????)
|
||||||
Module it87: Fix sg_tlx /proc entries
|
Library: Add 2.6 eeprom support
|
||||||
|
Module it87: Fix sg_tlx writes
|
||||||
|
|
||||||
|
|
||||||
2.8.2 (20031211)
|
2.8.2 (20031211)
|
||||||
IMPORTANT: Limit initialization removed from all chip drivers!
|
IMPORTANT: Limit initialization removed from all chip drivers!
|
||||||
|
52
lib/proc.c
52
lib/proc.c
@ -284,13 +284,16 @@ int sensors_get_chip_id(sensors_chip_name name)
|
|||||||
return -SENSORS_ERR_NO_ENTRY;
|
return -SENSORS_ERR_NO_ENTRY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This reads a feature /proc file */
|
/* This reads a feature /proc or /sys file.
|
||||||
|
Sysfs uses a one-value-per file system...
|
||||||
|
except for eeprom, which puts the entire eeprom into one file.
|
||||||
|
*/
|
||||||
int sensors_read_proc(sensors_chip_name name, int feature, double *value)
|
int sensors_read_proc(sensors_chip_name name, int feature, double *value)
|
||||||
{
|
{
|
||||||
int sysctl_name[4] = { CTL_DEV, DEV_SENSORS };
|
int sysctl_name[4] = { CTL_DEV, DEV_SENSORS };
|
||||||
const sensors_chip_feature *the_feature;
|
const sensors_chip_feature *the_feature;
|
||||||
int buflen = BUF_LEN;
|
int buflen = BUF_LEN;
|
||||||
int mag;
|
int mag, eepromoffset, i, ret=0;
|
||||||
char n[NAME_MAX];
|
char n[NAME_MAX];
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
@ -302,19 +305,38 @@ int sensors_read_proc(sensors_chip_name name, int feature, double *value)
|
|||||||
if(foundsysfs) {
|
if(foundsysfs) {
|
||||||
strcpy(n, name.busname);
|
strcpy(n, name.busname);
|
||||||
strcat(n, "/");
|
strcat(n, "/");
|
||||||
/* use rindex to append sysname to n */
|
/* total hack for eeprom */
|
||||||
getsysname(the_feature, rindex(n, '\0'), &mag);
|
if (! strcmp(name.prefix, "eeprom")){
|
||||||
if ((f = fopen(n, "r")) != NULL) {
|
strcat(n, "eeprom");
|
||||||
fscanf(f, "%lf", value);
|
if ((f = fopen(n, "r")) != NULL) {
|
||||||
fclose(f);
|
eepromoffset = 1 +
|
||||||
for (; mag > 0; mag --)
|
(the_feature->offset / sizeof(long)) +
|
||||||
*value /= 10.0;
|
(16 * (the_feature->sysctl - EEPROM_SYSCTL1));
|
||||||
// fprintf(stderr, "Feature %s value %lf scale %d offset %d\n",
|
for(i = 0; i <= eepromoffset; i++)
|
||||||
// the_feature->name, *value,
|
if(EOF == (ret = getc(f)))
|
||||||
// the_feature->scaling, the_feature->offset);
|
break;
|
||||||
return 0;
|
fclose(f);
|
||||||
} else
|
if(ret == EOF)
|
||||||
return -SENSORS_ERR_PROC;
|
return -SENSORS_ERR_PROC;
|
||||||
|
*value = ret;
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
return -SENSORS_ERR_PROC;
|
||||||
|
} else {
|
||||||
|
/* use rindex to append sysname to n */
|
||||||
|
getsysname(the_feature, rindex(n, '\0'), &mag);
|
||||||
|
if ((f = fopen(n, "r")) != NULL) {
|
||||||
|
fscanf(f, "%lf", value);
|
||||||
|
fclose(f);
|
||||||
|
for (; mag > 0; mag --)
|
||||||
|
*value /= 10.0;
|
||||||
|
// fprintf(stderr, "Feature %s value %lf scale %d offset %d\n",
|
||||||
|
// the_feature->name, *value,
|
||||||
|
// the_feature->scaling, the_feature->offset);
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
return -SENSORS_ERR_PROC;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sysctl_name[3] = the_feature->sysctl;
|
sysctl_name[3] = the_feature->sysctl;
|
||||||
if (sysctl(sysctl_name, 4, buf, &buflen, NULL, 0))
|
if (sysctl(sysctl_name, 4, buf, &buflen, NULL, 0))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user