Skip to content

Commit

Permalink
[ACPI] fix EC access width
Browse files Browse the repository at this point in the history
http://bugzilla.kernel.org/show_bug.cgi?id=4346

Written-by: David Shaohua Li and Luming Yu
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Luming Yu authored and Len Brown committed Jul 12, 2005
1 parent 451566f commit fa9cd54
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions drivers/acpi/ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ acpi_ec_space_handler (
{
int result = 0;
struct acpi_ec *ec = NULL;
u32 temp = 0;
u64 temp = *value;
acpi_integer f_v = 0;
int i = 0;

Expand All @@ -609,22 +609,21 @@ acpi_ec_space_handler (
if ((address > 0xFF) || !value || !handler_context)
return_VALUE(AE_BAD_PARAMETER);

if(bit_width != 8) {
if (bit_width != 8 && acpi_strict) {
printk(KERN_WARNING PREFIX "acpi_ec_space_handler: bit_width should be 8\n");
if (acpi_strict)
return_VALUE(AE_BAD_PARAMETER);
return_VALUE(AE_BAD_PARAMETER);
}

ec = (struct acpi_ec *) handler_context;

next_byte:
switch (function) {
case ACPI_READ:
result = acpi_ec_read(ec, (u8) address, &temp);
*value = (acpi_integer) temp;
temp = 0;
result = acpi_ec_read(ec, (u8) address, (u32 *)&temp);
break;
case ACPI_WRITE:
result = acpi_ec_write(ec, (u8) address, (u8) *value);
result = acpi_ec_write(ec, (u8) address, (u8) temp);
break;
default:
result = -EINVAL;
Expand All @@ -633,19 +632,18 @@ acpi_ec_space_handler (
}

bit_width -= 8;
if(bit_width){

if(function == ACPI_READ)
f_v |= (acpi_integer) (*value) << 8*i;
if(function == ACPI_WRITE)
(*value) >>=8;
if (bit_width) {
if (function == ACPI_READ)
f_v |= temp << 8 * i;
if (function == ACPI_WRITE)
temp >>= 8;
i++;
(u8)address ++;
goto next_byte;
}


if(function == ACPI_READ){
f_v |= (acpi_integer) (*value) << 8*i;
if (function == ACPI_READ) {
f_v |= temp << 8 * i;
*value = f_v;
}

Expand All @@ -664,8 +662,6 @@ acpi_ec_space_handler (
default:
return_VALUE(AE_OK);
}


}


Expand Down

0 comments on commit fa9cd54

Please sign in to comment.