diff options
author | Alexey Starikovskiy <astarikovskiy@suse.de> | 2007-05-29 08:42:52 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-06-23 15:54:56 -0400 |
commit | 5b7734b440d29dab583a6c3f0ee49ff20f323332 (patch) | |
tree | 9d97ce4e592a62658b5a71ef57ae9075ecf945cf /drivers/acpi | |
parent | a4146557cdfcd1adf1a8e8c92493c2cebe1088a1 (diff) |
ACPI EC: Re-factor EC space handler to avoid using label/goto for cycle.
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi')
-rw-r--r-- | drivers/acpi/ec.c | 56 |
1 files changed, 17 insertions, 39 deletions
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index 82f496c07675..5534b234509b 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
@@ -454,57 +454,35 @@ acpi_ec_space_setup(acpi_handle region_handle, | |||
454 | } | 454 | } |
455 | 455 | ||
456 | static acpi_status | 456 | static acpi_status |
457 | acpi_ec_space_handler(u32 function, | 457 | acpi_ec_space_handler(u32 function, acpi_physical_address address, |
458 | acpi_physical_address address, | 458 | u32 bits, acpi_integer *value, |
459 | u32 bit_width, | ||
460 | acpi_integer * value, | ||
461 | void *handler_context, void *region_context) | 459 | void *handler_context, void *region_context) |
462 | { | 460 | { |
463 | int result = 0; | ||
464 | struct acpi_ec *ec = handler_context; | 461 | struct acpi_ec *ec = handler_context; |
465 | u64 temp = *value; | 462 | int result = 0, i = 0; |
466 | acpi_integer f_v = 0; | 463 | u8 temp = 0; |
467 | int i = 0; | ||
468 | 464 | ||
469 | if ((address > 0xFF) || !value || !handler_context) | 465 | if ((address > 0xFF) || !value || !handler_context) |
470 | return AE_BAD_PARAMETER; | 466 | return AE_BAD_PARAMETER; |
471 | 467 | ||
472 | if (bit_width != 8 && acpi_strict) { | 468 | if (function != ACPI_READ && function != ACPI_WRITE) |
473 | return AE_BAD_PARAMETER; | 469 | return AE_BAD_PARAMETER; |
474 | } | ||
475 | |||
476 | next_byte: | ||
477 | switch (function) { | ||
478 | case ACPI_READ: | ||
479 | temp = 0; | ||
480 | result = acpi_ec_read(ec, (u8) address, (u8 *) & temp); | ||
481 | break; | ||
482 | case ACPI_WRITE: | ||
483 | result = acpi_ec_write(ec, (u8) address, (u8) temp); | ||
484 | break; | ||
485 | default: | ||
486 | result = -EINVAL; | ||
487 | goto out; | ||
488 | break; | ||
489 | } | ||
490 | 470 | ||
491 | bit_width -= 8; | 471 | if (bits != 8 && acpi_strict) |
492 | if (bit_width) { | 472 | return AE_BAD_PARAMETER; |
493 | if (function == ACPI_READ) | ||
494 | f_v |= temp << 8 * i; | ||
495 | if (function == ACPI_WRITE) | ||
496 | temp >>= 8; | ||
497 | i++; | ||
498 | address++; | ||
499 | goto next_byte; | ||
500 | } | ||
501 | 473 | ||
502 | if (function == ACPI_READ) { | 474 | while (bits - i > 0) { |
503 | f_v |= temp << 8 * i; | 475 | if (function == ACPI_READ) { |
504 | *value = f_v; | 476 | result = acpi_ec_read(ec, address, &temp); |
477 | (*value) |= ((acpi_integer)temp) << i; | ||
478 | } else { | ||
479 | temp = 0xff & ((*value) >> i); | ||
480 | result = acpi_ec_write(ec, address, temp); | ||
481 | } | ||
482 | i += 8; | ||
483 | ++address; | ||
505 | } | 484 | } |
506 | 485 | ||
507 | out: | ||
508 | switch (result) { | 486 | switch (result) { |
509 | case -EINVAL: | 487 | case -EINVAL: |
510 | return AE_BAD_PARAMETER; | 488 | return AE_BAD_PARAMETER; |