};
/* If we find an EC via the ECDT, we need to keep a ptr to its context */
+/* External interfaces use first EC only, so remember */
static struct acpi_ec {
acpi_handle handle;
unsigned long uid;
atomic_t query_pending;
atomic_t event_count;
wait_queue_head_t wait;
-} *boot_ec;
-
-/* External interfaces use first EC only, so remember */
-static struct acpi_device *first_ec;
+} *boot_ec, *first_ec;
/* --------------------------------------------------------------------------
Transaction Management
*/
int ec_burst_enable(void)
{
- struct acpi_ec *ec;
if (!first_ec)
return -ENODEV;
- ec = acpi_driver_data(first_ec);
- return acpi_ec_burst_enable(ec);
+ return acpi_ec_burst_enable(first_ec);
}
EXPORT_SYMBOL(ec_burst_enable);
int ec_burst_disable(void)
{
- struct acpi_ec *ec;
if (!first_ec)
return -ENODEV;
- ec = acpi_driver_data(first_ec);
- return acpi_ec_burst_disable(ec);
+ return acpi_ec_burst_disable(first_ec);
}
EXPORT_SYMBOL(ec_burst_disable);
int ec_read(u8 addr, u8 * val)
{
- struct acpi_ec *ec;
int err;
u8 temp_data;
if (!first_ec)
return -ENODEV;
- ec = acpi_driver_data(first_ec);
-
- err = acpi_ec_read(ec, addr, &temp_data);
+ err = acpi_ec_read(first_ec, addr, &temp_data);
if (!err) {
*val = temp_data;
int ec_write(u8 addr, u8 val)
{
- struct acpi_ec *ec;
int err;
if (!first_ec)
return -ENODEV;
- ec = acpi_driver_data(first_ec);
-
- err = acpi_ec_write(ec, addr, val);
+ err = acpi_ec_write(first_ec, addr, val);
return err;
}
const u8 * wdata, unsigned wdata_len,
u8 * rdata, unsigned rdata_len)
{
- struct acpi_ec *ec;
-
if (!first_ec)
return -ENODEV;
- ec = acpi_driver_data(first_ec);
-
- return acpi_ec_transaction(ec, command, wdata,
+ return acpi_ec_transaction(first_ec, command, wdata,
wdata_len, rdata, rdata_len);
}
kfree(ec);
ec = boot_ec;
}
- }
+ } else
+ first_ec = ec;
ec->handle = device->handle;
acpi_driver_data(device) = ec;
- if (!first_ec)
- first_ec = device;
acpi_ec_add_fs(device);
acpi_ec_remove_fs(device);
acpi_driver_data(device) = NULL;
- if (device == first_ec)
+ if (ec == first_ec)
first_ec = NULL;
/* Don't touch boot EC */
boot_ec->handle = ACPI_ROOT_OBJECT;
ret = ec_install_handlers(boot_ec);
- if (!ret)
+ if (!ret) {
+ first_ec = boot_ec;
return 0;
+ }
error:
kfree(boot_ec);
boot_ec = NULL;