i2c: tegra: Remove synchronization between init and isr
Chaitanya Bandi [Thu, 22 Mar 2012 11:47:37 +0000 (16:47 +0530)]
Removed unnecessary synchronization between init and isr
because clock driver is making sure that any operations
will be completed before disabling the driver clock.

Change-Id: I545e48be73697e023fedb8c663402c15e2a472df
Signed-off-by: Chaitanya Bandi <bandik@nvidia.com>
Reviewed-on: http://git-master/r/91779
Reviewed-by: Automatic_Commit_Validation_User
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>

drivers/i2c/busses/i2c-tegra.c

index 101ec47..8468804 100644 (file)
@@ -151,12 +151,10 @@ struct tegra_i2c_dev {
        struct clk *fast_clk;
        struct resource *iomem;
        struct rt_mutex dev_lock;
-       spinlock_t clk_lock;
        void __iomem *base;
        int cont_id;
        int irq;
        bool irq_disabled;
-       bool controller_enabled;
        int is_dvc;
        bool is_slave;
        struct completion msg_complete;
@@ -479,14 +477,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
        u32 status;
        const u32 status_err = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST | I2C_INT_TX_FIFO_OVERFLOW;
        struct tegra_i2c_dev *i2c_dev = dev_id;
-       unsigned long flags;
-
-       spin_lock_irqsave(&i2c_dev->clk_lock, flags);
-       if (!i2c_dev->controller_enabled) {
-               dev_warn(i2c_dev->dev, "Controller not enabled\n");
-               spin_unlock_irqrestore(&i2c_dev->clk_lock, flags);
-               return IRQ_NONE;
-       }
 
        status = i2c_readl(i2c_dev, I2C_INT_STATUS);
 
@@ -570,7 +560,6 @@ static irqreturn_t tegra_i2c_isr(int irq, void *dev_id)
                complete(&i2c_dev->msg_complete);
        }
 
-       spin_unlock_irqrestore(&i2c_dev->clk_lock, flags);
        return IRQ_HANDLED;
 
 err:
@@ -605,7 +594,6 @@ err:
                dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
 
        complete(&i2c_dev->msg_complete);
-       spin_unlock_irqrestore(&i2c_dev->clk_lock, flags);
        return IRQ_HANDLED;
 }
 
@@ -615,7 +603,6 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_bus *i2c_bus,
        struct tegra_i2c_dev *i2c_dev = i2c_bus->dev;
        u32 int_mask;
        int ret;
-       unsigned long flags;
        int arb_stat;
 
        if (msg->len == 0)
@@ -676,10 +663,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_bus *i2c_bus,
                        "i2c transfer timed out, addr 0x%04x, data 0x%02x\n",
                        msg->addr, msg->buf[0]);
 
-               spin_lock_irqsave(&i2c_dev->clk_lock, flags);
-               i2c_dev->controller_enabled = false;
                tegra_i2c_init(i2c_dev);
-               spin_unlock_irqrestore(&i2c_dev->clk_lock, flags);
                return -ETIMEDOUT;
        }
 
@@ -698,10 +682,7 @@ static int tegra_i2c_xfer_msg(struct tegra_i2c_bus *i2c_bus,
                }
        }
 
-       spin_lock_irqsave(&i2c_dev->clk_lock, flags);
-       i2c_dev->controller_enabled = false;
        tegra_i2c_init(i2c_dev);
-       spin_unlock_irqrestore(&i2c_dev->clk_lock, flags);
 
        if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
                if (msg->flags & I2C_M_IGNORE_NAK)
@@ -722,7 +703,6 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
        struct tegra_i2c_dev *i2c_dev = i2c_bus->dev;
        int i;
        int ret = 0;
-       unsigned long flags;
 
        rt_mutex_lock(&i2c_dev->dev_lock);
 
@@ -751,10 +731,6 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
        if (!i2c_dev->is_clkon_always)
                tegra_i2c_clock_enable(i2c_dev);
 
-       spin_lock_irqsave(&i2c_dev->clk_lock, flags);
-       i2c_dev->controller_enabled = true;
-       spin_unlock_irqrestore(&i2c_dev->clk_lock, flags);
-
        for (i = 0; i < num; i++) {
                int stop = (i == (num - 1)) ? 1  : 0;
                ret = tegra_i2c_xfer_msg(i2c_bus, &msgs[i], stop);
@@ -762,10 +738,6 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
                        break;
        }
 
-       spin_lock_irqsave(&i2c_dev->clk_lock, flags);
-       i2c_dev->controller_enabled = false;
-       spin_unlock_irqrestore(&i2c_dev->clk_lock, flags);
-
        if (!i2c_dev->is_clkon_always)
                tegra_i2c_clock_disable(i2c_dev);
 
@@ -886,9 +858,7 @@ static int tegra_i2c_probe(struct platform_device *pdev)
        i2c_dev->last_bus_clk_rate = plat->bus_clk_rate[0] ?: 100000;
        i2c_dev->msgs = NULL;
        i2c_dev->msgs_num = 0;
-       i2c_dev->controller_enabled = false;
        rt_mutex_init(&i2c_dev->dev_lock);
-       spin_lock_init(&i2c_dev->clk_lock);
 
        i2c_dev->slave_addr = plat->slave_addr;
        i2c_dev->hs_master_code = plat->hs_master_code;