Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/pmac: Convert therm_adt746x to new i2c probing

This simplifies the driver to stop using the deprecated attach interface,

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

+212 -284
+212 -284
drivers/macintosh/therm_adt746x.c
··· 47 47 48 48 static u8 default_limits_local[3] = {70, 50, 70}; /* local, sensor1, sensor2 */ 49 49 static u8 default_limits_chip[3] = {80, 65, 80}; /* local, sensor1, sensor2 */ 50 - static const char *sensor_location[3]; 50 + static const char *sensor_location[3] = { "?", "?", "?" }; 51 51 52 52 static int limit_adjust; 53 53 static int fan_speed = -1; ··· 79 79 int last_speed[2]; 80 80 int last_var[2]; 81 81 int pwm_inv[2]; 82 + struct task_struct *thread; 83 + struct platform_device *pdev; 84 + enum { 85 + ADT7460, 86 + ADT7467 87 + } type; 82 88 }; 83 - 84 - static enum {ADT7460, ADT7467} therm_type; 85 - static int therm_bus, therm_address; 86 - static struct platform_device * of_dev; 87 - static struct thermostat* thermostat; 88 - static struct task_struct *thread_therm = NULL; 89 89 90 90 static void write_both_fan_speed(struct thermostat *th, int speed); 91 91 static void write_fan_speed(struct thermostat *th, int speed, int fan); 92 - static void thermostat_create_files(void); 93 - static void thermostat_remove_files(void); 94 92 95 93 static int 96 94 write_reg(struct thermostat* th, int reg, u8 data) ··· 124 126 return data; 125 127 } 126 128 127 - static struct i2c_driver thermostat_driver; 128 - 129 - static int 130 - attach_thermostat(struct i2c_adapter *adapter) 131 - { 132 - unsigned long bus_no; 133 - struct i2c_board_info info; 134 - struct i2c_client *client; 135 - 136 - if (strncmp(adapter->name, "uni-n", 5)) 137 - return -ENODEV; 138 - bus_no = simple_strtoul(adapter->name + 6, NULL, 10); 139 - if (bus_no != therm_bus) 140 - return -ENODEV; 141 - 142 - memset(&info, 0, sizeof(struct i2c_board_info)); 143 - strlcpy(info.type, "therm_adt746x", I2C_NAME_SIZE); 144 - info.addr = therm_address; 145 - client = i2c_new_device(adapter, &info); 146 - if (!client) 147 - return -ENODEV; 148 - 149 - /* 150 - * Let i2c-core delete that device on driver removal. 151 - * This is safe because i2c-core holds the core_lock mutex for us. 152 - */ 153 - list_add_tail(&client->detected, &thermostat_driver.clients); 154 - return 0; 155 - } 156 - 157 - static int 158 - remove_thermostat(struct i2c_client *client) 159 - { 160 - struct thermostat *th = i2c_get_clientdata(client); 161 - int i; 162 - 163 - thermostat_remove_files(); 164 - 165 - if (thread_therm != NULL) { 166 - kthread_stop(thread_therm); 167 - } 168 - 169 - printk(KERN_INFO "adt746x: Putting max temperatures back from " 170 - "%d, %d, %d to %d, %d, %d\n", 171 - th->limits[0], th->limits[1], th->limits[2], 172 - th->initial_limits[0], th->initial_limits[1], 173 - th->initial_limits[2]); 174 - 175 - for (i = 0; i < 3; i++) 176 - write_reg(th, LIMIT_REG[i], th->initial_limits[i]); 177 - 178 - write_both_fan_speed(th, -1); 179 - 180 - thermostat = NULL; 181 - 182 - kfree(th); 183 - 184 - return 0; 185 - } 186 - 187 129 static int read_fan_speed(struct thermostat *th, u8 addr) 188 130 { 189 131 u8 tmp[2]; ··· 141 203 static void write_both_fan_speed(struct thermostat *th, int speed) 142 204 { 143 205 write_fan_speed(th, speed, 0); 144 - if (therm_type == ADT7460) 206 + if (th->type == ADT7460) 145 207 write_fan_speed(th, speed, 1); 146 208 } 147 209 ··· 154 216 else if (speed < -1) 155 217 speed = 0; 156 218 157 - if (therm_type == ADT7467 && fan == 1) 219 + if (th->type == ADT7467 && fan == 1) 158 220 return; 159 221 160 222 if (th->last_speed[fan] != speed) { ··· 177 239 write_reg(th, FAN_SPD_SET[fan], speed); 178 240 } else { 179 241 /* back to automatic */ 180 - if(therm_type == ADT7460) { 242 + if(th->type == ADT7460) { 181 243 manual = read_reg(th, 182 244 MANUAL_MODE[fan]) & (~MANUAL_MASK); 183 245 manual &= ~INVERT_MASK; ··· 231 293 /* we don't care about local sensor, so we start at sensor 1 */ 232 294 for (i = 1; i < 3; i++) { 233 295 int started = 0; 234 - int fan_number = (therm_type == ADT7460 && i == 2); 296 + int fan_number = (th->type == ADT7460 && i == 2); 235 297 int var = th->temps[i] - th->limits[i]; 236 298 237 299 if (var > -1) { ··· 308 370 309 371 static void set_limit(struct thermostat *th, int i) 310 372 { 311 - /* Set sensor1 limit higher to avoid powerdowns */ 312 - th->limits[i] = default_limits_chip[i] + limit_adjust; 313 - write_reg(th, LIMIT_REG[i], th->limits[i]); 373 + /* Set sensor1 limit higher to avoid powerdowns */ 374 + th->limits[i] = default_limits_chip[i] + limit_adjust; 375 + write_reg(th, LIMIT_REG[i], th->limits[i]); 314 376 315 - /* set our limits to normal */ 316 - th->limits[i] = default_limits_local[i] + limit_adjust; 377 + /* set our limits to normal */ 378 + th->limits[i] = default_limits_local[i] + limit_adjust; 317 379 } 318 380 319 - static int probe_thermostat(struct i2c_client *client, 320 - const struct i2c_device_id *id) 321 - { 322 - struct thermostat* th; 323 - int rc; 324 - int i; 325 - 326 - if (thermostat) 327 - return 0; 328 - 329 - th = kzalloc(sizeof(struct thermostat), GFP_KERNEL); 330 - if (!th) 331 - return -ENOMEM; 332 - 333 - i2c_set_clientdata(client, th); 334 - th->clt = client; 335 - 336 - rc = read_reg(th, CONFIG_REG); 337 - if (rc < 0) { 338 - dev_err(&client->dev, "Thermostat failed to read config!\n"); 339 - kfree(th); 340 - return -ENODEV; 341 - } 342 - 343 - /* force manual control to start the fan quieter */ 344 - if (fan_speed == -1) 345 - fan_speed = 64; 346 - 347 - if(therm_type == ADT7460) { 348 - printk(KERN_INFO "adt746x: ADT7460 initializing\n"); 349 - /* The 7460 needs to be started explicitly */ 350 - write_reg(th, CONFIG_REG, 1); 351 - } else 352 - printk(KERN_INFO "adt746x: ADT7467 initializing\n"); 353 - 354 - for (i = 0; i < 3; i++) { 355 - th->initial_limits[i] = read_reg(th, LIMIT_REG[i]); 356 - set_limit(th, i); 357 - } 358 - 359 - printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d" 360 - " to %d, %d, %d\n", 361 - th->initial_limits[0], th->initial_limits[1], 362 - th->initial_limits[2], th->limits[0], th->limits[1], 363 - th->limits[2]); 364 - 365 - thermostat = th; 366 - 367 - /* record invert bit status because fw can corrupt it after suspend */ 368 - th->pwm_inv[0] = read_reg(th, MANUAL_MODE[0]) & INVERT_MASK; 369 - th->pwm_inv[1] = read_reg(th, MANUAL_MODE[1]) & INVERT_MASK; 370 - 371 - /* be sure to really write fan speed the first time */ 372 - th->last_speed[0] = -2; 373 - th->last_speed[1] = -2; 374 - th->last_var[0] = -80; 375 - th->last_var[1] = -80; 376 - 377 - if (fan_speed != -1) { 378 - /* manual mode, stop fans */ 379 - write_both_fan_speed(th, 0); 380 - } else { 381 - /* automatic mode */ 382 - write_both_fan_speed(th, -1); 383 - } 384 - 385 - thread_therm = kthread_run(monitor_task, th, "kfand"); 386 - 387 - if (thread_therm == ERR_PTR(-ENOMEM)) { 388 - printk(KERN_INFO "adt746x: Kthread creation failed\n"); 389 - thread_therm = NULL; 390 - return -ENOMEM; 391 - } 392 - 393 - thermostat_create_files(); 394 - 395 - return 0; 396 - } 397 - 398 - static const struct i2c_device_id therm_adt746x_id[] = { 399 - { "therm_adt746x", 0 }, 400 - { } 401 - }; 402 - 403 - static struct i2c_driver thermostat_driver = { 404 - .driver = { 405 - .name = "therm_adt746x", 406 - }, 407 - .attach_adapter = attach_thermostat, 408 - .probe = probe_thermostat, 409 - .remove = remove_thermostat, 410 - .id_table = therm_adt746x_id, 411 - }; 412 - 413 - /* 414 - * Now, unfortunately, sysfs doesn't give us a nice void * we could 415 - * pass around to the attribute functions, so we don't really have 416 - * choice but implement a bunch of them... 417 - * 418 - * FIXME, it does now... 419 - */ 420 381 #define BUILD_SHOW_FUNC_INT(name, data) \ 382 + static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ 383 + { \ 384 + struct thermostat *th = dev_get_drvdata(dev); \ 385 + return sprintf(buf, "%d\n", data); \ 386 + } 387 + 388 + #define BUILD_SHOW_FUNC_INT_LITE(name, data) \ 421 389 static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ 422 390 { \ 423 391 return sprintf(buf, "%d\n", data); \ ··· 338 494 #define BUILD_SHOW_FUNC_FAN(name, data) \ 339 495 static ssize_t show_##name(struct device *dev, struct device_attribute *attr, char *buf) \ 340 496 { \ 497 + struct thermostat *th = dev_get_drvdata(dev); \ 341 498 return sprintf(buf, "%d (%d rpm)\n", \ 342 - thermostat->last_speed[data], \ 343 - read_fan_speed(thermostat, FAN_SPEED[data]) \ 499 + th->last_speed[data], \ 500 + read_fan_speed(th, FAN_SPEED[data]) \ 344 501 ); \ 345 502 } 346 503 347 504 #define BUILD_STORE_FUNC_DEG(name, data) \ 348 505 static ssize_t store_##name(struct device *dev, struct device_attribute *attr, const char *buf, size_t n) \ 349 506 { \ 507 + struct thermostat *th = dev_get_drvdata(dev); \ 350 508 int val; \ 351 509 int i; \ 352 510 val = simple_strtol(buf, NULL, 10); \ 353 511 printk(KERN_INFO "Adjusting limits by %d degrees\n", val); \ 354 512 limit_adjust = val; \ 355 513 for (i=0; i < 3; i++) \ 356 - set_limit(thermostat, i); \ 514 + set_limit(th, i); \ 357 515 return n; \ 358 516 } 359 517 ··· 371 525 return n; \ 372 526 } 373 527 374 - BUILD_SHOW_FUNC_INT(sensor1_temperature, (read_reg(thermostat, TEMP_REG[1]))) 375 - BUILD_SHOW_FUNC_INT(sensor2_temperature, (read_reg(thermostat, TEMP_REG[2]))) 376 - BUILD_SHOW_FUNC_INT(sensor1_limit, thermostat->limits[1]) 377 - BUILD_SHOW_FUNC_INT(sensor2_limit, thermostat->limits[2]) 528 + BUILD_SHOW_FUNC_INT(sensor1_temperature, (read_reg(th, TEMP_REG[1]))) 529 + BUILD_SHOW_FUNC_INT(sensor2_temperature, (read_reg(th, TEMP_REG[2]))) 530 + BUILD_SHOW_FUNC_INT(sensor1_limit, th->limits[1]) 531 + BUILD_SHOW_FUNC_INT(sensor2_limit, th->limits[2]) 378 532 BUILD_SHOW_FUNC_STR(sensor1_location, sensor_location[1]) 379 533 BUILD_SHOW_FUNC_STR(sensor2_location, sensor_location[2]) 380 534 381 - BUILD_SHOW_FUNC_INT(specified_fan_speed, fan_speed) 535 + BUILD_SHOW_FUNC_INT_LITE(specified_fan_speed, fan_speed) 536 + BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed) 537 + 382 538 BUILD_SHOW_FUNC_FAN(sensor1_fan_speed, 0) 383 539 BUILD_SHOW_FUNC_FAN(sensor2_fan_speed, 1) 384 540 385 - BUILD_STORE_FUNC_INT(specified_fan_speed,fan_speed) 386 - BUILD_SHOW_FUNC_INT(limit_adjust, limit_adjust) 387 - BUILD_STORE_FUNC_DEG(limit_adjust, thermostat) 541 + BUILD_SHOW_FUNC_INT_LITE(limit_adjust, limit_adjust) 542 + BUILD_STORE_FUNC_DEG(limit_adjust, th) 388 543 389 544 static DEVICE_ATTR(sensor1_temperature, S_IRUGO, 390 545 show_sensor1_temperature,NULL); ··· 411 564 static DEVICE_ATTR(limit_adjust, S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH, 412 565 show_limit_adjust, store_limit_adjust); 413 566 414 - 415 - static int __init 416 - thermostat_init(void) 567 + static void thermostat_create_files(struct thermostat *th) 417 568 { 418 - struct device_node* np; 419 - const u32 *prop; 420 - int i = 0, offset = 0; 569 + struct device_node *np = th->clt->dev.of_node; 570 + struct device *dev; 571 + int err; 421 572 422 - np = of_find_node_by_name(NULL, "fan"); 573 + /* To maintain ABI compatibility with userspace, create 574 + * the old style platform driver and attach the attributes 575 + * to it here 576 + */ 577 + th->pdev = of_platform_device_create(np, "temperatures", NULL); 578 + if (!th->pdev) 579 + return; 580 + dev = &th->pdev->dev; 581 + dev_set_drvdata(dev, th); 582 + err = device_create_file(dev, &dev_attr_sensor1_temperature); 583 + err |= device_create_file(dev, &dev_attr_sensor2_temperature); 584 + err |= device_create_file(dev, &dev_attr_sensor1_limit); 585 + err |= device_create_file(dev, &dev_attr_sensor2_limit); 586 + err |= device_create_file(dev, &dev_attr_sensor1_location); 587 + err |= device_create_file(dev, &dev_attr_sensor2_location); 588 + err |= device_create_file(dev, &dev_attr_limit_adjust); 589 + err |= device_create_file(dev, &dev_attr_specified_fan_speed); 590 + err |= device_create_file(dev, &dev_attr_sensor1_fan_speed); 591 + if(th->type == ADT7460) 592 + err |= device_create_file(dev, &dev_attr_sensor2_fan_speed); 593 + if (err) 594 + printk(KERN_WARNING 595 + "Failed to create temperature attribute file(s).\n"); 596 + } 597 + 598 + static void thermostat_remove_files(struct thermostat *th) 599 + { 600 + struct device *dev; 601 + 602 + if (!th->pdev) 603 + return; 604 + dev = &th->pdev->dev; 605 + device_remove_file(dev, &dev_attr_sensor1_temperature); 606 + device_remove_file(dev, &dev_attr_sensor2_temperature); 607 + device_remove_file(dev, &dev_attr_sensor1_limit); 608 + device_remove_file(dev, &dev_attr_sensor2_limit); 609 + device_remove_file(dev, &dev_attr_sensor1_location); 610 + device_remove_file(dev, &dev_attr_sensor2_location); 611 + device_remove_file(dev, &dev_attr_limit_adjust); 612 + device_remove_file(dev, &dev_attr_specified_fan_speed); 613 + device_remove_file(dev, &dev_attr_sensor1_fan_speed); 614 + if (th->type == ADT7460) 615 + device_remove_file(dev, &dev_attr_sensor2_fan_speed); 616 + of_device_unregister(th->pdev); 617 + 618 + } 619 + 620 + static int probe_thermostat(struct i2c_client *client, 621 + const struct i2c_device_id *id) 622 + { 623 + struct device_node *np = client->dev.of_node; 624 + struct thermostat* th; 625 + const __be32 *prop; 626 + int i, rc, vers, offset = 0; 627 + 423 628 if (!np) 424 - return -ENODEV; 425 - if (of_device_is_compatible(np, "adt7460")) 426 - therm_type = ADT7460; 427 - else if (of_device_is_compatible(np, "adt7467")) 428 - therm_type = ADT7467; 429 - else { 430 - of_node_put(np); 431 - return -ENODEV; 432 - } 433 - 629 + return -ENXIO; 434 630 prop = of_get_property(np, "hwsensor-params-version", NULL); 435 - printk(KERN_INFO "adt746x: version %d (%ssupported)\n", *prop, 436 - (*prop == 1)?"":"un"); 437 - if (*prop != 1) { 438 - of_node_put(np); 439 - return -ENODEV; 440 - } 441 - 442 - prop = of_get_property(np, "reg", NULL); 443 - if (!prop) { 444 - of_node_put(np); 445 - return -ENODEV; 446 - } 447 - 448 - /* look for bus either by path or using "reg" */ 449 - if (strstr(np->full_name, "/i2c-bus@") != NULL) { 450 - const char *tmp_bus = (strstr(np->full_name, "/i2c-bus@") + 9); 451 - therm_bus = tmp_bus[0]-'0'; 452 - } else { 453 - therm_bus = ((*prop) >> 8) & 0x0f; 454 - } 455 - 456 - therm_address = ((*prop) & 0xff) >> 1; 457 - 458 - printk(KERN_INFO "adt746x: Thermostat bus: %d, address: 0x%02x, " 459 - "limit_adjust: %d, fan_speed: %d\n", 460 - therm_bus, therm_address, limit_adjust, fan_speed); 631 + if (!prop) 632 + return -ENXIO; 633 + vers = be32_to_cpup(prop); 634 + printk(KERN_INFO "adt746x: version %d (%ssupported)\n", 635 + vers, vers == 1 ? "" : "un"); 636 + if (vers != 1) 637 + return -ENXIO; 461 638 462 639 if (of_get_property(np, "hwsensor-location", NULL)) { 463 640 for (i = 0; i < 3; i++) { ··· 494 623 printk(KERN_INFO "sensor %d: %s\n", i, sensor_location[i]); 495 624 offset += strlen(sensor_location[i]) + 1; 496 625 } 497 - } else { 498 - sensor_location[0] = "?"; 499 - sensor_location[1] = "?"; 500 - sensor_location[2] = "?"; 501 626 } 502 627 503 - of_dev = of_platform_device_create(np, "temperatures", NULL); 504 - of_node_put(np); 628 + th = kzalloc(sizeof(struct thermostat), GFP_KERNEL); 629 + if (!th) 630 + return -ENOMEM; 505 631 506 - if (of_dev == NULL) { 507 - printk(KERN_ERR "Can't register temperatures device !\n"); 632 + i2c_set_clientdata(client, th); 633 + th->clt = client; 634 + th->type = id->driver_data; 635 + 636 + rc = read_reg(th, CONFIG_REG); 637 + if (rc < 0) { 638 + dev_err(&client->dev, "Thermostat failed to read config!\n"); 639 + kfree(th); 508 640 return -ENODEV; 509 641 } 510 642 643 + /* force manual control to start the fan quieter */ 644 + if (fan_speed == -1) 645 + fan_speed = 64; 646 + 647 + if (th->type == ADT7460) { 648 + printk(KERN_INFO "adt746x: ADT7460 initializing\n"); 649 + /* The 7460 needs to be started explicitly */ 650 + write_reg(th, CONFIG_REG, 1); 651 + } else 652 + printk(KERN_INFO "adt746x: ADT7467 initializing\n"); 653 + 654 + for (i = 0; i < 3; i++) { 655 + th->initial_limits[i] = read_reg(th, LIMIT_REG[i]); 656 + set_limit(th, i); 657 + } 658 + 659 + printk(KERN_INFO "adt746x: Lowering max temperatures from %d, %d, %d" 660 + " to %d, %d, %d\n", 661 + th->initial_limits[0], th->initial_limits[1], 662 + th->initial_limits[2], th->limits[0], th->limits[1], 663 + th->limits[2]); 664 + 665 + /* record invert bit status because fw can corrupt it after suspend */ 666 + th->pwm_inv[0] = read_reg(th, MANUAL_MODE[0]) & INVERT_MASK; 667 + th->pwm_inv[1] = read_reg(th, MANUAL_MODE[1]) & INVERT_MASK; 668 + 669 + /* be sure to really write fan speed the first time */ 670 + th->last_speed[0] = -2; 671 + th->last_speed[1] = -2; 672 + th->last_var[0] = -80; 673 + th->last_var[1] = -80; 674 + 675 + if (fan_speed != -1) { 676 + /* manual mode, stop fans */ 677 + write_both_fan_speed(th, 0); 678 + } else { 679 + /* automatic mode */ 680 + write_both_fan_speed(th, -1); 681 + } 682 + 683 + th->thread = kthread_run(monitor_task, th, "kfand"); 684 + if (th->thread == ERR_PTR(-ENOMEM)) { 685 + printk(KERN_INFO "adt746x: Kthread creation failed\n"); 686 + th->thread = NULL; 687 + return -ENOMEM; 688 + } 689 + 690 + thermostat_create_files(th); 691 + 692 + return 0; 693 + } 694 + 695 + static int remove_thermostat(struct i2c_client *client) 696 + { 697 + struct thermostat *th = i2c_get_clientdata(client); 698 + int i; 699 + 700 + thermostat_remove_files(th); 701 + 702 + if (th->thread != NULL) 703 + kthread_stop(th->thread); 704 + 705 + printk(KERN_INFO "adt746x: Putting max temperatures back from " 706 + "%d, %d, %d to %d, %d, %d\n", 707 + th->limits[0], th->limits[1], th->limits[2], 708 + th->initial_limits[0], th->initial_limits[1], 709 + th->initial_limits[2]); 710 + 711 + for (i = 0; i < 3; i++) 712 + write_reg(th, LIMIT_REG[i], th->initial_limits[i]); 713 + 714 + write_both_fan_speed(th, -1); 715 + 716 + kfree(th); 717 + 718 + return 0; 719 + } 720 + 721 + static const struct i2c_device_id therm_adt746x_id[] = { 722 + { "MAC,adt7460", ADT7460 }, 723 + { "MAC,adt7467", ADT7467 }, 724 + { } 725 + }; 726 + MODULE_DEVICE_TABLE(i2c, therm_adt746x_id); 727 + 728 + static struct i2c_driver thermostat_driver = { 729 + .driver = { 730 + .name = "therm_adt746x", 731 + }, 732 + .probe = probe_thermostat, 733 + .remove = remove_thermostat, 734 + .id_table = therm_adt746x_id, 735 + }; 736 + 737 + static int __init thermostat_init(void) 738 + { 511 739 #ifndef CONFIG_I2C_POWERMAC 512 740 request_module("i2c-powermac"); 513 741 #endif ··· 614 644 return i2c_add_driver(&thermostat_driver); 615 645 } 616 646 617 - static void thermostat_create_files(void) 618 - { 619 - int err; 620 - 621 - err = device_create_file(&of_dev->dev, &dev_attr_sensor1_temperature); 622 - err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_temperature); 623 - err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_limit); 624 - err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_limit); 625 - err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_location); 626 - err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_location); 627 - err |= device_create_file(&of_dev->dev, &dev_attr_limit_adjust); 628 - err |= device_create_file(&of_dev->dev, &dev_attr_specified_fan_speed); 629 - err |= device_create_file(&of_dev->dev, &dev_attr_sensor1_fan_speed); 630 - if(therm_type == ADT7460) 631 - err |= device_create_file(&of_dev->dev, &dev_attr_sensor2_fan_speed); 632 - if (err) 633 - printk(KERN_WARNING 634 - "Failed to create temperature attribute file(s).\n"); 635 - } 636 - 637 - static void thermostat_remove_files(void) 638 - { 639 - if (of_dev) { 640 - device_remove_file(&of_dev->dev, &dev_attr_sensor1_temperature); 641 - device_remove_file(&of_dev->dev, &dev_attr_sensor2_temperature); 642 - device_remove_file(&of_dev->dev, &dev_attr_sensor1_limit); 643 - device_remove_file(&of_dev->dev, &dev_attr_sensor2_limit); 644 - device_remove_file(&of_dev->dev, &dev_attr_sensor1_location); 645 - device_remove_file(&of_dev->dev, &dev_attr_sensor2_location); 646 - device_remove_file(&of_dev->dev, &dev_attr_limit_adjust); 647 - device_remove_file(&of_dev->dev, &dev_attr_specified_fan_speed); 648 - device_remove_file(&of_dev->dev, &dev_attr_sensor1_fan_speed); 649 - 650 - if(therm_type == ADT7460) 651 - device_remove_file(&of_dev->dev, 652 - &dev_attr_sensor2_fan_speed); 653 - 654 - } 655 - } 656 - 657 - static void __exit 658 - thermostat_exit(void) 647 + static void __exit thermostat_exit(void) 659 648 { 660 649 i2c_del_driver(&thermostat_driver); 661 - of_device_unregister(of_dev); 662 650 } 663 651 664 652 module_init(thermostat_init);