From patchwork Mon Sep 7 19:26:03 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Herton Ronaldo Krzesinski X-Patchwork-Id: 46134 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n87JQDfc018963 for ; Mon, 7 Sep 2009 19:26:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750972AbZIGT0J (ORCPT ); Mon, 7 Sep 2009 15:26:09 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751172AbZIGT0J (ORCPT ); Mon, 7 Sep 2009 15:26:09 -0400 Received: from perninha.conectiva.com.br ([200.140.247.100]:53955 "EHLO perninha.conectiva.com.br" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750972AbZIGT0H (ORCPT ); Mon, 7 Sep 2009 15:26:07 -0400 Received: from localhost (perninha.conectiva.com.br [127.0.0.1]) by perninha.conectiva.com.br (Postfix) with ESMTP id C75E22EE60; Mon, 7 Sep 2009 15:26:09 -0400 (EDT) X-Virus-Scanned: amavisd-new at conectiva.com.br Received: from perninha.conectiva.com.br ([127.0.0.1]) by localhost (perninha.conectiva.com.br [127.0.0.1]) (amavisd-new, port 10025) with LMTP id HsFgcg1ZbO5a; Mon, 7 Sep 2009 15:26:08 -0400 (EDT) Received: from fox.conectiva (fox.conectiva [10.0.2.195]) by perninha.conectiva.com.br (Postfix) with ESMTP id DF0372EE4E; Mon, 7 Sep 2009 15:26:07 -0400 (EDT) Received: from palo.localnet (unknown [172.21.225.22]) by fox.conectiva (Postfix) with ESMTP id 254B22F228; Mon, 7 Sep 2009 16:26:04 -0300 (BRT) From: Herton Ronaldo Krzesinski Organization: Mandriva To: Alan Jenkins Subject: Re: [PATCH] topstar_acpi: add new driver for hotkeys support on Topstar N01 Date: Mon, 7 Sep 2009 16:26:03 -0300 User-Agent: KMail/1.12.1 (Linux/2.6.31-desktop-0.rc8.1mnb; KDE/4.3.1; i686; ; ) Cc: linux-acpi@vger.kernel.org, Corentin Chary References: <200909050229.55665.herton@mandriva.com.br> <9b2b86520909050602q1c62c648kdce76dc77b9f3dfd@mail.gmail.com> In-Reply-To: <9b2b86520909050602q1c62c648kdce76dc77b9f3dfd@mail.gmail.com> MIME-Version: 1.0 Message-Id: <200909071626.03334.herton@mandriva.com.br> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Em Sáb 05 Set 2009, às 10:02:32, Alan Jenkins escreveu: > On 9/5/09, Herton Ronaldo Krzesinski wrote: > > This adds Topstar Laptop Extras ACPI driver. It enables hotkeys > > functionality with Topstar N01 netbook. Besides hotkeys there are > > other functions exposed by its ACPI firmware, but for now only > > hotkeys reporting on Topstar N01 is supported. Topstar is a chinese > > manufacturer, its website can be currently reached at > > http://www.topstardigital.cn/ > > > > Signed-off-by: Herton Ronaldo Krzesinski > > > +static void __exit acpi_topstar_exit(void) > > +{ > > + acpi_bus_unregister_driver(&acpi_topstar_driver); > > + > > + printk(KERN_INFO "Topstar Laptop ACPI extras driver unloaded\n"); > > Oh... and this type of message always strikes me as gratuitous. rmmod > doesn't happen during normal operation. So if the user removed the > module... they know they did it. They can check lsmod if they forget > and are not sure. > > If (as a developer) you want to be sure the acpi driver was really > unregistered, you can (and probably should) look in sysfs. Hi, thanks for review. I addressed all issues you pointed out, and renamed the driver to topstar-laptop as suggested by Corentin Chary. I'll attach also the Reviewed-by: Alan Jenkins diff --git a/drivers/platform/x86/topstar_acpi.c b/drivers/platform/x86/topstar_acpi.c index e852de2..7be5b45 100644 --- a/drivers/platform/x86/topstar_acpi.c +++ b/drivers/platform/x86/topstar_acpi.c @@ -11,11 +11,11 @@ * published by the Free Software Foundation. */ -#include +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + +#include #include #include -#include -#include #include #define ACPI_TOPSTAR_HID "TPSACPI01" @@ -23,10 +23,6 @@ #define ACPI_TOPSTAR_DRIVER_NAME "Topstar laptop ACPI driver" #define ACPI_TOPSTAR_CLASS "topstar" -#define TOPSTAR_ACPI_NAME "topstar_acpi" -#define TOPSTAR_ACPI_ERR KERN_ERR TOPSTAR_ACPI_NAME ": " -#define TOPSTAR_ACPI_INFO KERN_INFO TOPSTAR_ACPI_NAME ": " - static const struct acpi_device_id topstar_device_ids[] = { { ACPI_TOPSTAR_HID, 0 }, { "", 0 }, @@ -79,12 +75,12 @@ static struct tps_key_entry *tps_get_key_by_keycode(int code) return NULL; } -static void acpi_topstar_notify(acpi_handle handle, u32 event, void *data) +static void acpi_topstar_notify(struct acpi_device *device, u32 event) { struct tps_key_entry *key; static bool dup_evnt[2]; bool *dup; - struct topstar_hkey *hkey = data; + struct topstar_hkey *hkey = device->driver_data; /* 0x83 and 0x84 key events comes duplicated... */ if (event == 0x83 || event == 0x84) { @@ -116,7 +112,7 @@ static void acpi_topstar_notify(acpi_handle handle, u32 event, void *data) if (event == 0x8e || event == 0x8f || event == 0x90) return; - printk(TOPSTAR_ACPI_INFO "unknown event = 0x%02x\n", event); + pr_info("unknown event = 0x%02x\n", event); } static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state) @@ -132,7 +128,7 @@ static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state) status = acpi_get_handle(device->handle, "FNCX", &handle); if (ACPI_FAILURE(status)) { - printk(TOPSTAR_ACPI_ERR "FNCX method not found\n"); + pr_err("FNCX method not found\n"); return -ENODEV; } fncx_params[0].integer.value = state ? 0x86 : 0x87; @@ -140,8 +136,7 @@ static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state) buf.pointer = &obj; status = acpi_evaluate_object(handle, NULL, &fncx_arg_list, &buf); if (ACPI_FAILURE(status)) { - printk(TOPSTAR_ACPI_ERR - "Unable to switch FNCX notifications\n"); + pr_err("Unable to switch FNCX notifications\n"); return -ENODEV; } @@ -187,7 +182,7 @@ static int acpi_topstar_init_hkey(struct topstar_hkey *hkey) hkey->inputdev = input_allocate_device(); if (!hkey->inputdev) { - printk(TOPSTAR_ACPI_ERR "Unable to allocate input device\n"); + pr_err("Unable to allocate input device\n"); return -ENODEV; } hkey->inputdev->name = "Topstar Laptop extra buttons"; @@ -200,7 +195,7 @@ static int acpi_topstar_init_hkey(struct topstar_hkey *hkey) set_bit(key->keycode, hkey->inputdev->keybit); } if (input_register_device(hkey->inputdev)) { - printk(TOPSTAR_ACPI_ERR "Unable to register input device\n"); + pr_err("Unable to register input device\n"); input_free_device(hkey->inputdev); return -ENODEV; } @@ -208,9 +203,10 @@ static int acpi_topstar_init_hkey(struct topstar_hkey *hkey) return 0; } +static int is_tps_dev; + static int acpi_topstar_add(struct acpi_device *device) { - acpi_status status; struct topstar_hkey *tps_hkey; if (!device) @@ -231,11 +227,7 @@ static int acpi_topstar_add(struct acpi_device *device) if (acpi_topstar_init_hkey(tps_hkey)) goto add_err; - status = acpi_install_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, - acpi_topstar_notify, tps_hkey); - if (ACPI_FAILURE(status)) - goto add_err; - + is_tps_dev = 1; return 0; add_err: @@ -251,9 +243,6 @@ static int acpi_topstar_remove(struct acpi_device *device, int type) if (!device || !tps_hkey) return -EINVAL; - acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY, - acpi_topstar_notify); - acpi_topstar_fncx_switch(device, false); input_unregister_device(tps_hkey->inputdev); @@ -270,31 +259,38 @@ static struct acpi_driver acpi_topstar_driver = { .ops = { .add = acpi_topstar_add, .remove = acpi_topstar_remove, + .notify = acpi_topstar_notify, }, }; -static int __init acpi_topstar_init(void) +static int __init topstar_laptop_init(void) { + int ret; + if (acpi_disabled) return -ENODEV; - if (acpi_bus_register_driver(&acpi_topstar_driver) < 0) + ret = acpi_bus_register_driver(&acpi_topstar_driver); + if (ret < 0) + return ret; + + if (!is_tps_dev) { + acpi_bus_unregister_driver(&acpi_topstar_driver); return -ENODEV; + } printk(KERN_INFO "Topstar Laptop ACPI extras driver loaded\n"); return 0; } -static void __exit acpi_topstar_exit(void) +static void __exit topstar_laptop_exit(void) { acpi_bus_unregister_driver(&acpi_topstar_driver); - - printk(KERN_INFO "Topstar Laptop ACPI extras driver unloaded\n"); } -module_init(acpi_topstar_init); -module_exit(acpi_topstar_exit); +module_init(topstar_laptop_init); +module_exit(topstar_laptop_exit); MODULE_AUTHOR("Herton Ronaldo Krzesinski"); MODULE_DESCRIPTION("Topstar Laptop ACPI Extras driver");