Changeset 1053
- Timestamp:
- 03/31/01 21:00:45 (11 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 3 modified
-
CHANGES (modified) (1 diff)
-
prog/detect/i2cdetect.c (modified) (3 diffs)
-
prog/dump/i2cdump.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/CHANGES
r1050 r1053 45 45 Module w83781d: Don't reinitialize as99127f chip; this may cause fan/temp 46 46 reading changes 47 Programs i2cdetect, i2cdump: add devfs /dev/i2c/x support 47 48 Program mkpatch.pl: Fix adm9240 typos, add more chips to Configure.help, 48 49 remove ltc1710 -
lm-sensors/trunk/prog/detect/i2cdetect.c
r847 r1053 2 2 i2cdetect.c - Part of i2cdetect, a user-space program to scan for I2C 3 3 devices. 4 Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl> 4 Copyright (c) 1999-2001 Frodo Looijaard <frodol@dds.nl> and 5 Mark D. Studebaker <mdsxyz123@yahoo.com> 5 6 6 7 This program is free software; you can redistribute it and/or modify … … 46 47 char *end; 47 48 int i,j,res,i2cbus,file; 48 int e1, e2 ;49 int e1, e2, e3; 49 50 char filename1[20]; 50 51 char filename2[20]; 52 char filename3[20]; 51 53 char *filename; 52 54 long funcs; … … 70 72 } 71 73 74 /* 75 * Try all three variants and give the correct error message 76 * upon failure 77 */ 78 72 79 sprintf(filename1,"/dev/i2c-%d",i2cbus); 73 80 sprintf(filename2,"/dev/i2c%d",i2cbus); 81 sprintf(filename3,"/dev/i2c/%d",i2cbus); 74 82 if ((file = open(filename1,O_RDWR)) < 0) { 75 83 e1 = errno; 76 84 if ((file = open(filename2,O_RDWR)) < 0) { 77 85 e2 = errno; 78 if(e1 == ENOENT && e2 == ENOENT) { 79 fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n", 80 filename1,filename2,strerror(ENOENT)); 86 if ((file = open(filename3,O_RDWR)) < 0) { 87 e3 = errno; 88 if(e1 == ENOENT && e2 == ENOENT && e3 == ENOENT) { 89 fprintf(stderr,"Error: Could not open file `%s', `%s', or `%s': %s\n", 90 filename1,filename2,filename3,strerror(ENOENT)); 91 } 92 if (e1 != ENOENT) { 93 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 94 filename1,strerror(e1)); 95 if(e1 == EACCES) 96 fprintf(stderr,"Run as root?\n"); 97 } 98 if (e2 != ENOENT) { 99 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 100 filename2,strerror(e2)); 101 if(e2 == EACCES) 102 fprintf(stderr,"Run as root?\n"); 103 } 104 if (e3 != ENOENT) { 105 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 106 filename3,strerror(e3)); 107 if(e3 == EACCES) 108 fprintf(stderr,"Run as root?\n"); 109 } 110 exit(1); 111 } else { 112 filename = filename3; 81 113 } 82 if (e1 != ENOENT) {83 fprintf(stderr,"Error: Could not open file `%s' : %s\n",84 filename1,strerror(e1));85 if(e1 == EACCES)86 fprintf(stderr,"Run as root?\n");87 }88 if (e2 != ENOENT) {89 fprintf(stderr,"Error: Could not open file `%s' : %s\n",90 filename2,strerror(e2));91 if(e2 == EACCES)92 fprintf(stderr,"Run as root?\n");93 }94 exit(1);95 114 } else { 96 115 filename = filename2; -
lm-sensors/trunk/prog/dump/i2cdump.c
r1049 r1053 47 47 char *end; 48 48 int i,j,res,i2cbus,address,size,file; 49 int e1, e2 ;49 int e1, e2, e3; 50 50 int bank = 0, bankreg = 0x4E; 51 51 char filename1[20]; 52 52 char filename2[20]; 53 char filename3[20]; 53 54 char *filename; 54 55 long funcs; … … 134 135 } 135 136 137 /* 138 * Try all three variants and give the correct error message 139 * upon failure 140 */ 141 136 142 sprintf(filename1,"/dev/i2c-%d",i2cbus); 137 143 sprintf(filename2,"/dev/i2c%d",i2cbus); 144 sprintf(filename3,"/dev/i2c/%d",i2cbus); 138 145 if ((file = open(filename1,O_RDWR)) < 0) { 139 146 e1 = errno; 140 147 if ((file = open(filename2,O_RDWR)) < 0) { 141 148 e2 = errno; 142 if(e1 == ENOENT && e2 == ENOENT) { 143 fprintf(stderr,"Error: Could not open file `%s' or `%s': %s\n", 144 filename1,filename2,strerror(ENOENT)); 145 } 146 if (e1 != ENOENT) { 147 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 148 filename1,strerror(e1)); 149 if(e1 == EACCES) 150 fprintf(stderr,"Run as root?\n"); 151 } 152 if (e2 != ENOENT) { 153 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 154 filename2,strerror(e2)); 155 if(e2 == EACCES) 156 fprintf(stderr,"Run as root?\n"); 157 } 158 exit(1); 149 if ((file = open(filename3,O_RDWR)) < 0) { 150 e3 = errno; 151 if(e1 == ENOENT && e2 == ENOENT && e3 == ENOENT) { 152 fprintf(stderr,"Error: Could not open file `%s', `%s', or `%s': %s\n", 153 filename1,filename2,filename3,strerror(ENOENT)); 154 } 155 if (e1 != ENOENT) { 156 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 157 filename1,strerror(e1)); 158 if(e1 == EACCES) 159 fprintf(stderr,"Run as root?\n"); 160 } 161 if (e2 != ENOENT) { 162 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 163 filename2,strerror(e2)); 164 if(e2 == EACCES) 165 fprintf(stderr,"Run as root?\n"); 166 } 167 if (e3 != ENOENT) { 168 fprintf(stderr,"Error: Could not open file `%s' : %s\n", 169 filename3,strerror(e3)); 170 if(e3 == EACCES) 171 fprintf(stderr,"Run as root?\n"); 172 } 173 exit(1); 174 } else { 175 filename = filename3; 176 } 159 177 } else { 160 filename = filename2;178 filename = filename2; 161 179 } 162 180 } else {
