Skip to content

Commit ab1c609

Browse files
AtsushiNemotowsakernel
authored andcommitted
i2c: altera: cleanup spinlock
Protect altr_i2c_int_enable() by the mutex and remove unneeded spinlock. Signed-off-by: Atsushi Nemoto <[email protected]> Reviewed-by: Thor Thayer <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent f89c326 commit ab1c609

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

drivers/i2c/busses/i2c-altera.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
* @fifo_size: size of the FIFO passed in.
7070
* @isr_mask: cached copy of local ISR enables.
7171
* @isr_status: cached copy of local ISR status.
72-
* @lock: spinlock for IRQ synchronization.
7372
* @isr_mutex: mutex for IRQ thread.
7473
*/
7574
struct altr_i2c_dev {
@@ -86,27 +85,21 @@ struct altr_i2c_dev {
8685
u32 fifo_size;
8786
u32 isr_mask;
8887
u32 isr_status;
89-
spinlock_t lock; /* IRQ synchronization */
9088
struct mutex isr_mutex;
9189
};
9290

9391
static void
9492
altr_i2c_int_enable(struct altr_i2c_dev *idev, u32 mask, bool enable)
9593
{
96-
unsigned long flags;
9794
u32 int_en;
9895

99-
spin_lock_irqsave(&idev->lock, flags);
100-
10196
int_en = readl(idev->base + ALTR_I2C_ISER);
10297
if (enable)
10398
idev->isr_mask = int_en | mask;
10499
else
105100
idev->isr_mask = int_en & ~mask;
106101

107102
writel(idev->isr_mask, idev->base + ALTR_I2C_ISER);
108-
109-
spin_unlock_irqrestore(&idev->lock, flags);
110103
}
111104

112105
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)
346339

347340
time_left = wait_for_completion_timeout(&idev->msg_complete,
348341
ALTR_I2C_XFER_TIMEOUT);
342+
mutex_lock(&idev->isr_mutex);
349343
altr_i2c_int_enable(idev, imask, false);
350344

351345
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)
358352
}
359353

360354
altr_i2c_core_disable(idev);
355+
mutex_unlock(&idev->isr_mutex);
361356

362357
return idev->msg_err;
363358
}
@@ -411,7 +406,6 @@ static int altr_i2c_probe(struct platform_device *pdev)
411406

412407
idev->dev = &pdev->dev;
413408
init_completion(&idev->msg_complete);
414-
spin_lock_init(&idev->lock);
415409
mutex_init(&idev->isr_mutex);
416410

417411
ret = device_property_read_u32(idev->dev, "fifo-size",
@@ -449,7 +443,9 @@ static int altr_i2c_probe(struct platform_device *pdev)
449443
return ret;
450444
}
451445

446+
mutex_lock(&idev->isr_mutex);
452447
altr_i2c_init(idev);
448+
mutex_unlock(&idev->isr_mutex);
453449

454450
i2c_set_adapdata(&idev->adapter, idev);
455451
strlcpy(idev->adapter.name, pdev->name, sizeof(idev->adapter.name));

0 commit comments

Comments
 (0)