Commit ab1c6093 authored by Atsushi Nemoto's avatar Atsushi Nemoto Committed by Wolfram Sang

i2c: altera: cleanup spinlock

Protect altr_i2c_int_enable() by the mutex and remove unneeded spinlock.
Signed-off-by: default avatarAtsushi Nemoto <atsushi.nemoto@sord.co.jp>
Reviewed-by: default avatarThor Thayer <thor.thayer@linux.intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent f89c326d
...@@ -69,7 +69,6 @@ ...@@ -69,7 +69,6 @@
* @fifo_size: size of the FIFO passed in. * @fifo_size: size of the FIFO passed in.
* @isr_mask: cached copy of local ISR enables. * @isr_mask: cached copy of local ISR enables.
* @isr_status: cached copy of local ISR status. * @isr_status: cached copy of local ISR status.
* @lock: spinlock for IRQ synchronization.
* @isr_mutex: mutex for IRQ thread. * @isr_mutex: mutex for IRQ thread.
*/ */
struct altr_i2c_dev { struct altr_i2c_dev {
...@@ -86,18 +85,14 @@ struct altr_i2c_dev { ...@@ -86,18 +85,14 @@ struct altr_i2c_dev {
u32 fifo_size; u32 fifo_size;
u32 isr_mask; u32 isr_mask;
u32 isr_status; u32 isr_status;
spinlock_t lock; /* IRQ synchronization */
struct mutex isr_mutex; struct mutex isr_mutex;
}; };
static void static void
altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable) altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable)
{ {
unsigned long flags;
u32 int_en; u32 int_en;
spin_lock_irqsave(&idev->lock, flags);
int_en = readl(idev->base + ALTR_I2C_ISER); int_en = readl(idev->base + ALTR_I2C_ISER);
if (enable) if (enable)
idev->isr_mask = int_en | mask; idev->isr_mask = int_en | mask;
...@@ -105,8 +100,6 @@ altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable) ...@@ -105,8 +100,6 @@ altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable)
idev->isr_mask = int_en & ~mask; idev->isr_mask = int_en & ~mask;
writel(idev->isr_mask, idev->base + ALTR_I2C_ISER); writel(idev->isr_mask, idev->base + ALTR_I2C_ISER);
spin_unlock_irqrestore(&idev->lock, flags);
} }
static void altr_i2c_int_clear(struct altr_i2c_dev *idev, u32 mask) static void altr_i2c_int_clear(struct altr_i2c_dev *idev, u32 mask)
...@@ -346,6 +339,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg) ...@@ -346,6 +339,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
time_left = wait_for_completion_timeout(&idev->msg_complete, time_left = wait_for_completion_timeout(&idev->msg_complete,
ALTR_I2C_XFER_TIMEOUT); ALTR_I2C_XFER_TIMEOUT);
mutex_lock(&idev->isr_mutex);
altr_i2c_int_enable(idev, imask, false); altr_i2c_int_enable(idev, imask, false);
value = readl(idev->base + ALTR_I2C_STATUS) & ALTR_I2C_STAT_CORE; value = readl(idev->base + ALTR_I2C_STATUS) & ALTR_I2C_STAT_CORE;
...@@ -358,6 +352,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg) ...@@ -358,6 +352,7 @@ static int altr_i2c_xfer_msg(struct altr_i2c_dev *idev, struct i2c_msg *msg)
} }
altr_i2c_core_disable(idev); altr_i2c_core_disable(idev);
mutex_unlock(&idev->isr_mutex);
return idev->msg_err; return idev->msg_err;
} }
...@@ -411,7 +406,6 @@ static int altr_i2c_probe(struct platform_device *pdev) ...@@ -411,7 +406,6 @@ static int altr_i2c_probe(struct platform_device *pdev)
idev->dev = &pdev->dev; idev->dev = &pdev->dev;
init_completion(&idev->msg_complete); init_completion(&idev->msg_complete);
spin_lock_init(&idev->lock);
mutex_init(&idev->isr_mutex); mutex_init(&idev->isr_mutex);
ret = device_property_read_u32(idev->dev, "fifo-size", ret = device_property_read_u32(idev->dev, "fifo-size",
...@@ -449,7 +443,9 @@ static int altr_i2c_probe(struct platform_device *pdev) ...@@ -449,7 +443,9 @@ static int altr_i2c_probe(struct platform_device *pdev)
return ret; return ret;
} }
mutex_lock(&idev->isr_mutex);
altr_i2c_init(idev); altr_i2c_init(idev);
mutex_unlock(&idev->isr_mutex);
i2c_set_adapdata(&idev->adapter, idev); i2c_set_adapdata(&idev->adapter, idev);
strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name)); strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name));
......
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