Patchwork [1/3] ACPI EC: add ec_set_bit() / ec_clr_bit()

login
register
about
Submitter Sven Schnelle
Date 2011-03-12 00:18:05
Message ID <1299889087-3174-1-git-send-email-svens@stackframe.org>
Download mbox | patch
Permalink /patch/2775/
State Accepted
Commit r6441
Headers show

Comments

Sven Schnelle - 2011-03-12 00:18:05
Signed-off-by: Sven Schnelle <svens@stackframe.org>
---
 src/ec/acpi/ec.c |   10 ++++++++++
 src/ec/acpi/ec.h |    2 ++
 2 files changed, 12 insertions(+), 0 deletions(-)

Patch

diff --git a/src/ec/acpi/ec.c b/src/ec/acpi/ec.c
index 7a01b7e..e353260 100644
--- a/src/ec/acpi/ec.c
+++ b/src/ec/acpi/ec.c
@@ -113,6 +113,16 @@  int ec_write(u8 addr, u8 data)
 	return send_ec_data(data);
 }
 
+void ec_set_bit(u8 addr, u8 bit)
+{
+	ec_write(addr, ec_read(addr) | (1 << bit));
+}
+
+void ec_clr_bit(u8 addr, u8 bit)
+{
+	ec_write(addr, ec_read(addr) &  ~(1 << bit));
+}
+
 struct chip_operations ec_acpi_ops = {
 	CHIP_NAME("ACPI Embedded Controller")
 };
diff --git a/src/ec/acpi/ec.h b/src/ec/acpi/ec.h
index 77ee637..cabbfea 100644
--- a/src/ec/acpi/ec.h
+++ b/src/ec/acpi/ec.h
@@ -44,6 +44,8 @@  int send_ec_data_nowait(u8 data);
 u8 recv_ec_data(void);
 u8 ec_read(u8 addr);
 int ec_write(u8 addr, u8 data);
+void ec_set_bit(u8 addr, u8 bit);
+void ec_clr_bit(u8 addr, u8 bit);
 
 #endif