Changeset 3434
- Timestamp:
- 01/19/00 00:54:07 (9 years ago)
- Files:
-
- i2c/trunk/kernel/i2c-algo-bit.c (modified) (6 diffs)
- i2c/trunk/kernel/i2c-algo-pcf.c (modified) (14 diffs)
- i2c/trunk/kernel/i2c-core.c (modified) (35 diffs)
- i2c/trunk/kernel/i2c-dev.c (modified) (8 diffs)
- i2c/trunk/kernel/i2c-dev.h (modified) (7 diffs)
- i2c/trunk/kernel/i2c-elektor.c (modified) (9 diffs)
- i2c/trunk/kernel/i2c-elektor.h (modified) (1 diff)
- i2c/trunk/kernel/i2c-elv.c (modified) (8 diffs)
- i2c/trunk/kernel/i2c-id.h (modified) (5 diffs)
- i2c/trunk/kernel/i2c-pcf8584.h (modified) (3 diffs)
- i2c/trunk/kernel/i2c-philips-par.c (modified) (2 diffs)
- i2c/trunk/kernel/i2c-velleman.c (modified) (1 diff)
- i2c/trunk/kernel/i2c.h (modified) (11 diffs)
- i2c/trunk/mkpatch/Config.in (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
i2c/trunk/kernel/i2c-algo-bit.c
r3433 r3434 76 76 static inline void sdalo(struct i2c_algo_bit_data *adap) 77 77 { 78 setsda(adap,0);79 udelay(adap->udelay);78 setsda(adap,0); 79 udelay(adap->udelay); 80 80 } 81 81 82 82 static inline void sdahi(struct i2c_algo_bit_data *adap) 83 83 { 84 setsda(adap,1);85 udelay(adap->udelay);84 setsda(adap,1); 85 udelay(adap->udelay); 86 86 } 87 87 88 88 static inline void scllo(struct i2c_algo_bit_data *adap) 89 89 { 90 setscl(adap,0);91 udelay(adap->udelay);90 setscl(adap,0); 91 udelay(adap->udelay); 92 92 #ifdef SLO_IO 93 SLO_IO93 SLO_IO 94 94 #endif 95 95 } … … 230 230 indata *= 2; 231 231 if ( getsda(adap) ) 232 indata |= 0x01;232 indata |= 0x01; 233 233 scllo(adap); 234 234 } … … 518 518 { 519 519 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | 520 I2C_FUNC_PROTOCOL_MANGLING;520 I2C_FUNC_PROTOCOL_MANGLING; 521 521 } 522 522 … … 532 532 NULL, /* slave_recv */ 533 533 algo_control, /* ioctl */ 534 bit_func, /* functionality*/534 bit_func, /* functionality */ 535 535 }; 536 536 … … 541 541 { 542 542 int i; 543 struct i2c_algo_bit_data *bit_adap = adap->algo_data;543 struct i2c_algo_bit_data *bit_adap = adap->algo_data; 544 544 545 545 if (bit_test) { … … 561 561 /* scan bus */ 562 562 if (bit_scan) { 563 int ack;563 int ack; 564 564 printk(KERN_INFO " i2c-algo-bit.o: scanning bus %s.\n", adap->name); 565 565 for (i = 0x00; i < 0xff; i+=2) { i2c/trunk/kernel/i2c-algo-pcf.c
r3433 r3434 85 85 static void i2c_start(struct i2c_algo_pcf_data *adap) 86 86 { 87 DEBPROTO(printk("S "));88 set_pcf(adap, 1, I2C_PCF_START);87 DEBPROTO(printk("S ")); 88 set_pcf(adap, 1, I2C_PCF_START); 89 89 } 90 90 91 91 static void i2c_repstart(struct i2c_algo_pcf_data *adap) 92 92 { 93 DEBPROTO(printk(" Sr "));94 set_pcf(adap, 1, I2C_PCF_REPSTART);93 DEBPROTO(printk(" Sr ")); 94 set_pcf(adap, 1, I2C_PCF_REPSTART); 95 95 } 96 96 … … 98 98 static void i2c_stop(struct i2c_algo_pcf_data *adap) 99 99 { 100 DEBPROTO(printk("P\n"));101 set_pcf(adap, 1, I2C_PCF_STOP);100 DEBPROTO(printk("P\n")); 101 set_pcf(adap, 1, I2C_PCF_STOP); 102 102 } 103 103 … … 105 105 static int wait_for_bb(struct i2c_algo_pcf_data *adap) { 106 106 107 int timeout = DEF_TIMEOUT;108 int status;109 110 status = get_pcf(adap, 1);111 while (timeout-- && !(status & I2C_PCF_BB)) {112 udelay(1000); /* How much is this? */113 status = get_pcf(adap, 1);114 }115 if (timeout<=0)116 printk("Timeout waiting for Bus Busy\n");117 /*118 set_pcf(adap, 1, I2C_PCF_STOP);119 */120 return(timeout<=0);107 int timeout = DEF_TIMEOUT; 108 int status; 109 110 status = get_pcf(adap, 1); 111 while (timeout-- && !(status & I2C_PCF_BB)) { 112 udelay(1000); /* How much is this? */ 113 status = get_pcf(adap, 1); 114 } 115 if (timeout<=0) 116 printk("Timeout waiting for Bus Busy\n"); 117 /* 118 set_pcf(adap, 1, I2C_PCF_STOP); 119 */ 120 return(timeout<=0); 121 121 } 122 122 … … 130 130 static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status) { 131 131 132 int timeout = DEF_TIMEOUT;133 134 *status = get_pcf(adap, 1);135 while (timeout-- && (*status & I2C_PCF_PIN)) {136 adap->waitforpin();137 *status = get_pcf(adap, 1);138 }139 if (timeout <= 0)140 return(-1);141 else142 return(0);132 int timeout = DEF_TIMEOUT; 133 134 *status = get_pcf(adap, 1); 135 while (timeout-- && (*status & I2C_PCF_PIN)) { 136 adap->waitforpin(); 137 *status = get_pcf(adap, 1); 138 } 139 if (timeout <= 0) 140 return(-1); 141 else 142 return(0); 143 143 } 144 144 … … 258 258 unsigned char addr, int retries) 259 259 { 260 int i, status, ret = -1;261 for (i=0;i<retries;i++) {262 i2c_outb(adap, addr);263 i2c_start(adap);264 status = get_pcf(adap, 1);265 if (wait_for_pin(adap, &status) >= 0) {266 if ((status && I2C_PCF_LRB) == 0) {267 i2c_stop(adap);268 break; /* success! */269 }270 }271 i2c_stop(adap);272 udelay(adap->udelay);273 }274 DEB2(if (i) printk("i2c-algo-pcf.o: needed %d retries for %d\n",i,addr));275 return ret;260 int i, status, ret = -1; 261 for (i=0;i<retries;i++) { 262 i2c_outb(adap, addr); 263 i2c_start(adap); 264 status = get_pcf(adap, 1); 265 if (wait_for_pin(adap, &status) >= 0) { 266 if ((status && I2C_PCF_LRB) == 0) { 267 i2c_stop(adap); 268 break; /* success! */ 269 } 270 } 271 i2c_stop(adap); 272 udelay(adap->udelay); 273 } 274 DEB2(if (i) printk("i2c-algo-pcf.o: needed %d retries for %d\n",i,addr)); 275 return ret; 276 276 } 277 277 … … 279 279 static int pcf_sendbytes(struct i2c_adapter *i2c_adap,const char *buf, int count) 280 280 { 281 struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;282 int wrcount, status, timeout;283 284 for (wrcount=0; wrcount<count; ++wrcount) {285 DEB2(printk("i2c-algo-pcf.o: %s i2c_write: writing %2.2X\n",286 i2c_adap->name, buf[wrcount]&0xff));287 i2c_outb(adap, buf[wrcount]);288 timeout = wait_for_pin(adap, &status);289 if (timeout) {290 printk("i2c-algo-pcf.o: %s i2c_write: error - timeout.\n",291 i2c_adap->name);292 i2c_stop(adap);293 return -EREMOTEIO; /* got a better one ?? */294 }295 if (status & I2C_PCF_LRB) {296 printk("i2c-algo-pcf.o: %s i2c_write: error - no ack.\n",297 i2c_adap->name);298 i2c_stop(adap);299 return -EREMOTEIO; /* got a better one ?? */300 }301 }302 return (wrcount);281 struct i2c_algo_pcf_data *adap = i2c_adap->algo_data; 282 int wrcount, status, timeout; 283 284 for (wrcount=0; wrcount<count; ++wrcount) { 285 DEB2(printk("i2c-algo-pcf.o: %s i2c_write: writing %2.2X\n", 286 i2c_adap->name, buf[wrcount]&0xff)); 287 i2c_outb(adap, buf[wrcount]); 288 timeout = wait_for_pin(adap, &status); 289 if (timeout) { 290 printk("i2c-algo-pcf.o: %s i2c_write: error - timeout.\n", 291 i2c_adap->name); 292 i2c_stop(adap); 293 return -EREMOTEIO; /* got a better one ?? */ 294 } 295 if (status & I2C_PCF_LRB) { 296 printk("i2c-algo-pcf.o: %s i2c_write: error - no ack.\n", 297 i2c_adap->name); 298 i2c_stop(adap); 299 return -EREMOTEIO; /* got a better one ?? */ 300 } 301 } 302 return (wrcount); 303 303 } 304 304 … … 306 306 static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count) 307 307 { 308 int rdcount=0, i, status, timeout, dummy=1;309 struct i2c_algo_pcf_data *adap = i2c_adap->algo_data;308 int rdcount=0, i, status, timeout, dummy=1; 309 struct i2c_algo_pcf_data *adap = i2c_adap->algo_data; 310 310 311 for (i=0; i<count-1; ++i) { 312 buf[rdcount] = i2c_inb(adap); 313 if (dummy) { 314 dummy = 0; 315 } 316 else 317 rdcount++; 318 timeout = wait_for_pin(adap, &status); 319 if (timeout) { 320 printk("i2c-algo-pcf.o: i2c_read: i2c_inb timed out.\n"); 321 return (-1); 322 } 323 if (status & I2C_PCF_LRB) { 324 printk("i2c-algo-pcf.o: i2c_read: i2c_inb, No ack.\n"); 325 return (-1); 326 } 327 } 328 set_pcf(adap, 1, I2C_PCF_ESO); 329 buf[rdcount] = i2c_inb(adap); 330 if (dummy) { 331 dummy = 0; 332 } 333 else 334 rdcount++; 335 timeout = wait_for_pin(adap, &status); 336 if (timeout) { 337 printk("i2c-algo-pcf.o: i2c_read: i2c_inb timed out.\n"); 338 return (-1); 339 } 340 return (rdcount); 311 for (i=0; i<count-1; ++i) { 312 buf[rdcount] = i2c_inb(adap); 313 if (dummy) { 314 dummy = 0; 315 } else 316 rdcount++; 317 timeout = wait_for_pin(adap, &status); 318 if (timeout) { 319 printk("i2c-algo-pcf.o: i2c_read: i2c_inb timed out.\n"); 320 return (-1); 321 } 322 if (status & I2C_PCF_LRB) { 323 printk("i2c-algo-pcf.o: i2c_read: i2c_inb, No ack.\n"); 324 return (-1); 325 } 326 } 327 set_pcf(adap, 1, I2C_PCF_ESO); 328 buf[rdcount] = i2c_inb(adap); 329 if (dummy) { 330 dummy = 0; 331 } else 332 rdcount++; 333 timeout = wait_for_pin(adap, &status); 334 if (timeout) { 335 printk("i2c-algo-pcf.o: i2c_read: i2c_inb timed out.\n"); 336 return (-1); 337 } 338 return (rdcount); 341 339 } 342 340 … … 350 348 if ( (flags & I2C_M_TEN) ) { 351 349 /* a ten bit address */ 352 addr = 0xf0 | (( msg->addr >> 7) & 0x03);350 addr = 0xf0 | (( msg->addr >> 7) & 0x03); 353 351 DEB2(printk("addr0: %d\n",addr)); 354 352 /* try extended address code...*/ … … 377 375 } else { /* normal 7bit address */ 378 376 addr = ( msg->addr << 1 ); 379 if (flags & I2C_M_RD )380 addr |= 1;377 if (flags & I2C_M_RD ) 378 addr |= 1; 381 379 if (flags & I2C_M_REV_DIR_ADDR ) 382 380 addr ^= 1; … … 404 402 pmsg = &msgs[i]; 405 403 if (!(pmsg->flags & I2C_M_NOSTART)) { 406 if (i) {404 if (i) 407 405 i2c_repstart(adap); 408 }409 406 ret = pcf_doAddress(adap, pmsg, i2c_adap->retries); 410 407 timeout = wait_for_pin(adap, &status); 411 408 if (timeout) { 412 DEB2(printk("i2c-algo-pcf.o: Timeout waiting for PIN(1) in pcf_xfer\n");)413 return (-EREMOTEIO);409 DEB2(printk("i2c-algo-pcf.o: Timeout waiting for PIN(1) in pcf_xfer\n");) 410 return (-EREMOTEIO); 414 411 } 415 412 if (status & I2C_PCF_LRB) { 416 i2c_stop(adap);417 DEB2(printk("i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");)418 return (-EREMOTEIO);413 i2c_stop(adap); 414 DEB2(printk("i2c-algo-pcf.o: No LRB(1) in pcf_xfer\n");) 415 return (-EREMOTEIO); 419 416 } 420 417 } 421 418 DEB3(printk("i2c-algo-pcf.o: Msg %d, addr=0x%x, flags=0x%x, len=%d\n", 422 i, msgs[i].addr, msgs[i].flags, msgs[i].len);)419 i, msgs[i].addr, msgs[i].flags, msgs[i].len);) 423 420 if (pmsg->flags & I2C_M_RD ) { 424 421 /* read bytes into buffer*/ … … 443 440 static u32 pcf_func(struct i2c_adapter *adap) 444 441 { 445 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |442 return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR | 446 443 I2C_FUNC_PROTOCOL_MANGLING; 447 444 } … … 457 454 NULL, /* slave_recv */ 458 455 algo_control, /* ioctl */ 459 pcf_func, /* functionality*/456 pcf_func, /* functionality */ 460 457 }; 461 458 … … 493 490 /* scan bus */ 494 491 if (pcf_scan) { 495 printk(KERN_INFO " i2c-algo-pcf.o: scanning bus %s.\n", adap->name);496 for (i = 0x00; i < 0xff; i+=2) {497 i2c_outb(pcf_adap, i);498 i2c_start(pcf_adap);499 if ((wait_for_pin(pcf_adap, &status) >= 0) &&500 ((status && I2C_PCF_LRB) == 0)) {501 printk("(%02x)",i>>1);502 } else {503 printk(".");504 }505 i2c_stop(pcf_adap);506 udelay(pcf_adap->udelay);507 }508 printk("\n");492 printk(KERN_INFO " i2c-algo-pcf.o: scanning bus %s.\n", adap->name); 493 for (i = 0x00; i < 0xff; i+=2) { 494 i2c_outb(pcf_adap, i); 495 i2c_start(pcf_adap); 496 if ((wait_for_pin(pcf_adap, &status) >= 0) && 497 ((status && I2C_PCF_LRB) == 0)) { 498 printk("(%02x)",i>>1); 499 } else { 500 printk("."); 501 } 502 i2c_stop(pcf_adap); 503 udelay(pcf_adap->udelay); 504 } 505 printk("\n"); 509 506 } 510 507 return 0; … … 525 522 int __init i2c_algo_pcf_init (void) 526 523 { 527 printk("i2c-algo-pcf.o: i2c pcf8584 algorithm module\n");524 printk("i2c-algo-pcf.o: i2c pcf8584 algorithm module\n"); 528 525 return 0; 529 526 } i2c/trunk/kernel/i2c-core.c
r3433 r3434 61 61 62 62 /**** lock for writing to global variables: the adapter & driver list */ 63 struct semaphore adap_lock; 64 struct semaphore driver_lock; 63 struct semaphore adap_lock; 64 struct semaphore driver_lock; 65 65 66 66 /**** adapter list */ … … 99 99 implementation of the read hook */ 100 100 static struct file_operations i2cproc_operations = { 101 NULL,102 i2cproc_bus_read,101 NULL, 102 i2cproc_bus_read, 103 103 }; 104 104 105 105 static struct inode_operations i2cproc_inode_operations = { 106 &i2cproc_operations106 &i2cproc_operations 107 107 }; 108 108 … … 117 117 118 118 119 /* --------------------------------------------------- 119 /* --------------------------------------------------- 120 120 * registering functions 121 121 * --------------------------------------------------- … … 162 162 if (! proc_entry) { 163 163 printk("i2c-core.o: Could not create /proc/bus/%s\n", 164 name);164 name); 165 165 return -ENOENT; 166 }166 } 167 167 proc_entry->ops = &i2cproc_inode_operations; 168 168 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) … … 230 230 ADAP_UNLOCK(); 231 231 DEB(printk("i2c-core.o: adapter unregistered: %s\n",adap->name)); 232 return 0; 232 return 0; 233 233 } 234 234 … … 304 304 /* Have a look at each adapter, if clients of this driver are still 305 305 * attached. If so, detach them to be able to kill the driver 306 * afterwards.306 * afterwards. 307 307 */ 308 308 DEB2(printk("i2c-core.o: unregister_driver - looking for clients.\n")); … … 339 339 int i2c_check_addr (struct i2c_adapter *adapter, int addr) 340 340 { 341 int i;342 for (i = 0; i < I2C_CLIENT_MAX ; i++)343 if (adapter->clients[i] && (adapter->clients[i]->addr == addr))344 return -EBUSY;345 return 0;341 int i; 342 for (i = 0; i < I2C_CLIENT_MAX ; i++) 343 if (adapter->clients[i] && (adapter->clients[i]->addr == addr)) 344 return -EBUSY; 345 return 0; 346 346 } 347 347 … … 351 351 int i; 352 352 353 if (i2c_check_addr(client->adapter,client->addr))354 return -EBUSY;353 if (i2c_check_addr(client->adapter,client->addr)) 354 return -EBUSY; 355 355 356 356 for (i = 0; i < I2C_CLIENT_MAX; i++) … … 399 399 400 400 DEB(printk("i2c-core.o: client [%s] unregistered.\n",client->name)); 401 return 0; 401 return 0; 402 402 } 403 403 … … 434 434 void monitor_bus_i2c(struct inode *inode, int fill) 435 435 { 436 if (fill)437 MOD_INC_USE_COUNT;438 else439 MOD_DEC_USE_COUNT;436 if (fill) 437 MOD_INC_USE_COUNT; 438 else 439 MOD_DEC_USE_COUNT; 440 440 } 441 441 #endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,37)) */ … … 452 452 nr += sprintf(buf+nr, "i2c-%d\t", i); 453 453 if (adapters[i]->algo->smbus_xfer) { 454 if (adapters[i]->algo->master_xfer)454 if (adapters[i]->algo->master_xfer) 455 455 nr += sprintf(buf+nr,"smbus/i2c"); 456 456 else … … 471 471 loff_t *ppos) 472 472 { 473 struct inode * inode = file->f_dentry->d_inode;474 char *kbuf;475 struct i2c_client *client;476 int i,j,len=0;477 478 if (count < 0)479 return -EINVAL;480 if (count > 4000)481 count = 4000;482 for (i = 0; i < I2C_ADAP_MAX; i++)483 if (adapters[i]->inode == inode->i_ino) {484 /* We need a bit of slack in the kernel buffer; this makes the485 sprintf safe. */486 if (! (kbuf = kmalloc(count + 80,GFP_KERNEL)))487 return -ENOMEM;488 for (j = 0; j < I2C_CLIENT_MAX; j++)489 if ((client = adapters[i]->clients[j]))490 /* Filter out dummy clients */491 if (client->driver->id != I2C_DRIVERID_I2CDEV)492 len += sprintf(kbuf+len,"%02x\t%-32s\t%-32s\n",493 client->addr,494 client->name,client->driver->name);495 if (file->f_pos+len > count)496 len = count - file->f_pos;497 len = len - file->f_pos;498 if (len < 0)499 len = 0;500 copy_to_user (buf,kbuf+file->f_pos,len);501 file->f_pos += len;502 kfree(kbuf);503 return len;504 }505 return -ENOENT;473 struct inode * inode = file->f_dentry->d_inode; 474 char *kbuf; 475 struct i2c_client *client; 476 int i,j,len=0; 477 478 if (count < 0) 479 return -EINVAL; 480 if (count > 4000) 481 count = 4000; 482 for (i = 0; i < I2C_ADAP_MAX; i++) 483 if (adapters[i]->inode == inode->i_ino) { 484 /* We need a bit of slack in the kernel buffer; this makes the 485 sprintf safe. */ 486 if (! (kbuf = kmalloc(count + 80,GFP_KERNEL))) 487 return -ENOMEM; 488 for (j = 0; j < I2C_CLIENT_MAX; j++) 489 if ((client = adapters[i]->clients[j])) 490 /* Filter out dummy clients */ 491 if (client->driver->id != I2C_DRIVERID_I2CDEV) 492 len += sprintf(kbuf+len,"%02x\t%-32s\t%-32s\n", 493 client->addr, 494 client->name,client->driver->name); 495 if (file->f_pos+len > count) 496 len = count - file->f_pos; 497 len = len - file->f_pos; 498 if (len < 0) 499 len = 0; 500 copy_to_user (buf,kbuf+file->f_pos,len); 501 file->f_pos += len; 502 kfree(kbuf); 503 return len; 504 } 505 return -ENOENT; 506 506 } 507 507 … … 547 547 #endif /* def CONFIG_PROC_FS */ 548 548 549 /* --------------------------------------------------- 549 /* --------------------------------------------------- 550 550 * dummy driver notification 551 551 * --------------------------------------------------- … … 556 556 int i; 557 557 for (i=0; i<I2C_DRIVER_MAX; i++) 558 if (drivers[i] && (drivers[i]->flags & I2C_DF_DUMMY))559 drivers[i]->attach_adapter(adap);558 if (drivers[i] && (drivers[i]->flags & I2C_DF_DUMMY)) 559 drivers[i]->attach_adapter(adap); 560 560 } 561 561 … … 564 564 int i; 565 565 for (i=0; i<I2C_DRIVER_MAX; i++) 566 if (drivers[i] && (drivers[i]->flags & I2C_DF_DUMMY))567 drivers[i]->detach_client(client);566 if (drivers[i] && (drivers[i]->flags & I2C_DF_DUMMY)) 567 drivers[i]->detach_client(client); 568 568 } 569 569 … … 588 588 } else { 589 589 printk("i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n", 590 adap->id);590 adap->id); 591 591 return -ENOSYS; 592 592 } … … 618 618 } else { 619 619 printk("i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n", 620 client->adapter->id);620 client->adapter->id); 621 621 return -ENOSYS; 622 622 } … … 651 651 } else { 652 652 printk("i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n", 653 client->adapter->id);653 client->adapter->id); 654 654 return -ENOSYS; 655 655 } … … 687 687 i2c_client_found_addr_proc *found_proc) 688 688 { 689 int addr,i,found,err; 690 int adap_id = i2c_adapter_id(adapter); 691 692 /* Forget it if we can't probe using SMBUS_QUICK */ 693 if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) 694 return -1; 695 696 for (addr = 0x00; 697 addr <= 0x7f; 698 addr++) { 699 700 /* Skip if already in use */ 701 if (i2c_check_addr(adapter,addr)) 702 continue; 703 704 /* If it is in one of the force entries, we don't do any detection 705 at all */ 706 found = 0; 707 708 for (i = 0; 709 !found && (address_data->force[i] != I2C_CLIENT_END); 710 i += 3) { 711 if (((adap_id == address_data->force[i]) || 712 (address_data->force[i] == ANY_I2C_BUS)) && 713 (addr == address_data->force[i+1])) { 714 DEB2(printk("i2c-core.o: found force parameter for adapter %d, addr %04x\n", 715 adap_id,addr)); 716 if ((err = found_proc(adapter,addr,0,0))) 717 return err; 718 found = 1; 719 } 720 } 721 if (found) 722 continue; 723 724 /* If this address is in one of the ignores, we can forget about it 725 right now */ 726 for (i = 0; 727 !found && (address_data->ignore[i] != I2C_CLIENT_END); 728 i += 2) { 729 if (((adap_id == address_data->ignore[i]) || 730 ((address_data->ignore[i] == ANY_I2C_BUS))) && 731 (addr == address_data->ignore[i+1])) { 732 DEB2(printk("i2c-core.o: found ignore parameter for adapter %d, " 733 "addr %04x\n", adap_id ,addr)); 734 found = 1; 735 } 736 } 737 for (i = 0; 738 !found && (address_data->ignore_range[i] != I2C_CLIENT_END); 739 i += 3) { 740 if (((adap_id == address_data->ignore_range[i]) || 741 ((address_data->ignore_range[i]==ANY_I2C_BUS))) && 742 (addr >= address_data->ignore_range[i+1]) && 743 (addr <= address_data->ignore_range[i+2])) { 744 DEB2(printk("i2c-core.o: found ignore_range parameter for adapter %d, " 745 "addr %04x\n", adap_id,addr)); 746 found = 1; 747 } 748 } 749 if (found) 750 continue; 751 752 /* Now, we will do a detection, but only if it is in the normal or 753 probe entries */ 754 for (i = 0; 755 !found && (address_data->normal_i2c[i] != I2C_CLIENT_END); 756 i += 1) { 757 if (addr == address_data->normal_i2c[i]) { 758 found = 1; 759 DEB2(printk("i2c-core.o: found normal i2c entry for adapter %d, " 760 "addr %02x", adap_id,addr)); 761 } 762 } 763 764 for (i = 0; 765 !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); 766 i += 2) { 767 if ((addr >= address_data->normal_i2c_range[i]) && 768 (addr <= address_data->normal_i2c_range[i+1])) { 769 found = 1; 770 DEB2(printk("i2c-core.o: found normal i2c_range entry for adapter %d, " 771 "addr %04x\n", adap_id,addr)); 772 } 773 } 774 775 for (i = 0; 776 !found && (address_data->probe[i] != I2C_CLIENT_END); 777 i += 2) { 778 if (((adap_id == address_data->probe[i]) || 779 ((address_data->probe[i] == ANY_I2C_BUS))) && 780 (addr == address_data->probe[i+1])) { 781 found = 1; 782 DEB2(printk("i2c-core.o: found probe parameter for adapter %d, " 783 "addr %04x\n", adap_id,addr)); 784 } 785 } 786 for (i = 0; 787 !found && (address_data->probe_range[i] != I2C_CLIENT_END); 788 i += 3) { 789 if (((adap_id == address_data->probe_range[i]) || 790 (address_data->probe_range[i] == ANY_I2C_BUS)) && 791 (addr >= address_data->probe_range[i+1]) && 792 (addr <= address_data->probe_range[i+2])) { 793 found = 1; 794 DEB2(printk("i2c-core.o: found probe_range parameter for adapter %d, " 795 "addr %04x\n", adap_id,addr)); 796 } 797 } 798 if (!found) 799 continue; 800 801 /* OK, so we really should examine this address. First check 802 whether there is some client here at all! */ 803 if (i2c_smbus_xfer(adapter,addr,0,0,0,I2C_SMBUS_QUICK,NULL) >= 0) 804 if ((err = found_proc(adapter,addr,0,-1))) 805 return err; 806 } 807 return 0; 808 } 809 810 /* +++ frodo 689 int addr,i,found,err; 690 int adap_id = i2c_adapter_id(adapter); 691 692 /* Forget it if we can't probe using SMBUS_QUICK */ 693 if (! i2c_check_functionality(adapter,I2C_FUNC_SMBUS_QUICK)) 694 return -1; 695 696 for (addr = 0x00; addr <= 0x7f; addr++) { 697 698 /* Skip if already in use */ 699 if (i2c_check_addr(adapter,addr)) 700 continue; 701 702 /* If it is in one of the force entries, we don't do any detection 703 at all */ 704 found = 0; 705 706 for (i = 0; !found && (address_data->force[i] != I2C_CLIENT_END); i += 3) { 707 if (((adap_id == address_data->force[i]) || 708 (address_data->force[i] == ANY_I2C_BUS)) && 709 (addr == address_data->force[i+1])) { 710 DEB2(printk("i2c-core.o: found force parameter for adapter %d, addr %04x\n", 711 adap_id,addr)); 712 if ((err = found_proc(adapter,addr,0,0))) 713 return err; 714 found = 1; 715 } 716 } 717 if (found) 718 continue; 719 720 /* If this address is in one of the ignores, we can forget about it 721 right now */ 722 for (i = 0; !found && (address_data->ignore[i] != I2C_CLIENT_END); i += 2) { 723 if (((adap_id == address_data->ignore[i]) || 724 ((address_data->ignore[i] == ANY_I2C_BUS))) && 725 (addr == address_data->ignore[i+1])) { 726 DEB2(printk("i2c-core.o: found ignore parameter for adapter %d, " 727 "addr %04x\n", adap_id ,addr)); 728 found = 1; 729 } 730 } 731 for (i = 0; !found && (address_data->ignore_range[i] != I2C_CLIENT_END); i += 3) { 732 if (((adap_id == address_data->ignore_range[i]) || 733 ((address_data->ignore_range[i]==ANY_I2C_BUS))) && 734 (addr >= address_data->ignore_range[i+1]) && 735 (addr <= address_data->ignore_range[i+2])) { 736 DEB2(printk("i2c-core.o: found ignore_range parameter for adapter %d, " 737 "addr %04x\n", adap_id,addr)); 738 found = 1; 739 } 740 } 741 if (found) 742 continue; 743 744 /* Now, we will do a detection, but only if it is in the normal or 745 probe entries */ 746 for (i = 0; !found && (address_data->normal_i2c[i] != I2C_CLIENT_END); i += 1) { 747 if (addr == address_data->normal_i2c[i]) { 748 found = 1; 749 DEB2(printk("i2c-core.o: found normal i2c entry for adapter %d, " 750 "addr %02x", adap_id,addr)); 751 } 752 } 753 754 for (i = 0; !found && (address_data->normal_i2c_range[i] != I2C_CLIENT_END); i += 2) { 755 if ((addr >= address_data->normal_i2c_range[i]) && 756 (addr <= address_data->normal_i2c_range[i+1])) { 757 found = 1; 758 DEB2(printk("i2c-core.o: found normal i2c_range entry for adapter %d, " 759 "addr %04x\n", adap_id,addr)); 760 } 761 } 762 763 for (i = 0; !found && (address_data->probe[i] != I2C_CLIENT_END); i += 2) { 764 if (((adap_id == address_data->probe[i]) || 765 ((address_data->probe[i] == ANY_I2C_BUS))) && 766 (addr == address_data->probe[i+1])) { 767 found = 1; 768 DEB2(printk("i2c-core.o: found probe parameter for adapter %d, " 769 "addr %04x\n", adap_id,addr)); 770 } 771 } 772 for (i = 0; !found && (address_data->probe_range[i] != I2C_CLIENT_END); i += 3) { 773 if (((adap_id == address_data->probe_range[i]) || 774 (address_data->probe_range[i] == ANY_I2C_BUS)) && 775 (addr >= address_data->probe_range[i+1]) && 776 (addr <= address_data->probe_range[i+2])) { 777 found = 1; 778 DEB2(printk("i2c-core.o: found probe_range parameter for adapter %d, " 779 "addr %04x\n", adap_id,addr)); 780 } 781 } 782 if (!found) 783 continue; 784 785 /* OK, so we really should examine this address. First check 786 whether there is some client here at all! */ 787 if (i2c_smbus_xfer(adapter,addr,0,0,0,I2C_SMBUS_QUICK,NULL) >= 0) 788 if ((err = found_proc(adapter,addr,0,-1))) 789 return err; 790 } 791 return 0; 792 } 793 794 /* 811 795 * return id number for a specific adapter 812 796 */ … … 825 809 { 826 810 return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 827 value,0,I2C_SMBUS_QUICK,NULL);811 value,0,I2C_SMBUS_QUICK,NULL); 828 812 } 829 813 … … 832 816 union i2c_smbus_data data; 833 817 if (i2c_smbus_xfer(client->adapter,client->addr,client->flags, 834 I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data))818 I2C_SMBUS_READ,0,I2C_SMBUS_BYTE, &data)) 835 819 return -1; 836 820 else … …
