From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hiroshi Miura Subject: [PATCH]Panasonic Hotkey Driver v0.6.3 Date: Thu, 26 Aug 2004 17:45:40 +0900 Sender: acpi-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Message-ID: <87pt5e5lu3.wl%miura@da-cha.org> References: <41244219.1090603@linuxboxen.org> <87zn4pl116.wl%miura@da-cha.org> <87n00pkqc5.wl%miura@da-cha.org> <41270B53.3060903@linuxboxen.org> <87d61klqzh.wl%miura@da-cha.org> <41284119.1060504@linuxboxen.org> <412858F0.8050406@linuxboxen.org> <41297BA7.3050503@linuxboxen.org> Mime-Version: 1.0 (generated by SEMI 1.14.6 - =?ISO-2022-JP?B?IhskQjRdGyhC?= =?ISO-2022-JP?B?GyRCMiwbKEIi?=) Content-Type: multipart/mixed; boundary="Multipart_Thu_Aug_26_17:45:40_2004-1" Return-path: In-Reply-To: <41297BA7.3050503-Jp3n8lUXroSX6QiC4yPwbg@public.gmane.org> Errors-To: acpi-devel-admin-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , List-Archive: To: David Bronaugh Cc: acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org, letsnote-tech-eXqGM+LsbTTAqL8d+zIrHngSJqDPrsil@public.gmane.org List-Id: linux-acpi@vger.kernel.org --Multipart_Thu_Aug_26_17:45:40_2004-1 Content-Type: text/plain; charset=US-ASCII Hi, Bugfix: v0.6.2 cannot generate hotkey event because pcc_acpi_get_key() does not return proper value. And it is not handle return value of acpi_bus_register_driver(), too. Cleanup: ACPI subsystem has funcion 'acpi_evaluate_integer', I can replase read_acpi_int by it. These patchs fix these problems. # these are generated by bkexport script. --Multipart_Thu_Aug_26_17:45:40_2004-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="pcc_acpi_20040826_1.patch" Content-Transfer-Encoding: 7bit #### AUTHOR miura-yiisDzvROlQdnm+yROfE0A@public.gmane.org #### COMMENT START ### Comments for ChangeSet [ACPI] pcc_acpi: clean up. replace read_acpi_int to standard acpi_evaluate_interger. ### Comments for drivers/acpi/pcc_acpi.c replace read_acpi_int to standard acpi_evaluate_interger. #### COMMENT END # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/08/25 21:16:52+09:00 miura-yiisDzvROlQdnm+yROfE0A@public.gmane.org # [ACPI] pcc_acpi: clean up. replace read_acpi_int to standard acpi_evaluate_interger. # # drivers/acpi/pcc_acpi.c # 2004/08/25 21:16:32+09:00 miura-yiisDzvROlQdnm+yROfE0A@public.gmane.org +17 -39 # replace read_acpi_int to standard acpi_evaluate_interger. # diff -Nru a/drivers/acpi/pcc_acpi.c b/drivers/acpi/pcc_acpi.c --- a/drivers/acpi/pcc_acpi.c 2004-08-26 17:23:24 +09:00 +++ b/drivers/acpi/pcc_acpi.c 2004-08-26 17:23:24 +09:00 @@ -52,7 +52,7 @@ * */ -#define ACPI_PCC_VERSION "0.6.2" +#define ACPI_PCC_VERSION "0.6.3" #include #include @@ -155,32 +155,6 @@ return_VALUE(status == AE_OK); } -static int read_acpi_int(acpi_handle handle, const char* methodName, int* pVal) -{ - struct acpi_buffer results; - union acpi_object out_objs[1]; - acpi_status status; - - results.length = sizeof(out_objs); - results.pointer = out_objs; - - status = acpi_evaluate_object(handle, (char*)methodName, 0, &results); - if (ACPI_FAILURE(status)) { - printk(KERN_INFO LOGPREFIX "acpi evaluate error on %s\n", - methodName); - return -EFAULT; - } - - if (out_objs[0].type == ACPI_TYPE_INTEGER) { - *pVal = out_objs[0].integer.value; - } else { - printk(KERN_INFO LOGPREFIX "return value is not int\n"); - status = AE_ERROR; - } - - return (status == AE_OK); -} - /* register utils for proc handler */ static int dispatch_read(char* page, char** start, off_t off, int count, int* eof, ProcItem* item) @@ -238,18 +212,20 @@ return result; } -static inline int acpi_pcc_get_sqty(void) +static inline int acpi_pcc_get_sqty(struct acpi_device *device) { - int s; + unsigned long s; + acpi_status status; ACPI_FUNCTION_TRACE("acpi_pcc_get_sqty"); - if (read_acpi_int(NULL, DEVICE_NAME_HKEY "." METHOD_HKEY_SQTY, &s)) { - return s; + status = acpi_evaluate_integer(device->handle,METHOD_HKEY_SQTY,NULL,&s); + if (ACPI_SUCCESS(status)) { + return_VALUE(s); } else { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "evaluation error HKEY.SQTY\n")); - return -EINVAL; + return_VALUE(-EINVAL); } } @@ -439,17 +415,19 @@ /* hotkey driver */ static int acpi_pcc_hotkey_get_key(struct acpi_hotkey *hotkey) { - int result; - int status; + unsigned long result; + acpi_status status; - status = read_acpi_int(hotkey->handle, METHOD_HKEY_QUERY, &result); - if (status < 0) { - printk(KERN_INFO LOGPREFIX "error getting hotkey status\n"); + ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_get_key"); + + status = acpi_evaluate_integer(hotkey->handle,METHOD_HKEY_QUERY,NULL,&result); + if (ACPI_FAILURE(status)) { + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "error getting hotkey status\n")); } else { hotkey->status = result; } - return (status); + return_VALUE(status); } void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data) @@ -559,7 +537,7 @@ return_VALUE(-EINVAL); } - num_sifr = acpi_pcc_get_sqty(); + num_sifr = acpi_pcc_get_sqty(device); if (num_sifr > 255) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "num_sifr too large")); --Multipart_Thu_Aug_26_17:45:40_2004-1 Content-Type: application/octet-stream; type=patch Content-Disposition: attachment; filename="pcc_acpi_20040826_2.patch" Content-Transfer-Encoding: 7bit #### AUTHOR miura-yiisDzvROlQdnm+yROfE0A@public.gmane.org #### COMMENT START ### Comments for ChangeSet [ACPI] pcc_acpi: fix to enable notifier and clean up. ### Comments for drivers/acpi/pcc_acpi.c v0.6.3 replace read_acpi_int by standard function acpi_evaluate_integer some clean up and make smart copyright notice. fix return value of pcc_acpi_get_key. fix checking return value of acpi_bus_register_driver() #### COMMENT END # This is a BitKeeper generated diff -Nru style patch. # # ChangeSet # 2004/08/26 12:10:56+09:00 miura-yiisDzvROlQdnm+yROfE0A@public.gmane.org # [ACPI] pcc_acpi: fix to enable notifier and clean up. # # drivers/acpi/pcc_acpi.c # 2004/08/26 12:10:36+09:00 miura-yiisDzvROlQdnm+yROfE0A@public.gmane.org +31 -18 # v0.6.3 replace read_acpi_int by standard function acpi_evaluate_integer # some clean up and make smart copyright notice. # fix return value of pcc_acpi_get_key. # fix checking return value of acpi_bus_register_driver() # diff -Nru a/drivers/acpi/pcc_acpi.c b/drivers/acpi/pcc_acpi.c --- a/drivers/acpi/pcc_acpi.c 2004-08-26 17:24:08 +09:00 +++ b/drivers/acpi/pcc_acpi.c 2004-08-26 17:24:08 +09:00 @@ -1,8 +1,9 @@ /* * Panasonic HotKey and lcd brightness control Extra driver - * Written by Hiroshi Miura 2004 + * (C) 2004 Hiroshi Miura + * (C) 2004 NTT DATA Intellilink Co. http://www.intellilink.co.jp/ * - * Copyright (C) 2002-2004 John Belmonte + * derived from toshiba_acpi.c, Copyright (C) 2002-2004 John Belmonte * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as @@ -20,6 +21,12 @@ *--------------------------------------------------------------------------- * * ChangeLog: + * Aug.25, 2004 Hiroshi Miura + * -v0.6.3 replace read_acpi_int by standard function acpi_evaluate_integer + * some clean up and make smart copyright notice. + * fix return value of pcc_acpi_get_key() + * fix checking return value of acpi_bus_register_driver() + * * Aug.22, 2004 David Bronaugh * -v0.6.2 Add check on ACPI data (num_sifr) * Coding style cleanups, better error messages/handling @@ -92,7 +99,6 @@ * *******************************************************************/ #define PROC_PCC "pcc" -#define PROC_VIDEO "video" #define ACPI_PCC_DRIVER_NAME "PCC HotKey Driver" #define ACPI_HOTKEY_DEVICE_NAME "HotKey" @@ -275,16 +281,18 @@ { u32* sinf = kmalloc(sizeof(u32) * (num_sifr + 1), GFP_KERNEL); + ACPI_FUNCTION_TRACE("acpi_pcc_read_sinf_field"); + if (!sinf) { - printk(KERN_INFO LOGPREFIX "Couldn't allocate %i bytes\n", - sizeof(u32) * num_sifr); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't allocate %i bytes\n", + sizeof(u32) * num_sifr)); return p; } if (acpi_pcc_retrieve_biosdata(sinf)) { p += sprintf(p, "%d\n", sinf[field]); } else { - printk(KERN_INFO LOGPREFIX "Couldn't retrieve BIOS data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't retrieve BIOS data\n")); } kfree(sinf); @@ -362,19 +370,21 @@ u32 bright; u32* sinf = kmalloc(sizeof(u32) * (num_sifr + 1), GFP_KERNEL); + ACPI_FUNCTION_TRACE("acpi_pcc_write_brightness"); + if (!sinf) { - printk(KERN_INFO LOGPREFIX "Couldn't allocate %i bytes\n", - sizeof(u32) * num_sifr); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't allocate %i bytes\n", + sizeof(u32) * num_sifr)); return count; } if (!acpi_pcc_retrieve_biosdata(sinf)) { - printk(KERN_INFO LOGPREFIX "Couldn't retrieve BIOS data\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't retrieve BIOS data\n")); goto end; } if (!sscanf(buffer, "%i", &bright)) { - printk(KERN_INFO LOGPREFIX "Invalid DC brightness\n"); + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Invalid DC brightness\n")); goto end; } @@ -416,7 +426,7 @@ static int acpi_pcc_hotkey_get_key(struct acpi_hotkey *hotkey) { unsigned long result; - acpi_status status; + acpi_status status = AE_OK; ACPI_FUNCTION_TRACE("acpi_pcc_hotkey_get_key"); @@ -427,7 +437,7 @@ hotkey->status = result; } - return_VALUE(status); + return_VALUE(status == AE_OK); } void acpi_pcc_hotkey_notify(acpi_handle handle, u32 event, void *data) @@ -498,21 +508,24 @@ static int __init acpi_pcc_proc_init(void) { acpi_status status = AE_OK; + + ACPI_FUNCTION_TRACE("acpi_pcc_proc_init"); + acpi_pcc_dir = proc_mkdir(PROC_PCC, acpi_root_dir); if (unlikely(!acpi_pcc_dir)) { - printk(KERN_INFO LOGPREFIX "Couldn't create dir in /proc\n"); - return -ENODEV; + ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Couldn't create dir in /proc\n")); + return_VALUE(-ENODEV); } acpi_pcc_dir->owner = THIS_MODULE; status = add_device(pcc_proc_items, acpi_pcc_dir); if (ACPI_FAILURE(status)) { remove_proc_entry(PROC_PCC, acpi_root_dir); - return -ENODEV; + return_VALUE(-ENODEV); } - return (status == AE_OK); + return_VALUE(status == AE_OK); } static acpi_status __exit remove_device(ProcItem *proc_items, @@ -604,7 +617,7 @@ static int __init acpi_pcc_init(void) { - acpi_status result = AE_OK; + int result = 0; ACPI_FUNCTION_TRACE("acpi_pcc_init"); @@ -613,7 +626,7 @@ } result = acpi_bus_register_driver(&acpi_hotkey_driver); - if (ACPI_FAILURE(result)) { + if (result < 0) { ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "Error registering hotkey driver\n")); return_VALUE(-ENODEV); } --Multipart_Thu_Aug_26_17:45:40_2004-1 Content-Type: text/plain; charset=US-ASCII -- Hiroshi Miura --- http://www.da-cha.org/ --- miura-yiisDzvROlQdnm+yROfE0A@public.gmane.org NTTDATA Corp. OpenSource Software Center. --- miurahr-3MafRgGXt7BL9jVzuh4AOg@public.gmane.org NTTDATA Intellilink Corp. OpenSource Engineering Dev. -- miurahr-w0OK63jvRlAuJ+9fw/WgBHgSJqDPrsil@public.gmane.org Key fingerprint = 9117 9407 5684 FBF1 4063 15B4 401D D077 04AB 8617 --Multipart_Thu_Aug_26_17:45:40_2004-1-- ------------------------------------------------------- SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285