From 4130923e60c23748bbf23d856bae9e85c786cfe9 Mon Sep 17 00:00:00 2001 From: Nathael Pajani Date: Mon, 11 Mar 2013 17:21:37 +0100 Subject: [PATCH] Removed locking : unusefull, badly implemented, and blocking I2C. --- drivers/i2c.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/drivers/i2c.c b/drivers/i2c.c index 441859b..0d4e539 100644 --- a/drivers/i2c.c +++ b/drivers/i2c.c @@ -33,7 +33,6 @@ * I2C Bus structure * * clock : current i2c clock. - * bus_lock : lock to take hold of the bus. * state : global state of the i2c engine. * master_status : status returned by i2c block as found in "status" register. * @@ -48,7 +47,6 @@ struct i2c_bus { volatile struct lpc_i2c* regs; volatile uint32_t clock; - volatile uint32_t bus_lock; volatile uint32_t state; volatile uint32_t master_status; volatile uint32_t slave_status; @@ -290,13 +288,7 @@ int i2c_read(const void *cmd_buf, size_t cmd_size, const void* ctrl_buf, void* i if ((inbuff == NULL) && (count > 0)) return -EINVAL; - /* Lock acquire */ - if (sync_lock_test_and_set(&mod_i2c.bus_lock, 1) == 1) - return -EAGAIN; - if (mod_i2c.state == I2C_BUSY) { - /* Someone uses the bus without hold of the bus lock ?? */ - sync_lock_release(&mod_i2c.bus_lock); return -EBUSY; } if (mod_i2c.state != I2C_OK) { @@ -349,9 +341,6 @@ int i2c_read(const void *cmd_buf, size_t cmd_size, const void* ctrl_buf, void* i do {} while (mod_i2c.state == I2C_BUSY); mod_i2c.state = I2C_OK; - /* Release the lock */ - sync_lock_release(&mod_i2c.bus_lock); - return ret; } @@ -383,13 +372,7 @@ int i2c_write(const void *buf, size_t count, const void* ctrl_buf) if (buf == NULL) return -EINVAL; - /* Lock acquire */ - if (sync_lock_test_and_set(&mod_i2c.bus_lock, 1) == 1) - return -EAGAIN; - if (mod_i2c.state == I2C_BUSY) { - /* Someone uses the bus without hold of the bus lock ?? */ - sync_lock_release(&mod_i2c.bus_lock); return -EBUSY; } if (mod_i2c.state != I2C_OK) { @@ -442,9 +425,6 @@ int i2c_write(const void *buf, size_t count, const void* ctrl_buf) do {} while (mod_i2c.state == I2C_BUSY); mod_i2c.state = I2C_OK; - /* Release the lock */ - sync_lock_release(&mod_i2c.bus_lock); - return ret; } -- 2.43.0