Changeset 3180
- Timestamp:
- 11/05/05 20:45:58 (8 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/kernel/chips/lm90.c (modified) (27 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/lm90.c
r3179 r3180 160 160 (val) >= 31 ? 31 : (val)) 161 161 162 /* 162 /* 163 163 * ADT7461 is almost identical to LM90 except that attempts to write 164 164 * values that are outside the range 0 < temp < 127 are treated as 165 * the boundary value. 165 * the boundary value. 166 166 */ 167 167 … … 212 212 */ 213 213 214 struct lm90_data 215 { 214 struct lm90_data { 216 215 struct i2c_client client; 217 216 int sysctl_id; … … 285 284 err = i2c_smbus_read_byte_data(client, reg); 286 285 287 if (err < 0) 288 { 289 printk("lm90.o: Register 0x%02x read failed (%d)\n", 286 if (err < 0) { 287 printk(KERN_WARNING "lm90: Register 0x%02x read failed (%d)\n", 290 288 reg, err); 291 289 return err; … … 314 312 const char *client_name = ""; 315 313 314 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) { 316 315 #ifdef DEBUG 317 if (i2c_is_isa_adapter(adapter)) 318 { 319 printk("lm90.o: Called for an ISA bus adapter, aborting.\n"); 320 return 0; 321 } 322 #endif 323 324 if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA)) 325 { 326 #ifdef DEBUG 327 printk("lm90.o: I2C bus doesn't support byte read mode, " 328 "skipping.\n"); 316 printk(KERN_DEBUG "lm90: adapter doesn't support byte mode, " 317 "skipping\n"); 329 318 #endif 330 319 return 0; 331 320 } 332 321 333 if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) 334 { 335 printk("lm90.o: Out of memory in lm90_detect (new_client).\n"); 322 if (!(data = kmalloc(sizeof(struct lm90_data), GFP_KERNEL))) { 323 printk(KERN_ERR "lm90: Out of memory in lm90_detect\n"); 336 324 return -ENOMEM; 337 325 } … … 365 353 kind = lm90; 366 354 367 if (kind < 0) /* detection and identification */ 368 { 355 if (kind < 0) { /* detection and identification */ 369 356 u8 man_id, chip_id, reg_config1, reg_convrate; 370 357 … … 377 364 || lm90_read_reg(new_client, LM90_REG_R_CONVRATE, 378 365 ®_convrate) < 0) 379 goto ERROR1; 380 381 if (man_id == 0x01) /* National Semiconductor */ 382 { 366 goto exit_free; 367 368 if (man_id == 0x01) { /* National Semiconductor */ 383 369 u8 reg_config2; 384 370 385 371 if (lm90_read_reg(new_client, LM90_REG_R_CONFIG2, 386 372 ®_config2) < 0) 387 goto ERROR1;373 goto exit_free; 388 374 389 375 if ((reg_config1 & 0x2A) == 0x00 390 376 && (reg_config2 & 0xF8) == 0x00 391 && reg_convrate <= 0x09) 392 { 377 && reg_convrate <= 0x09) { 393 378 if (address == 0x4C 394 379 && (chip_id & 0xF0) == 0x20) /* LM90 */ … … 400 385 kind = lm99; 401 386 } 402 } 403 else if (man_id == 0x41) /* Analog Devices */ 404 { 387 } else 388 if (man_id == 0x41) { /* Analog Devices */ 405 389 if ((chip_id & 0xF0) == 0x40 /* ADM1032 */ 406 390 && (reg_config1 & 0x3F) == 0x00 … … 410 394 if (chip_id == 0x51 /* ADT7461 */ 411 395 && (reg_config1 & 0x1F) == 0x00 /* check compat mode */ 412 && reg_convrate <= 0x0A) 396 && reg_convrate <= 0x0A) 413 397 kind = adt7461; 414 } 415 else if (man_id == 0x4D) /* Maxim */ 416 { 398 } else 399 if (man_id == 0x4D) { /* Maxim */ 417 400 /* 418 401 * The Maxim variants do NOT have a chip_id register. … … 431 414 } 432 415 433 if (kind <= 0) /* identification failed */ 434 { 435 printk("lm90.o: Unsupported chip.\n"); 436 goto ERROR1; 437 } 438 439 if (kind == lm90) 440 { 416 if (kind <= 0) { /* identification failed */ 417 printk(KERN_INFO "lm90: Unsupported chip\n"); 418 goto exit_free; 419 } 420 421 if (kind == lm90) { 441 422 type_name = "lm90"; 442 423 client_name = "LM90 chip"; 443 } 444 else if (kind == adm1032) 445 { 424 } else if (kind == adm1032) { 446 425 type_name = "adm1032"; 447 426 client_name = "ADM1032 chip"; 448 } 449 else if (kind == lm99) 450 { 427 } else if (kind == lm99) { 451 428 type_name = "lm99"; 452 429 client_name = "LM99 chip"; 453 } 454 else if (kind == lm86) 455 { 430 } else if (kind == lm86) { 456 431 type_name = "lm86"; 457 432 client_name = "LM86 chip"; 458 } 459 else if (kind == max6657) 460 { 433 } else if (kind == max6657) { 461 434 type_name = "max6657"; 462 435 client_name = "MAX6657 chip"; 463 } 464 else if (kind == adt7461) 465 { 436 } else if (kind == adt7461) { 466 437 type_name = "adt7461"; 467 438 client_name = "ADT7561 chip"; 468 } 469 else 470 { 471 printk("lm90.o: Unknown kind %d.\n", kind); 472 goto ERROR1; 439 } else { 440 printk(KERN_ERR "lm90: Unknown kind %d\n", kind); 441 goto exit_free; 473 442 } 474 443 … … 487 456 */ 488 457 489 if ((err = i2c_attach_client(new_client))) 490 { 491 #ifdef DEBUG 492 printk("lm90.o: Failed attaching client.\n"); 493 #endif 494 goto ERROR1; 458 if ((err = i2c_attach_client(new_client))) { 459 printk(KERN_ERR "lm90: Failed to attach client (%d)\n", err); 460 goto exit_free; 495 461 } 496 462 … … 500 466 501 467 if ((err = i2c_register_entry(new_client, type_name, 502 lm90_dir_table_template, THIS_MODULE)) < 0) 503 { 504 #ifdef DEBUG 505 printk("lm90.o: Failed registering directory entry.\n"); 506 #endif 507 goto ERROR2; 468 lm90_dir_table_template, THIS_MODULE)) < 0) { 469 printk(KERN_ERR "lm90: Failed to register directory entry " 470 "(%d)\n", err); 471 goto exit_detach; 508 472 } 509 473 data->sysctl_id = err; … … 516 480 return 0; 517 481 518 ERROR2:482 exit_detach: 519 483 i2c_detach_client(new_client); 520 ERROR1:484 exit_free: 521 485 kfree(data); 522 486 return err; … … 533 497 i2c_smbus_write_byte_data(client, LM90_REG_W_CONVRATE, 534 498 5); /* 2 Hz */ 535 if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) 536 { 537 printk("lm90.o: Initialization failed!\n"); 499 if (lm90_read_reg(client, LM90_REG_R_CONFIG1, &config) < 0) { 500 printk(KERN_ERR "lm90: Initialization failed!\n"); 538 501 return; 539 502 } … … 549 512 550 513 i2c_deregister_entry(((struct lm90_data *) (client->data))->sysctl_id); 551 if ((err = i2c_detach_client(client))) 552 { 553 printk("lm90.o: Client deregistration failed, client not " 554 "detached.\n"); 514 if ((err = i2c_detach_client(client))) { 515 printk(KERN_ERR "lm90: Client deregistration failed, client " 516 "not detached (%d)\n", err); 555 517 return err; 556 518 } … … 567 529 568 530 if ((jiffies - data->last_updated > HZ * 2) || 569 (jiffies < data->last_updated) || !data->valid) 570 { 531 (jiffies < data->last_updated) || !data->valid) { 571 532 u8 oldh, newh, l; 572 533 #ifdef DEBUG 573 printk( "lm90.o: Updating data.\n");534 printk(KERN_DEBUG "lm90: Updating register values\n"); 574 535 #endif 575 536 … … 631 592 if (operation == SENSORS_PROC_REAL_INFO) 632 593 *nrels_mag = 0; /* magnitude */ 633 else if (operation == SENSORS_PROC_REAL_READ) 634 { 594 else if (operation == SENSORS_PROC_REAL_READ) { 635 595 lm90_update_client(client); 636 596 results[0] = TEMP1_FROM_REG(data->local_high); … … 638 598 results[2] = TEMP1_FROM_REG(data->local_temp); 639 599 *nrels_mag = 3; 640 } 641 else if (operation == SENSORS_PROC_REAL_WRITE) 642 { 643 if (*nrels_mag >= 1) 644 { 600 } else if (operation == SENSORS_PROC_REAL_WRITE) { 601 if (*nrels_mag >= 1) { 645 602 if (data->kind == adt7461) 646 603 data->local_high = TEMP1_TO_REG_ADT7461(results[0]); … … 650 607 data->local_high); 651 608 } 652 if (*nrels_mag >= 2) 653 { 609 if (*nrels_mag >= 2) { 654 610 if (data->kind == adt7461) 655 611 data->local_low = TEMP1_TO_REG_ADT7461(results[1]); … … 669 625 if (operation == SENSORS_PROC_REAL_INFO) 670 626 *nrels_mag = 1; /* magnitude */ 671 else if (operation == SENSORS_PROC_REAL_READ) 672 { 627 else if (operation == SENSORS_PROC_REAL_READ) { 673 628 lm90_update_client(client); 674 629 results[0] = TEMP2_FROM_REG(data->remote_high); … … 676 631 results[2] = TEMP2_FROM_REG(data->remote_temp); 677 632 *nrels_mag = 3; 678 } 679 else if (operation == SENSORS_PROC_REAL_WRITE) 680 { 681 if (*nrels_mag >= 1) 682 { 633 } else if (operation == SENSORS_PROC_REAL_WRITE) { 634 if (*nrels_mag >= 1) { 683 635 if (data->kind == adt7461) 684 636 data->remote_high = TEMP2_TO_REG_ADT7461(results[0]); 685 else 637 else 686 638 data->remote_high = TEMP2_TO_REG(results[0]); 687 639 i2c_smbus_write_byte_data(client, LM90_REG_W_REMOTE_HIGHH, … … 690 642 data->remote_high & 0xFF); 691 643 } 692 if (*nrels_mag >= 2) 693 { 644 if (*nrels_mag >= 2) { 694 645 if (data->kind == adt7461) 695 646 data->remote_low = TEMP2_TO_REG_ADT7461(results[1]); 696 else 647 else 697 648 data->remote_low = TEMP2_TO_REG(results[1]); 698 649 i2c_smbus_write_byte_data(client, LM90_REG_W_REMOTE_LOWH, … … 711 662 if (operation == SENSORS_PROC_REAL_INFO) 712 663 *nrels_mag = 0; /* magnitude */ 713 else if (operation == SENSORS_PROC_REAL_READ) 714 { 664 else if (operation == SENSORS_PROC_REAL_READ) { 715 665 lm90_update_client(client); 716 666 results[0] = TEMP1_FROM_REG(data->local_crit); 717 667 *nrels_mag = 1; 718 } 719 else if (operation == SENSORS_PROC_REAL_WRITE) 720 { 721 if (*nrels_mag >= 1) 722 { 668 } else if (operation == SENSORS_PROC_REAL_WRITE) { 669 if (*nrels_mag >= 1) { 723 670 if (data->kind == adt7461) 724 671 data->local_crit = TEMP1_TO_REG_ADT7461(results[0]); … … 738 685 if (operation == SENSORS_PROC_REAL_INFO) 739 686 *nrels_mag = 0; /* magnitude */ 740 else if (operation == SENSORS_PROC_REAL_READ) 741 { 687 else if (operation == SENSORS_PROC_REAL_READ) { 742 688 lm90_update_client(client); 743 689 results[0] = TEMP1_FROM_REG(data->remote_crit); 744 690 *nrels_mag = 1; 745 } 746 else if (operation == SENSORS_PROC_REAL_WRITE) 747 { 748 if (*nrels_mag >= 1) 749 { 691 } else if (operation == SENSORS_PROC_REAL_WRITE) { 692 if (*nrels_mag >= 1) { 750 693 if (data->kind == adt7461) 751 694 data->remote_crit = TEMP1_TO_REG_ADT7461(results[0]); … … 780 723 if (operation == SENSORS_PROC_REAL_INFO) 781 724 *nrels_mag = 0; /* magnitude */ 782 else if (operation == SENSORS_PROC_REAL_READ) 783 { 725 else if (operation == SENSORS_PROC_REAL_READ) { 784 726 lm90_update_client(client); 785 727 results[0] = TEMP1_FROM_REG(data->local_crit) - 786 728 TEMP1_FROM_REG(data->hyst); 787 729 *nrels_mag = 1; 788 } 789 else if (operation == SENSORS_PROC_REAL_WRITE) 790 { 791 if (*nrels_mag >= 1) 792 { 730 } else if (operation == SENSORS_PROC_REAL_WRITE) { 731 if (*nrels_mag >= 1) { 793 732 data->hyst = HYST_TO_REG(data->local_crit - results[0]); 794 733 i2c_smbus_write_byte_data(client, LM90_REG_W_TCRIT_HYST, … … 805 744 if (operation == SENSORS_PROC_REAL_INFO) 806 745 *nrels_mag = 0; /* magnitude */ 807 else if (operation == SENSORS_PROC_REAL_READ) 808 { 746 else if (operation == SENSORS_PROC_REAL_READ) { 809 747 lm90_update_client(client); 810 748 results[0] = TEMP1_FROM_REG(data->remote_crit) - … … 821 759 if (operation == SENSORS_PROC_REAL_INFO) 822 760 *nrels_mag = 0; /* magnitude */ 823 else if (operation == SENSORS_PROC_REAL_READ) 824 { 761 else if (operation == SENSORS_PROC_REAL_READ) { 825 762 lm90_update_client(client); 826 763 results[0] = data->alarms; … … 831 768 static int __init sm_lm90_init(void) 832 769 { 833 printk(KERN_INFO "lm90.o version %s (%s)\n", LM_VERSION, LM_DATE); 770 printk(KERN_INFO "lm90 driver version %s (%s)\n", LM_VERSION, 771 LM_DATE); 834 772 return i2c_add_driver(&lm90_driver); 835 773 }
