2010-07-09 01:20:56 +02:00
|
|
|
/*
|
|
|
|
* quickstart.c - ACPI Direct App Launch driver
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007-2010 Angelo Arrifano <miknix@gmail.com>
|
|
|
|
*
|
2012-01-11 23:22:36 +01:00
|
|
|
* Information gathered from disassembled dsdt and from here:
|
2011-02-08 20:41:19 +01:00
|
|
|
* <http://www.microsoft.com/whdc/system/platform/firmware/DirAppLaunch.mspx>
|
2010-07-09 01:20:56 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-02-10 21:05:44 +01:00
|
|
|
#define QUICKSTART_VERSION "1.04"
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-22 19:50:13 +01:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2010-07-09 01:20:56 +02:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <acpi/acpi_drivers.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Angelo Arrifano");
|
|
|
|
MODULE_DESCRIPTION("ACPI Direct App Launch driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
#define QUICKSTART_ACPI_DEVICE_NAME "quickstart"
|
|
|
|
#define QUICKSTART_ACPI_CLASS "quickstart"
|
|
|
|
#define QUICKSTART_ACPI_HID "PNP0C32"
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
#define QUICKSTART_PF_DRIVER_NAME "quickstart"
|
|
|
|
#define QUICKSTART_PF_DEVICE_NAME "quickstart"
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
/*
|
|
|
|
* There will be two events:
|
|
|
|
* 0x02 - A hot button was pressed while device was off/sleeping.
|
|
|
|
* 0x80 - A hot button was pressed while device was up.
|
|
|
|
*/
|
|
|
|
#define QUICKSTART_EVENT_WAKE 0x02
|
|
|
|
#define QUICKSTART_EVENT_RUNTIME 0x80
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:49 +01:00
|
|
|
struct quickstart_button {
|
2010-07-09 01:20:56 +02:00
|
|
|
char *name;
|
|
|
|
unsigned int id;
|
2012-01-11 23:22:47 +01:00
|
|
|
struct list_head list;
|
2010-07-09 01:20:56 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct quickstart_acpi {
|
|
|
|
struct acpi_device *device;
|
2012-01-11 23:22:49 +01:00
|
|
|
struct quickstart_button *button;
|
2010-07-09 01:20:56 +02:00
|
|
|
};
|
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
static LIST_HEAD(buttons);
|
2012-01-11 23:22:49 +01:00
|
|
|
static struct quickstart_button *pressed;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:39 +01:00
|
|
|
static struct input_dev *quickstart_input;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
/* Platform driver functions */
|
2013-08-24 19:34:53 +02:00
|
|
|
static ssize_t buttons_show(struct device *dev, struct device_attribute *attr,
|
|
|
|
char *buf)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
|
|
|
int count = 0;
|
2012-01-11 23:22:49 +01:00
|
|
|
struct quickstart_button *b;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
if (list_empty(&buttons))
|
2010-07-09 01:20:56 +02:00
|
|
|
return snprintf(buf, PAGE_SIZE, "none");
|
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
list_for_each_entry(b, &buttons, list) {
|
2012-01-11 23:22:48 +01:00
|
|
|
count += snprintf(buf + count, PAGE_SIZE - count, "%u\t%s\n",
|
2012-01-11 23:22:47 +01:00
|
|
|
b->id, b->name);
|
|
|
|
|
|
|
|
if (count >= PAGE_SIZE) {
|
|
|
|
count = PAGE_SIZE;
|
|
|
|
break;
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2013-08-24 19:34:53 +02:00
|
|
|
static ssize_t pressed_button_show(struct device *dev,
|
|
|
|
struct device_attribute *attr, char *buf)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
2012-02-10 21:05:42 +01:00
|
|
|
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
2012-01-11 23:22:46 +01:00
|
|
|
(pressed ? pressed->name : "none"));
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-24 19:34:53 +02:00
|
|
|
static ssize_t pressed_button_store(struct device *dev,
|
|
|
|
struct device_attribute *attr,
|
|
|
|
const char *buf, size_t count)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
|
|
|
if (count < 2)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
if (strncasecmp(buf, "none", 4) != 0)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-01-11 23:22:46 +01:00
|
|
|
pressed = NULL;
|
2010-07-09 01:20:56 +02:00
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
/* Helper functions */
|
2012-01-11 23:22:49 +01:00
|
|
|
static struct quickstart_button *quickstart_buttons_add(void)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
2012-01-11 23:22:49 +01:00
|
|
|
struct quickstart_button *b;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
b = kzalloc(sizeof(*b), GFP_KERNEL);
|
|
|
|
if (!b)
|
|
|
|
return NULL;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
list_add_tail(&b->list, &buttons);
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
return b;
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:49 +01:00
|
|
|
static void quickstart_button_del(struct quickstart_button *data)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
|
|
|
if (!data)
|
|
|
|
return;
|
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
list_del(&data->list);
|
|
|
|
kfree(data->name);
|
|
|
|
kfree(data);
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
static void quickstart_buttons_free(void)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
2012-01-11 23:22:49 +01:00
|
|
|
struct quickstart_button *b, *n;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
list_for_each_entry_safe(b, n, &buttons, list)
|
|
|
|
quickstart_button_del(b);
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ACPI Driver functions */
|
|
|
|
static void quickstart_acpi_notify(acpi_handle handle, u32 event, void *data)
|
|
|
|
{
|
|
|
|
struct quickstart_acpi *quickstart = data;
|
|
|
|
|
|
|
|
if (!quickstart)
|
|
|
|
return;
|
|
|
|
|
2012-01-11 23:22:44 +01:00
|
|
|
switch (event) {
|
|
|
|
case QUICKSTART_EVENT_WAKE:
|
2012-01-11 23:22:49 +01:00
|
|
|
pressed = quickstart->button;
|
2012-01-11 23:22:44 +01:00
|
|
|
break;
|
|
|
|
case QUICKSTART_EVENT_RUNTIME:
|
2012-01-11 23:22:49 +01:00
|
|
|
input_report_key(quickstart_input, quickstart->button->id, 1);
|
2010-07-09 01:20:56 +02:00
|
|
|
input_sync(quickstart_input);
|
2012-01-11 23:22:49 +01:00
|
|
|
input_report_key(quickstart_input, quickstart->button->id, 0);
|
2010-07-09 01:20:56 +02:00
|
|
|
input_sync(quickstart_input);
|
2012-01-11 23:22:44 +01:00
|
|
|
break;
|
|
|
|
default:
|
2012-01-22 19:50:13 +01:00
|
|
|
pr_err("Unexpected ACPI event notify (%u)\n", event);
|
2012-01-11 23:22:44 +01:00
|
|
|
break;
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:40 +01:00
|
|
|
static int quickstart_acpi_ghid(struct quickstart_acpi *quickstart)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
|
|
|
acpi_status status;
|
|
|
|
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
|
2012-01-11 23:22:40 +01:00
|
|
|
int ret = 0;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
/*
|
|
|
|
* This returns a buffer telling the button usage ID,
|
|
|
|
* and triggers pending notify events (The ones before booting).
|
|
|
|
*/
|
|
|
|
status = acpi_evaluate_object(quickstart->device->handle, "GHID", NULL,
|
|
|
|
&buffer);
|
2012-01-11 23:22:40 +01:00
|
|
|
if (ACPI_FAILURE(status)) {
|
2012-01-22 19:50:13 +01:00
|
|
|
pr_err("%s GHID method failed\n", quickstart->button->name);
|
2012-01-11 23:22:40 +01:00
|
|
|
return -EINVAL;
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
/*
|
|
|
|
* <<The GHID method can return a BYTE, WORD, or DWORD.
|
2010-07-09 01:20:56 +02:00
|
|
|
* The value must be encoded in little-endian byte
|
2012-01-11 23:22:36 +01:00
|
|
|
* order (least significant byte first).>>
|
|
|
|
*/
|
2012-01-11 23:22:40 +01:00
|
|
|
switch (buffer.length) {
|
|
|
|
case 1:
|
2012-01-11 23:22:49 +01:00
|
|
|
quickstart->button->id = *(uint8_t *)buffer.pointer;
|
2012-01-11 23:22:40 +01:00
|
|
|
break;
|
|
|
|
case 2:
|
2012-01-11 23:22:49 +01:00
|
|
|
quickstart->button->id = *(uint16_t *)buffer.pointer;
|
2012-01-11 23:22:40 +01:00
|
|
|
break;
|
|
|
|
case 4:
|
2012-01-11 23:22:49 +01:00
|
|
|
quickstart->button->id = *(uint32_t *)buffer.pointer;
|
2012-01-11 23:22:40 +01:00
|
|
|
break;
|
|
|
|
case 8:
|
2012-01-11 23:22:49 +01:00
|
|
|
quickstart->button->id = *(uint64_t *)buffer.pointer;
|
2012-01-11 23:22:40 +01:00
|
|
|
break;
|
|
|
|
default:
|
2012-02-10 21:05:43 +01:00
|
|
|
pr_err("%s GHID method returned buffer of unexpected length %lu\n",
|
|
|
|
quickstart->button->name,
|
|
|
|
(unsigned long)buffer.length);
|
2012-01-11 23:22:40 +01:00
|
|
|
ret = -EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
kfree(buffer.pointer);
|
2012-01-11 23:22:40 +01:00
|
|
|
|
|
|
|
return ret;
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:43 +01:00
|
|
|
static int quickstart_acpi_config(struct quickstart_acpi *quickstart)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
2012-01-11 23:22:43 +01:00
|
|
|
char *bid = acpi_device_bid(quickstart->device);
|
|
|
|
char *name;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:43 +01:00
|
|
|
name = kmalloc(strlen(bid) + 1, GFP_KERNEL);
|
|
|
|
if (!name)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
/* Add new button to list */
|
2012-01-11 23:22:49 +01:00
|
|
|
quickstart->button = quickstart_buttons_add();
|
|
|
|
if (!quickstart->button) {
|
2012-01-11 23:22:43 +01:00
|
|
|
kfree(name);
|
2012-01-11 23:22:47 +01:00
|
|
|
return -ENOMEM;
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
2012-01-11 23:22:43 +01:00
|
|
|
|
2012-01-11 23:22:49 +01:00
|
|
|
quickstart->button->name = name;
|
|
|
|
strcpy(quickstart->button->name, bid);
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int quickstart_acpi_add(struct acpi_device *device)
|
|
|
|
{
|
2012-01-11 23:22:42 +01:00
|
|
|
int ret;
|
|
|
|
acpi_status status;
|
|
|
|
struct quickstart_acpi *quickstart;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
if (!device)
|
|
|
|
return -EINVAL;
|
|
|
|
|
2012-01-11 23:22:42 +01:00
|
|
|
quickstart = kzalloc(sizeof(*quickstart), GFP_KERNEL);
|
2010-07-09 01:20:56 +02:00
|
|
|
if (!quickstart)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
quickstart->device = device;
|
2012-01-11 23:22:42 +01:00
|
|
|
|
2010-07-09 01:20:56 +02:00
|
|
|
strcpy(acpi_device_name(device), QUICKSTART_ACPI_DEVICE_NAME);
|
|
|
|
strcpy(acpi_device_class(device), QUICKSTART_ACPI_CLASS);
|
|
|
|
device->driver_data = quickstart;
|
|
|
|
|
|
|
|
/* Add button to list and initialize some stuff */
|
2012-01-11 23:22:43 +01:00
|
|
|
ret = quickstart_acpi_config(quickstart);
|
2012-01-11 23:22:42 +01:00
|
|
|
if (ret < 0)
|
2010-07-09 01:20:56 +02:00
|
|
|
goto fail_config;
|
|
|
|
|
2012-01-11 23:22:42 +01:00
|
|
|
status = acpi_install_notify_handler(device->handle, ACPI_ALL_NOTIFY,
|
2010-07-09 01:20:56 +02:00
|
|
|
quickstart_acpi_notify,
|
|
|
|
quickstart);
|
|
|
|
if (ACPI_FAILURE(status)) {
|
2012-01-22 19:50:13 +01:00
|
|
|
pr_err("Notify handler install error\n");
|
2010-07-09 01:20:56 +02:00
|
|
|
ret = -ENODEV;
|
|
|
|
goto fail_installnotify;
|
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:42 +01:00
|
|
|
ret = quickstart_acpi_ghid(quickstart);
|
|
|
|
if (ret < 0)
|
|
|
|
goto fail_ghid;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2012-01-11 23:22:42 +01:00
|
|
|
fail_ghid:
|
|
|
|
acpi_remove_notify_handler(device->handle, ACPI_ALL_NOTIFY,
|
|
|
|
quickstart_acpi_notify);
|
|
|
|
|
2010-07-09 01:20:56 +02:00
|
|
|
fail_installnotify:
|
2012-01-11 23:22:49 +01:00
|
|
|
quickstart_button_del(quickstart->button);
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
fail_config:
|
|
|
|
|
|
|
|
kfree(quickstart);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2013-01-24 00:24:48 +01:00
|
|
|
static int quickstart_acpi_remove(struct acpi_device *device)
|
2010-07-09 01:20:56 +02:00
|
|
|
{
|
2012-01-11 23:22:41 +01:00
|
|
|
acpi_status status;
|
|
|
|
struct quickstart_acpi *quickstart;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:41 +01:00
|
|
|
if (!device)
|
2010-07-09 01:20:56 +02:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
quickstart = acpi_driver_data(device);
|
2012-01-11 23:22:41 +01:00
|
|
|
if (!quickstart)
|
|
|
|
return -EINVAL;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
2012-01-11 23:22:36 +01:00
|
|
|
status = acpi_remove_notify_handler(device->handle, ACPI_ALL_NOTIFY,
|
|
|
|
quickstart_acpi_notify);
|
2010-07-09 01:20:56 +02:00
|
|
|
if (ACPI_FAILURE(status))
|
2012-01-22 19:50:13 +01:00
|
|
|
pr_err("Error removing notify handler\n");
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
kfree(quickstart);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-01-11 23:22:38 +01:00
|
|
|
/* Platform driver structs */
|
2013-08-24 19:34:53 +02:00
|
|
|
static DEVICE_ATTR_RW(pressed_button);
|
|
|
|
static DEVICE_ATTR_RO(buttons);
|
2012-01-11 23:22:38 +01:00
|
|
|
static struct platform_device *pf_device;
|
|
|
|
static struct platform_driver pf_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = QUICKSTART_PF_DRIVER_NAME,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct acpi_device_id quickstart_device_ids[] = {
|
|
|
|
{QUICKSTART_ACPI_HID, 0},
|
|
|
|
{"", 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct acpi_driver quickstart_acpi_driver = {
|
|
|
|
.name = "quickstart",
|
|
|
|
.class = QUICKSTART_ACPI_CLASS,
|
|
|
|
.ids = quickstart_device_ids,
|
|
|
|
.ops = {
|
|
|
|
.add = quickstart_acpi_add,
|
|
|
|
.remove = quickstart_acpi_remove,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2010-07-09 01:20:56 +02:00
|
|
|
/* Module functions */
|
|
|
|
static void quickstart_exit(void)
|
|
|
|
{
|
|
|
|
input_unregister_device(quickstart_input);
|
|
|
|
|
|
|
|
device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
|
|
|
|
device_remove_file(&pf_device->dev, &dev_attr_buttons);
|
|
|
|
|
|
|
|
platform_device_unregister(pf_device);
|
|
|
|
|
|
|
|
platform_driver_unregister(&pf_driver);
|
|
|
|
|
|
|
|
acpi_bus_unregister_driver(&quickstart_acpi_driver);
|
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
quickstart_buttons_free();
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init quickstart_init_input(void)
|
|
|
|
{
|
2012-01-11 23:22:49 +01:00
|
|
|
struct quickstart_button *b;
|
2010-11-12 06:04:43 +01:00
|
|
|
int ret;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
quickstart_input = input_allocate_device();
|
|
|
|
|
|
|
|
if (!quickstart_input)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
quickstart_input->name = "Quickstart ACPI Buttons";
|
|
|
|
quickstart_input->id.bustype = BUS_HOST;
|
|
|
|
|
2012-01-11 23:22:47 +01:00
|
|
|
list_for_each_entry(b, &buttons, list) {
|
2010-07-09 01:20:56 +02:00
|
|
|
set_bit(EV_KEY, quickstart_input->evbit);
|
2012-01-11 23:22:47 +01:00
|
|
|
set_bit(b->id, quickstart_input->keybit);
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
2010-11-12 06:04:43 +01:00
|
|
|
ret = input_register_device(quickstart_input);
|
|
|
|
if (ret) {
|
|
|
|
input_free_device(quickstart_input);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2010-07-09 01:20:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init quickstart_init(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* ACPI driver register */
|
2010-08-10 07:42:25 +02:00
|
|
|
ret = acpi_bus_register_driver(&quickstart_acpi_driver);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
/* If existing bus with no devices */
|
2012-01-11 23:22:47 +01:00
|
|
|
if (list_empty(&buttons)) {
|
2010-07-09 01:20:56 +02:00
|
|
|
ret = -ENODEV;
|
|
|
|
goto fail_pfdrv_reg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Platform driver register */
|
|
|
|
ret = platform_driver_register(&pf_driver);
|
|
|
|
if (ret)
|
|
|
|
goto fail_pfdrv_reg;
|
|
|
|
|
|
|
|
/* Platform device register */
|
|
|
|
pf_device = platform_device_alloc(QUICKSTART_PF_DEVICE_NAME, -1);
|
|
|
|
if (!pf_device) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto fail_pfdev_alloc;
|
|
|
|
}
|
|
|
|
ret = platform_device_add(pf_device);
|
|
|
|
if (ret)
|
|
|
|
goto fail_pfdev_add;
|
|
|
|
|
|
|
|
/* Create device sysfs file */
|
|
|
|
ret = device_create_file(&pf_device->dev, &dev_attr_pressed_button);
|
|
|
|
if (ret)
|
|
|
|
goto fail_dev_file;
|
|
|
|
|
|
|
|
ret = device_create_file(&pf_device->dev, &dev_attr_buttons);
|
|
|
|
if (ret)
|
|
|
|
goto fail_dev_file2;
|
|
|
|
|
|
|
|
/* Input device */
|
|
|
|
ret = quickstart_init_input();
|
|
|
|
if (ret)
|
|
|
|
goto fail_input;
|
|
|
|
|
2012-01-22 19:50:13 +01:00
|
|
|
pr_info("ACPI Direct App Launch ver %s\n", QUICKSTART_VERSION);
|
2010-07-09 01:20:56 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
fail_input:
|
|
|
|
device_remove_file(&pf_device->dev, &dev_attr_buttons);
|
|
|
|
|
|
|
|
fail_dev_file2:
|
|
|
|
device_remove_file(&pf_device->dev, &dev_attr_pressed_button);
|
|
|
|
|
|
|
|
fail_dev_file:
|
|
|
|
platform_device_del(pf_device);
|
|
|
|
|
|
|
|
fail_pfdev_add:
|
|
|
|
platform_device_put(pf_device);
|
|
|
|
|
|
|
|
fail_pfdev_alloc:
|
|
|
|
platform_driver_unregister(&pf_driver);
|
|
|
|
|
|
|
|
fail_pfdrv_reg:
|
|
|
|
acpi_bus_unregister_driver(&quickstart_acpi_driver);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(quickstart_init);
|
|
|
|
module_exit(quickstart_exit);
|