Changeset 3434

Show
Ignore:
Timestamp:
01/19/00 00:54:07 (9 years ago)
Author:
frodo
Message:

First pass of Kernel Coding Standards support

Tabs are now used at all places, and they are always 8 characters long.

Some lines are now a bit long; I will fix them tomorrow.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • i2c/trunk/kernel/i2c-algo-bit.c

    r3433 r3434  
    7676static inline void sdalo(struct i2c_algo_bit_data *adap) 
    7777{ 
    78     setsda(adap,0); 
    79     udelay(adap->udelay); 
     78       setsda(adap,0); 
     79       udelay(adap->udelay); 
    8080} 
    8181 
    8282static inline void sdahi(struct i2c_algo_bit_data *adap) 
    8383{ 
    84     setsda(adap,1); 
    85     udelay(adap->udelay); 
     84       setsda(adap,1); 
     85       udelay(adap->udelay); 
    8686} 
    8787 
    8888static inline void scllo(struct i2c_algo_bit_data *adap) 
    8989{ 
    90     setscl(adap,0); 
    91     udelay(adap->udelay); 
     90       setscl(adap,0); 
     91       udelay(adap->udelay); 
    9292#ifdef SLO_IO 
    93     SLO_IO 
     93       SLO_IO 
    9494#endif 
    9595} 
     
    230230                indata *= 2; 
    231231                if ( getsda(adap) )  
    232                   indata |= 0x01; 
     232                       indata |= 0x01; 
    233233                scllo(adap); 
    234234        } 
     
    518518{ 
    519519        return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |  
    520                I2C_FUNC_PROTOCOL_MANGLING; 
     520              I2C_FUNC_PROTOCOL_MANGLING; 
    521521} 
    522522 
     
    532532        NULL,                           /* slave_recv           */ 
    533533        algo_control,                   /* ioctl                */ 
    534         bit_func,                       /* functionality        */ 
     534       bit_func,                       /* functionality        */ 
    535535}; 
    536536 
     
    541541{ 
    542542        int i; 
    543         struct i2c_algo_bit_data *bit_adap = adap->algo_data; 
     543       struct i2c_algo_bit_data *bit_adap = adap->algo_data; 
    544544 
    545545        if (bit_test) { 
     
    561561        /* scan bus */ 
    562562        if (bit_scan) { 
    563                 int ack; 
     563               int ack; 
    564564                printk(KERN_INFO " i2c-algo-bit.o: scanning bus %s.\n", adap->name); 
    565565                for (i = 0x00; i < 0xff; i+=2) { 
  • i2c/trunk/kernel/i2c-algo-pcf.c

    r3433 r3434  
    8585static void i2c_start(struct i2c_algo_pcf_data *adap)  
    8686{ 
    87    DEBPROTO(printk("S ")); 
    88    set_pcf(adap, 1, I2C_PCF_START); 
     87       DEBPROTO(printk("S ")); 
     88       set_pcf(adap, 1, I2C_PCF_START); 
    8989} 
    9090 
    9191static void i2c_repstart(struct i2c_algo_pcf_data *adap)  
    9292{ 
    93    DEBPROTO(printk(" Sr ")); 
    94    set_pcf(adap, 1, I2C_PCF_REPSTART); 
     93       DEBPROTO(printk(" Sr ")); 
     94       set_pcf(adap, 1, I2C_PCF_REPSTART); 
    9595} 
    9696 
     
    9898static void i2c_stop(struct i2c_algo_pcf_data *adap)  
    9999{ 
    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); 
    102102} 
    103103 
     
    105105static int wait_for_bb(struct i2c_algo_pcf_data *adap) { 
    106106 
    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); 
    121121} 
    122122 
     
    130130static int wait_for_pin(struct i2c_algo_pcf_data *adap, int *status) { 
    131131 
    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); 
     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); 
    143143} 
    144144 
     
    258258                       unsigned char addr, int retries) 
    259259{ 
    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; 
    276276} 
    277277 
     
    279279static int pcf_sendbytes(struct i2c_adapter *i2c_adap,const char *buf, int count) 
    280280{ 
    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); 
    303303} 
    304304 
     
    306306static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf, int count) 
    307307{ 
    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; 
    310310  
    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); 
    341339} 
    342340 
     
    350348        if ( (flags & I2C_M_TEN)  ) {  
    351349                /* a ten bit address */ 
    352                 addr = 0xf0 | (( msg->addr >> 7) & 0x03); 
     350               addr = 0xf0 | (( msg->addr >> 7) & 0x03); 
    353351                DEB2(printk("addr0: %d\n",addr)); 
    354352                /* try extended address code...*/ 
     
    377375        } else {                /* normal 7bit address  */ 
    378376                addr = ( msg->addr << 1 ); 
    379                 if (flags & I2C_M_RD ) 
    380                         addr |= 1; 
     377               if (flags & I2C_M_RD ) 
     378                       addr |= 1; 
    381379                if (flags & I2C_M_REV_DIR_ADDR ) 
    382380                        addr ^= 1; 
     
    404402                pmsg = &msgs[i]; 
    405403                if (!(pmsg->flags & I2C_M_NOSTART)) { 
    406                         if (i) { 
     404                        if (i)  
    407405                                i2c_repstart(adap); 
    408                         } 
    409406                        ret = pcf_doAddress(adap, pmsg, i2c_adap->retries); 
    410407                        timeout = wait_for_pin(adap, &status); 
    411408                        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); 
    414411                        } 
    415412                        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); 
    419416                        } 
    420417                } 
    421418                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);) 
    423420                if (pmsg->flags & I2C_M_RD ) { 
    424421                        /* read bytes into buffer*/ 
     
    443440static u32 pcf_func(struct i2c_adapter *adap) 
    444441{ 
    445         return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |  
     442       return I2C_FUNC_SMBUS_EMUL | I2C_FUNC_10BIT_ADDR |  
    446443               I2C_FUNC_PROTOCOL_MANGLING;  
    447444} 
     
    457454        NULL,                           /* slave_recv           */ 
    458455        algo_control,                   /* ioctl                */ 
    459         pcf_func,                       /* functionality        */ 
     456        pcf_func,                      /* functionality        */ 
    460457}; 
    461458 
     
    493490        /* scan bus */ 
    494491        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"); 
    509506        } 
    510507        return 0; 
     
    525522int __init i2c_algo_pcf_init (void) 
    526523{ 
    527         printk("i2c-algo-pcf.o: i2c pcf8584 algorithm module\n"); 
     524       printk("i2c-algo-pcf.o: i2c pcf8584 algorithm module\n"); 
    528525        return 0; 
    529526} 
  • i2c/trunk/kernel/i2c-core.c

    r3433 r3434  
    6161 
    6262/**** lock for writing to global variables: the adapter & driver list */ 
    63 struct semaphore adap_lock;   
    64 struct semaphore driver_lock;   
     63struct semaphore adap_lock; 
     64struct semaphore driver_lock; 
    6565 
    6666/**** adapter list */ 
     
    9999   implementation of the read hook */ 
    100100static struct file_operations i2cproc_operations = { 
    101         NULL, 
    102         i2cproc_bus_read, 
     101       NULL, 
     102       i2cproc_bus_read, 
    103103}; 
    104104 
    105105static struct inode_operations i2cproc_inode_operations = { 
    106         &i2cproc_operations 
     106       &i2cproc_operations 
    107107}; 
    108108 
     
    117117 
    118118 
    119 /* ---------------------------------------------------     
     119/* --------------------------------------------------- 
    120120 * registering functions  
    121121 * ---------------------------------------------------  
     
    162162                if (! proc_entry) { 
    163163                        printk("i2c-core.o: Could not create /proc/bus/%s\n", 
    164                                name); 
     164                              name); 
    165165                        return -ENOENT; 
    166               } 
     166              } 
    167167                proc_entry->ops = &i2cproc_inode_operations; 
    168168#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,3,27)) 
     
    230230        ADAP_UNLOCK();   
    231231        DEB(printk("i2c-core.o: adapter unregistered: %s\n",adap->name)); 
    232         return 0;     
     232        return 0; 
    233233} 
    234234 
     
    304304        /* Have a look at each adapter, if clients of this driver are still 
    305305         * attached. If so, detach them to be able to kill the driver  
    306         * afterwards. 
     306        * afterwards. 
    307307         */ 
    308308        DEB2(printk("i2c-core.o: unregister_driver - looking for clients.\n")); 
     
    339339int i2c_check_addr (struct i2c_adapter *adapter, int addr) 
    340340{ 
    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; 
    346346} 
    347347 
     
    351351        int i; 
    352352 
    353         if (i2c_check_addr(client->adapter,client->addr)) 
    354           return -EBUSY; 
     353       if (i2c_check_addr(client->adapter,client->addr)) 
     354               return -EBUSY; 
    355355 
    356356        for (i = 0; i < I2C_CLIENT_MAX; i++) 
     
    399399 
    400400        DEB(printk("i2c-core.o: client [%s] unregistered.\n",client->name)); 
    401         return 0;     
     401        return 0; 
    402402} 
    403403 
     
    434434void monitor_bus_i2c(struct inode *inode, int fill) 
    435435{ 
    436   if (fill) 
    437     MOD_INC_USE_COUNT; 
    438   else 
    439     MOD_DEC_USE_COUNT; 
     436       if (fill) 
     437               MOD_INC_USE_COUNT; 
     438       else 
     439               MOD_DEC_USE_COUNT; 
    440440} 
    441441#endif /* (LINUX_VERSION_CODE <= KERNEL_VERSION(2,3,37)) */ 
     
    452452                        nr += sprintf(buf+nr, "i2c-%d\t", i); 
    453453                        if (adapters[i]->algo->smbus_xfer) { 
    454                                 if (adapters[i]->algo->master_xfer) 
     454                               if (adapters[i]->algo->master_xfer) 
    455455                                        nr += sprintf(buf+nr,"smbus/i2c"); 
    456456                                else 
     
    471471                         loff_t *ppos) 
    472472{ 
    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; 
     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; 
    506506} 
    507507 
     
    547547#endif /* def CONFIG_PROC_FS */ 
    548548 
    549 /* ---------------------------------------------------     
     549/* --------------------------------------------------- 
    550550 * dummy driver notification 
    551551 * ---------------------------------------------------  
     
    556556        int i;   
    557557        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); 
    560560} 
    561561 
     
    564564        int i; 
    565565        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); 
    568568} 
    569569 
     
    588588        } else { 
    589589                printk("i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n", 
    590                        adap->id); 
     590                      adap->id); 
    591591                return -ENOSYS; 
    592592        } 
     
    618618        } else { 
    619619                printk("i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n", 
    620                        client->adapter->id); 
     620                      client->adapter->id); 
    621621                return -ENOSYS; 
    622622        } 
     
    651651        } else { 
    652652                printk("i2c-core.o: I2C adapter %04x: I2C level transfers not supported\n", 
    653                        client->adapter->id); 
     653                      client->adapter->id); 
    654654                return -ENOSYS; 
    655655        } 
     
    687687                   i2c_client_found_addr_proc *found_proc) 
    688688{ 
    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/* 
    811795 * return id number for a specific adapter 
    812796 */ 
     
    825809{ 
    826810        return i2c_smbus_xfer(client->adapter,client->addr,client->flags, 
    827                               value,0,I2C_SMBUS_QUICK,NULL); 
     811                             value,0,I2C_SMBUS_QUICK,NULL); 
    828812} 
    829813 
     
    832816        union i2c_smbus_data data; 
    833817        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)) 
    835819                return -1; 
    836820        else