Subject: [PATCH] [acpi driver model] Add logic to register device events - Call acpi_device_event_add() in acpi_device_add(), after a device has been added to the driver. - Call acpi_device_event_remove() in acpi_device_remove() when the device is getting removed from the driver. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/core/driver.c | 32 +++++++++++++++++++++++++------- 1 files changed, 25 insertions(+), 7 deletions(-) applies-to: 0296489edeccdcaab1d4cd3a5dbba275eb161b88 e77dafc2b97c898f484ceb21873378cd1d6c2005 diff --git a/drivers/acpi/drivers/core/driver.c b/drivers/acpi/drivers/core/driver.c index bbe67e6..4ac5ac3 100644 --- a/drivers/acpi/drivers/core/driver.c +++ b/drivers/acpi/drivers/core/driver.c @@ -15,7 +15,7 @@ */ #include "core.h" - +#include "event.h" /** * acpi_device_start - Fire up an ACPI device. @@ -98,20 +98,33 @@ static int acpi_device_add(struct device * Start the device */ ret = acpi_device_start(ad); - if (!ret) - goto Done; + if (ret) + goto RemoveDevice; /* - * Something bad happened.. - * tear down the device and return the error. + * Initialize the events, if the driver supports them */ - if (adrv->d_remove) - adrv->d_remove(ad); + ret = acpi_device_event_add(ad); + if (ret) + goto StopDevice; Done: dbg("Probing Done: Device [%s] Driver [%s], Return [%d]", ad->dev.bus_id, adrv->d_drv.name, ret); return ret; + + StopDevice: + acpi_device_stop(ad); + + RemoveDevice: + /* + * Something bad happened.. + * tear down the device and return the error. + */ + if (adrv->d_remove) + adrv->d_remove(ad); + + goto Done; } @@ -125,6 +138,11 @@ static int acpi_device_remove(struct dev ad->dev.bus_id, adrv->d_drv.name); /* + * Remove the event handler + */ + acpi_device_event_remove(ad); + + /* * Stop the device, ignore the error */ acpi_device_stop(ad); --- 0.99.9.GIT