Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 141991
b: refs/heads/master
c: 46ec859
h: refs/heads/master
i:
  141989: 4bfcb35
  141987: 6436cbe
  141983: c631e1b
v: v3
  • Loading branch information
Bjorn Helgaas authored and Len Brown committed Apr 5, 2009
1 parent 067033b commit 139b4c6
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 478c6a43fcbc6c11609f8cee7c7b57223907754f
refs/heads/master: 46ec8598fde74ba59703575c22a6fb0b6b151bb6
71 changes: 71 additions & 0 deletions trunk/drivers/acpi/scan.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,61 @@ static int acpi_device_uevent(struct device *dev, struct kobj_uevent_env *env)
return 0;
}

static void acpi_device_notify(acpi_handle handle, u32 event, void *data)
{
struct acpi_device *device = data;

device->driver->ops.notify(device, event);
}

static acpi_status acpi_device_notify_fixed(void *data)
{
struct acpi_device *device = data;

acpi_device_notify(device->handle, ACPI_FIXED_HARDWARE_EVENT, device);
return AE_OK;
}

static int acpi_device_install_notify_handler(struct acpi_device *device)
{
acpi_status status;
char *hid;

hid = acpi_device_hid(device);
if (!strcmp(hid, ACPI_BUTTON_HID_POWERF))
status =
acpi_install_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
acpi_device_notify_fixed,
device);
else if (!strcmp(hid, ACPI_BUTTON_HID_SLEEPF))
status =
acpi_install_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
acpi_device_notify_fixed,
device);
else
status = acpi_install_notify_handler(device->handle,
ACPI_DEVICE_NOTIFY,
acpi_device_notify,
device);

if (ACPI_FAILURE(status))
return -EINVAL;
return 0;
}

static void acpi_device_remove_notify_handler(struct acpi_device *device)
{
if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_POWERF))
acpi_remove_fixed_event_handler(ACPI_EVENT_POWER_BUTTON,
acpi_device_notify_fixed);
else if (!strcmp(acpi_device_hid(device), ACPI_BUTTON_HID_SLEEPF))
acpi_remove_fixed_event_handler(ACPI_EVENT_SLEEP_BUTTON,
acpi_device_notify_fixed);
else
acpi_remove_notify_handler(device->handle, ACPI_DEVICE_NOTIFY,
acpi_device_notify);
}

static int acpi_bus_driver_init(struct acpi_device *, struct acpi_driver *);
static int acpi_start_single_object(struct acpi_device *);
static int acpi_device_probe(struct device * dev)
Expand All @@ -371,6 +426,20 @@ static int acpi_device_probe(struct device * dev)
if (!ret) {
if (acpi_dev->bus_ops.acpi_op_start)
acpi_start_single_object(acpi_dev);

if (acpi_drv->ops.notify) {
ret = acpi_device_install_notify_handler(acpi_dev);
if (ret) {
if (acpi_drv->ops.stop)
acpi_drv->ops.stop(acpi_dev,
acpi_dev->removal_type);
if (acpi_drv->ops.remove)
acpi_drv->ops.remove(acpi_dev,
acpi_dev->removal_type);
return ret;
}
}

ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"Found driver [%s] for device [%s]\n",
acpi_drv->name, acpi_dev->pnp.bus_id));
Expand All @@ -385,6 +454,8 @@ static int acpi_device_remove(struct device * dev)
struct acpi_driver *acpi_drv = acpi_dev->driver;

if (acpi_drv) {
if (acpi_drv->ops.notify)
acpi_device_remove_notify_handler(acpi_dev);
if (acpi_drv->ops.stop)
acpi_drv->ops.stop(acpi_dev, acpi_dev->removal_type);
if (acpi_drv->ops.remove)
Expand Down
2 changes: 2 additions & 0 deletions trunk/include/acpi/acpi_bus.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ typedef int (*acpi_op_suspend) (struct acpi_device * device,
typedef int (*acpi_op_resume) (struct acpi_device * device);
typedef int (*acpi_op_bind) (struct acpi_device * device);
typedef int (*acpi_op_unbind) (struct acpi_device * device);
typedef void (*acpi_op_notify) (struct acpi_device * device, u32 event);

struct acpi_bus_ops {
u32 acpi_op_add:1;
Expand All @@ -110,6 +111,7 @@ struct acpi_device_ops {
acpi_op_resume resume;
acpi_op_bind bind;
acpi_op_unbind unbind;
acpi_op_notify notify;
};

struct acpi_driver {
Expand Down
10 changes: 10 additions & 0 deletions trunk/include/acpi/acpi_drivers.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@
#define ACPI_BAY_HID "LNXIOBAY"
#define ACPI_DOCK_HID "LNXDOCK"

/*
* For fixed hardware buttons, we fabricate acpi_devices with HID
* ACPI_BUTTON_HID_POWERF or ACPI_BUTTON_HID_SLEEPF. Fixed hardware
* signals only an event; it doesn't supply a notification value.
* To allow drivers to treat notifications from fixed hardware the
* same as those from real devices, we turn the events into this
* notification value.
*/
#define ACPI_FIXED_HARDWARE_EVENT 0x100

/* --------------------------------------------------------------------------
PCI
-------------------------------------------------------------------------- */
Expand Down

0 comments on commit 139b4c6

Please sign in to comment.