Changeset 18
- Timestamp:
- 11/28/98 02:40:37 (14 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 4 modified
-
kernel/i2c-proc.c (modified) (10 diffs)
-
kernel/include/sensors.h (modified) (1 diff)
-
src/i2c-proc.c (modified) (10 diffs)
-
src/sensors.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/i2c-proc.c
r17 r18 41 41 static void i2cproc_inc_use(struct i2c_client *client); 42 42 static void i2cproc_dec_use(struct i2c_client *client); 43 44 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 45 46 static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 47 int *eof , void *private); 48 49 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 50 43 static int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 44 int count); 45 46 /* To implement the dynamic /proc/bus/i2c-? files, we need our own 47 implementation of the read hook */ 48 static struct file_operations i2cproc_operations = { 49 NULL, 50 i2cproc_bus_read, 51 }; 52 53 static struct inode_operations i2cproc_inode_operations = { 54 &i2cproc_operations 55 }; 56 57 58 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 59 60 static int i2proc_bus_read(char *buf, char **start, off_t offset, int len, 61 int *eof , void *private); 62 ssize_t array_read(struct file * file, char * buf,size_t count, loff_t *ppos); 63 64 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 65 66 int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 67 int count); 51 68 static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 52 69 int unused); … … 89 106 /* This is a sorted list of all adapters that will have entries in /proc/bus */ 90 107 static struct i2c_adapter *i2cproc_adapters[I2C_ADAP_MAX]; 108 109 /* Inodes of /dev/bus/i2c-? files */ 110 static int i2cproc_inodes[I2C_ADAP_MAX]; 91 111 92 112 /* We will use a nasty trick: we register a driver, that will be notified … … 208 228 } 209 229 230 /* This function generates the output for /proc/bus/i2c */ 210 231 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 211 232 int read_bus_i2c(char *buf, char **start, off_t offset, int len, int *eof, … … 219 240 for (i = 0; i < I2C_ADAP_MAX; i++) 220 241 if (i2cproc_adapters[i]) 221 len += sprintf(buf, " /dev/i2c-%d\t%s\t%-32s\t%-32s\n",i,242 len += sprintf(buf, "i2c-%d\t%s\t%-32s\t%-32s\n",i, 222 243 i2c_is_smbus_adapter(i2cproc_adapters[i])?"smbus": 223 244 #ifdef DEBUG … … 230 251 } 231 252 232 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 233 int read_bus_i2c_file(char *buf, char **start, off_t offset, int len, 234 int *eof, void *private) 235 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 236 int read_bus_i2c_file(char *buf, char **start, off_t offset, int len, 237 int unused) 238 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ 239 { 240 len = 0; 241 return len; 253 /* This function generates the output for /proc/bus/i2c-? */ 254 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 255 ssize_t i2cproc_read(struct file * file, char * buf,size_t count, loff_t *ppos) 256 { 257 struct inode * inode = file->f_dentry->d_inode; 258 #else (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) 259 int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 260 int count) 261 { 262 #endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 263 char *kbuf; 264 struct i2c_client *client; 265 int i,j,len=0; 266 267 if (count < 0) 268 return -EINVAL; 269 if (count > 4000) 270 count = 4000; 271 for (i = 0; i < I2C_ADAP_MAX; i++) 272 if (i2cproc_inodes[i] == inode->i_ino) { 273 if (! (kbuf = kmalloc(count,GFP_KERNEL))) 274 return -ENOMEM; 275 for (j = 0; j < I2C_CLIENT_MAX; j++) 276 if ((client = i2cproc_adapters[i]->clients[j])) 277 /* Filter out dummy clients */ 278 #ifndef DEBUG 279 if (client->driver->id != I2C_DRIVERID_I2CPROC) 280 #endif /* ndef DEBUG */ 281 len += sprintf(kbuf+len,"%x\t%-32s\t%-32s\n", 282 #ifdef DEBUG 283 i2c_is_isa_client(client)? 284 ((struct isa_client *) client)->isa_addr&0xffffff: 285 #endif /* def DEBUG */ 286 client->addr, 287 client->name,client->driver->name); 288 if (file->f_pos+len > count) 289 len = count - file->f_pos; 290 len = len - file->f_pos; 291 if (len < 0) 292 len = 0; 293 memcpy_tofs(buf,kbuf+file->f_pos,len); 294 file->f_pos += len; 295 kfree(kbuf); 296 return len; 297 } 298 return -ENOENT; 242 299 } 243 300 … … 266 323 } 267 324 325 #ifndef DEBUG 268 326 if (! (client = kmalloc(sizeof(struct i2c_client),GFP_KERNEL))) { 327 #else /* def DEBUG */ 328 if (! (client = kmalloc(sizeof(struct isa_client),GFP_KERNEL))) { 329 #endif 269 330 printk("i2c-proc.o: Out of memory!\n"); 270 331 return -ENOMEM; 271 332 } 272 333 memcpy(client,&i2cproc_client_template,sizeof(struct i2c_client)); 334 #ifdef DEBUG 335 ((struct isa_client *) client) -> isa_addr = -1; 336 #endif /* def DEBUG */ 273 337 client->adapter = adapter; 274 338 if ((res = i2c_attach_client(client))) { … … 289 353 return -ENOENT; 290 354 } 291 proc_entry-> read_proc = &read_bus_i2c_file;355 proc_entry->ops = &i2cproc_inode_operations; 292 356 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 293 357 if (!(proc_entry = kmalloc(sizeof(struct proc_dir_entry)+strlen(name)+1, … … 302 366 proc_entry->mode = S_IRUGO | S_IFREG; 303 367 proc_entry->nlink = 1; 304 proc_entry-> get_info = &read_bus_i2c_file;368 proc_entry->ops = &i2cproc_inode_operations; 305 369 strcpy((char *) proc_entry->name,name); 306 370 … … 313 377 314 378 i2cproc_proc_entries[i] = proc_entry; 379 i2cproc_inodes[i] = proc_entry->low_ino; 315 380 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ 316 381 return 0; … … 355 420 } 356 421 i2cproc_adapters[i] = NULL; 422 i2cproc_inodes[i] = 0; 357 423 kfree(client); 358 424 return 0; -
lm-sensors/trunk/kernel/include/sensors.h
r16 r18 22 22 23 23 /* Driver IDs */ 24 #define I2C_DRIVERID_ LM78 225 #define I2C_DRIVERID_ I2CPROC 124 #define I2C_DRIVERID_I2CPROC 1001 25 #define I2C_DRIVERID_LM78 1002 26 26 27 27 #endif /* def SENSORS_SENSORS_H */ -
lm-sensors/trunk/src/i2c-proc.c
r17 r18 41 41 static void i2cproc_inc_use(struct i2c_client *client); 42 42 static void i2cproc_dec_use(struct i2c_client *client); 43 44 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 45 46 static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 47 int *eof , void *private); 48 49 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 50 43 static int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 44 int count); 45 46 /* To implement the dynamic /proc/bus/i2c-? files, we need our own 47 implementation of the read hook */ 48 static struct file_operations i2cproc_operations = { 49 NULL, 50 i2cproc_bus_read, 51 }; 52 53 static struct inode_operations i2cproc_inode_operations = { 54 &i2cproc_operations 55 }; 56 57 58 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 59 60 static int i2proc_bus_read(char *buf, char **start, off_t offset, int len, 61 int *eof , void *private); 62 ssize_t array_read(struct file * file, char * buf,size_t count, loff_t *ppos); 63 64 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 65 66 int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 67 int count); 51 68 static int read_bus_i2c(char *buf, char **start, off_t offset, int len, 52 69 int unused); … … 89 106 /* This is a sorted list of all adapters that will have entries in /proc/bus */ 90 107 static struct i2c_adapter *i2cproc_adapters[I2C_ADAP_MAX]; 108 109 /* Inodes of /dev/bus/i2c-? files */ 110 static int i2cproc_inodes[I2C_ADAP_MAX]; 91 111 92 112 /* We will use a nasty trick: we register a driver, that will be notified … … 208 228 } 209 229 230 /* This function generates the output for /proc/bus/i2c */ 210 231 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 211 232 int read_bus_i2c(char *buf, char **start, off_t offset, int len, int *eof, … … 219 240 for (i = 0; i < I2C_ADAP_MAX; i++) 220 241 if (i2cproc_adapters[i]) 221 len += sprintf(buf, " /dev/i2c-%d\t%s\t%-32s\t%-32s\n",i,242 len += sprintf(buf, "i2c-%d\t%s\t%-32s\t%-32s\n",i, 222 243 i2c_is_smbus_adapter(i2cproc_adapters[i])?"smbus": 223 244 #ifdef DEBUG … … 230 251 } 231 252 232 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 233 int read_bus_i2c_file(char *buf, char **start, off_t offset, int len, 234 int *eof, void *private) 235 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 236 int read_bus_i2c_file(char *buf, char **start, off_t offset, int len, 237 int unused) 238 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ 239 { 240 len = 0; 241 return len; 253 /* This function generates the output for /proc/bus/i2c-? */ 254 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 255 ssize_t i2cproc_read(struct file * file, char * buf,size_t count, loff_t *ppos) 256 { 257 struct inode * inode = file->f_dentry->d_inode; 258 #else (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) 259 int i2cproc_bus_read(struct inode * inode, struct file * file,char * buf, 260 int count) 261 { 262 #endif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) 263 char *kbuf; 264 struct i2c_client *client; 265 int i,j,len=0; 266 267 if (count < 0) 268 return -EINVAL; 269 if (count > 4000) 270 count = 4000; 271 for (i = 0; i < I2C_ADAP_MAX; i++) 272 if (i2cproc_inodes[i] == inode->i_ino) { 273 if (! (kbuf = kmalloc(count,GFP_KERNEL))) 274 return -ENOMEM; 275 for (j = 0; j < I2C_CLIENT_MAX; j++) 276 if ((client = i2cproc_adapters[i]->clients[j])) 277 /* Filter out dummy clients */ 278 #ifndef DEBUG 279 if (client->driver->id != I2C_DRIVERID_I2CPROC) 280 #endif /* ndef DEBUG */ 281 len += sprintf(kbuf+len,"%x\t%-32s\t%-32s\n", 282 #ifdef DEBUG 283 i2c_is_isa_client(client)? 284 ((struct isa_client *) client)->isa_addr&0xffffff: 285 #endif /* def DEBUG */ 286 client->addr, 287 client->name,client->driver->name); 288 if (file->f_pos+len > count) 289 len = count - file->f_pos; 290 len = len - file->f_pos; 291 if (len < 0) 292 len = 0; 293 memcpy_tofs(buf,kbuf+file->f_pos,len); 294 file->f_pos += len; 295 kfree(kbuf); 296 return len; 297 } 298 return -ENOENT; 242 299 } 243 300 … … 266 323 } 267 324 325 #ifndef DEBUG 268 326 if (! (client = kmalloc(sizeof(struct i2c_client),GFP_KERNEL))) { 327 #else /* def DEBUG */ 328 if (! (client = kmalloc(sizeof(struct isa_client),GFP_KERNEL))) { 329 #endif 269 330 printk("i2c-proc.o: Out of memory!\n"); 270 331 return -ENOMEM; 271 332 } 272 333 memcpy(client,&i2cproc_client_template,sizeof(struct i2c_client)); 334 #ifdef DEBUG 335 ((struct isa_client *) client) -> isa_addr = -1; 336 #endif /* def DEBUG */ 273 337 client->adapter = adapter; 274 338 if ((res = i2c_attach_client(client))) { … … 289 353 return -ENOENT; 290 354 } 291 proc_entry-> read_proc = &read_bus_i2c_file;355 proc_entry->ops = &i2cproc_inode_operations; 292 356 #else /* (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,29)) */ 293 357 if (!(proc_entry = kmalloc(sizeof(struct proc_dir_entry)+strlen(name)+1, … … 302 366 proc_entry->mode = S_IRUGO | S_IFREG; 303 367 proc_entry->nlink = 1; 304 proc_entry-> get_info = &read_bus_i2c_file;368 proc_entry->ops = &i2cproc_inode_operations; 305 369 strcpy((char *) proc_entry->name,name); 306 370 … … 313 377 314 378 i2cproc_proc_entries[i] = proc_entry; 379 i2cproc_inodes[i] = proc_entry->low_ino; 315 380 #endif /* (LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,29)) */ 316 381 return 0; … … 355 420 } 356 421 i2cproc_adapters[i] = NULL; 422 i2cproc_inodes[i] = 0; 357 423 kfree(client); 358 424 return 0; -
lm-sensors/trunk/src/sensors.h
r16 r18 22 22 23 23 /* Driver IDs */ 24 #define I2C_DRIVERID_ LM78 225 #define I2C_DRIVERID_ I2CPROC 124 #define I2C_DRIVERID_I2CPROC 1001 25 #define I2C_DRIVERID_LM78 1002 26 26 27 27 #endif /* def SENSORS_SENSORS_H */
