Changeset 33
- Timestamp:
- 12/04/98 16:26:29 (14 years ago)
- Location:
- lm-sensors/trunk
- Files:
-
- 2 modified
-
kernel/chips/lm78.c (modified) (2 diffs)
-
src/lm78.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/lm78.c
r29 r33 335 335 /* Determine exact type */ 336 336 outb_p(LM78_REG_CHIPID,address + LM78_ADDR_REG_OFFSET); 337 err = inb_p(address + LM78_DATA_REG_OFFSET); 337 err = inb_p(address + LM78_DATA_REG_OFFSET) & 0xfe; 338 if (err == 0x00) { 339 type = lm78; 340 type_name = "lm78"; 341 client_name = "LM78 chip"; 342 } else if (err == 0x40) { 343 type = lm78j; 344 type_name = "lm78-j"; 345 client_name = "LM78-J chip"; 346 } else if (err == 0xc0) { 347 type = lm79; 348 type_name = "lm79"; 349 client_name = "LM79 chip"; 350 } else { 351 #ifdef DEBUG 352 printk("lm78.o: warning: probed non-lm78 chip?!? (%x)\n",err); 353 #endif 354 continue; 355 } 356 357 request_region(address, LM78_EXTENT, type_name); 358 359 /* Allocate space for a new client structure */ 360 if (! (new_client = kmalloc(sizeof(struct isa_client) + 361 sizeof(struct lm78_data), 362 GFP_KERNEL))) 363 { 364 err=-ENOMEM; 365 goto ERROR1; 366 } 367 368 /* Fill the new client structure with data */ 369 new_client->data = (struct lm78_data *) (new_client + 1); 370 new_client->addr = 0; 371 strcpy(new_client->name,client_name); 372 ((struct lm78_data *) (new_client->data))->type = type; 373 new_client->isa_addr = address; 374 if ((err = lm78_new_client((struct i2c_adapter *) adapter, 375 (struct i2c_client *) new_client))) 376 goto ERROR2; 377 378 /* Tell i2c-core a new client has arrived */ 379 if ((err = isa_attach_client(new_client))) 380 goto ERROR3; 381 382 /* Register a new directory entry with module sensors */ 383 if ((err = sensors_register_entry((struct i2c_client *) new_client, 384 type_name, 385 lm78_dir_table_template)) < 0) 386 goto ERROR4; 387 ((struct lm78_data *) (new_client->data)) -> sysctl_id = err; 388 389 /* Initialize the LM78 chip */ 390 lm78_init_client((struct i2c_client *) new_client); 391 continue; 392 393 /* OK, this is not exactly good programming practice, usually. But it is 394 very code-efficient in this case. */ 395 396 ERROR4: 397 isa_detach_client(new_client); 398 ERROR3: 399 lm78_remove_client((struct i2c_client *) new_client); 400 ERROR2: 401 kfree(new_client); 402 ERROR1: 403 release_region(address, LM78_EXTENT); 404 } 405 return err; 406 407 } 408 409 /* Deregister and remove a LM78 client */ 410 int lm78_detach_isa(struct isa_client *client) 411 { 412 int err,i; 413 for (i = 0; i < MAX_LM78_NR; i++) 414 if ((client == (struct isa_client *) (lm78_list[i]))) 415 break; 416 if (i == MAX_LM78_NR) { 417 printk("lm78.o: Client to detach not found.\n"); 418 return -ENOENT; 419 } 420 421 sensors_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id); 422 423 if ((err = isa_detach_client(client))) { 424 printk("lm78.o: Client deregistration failed, client not detached.\n"); 425 return err; 426 } 427 lm78_remove_client((struct i2c_client *) client); 428 release_region(client->isa_addr,LM78_EXTENT); 429 kfree(client); 430 return 0; 431 } 432 433 int lm78_detect_smbus(struct i2c_adapter *adapter) 434 { 435 int address,err; 436 struct i2c_client *new_client; 437 enum lm78_type type; 438 const char *type_name,*client_name; 439 440 /* OK, this is no detection. I know. It will do for now, though. */ 441 err = 0; 442 for (address = 0x20; (! err) && (address <= 0x2f); address ++) { 443 444 /* Later on, we will keep a list of registered addresses for each 445 adapter, and check whether they are used here */ 446 447 if (smbus_read_byte_data(adapter,address,LM78_REG_CONFIG) == 0xff) 448 continue; 449 450 /* Real detection code goes here */ 451 452 /* Determine exact type */ 453 err = smbus_read_byte_data(adapter,address,LM78_REG_CHIPID) & 0xfe; 338 454 if (err == 0x00) { 339 455 type = lm78; … … 348 464 type_name = "lm79"; 349 465 client_name = "LM79 chip"; 350 } 351 else 466 } else { 467 #ifdef DEBUG 468 printk("lm78.o: warning: probed non-lm78 chip?!? (%x)\n",err); 469 #endif 352 470 continue; 353 354 355 request_region(address, LM78_EXTENT, type_name); 356 357 /* Allocate space for a new client structure */ 358 if (! (new_client = kmalloc(sizeof(struct isa_client) + 359 sizeof(struct lm78_data), 360 GFP_KERNEL))) 361 { 362 err=-ENOMEM; 363 goto ERROR1; 364 } 365 366 /* Fill the new client structure with data */ 367 new_client->data = (struct lm78_data *) (new_client + 1); 368 new_client->addr = 0; 369 strcpy(new_client->name,client_name); 370 ((struct lm78_data *) (new_client->data))->type = type; 371 new_client->isa_addr = address; 372 if ((err = lm78_new_client((struct i2c_adapter *) adapter, 373 (struct i2c_client *) new_client))) 374 goto ERROR2; 375 376 /* Tell i2c-core a new client has arrived */ 377 if ((err = isa_attach_client(new_client))) 378 goto ERROR3; 379 380 /* Register a new directory entry with module sensors */ 381 if ((err = sensors_register_entry((struct i2c_client *) new_client, 382 type_name, 383 lm78_dir_table_template)) < 0) 384 goto ERROR4; 385 ((struct lm78_data *) (new_client->data)) -> sysctl_id = err; 386 387 /* Initialize the LM78 chip */ 388 lm78_init_client((struct i2c_client *) new_client); 389 continue; 390 391 /* OK, this is not exactly good programming practice, usually. But it is 392 very code-efficient in this case. */ 393 394 ERROR4: 395 isa_detach_client(new_client); 396 ERROR3: 397 lm78_remove_client((struct i2c_client *) new_client); 398 ERROR2: 399 kfree(new_client); 400 ERROR1: 401 release_region(address, LM78_EXTENT); 402 } 403 return err; 404 405 } 406 407 /* Deregister and remove a LM78 client */ 408 int lm78_detach_isa(struct isa_client *client) 409 { 410 int err,i; 411 for (i = 0; i < MAX_LM78_NR; i++) 412 if ((client == (struct isa_client *) (lm78_list[i]))) 413 break; 414 if (i == MAX_LM78_NR) { 415 printk("lm78.o: Client to detach not found.\n"); 416 return -ENOENT; 417 } 418 419 sensors_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id); 420 421 if ((err = isa_detach_client(client))) { 422 printk("lm78.o: Client deregistration failed, client not detached.\n"); 423 return err; 424 } 425 lm78_remove_client((struct i2c_client *) client); 426 release_region(client->isa_addr,LM78_EXTENT); 427 kfree(client); 428 return 0; 429 } 430 431 int lm78_detect_smbus(struct i2c_adapter *adapter) 432 { 433 int address,err; 434 struct i2c_client *new_client; 435 enum lm78_type type; 436 const char *type_name,*client_name; 437 438 /* OK, this is no detection. I know. It will do for now, though. */ 439 err = 0; 440 for (address = 0x20; (! err) && (address <= 0x2f); address ++) { 441 442 /* Later on, we will keep a list of registered addresses for each 443 adapter, and check whether they are used here */ 444 445 if (smbus_read_byte_data(adapter,address,LM78_REG_CONFIG) == 0xff) 446 continue; 447 448 /* Real detection code goes here */ 449 450 /* Determine exact type */ 451 err = smbus_read_byte_data(adapter,address,LM78_REG_CHIPID); 452 if (err == 0x00) { 453 type = lm78; 454 type_name = "lm78"; 455 client_name = "LM78 chip"; 456 } else if (err == 0x40) { 457 type = lm78j; 458 type_name = "lm78-j"; 459 client_name = "LM78-J chip"; 460 } else if (err == 0x80) { 461 type = lm79; 462 type_name = "lm79"; 463 client_name = "LM79 chip"; 464 } else 465 continue; 471 } 466 472 467 473 -
lm-sensors/trunk/src/lm78.c
r29 r33 335 335 /* Determine exact type */ 336 336 outb_p(LM78_REG_CHIPID,address + LM78_ADDR_REG_OFFSET); 337 err = inb_p(address + LM78_DATA_REG_OFFSET); 337 err = inb_p(address + LM78_DATA_REG_OFFSET) & 0xfe; 338 if (err == 0x00) { 339 type = lm78; 340 type_name = "lm78"; 341 client_name = "LM78 chip"; 342 } else if (err == 0x40) { 343 type = lm78j; 344 type_name = "lm78-j"; 345 client_name = "LM78-J chip"; 346 } else if (err == 0xc0) { 347 type = lm79; 348 type_name = "lm79"; 349 client_name = "LM79 chip"; 350 } else { 351 #ifdef DEBUG 352 printk("lm78.o: warning: probed non-lm78 chip?!? (%x)\n",err); 353 #endif 354 continue; 355 } 356 357 request_region(address, LM78_EXTENT, type_name); 358 359 /* Allocate space for a new client structure */ 360 if (! (new_client = kmalloc(sizeof(struct isa_client) + 361 sizeof(struct lm78_data), 362 GFP_KERNEL))) 363 { 364 err=-ENOMEM; 365 goto ERROR1; 366 } 367 368 /* Fill the new client structure with data */ 369 new_client->data = (struct lm78_data *) (new_client + 1); 370 new_client->addr = 0; 371 strcpy(new_client->name,client_name); 372 ((struct lm78_data *) (new_client->data))->type = type; 373 new_client->isa_addr = address; 374 if ((err = lm78_new_client((struct i2c_adapter *) adapter, 375 (struct i2c_client *) new_client))) 376 goto ERROR2; 377 378 /* Tell i2c-core a new client has arrived */ 379 if ((err = isa_attach_client(new_client))) 380 goto ERROR3; 381 382 /* Register a new directory entry with module sensors */ 383 if ((err = sensors_register_entry((struct i2c_client *) new_client, 384 type_name, 385 lm78_dir_table_template)) < 0) 386 goto ERROR4; 387 ((struct lm78_data *) (new_client->data)) -> sysctl_id = err; 388 389 /* Initialize the LM78 chip */ 390 lm78_init_client((struct i2c_client *) new_client); 391 continue; 392 393 /* OK, this is not exactly good programming practice, usually. But it is 394 very code-efficient in this case. */ 395 396 ERROR4: 397 isa_detach_client(new_client); 398 ERROR3: 399 lm78_remove_client((struct i2c_client *) new_client); 400 ERROR2: 401 kfree(new_client); 402 ERROR1: 403 release_region(address, LM78_EXTENT); 404 } 405 return err; 406 407 } 408 409 /* Deregister and remove a LM78 client */ 410 int lm78_detach_isa(struct isa_client *client) 411 { 412 int err,i; 413 for (i = 0; i < MAX_LM78_NR; i++) 414 if ((client == (struct isa_client *) (lm78_list[i]))) 415 break; 416 if (i == MAX_LM78_NR) { 417 printk("lm78.o: Client to detach not found.\n"); 418 return -ENOENT; 419 } 420 421 sensors_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id); 422 423 if ((err = isa_detach_client(client))) { 424 printk("lm78.o: Client deregistration failed, client not detached.\n"); 425 return err; 426 } 427 lm78_remove_client((struct i2c_client *) client); 428 release_region(client->isa_addr,LM78_EXTENT); 429 kfree(client); 430 return 0; 431 } 432 433 int lm78_detect_smbus(struct i2c_adapter *adapter) 434 { 435 int address,err; 436 struct i2c_client *new_client; 437 enum lm78_type type; 438 const char *type_name,*client_name; 439 440 /* OK, this is no detection. I know. It will do for now, though. */ 441 err = 0; 442 for (address = 0x20; (! err) && (address <= 0x2f); address ++) { 443 444 /* Later on, we will keep a list of registered addresses for each 445 adapter, and check whether they are used here */ 446 447 if (smbus_read_byte_data(adapter,address,LM78_REG_CONFIG) == 0xff) 448 continue; 449 450 /* Real detection code goes here */ 451 452 /* Determine exact type */ 453 err = smbus_read_byte_data(adapter,address,LM78_REG_CHIPID) & 0xfe; 338 454 if (err == 0x00) { 339 455 type = lm78; … … 348 464 type_name = "lm79"; 349 465 client_name = "LM79 chip"; 350 } 351 else 466 } else { 467 #ifdef DEBUG 468 printk("lm78.o: warning: probed non-lm78 chip?!? (%x)\n",err); 469 #endif 352 470 continue; 353 354 355 request_region(address, LM78_EXTENT, type_name); 356 357 /* Allocate space for a new client structure */ 358 if (! (new_client = kmalloc(sizeof(struct isa_client) + 359 sizeof(struct lm78_data), 360 GFP_KERNEL))) 361 { 362 err=-ENOMEM; 363 goto ERROR1; 364 } 365 366 /* Fill the new client structure with data */ 367 new_client->data = (struct lm78_data *) (new_client + 1); 368 new_client->addr = 0; 369 strcpy(new_client->name,client_name); 370 ((struct lm78_data *) (new_client->data))->type = type; 371 new_client->isa_addr = address; 372 if ((err = lm78_new_client((struct i2c_adapter *) adapter, 373 (struct i2c_client *) new_client))) 374 goto ERROR2; 375 376 /* Tell i2c-core a new client has arrived */ 377 if ((err = isa_attach_client(new_client))) 378 goto ERROR3; 379 380 /* Register a new directory entry with module sensors */ 381 if ((err = sensors_register_entry((struct i2c_client *) new_client, 382 type_name, 383 lm78_dir_table_template)) < 0) 384 goto ERROR4; 385 ((struct lm78_data *) (new_client->data)) -> sysctl_id = err; 386 387 /* Initialize the LM78 chip */ 388 lm78_init_client((struct i2c_client *) new_client); 389 continue; 390 391 /* OK, this is not exactly good programming practice, usually. But it is 392 very code-efficient in this case. */ 393 394 ERROR4: 395 isa_detach_client(new_client); 396 ERROR3: 397 lm78_remove_client((struct i2c_client *) new_client); 398 ERROR2: 399 kfree(new_client); 400 ERROR1: 401 release_region(address, LM78_EXTENT); 402 } 403 return err; 404 405 } 406 407 /* Deregister and remove a LM78 client */ 408 int lm78_detach_isa(struct isa_client *client) 409 { 410 int err,i; 411 for (i = 0; i < MAX_LM78_NR; i++) 412 if ((client == (struct isa_client *) (lm78_list[i]))) 413 break; 414 if (i == MAX_LM78_NR) { 415 printk("lm78.o: Client to detach not found.\n"); 416 return -ENOENT; 417 } 418 419 sensors_deregister_entry(((struct lm78_data *)(client->data))->sysctl_id); 420 421 if ((err = isa_detach_client(client))) { 422 printk("lm78.o: Client deregistration failed, client not detached.\n"); 423 return err; 424 } 425 lm78_remove_client((struct i2c_client *) client); 426 release_region(client->isa_addr,LM78_EXTENT); 427 kfree(client); 428 return 0; 429 } 430 431 int lm78_detect_smbus(struct i2c_adapter *adapter) 432 { 433 int address,err; 434 struct i2c_client *new_client; 435 enum lm78_type type; 436 const char *type_name,*client_name; 437 438 /* OK, this is no detection. I know. It will do for now, though. */ 439 err = 0; 440 for (address = 0x20; (! err) && (address <= 0x2f); address ++) { 441 442 /* Later on, we will keep a list of registered addresses for each 443 adapter, and check whether they are used here */ 444 445 if (smbus_read_byte_data(adapter,address,LM78_REG_CONFIG) == 0xff) 446 continue; 447 448 /* Real detection code goes here */ 449 450 /* Determine exact type */ 451 err = smbus_read_byte_data(adapter,address,LM78_REG_CHIPID); 452 if (err == 0x00) { 453 type = lm78; 454 type_name = "lm78"; 455 client_name = "LM78 chip"; 456 } else if (err == 0x40) { 457 type = lm78j; 458 type_name = "lm78-j"; 459 client_name = "LM78-J chip"; 460 } else if (err == 0x80) { 461 type = lm79; 462 type_name = "lm79"; 463 client_name = "LM79 chip"; 464 } else 465 continue; 471 } 466 472 467 473
