From: Alexey Starikovskiy <aystarik@gmail.com>
To: len.brown@intel.com, linux-acpi@vger.kernel.org
Cc: Alexey Starikovskiy <aystarik@gmail.com>
Subject: [PATCH 1/3] ACPI EC: Re-factor EC space handler to avoid using label/goto for cycle.
Date: Tue, 29 May 2007 16:42:52 +0400 [thread overview]
Message-ID: <20070529124252.20303.89820.stgit@z61m> (raw)
In-Reply-To: <20070529123823.20303.55101.stgit@z61m>
Signed-off-by: Alexey Starikovskiy <aystarik@gmail.com>
---
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 82f496c..5534b23 100644
--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -454,57 +454,35 @@ acpi_ec_space_setup(acpi_handle region_handle,
}
static acpi_status
-acpi_ec_space_handler(u32 function,
- acpi_physical_address address,
- u32 bit_width,
- acpi_integer * value,
+acpi_ec_space_handler(u32 function, acpi_physical_address address,
+ u32 bits, acpi_integer *value,
void *handler_context, void *region_context)
{
- int result = 0;
struct acpi_ec *ec = handler_context;
- u64 temp = *value;
- acpi_integer f_v = 0;
- int i = 0;
+ int result = 0, i = 0;
+ u8 temp = 0;
if ((address > 0xFF) || !value || !handler_context)
return AE_BAD_PARAMETER;
- if (bit_width != 8 && acpi_strict) {
+ if (function != ACPI_READ && function != ACPI_WRITE)
return AE_BAD_PARAMETER;
- }
-
- next_byte:
- switch (function) {
- case ACPI_READ:
- temp = 0;
- result = acpi_ec_read(ec, (u8) address, (u8 *) & temp);
- break;
- case ACPI_WRITE:
- result = acpi_ec_write(ec, (u8) address, (u8) temp);
- break;
- default:
- result = -EINVAL;
- goto out;
- break;
- }
- bit_width -= 8;
- if (bit_width) {
- if (function == ACPI_READ)
- f_v |= temp << 8 * i;
- if (function == ACPI_WRITE)
- temp >>= 8;
- i++;
- address++;
- goto next_byte;
- }
+ if (bits != 8 && acpi_strict)
+ return AE_BAD_PARAMETER;
- if (function == ACPI_READ) {
- f_v |= temp << 8 * i;
- *value = f_v;
+ while (bits - i > 0) {
+ if (function == ACPI_READ) {
+ result = acpi_ec_read(ec, address, &temp);
+ (*value) |= ((acpi_integer)temp) << i;
+ } else {
+ temp = 0xff & ((*value) >> i);
+ result = acpi_ec_write(ec, address, temp);
+ }
+ i += 8;
+ ++address;
}
- out:
switch (result) {
case -EINVAL:
return AE_BAD_PARAMETER;
next prev parent reply other threads:[~2007-05-29 12:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-29 12:42 [PATCH 0/3] Series short description Alexey Starikovskiy
2007-05-29 12:42 ` Alexey Starikovskiy [this message]
2007-06-23 20:02 ` [PATCH 1/3] ACPI EC: Re-factor EC space handler to avoid using label/goto for cycle Len Brown
2007-05-29 12:42 ` [PATCH 2/3] ACPI EC: drop usage of ACPI_DEBUG_PRINT as too heavy weight Alexey Starikovskiy
2007-06-23 20:03 ` Len Brown
2007-05-29 12:43 ` [PATCH 3/3] ACPI EC: Add support for non-AML EC query handlers Alexey Starikovskiy
2007-06-23 20:07 ` Len Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070529124252.20303.89820.stgit@z61m \
--to=aystarik@gmail.com \
--cc=len.brown@intel.com \
--cc=linux-acpi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox