mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-14 19:03:13 +00:00
All tools now understand both /dev/i2c-* and /dev/i2c*
git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@827 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
e72953e4fc
commit
93f3a9f7ac
3 files changed
+42
-21
No files matched your search
+15
-6
@@ -45,7 +45,9 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
char *end;
|
||||
int i,j,res,i2cbus,file;
|
||||
char filename[20];
|
||||
char filename1[20];
|
||||
char filename2[20];
|
||||
char *filename;
|
||||
long funcs;
|
||||
|
||||
|
||||
@@ -66,11 +68,18 @@ int main(int argc, char *argv[])
|
||||
help();
|
||||
}
|
||||
|
||||
sprintf(filename,"/dev/i2c-%d",i2cbus);
|
||||
if ((file = open(filename,O_RDWR)) < 0) {
|
||||
fprintf(stderr,"Error: Could not open file `%s': %s\n",filename,
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
||||
sprintf(filename2,"/dev/i2c%d",i2cbus);
|
||||
if ((file = open(filename1,O_RDWR)) < 0) {
|
||||
if ((file = open(filename2,O_RDWR)) < 0) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",filename1,
|
||||
filename2,strerror(errno));
|
||||
exit(1);
|
||||
} else {
|
||||
filename = filename2;
|
||||
}
|
||||
} else {
|
||||
filename = filename1;
|
||||
}
|
||||
|
||||
if (ioctl(file,I2C_FUNCS,&funcs) < 0) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/perl
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
#
|
||||
# sensors-detect - Detect PCI bus and chips
|
||||
@@ -1117,12 +1117,13 @@ sub add_isa_to_chips_detected
|
||||
defined $alias_detect and
|
||||
$new_misdetected_ref->[$i]->{chipname} eq $datahash->{chipname}) {
|
||||
open FILE,"/dev/i2c-$new_misdetected_ref->[$i]->{i2c_devnr}" or
|
||||
open FILE,"/dev/i2c$new_misdetected_ref->[$i]->{i2c_devnr}" or
|
||||
print("Can't open ",
|
||||
"/dev/i2c-$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
"/dev/i2c[-]$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
next;
|
||||
i2c_set_slave_addr \*FILE,$new_misdetected_ref->[$i]->{i2c_addr} or
|
||||
print("Can't set I2C address for ",
|
||||
"/dev/i2c-$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
"/dev/i2c[-]$new_misdetected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
next;
|
||||
if (&$alias_detect ($datahash->{isa_addr},\*FILE,
|
||||
$new_misdetected_ref->[$i]->{i2c_addr})) {
|
||||
@@ -1143,12 +1144,13 @@ sub add_isa_to_chips_detected
|
||||
defined $alias_detect and
|
||||
$new_detected_ref->[$i]->{chipname} eq $datahash->{chipname}) {
|
||||
open FILE,"/dev/i2c-$new_detected_ref->[$i]->{i2c_devnr}" or
|
||||
open FILE,"/dev/i2c$new_detected_ref->[$i]->{i2c_devnr}" or
|
||||
print("Can't open ",
|
||||
"/dev/i2c-$new_detected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
"/dev/i2c[-]$new_detected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
next;
|
||||
i2c_set_slave_addr \*FILE,$new_detected_ref->[$i]->{i2c_addr} or
|
||||
print("Can't set I2C address for ",
|
||||
"/dev/i2c-$new_detected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
"/dev/i2c[-]$new_detected_ref->[$i]->{i2c_devnr}?!?\n"),
|
||||
next;
|
||||
if (&$alias_detect ($datahash->{isa_addr},\*FILE,
|
||||
$new_detected_ref->[$i]->{i2c_addr})) {
|
||||
@@ -1213,7 +1215,8 @@ sub scan_adapter
|
||||
my @not_to_scan = @$not_to_scan;
|
||||
|
||||
open FILE,"/dev/i2c-$adapter_nr" or
|
||||
(print "Can't open /dev/i2c-$adapter_nr ($!)\n"), return;
|
||||
open FILE,"/dev/i2c$adapter_nr" or
|
||||
(print "Can't open /dev/i2c[-]$adapter_nr ($!)\n"), return;
|
||||
|
||||
# Now scan each address in turn
|
||||
foreach $addr (0..0x7f) {
|
||||
@@ -2024,7 +2027,7 @@ sub main
|
||||
"Read\n",
|
||||
" doc/modules for more information.\n";
|
||||
print " Also, you need to be `root', or at least have access to the ",
|
||||
"/dev/i2c-* files\n",
|
||||
"/dev/i2c[-]* files\n",
|
||||
" for some things. You can use prog/mkdev/mkdev.sh to create these ",
|
||||
"/dev files\n",
|
||||
" if you do not have them already.\n";
|
||||
@@ -2097,7 +2100,7 @@ sub main
|
||||
"you edited\n",
|
||||
" `/etc/conf.modules' (or `/etc/modules.conf') for automatic ",
|
||||
"loading of\n",
|
||||
" this module. If not, you won't be able to open any /dev/i2c-* ",
|
||||
" this module. If not, you won't be able to open any /dev/i2c[-]* ",
|
||||
"file.\n";
|
||||
} else {
|
||||
print " i2c-dev is not loaded. Do you want to load it now? (YES/no): ";
|
||||
@@ -2106,7 +2109,7 @@ sub main
|
||||
"`/etc/conf.modules'\n",
|
||||
" (or `/etc/modules.conf') for automatic loading of this ",
|
||||
"module. If not,\n",
|
||||
" you won't be able to open any /dev/i2c-* file (unless you",
|
||||
" you won't be able to open any /dev/i2c[-]* file (unless you",
|
||||
"have it built-in\n",
|
||||
" into your kernel)\n";
|
||||
} elsif (system "modprobe","i2c-dev") {
|
||||
|
||||
+15
-6
@@ -46,7 +46,9 @@ int main(int argc, char *argv[])
|
||||
char *end;
|
||||
int i,j,res,i2cbus,address,size,file;
|
||||
int bank = 0, bankreg = 0x4E;
|
||||
char filename[20];
|
||||
char filename1[20];
|
||||
char filename2[20];
|
||||
char *filename;
|
||||
|
||||
|
||||
if (argc < 2) {
|
||||
@@ -123,11 +125,18 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
sprintf(filename,"/dev/i2c-%d",i2cbus);
|
||||
if ((file = open(filename,O_RDWR)) < 0) {
|
||||
fprintf(stderr,"Error: Could not open file `%s': %s\n",filename,
|
||||
strerror(errno));
|
||||
exit(1);
|
||||
sprintf(filename1,"/dev/i2c-%d",i2cbus);
|
||||
sprintf(filename2,"/dev/i2c-%d",i2cbus);
|
||||
if ((file = open(filename1,O_RDWR)) < 0) {
|
||||
if ((file = open(filename1,O_RDWR)) < 0) {
|
||||
fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n",filename1,
|
||||
filename2,strerror(errno));
|
||||
exit(1);
|
||||
} else {
|
||||
filename = filename2;
|
||||
}
|
||||
} else {
|
||||
filename = filename1;
|
||||
}
|
||||
|
||||
/* use FORCE so that we can look at registers even when
|
||||
|
||||
Reference in new issue
Block a user