From cabf8e92c025703c3029b65ceb4dc353870a746e Mon Sep 17 00:00:00 2001 From: Carlos Corbacho Date: Sat, 13 Oct 2007 23:57:11 +0100 Subject: [PATCH] acer_acpi: Remove dynamic allocation of acer_data Now that acer_data is a fixed sized structure, shared by both AMW0 and WMID, we do not need to allocate it. Change Interface to contain an 'acer_data' structure, rather than a void *, and remove all kmalloc. --- acer_acpi.c | 58 +++++++++++++++++----------------------------------------- 1 file changed, 17 insertions(+), 41 deletions(-) diff --git a/acer_acpi.c b/acer_acpi.c index 6766f60..2de611d 100644 --- a/acer_acpi.c +++ b/acer_acpi.c @@ -256,6 +256,14 @@ static void set_keyboard_quirk(void) send_kbd_cmd(0x59, 0x90); } +struct acer_data { + int mailled; + int wireless; + int bluetooth; + int threeg; + int brightness; +}; + /* Each low-level interface must define at least some of the following */ struct Interface { /* @@ -278,23 +286,14 @@ struct Interface { void (*init) (struct Interface *); /* - * Interface-specific private data member. Must *not* be touched by - * anyone outside of this struct + * Private data for the current interface */ - void *data; + struct acer_data data; }; /* The static interface pointer, points to the currently detected interface */ static struct Interface *interface; -struct acer_data { - int mailled; - int wireless; - int bluetooth; - int threeg; - int brightness; -}; - /* * Embedded Controller quirks * Some laptops require us to directly access the EC to either enable or query @@ -582,11 +581,6 @@ static acpi_status WMAB_execute(struct WMAB_args *regbuf, struct acpi_buffer *re static void AMW0_init(struct Interface *iface) { bool help = 0; - struct acer_data *data; - - /* Allocate our private data structure */ - iface->data = kmalloc(sizeof(struct acer_data), GFP_KERNEL); - data = (struct acer_data *) iface->data; /* * If the commandline doesn't specify these, we need to force them to @@ -605,19 +599,19 @@ static void AMW0_init(struct Interface *iface) { */ if (quirks->bluetooth == 0) { help = 1; - data->bluetooth = -1; + iface->data.bluetooth = -1; printk(ACER_INFO "No EC data for reading bluetooth - bluetooth value when read will be a 'best guess'\n"); } if (quirks->wireless == 0) { help = 1; printk(ACER_INFO "No EC data for reading wireless - wireless value when read will be a 'best guess'\n"); - data->wireless = -1; + iface->data.wireless = -1; } if (quirks->mailled == 0) { help = 1; printk(ACER_INFO "No EC data for reading mail LED - mail LED value when read will be a 'best guess'\n"); - data->mailled = -1; + iface->data.mailled = -1; } if (help) { @@ -628,7 +622,7 @@ static void AMW0_init(struct Interface *iface) { static acpi_status AMW0_get_bool(bool *value, u32 cap, struct Interface *iface) { - struct acer_data *data = iface->data; + struct acer_data *data = &iface->data; u8 result; DEBUG(2, " AMW0_get_bool: cap=%d\n", cap); @@ -693,6 +687,7 @@ static acpi_status AMW0_get_bool(bool *value, u32 cap, struct Interface *iface) static acpi_status AMW0_set_bool(bool value, u32 cap, struct Interface *iface) { struct WMAB_args args; + struct acer_data *data = &iface->data; acpi_status status; args.eax = ACER_AMW0_WRITE; @@ -720,7 +715,6 @@ static acpi_status AMW0_set_bool(bool value, u32 cap, struct Interface *iface) * success */ if (ACPI_SUCCESS(status)) { - struct acer_data *data = iface->data; switch (cap) { case ACER_CAP_MAILLED: data->mailled = value; @@ -786,16 +780,6 @@ static struct Interface AMW0_interface = { /* * New interface (The WMID interface) */ - -static void WMID_init(struct Interface *iface) -{ - struct acer_data *data; - - /* Allocate our private data structure */ - iface->data = kmalloc(sizeof(struct acer_data), GFP_KERNEL); - data = (struct acer_data *) iface->data; -} - static acpi_status WMI_execute_u32(u32 method_id, u32 in, u32 *out) { @@ -928,8 +912,6 @@ static struct Interface WMID_interface = { | ACER_CAP_BLUETOOTH | ACER_CAP_THREEG ), - .init = WMID_init, - .data = NULL, }; #ifdef CONFIG_PROC @@ -1422,7 +1404,7 @@ static int acer_platform_suspend(struct platform_device *device, pm_message_t st */ bool value; u8 u8value; - struct acer_data *data = interface->data; + struct acer_data *data = &interface->data; #define save_bool_device(device, cap) \ if (has_cap(cap)) {\ @@ -1448,7 +1430,7 @@ static int acer_platform_suspend(struct platform_device *device, pm_message_t st static int acer_platform_resume(struct platform_device *device) { - struct acer_data *data = interface->data; + struct acer_data *data = &interface->data; #define restore_bool_device(device, cap) \ if (has_cap(cap))\ @@ -1594,8 +1576,6 @@ error_proc_add: if (acer_proc_dir) remove_proc_entry(PROC_ACER, acpi_root_dir); error_proc_mkdir: - if (interface->data != NULL) - kfree(interface->data); #endif return -ENODEV; } @@ -1612,10 +1592,6 @@ static void __exit acer_acpi_exit(void) if (acer_proc_dir) remove_proc_entry(PROC_ACER, acpi_root_dir); #endif - - if (interface->data != NULL) - kfree(interface->data); - printk(ACER_INFO "Acer Laptop ACPI Extras unloaded\n"); return; } -- 2.11.4.GIT