Commit d033879c authored by Alexey Starikovskiy's avatar Alexey Starikovskiy Committed by Len Brown
Browse files

ACPI: EC: first_ec is better to be acpi_ec than acpi_device.

parent d66d969d
Loading
Loading
Loading
Loading
+13 −28
Original line number Original line Diff line number Diff line
@@ -91,6 +91,7 @@ static struct acpi_driver acpi_ec_driver = {
};
};


/* If we find an EC via the ECDT, we need to keep a ptr to its context */
/* 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 {
static struct acpi_ec {
	acpi_handle handle;
	acpi_handle handle;
	unsigned long uid;
	unsigned long uid;
@@ -102,10 +103,7 @@ static struct acpi_ec {
	atomic_t query_pending;
	atomic_t query_pending;
	atomic_t event_count;
	atomic_t event_count;
	wait_queue_head_t wait;
	wait_queue_head_t wait;
} *boot_ec;
} *boot_ec, *first_ec;

/* External interfaces use first EC only, so remember */
static struct acpi_device *first_ec;


/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
                             Transaction Management
                             Transaction Management
@@ -299,38 +297,31 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data)
 */
 */
int ec_burst_enable(void)
int ec_burst_enable(void)
{
{
	struct acpi_ec *ec;
	if (!first_ec)
	if (!first_ec)
		return -ENODEV;
		return -ENODEV;
	ec = acpi_driver_data(first_ec);
	return acpi_ec_burst_enable(first_ec);
	return acpi_ec_burst_enable(ec);
}
}


EXPORT_SYMBOL(ec_burst_enable);
EXPORT_SYMBOL(ec_burst_enable);


int ec_burst_disable(void)
int ec_burst_disable(void)
{
{
	struct acpi_ec *ec;
	if (!first_ec)
	if (!first_ec)
		return -ENODEV;
		return -ENODEV;
	ec = acpi_driver_data(first_ec);
	return acpi_ec_burst_disable(first_ec);
	return acpi_ec_burst_disable(ec);
}
}


EXPORT_SYMBOL(ec_burst_disable);
EXPORT_SYMBOL(ec_burst_disable);


int ec_read(u8 addr, u8 * val)
int ec_read(u8 addr, u8 * val)
{
{
	struct acpi_ec *ec;
	int err;
	int err;
	u8 temp_data;
	u8 temp_data;


	if (!first_ec)
	if (!first_ec)
		return -ENODEV;
		return -ENODEV;


	ec = acpi_driver_data(first_ec);
	err = acpi_ec_read(first_ec, addr, &temp_data);

	err = acpi_ec_read(ec, addr, &temp_data);


	if (!err) {
	if (!err) {
		*val = temp_data;
		*val = temp_data;
@@ -343,15 +334,12 @@ EXPORT_SYMBOL(ec_read);


int ec_write(u8 addr, u8 val)
int ec_write(u8 addr, u8 val)
{
{
	struct acpi_ec *ec;
	int err;
	int err;


	if (!first_ec)
	if (!first_ec)
		return -ENODEV;
		return -ENODEV;


	ec = acpi_driver_data(first_ec);
	err = acpi_ec_write(first_ec, addr, val);

	err = acpi_ec_write(ec, addr, val);


	return err;
	return err;
}
}
@@ -362,14 +350,10 @@ int ec_transaction(u8 command,
		   const u8 * wdata, unsigned wdata_len,
		   const u8 * wdata, unsigned wdata_len,
		   u8 * rdata, unsigned rdata_len)
		   u8 * rdata, unsigned rdata_len)
{
{
	struct acpi_ec *ec;

	if (!first_ec)
	if (!first_ec)
		return -ENODEV;
		return -ENODEV;


	ec = acpi_driver_data(first_ec);
	return acpi_ec_transaction(first_ec, command, wdata,

	return acpi_ec_transaction(ec, command, wdata,
				   wdata_len, rdata, rdata_len);
				   wdata_len, rdata, rdata_len);
}
}


@@ -655,11 +639,10 @@ static int acpi_ec_add(struct acpi_device *device)
			kfree(ec);
			kfree(ec);
			ec = boot_ec;
			ec = boot_ec;
		}
		}
	}
	} else
		first_ec = ec;
	ec->handle = device->handle;
	ec->handle = device->handle;
	acpi_driver_data(device) = ec;
	acpi_driver_data(device) = ec;
	if (!first_ec)
		first_ec = device;


	acpi_ec_add_fs(device);
	acpi_ec_add_fs(device);


@@ -682,7 +665,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type)
	acpi_ec_remove_fs(device);
	acpi_ec_remove_fs(device);


	acpi_driver_data(device) = NULL;
	acpi_driver_data(device) = NULL;
	if (device == first_ec)
	if (ec == first_ec)
		first_ec = NULL;
		first_ec = NULL;


	/* Don't touch boot EC */
	/* Don't touch boot EC */
@@ -846,8 +829,10 @@ int __init acpi_ec_ecdt_probe(void)
	boot_ec->handle = ACPI_ROOT_OBJECT;
	boot_ec->handle = ACPI_ROOT_OBJECT;


	ret = ec_install_handlers(boot_ec);
	ret = ec_install_handlers(boot_ec);
	if (!ret)
	if (!ret) {
		first_ec = boot_ec;
		return 0;
		return 0;
	}
      error:
      error:
	kfree(boot_ec);
	kfree(boot_ec);
	boot_ec = NULL;
	boot_ec = NULL;