Skip to contentSkip to conversation

cbus-retu: Acquire mutex on write operation

PATCH In review Michael Buesch 2 participants 3 messages Feb 26, 2011 – Feb 28, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cbus-retu: Acquire mutex on write operation

The mutex has to be acquired on register write to avoid interference with a simultaneous retu_set_clear_reg_bits operation.

---

Tested on n810.

drivers/cbus/retu.c +2 -0
Index: linux-omap-2.6/drivers/cbus/retu.c
===================================================================
@@ -120,7 +120,9 @@
 {
 	struct retu		*retu = dev_get_drvdata(child->parent);
 
+	mutex_lock(&retu->mutex);
 	__retu_write_reg(retu, reg, val);
+	mutex_unlock(&retu->mutex);
 }
 EXPORT_SYMBOL_GPL(retu_write_reg);
 
#1 lore raw
Quoted 4 lines · Michael Buesch

The mutex has to be acquired on register write to avoid interference with a simultaneous retu_set_clear_reg_bits operation.

good catch, please do the same for retu_read_reg()

Signature · 1 line
balbi
#2 lore raw
Quoted 7 lines · Felipe Balbi
Quoted 4 lines · Michael Buesch

The mutex has to be acquired on register write to avoid interference with a simultaneous retu_set_clear_reg_bits operation.

good catch, please do the same for retu_read_reg()

I don't think this is necessary, because cbus_read_reg() and cbus_write_reg() are atomic due to the cbus host->lock. I think we can depend on this.
We could probably improve the comment on the lock in cbus_transfer(), though.

Signature · 1 line
Greetings Michael.