The EC of MSI laptops supports several features represented by a single bit. Add ec_set_bit and ec_check_bit functions to operate on these bits. Cc: Aakash Singh <mail@xxxxxxxxxxxxxxx> Cc: Jose Angel Pastrana <japp0005@xxxxxxxxxxxx> Signed-off-by: Nikita Kravets <teackot@xxxxxxxxx> --- drivers/platform/x86/msi-ec.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/platform/x86/msi-ec.c b/drivers/platform/x86/msi-ec.c index 09472b21e093..ae73dcf01d09 100644 --- a/drivers/platform/x86/msi-ec.c +++ b/drivers/platform/x86/msi-ec.c @@ -699,6 +699,34 @@ static int ec_read_seq(u8 addr, u8 *buf, u8 len) return 0; } +static int ec_set_bit(u8 addr, u8 bit, bool value) +{ + int result; + u8 stored; + + result = ec_read(addr, &stored); + if (result < 0) + return result; + + stored ^= (-(u8) value ^ stored) & (1 << bit); + + return ec_write(addr, stored); +} + +static int ec_check_bit(u8 addr, u8 bit, bool *output) +{ + int result; + u8 stored; + + result = ec_read(addr, &stored); + if (result < 0) + return result; + + *output = (stored >> bit) & 1; + + return 0; +} + static int ec_get_firmware_version(u8 buf[MSI_EC_FW_VERSION_LENGTH + 1]) { int result; -- 2.42.0