aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/intel_menlow.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/platform/x86/intel_menlow.c')
-rw-r--r--drivers/platform/x86/intel_menlow.c33
1 files changed, 22 insertions, 11 deletions
diff --git a/drivers/platform/x86/intel_menlow.c b/drivers/platform/x86/intel_menlow.c
index 2f795ce2b939..eacd5da7dd24 100644
--- a/drivers/platform/x86/intel_menlow.c
+++ b/drivers/platform/x86/intel_menlow.c
@@ -53,6 +53,8 @@ MODULE_LICENSE("GPL");
53#define MEMORY_ARG_CUR_BANDWIDTH 1 53#define MEMORY_ARG_CUR_BANDWIDTH 1
54#define MEMORY_ARG_MAX_BANDWIDTH 0 54#define MEMORY_ARG_MAX_BANDWIDTH 0
55 55
56static void intel_menlow_unregister_sensor(void);
57
56/* 58/*
57 * GTHS returning 'n' would mean that [0,n-1] states are supported 59 * GTHS returning 'n' would mean that [0,n-1] states are supported
58 * In that case max_cstate would be n-1 60 * In that case max_cstate would be n-1
@@ -406,8 +408,10 @@ static int intel_menlow_add_one_attribute(char *name, int mode, void *show,
406 attr->handle = handle; 408 attr->handle = handle;
407 409
408 result = device_create_file(dev, &attr->attr); 410 result = device_create_file(dev, &attr->attr);
409 if (result) 411 if (result) {
412 kfree(attr);
410 return result; 413 return result;
414 }
411 415
412 mutex_lock(&intel_menlow_attr_lock); 416 mutex_lock(&intel_menlow_attr_lock);
413 list_add_tail(&attr->node, &intel_menlow_attr_list); 417 list_add_tail(&attr->node, &intel_menlow_attr_list);
@@ -431,11 +435,11 @@ static acpi_status intel_menlow_register_sensor(acpi_handle handle, u32 lvl,
431 /* _TZ must have the AUX0/1 methods */ 435 /* _TZ must have the AUX0/1 methods */
432 status = acpi_get_handle(handle, GET_AUX0, &dummy); 436 status = acpi_get_handle(handle, GET_AUX0, &dummy);
433 if (ACPI_FAILURE(status)) 437 if (ACPI_FAILURE(status))
434 goto not_found; 438 return (status == AE_NOT_FOUND) ? AE_OK : status;
435 439
436 status = acpi_get_handle(handle, SET_AUX0, &dummy); 440 status = acpi_get_handle(handle, SET_AUX0, &dummy);
437 if (ACPI_FAILURE(status)) 441 if (ACPI_FAILURE(status))
438 goto not_found; 442 return (status == AE_NOT_FOUND) ? AE_OK : status;
439 443
440 result = intel_menlow_add_one_attribute("aux0", 0644, 444 result = intel_menlow_add_one_attribute("aux0", 0644,
441 aux0_show, aux0_store, 445 aux0_show, aux0_store,
@@ -445,17 +449,19 @@ static acpi_status intel_menlow_register_sensor(acpi_handle handle, u32 lvl,
445 449
446 status = acpi_get_handle(handle, GET_AUX1, &dummy); 450 status = acpi_get_handle(handle, GET_AUX1, &dummy);
447 if (ACPI_FAILURE(status)) 451 if (ACPI_FAILURE(status))
448 goto not_found; 452 goto aux1_not_found;
449 453
450 status = acpi_get_handle(handle, SET_AUX1, &dummy); 454 status = acpi_get_handle(handle, SET_AUX1, &dummy);
451 if (ACPI_FAILURE(status)) 455 if (ACPI_FAILURE(status))
452 goto not_found; 456 goto aux1_not_found;
453 457
454 result = intel_menlow_add_one_attribute("aux1", 0644, 458 result = intel_menlow_add_one_attribute("aux1", 0644,
455 aux1_show, aux1_store, 459 aux1_show, aux1_store,
456 &thermal->device, handle); 460 &thermal->device, handle);
457 if (result) 461 if (result) {
462 intel_menlow_unregister_sensor();
458 return AE_ERROR; 463 return AE_ERROR;
464 }
459 465
460 /* 466 /*
461 * create the "dabney_enabled" attribute which means the user app 467 * create the "dabney_enabled" attribute which means the user app
@@ -465,14 +471,17 @@ static acpi_status intel_menlow_register_sensor(acpi_handle handle, u32 lvl,
465 result = intel_menlow_add_one_attribute("bios_enabled", 0444, 471 result = intel_menlow_add_one_attribute("bios_enabled", 0444,
466 bios_enabled_show, NULL, 472 bios_enabled_show, NULL,
467 &thermal->device, handle); 473 &thermal->device, handle);
468 if (result) 474 if (result) {
475 intel_menlow_unregister_sensor();
469 return AE_ERROR; 476 return AE_ERROR;
477 }
470 478
471 not_found: 479 aux1_not_found:
472 if (status == AE_NOT_FOUND) 480 if (status == AE_NOT_FOUND)
473 return AE_OK; 481 return AE_OK;
474 else 482
475 return status; 483 intel_menlow_unregister_sensor();
484 return status;
476} 485}
477 486
478static void intel_menlow_unregister_sensor(void) 487static void intel_menlow_unregister_sensor(void)
@@ -513,8 +522,10 @@ static int __init intel_menlow_module_init(void)
513 status = acpi_walk_namespace(ACPI_TYPE_THERMAL, ACPI_ROOT_OBJECT, 522 status = acpi_walk_namespace(ACPI_TYPE_THERMAL, ACPI_ROOT_OBJECT,
514 ACPI_UINT32_MAX, 523 ACPI_UINT32_MAX,
515 intel_menlow_register_sensor, NULL, NULL, NULL); 524 intel_menlow_register_sensor, NULL, NULL, NULL);
516 if (ACPI_FAILURE(status)) 525 if (ACPI_FAILURE(status)) {
526 acpi_bus_unregister_driver(&intel_menlow_memory_driver);
517 return -ENODEV; 527 return -ENODEV;
528 }
518 529
519 return 0; 530 return 0;
520} 531}