return 0;
}
+static int ec_read_multiple(u8 address, u8 *buffer, size_t bytes)
+{
+ size_t i;
+ int ret;
+
+ for (i = 0; i < bytes; i++) {
+ ret = ec_read(address + i, &buffer[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
+static int ec_write_multiple(u8 address, u8 *buffer, size_t bytes)
+{
+ size_t i;
+ int ret;
+
+ for (i = 0; i < bytes; i++) {
+ ret = ec_write(address + i, buffer[i]);
+ if (ret < 0)
+ return ret;
+ }
+
+ return 0;
+}
+
/*
* WMI can have EmbeddedControl access regions. In which case, we just want to
* hand these off to the EC driver.
u32 bits, u64 *value,
void *handler_context, void *region_context)
{
- int result = 0;
- u8 temp = 0;
+ int bytes = bits / BITS_PER_BYTE;
+ int ret;
- if ((address > 0xFF) || !value)
+ if (!value)
+ return AE_NULL_ENTRY;
+
+ if (!bytes || bytes > sizeof(*value))
return AE_BAD_PARAMETER;
- if (function != ACPI_READ && function != ACPI_WRITE)
+ if (address > U8_MAX || address + bytes - 1 > U8_MAX)
return AE_BAD_PARAMETER;
- if (bits != 8)
+ if (function != ACPI_READ && function != ACPI_WRITE)
return AE_BAD_PARAMETER;
- if (function == ACPI_READ) {
- result = ec_read(address, &temp);
- *value = temp;
- } else {
- temp = 0xff & *value;
- result = ec_write(address, temp);
- }
+ if (function == ACPI_READ)
+ ret = ec_read_multiple(address, (u8 *)value, bytes);
+ else
+ ret = ec_write_multiple(address, (u8 *)value, bytes);
- switch (result) {
+ switch (ret) {
case -EINVAL:
return AE_BAD_PARAMETER;
case -ENODEV: