Changeset 952
- Timestamp:
- 12/16/00 16:42:02 (12 years ago)
- Files:
-
- 1 modified
-
lm-sensors/trunk/kernel/chips/lm87.c (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lm-sensors/trunk/kernel/chips/lm87.c
r933 r952 1 1 /* 2 LM87.c - Part of lm_sensors, Linux kernel modules for hardware2 lm87.c - Part of lm_sensors, Linux kernel modules for hardware 3 3 monitoring 4 4 Copyright (c) 2000 Frodo Looijaard <frodol@dds.nl> … … 54 54 55 55 /* Insmod parameters */ 56 SENSORS_INSMOD_1( LM87);56 SENSORS_INSMOD_1(lm87); 57 57 58 58 /* The following is the calculation for the register offset … … 85 85 /* These are all read-only */ 86 86 #define LM87_REG_2_5V_EXT_TEMP_2 0x20 /* front ambient for us */ 87 #define LM87_REG_VCCP1 0x21 /* this will beCPU core voltage */87 #define LM87_REG_VCCP1 0x21 /* CPU core voltage */ 88 88 #define LM87_REG_3_3V 0x22 89 89 #define LM87_REG_5V 0x23 … … 239 239 dynamically allocated, at the same time when a new LM87 client is 240 240 allocated. */ 241 struct LM87_data {241 struct lm87_data { 242 242 int sysctl_id; 243 243 enum chips type; … … 273 273 extern 274 274 #endif 275 int __init sensors_ LM87_init(void);276 static int __init LM87_cleanup(void);277 278 static int LM87_attach_adapter(struct i2c_adapter *adapter);279 static int LM87_detect(struct i2c_adapter *adapter, int address,275 int __init sensors_lm87_init(void); 276 static int __init lm87_cleanup(void); 277 278 static int lm87_attach_adapter(struct i2c_adapter *adapter); 279 static int lm87_detect(struct i2c_adapter *adapter, int address, 280 280 unsigned short flags, int kind); 281 static int LM87_detach_client(struct i2c_client *client);282 static int LM87_command(struct i2c_client *client, unsigned int cmd,281 static int lm87_detach_client(struct i2c_client *client); 282 static int lm87_command(struct i2c_client *client, unsigned int cmd, 283 283 void *arg); 284 static void LM87_inc_use(struct i2c_client *client);285 static void LM87_dec_use(struct i2c_client *client);286 287 static int LM87_read_value(struct i2c_client *client, u8 register);288 static int LM87_write_value(struct i2c_client *client, u8 register,284 static void lm87_inc_use(struct i2c_client *client); 285 static void lm87_dec_use(struct i2c_client *client); 286 287 static int lm87_read_value(struct i2c_client *client, u8 register); 288 static int lm87_write_value(struct i2c_client *client, u8 register, 289 289 u8 value); 290 static void LM87_update_client(struct i2c_client *client);291 static void LM87_init_client(struct i2c_client *client);292 293 294 static void LM87_in(struct i2c_client *client, int operation,290 static void lm87_update_client(struct i2c_client *client); 291 static void lm87_init_client(struct i2c_client *client); 292 293 294 static void lm87_in(struct i2c_client *client, int operation, 295 295 int ctl_name, int *nrels_mag, long *results); 296 static void LM87_fan(struct i2c_client *client, int operation,296 static void lm87_fan(struct i2c_client *client, int operation, 297 297 int ctl_name, int *nrels_mag, long *results); 298 static void LM87_temp(struct i2c_client *client, int operation,298 static void lm87_temp(struct i2c_client *client, int operation, 299 299 int ctl_name, int *nrels_mag, long *results); 300 static void LM87_alarms(struct i2c_client *client, int operation,300 static void lm87_alarms(struct i2c_client *client, int operation, 301 301 int ctl_name, int *nrels_mag, long *results); 302 static void LM87_fan_div(struct i2c_client *client, int operation,302 static void lm87_fan_div(struct i2c_client *client, int operation, 303 303 int ctl_name, int *nrels_mag, long *results); 304 static void LM87_analog_out(struct i2c_client *client, int operation,304 static void lm87_analog_out(struct i2c_client *client, int operation, 305 305 int ctl_name, int *nrels_mag, 306 306 long *results); 307 static void LM87_vid(struct i2c_client *client, int operation,307 static void lm87_vid(struct i2c_client *client, int operation, 308 308 int ctl_name, int *nrels_mag, long *results); 309 309 … … 311 311 allocation could also be used; the code needed for this would probably 312 312 take more memory than the datastructure takes now. */ 313 static int LM87_id = 0;314 315 static struct i2c_driver LM87_driver = {313 static int lm87_id = 0; 314 315 static struct i2c_driver lm87_driver = { 316 316 /* name */ "LM87 sensor driver", 317 317 /* id */ I2C_DRIVERID_LM87, 318 318 /* flags */ I2C_DF_NOTIFY, 319 /* attach_adapter */ & LM87_attach_adapter,320 /* detach_client */ & LM87_detach_client,321 /* command */ & LM87_command,322 /* inc_use */ & LM87_inc_use,323 /* dec_use */ & LM87_dec_use319 /* attach_adapter */ &lm87_attach_adapter, 320 /* detach_client */ &lm87_detach_client, 321 /* command */ &lm87_command, 322 /* inc_use */ &lm87_inc_use, 323 /* dec_use */ &lm87_dec_use 324 324 }; 325 325 326 /* Used by LM87_init/cleanup */327 static int __initdata LM87_initialized = 0;326 /* Used by lm87_init/cleanup */ 327 static int __initdata lm87_initialized = 0; 328 328 329 329 /* The /proc/sys entries */ … … 334 334 when a new copy is allocated. */ 335 335 336 static ctl_table LM87_dir_table_template[] = { 337 {LM87_SYSCTL_IN0, "2.5V", NULL, 0, 0644, NULL, &sensors_proc_real, 338 &sensors_sysctl_real, NULL, &LM87_in}, 339 {LM87_SYSCTL_IN1, "cpu_volt", NULL, 0, 0644, NULL, &sensors_proc_real, 340 &sensors_sysctl_real, NULL, &LM87_in}, 341 {LM87_SYSCTL_IN2, "3.3V", NULL, 0, 0644, NULL, &sensors_proc_real, 342 &sensors_sysctl_real, NULL, &LM87_in}, 343 {LM87_SYSCTL_IN3, "5V", NULL, 0, 0644, NULL, &sensors_proc_real, 344 &sensors_sysctl_real, NULL, &LM87_in}, 345 {LM87_SYSCTL_IN4, "12V", NULL, 0, 0644, NULL, &sensors_proc_real, 346 &sensors_sysctl_real, NULL, &LM87_in}, 347 {LM87_SYSCTL_IN5, "Vccp2", NULL, 0, 0644, NULL, &sensors_proc_real, 348 &sensors_sysctl_real, NULL, &LM87_in}, 349 {LM87_SYSCTL_FAN, "fan", NULL, 0, 0644, NULL, &sensors_proc_real, 350 &sensors_sysctl_real, NULL, &LM87_fan}, 351 {LM87_SYSCTL_FRNT_TEMP, "front_amb_temp", NULL, 0, 0644, NULL, &sensors_proc_real, 352 &sensors_sysctl_real, NULL, &LM87_temp}, 353 {LM87_SYSCTL_CPU_TEMP, "cpu_temp", NULL, 0, 0644, NULL, &sensors_proc_real, 354 &sensors_sysctl_real, NULL, &LM87_temp}, 355 {LM87_SYSCTL_INT_TEMP, "int_temp", NULL, 0, 0644, NULL, &sensors_proc_real, 356 &sensors_sysctl_real, NULL, &LM87_temp}, 357 {LM87_SYSCTL_FAN_DIV, "fan_div", NULL, 0, 0644, NULL, &sensors_proc_real, 358 &sensors_sysctl_real, NULL, &LM87_fan_div}, 336 static ctl_table lm87_dir_table_template[] = { 337 {LM87_SYSCTL_IN0, "in0", NULL, 0, 0644, NULL, &sensors_proc_real, 338 &sensors_sysctl_real, NULL, &lm87_in}, 339 {LM87_SYSCTL_IN1, "in1", NULL, 0, 0644, NULL, &sensors_proc_real, 340 &sensors_sysctl_real, NULL, &lm87_in}, 341 {LM87_SYSCTL_IN2, "in2", NULL, 0, 0644, NULL, &sensors_proc_real, 342 &sensors_sysctl_real, NULL, &lm87_in}, 343 {LM87_SYSCTL_IN3, "in3", NULL, 0, 0644, NULL, &sensors_proc_real, 344 &sensors_sysctl_real, NULL, &lm87_in}, 345 {LM87_SYSCTL_IN4, "in4", NULL, 0, 0644, NULL, &sensors_proc_real, 346 &sensors_sysctl_real, NULL, &lm87_in}, 347 {LM87_SYSCTL_IN5, "in5", NULL, 0, 0644, NULL, &sensors_proc_real, 348 &sensors_sysctl_real, NULL, &lm87_in}, 349 {LM87_SYSCTL_FAN, "fan1", NULL, 0, 0644, NULL, &sensors_proc_real, 350 &sensors_sysctl_real, NULL, &lm87_fan}, 351 {LM87_SYSCTL_FRNT_TEMP, "temp1", NULL, 352 0, 0644, NULL, &sensors_proc_real, 353 &sensors_sysctl_real, NULL, &lm87_temp}, 354 {LM87_SYSCTL_CPU_TEMP, "temp2", NULL, 0, 0644, NULL, &sensors_proc_real, 355 &sensors_sysctl_real, NULL, &lm87_temp}, 356 {LM87_SYSCTL_INT_TEMP, "temp3", NULL, 0, 0644, NULL, &sensors_proc_real, 357 &sensors_sysctl_real, NULL, &lm87_temp}, 358 {LM87_SYSCTL_FAN_DIV, "fan_div", NULL, 359 0, 0644, NULL, &sensors_proc_real, 360 &sensors_sysctl_real, NULL, &lm87_fan_div}, 359 361 {LM87_SYSCTL_ALARMS, "alarms", NULL, 0, 0444, NULL, &sensors_proc_real, 360 &sensors_sysctl_real, NULL, &LM87_alarms}, 361 {LM87_SYSCTL_ANALOG_OUT, "analog_out", NULL, 0, 0644, NULL, &sensors_proc_real, 362 &sensors_sysctl_real, NULL, &LM87_analog_out}, 362 &sensors_sysctl_real, NULL, &lm87_alarms}, 363 {LM87_SYSCTL_ANALOG_OUT, "analog_out", NULL, 364 0, 0644, NULL, &sensors_proc_real, 365 &sensors_sysctl_real, NULL, &lm87_analog_out}, 363 366 {LM87_SYSCTL_VID, "vid", NULL, 0, 0444, NULL, &sensors_proc_real, 364 &sensors_sysctl_real, NULL, & LM87_vid},367 &sensors_sysctl_real, NULL, &lm87_vid}, 365 368 {0} 366 369 }; 367 370 368 int LM87_attach_adapter(struct i2c_adapter *adapter)371 int lm87_attach_adapter(struct i2c_adapter *adapter) 369 372 { 370 373 int error; … … 379 382 lm87_client_data.force = addr_data.forces->force; 380 383 381 error = i2c_probe(adapter, &lm87_client_data, LM87_detect);382 sensors_detect(adapter, &addr_data, LM87_detect);384 error = i2c_probe(adapter, &lm87_client_data, lm87_detect); 385 sensors_detect(adapter, &addr_data, lm87_detect); 383 386 384 387 return error; 385 388 } 386 389 387 static int LM87_detect(struct i2c_adapter *adapter, int address,390 static int lm87_detect(struct i2c_adapter *adapter, int address, 388 391 unsigned short flags, int kind) 389 392 { 390 393 int i; 391 394 struct i2c_client *new_client; 392 struct LM87_data *data;395 struct lm87_data *data; 393 396 int err = 0; 394 397 const char *type_name = ""; … … 403 406 404 407 if (!(new_client = kmalloc(sizeof(struct i2c_client) + 405 sizeof(struct LM87_data),408 sizeof(struct lm87_data), 406 409 GFP_KERNEL))) { 407 410 err = -ENOMEM; … … 409 412 } 410 413 411 data = (struct LM87_data *) (new_client + 1);414 data = (struct lm87_data *) (new_client + 1); 412 415 new_client->addr = address; 413 416 new_client->data = data; 414 417 new_client->adapter = adapter; 415 new_client->driver = & LM87_driver;418 new_client->driver = &lm87_driver; 416 419 new_client->flags = 0; 417 420 … … 419 422 420 423 if (kind < 0) { 421 if (( LM87_read_value(new_client, LM87_REG_CONFIG) & 0x80) != 0x00)424 if ((lm87_read_value(new_client, LM87_REG_CONFIG) & 0x80) != 0x00) 422 425 goto ERROR1; 423 426 } 424 427 425 /* Fill in the remaining client fields and put i t into the global list */426 type_name = " LM87";428 /* Fill in the remaining client fields and put into the global list */ 429 type_name = "lm87"; 427 430 client_name = "LM87 chip"; 428 431 strcpy(new_client->name, client_name); 429 432 data->type = kind; 430 433 431 new_client->id = LM87_id++;434 new_client->id = lm87_id++; 432 435 data->valid = 0; 433 436 init_MUTEX(&data->update_lock); … … 440 443 if ((i = sensors_register_entry(new_client, 441 444 type_name, 442 LM87_dir_table_template,445 lm87_dir_table_template, 443 446 THIS_MODULE)) < 0) { 444 447 err = i; … … 448 451 449 452 /* Initialize the LM87 chip */ 450 LM87_init_client(new_client);453 lm87_init_client(new_client); 451 454 return 0; 452 455 … … 463 466 } 464 467 465 int LM87_detach_client(struct i2c_client *client)468 int lm87_detach_client(struct i2c_client *client) 466 469 { 467 470 int err; 468 471 469 sensors_deregister_entry(((struct LM87_data *) (client->data))->472 sensors_deregister_entry(((struct lm87_data *) (client->data))-> 470 473 sysctl_id); 471 474 472 475 if ((err = i2c_detach_client(client))) { 473 476 printk 474 ("LM87.o: Client deregistration failed, client not detached.\n");477 ("lm87.o: Client deregistration failed, client not detached.\n"); 475 478 return err; 476 479 } … … 483 486 484 487 /* No commands defined yet */ 485 int LM87_command(struct i2c_client *client, unsigned int cmd, void *arg)488 int lm87_command(struct i2c_client *client, unsigned int cmd, void *arg) 486 489 { 487 490 return 0; 488 491 } 489 492 490 void LM87_inc_use(struct i2c_client *client)493 void lm87_inc_use(struct i2c_client *client) 491 494 { 492 495 #ifdef MODULE … … 495 498 } 496 499 497 void LM87_dec_use(struct i2c_client *client)500 void lm87_dec_use(struct i2c_client *client) 498 501 { 499 502 #ifdef MODULE … … 502 505 } 503 506 504 int LM87_read_value(struct i2c_client *client, u8 reg)507 int lm87_read_value(struct i2c_client *client, u8 reg) 505 508 { 506 509 return 0xFF & i2c_smbus_read_byte_data(client, reg); 507 510 } 508 511 509 int LM87_write_value(struct i2c_client *client, u8 reg, u8 value)512 int lm87_write_value(struct i2c_client *client, u8 reg, u8 value) 510 513 { 511 514 return i2c_smbus_write_byte_data(client, reg, value); … … 513 516 514 517 /* Called when we have found a new LM87. It should set limits, etc. */ 515 void LM87_init_client(struct i2c_client *client)518 void lm87_init_client(struct i2c_client *client) 516 519 { 517 520 /* Reset all except Watchdog values and last conversion values 518 521 This sets fan-divs to 2, among others. This makes most other 519 522 initializations unnecessary */ 520 LM87_write_value(client, LM87_REG_CONFIG, 0x80);523 lm87_write_value(client, LM87_REG_CONFIG, 0x80); 521 524 522 525 /* Setup Channel Mode register for configuration of monitoring … … 524 527 * bit 2 - Configures 2.5V/D2 input (1 = 2nd Therm.) 525 528 */ 526 LM87_write_value(client, LM87_REG_CHANNEL_MODE, 0x05);527 528 529 LM87_write_value(client, LM87_REG_IN_MIN(1),529 lm87_write_value(client, LM87_REG_CHANNEL_MODE, 0x05); 530 531 532 lm87_write_value(client, LM87_REG_IN_MIN(1), 530 533 IN_TO_REG(LM87_INIT_IN_MIN_1, 1)); 531 LM87_write_value(client, LM87_REG_IN_MAX(1),534 lm87_write_value(client, LM87_REG_IN_MAX(1), 532 535 IN_TO_REG(LM87_INIT_IN_MAX_1, 1)); 533 LM87_write_value(client, LM87_REG_IN_MIN(2),536 lm87_write_value(client, LM87_REG_IN_MIN(2), 534 537 IN_TO_REG(LM87_INIT_IN_MIN_2, 2)); 535 LM87_write_value(client, LM87_REG_IN_MAX(2),538 lm87_write_value(client, LM87_REG_IN_MAX(2), 536 539 IN_TO_REG(LM87_INIT_IN_MAX_2, 2)); 537 LM87_write_value(client, LM87_REG_IN_MIN(3),540 lm87_write_value(client, LM87_REG_IN_MIN(3), 538 541 IN_TO_REG(LM87_INIT_IN_MIN_3, 3)); 539 LM87_write_value(client, LM87_REG_IN_MAX(3),542 lm87_write_value(client, LM87_REG_IN_MAX(3), 540 543 IN_TO_REG(LM87_INIT_IN_MAX_3, 3)); 541 LM87_write_value(client, LM87_REG_IN_MIN(4),544 lm87_write_value(client, LM87_REG_IN_MIN(4), 542 545 IN_TO_REG(LM87_INIT_IN_MIN_4, 4)); 543 LM87_write_value(client, LM87_REG_IN_MAX(4),546 lm87_write_value(client, LM87_REG_IN_MAX(4), 544 547 IN_TO_REG(LM87_INIT_IN_MAX_4, 4)); 545 LM87_write_value(client, LM87_REG_IN_MIN(5),548 lm87_write_value(client, LM87_REG_IN_MIN(5), 546 549 IN_TO_REG(LM87_INIT_IN_MIN_5, 5)); 547 LM87_write_value(client, LM87_REG_IN_MAX(5),550 lm87_write_value(client, LM87_REG_IN_MAX(5), 548 551 IN_TO_REG(LM87_INIT_IN_MAX_5, 5)); 549 552 550 LM87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH,553 lm87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH, 551 554 TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MAX)); 552 LM87_write_value(client, LM87_REG_EXT_TEMP_1_LOW,555 lm87_write_value(client, LM87_REG_EXT_TEMP_1_LOW, 553 556 TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MIN)); 554 LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH,557 lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH, 555 558 TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MAX)); 556 LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW,559 lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW, 557 560 TEMP_LIMIT_TO_REG(LM87_INIT_EXT_TEMP_MIN)); 558 LM87_write_value(client, LM87_REG_INT_TEMP_HIGH,561 lm87_write_value(client, LM87_REG_INT_TEMP_HIGH, 559 562 TEMP_LIMIT_TO_REG(LM87_INIT_INT_TEMP_MAX)); 560 LM87_write_value(client, LM87_REG_INT_TEMP_LOW,563 lm87_write_value(client, LM87_REG_INT_TEMP_LOW, 561 564 TEMP_LIMIT_TO_REG(LM87_INIT_INT_TEMP_MIN)); 562 565 563 LM87_write_value(client, LM87_REG_FAN1_AIN1_LIMIT,566 lm87_write_value(client, LM87_REG_FAN1_AIN1_LIMIT, 564 567 IN_TO_REG(LM87_INIT_IN_MAX_0, 0)); 565 568 566 LM87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT,569 lm87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT, 567 570 FAN_TO_REG(LM87_INIT_FAN_MIN, 2)); 568 571 569 572 /* Start monitoring */ 570 LM87_write_value(client, LM87_REG_CONFIG, 0x01);571 } 572 573 void LM87_update_client(struct i2c_client *client)574 { 575 struct LM87_data *data = client->data;573 lm87_write_value(client, LM87_REG_CONFIG, 0x01); 574 } 575 576 void lm87_update_client(struct i2c_client *client) 577 { 578 struct lm87_data *data = client->data; 576 579 u8 i; 577 580 … … 587 590 for (i = 0; i <= 5; i++) { 588 591 /* Since we are using AIN 1 as our 2.5V monitoring, need to 589 * accomodate with a hardcode register address and we only get 592 * accomodate with a hardcode 593 * register address and we only get 590 594 * to look at one threshold. 591 595 */ 592 596 if (i == 0) { 593 597 data->in[i] = 594 LM87_read_value(client, LM87_REG_FAN1_AIN1);598 lm87_read_value(client, LM87_REG_FAN1_AIN1); 595 599 data->in_min[i] = 0; 596 600 data->in_max[i] = 597 LM87_read_value(client, LM87_REG_FAN1_AIN1_LIMIT);601 lm87_read_value(client, LM87_REG_FAN1_AIN1_LIMIT); 598 602 } 599 603 else { 600 604 data->in[i] = 601 LM87_read_value(client, LM87_REG_IN(i));605 lm87_read_value(client, LM87_REG_IN(i)); 602 606 data->in_min[i] = 603 LM87_read_value(client,607 lm87_read_value(client, 604 608 LM87_REG_IN_MIN(i)); 605 609 data->in_max[i] = 606 LM87_read_value(client,610 lm87_read_value(client, 607 611 LM87_REG_IN_MAX(i)); 608 612 } … … 610 614 611 615 data->fan = 612 LM87_read_value(client, LM87_REG_FAN2_AIN2);616 lm87_read_value(client, LM87_REG_FAN2_AIN2); 613 617 data->fan_min = 614 LM87_read_value(client, LM87_REG_FAN2_AIN2_LIMIT);618 lm87_read_value(client, LM87_REG_FAN2_AIN2_LIMIT); 615 619 616 620 data->front_amb_temp = 617 LM87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2);621 lm87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2); 618 622 data->cpu_temp = 619 LM87_read_value(client, LM87_REG_EXT_TEMP_1);623 lm87_read_value(client, LM87_REG_EXT_TEMP_1); 620 624 data->int_temp = 621 LM87_read_value(client, LM87_REG_INT_TEMP);625 lm87_read_value(client, LM87_REG_INT_TEMP); 622 626 623 627 data->front_amb_temp_max = 624 LM87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH);628 lm87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH); 625 629 data->front_amb_temp_min = 626 LM87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW);630 lm87_read_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW); 627 631 628 632 data->cpu_temp_max = 629 LM87_read_value(client, LM87_REG_EXT_TEMP_1_HIGH);633 lm87_read_value(client, LM87_REG_EXT_TEMP_1_HIGH); 630 634 data->cpu_temp_min = 631 LM87_read_value(client, LM87_REG_EXT_TEMP_1_LOW);635 lm87_read_value(client, LM87_REG_EXT_TEMP_1_LOW); 632 636 633 637 data->int_temp_max = 634 LM87_read_value(client, LM87_REG_INT_TEMP_HIGH);638 lm87_read_value(client, LM87_REG_INT_TEMP_HIGH); 635 639 data->int_temp_min = 636 LM87_read_value(client, LM87_REG_INT_TEMP_LOW);637 638 i = LM87_read_value(client, LM87_REG_VID_FAN_DIV);640 lm87_read_value(client, LM87_REG_INT_TEMP_LOW); 641 642 i = lm87_read_value(client, LM87_REG_VID_FAN_DIV); 639 643 data->fan_div = (i >> 4) & 0x03; 640 644 data->vid = i & 0x0f; 641 645 data->vid |= 642 ( LM87_read_value(client, LM87_REG_VID4) & 0x01)646 (lm87_read_value(client, LM87_REG_VID4) & 0x01) 643 647 << 4; 644 648 645 649 data->alarms = 646 LM87_read_value(client,650 lm87_read_value(client, 647 651 LM87_REG_INT1_STAT) + 648 ( LM87_read_value(client, LM87_REG_INT2_STAT) <<652 (lm87_read_value(client, LM87_REG_INT2_STAT) << 649 653 8); 650 654 data->analog_out = 651 LM87_read_value(client, LM87_REG_ANALOG_OUT);655 lm87_read_value(client, LM87_REG_ANALOG_OUT); 652 656 data->last_updated = jiffies; 653 657 data->valid = 1; … … 671 675 good practice, but as long as you put less than about 5 values in results, 672 676 you can assume it is large enough. */ 673 void LM87_in(struct i2c_client *client, int operation, int ctl_name,677 void lm87_in(struct i2c_client *client, int operation, int ctl_name, 674 678 int *nrels_mag, long *results) 675 679 { … … 682 686 int scales[6] = { 260, 200, 344, 520, 1250, 260 }; 683 687 684 struct LM87_data *data = client->data;688 struct lm87_data *data = client->data; 685 689 int nr = ctl_name - LM87_SYSCTL_IN0; 686 690 … … 688 692 *nrels_mag = 2; 689 693 else if (operation == SENSORS_PROC_REAL_READ) { 690 LM87_update_client(client);694 lm87_update_client(client); 691 695 692 696 results[0] = … … 711 715 data->in_min[nr] = 712 716 IN_TO_REG((results[0] * 192) / scales[nr], nr); 713 LM87_write_value(client, LM87_REG_IN_MIN(nr),717 lm87_write_value(client, LM87_REG_IN_MIN(nr), 714 718 data->in_min[nr]); 715 719 } … … 717 721 data->in_max[nr] = 718 722 IN_TO_REG((results[1] * 192) / scales[nr], nr); 719 LM87_write_value(client, LM87_REG_IN_MAX(nr),723 lm87_write_value(client, LM87_REG_IN_MAX(nr), 720 724 data->in_max[nr]); 721 725 } … … 723 727 } 724 728 725 void LM87_fan(struct i2c_client *client, int operation, int ctl_name,729 void lm87_fan(struct i2c_client *client, int operation, int ctl_name, 726 730 int *nrels_mag, long *results) 727 731 { 728 struct LM87_data *data = client->data;732 struct lm87_data *data = client->data; 729 733 int nr = ctl_name - LM87_SYSCTL_FAN + 1; /* not sure +1 needed */ 730 734 … … 732 736 *nrels_mag = 0; 733 737 else if (operation == SENSORS_PROC_REAL_READ) { 734 LM87_update_client(client);738 lm87_update_client(client); 735 739 results[0] = FAN_FROM_REG(data->fan_min, 736 740 DIV_FROM_REG(data->fan_div)); … … 743 747 DIV_FROM_REG 744 748 (data->fan_div)); 745 LM87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT,749 lm87_write_value(client, LM87_REG_FAN2_AIN2_LIMIT, 746 750 data->fan_min); 747 751 } … … 750 754 751 755 752 void LM87_temp(struct i2c_client *client, int operation, int ctl_name,756 void lm87_temp(struct i2c_client *client, int operation, int ctl_name, 753 757 int *nrels_mag, long *results) 754 758 { 755 struct LM87_data *data = client->data;759 struct lm87_data *data = client->data; 756 760 757 761 if (operation == SENSORS_PROC_REAL_INFO) … … 759 763 else if (operation == SENSORS_PROC_REAL_READ) 760 764 { 761 LM87_update_client(client);765 lm87_update_client(client); 762 766 763 767 /* find out which temp. is being requested */ … … 784 788 if (*nrels_mag >= 1) { 785 789 if (ctl_name == LM87_SYSCTL_FRNT_TEMP) { 786 data->front_amb_temp_max = TEMP_LIMIT_TO_REG(results[0]); 787 LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH, 790 data->front_amb_temp_max = 791 TEMP_LIMIT_TO_REG(results[0]); 792 lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_HIGH, 788 793 data->front_amb_temp_max); 789 794 } 790 795 if (ctl_name == LM87_SYSCTL_CPU_TEMP) { 791 796 data->cpu_temp_max = TEMP_LIMIT_TO_REG(results[0]); 792 LM87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH,797 lm87_write_value(client, LM87_REG_EXT_TEMP_1_HIGH, 793 798 data->int_temp_max); 794 799 } 795 800 if (ctl_name == LM87_SYSCTL_INT_TEMP) { 796 801 data->int_temp_max = TEMP_LIMIT_TO_REG(results[0]); 797 LM87_write_value(client, LM87_REG_INT_TEMP_HIGH,802 lm87_write_value(client, LM87_REG_INT_TEMP_HIGH, 798 803 data->int_temp_max); 799 804 } … … 801 806 if (*nrels_mag >= 2) { 802 807 if (ctl_name == LM87_SYSCTL_FRNT_TEMP) { 803 data->front_amb_temp_min = TEMP_LIMIT_TO_REG(results[0]); 804 LM87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW, 808 data->front_amb_temp_min = 809 TEMP_LIMIT_TO_REG(results[0]); 810 lm87_write_value(client, LM87_REG_2_5V_EXT_TEMP_2_LOW, 805 811 data->front_amb_temp_min); 806 812 } 807 813 if (ctl_name == LM87_SYSCTL_CPU_TEMP) { 808 814 data->cpu_temp_min = TEMP_LIMIT_TO_REG(results[0]); 809 LM87_write_value(client, LM87_REG_EXT_TEMP_1_LOW,815 lm87_write_value(client, LM87_REG_EXT_TEMP_1_LOW, 810 816 data->int_temp_min); 811 817 } 812 818 if (ctl_name == LM87_SYSCTL_INT_TEMP) { 813 819 data->int_temp_min = TEMP_LIMIT_TO_REG(results[1]); 814 LM87_write_value(client, LM87_REG_INT_TEMP_LOW,820 lm87_write_value(client, LM87_REG_INT_TEMP_LOW, 815 821 data->int_temp_min); 816 822 } … … 819 825 } 820 826 821 void LM87_alarms(struct i2c_client *client, int operation, int ctl_name,827 void lm87_alarms(struct i2c_client *client, int operation, int ctl_name, 822 828 int *nrels_mag, long *results) 823 829 { 824 struct LM87_data *data = client->data;830 struct lm87_data *data = client->data; 825 831 if (operation == SENSORS_PROC_REAL_INFO) 826 832 *nrels_mag = 0; 827 833 else if (operation == SENSORS_PROC_REAL_READ) { 828 LM87_update_client(client);834 lm87_update_client(client); 829 835 results[0] = ALARMS_FROM_REG(data->alarms); 830 836 *nrels_mag = 1; … … 832 838 } 833 839 834 void LM87_fan_div(struct i2c_client *client, int operation,840 void lm87_fan_div(struct i2c_client *client, int operation, 835 841 int ctl_name, int *nrels_mag, long *results) 836 842 { 837 struct LM87_data *data = client->data;843 struct lm87_data *data = client->data; 838 844 int old; 839 845 … … 841 847 *nrels_mag = 0; 842 848 else if (operation == SENSORS_PROC_REAL_READ) { 843 LM87_update_client(client);849 lm87_update_client(client); 844 850 results[0] = DIV_FROM_REG(data->fan_div); 845 851 *nrels_mag = 1; 846 852 } else if (operation == SENSORS_PROC_REAL_WRITE) { 847 old = LM87_read_value(client, LM87_REG_VID_FAN_DIV);853 old = lm87_read_value(client, LM87_REG_VID_FAN_DIV); 848 854 if (*nrels_mag >= 2) { 849 855 data->fan_div = DIV_TO_REG(results[1]); … … 853 859 data->fan_div = DIV_TO_REG(results[0]); 854 860 old = (old & 0xcf) | (data->fan_div << 4); 855 LM87_write_value(client, LM87_REG_VID_FAN_DIV, old);861 lm87_write_value(client, LM87_REG_VID_FAN_DIV, old); 856 862 } 857 863 } 858 864 } 859 865 860 void LM87_analog_out(struct i2c_client *client, int operation,866 void lm87_analog_out(struct i2c_client *client, int operation, 861 867 int ctl_name, int *nrels_mag, long *results) 862 868 { 863 struct LM87_data *data = client->data;869 struct lm87_data *data = client->data; 864 870 865 871 if (operation == SENSORS_PROC_REAL_INFO) 866 872 *nrels_mag = 0; 867 873 else if (operation == SENSORS_PROC_REAL_READ) { 868 LM87_update_client(client);874 lm87_update_client(client); 869 875 results[0] = data->analog_out; 870 876 *nrels_mag = 1; … … 872 878 if (*nrels_mag >= 1) { 873 879 data->analog_out = results[0]; 874 LM87_write_value(client, LM87_REG_ANALOG_OUT,880 lm87_write_value(client, LM87_REG_ANALOG_OUT, 875 881 data->analog_out); 876 882 } … … 878 884 } 879 885 880 void LM87_vid(struct i2c_client *client, int operation, int ctl_name,886 void lm87_vid(struct i2c_client *client, int operation, int ctl_name, 881 887 int *nrels_mag, long *results) 882 888 { 883 struct LM87_data *data = client->data;889 struct lm87_data *data = client->data; 884 890 885 891 … … 888 894 else if (operation == SENSORS_PROC_REAL_READ) { 889 895 890 LM87_update_client(client);896 lm87_update_client(client); 891 897 if ((data->vid == 0x1f) || (data->vid == 0x0f)) { 892 898 results[0] = 0; 893 899 } 894 900 else if (data->vid > 0x0f) { 895 results[0] = (1275 - (((data->vid - 0x10) * 1000) * 0.025))/10; 901 results[0] = (1275 - 902 (((data->vid - 0x10) * 1000) * 0.025))/10; 896 903 } 897 904 else { … … 903 910 } 904 911 905 int __init sensors_ LM87_init(void)912 int __init sensors_lm87_init(void) 906 913 { 907 914 int res; 908 915 909 printk(" LM87.o version %s (%s)\n", LM_VERSION, LM_DATE);910 LM87_initialized = 0;911 912 if ((res = i2c_add_driver(& LM87_driver))) {916 printk("lm87.o version %s (%s)\n", LM_VERSION, LM_DATE); 917 lm87_initialized = 0; 918 919 if ((res = i2c_add_driver(&lm87_driver))) { 913 920 printk 914 ("LM87.o: Driver registration failed, module not inserted.\n");915 LM87_cleanup();921 ("lm87.o: Driver registration failed, module not inserted.\n"); 922 lm87_cleanup(); 916 923 return res; 917 924 } 918 LM87_initialized++;925 lm87_initialized++; 919 926 return 0; 920 927 } 921 928 922 int __init LM87_cleanup(void)929 int __init lm87_cleanup(void) 923 930 { 924 931 int res; 925 932 926 if ( LM87_initialized >= 1) {927 if ((res = i2c_del_driver(& LM87_driver))) {933 if (lm87_initialized >= 1) { 934 if ((res = i2c_del_driver(&lm87_driver))) { 928 935 printk 929 ("LM87.o: Driver deregistration failed, module not removed.\n");936 ("lm87.o: Driver deregistration failed, module not removed.\n"); 930 937 return res; 931 938 } 932 LM87_initialized--;939 lm87_initialized--; 933 940 } 934 941 return 0; … … 943 950 and Stephen Rousset <stephen.rousset@rocketlogix.com>"); 944 951 945 MODULE_DESCRIPTION(" LM87 driver");952 MODULE_DESCRIPTION("lm87 driver"); 946 953 947 954 int init_module(void) 948 955 { 949 return sensors_ LM87_init();956 return sensors_lm87_init(); 950 957 } 951 958 952 959 int cleanup_module(void) 953 960 { 954 return LM87_cleanup();961 return lm87_cleanup(); 955 962 } 956 963
