svn commit: r208722 - head/sys/dev/acpica
Jung-uk Kim
jkim at FreeBSD.org
Tue Jun 1 21:15:05 UTC 2010
Author: jkim
Date: Tue Jun 1 21:15:05 2010
New Revision: 208722
URL: http://svn.freebsd.org/changeset/base/208722
Log:
Remove unnecessary pointer type castings, shift operations and dead code.
Modified:
head/sys/dev/acpica/acpi_ec.c
Modified: head/sys/dev/acpica/acpi_ec.c
==============================================================================
--- head/sys/dev/acpica/acpi_ec.c Tue Jun 1 20:29:03 2010 (r208721)
+++ head/sys/dev/acpica/acpi_ec.c Tue Jun 1 21:15:05 2010 (r208722)
@@ -223,7 +223,7 @@ static ACPI_STATUS EcSpaceSetup(ACPI_HAN
void *Context, void **return_Context);
static ACPI_STATUS EcSpaceHandler(UINT32 Function,
ACPI_PHYSICAL_ADDRESS Address,
- UINT32 width, UINT64 *Value,
+ UINT32 Width, UINT64 *Value,
void *Context, void *RegionContext);
static ACPI_STATUS EcWaitEvent(struct acpi_ec_softc *sc, EC_EVENT Event,
u_int gen_count);
@@ -231,7 +231,7 @@ static ACPI_STATUS EcCommand(struct acpi
static ACPI_STATUS EcRead(struct acpi_ec_softc *sc, UINT8 Address,
UINT8 *Data);
static ACPI_STATUS EcWrite(struct acpi_ec_softc *sc, UINT8 Address,
- UINT8 *Data);
+ UINT8 Data);
static int acpi_ec_probe(device_t dev);
static int acpi_ec_attach(device_t dev);
static int acpi_ec_suspend(device_t dev);
@@ -717,25 +717,27 @@ EcSpaceSetup(ACPI_HANDLE Region, UINT32
}
static ACPI_STATUS
-EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 width,
+EcSpaceHandler(UINT32 Function, ACPI_PHYSICAL_ADDRESS Address, UINT32 Width,
UINT64 *Value, void *Context, void *RegionContext)
{
struct acpi_ec_softc *sc = (struct acpi_ec_softc *)Context;
ACPI_STATUS Status;
- UINT8 EcAddr, EcData;
- int i;
+ UINT8 *EcData;
+ UINT8 EcAddr;
+ int bytes, i;
ACPI_FUNCTION_TRACE_U32((char *)(uintptr_t)__func__, (UINT32)Address);
- if (width % 8 != 0 || Value == NULL || Context == NULL)
+ if (Width % 8 != 0 || Value == NULL || Context == NULL)
return_ACPI_STATUS (AE_BAD_PARAMETER);
- if (Address + (width / 8) - 1 > 0xFF)
+ bytes = Width / 8;
+ if (Address + bytes - 1 > 0xFF)
return_ACPI_STATUS (AE_BAD_ADDRESS);
if (Function == ACPI_READ)
*Value = 0;
EcAddr = Address;
- Status = AE_ERROR;
+ EcData = (UINT8 *)Value;
/*
* If booting, check if we need to run the query handler. If so, we
@@ -753,17 +755,14 @@ EcSpaceHandler(UINT32 Function, ACPI_PHY
if (ACPI_FAILURE(Status))
return_ACPI_STATUS (Status);
- /* Perform the transaction(s), based on width. */
- for (i = 0; i < width; i += 8, EcAddr++) {
+ /* Perform the transaction(s), based on Width. */
+ for (i = 0; i < bytes; i++, EcAddr++, EcData++) {
switch (Function) {
case ACPI_READ:
- Status = EcRead(sc, EcAddr, &EcData);
- if (ACPI_SUCCESS(Status))
- *Value |= ((UINT64)EcData) << i;
+ Status = EcRead(sc, EcAddr, EcData);
break;
case ACPI_WRITE:
- EcData = (UINT8)((*Value) >> i);
- Status = EcWrite(sc, EcAddr, &EcData);
+ Status = EcWrite(sc, EcAddr, *EcData);
break;
default:
device_printf(sc->ec_dev, "invalid EcSpaceHandler function %d\n",
@@ -986,14 +985,14 @@ EcRead(struct acpi_ec_softc *sc, UINT8 A
}
static ACPI_STATUS
-EcWrite(struct acpi_ec_softc *sc, UINT8 Address, UINT8 *Data)
+EcWrite(struct acpi_ec_softc *sc, UINT8 Address, UINT8 Data)
{
ACPI_STATUS status;
UINT8 data;
u_int gen_count;
ACPI_SERIAL_ASSERT(ec);
- CTR2(KTR_ACPI, "ec write to %#x, data %#x", Address, *Data);
+ CTR2(KTR_ACPI, "ec write to %#x, data %#x", Address, Data);
/* If we can't start burst mode, continue anyway. */
status = EcCommand(sc, EC_COMMAND_BURST_ENABLE);
@@ -1018,7 +1017,7 @@ EcWrite(struct acpi_ec_softc *sc, UINT8
}
gen_count = sc->ec_gencount;
- EC_SET_DATA(sc, *Data);
+ EC_SET_DATA(sc, Data);
status = EcWaitEvent(sc, EC_EVENT_INPUT_BUFFER_EMPTY, gen_count);
if (ACPI_FAILURE(status)) {
device_printf(sc->ec_dev, "EcWrite: failed waiting for sent data\n");
More information about the svn-src-head
mailing list