Changeset 582
- Timestamp:
- 09/27/99 15:20:45 (9 years ago)
- Files:
-
- lm-sensors/trunk/TODO (modified) (1 diff)
- lm-sensors/trunk/kernel/chips/adm1021.c (modified) (7 diffs)
- lm-sensors/trunk/kernel/chips/adm9240.c (modified) (7 diffs)
- lm-sensors/trunk/kernel/chips/bt869.c (modified) (5 diffs)
- lm-sensors/trunk/kernel/chips/eeprom.c (modified) (6 diffs)
- lm-sensors/trunk/kernel/chips/gl520sm.c (modified) (7 diffs)
- lm-sensors/trunk/kernel/chips/icspll.c (modified) (5 diffs)
- lm-sensors/trunk/kernel/chips/lm75.c (modified) (7 diffs)
- lm-sensors/trunk/kernel/chips/lm78.c (modified) (10 diffs)
- lm-sensors/trunk/kernel/chips/lm80.c (modified) (6 diffs)
- lm-sensors/trunk/kernel/chips/ltc1710.c (modified) (6 diffs)
- lm-sensors/trunk/kernel/chips/matorb.c (modified) (7 diffs)
- lm-sensors/trunk/kernel/chips/maxilife.c (modified) (5 diffs)
- lm-sensors/trunk/kernel/chips/sis5595.c (modified) (5 diffs)
- lm-sensors/trunk/kernel/chips/thmc50.c (modified) (6 diffs)
- lm-sensors/trunk/kernel/chips/w83781d.c (modified) (7 diffs)
- lm-sensors/trunk/kernel/include/Module.mk (modified) (1 diff)
- lm-sensors/trunk/lib/Module.mk (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
lm-sensors/trunk/TODO
r580 r582 11 11 ============== 12 12 13 * All clients: We can remove the foo_list of registered clients. They are not14 used anymore.15 * Most clients: Some typecasts to `struct i2c_client' are completely16 unnecessary by now. Remove them.17 13 * LM78 detection: Tom Webster has proven that the reset bit in the 18 14 id register can be one (strange!) lm-sensors/trunk/kernel/chips/adm1021.c
r536 r582 183 183 allocation could also be used; the code needed for this would probably 184 184 take more memory than the datastructure takes now. */ 185 #define MAX_ADM1021_NR 9 186 static struct i2c_client *adm1021_list[MAX_ADM1021_NR]; 185 static int adm1021_id = 0; 187 186 188 187 int adm1021_attach_adapter(struct i2c_adapter *adapter) … … 275 274 data->type = kind; 276 275 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++; 288 277 data->valid = 0; 289 278 init_MUTEX(&data->update_lock); … … 294 283 295 284 /* 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, 297 286 type_name, 298 287 data->type==adm1021?adm1021_dir_table_template: … … 304 293 305 294 /* Initialize the ADM1021 chip */ 306 adm1021_init_client( (struct i2c_client *)new_client);295 adm1021_init_client(new_client); 307 296 return 0; 308 297 … … 313 302 i2c_detach_client(new_client); 314 303 ERROR3: 315 for (i = 0; i < MAX_ADM1021_NR; i++)316 if (new_client == adm1021_list[i])317 adm1021_list[i] = NULL;318 ERROR2:319 304 ERROR1: 320 305 kfree(new_client); … … 343 328 { 344 329 345 int err ,i;330 int err; 346 331 347 332 sensors_deregister_entry(((struct adm1021_data *)(client->data))->sysctl_id); … … 351 336 return err; 352 337 } 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;362 338 363 339 kfree(client); lm-sensors/trunk/kernel/chips/adm9240.c
r532 r582 287 287 allocation could also be used; the code needed for this would probably 288 288 take more memory than the datastructure takes now. */ 289 #define MAX_ADM9240_NR 4 290 static struct i2c_client *adm9240_list[MAX_ADM9240_NR]; 289 static int adm9240_id = 0; 291 290 292 291 static struct i2c_driver adm9240_driver = { … … 428 427 data->type = kind; 429 428 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 ++; 441 430 data->valid = 0; 442 431 init_MUTEX(&data->update_lock); … … 447 436 448 437 /* 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, 450 439 type_name, 451 440 adm9240_dir_table_template)) < 0) { … … 456 445 457 446 /* Initialize the ADM9240 chip */ 458 adm9240_init_client( (struct i2c_client *)new_client);447 adm9240_init_client(new_client); 459 448 return 0; 460 449 … … 465 454 i2c_detach_client(new_client); 466 455 ERROR3: 467 for (i = 0; i < MAX_ADM9240_NR; i++)468 if (new_client == adm9240_list[i])469 adm9240_list[i] = NULL;470 ERROR2:471 456 ERROR1: 472 457 kfree(new_client); … … 477 462 int adm9240_detach_client(struct i2c_client *client) 478 463 { 479 int err ,i;464 int err; 480 465 481 466 sensors_deregister_entry(((struct adm9240_data *)(client->data))->sysctl_id); … … 485 470 return err; 486 471 } 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;496 472 497 473 kfree(client); lm-sensors/trunk/kernel/chips/bt869.c
r579 r582 152 152 static int __initdata bt869_initialized = 0; 153 153 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 154 int bt869_id = 0; 160 155 161 156 int bt869_attach_adapter(struct i2c_adapter *adapter) … … 227 222 strcpy(new_client->name,client_name); 228 223 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++; 241 225 data->valid = 0; 242 226 init_MUTEX(&data->update_lock); … … 263 247 i2c_detach_client(new_client); 264 248 ERROR3: 265 for (i = 0; i < MAX_bt869_NR; i++)266 if (new_client == bt869_list[i])267 bt869_list[i] = NULL;268 ERROR2:269 249 ERROR1: 270 250 kfree(new_client); … … 275 255 int bt869_detach_client(struct i2c_client *client) 276 256 { 277 int err ,i;257 int err; 278 258 279 259 sensors_deregister_entry(((struct bt869_data *)(client->data))->sysctl_id); … … 283 263 return err; 284 264 } 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;294 265 295 266 kfree(client); lm-sensors/trunk/kernel/chips/eeprom.c
r516 r582 149 149 static int __initdata eeprom_initialized = 0; 150 150 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]; 151 static int eeprom_id = 0; 156 152 157 153 int eeprom_attach_adapter(struct i2c_adapter *adapter) … … 191 187 } 192 188 193 data = (struct eeprom_data *) ( ((struct i2c_client *) new_client)+ 1);189 data = (struct eeprom_data *) (new_client + 1); 194 190 new_client->addr = address; 195 191 new_client->data = data; … … 225 221 strcpy(new_client->name,client_name); 226 222 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++; 239 224 data->valid = 0; 240 225 init_MUTEX(&data->update_lock); … … 260 245 i2c_detach_client(new_client); 261 246 ERROR3: 262 for (i = 0; i < MAX_EEPROM_NR; i++)263 if (new_client == eeprom_list[i])264 eeprom_list[i] = NULL;265 ERROR2:266 247 ERROR1: 267 248 kfree(new_client); … … 272 253 int eeprom_detach_client(struct i2c_client *client) 273 254 { 274 int err ,i;255 int err; 275 256 276 257 sensors_deregister_entry(((struct eeprom_data *)(client->data))->sysctl_id); … … 280 261 return err; 281 262 } 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;291 263 292 264 kfree(client); lm-sensors/trunk/kernel/chips/gl520sm.c
r520 r582 281 281 allocation could also be used; the code needed for this would probably 282 282 take more memory than the datastructure takes now. */ 283 #define MAX_GL520_NR 4 284 static struct i2c_client *gl520_list[MAX_GL520_NR]; 283 static int gl520_id = 0; 285 284 286 285 int gl520_attach_adapter(struct i2c_adapter *adapter) … … 353 352 data->type = kind; 354 353 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++; 366 355 data->valid = 0; 367 356 init_MUTEX(&data->update_lock); … … 372 361 373 362 /* 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, 375 364 type_name, 376 365 gl520_dir_table_template)) < 0) { … … 383 372 data->two_temps=1; 384 373 data->alarm_mask=0xff; 385 gl520_init_client( (struct i2c_client *)new_client);374 gl520_init_client(new_client); 386 375 return 0; 387 376 … … 392 381 i2c_detach_client(new_client); 393 382 ERROR3: 394 for (i = 0; i < MAX_GL520_NR; i++)395 if (new_client == gl520_list[i])396 gl520_list[i] = NULL;397 ERROR2:398 383 ERROR1: 399 384 kfree(new_client); … … 453 438 int gl520_detach_client(struct i2c_client *client) 454 439 { 455 int err ,i;440 int err; 456 441 457 442 sensors_deregister_entry(((struct gl520_data *)(client->data))->sysctl_id); … … 461 446 return err; 462 447 } 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;472 448 473 449 kfree(client); lm-sensors/trunk/kernel/chips/icspll.c
r516 r582 119 119 static int __initdata icspll_initialized = 0; 120 120 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 121 static int icspll_id = 0; 128 122 int icspll_attach_adapter(struct i2c_adapter *adapter) 129 123 { … … 167 161 } 168 162 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 181 163 /* Fill the new client structure with data */ 182 164 data = (struct icspll_data *) (new_client + 1); 183 165 new_client->data = data; 184 new_client->id = i ;166 new_client->id = icspll_id++; 185 167 new_client->addr = address; 186 168 new_client->adapter = adapter; … … 212 194 i2c_detach_client(new_client); 213 195 ERROR2: 214 icspll_list[i] = NULL;215 196 ERROR1: 216 197 kfree(new_client); … … 222 203 { 223 204 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 }231 205 232 206 sensors_deregister_entry(((struct icspll_data *)(client->data))->sysctl_id); … … 237 211 } 238 212 239 icspll_list[i] = NULL;240 213 kfree(client); 241 214 return 0; lm-sensors/trunk/kernel/chips/lm75.c
r564 r582 128 128 static int __initdata lm75_initialized = 0; 129 129 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 130 static int lm75_id = 0; 136 131 137 132 int lm75_attach_adapter(struct i2c_adapter *adapter) … … 171 166 } 172 167 173 data = (struct lm75_data *) ( ((struct i2c_client *) new_client)+ 1);168 data = (struct lm75_data *) (new_client + 1); 174 169 new_client->addr = address; 175 170 new_client->data = data; … … 205 200 strcpy(new_client->name,client_name); 206 201 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++; 219 203 data->valid = 0; 220 204 init_MUTEX(&data->update_lock); … … 232 216 data->sysctl_id = i; 233 217 234 lm75_init_client( (struct i2c_client *)new_client);218 lm75_init_client(new_client); 235 219 return 0; 236 220 … … 241 225 i2c_detach_client(new_client); 242 226 ERROR3: 243 for (i = 0; i < MAX_LM75_NR; i++)244 if (new_client == lm75_list[i])245 lm75_list[i] = NULL;246 ERROR2:247 227 ERROR1: 248 228 kfree(new_client); … … 253 233 int lm75_detach_client(struct i2c_client *client) 254 234 { 255 int err ,i;235 int err; 256 236 257 237 sensors_deregister_entry(((struct lm75_data *)(client->data))->sysctl_id); … … 261 241 return err; 262 242 } 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;272 243 273 244 kfree(client); lm-sensors/trunk/kernel/chips/lm78.c
r516 r582 239 239 int *nrels_mag, long *results); 240 240 241 /* I choose here for semi-static LM78 allocation. Complete dynamic242 allocation could also be used; the code needed for this would probably243 take more memory than the datastructure takes now. */244 #define MAX_LM78_NR 8245 static struct i2c_client *lm78_list[MAX_LM78_NR];246 247 241 static struct i2c_driver lm78_driver = { 248 242 /* name */ "LM78(-J) and LM79 sensor driver", … … 258 252 /* Used by lm78_init/cleanup */ 259 253 static int __initdata lm78_initialized = 0; 254 255 static int lm78_id = 0; 260 256 261 257 /* The /proc/sys entries */ … … 356 352 But it allows us to access lm78_{read,write}_value. */ 357 353 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)) + 360 355 sizeof(struct lm78_data), 361 356 GFP_KERNEL))) { … … 364 359 } 365 360 366 data = (struct lm78_data *) ( ((struct i2c_client *) new_client)+ 1);361 data = (struct lm78_data *) (new_client + 1); 367 362 if (is_isa) 368 363 init_MUTEX(&data->lock); … … 422 417 data->type = kind; 423 418 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 ++; 435 420 data->valid = 0; 436 421 init_MUTEX(&data->update_lock); … … 441 426 442 427 /* 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, 444 429 type_name, 445 430 lm78_dir_table_template)) < 0) { … … 450 435 451 436 /* Initialize the LM78 chip */ 452 lm78_init_client( (struct i2c_client *)new_client);437 lm78_init_client(new_client); 453 438 return 0; 454 439 … … 459 444 i2c_detach_client(new_client); 460 445 ERROR3: 461 for (i = 0; i < MAX_LM78_NR; i++)462 if (new_client == lm78_list[i])463 lm78_list[i] = NULL;464 ERROR2:465 446 if (is_isa) 466 447 release_region(address,LM78_EXTENT); … … 473 454 int lm78_detach_client(struct i2c_client *client) 474 455 { 475 int err ,i;456 int err; 476 457 477 458 sensors_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id); … … 481 462 return err; 482 463 } 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;492 464 493 465 if i2c_is_isa_client(client) lm-sensors/trunk/kernel/chips/lm80.c
r543 r582 228 228 int *nrels_mag, long *results); 229 229 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]; 230 static int lm80_id = 0; 235 231 236 232 static struct i2c_driver lm80_driver = { … … 317 313 } 318 314 319 data = (struct lm80_data *) ( ((struct i2c_client *) new_client)+ 1);315 data = (struct lm80_data *) (new_client + 1); 320 316 new_client->addr = address; 321 317 new_client->data = data; … … 351 347 strcpy(new_client->name,client_name); 352 348 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++; 365 350 data->valid = 0; 366 351 init_MUTEX(&data->update_lock); … … 386 371 i2c_detach_client(new_client); 387 372 ERROR3: 388 for (i = 0; i < MAX_LM80_NR; i++)389 if (new_client == lm80_list[i])390 lm80_list[i] = NULL;391 ERROR2:392 373 ERROR1: 393 374 kfree(new_client); … … 398 379 int lm80_detach_client(struct i2c_client *client) 399 380 { 400 int err ,i;381 int err; 401 382 402 383 sensors_deregister_entry(((struct lm80_data *)(client->data))->sysctl_id); … … 406 387 return err; 407 388 } 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;417 389 418 390 kfree(client); lm-sensors/trunk/kernel/chips/ltc1710.c
r516 r582 142 142 allocation could also be used; the code needed for this would probably 143 143 take more memory than the datastructure takes now. */ 144 #define MAX_LTC1710_NR 3 145 static struct i2c_client *ltc1710_list[MAX_LTC1710_NR]; 144 static int ltc1710_id = 0; 146 145 147 146 int ltc1710_attach_adapter(struct i2c_adapter *adapter) … … 181 180 } 182 181 183 data = (struct ltc1710_data *) ( ((struct i2c_client *) new_client)+ 1);182 data = (struct ltc1710_data *) (new_client + 1); 184 183 new_client->addr = address; 185 184 new_client->data = data; … … 207 206 strcpy(new_client->name,client_name); 208 207 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++; 221 209 data->valid = 0; 222 210 init_MUTEX(&data->update_lock); … … 242 230 i2c_detach_client(new_client); 243 231 ERROR3: 244 for (i = 0; i < MAX_LTC1710_NR; i++)245 if (new_client == ltc1710_list[i])246 ltc1710_list[i] = NULL;247 ERROR2:248 232 ERROR1: 249 233 kfree(new_client); … … 255 239 int ltc1710_detach_client(struct i2c_client *client) 256 240 { 257 int err ,i;241 int err; 258 242 259 243 sensors_deregister_entry(((struct ltc1710_data *)(client->data))->sysctl_id); … … 263 247 return err; 264 248 } 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;274 249 275 250 kfree(client); lm-sensors/trunk/kernel/chips/matorb.c
r516 r582 113 113 static int __initdata matorb_initialized = 0; 114 114 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 115 static int matorb_id = 0; 121 116 122 117 int matorb_attach_adapter(struct i2c_adapter *adapter) … … 157 152 } 158 153 159 data = (struct matorb_data *) ( ((struct i2c_client *) new_client)+ 1);154 data = (struct matorb_data *) (new_client + 1); 160 155 new_client->addr = address; 161 156 new_client->data = data; … … 171 166 strcpy(new_client->name,client_name); 172 167 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 ++; 185 169 data->valid = 0; 186 170 init_MUTEX(&data->update_lock); … … 198 182 data->sysctl_id = i; 199 183 200 matorb_init_client( (struct i2c_client *)new_client);184 matorb_init_client(new_client); 201 185 return 0; 202 186 … … 207 191 i2c_detach_client(new_client); 208 192 ERROR3: 209 for (i = 0; i < MAX_MATORB_NR; i++)210 if (new_client == matorb_list[i])211 matorb_list[i] = NULL;212 ERROR2:213 193 kfree(new_client); 214 194 ERROR0: … … 218 198 int matorb_detach_client(struct i2c_client *client) 219 199 { 220 int err ,i;200 int err; 221 201 222 202 sensors_deregister_entry(((struct matorb_data *)(client->data))->sysctl_id); … … 226 206 return err; 227 207 } 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;237 208 238 209 kfree(client); lm-sensors/trunk/kernel/chips/maxilife.c
r516 r582 199 199 200 200 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]; 201 static int maxi_id = 0; 206 202 207 203 /* The driver. I choose to use type i2c_driver, as at is identical to … … 376 372 i2c_detach_client(new_client); 377 373 ERROR3: 378 maxi_remove_client( (struct i2c_client *)new_client);374 maxi_remove_client(new_client); 379 375 ERROR2: 380 376 kfree(new_client); … … 385 381 int maxi_detach_smbus(struct i2c_client *client) 386 382 { 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; 395 384 396 385 sensors_deregister_entry(((struct maxi_data *)(client->data))->sysctl_id); … … 409 398 struct i2c_client *new_client) 410 399 { 411 int i;412 400 struct maxi_data *data; 413 401 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++; 426 403 new_client->adapter = adapter; 427 404 new_client->driver = &maxi_driver; … … 436 413 void maxi_remove_client(struct i2c_client *client) 437 414 { 438 int i;439 for (i = 0; i < MAX_MAXI_NR; i++)440 if (client == maxi_list[i])441 maxi_list[i] = NULL;442 415 } 443 416 lm-sensors/trunk/kernel/chips/sis5595.c
r516 r582 218 218 int *nrels_mag, long *results); 219 219 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]; 220 static int sis5595_id = 0; 225 221 226 222 /* The driver. I choose to use type i2c_driver, as at is identical to both … … 402 398 strcpy(new_client->name,client_name); 403 399 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++; 415 401 data->valid = 0; 416 402 init_MUTEX(&data->update_lock); … … 439 425 i2c_detach_client(new_client); 440 426 ERROR3: 441 for (i = 0; i < MAX_SIS5595_NR; i++)442 if (new_client == sis5595_list[i])443 sis5595_list[i] = NULL;444 ERROR2:445 427 release_region(address,SIS5595_EXTENT); 446 428 ERROR1: … … 452 434 int sis5595_detach_client(struct i2c_client *client) 453 435 { 454 int err ,i;436 int err; 455 437 456 438 sensors_deregister_entry(((struct sis5595_data *)(client->data))->sysctl_id); … … 460 442 return err; 461 443 } 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;471 444 472 445 release_region(client->addr,SIS5595_EXTENT); lm-sensors/trunk/kernel/chips/thmc50.c
r566 r582 170 170 static int __initdata thmc50_initialized = 0; 171 171 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 172 static int thmc50_id = 0; 178 173 179 174 int thmc50_attach_adapter(struct i2c_adapter *adapter) … … 249 244 strcpy(new_client->name,client_name); 250 245 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++; 263 247 data->valid = 0; 264 248 init_MUTEX(&data->update_lock); … … 276 260 data->sysctl_id = i; 277 261 278 thmc50_init_client( (struct i2c_client *)new_client);262 thmc50_init_client(new_client); 279 263 return 0; 280 264 … … 285 269 i2c_detach_client(new_client); 286 270 ERROR3: 287 for (i = 0; i < MAX_THMC50_NR; i++)288 if (new_client == thmc50_list[i])289 thmc50_list[i] = NULL;290 ERROR2:291 271 ERROR1: 292 272 kfree(new_client); … … 297 277 int thmc50_detach_client(struct i2c_client *client) 298 278 { 299 int err ,i;279 int err; 300 280 301 281 sensors_deregister_entry(((struct thmc50_data *)(client->data))->sysctl_id); … … 305 285 return err; 306 286 } 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;316 287 317 288 kfree(client); lm-sensors/trunk/kernel/chips/w83781d.c
r539 r582 405 405 #endif 406 406 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]; 407 static int w83781d_id = 0; 412 408 413 409 static struct i2c_driver w83781d_driver = { … … 695 691 } 696 692 697 data = (struct w83781d_data *) ( ((struct i2c_client *) new_client)+ 1);693 data = (struct w83781d_data *) (new_client + 1); 698 694 new_client->addr = address; 699 695 init_MUTEX(&data->lock); … … 774 770 data->type = kind; 775 771 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
