diff options
author | Alan Jenkins <alan-jenkins@tuffmail.co.uk> | 2009-12-03 02:45:02 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-12-09 15:54:31 -0500 |
commit | 6b188a7b218cb33d918e72f24995341f949297d2 (patch) | |
tree | caeee6fd6cdd7546facdf1de393005597f425389 /drivers/platform/x86/eeepc-laptop.c | |
parent | 951037ea1cf4dc323906fd45d55ff015fd295d0c (diff) |
eeepc-laptop: simplify acpi initialization
We don't need to store init_flags after using them. And we don't use
the result of INIT, so we don't need to allocate a buffer for it.
Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform/x86/eeepc-laptop.c')
-rw-r--r-- | drivers/platform/x86/eeepc-laptop.c | 55 |
1 files changed, 26 insertions, 29 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index 9f33e5178d6c..50ceaaf411c2 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -136,7 +136,6 @@ struct eeepc_hotk { | |||
136 | acpi_handle handle; /* the handle of the hotk device */ | 136 | acpi_handle handle; /* the handle of the hotk device */ |
137 | u32 cm_supported; /* the control methods supported | 137 | u32 cm_supported; /* the control methods supported |
138 | by this BIOS */ | 138 | by this BIOS */ |
139 | uint init_flag; /* Init flags */ | ||
140 | u16 event_count[128]; /* count for each event */ | 139 | u16 event_count[128]; /* count for each event */ |
141 | struct input_dev *inputdev; | 140 | struct input_dev *inputdev; |
142 | u16 *keycode_map; | 141 | u16 *keycode_map; |
@@ -256,8 +255,7 @@ MODULE_LICENSE("GPL"); | |||
256 | /* | 255 | /* |
257 | * ACPI Helpers | 256 | * ACPI Helpers |
258 | */ | 257 | */ |
259 | static int write_acpi_int(acpi_handle handle, const char *method, int val, | 258 | static int write_acpi_int(acpi_handle handle, const char *method, int val) |
260 | struct acpi_buffer *output) | ||
261 | { | 259 | { |
262 | struct acpi_object_list params; | 260 | struct acpi_object_list params; |
263 | union acpi_object in_obj; | 261 | union acpi_object in_obj; |
@@ -268,7 +266,7 @@ static int write_acpi_int(acpi_handle handle, const char *method, int val, | |||
268 | in_obj.type = ACPI_TYPE_INTEGER; | 266 | in_obj.type = ACPI_TYPE_INTEGER; |
269 | in_obj.integer.value = val; | 267 | in_obj.integer.value = val; |
270 | 268 | ||
271 | status = acpi_evaluate_object(handle, (char *)method, ¶ms, output); | 269 | status = acpi_evaluate_object(handle, (char *)method, ¶ms, NULL); |
272 | return (status == AE_OK ? 0 : -1); | 270 | return (status == AE_OK ? 0 : -1); |
273 | } | 271 | } |
274 | 272 | ||
@@ -296,7 +294,7 @@ static int set_acpi(int cm, int value) | |||
296 | if ((ehotk->cm_supported & (0x1 << cm)) == 0) | 294 | if ((ehotk->cm_supported & (0x1 << cm)) == 0) |
297 | return -ENODEV; | 295 | return -ENODEV; |
298 | 296 | ||
299 | if (write_acpi_int(ehotk->handle, method, value, NULL)) | 297 | if (write_acpi_int(ehotk->handle, method, value)) |
300 | pr_warning("Error writing %s\n", method); | 298 | pr_warning("Error writing %s\n", method); |
301 | return 0; | 299 | return 0; |
302 | } | 300 | } |
@@ -624,36 +622,36 @@ static void cmsg_quirks(void) | |||
624 | cmsg_quirk(CM_ASL_TPD, "TPD"); | 622 | cmsg_quirk(CM_ASL_TPD, "TPD"); |
625 | } | 623 | } |
626 | 624 | ||
627 | static int eeepc_hotk_check(void) | 625 | static int eeepc_hotk_init(void) |
628 | { | 626 | { |
629 | struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; | 627 | unsigned int init_flags; |
630 | int result; | 628 | int result; |
631 | 629 | ||
632 | result = acpi_bus_get_status(ehotk->device); | 630 | result = acpi_bus_get_status(ehotk->device); |
633 | if (result) | 631 | if (result) |
634 | return result; | 632 | return result; |
635 | if (ehotk->device->status.present) { | 633 | if (!ehotk->device->status.present) { |
636 | if (write_acpi_int(ehotk->handle, "INIT", ehotk->init_flag, | ||
637 | &buffer)) { | ||
638 | pr_err("Hotkey initialization failed\n"); | ||
639 | return -ENODEV; | ||
640 | } else { | ||
641 | pr_notice("Hotkey init flags 0x%x\n", ehotk->init_flag); | ||
642 | } | ||
643 | /* get control methods supported */ | ||
644 | if (read_acpi_int(ehotk->handle, "CMSG" | ||
645 | , &ehotk->cm_supported)) { | ||
646 | pr_err("Get control methods supported failed\n"); | ||
647 | return -ENODEV; | ||
648 | } else { | ||
649 | cmsg_quirks(); | ||
650 | pr_info("Get control methods supported: 0x%x\n", | ||
651 | ehotk->cm_supported); | ||
652 | } | ||
653 | } else { | ||
654 | pr_err("Hotkey device not present, aborting\n"); | 634 | pr_err("Hotkey device not present, aborting\n"); |
655 | return -EINVAL; | 635 | return -ENODEV; |
656 | } | 636 | } |
637 | |||
638 | init_flags = DISABLE_ASL_WLAN | DISABLE_ASL_DISPLAYSWITCH; | ||
639 | pr_notice("Hotkey init flags 0x%x\n", init_flags); | ||
640 | |||
641 | if (write_acpi_int(ehotk->handle, "INIT", init_flags)) { | ||
642 | pr_err("Hotkey initialization failed\n"); | ||
643 | return -ENODEV; | ||
644 | } | ||
645 | |||
646 | /* get control methods supported */ | ||
647 | if (read_acpi_int(ehotk->handle, "CMSG", | ||
648 | &ehotk->cm_supported)) { | ||
649 | pr_err("Get control methods supported failed\n"); | ||
650 | return -ENODEV; | ||
651 | } | ||
652 | cmsg_quirks(); | ||
653 | pr_info("Get control methods supported: 0x%x\n", ehotk->cm_supported); | ||
654 | |||
657 | return 0; | 655 | return 0; |
658 | } | 656 | } |
659 | 657 | ||
@@ -1264,14 +1262,13 @@ static int __devinit eeepc_hotk_add(struct acpi_device *device) | |||
1264 | ehotk = kzalloc(sizeof(struct eeepc_hotk), GFP_KERNEL); | 1262 | ehotk = kzalloc(sizeof(struct eeepc_hotk), GFP_KERNEL); |
1265 | if (!ehotk) | 1263 | if (!ehotk) |
1266 | return -ENOMEM; | 1264 | return -ENOMEM; |
1267 | ehotk->init_flag = DISABLE_ASL_WLAN | DISABLE_ASL_DISPLAYSWITCH; | ||
1268 | ehotk->handle = device->handle; | 1265 | ehotk->handle = device->handle; |
1269 | strcpy(acpi_device_name(device), EEEPC_HOTK_DEVICE_NAME); | 1266 | strcpy(acpi_device_name(device), EEEPC_HOTK_DEVICE_NAME); |
1270 | strcpy(acpi_device_class(device), EEEPC_HOTK_CLASS); | 1267 | strcpy(acpi_device_class(device), EEEPC_HOTK_CLASS); |
1271 | device->driver_data = ehotk; | 1268 | device->driver_data = ehotk; |
1272 | ehotk->device = device; | 1269 | ehotk->device = device; |
1273 | 1270 | ||
1274 | result = eeepc_hotk_check(); | 1271 | result = eeepc_hotk_init(); |
1275 | if (result) | 1272 | if (result) |
1276 | goto fail_platform_driver; | 1273 | goto fail_platform_driver; |
1277 | eeepc_enable_camera(); | 1274 | eeepc_enable_camera(); |