From 852cba45232cfb3e3f12991b3524f32d0633096a Mon Sep 17 00:00:00 2001 From: Christoffer Sandberg Date: Tue, 14 Feb 2023 11:03:58 +0100 Subject: [PATCH] uniwill_wmi: Zero BFLG according to wmi impl. Note: weird behaviour but BFLG is always zeroed --- src/uniwill_wmi.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/uniwill_wmi.c b/src/uniwill_wmi.c index 1c5fe65..ac820d9 100644 --- a/src/uniwill_wmi.c +++ b/src/uniwill_wmi.c @@ -131,8 +131,14 @@ static u32 uw_ec_read_addr_direct(u8 addr_low, u8 addr_high, union uw_ec_read_re ec_read(UNIWILL_EC_REG_FLAGS, &flags); if ((flags & (1 << UNIWILL_EC_BIT_BFLG)) > 0) { - output->dword = 0xfefefefe; + pr_debug("read: BFLG set\n"); + + // Note: weird behaviour but BFLG is always zeroed + flags &= ~(1 << UNIWILL_EC_BIT_BFLG); + ec_write(UNIWILL_EC_REG_FLAGS, flags); + mutex_unlock(&uniwill_ec_lock); + output->dword = 0xfefefefe; return -EBUSY; } @@ -187,8 +193,14 @@ static u32 uw_ec_write_addr_direct(u8 addr_low, u8 addr_high, u8 data_low, u8 da ec_read(UNIWILL_EC_REG_FLAGS, &flags); if ((flags & (1 << UNIWILL_EC_BIT_BFLG)) > 0) { - output->dword = 0xfefefefe; + pr_debug("write: BFLG set\n"); + + // Note: weird behaviour but BFLG is always zeroed + flags &= ~(1 << UNIWILL_EC_BIT_BFLG); + ec_write(UNIWILL_EC_REG_FLAGS, flags); + mutex_unlock(&uniwill_ec_lock); + output->dword = 0xfefefefe; return -EBUSY; }