@@ -19,17 +19,8 @@
#include <linux/acpi.h>
#include <linux/input.h>
-#define ACPI_TOPSTAR_HID "TPSACPI01"
-#define ACPI_TOPSTAR_DEVICE_NAME "Topstar TPSACPI01"
-#define ACPI_TOPSTAR_DRIVER_NAME "Topstar laptop ACPI driver"
#define ACPI_TOPSTAR_CLASS "topstar"
-static const struct acpi_device_id topstar_device_ids[] = {
- { ACPI_TOPSTAR_HID, 0 },
- { "", 0 },
-};
-MODULE_DEVICE_TABLE(acpi, topstar_device_ids);
-
struct topstar_hkey {
struct input_dev *inputdev;
};
@@ -82,7 +73,7 @@ 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 = device->driver_data;
+ struct topstar_hkey *hkey = acpi_driver_data(device);
/* 0x83 and 0x84 key events comes duplicated... */
if (event == 0x83 || event == 0x84) {
@@ -120,23 +111,13 @@ static void acpi_topstar_notify(struct acpi_device *device, u32 event)
static int acpi_topstar_fncx_switch(struct acpi_device *device, bool state)
{
acpi_status status;
- acpi_handle handle = NULL;
union acpi_object fncx_params[1] = {
{ .type = ACPI_TYPE_INTEGER }
};
struct acpi_object_list fncx_arg_list = { 1, &fncx_params[0] };
- struct acpi_buffer buf;
- union acpi_object obj;
- status = acpi_get_handle(device->handle, "FNCX", &handle);
- if (ACPI_FAILURE(status)) {
- pr_err("FNCX method not found\n");
- return -ENODEV;
- }
fncx_params[0].integer.value = state ? 0x86 : 0x87;
- buf.length = sizeof(obj);
- buf.pointer = &obj;
- status = acpi_evaluate_object(handle, NULL, &fncx_arg_list, &buf);
+ status = acpi_evaluate_object(device->handle, "FNCX", &fncx_arg_list, NULL);
if (ACPI_FAILURE(status)) {
pr_err("Unable to switch FNCX notifications\n");
return -ENODEV;
@@ -149,12 +130,11 @@ static int topstar_getkeycode(struct input_dev *dev, int scancode, int *keycode)
{
struct tps_key_entry *key = tps_get_key_by_scancode(scancode);
- if (key) {
- *keycode = key->keycode;
- return 0;
- }
+ if (!key)
+ return -EINVAL;
- return -EINVAL;
+ *keycode = key->keycode;
+ return 0;
}
static int topstar_setkeycode(struct input_dev *dev, int scancode, int keycode)
@@ -166,16 +146,16 @@ static int topstar_setkeycode(struct input_dev *dev, int scancode, int keycode)
return -EINVAL;
key = tps_get_key_by_scancode(scancode);
- if (key) {
- old_keycode = key->keycode;
- key->keycode = keycode;
- set_bit(keycode, dev->keybit);
- if (!tps_get_key_by_keycode(old_keycode))
- clear_bit(old_keycode, dev->keybit);
- return 0;
- }
- return -EINVAL;
+ if (!key)
+ return -EINVAL;
+
+ old_keycode = key->keycode;
+ key->keycode = keycode;
+ set_bit(keycode, dev->keybit);
+ if (!tps_get_key_by_keycode(old_keycode))
+ clear_bit(old_keycode, dev->keybit);
+ return 0;
}
static int acpi_topstar_init_hkey(struct topstar_hkey *hkey)
@@ -211,30 +191,25 @@ static int acpi_topstar_add(struct acpi_device *device)
{
struct topstar_hkey *tps_hkey;
- if (!device)
- return -EINVAL;
-
tps_hkey = kzalloc(sizeof(struct topstar_hkey), GFP_KERNEL);
if (!tps_hkey)
return -ENOMEM;
- sprintf(acpi_device_name(device), "%s", ACPI_TOPSTAR_DEVICE_NAME);
- sprintf(acpi_device_class(device), "%s", ACPI_TOPSTAR_CLASS);
+ strcpy(acpi_device_name(device), "Topstar TPSACPI");
+ strcpy(acpi_device_class(device), ACPI_TOPSTAR_CLASS);
if (acpi_topstar_fncx_switch(device, true))
goto add_err;
- device->driver_data = tps_hkey;
-
if (acpi_topstar_init_hkey(tps_hkey))
goto add_err;
+ device->driver_data = tps_hkey;
found_tps_dev = true;
return 0;
add_err:
kfree(tps_hkey);
- device->driver_data = NULL;
return -ENODEV;
}
@@ -242,9 +217,6 @@ static int acpi_topstar_remove(struct acpi_device *device, int type)
{
struct topstar_hkey *tps_hkey = acpi_driver_data(device);
- if (!device || !tps_hkey)
- return -EINVAL;
-
acpi_topstar_fncx_switch(device, false);
input_unregister_device(tps_hkey->inputdev);
@@ -254,8 +226,14 @@ static int acpi_topstar_remove(struct acpi_device *device, int type)
return 0;
}
+static const struct acpi_device_id topstar_device_ids[] = {
+ { "TPSACPI01", 0 },
+ { "", 0 },
+};
+MODULE_DEVICE_TABLE(acpi, topstar_device_ids);
+
static struct acpi_driver acpi_topstar_driver = {
- .name = ACPI_TOPSTAR_DRIVER_NAME,
+ .name = "Topstar laptop ACPI driver",
.class = ACPI_TOPSTAR_CLASS,
.ids = topstar_device_ids,
.ops = {
@@ -269,9 +247,6 @@ static int __init topstar_laptop_init(void)
{
int ret;
- if (acpi_disabled)
- return -ENODEV;
-
ret = acpi_bus_register_driver(&acpi_topstar_driver);
if (ret < 0)
return ret;