Subject: [PATCH] [acpi ec] Cache the first EC device found - Define struct acpi_ec * first_ec; set in ec_add() and clear when that EC device is removed.. Signed-off-by: Patrick Mochel --- drivers/acpi/drivers/ec/driver.c | 12 +++++++++--- drivers/acpi/drivers/ec/ec.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) applies-to: 9226ce4e2e3eb3e4d583ff008e34327982f9116d 57caf6c702f7de0031c43564ddf8b7d594dc81e2 diff --git a/drivers/acpi/drivers/ec/driver.c b/drivers/acpi/drivers/ec/driver.c index 888c17c..5761e91 100644 --- a/drivers/acpi/drivers/ec/driver.c +++ b/drivers/acpi/drivers/ec/driver.c @@ -16,7 +16,7 @@ #include "ec.h" int ec_poll_mode = EC_MODE_INTR; - +struct acpi_ec * first_ec = NULL; static int ec_add(struct acpi_dev * ad) { @@ -54,6 +54,9 @@ static int ec_add(struct acpi_dev * ad) else ec_poll_init(ae); + if (!first_ec) + first_ec = ae; + printk(KERN_INFO PREFIX "ec [%s] (gpe %ld)\n", acpi_dev_bid(ad), ae->e_gpe_bit); return ret; @@ -61,10 +64,13 @@ static int ec_add(struct acpi_dev * ad) static int ec_remove(struct acpi_dev * ad) { - struct acpi_ec * af = dev_get_drvdata(&ad->dev); + struct acpi_ec * ec = dev_get_drvdata(&ad->dev); + + if (first_ec == ec) + first_ec = NULL; dev_set_drvdata(&ad->dev, NULL); - kfree(af); + kfree(ec); return 0; } diff --git a/drivers/acpi/drivers/ec/ec.h b/drivers/acpi/drivers/ec/ec.h index a5ca5a6..7901d80 100644 --- a/drivers/acpi/drivers/ec/ec.h +++ b/drivers/acpi/drivers/ec/ec.h @@ -62,6 +62,7 @@ struct acpi_ec { * driver.c */ extern int ec_poll_mode; +extern struct acpi_ec * first_ec; /* * device.c --- 0.99.9.GIT