Changeset 582

Show
Ignore:
Timestamp:
09/27/99 15:20:45 (9 years ago)
Author:
frodo
Message:

Some code cleanups

* Removed several superfluous (struct i2c_client *) casts (they were left

from the time we had separate structs for smbus and isa)

* Removed the internal lists of registered clients

They have not been used for quite some time now, took memory space,
and limited the maximum number of clients that could be registered.

Also removed two small Makefile errors - I am happy I caught them before
the next release!

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lm-sensors/trunk/TODO

    r580 r582  
    1111============== 
    1212 
    13 * All clients: We can remove the foo_list of registered clients. They are not  
    14   used anymore. 
    15 * Most clients: Some typecasts to `struct i2c_client' are completely  
    16   unnecessary by now. Remove them. 
    1713* LM78 detection: Tom Webster has proven that the reset bit in the  
    1814  id register can be one (strange!) 
  • lm-sensors/trunk/kernel/chips/adm1021.c

    r536 r582  
    183183   allocation could also be used; the code needed for this would probably 
    184184   take more memory than the datastructure takes now. */ 
    185 #define MAX_ADM1021_NR 9 
    186 static struct i2c_client *adm1021_list[MAX_ADM1021_NR]; 
     185static int adm1021_id = 0; 
    187186 
    188187int adm1021_attach_adapter(struct i2c_adapter *adapter) 
     
    275274  data->type = kind; 
    276275 
    277   for(i = 0; i < MAX_ADM1021_NR; i++) 
    278     if (! adm1021_list[i]) 
    279       break; 
    280   if (i == MAX_ADM1021_NR) { 
    281     printk("adm1021.o: No empty slots left, recompile and heighten " 
    282            "MAX_ADM1021_NR!\n"); 
    283     err = -ENOMEM; 
    284     goto ERROR2; 
    285   } 
    286   adm1021_list[i] = new_client; 
    287   new_client->id = i; 
     276  new_client->id = adm1021_id++; 
    288277  data->valid = 0; 
    289278  init_MUTEX(&data->update_lock); 
     
    294283 
    295284  /* Register a new directory entry with module sensors */ 
    296   if ((i = sensors_register_entry((struct i2c_client *) new_client, 
     285  if ((i = sensors_register_entry(new_client, 
    297286                        type_name, 
    298287                        data->type==adm1021?adm1021_dir_table_template: 
     
    304293 
    305294  /* Initialize the ADM1021 chip */ 
    306   adm1021_init_client((struct i2c_client *) new_client); 
     295  adm1021_init_client(new_client); 
    307296  return 0; 
    308297 
     
    313302  i2c_detach_client(new_client); 
    314303ERROR3: 
    315   for (i = 0; i < MAX_ADM1021_NR; i++) 
    316     if (new_client == adm1021_list[i]) 
    317       adm1021_list[i] = NULL; 
    318 ERROR2: 
    319304ERROR1: 
    320305  kfree(new_client); 
     
    343328{ 
    344329 
    345   int err,i
     330  int err
    346331 
    347332  sensors_deregister_entry(((struct adm1021_data *)(client->data))->sysctl_id); 
     
    351336    return err; 
    352337  } 
    353  
    354   for (i = 0; i < MAX_ADM1021_NR; i++) 
    355     if (client == adm1021_list[i]) 
    356       break; 
    357   if ((i == MAX_ADM1021_NR)) { 
    358     printk("adm1021.o: Client to detach not found.\n"); 
    359     return -ENOENT; 
    360   } 
    361   adm1021_list[i] = NULL; 
    362338 
    363339  kfree(client); 
  • lm-sensors/trunk/kernel/chips/adm9240.c

    r532 r582  
    287287   allocation could also be used; the code needed for this would probably 
    288288   take more memory than the datastructure takes now. */ 
    289 #define MAX_ADM9240_NR 4 
    290 static struct i2c_client *adm9240_list[MAX_ADM9240_NR]; 
     289static int adm9240_id = 0; 
    291290 
    292291static struct i2c_driver adm9240_driver = { 
     
    428427  data->type = kind; 
    429428 
    430   for(i = 0; i < MAX_ADM9240_NR; i++) 
    431     if (! adm9240_list[i]) 
    432       break; 
    433   if (i == MAX_ADM9240_NR) { 
    434     printk("adm9240.o: No empty slots left, recompile and heighten " 
    435            "MAX_ADM9240_NR!\n"); 
    436     err = -ENOMEM; 
    437     goto ERROR2; 
    438   } 
    439   adm9240_list[i] = new_client; 
    440   new_client->id = i; 
     429  new_client->id = adm9240_id ++; 
    441430  data->valid = 0; 
    442431  init_MUTEX(&data->update_lock); 
     
    447436 
    448437  /* Register a new directory entry with module sensors */ 
    449   if ((i = sensors_register_entry((struct i2c_client *) new_client, 
     438  if ((i = sensors_register_entry(new_client, 
    450439                                  type_name, 
    451440                                  adm9240_dir_table_template)) < 0) { 
     
    456445 
    457446  /* Initialize the ADM9240 chip */ 
    458   adm9240_init_client((struct i2c_client *) new_client); 
     447  adm9240_init_client(new_client); 
    459448  return 0; 
    460449 
     
    465454  i2c_detach_client(new_client); 
    466455ERROR3: 
    467   for (i = 0; i < MAX_ADM9240_NR; i++) 
    468     if (new_client == adm9240_list[i]) 
    469       adm9240_list[i] = NULL; 
    470 ERROR2: 
    471456ERROR1: 
    472457  kfree(new_client); 
     
    477462int adm9240_detach_client(struct i2c_client *client) 
    478463{ 
    479   int err,i
     464  int err
    480465 
    481466  sensors_deregister_entry(((struct adm9240_data *)(client->data))->sysctl_id); 
     
    485470    return err; 
    486471  } 
    487  
    488   for (i = 0; i < MAX_ADM9240_NR; i++) 
    489     if (client == adm9240_list[i]) 
    490       break; 
    491   if ((i == MAX_ADM9240_NR)) { 
    492     printk("adm9240.o: Client to detach not found.\n"); 
    493     return -ENOENT; 
    494   } 
    495   adm9240_list[i] = NULL; 
    496472 
    497473  kfree(client); 
  • lm-sensors/trunk/kernel/chips/bt869.c

    r579 r582  
    152152static int __initdata bt869_initialized = 0; 
    153153 
    154 /* I choose here for semi-static bt869 allocation. Complete dynamic 
    155    allocation could also be used; the code needed for this would probably 
    156    take more memory than the datastructure takes now. */ 
    157 #define MAX_bt869_NR 16 
    158 static struct i2c_client *bt869_list[MAX_bt869_NR]; 
    159  
     154int bt869_id = 0; 
    160155 
    161156int bt869_attach_adapter(struct i2c_adapter *adapter) 
     
    227222  strcpy(new_client->name,client_name); 
    228223 
    229   /* Find a place in our global list */ 
    230   for (i = 0; i < MAX_bt869_NR; i++) 
    231     if (! bt869_list[i]) 
    232        break; 
    233   if (i == MAX_bt869_NR) { 
    234     err = -ENOMEM; 
    235     printk("bt869.o: No empty slots left, recompile and heighten " 
    236            "MAX_bt869_NR!\n"); 
    237     goto ERROR2; 
    238   } 
    239   bt869_list[i] = new_client; 
    240   new_client->id = i; 
     224  new_client->id = bt869_id++; 
    241225  data->valid = 0; 
    242226  init_MUTEX(&data->update_lock); 
     
    263247  i2c_detach_client(new_client); 
    264248ERROR3: 
    265   for (i = 0; i < MAX_bt869_NR; i++) 
    266     if (new_client == bt869_list[i]) 
    267       bt869_list[i] = NULL; 
    268 ERROR2: 
    269249ERROR1: 
    270250  kfree(new_client); 
     
    275255int bt869_detach_client(struct i2c_client *client) 
    276256{ 
    277   int err,i
     257  int err
    278258 
    279259  sensors_deregister_entry(((struct bt869_data *)(client->data))->sysctl_id); 
     
    283263    return err; 
    284264  } 
    285  
    286   for (i = 0; i < MAX_bt869_NR; i++) 
    287     if (client == bt869_list[i]) 
    288       break; 
    289   if ((i == MAX_bt869_NR)) { 
    290     printk("bt869.o: Client to detach not found.\n"); 
    291     return -ENOENT; 
    292   } 
    293   bt869_list[i] = NULL; 
    294265 
    295266  kfree(client); 
  • lm-sensors/trunk/kernel/chips/eeprom.c

    r516 r582  
    149149static int __initdata eeprom_initialized = 0; 
    150150 
    151 /* I choose here for semi-static LM78 allocation. Complete dynamic 
    152    allocation could also be used; the code needed for this would probably 
    153    take more memory than the datastructure takes now. */ 
    154 #define MAX_EEPROM_NR 8 
    155 static struct i2c_client *eeprom_list[MAX_EEPROM_NR]; 
     151static int eeprom_id = 0; 
    156152 
    157153int eeprom_attach_adapter(struct i2c_adapter *adapter) 
     
    191187  } 
    192188 
    193   data = (struct eeprom_data *) (((struct i2c_client *) new_client) + 1); 
     189  data = (struct eeprom_data *) (new_client + 1); 
    194190  new_client->addr = address; 
    195191  new_client->data = data; 
     
    225221  strcpy(new_client->name,client_name); 
    226222 
    227   /* Find a place in our global list */ 
    228   for (i = 0; i < MAX_EEPROM_NR; i++) 
    229     if (! eeprom_list[i]) 
    230        break; 
    231   if (i == MAX_EEPROM_NR) { 
    232     err = -ENOMEM; 
    233     printk("eeprom.o: No empty slots left, recompile and heighten " 
    234            "MAX_EEPROM_NR!\n"); 
    235     goto ERROR2; 
    236   } 
    237   eeprom_list[i] = new_client; 
    238   new_client->id = i; 
     223  new_client->id = eeprom_id++; 
    239224  data->valid = 0; 
    240225  init_MUTEX(&data->update_lock); 
     
    260245  i2c_detach_client(new_client); 
    261246ERROR3: 
    262   for (i = 0; i < MAX_EEPROM_NR; i++) 
    263     if (new_client == eeprom_list[i]) 
    264       eeprom_list[i] = NULL; 
    265 ERROR2: 
    266247ERROR1: 
    267248  kfree(new_client); 
     
    272253int eeprom_detach_client(struct i2c_client *client) 
    273254{ 
    274   int err,i
     255  int err
    275256 
    276257  sensors_deregister_entry(((struct eeprom_data *)(client->data))->sysctl_id); 
     
    280261    return err; 
    281262  } 
    282  
    283   for (i = 0; i < MAX_EEPROM_NR; i++) 
    284     if (client == eeprom_list[i]) 
    285       break; 
    286   if ((i == MAX_EEPROM_NR)) { 
    287     printk("eeprom.o: Client to detach not found.\n"); 
    288     return -ENOENT; 
    289   } 
    290   eeprom_list[i] = NULL; 
    291263 
    292264  kfree(client); 
  • lm-sensors/trunk/kernel/chips/gl520sm.c

    r520 r582  
    281281   allocation could also be used; the code needed for this would probably 
    282282   take more memory than the datastructure takes now. */ 
    283 #define MAX_GL520_NR 4 
    284 static struct i2c_client *gl520_list[MAX_GL520_NR]; 
     283static int gl520_id = 0; 
    285284 
    286285int gl520_attach_adapter(struct i2c_adapter *adapter) 
     
    353352  data->type = kind; 
    354353 
    355   for(i = 0; i < MAX_GL520_NR; i++) 
    356     if (! gl520_list[i]) 
    357       break; 
    358   if (i == MAX_GL520_NR) { 
    359     printk("gl520sm.o: No empty slots left, recompile and heighten " 
    360            "MAX_GL520_NR!\n"); 
    361     err = -ENOMEM; 
    362     goto ERROR2; 
    363   } 
    364   gl520_list[i] = new_client; 
    365   new_client->id = i; 
     354  new_client->id = gl520_id++; 
    366355  data->valid = 0; 
    367356  init_MUTEX(&data->update_lock); 
     
    372361 
    373362  /* Register a new directory entry with module sensors */ 
    374   if ((i = sensors_register_entry((struct i2c_client *) new_client, 
     363  if ((i = sensors_register_entry(new_client, 
    375364                                  type_name, 
    376365                                  gl520_dir_table_template)) < 0) { 
     
    383372  data->two_temps=1; 
    384373  data->alarm_mask=0xff; 
    385   gl520_init_client((struct i2c_client *) new_client); 
     374  gl520_init_client(new_client); 
    386375  return 0; 
    387376 
     
    392381  i2c_detach_client(new_client); 
    393382ERROR3: 
    394   for (i = 0; i < MAX_GL520_NR; i++) 
    395     if (new_client == gl520_list[i]) 
    396       gl520_list[i] = NULL; 
    397 ERROR2: 
    398383ERROR1: 
    399384  kfree(new_client); 
     
    453438int gl520_detach_client(struct i2c_client *client) 
    454439{ 
    455   int err,i
     440  int err
    456441 
    457442  sensors_deregister_entry(((struct gl520_data *)(client->data))->sysctl_id); 
     
    461446    return err; 
    462447  } 
    463  
    464   for (i = 0; i < MAX_GL520_NR; i++) 
    465     if (client == gl520_list[i]) 
    466       break; 
    467   if ((i == MAX_GL520_NR)) { 
    468     printk("gl520sm.o: Client to detach not found.\n"); 
    469     return -ENOENT; 
    470   } 
    471   gl520_list[i] = NULL; 
    472448 
    473449  kfree(client); 
  • lm-sensors/trunk/kernel/chips/icspll.c

    r516 r582  
    119119static int __initdata icspll_initialized = 0; 
    120120 
    121 /* I choose here for semi-static allocation. Complete dynamic 
    122    allocation could also be used; the code needed for this would probably 
    123    take more memory than the datastructure takes now. */ 
    124 #define MAX_ICSPLL_NR 2 
    125 static struct i2c_client *icspll_list[MAX_ICSPLL_NR]; 
    126  
    127  
     121static int icspll_id = 0; 
    128122int icspll_attach_adapter(struct i2c_adapter *adapter) 
    129123{ 
     
    167161    } 
    168162 
    169     /* Find a place in our global list */ 
    170     for (i = 0; i < MAX_ICSPLL_NR; i++) 
    171       if (! icspll_list[i]) 
    172          break; 
    173     if (i == MAX_ICSPLL_NR) { 
    174       err = -ENOMEM; 
    175       printk("icspll.o: No empty slots left, recompile and heighten " 
    176              "MAX_ICSPLL_NR!\n"); 
    177       goto ERROR1; 
    178     } 
    179     icspll_list[i] = new_client; 
    180      
    181163    /* Fill the new client structure with data */ 
    182164    data = (struct icspll_data *) (new_client + 1); 
    183165    new_client->data = data; 
    184     new_client->id = i
     166    new_client->id = icspll_id++
    185167    new_client->addr = address; 
    186168    new_client->adapter = adapter; 
     
    212194    i2c_detach_client(new_client); 
    213195ERROR2: 
    214     icspll_list[i] = NULL; 
    215196ERROR1: 
    216197    kfree(new_client); 
     
    222203{ 
    223204  int err,i; 
    224   for (i = 0; i < MAX_ICSPLL_NR; i++) 
    225     if (client == icspll_list[i]) 
    226       break; 
    227   if ((i == MAX_ICSPLL_NR)) { 
    228     printk("icspll.o: Client to detach not found.\n"); 
    229     return -ENOENT; 
    230   } 
    231205 
    232206  sensors_deregister_entry(((struct icspll_data *)(client->data))->sysctl_id); 
     
    237211  } 
    238212 
    239   icspll_list[i] = NULL; 
    240213  kfree(client); 
    241214  return 0; 
  • lm-sensors/trunk/kernel/chips/lm75.c

    r564 r582  
    128128static int __initdata lm75_initialized = 0; 
    129129 
    130 /* I choose here for semi-static LM75 allocation. Complete dynamic 
    131    allocation could also be used; the code needed for this would probably 
    132    take more memory than the datastructure takes now. */ 
    133 #define MAX_LM75_NR 16 
    134 static struct i2c_client *lm75_list[MAX_LM75_NR]; 
    135  
     130static int lm75_id = 0; 
    136131 
    137132int lm75_attach_adapter(struct i2c_adapter *adapter) 
     
    171166  } 
    172167 
    173   data = (struct lm75_data *) (((struct i2c_client *) new_client) + 1); 
     168  data = (struct lm75_data *) (new_client + 1); 
    174169  new_client->addr = address; 
    175170  new_client->data = data; 
     
    205200  strcpy(new_client->name,client_name); 
    206201 
    207   /* Find a place in our global list */ 
    208   for (i = 0; i < MAX_LM75_NR; i++) 
    209     if (! lm75_list[i]) 
    210        break; 
    211   if (i == MAX_LM75_NR) { 
    212     err = -ENOMEM; 
    213     printk("lm75.o: No empty slots left, recompile and heighten " 
    214            "MAX_LM75_NR!\n"); 
    215     goto ERROR2; 
    216   } 
    217   lm75_list[i] = new_client; 
    218   new_client->id = i; 
     202  new_client->id = lm75_id++; 
    219203  data->valid = 0; 
    220204  init_MUTEX(&data->update_lock); 
     
    232216  data->sysctl_id = i; 
    233217 
    234   lm75_init_client((struct i2c_client *) new_client); 
     218  lm75_init_client(new_client); 
    235219  return 0; 
    236220 
     
    241225  i2c_detach_client(new_client); 
    242226ERROR3: 
    243   for (i = 0; i < MAX_LM75_NR; i++) 
    244     if (new_client == lm75_list[i]) 
    245       lm75_list[i] = NULL; 
    246 ERROR2: 
    247227ERROR1: 
    248228  kfree(new_client); 
     
    253233int lm75_detach_client(struct i2c_client *client) 
    254234{ 
    255   int err,i
     235  int err
    256236 
    257237  sensors_deregister_entry(((struct lm75_data *)(client->data))->sysctl_id); 
     
    261241    return err; 
    262242  } 
    263  
    264   for (i = 0; i < MAX_LM75_NR; i++) 
    265     if (client == lm75_list[i]) 
    266       break; 
    267   if ((i == MAX_LM75_NR)) { 
    268     printk("lm75.o: Client to detach not found.\n"); 
    269     return -ENOENT; 
    270   } 
    271   lm75_list[i] = NULL; 
    272243 
    273244  kfree(client); 
  • lm-sensors/trunk/kernel/chips/lm78.c

    r516 r582  
    239239                         int *nrels_mag, long *results); 
    240240 
    241 /* I choose here for semi-static LM78 allocation. Complete dynamic 
    242    allocation could also be used; the code needed for this would probably 
    243    take more memory than the datastructure takes now. */ 
    244 #define MAX_LM78_NR 8 
    245 static struct i2c_client *lm78_list[MAX_LM78_NR]; 
    246  
    247241static struct i2c_driver lm78_driver = { 
    248242  /* name */            "LM78(-J) and LM79 sensor driver", 
     
    258252/* Used by lm78_init/cleanup */ 
    259253static int __initdata lm78_initialized = 0; 
     254 
     255static int lm78_id = 0; 
    260256 
    261257/* The /proc/sys entries */ 
     
    356352     But it allows us to access lm78_{read,write}_value. */ 
    357353 
    358   if (! (new_client = kmalloc((is_isa?sizeof(struct i2c_client): 
    359                                       sizeof(struct i2c_client)) +  
     354  if (! (new_client = kmalloc((sizeof(struct i2c_client)) +  
    360355                              sizeof(struct lm78_data), 
    361356                              GFP_KERNEL))) { 
     
    364359  } 
    365360 
    366   data = (struct lm78_data *) (((struct i2c_client *) new_client) + 1); 
     361  data = (struct lm78_data *) (new_client + 1); 
    367362  if (is_isa)  
    368363    init_MUTEX(&data->lock); 
     
    422417  data->type = kind; 
    423418 
    424   for(i = 0; i < MAX_LM78_NR; i++) 
    425     if (! lm78_list[i]) 
    426       break; 
    427   if (i == MAX_LM78_NR) { 
    428     printk("lm78.o: No empty slots left, recompile and heighten " 
    429            "MAX_LM78_NR!\n"); 
    430     err = -ENOMEM; 
    431     goto ERROR2; 
    432   } 
    433   lm78_list[i] = new_client; 
    434   new_client->id = i; 
     419  new_client->id = lm78_id ++; 
    435420  data->valid = 0; 
    436421  init_MUTEX(&data->update_lock); 
     
    441426 
    442427  /* Register a new directory entry with module sensors */ 
    443   if ((i = sensors_register_entry((struct i2c_client *) new_client, 
     428  if ((i = sensors_register_entry(new_client, 
    444429                                  type_name, 
    445430                                  lm78_dir_table_template)) < 0) { 
     
    450435 
    451436  /* Initialize the LM78 chip */ 
    452   lm78_init_client((struct i2c_client *) new_client); 
     437  lm78_init_client(new_client); 
    453438  return 0; 
    454439 
     
    459444  i2c_detach_client(new_client); 
    460445ERROR3: 
    461   for (i = 0; i < MAX_LM78_NR; i++) 
    462     if (new_client == lm78_list[i])  
    463       lm78_list[i] = NULL; 
    464 ERROR2: 
    465446  if (is_isa) 
    466447    release_region(address,LM78_EXTENT); 
     
    473454int lm78_detach_client(struct i2c_client *client) 
    474455{ 
    475   int err,i
     456  int err
    476457 
    477458  sensors_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id); 
     
    481462    return err; 
    482463  } 
    483  
    484   for (i = 0; i < MAX_LM78_NR; i++) 
    485     if (client == lm78_list[i]) 
    486       break; 
    487   if ((i == MAX_LM78_NR)) { 
    488     printk("lm78.o: Client to detach not found.\n"); 
    489     return -ENOENT; 
    490   } 
    491   lm78_list[i] = NULL; 
    492464 
    493465  if i2c_is_isa_client(client) 
  • lm-sensors/trunk/kernel/chips/lm80.c

    r543 r582  
    228228                         int *nrels_mag, long *results); 
    229229 
    230 /* I choose here for semi-static LM80 allocation. Complete dynamic 
    231    allocation could also be used; the code needed for this would probably 
    232    take more memory than the datastructure takes now. */ 
    233 #define MAX_LM80_NR 4 
    234 static struct i2c_client *lm80_list[MAX_LM80_NR]; 
     230static int lm80_id = 0; 
    235231 
    236232static struct i2c_driver lm80_driver = { 
     
    317313  } 
    318314 
    319   data = (struct lm80_data *) (((struct i2c_client *) new_client) + 1); 
     315  data = (struct lm80_data *) (new_client + 1); 
    320316  new_client->addr = address; 
    321317  new_client->data = data; 
     
    351347  strcpy(new_client->name,client_name); 
    352348 
    353   /* Find a place in our global list */ 
    354   for (i = 0; i < MAX_LM80_NR; i++) 
    355     if (! lm80_list[i]) 
    356        break; 
    357   if (i == MAX_LM80_NR) { 
    358     err = -ENOMEM; 
    359     printk("lm80.o: No empty slots left, recompile and heighten " 
    360            "MAX_LM80_NR!\n"); 
    361     goto ERROR2; 
    362   } 
    363   lm80_list[i] = new_client; 
    364   new_client->id = i; 
     349  new_client->id = lm80_id++; 
    365350  data->valid = 0; 
    366351  init_MUTEX(&data->update_lock); 
     
    386371  i2c_detach_client(new_client); 
    387372ERROR3: 
    388   for (i = 0; i < MAX_LM80_NR; i++) 
    389     if (new_client == lm80_list[i]) 
    390       lm80_list[i] = NULL; 
    391 ERROR2: 
    392373ERROR1: 
    393374  kfree(new_client); 
     
    398379int lm80_detach_client(struct i2c_client *client) 
    399380{ 
    400   int err,i
     381  int err
    401382 
    402383  sensors_deregister_entry(((struct lm80_data *)(client->data))->sysctl_id); 
     
    406387    return err; 
    407388  } 
    408  
    409   for (i = 0; i < MAX_LM80_NR; i++) 
    410     if (client == lm80_list[i]) 
    411       break; 
    412   if ((i == MAX_LM80_NR)) { 
    413     printk("lm80.o: Client to detach not found.\n"); 
    414     return -ENOENT; 
    415   } 
    416   lm80_list[i] = NULL; 
    417389 
    418390  kfree(client); 
  • lm-sensors/trunk/kernel/chips/ltc1710.c

    r516 r582  
    142142   allocation could also be used; the code needed for this would probably 
    143143   take more memory than the datastructure takes now. */ 
    144 #define MAX_LTC1710_NR 3 
    145 static struct i2c_client *ltc1710_list[MAX_LTC1710_NR]; 
     144static int ltc1710_id = 0; 
    146145 
    147146int ltc1710_attach_adapter(struct i2c_adapter *adapter) 
     
    181180  } 
    182181 
    183   data = (struct ltc1710_data *) (((struct i2c_client *) new_client) + 1); 
     182  data = (struct ltc1710_data *) (new_client + 1); 
    184183  new_client->addr = address; 
    185184  new_client->data = data; 
     
    207206  strcpy(new_client->name,client_name); 
    208207 
    209   /* Find a place in our global list */ 
    210   for (i = 0; i < MAX_LTC1710_NR; i++) 
    211     if (! ltc1710_list[i]) 
    212        break; 
    213   if (i == MAX_LTC1710_NR) { 
    214     err = -ENOMEM; 
    215     printk("ltc1710.o: No empty slots left, recompile and heighten " 
    216            "MAX_LTC1710_NR!\n"); 
    217     goto ERROR2; 
    218   } 
    219   ltc1710_list[i] = new_client; 
    220   new_client->id = i; 
     208  new_client->id = ltc1710_id++; 
    221209  data->valid = 0; 
    222210  init_MUTEX(&data->update_lock); 
     
    242230  i2c_detach_client(new_client); 
    243231ERROR3: 
    244   for (i = 0; i < MAX_LTC1710_NR; i++) 
    245     if (new_client == ltc1710_list[i]) 
    246       ltc1710_list[i] = NULL; 
    247 ERROR2: 
    248232ERROR1: 
    249233  kfree(new_client); 
     
    255239int ltc1710_detach_client(struct i2c_client *client) 
    256240{ 
    257   int err,i
     241  int err
    258242 
    259243  sensors_deregister_entry(((struct ltc1710_data *)(client->data))->sysctl_id); 
     
    263247    return err; 
    264248  } 
    265  
    266   for (i = 0; i < MAX_LTC1710_NR; i++) 
    267     if (client == ltc1710_list[i]) 
    268       break; 
    269   if ((i == MAX_LTC1710_NR)) { 
    270     printk("ltc1710.o: Client to detach not found.\n"); 
    271     return -ENOENT; 
    272   } 
    273   ltc1710_list[i] = NULL; 
    274249 
    275250  kfree(client); 
  • lm-sensors/trunk/kernel/chips/matorb.c

    r516 r582  
    113113static int __initdata matorb_initialized = 0; 
    114114 
    115 /* I choose here for semi-static MATORB allocation. Complete dynamic 
    116    allocation could also be used; the code needed for this would probably 
    117    take more memory than the datastructure takes now. */ 
    118 #define MAX_MATORB_NR 16 
    119 static struct i2c_client *matorb_list[MAX_MATORB_NR]; 
    120  
     115static int matorb_id = 0; 
    121116 
    122117int matorb_attach_adapter(struct i2c_adapter *adapter) 
     
    157152  } 
    158153 
    159   data = (struct matorb_data *) (((struct i2c_client *) new_client) + 1); 
     154  data = (struct matorb_data *) (new_client + 1); 
    160155  new_client->addr = address; 
    161156  new_client->data = data; 
     
    171166  strcpy(new_client->name,client_name); 
    172167 
    173   /* Find a place in our global list */ 
    174   for (i = 0; i < MAX_MATORB_NR; i++) 
    175     if (! matorb_list[i]) 
    176        break; 
    177   if (i == MAX_MATORB_NR) { 
    178     err = -ENOMEM; 
    179     printk("matorb.o: No empty slots left, recompile and heighten " 
    180            "MAX_MATORB_NR!\n"); 
    181     goto ERROR2; 
    182   } 
    183   matorb_list[i] = new_client; 
    184   new_client->id = i; 
     168  new_client->id = matorb_id ++; 
    185169  data->valid = 0; 
    186170  init_MUTEX(&data->update_lock); 
     
    198182  data->sysctl_id = i; 
    199183 
    200   matorb_init_client((struct i2c_client *) new_client); 
     184  matorb_init_client(new_client); 
    201185  return 0; 
    202186 
     
    207191  i2c_detach_client(new_client); 
    208192ERROR3: 
    209   for (i = 0; i < MAX_MATORB_NR; i++) 
    210     if (new_client == matorb_list[i]) 
    211       matorb_list[i] = NULL; 
    212 ERROR2: 
    213193  kfree(new_client); 
    214194ERROR0: 
     
    218198int matorb_detach_client(struct i2c_client *client) 
    219199{ 
    220   int err,i
     200  int err
    221201 
    222202  sensors_deregister_entry(((struct matorb_data *)(client->data))->sysctl_id); 
     
    226206    return err; 
    227207  } 
    228  
    229   for (i = 0; i < MAX_MATORB_NR; i++) 
    230     if (client == matorb_list[i]) 
    231       break; 
    232   if ((i == MAX_MATORB_NR)) { 
    233     printk("matorb.o: Client to detach not found.\n"); 
    234     return -ENOENT; 
    235   } 
    236   matorb_list[i] = NULL; 
    237208 
    238209  kfree(client); 
  • lm-sensors/trunk/kernel/chips/maxilife.c

    r516 r582  
    199199 
    200200 
    201 /* I choose here for semi-static MaxiLife allocation. Complete dynamic 
    202    allocation could also be used; the code needed for this would probably 
    203    take more memory than the datastructure takes now. */ 
    204 #define MAX_MAXI_NR 4 
    205 static struct i2c_client *maxi_list[MAX_MAXI_NR]; 
     201static int maxi_id = 0; 
    206202 
    207203/* The driver. I choose to use type i2c_driver, as at is identical to 
     
    376372      i2c_detach_client(new_client); 
    377373ERROR3: 
    378       maxi_remove_client((struct i2c_client *) new_client); 
     374      maxi_remove_client(new_client); 
    379375ERROR2: 
    380376      kfree(new_client); 
     
    385381int maxi_detach_smbus(struct i2c_client *client) 
    386382{ 
    387    int err,i; 
    388    for (i = 0; i < MAX_MAXI_NR; i++) 
    389       if (client == maxi_list[i]) 
    390          break; 
    391    if ((i == MAX_MAXI_NR)) { 
    392       printk("maxilife: Client to detach not found.\n"); 
    393       return -ENOENT; 
    394    } 
     383   int err; 
    395384 
    396385   sensors_deregister_entry(((struct maxi_data *)(client->data))->sysctl_id); 
     
    409398                    struct i2c_client *new_client) 
    410399{ 
    411    int i; 
    412400   struct maxi_data *data; 
    413401 
    414    /* First, seek out an empty slot */ 
    415    for (i = 0; i < MAX_MAXI_NR; i++) 
    416       if (!maxi_list[i]) 
    417          break; 
    418    if (i == MAX_MAXI_NR) { 
    419       printk("maxilife: No empty slots left, recompile and heighten " 
    420              "MAX_MAXI_NR!\n"); 
    421       return -ENOMEM; 
    422    } 
    423    
    424    maxi_list[i] = new_client; 
    425    new_client->id = i; 
     402   new_client->id = maxi_id++; 
    426403   new_client->adapter = adapter; 
    427404   new_client->driver = &maxi_driver; 
     
    436413void maxi_remove_client(struct i2c_client *client) 
    437414{ 
    438    int i; 
    439    for (i = 0; i < MAX_MAXI_NR; i++) 
    440       if (client == maxi_list[i])  
    441          maxi_list[i] = NULL; 
    442415} 
    443416 
  • lm-sensors/trunk/kernel/chips/sis5595.c

    r516 r582  
    218218                         int *nrels_mag, long *results); 
    219219 
    220 /* I choose here for semi-static SIS5595 allocation. Complete dynamic 
    221    allocation could also be used; the code needed for this would probably 
    222    take more memory than the datastructure takes now. */ 
    223 #define MAX_SIS5595_NR 4 
    224 static struct i2c_client *sis5595_list[MAX_SIS5595_NR]; 
     220static int sis5595_id = 0; 
    225221 
    226222/* The driver. I choose to use type i2c_driver, as at is identical to both 
     
    402398  strcpy(new_client->name,client_name); 
    403399 
    404   for(i = 0; i < MAX_SIS5595_NR; i++) 
    405     if (! sis5595_list[i]) 
    406       break; 
    407   if (i == MAX_SIS5595_NR) { 
    408     printk("sis5595.o: No empty slots left, recompile and heighten " 
    409            "MAX_SIS5595_NR!\n"); 
    410     err = -ENOMEM; 
    411     goto ERROR2; 
    412   } 
    413   sis5595_list[i] = new_client; 
    414   new_client->id = i; 
     400  new_client->id = sis5595_id++; 
    415401  data->valid = 0; 
    416402  init_MUTEX(&data->update_lock); 
     
    439425  i2c_detach_client(new_client); 
    440426ERROR3: 
    441   for (i = 0; i < MAX_SIS5595_NR; i++) 
    442     if (new_client == sis5595_list[i]) 
    443       sis5595_list[i] = NULL; 
    444 ERROR2: 
    445427  release_region(address,SIS5595_EXTENT); 
    446428ERROR1: 
     
    452434int sis5595_detach_client(struct i2c_client *client) 
    453435{ 
    454   int err,i
     436  int err
    455437 
    456438  sensors_deregister_entry(((struct sis5595_data *)(client->data))->sysctl_id); 
     
    460442    return err; 
    461443  } 
    462  
    463   for (i = 0; i < MAX_SIS5595_NR; i++) 
    464     if (client == sis5595_list[i]) 
    465       break; 
    466   if ((i == MAX_SIS5595_NR)) { 
    467     printk("sis5595.o: Client to detach not found.\n"); 
    468     return -ENOENT; 
    469   } 
    470   sis5595_list[i] = NULL; 
    471444 
    472445  release_region(client->addr,SIS5595_EXTENT); 
  • lm-sensors/trunk/kernel/chips/thmc50.c

    r566 r582  
    170170static int __initdata thmc50_initialized = 0; 
    171171 
    172 /* I choose here for semi-static THMC50 allocation. Complete dynamic 
    173    allocation could also be used; the code needed for this would probably 
    174    take more memory than the datastructure takes now. */ 
    175 #define MAX_THMC50_NR 16 
    176 static struct i2c_client *thmc50_list[MAX_THMC50_NR]; 
    177  
     172static int thmc50_id = 0; 
    178173 
    179174int thmc50_attach_adapter(struct i2c_adapter *adapter) 
     
    249244  strcpy(new_client->name,client_name); 
    250245 
    251   /* Find a place in our global list */ 
    252   for (i = 0; i < MAX_THMC50_NR; i++) 
    253     if (! thmc50_list[i]) 
    254        break; 
    255   if (i == MAX_THMC50_NR) { 
    256     err = -ENOMEM; 
    257     printk("thmc50.o: No empty slots left, recompile and heighten " 
    258            "MAX_THMC50_NR!\n"); 
    259     goto ERROR2; 
    260   } 
    261   thmc50_list[i] = new_client; 
    262   new_client->id = i; 
     246  new_client->id = thmc50_id++; 
    263247  data->valid = 0; 
    264248  init_MUTEX(&data->update_lock); 
     
    276260  data->sysctl_id = i; 
    277261 
    278   thmc50_init_client((struct i2c_client *) new_client); 
     262  thmc50_init_client(new_client); 
    279263  return 0; 
    280264 
     
    285269  i2c_detach_client(new_client); 
    286270ERROR3: 
    287   for (i = 0; i < MAX_THMC50_NR; i++) 
    288     if (new_client == thmc50_list[i]) 
    289       thmc50_list[i] = NULL; 
    290 ERROR2: 
    291271ERROR1: 
    292272  kfree(new_client); 
     
    297277int thmc50_detach_client(struct i2c_client *client) 
    298278{ 
    299   int err,i
     279  int err
    300280 
    301281  sensors_deregister_entry(((struct thmc50_data *)(client->data))->sysctl_id); 
     
    305285    return err; 
    306286  } 
    307  
    308   for (i = 0; i < MAX_THMC50_NR; i++) 
    309     if (client == thmc50_list[i]) 
    310       break; 
    311   if ((i == MAX_THMC50_NR)) { 
    312     printk("thmc50.o: Client to detach not found.\n"); 
    313     return -ENOENT; 
    314   } 
    315   thmc50_list[i] = NULL; 
    316287 
    317288  kfree(client); 
  • lm-sensors/trunk/kernel/chips/w83781d.c

    r539 r582  
    405405#endif 
    406406 
    407 /* I choose here for semi-static W83781D allocation. Complete dynamic 
    408    allocation could also be used; the code needed for this would probably 
    409    take more memory than the datastructure takes now. */ 
    410 #define MAX_W83781D_NR 8 
    411 static struct i2c_client *w83781d_list[MAX_W83781D_NR]; 
     407static int w83781d_id = 0; 
    412408 
    413409static struct i2c_driver w83781d_driver = { 
     
    695691  } 
    696692 
    697   data = (struct w83781d_data *) (((struct i2c_client *) new_client) + 1); 
     693  data = (struct w83781d_data *) (new_client + 1); 
    698694  new_client->addr = address; 
    699695  init_MUTEX(&data->lock); 
     
    774770  data->type = kind; 
    775771 
    776   for(i = 0; i < MAX_W83781D_NR; i++) 
    777     if (! w83781d_list[i]) 
    778       break; 
    779   if (i == MAX_W83781D_NR) { 
    780     printk("w83781d.o: No empty slots left, recompile and heig