mirror of
https://github.com/lm-sensors/lm-sensors
synced 2025-08-31 14:25:39 +00:00
add devfs /dev/i2c/x support
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@1053 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -44,6 +44,7 @@ ask CVS about it:
|
||||
Module via686a: Allow force=9191,address (for A7V/K7V boards)
|
||||
Module w83781d: Don't reinitialize as99127f chip; this may cause fan/temp
|
||||
reading changes
|
||||
Programs i2cdetect, i2cdump: add devfs /dev/i2c/x support
|
||||
Program mkpatch.pl: Fix adm9240 typos, add more chips to Configure.help,
|
||||
remove ltc1710
|
||||
Program sens_update_rrd: new
|
||||
|
@@ -1,7 +1,8 @@
|
||||
/*
|
||||
i2cdetect.c - Part of i2cdetect, a user-space program to scan for I2C
|
||||
devices.
|
||||
Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl>
|
||||
Copyright (c) 1999-2001 Frodo Looijaard <frodol@dds.nl> and
|
||||
Mark D. Studebaker <mdsxyz123@yahoo.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@@ -45,9 +46,10 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
char *end;
|
||||
int i,j,res,i2cbus,file;
|
||||
int e1, e2;
|
||||
int e1, e2, e3;
|
||||
char filename1[20];
|
||||
char filename2[20];
|
||||
char filename3[20];
|
||||
char *filename;
|
||||
long funcs;
|
||||
|
||||
@@ -69,29 +71,46 @@ int main(int argc, char *argv[])
|
||||
help();
|
||||
}
|
||||
|
||||
/*
|
||||
* Try all three variants and give the correct error message
|
||||
* upon failure
|
||||
*/
|
||||
|
||||
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
||||
sprintf(filename2,"/dev/i2c%d",i2cbus);
|
||||
sprintf(filename3,"/dev/i2c/%d",i2cbus);
|
||||
if ((file = open(filename1,O_RDWR)) < 0) {
|
||||
e1 = errno;
|
||||
if ((file = open(filename2,O_RDWR)) < 0) {
|
||||
e2 = errno;
|
||||
if(e1 == ENOENT && e2 == ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",
|
||||
filename1,filename2,strerror(ENOENT));
|
||||
if ((file = open(filename3,O_RDWR)) < 0) {
|
||||
e3 = errno;
|
||||
if(e1 == ENOENT && e2 == ENOENT && e3 == ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s', `%s', or `%s': %s\n",
|
||||
filename1,filename2,filename3,strerror(ENOENT));
|
||||
}
|
||||
if (e1 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename1,strerror(e1));
|
||||
if(e1 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
if (e2 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename2,strerror(e2));
|
||||
if(e2 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
if (e3 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename3,strerror(e3));
|
||||
if(e3 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
exit(1);
|
||||
} else {
|
||||
filename = filename3;
|
||||
}
|
||||
if (e1 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename1,strerror(e1));
|
||||
if(e1 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
if (e2 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename2,strerror(e2));
|
||||
if(e2 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
exit(1);
|
||||
} else {
|
||||
filename = filename2;
|
||||
}
|
||||
|
@@ -46,10 +46,11 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
char *end;
|
||||
int i,j,res,i2cbus,address,size,file;
|
||||
int e1, e2;
|
||||
int e1, e2, e3;
|
||||
int bank = 0, bankreg = 0x4E;
|
||||
char filename1[20];
|
||||
char filename2[20];
|
||||
char filename3[20];
|
||||
char *filename;
|
||||
long funcs;
|
||||
unsigned char cblock[256];
|
||||
@@ -133,31 +134,48 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Try all three variants and give the correct error message
|
||||
* upon failure
|
||||
*/
|
||||
|
||||
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
||||
sprintf(filename2,"/dev/i2c%d",i2cbus);
|
||||
sprintf(filename3,"/dev/i2c/%d",i2cbus);
|
||||
if ((file = open(filename1,O_RDWR)) < 0) {
|
||||
e1 = errno;
|
||||
if ((file = open(filename2,O_RDWR)) < 0) {
|
||||
e2 = errno;
|
||||
if(e1 == ENOENT && e2 == ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",
|
||||
filename1,filename2,strerror(ENOENT));
|
||||
if ((file = open(filename3,O_RDWR)) < 0) {
|
||||
e3 = errno;
|
||||
if(e1 == ENOENT && e2 == ENOENT && e3 == ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s', `%s', or `%s': %s\n",
|
||||
filename1,filename2,filename3,strerror(ENOENT));
|
||||
}
|
||||
if (e1 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename1,strerror(e1));
|
||||
if(e1 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
if (e2 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename2,strerror(e2));
|
||||
if(e2 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
if (e3 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename3,strerror(e3));
|
||||
if(e3 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
exit(1);
|
||||
} else {
|
||||
filename = filename3;
|
||||
}
|
||||
if (e1 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename1,strerror(e1));
|
||||
if(e1 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
if (e2 != ENOENT) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' : %s\n",
|
||||
filename2,strerror(e2));
|
||||
if(e2 == EACCES)
|
||||
fprintf(stderr,"Run as root?\n");
|
||||
}
|
||||
exit(1);
|
||||
} else {
|
||||
filename = filename2;
|
||||
filename = filename2;
|
||||
}
|
||||
} else {
|
||||
filename = filename1;
|
||||
|
Reference in New Issue
Block a user