Changeset 3417
- Timestamp:
- 12/08/99 21:33:58 (9 years ago)
- Files:
-
- i2c/trunk/doc/writing-clients (modified) (1 diff)
- i2c/trunk/kernel/i2c-core.c (modified) (4 diffs)
- i2c/trunk/kernel/i2c-dev.c (modified) (1 diff)
- i2c/trunk/kernel/i2c.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c/trunk/doc/writing-clients
r3412 r3417 357 357 The i2c_probe or sensors_detect function will call the foo_detect_client 358 358 function only for those i2c addresses that actually have a device on 359 them (unless a `force' parameter was used). 359 them (unless a `force' parameter was used). In addition, addresses that 360 are already in use (by some other registered client) are skipped. 360 361 361 362 i2c/trunk/kernel/i2c-core.c
r3411 r3417 452 452 } 453 453 454 int i2c_check_addr (struct i2c_adapter *adapter, int addr) 455 { 456 int i; 457 for (i = 0; i < I2C_CLIENT_MAX ; i++) 458 if (adapter->clients[i] && (adapter->clients[i]->addr == addr)) 459 return -EBUSY; 460 return 0; 461 } 454 462 455 463 int i2c_attach_client(struct i2c_client *client) … … 457 465 struct i2c_adapter *adapter = client->adapter; 458 466 int i; 467 468 if (i2c_check_addr(client->adapter,client->addr)) 469 return -EBUSY; 459 470 460 471 for (i = 0; i < I2C_CLIENT_MAX; i++) … … 855 866 addr <= 0x7f; 856 867 addr++) { 868 869 /* Skip if already in use */ 870 if (i2c_check_addr(adapter,addr)) 871 continue; 857 872 858 873 /* If it is in one of the force entries, we don't do any detection … … 1312 1327 EXPORT_SYMBOL(i2c_inc_use_client); 1313 1328 EXPORT_SYMBOL(i2c_dec_use_client); 1329 EXPORT_SYMBOL(i2c_check_addr); 1314 1330 1315 1331 i2c/trunk/kernel/i2c-dev.c
r3406 r3417 278 278 switch ( cmd ) { 279 279 case I2C_SLAVE: 280 case I2C_SLAVE_FORCE: 280 281 if ((arg > 0x3ff) || (((client->flags & I2C_M_TEN) == 0) && arg > 0x7f)) 281 282 return -EINVAL; 283 if ((cmd == I2C_SLAVE) && i2c_check_addr(client->adapter,arg)) 284 return -EBUSY; 282 285 client->addr = arg; 283 286 return 0; i2c/trunk/kernel/i2c.h
r3408 r3417 325 325 extern void i2c_dec_use_client(struct i2c_client *); 326 326 327 /* returns -EBUSY if address has been taken, 0 if not. Note that the only 328 other place at which this is called is within i2c_attach_client; so 329 you can cheat by simply not registering. Not recommended, of course! */ 330 extern int i2c_check_addr (struct i2c_adapter *adapter, int addr); 327 331 328 332 /* Detect function. It itterates over all possible addresses itself. … … 428 432 #define I2C_SLAVE 0x0703 /* Change slave address */ 429 433 /* Attn.: Slave address is 7 or 10 bits */ 434 #define I2C_SLAVE_FORCE 0x0706 /* Change slave address */ 435 /* Attn.: Slave address is 7 or 10 bits */ 436 /* This changes the address, even if it */ 437 /* is already taken! */ 430 438 #define I2C_TENBIT 0x0704 /* 0 for 7 bit addrs, != 0 for 10 bit */ 431 439
