diff options
author | Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> | 2007-03-07 14:28:00 -0500 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-03-09 23:27:28 -0500 |
commit | d033879c9838b960014e861d0eb3bdf11d3b9d9d (patch) | |
tree | 9e48de50d44fd13c040bd49f6d564b8cb54a3222 /drivers/acpi | |
parent | d66d969df88c742494736ed06eeaf3229d3a7259 (diff) |
ACPI: EC: first_ec is better to be acpi_ec than acpi_device.
Signed-off-by: Alexey Starikovskiy <alexey.y.starikovskiy@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/ec.c | 41 |
1 files changed, 13 insertions, 28 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 125046884b8b..187981a3e881 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -91,6 +91,7 @@ static struct acpi_driver acpi_ec_driver = { | |||
91 | }; | 91 | }; |
92 | 92 | ||
93 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ | 93 | /* If we find an EC via the ECDT, we need to keep a ptr to its context */ |
94 | /* External interfaces use first EC only, so remember */ | ||
94 | static struct acpi_ec { | 95 | static struct acpi_ec { |
95 | acpi_handle handle; | 96 | acpi_handle handle; |
96 | unsigned long uid; | 97 | unsigned long uid; |
@@ -102,10 +103,7 @@ static struct acpi_ec { | |||
102 | atomic_t query_pending; | 103 | atomic_t query_pending; |
103 | atomic_t event_count; | 104 | atomic_t event_count; |
104 | wait_queue_head_t wait; | 105 | wait_queue_head_t wait; |
105 | } *boot_ec; | 106 | } *boot_ec, *first_ec; |
106 | |||
107 | /* External interfaces use first EC only, so remember */ | ||
108 | static struct acpi_device *first_ec; | ||
109 | 107 | ||
110 | /* -------------------------------------------------------------------------- | 108 | /* -------------------------------------------------------------------------- |
111 | Transaction Management | 109 | Transaction Management |
@@ -299,38 +297,31 @@ static int acpi_ec_write(struct acpi_ec *ec, u8 address, u8 data) | |||
299 | */ | 297 | */ |
300 | int ec_burst_enable(void) | 298 | int ec_burst_enable(void) |
301 | { | 299 | { |
302 | struct acpi_ec *ec; | ||
303 | if (!first_ec) | 300 | if (!first_ec) |
304 | return -ENODEV; | 301 | return -ENODEV; |
305 | ec = acpi_driver_data(first_ec); | 302 | return acpi_ec_burst_enable(first_ec); |
306 | return acpi_ec_burst_enable(ec); | ||
307 | } | 303 | } |
308 | 304 | ||
309 | EXPORT_SYMBOL(ec_burst_enable); | 305 | EXPORT_SYMBOL(ec_burst_enable); |
310 | 306 | ||
311 | int ec_burst_disable(void) | 307 | int ec_burst_disable(void) |
312 | { | 308 | { |
313 | struct acpi_ec *ec; | ||
314 | if (!first_ec) | 309 | if (!first_ec) |
315 | return -ENODEV; | 310 | return -ENODEV; |
316 | ec = acpi_driver_data(first_ec); | 311 | return acpi_ec_burst_disable(first_ec); |
317 | return acpi_ec_burst_disable(ec); | ||
318 | } | 312 | } |
319 | 313 | ||
320 | EXPORT_SYMBOL(ec_burst_disable); | 314 | EXPORT_SYMBOL(ec_burst_disable); |
321 | 315 | ||
322 | int ec_read(u8 addr, u8 * val) | 316 | int ec_read(u8 addr, u8 * val) |
323 | { | 317 | { |
324 | struct acpi_ec *ec; | ||
325 | int err; | 318 | int err; |
326 | u8 temp_data; | 319 | u8 temp_data; |
327 | 320 | ||
328 | if (!first_ec) | 321 | if (!first_ec) |
329 | return -ENODEV; | 322 | return -ENODEV; |
330 | 323 | ||
331 | ec = acpi_driver_data(first_ec); | 324 | err = acpi_ec_read(first_ec, addr, &temp_data); |
332 | |||
333 | err = acpi_ec_read(ec, addr, &temp_data); | ||
334 | 325 | ||
335 | if (!err) { | 326 | if (!err) { |
336 | *val = temp_data; | 327 | *val = temp_data; |
@@ -343,15 +334,12 @@ EXPORT_SYMBOL(ec_read); | |||
343 | 334 | ||
344 | int ec_write(u8 addr, u8 val) | 335 | int ec_write(u8 addr, u8 val) |
345 | { | 336 | { |
346 | struct acpi_ec *ec; | ||
347 | int err; | 337 | int err; |
348 | 338 | ||
349 | if (!first_ec) | 339 | if (!first_ec) |
350 | return -ENODEV; | 340 | return -ENODEV; |
351 | 341 | ||
352 | ec = acpi_driver_data(first_ec); | 342 | err = acpi_ec_write(first_ec, addr, val); |
353 | |||
354 | err = acpi_ec_write(ec, addr, val); | ||
355 | 343 | ||
356 | return err; | 344 | return err; |
357 | } | 345 | } |
@@ -362,14 +350,10 @@ int ec_transaction(u8 command, | |||
362 | const u8 * wdata, unsigned wdata_len, | 350 | const u8 * wdata, unsigned wdata_len, |
363 | u8 * rdata, unsigned rdata_len) | 351 | u8 * rdata, unsigned rdata_len) |
364 | { | 352 | { |
365 | struct acpi_ec *ec; | ||
366 | |||
367 | if (!first_ec) | 353 | if (!first_ec) |
368 | return -ENODEV; | 354 | return -ENODEV; |
369 | 355 | ||
370 | ec = acpi_driver_data(first_ec); | 356 | return acpi_ec_transaction(first_ec, command, wdata, |
371 | |||
372 | return acpi_ec_transaction(ec, command, wdata, | ||
373 | wdata_len, rdata, rdata_len); | 357 | wdata_len, rdata, rdata_len); |
374 | } | 358 | } |
375 | 359 | ||
@@ -655,11 +639,10 @@ static int acpi_ec_add(struct acpi_device *device) | |||
655 | kfree(ec); | 639 | kfree(ec); |
656 | ec = boot_ec; | 640 | ec = boot_ec; |
657 | } | 641 | } |
658 | } | 642 | } else |
643 | first_ec = ec; | ||
659 | ec->handle = device->handle; | 644 | ec->handle = device->handle; |
660 | acpi_driver_data(device) = ec; | 645 | acpi_driver_data(device) = ec; |
661 | if (!first_ec) | ||
662 | first_ec = device; | ||
663 | 646 | ||
664 | acpi_ec_add_fs(device); | 647 | acpi_ec_add_fs(device); |
665 | 648 | ||
@@ -682,7 +665,7 @@ static int acpi_ec_remove(struct acpi_device *device, int type) | |||
682 | acpi_ec_remove_fs(device); | 665 | acpi_ec_remove_fs(device); |
683 | 666 | ||
684 | acpi_driver_data(device) = NULL; | 667 | acpi_driver_data(device) = NULL; |
685 | if (device == first_ec) | 668 | if (ec == first_ec) |
686 | first_ec = NULL; | 669 | first_ec = NULL; |
687 | 670 | ||
688 | /* Don't touch boot EC */ | 671 | /* Don't touch boot EC */ |
@@ -846,8 +829,10 @@ int __init acpi_ec_ecdt_probe(void) | |||
846 | boot_ec->handle = ACPI_ROOT_OBJECT; | 829 | boot_ec->handle = ACPI_ROOT_OBJECT; |
847 | 830 | ||
848 | ret = ec_install_handlers(boot_ec); | 831 | ret = ec_install_handlers(boot_ec); |
849 | if (!ret) | 832 | if (!ret) { |
833 | first_ec = boot_ec; | ||
850 | return 0; | 834 | return 0; |
835 | } | ||
851 | error: | 836 | error: |
852 | kfree(boot_ec); | 837 | kfree(boot_ec); |
853 | boot_ec = NULL; | 838 | boot_ec = NULL; |