Commit d2db44bd authored by Imre Deak's avatar Imre Deak Committed by Juha Yrjola

CBUS: Tahvo: add atomic set and clear register bits function

Signed-off-by: default avatarImre Deak <imre.deak@solidboot.com>
Signed-off-by: default avatarJuha Yrjola <juha.yrjola@solidboot.com>
parent b87347f7
...@@ -91,6 +91,26 @@ void tahvo_write_reg(int reg, u16 val) ...@@ -91,6 +91,26 @@ void tahvo_write_reg(int reg, u16 val)
cbus_write_reg(cbus_host, TAHVO_ID, reg, val); cbus_write_reg(cbus_host, TAHVO_ID, reg, val);
} }
/**
* tahvo_set_clear_reg_bits - set and clear register bits atomically
* @reg: the register to write to
* @bits: the bits to set
*
* This function sets and clears the specified Tahvo register bits atomically
*/
void tahvo_set_clear_reg_bits(int reg, u16 set, u16 clear)
{
unsigned long flags;
u16 w;
spin_lock_irqsave(&tahvo_lock, flags);
w = tahvo_read_reg(reg);
w &= ~clear;
w |= set;
tahvo_write_reg(reg, w);
spin_unlock_irqrestore(&tahvo_lock, flags);
}
/* /*
* Disable given TAHVO interrupt * Disable given TAHVO interrupt
*/ */
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
int tahvo_read_reg(int reg); int tahvo_read_reg(int reg);
void tahvo_write_reg(int reg, u16 val); void tahvo_write_reg(int reg, u16 val);
void tahvo_set_clear_reg_bits(int reg, u16 set, u16 clear);
int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name); int tahvo_request_irq(int id, void *irq_handler, unsigned long arg, char *name);
void tahvo_free_irq(int id); void tahvo_free_irq(int id);
void tahvo_enable_irq(int id); void tahvo_enable_irq(int id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment