Hi, On 3/4/24 23:17, Armin Wolf wrote: > The ACPI EC address space handler currently only supports > reading/writing 8 bit values. Some firmware implementations however > want to access for example 16 bit values, which is prefectly legal > according to the ACPI spec. > > Add support for reading/writing such values. > > Tested on a Dell Inspiron 3505 and a Asus Prime B650-Plus. > > Signed-off-by: Armin Wolf <W_Armin@xxxxxx> Thanks, patch looks good to me: Reviewed-by: Hans de Goede <hdegoede@xxxxxxxxxx> Regards, Hans > --- > drivers/platform/x86/wmi.c | 44 +++++++++++++++++++++++++++++--------- > 1 file changed, 34 insertions(+), 10 deletions(-) > > diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c > index 1920e115da89..900e0e52a5fa 100644 > --- a/drivers/platform/x86/wmi.c > +++ b/drivers/platform/x86/wmi.c > @@ -1153,6 +1153,32 @@ static int parse_wdg(struct device *wmi_bus_dev, struct platform_device *pdev) > return 0; > } > > +static int ec_read_multiple(u8 address, u8 *buffer, size_t bytes) > +{ > + int i, 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) > +{ > + int i, 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. > @@ -1162,27 +1188,25 @@ acpi_wmi_ec_space_handler(u32 function, acpi_physical_address address, > u32 bits, u64 *value, > void *handler_context, void *region_context) > { > - int result = 0; > - u8 temp = 0; > + int bytes = bits / 8; > + int ret; > > - if ((address > 0xFF) || !value) > + if (address > 0xFF || !value) > return AE_BAD_PARAMETER; > > - if (function != ACPI_READ && function != ACPI_WRITE) > + if (bytes > sizeof(*value)) > 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; > + ret = ec_read_multiple(address, (u8 *)value, bytes); > } else { > - temp = 0xff & *value; > - result = ec_write(address, temp); > + ret = ec_write_multiple(address, (u8 *)value, bytes); > } > > - switch (result) { > + switch (ret) { > case -EINVAL: > return AE_BAD_PARAMETER; > case -ENODEV: > -- > 2.39.2 >