69
69
* @fifo_size: size of the FIFO passed in.
70
70
* @isr_mask: cached copy of local ISR enables.
71
71
* @isr_status: cached copy of local ISR status.
72
- * @lock: spinlock for IRQ synchronization.
73
72
* @isr_mutex: mutex for IRQ thread.
74
73
*/
75
74
struct altr_i2c_dev {
@@ -86,27 +85,21 @@ struct altr_i2c_dev {
86
85
u32 fifo_size ;
87
86
u32 isr_mask ;
88
87
u32 isr_status ;
89
- spinlock_t lock ; /* IRQ synchronization */
90
88
struct mutex isr_mutex ;
91
89
};
92
90
93
91
static void
94
92
altr_i2c_int_enable (struct altr_i2c_dev * idev , u32 mask , bool enable )
95
93
{
96
- unsigned long flags ;
97
94
u32 int_en ;
98
95
99
- spin_lock_irqsave (& idev -> lock , flags );
100
-
101
96
int_en = readl (idev -> base + ALTR_I2C_ISER );
102
97
if (enable )
103
98
idev -> isr_mask = int_en | mask ;
104
99
else
105
100
idev -> isr_mask = int_en & ~mask ;
106
101
107
102
writel (idev -> isr_mask , idev -> base + ALTR_I2C_ISER );
108
-
109
- spin_unlock_irqrestore (& idev -> lock , flags );
110
103
}
111
104
112
105
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
339
347
340
time_left = wait_for_completion_timeout (& idev -> msg_complete ,
348
341
ALTR_I2C_XFER_TIMEOUT );
342
+ mutex_lock (& idev -> isr_mutex );
349
343
altr_i2c_int_enable (idev , imask , false);
350
344
351
345
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
352
}
359
353
360
354
altr_i2c_core_disable (idev );
355
+ mutex_unlock (& idev -> isr_mutex );
361
356
362
357
return idev -> msg_err ;
363
358
}
@@ -411,7 +406,6 @@ static int altr_i2c_probe(struct platform_device *pdev)
411
406
412
407
idev -> dev = & pdev -> dev ;
413
408
init_completion (& idev -> msg_complete );
414
- spin_lock_init (& idev -> lock );
415
409
mutex_init (& idev -> isr_mutex );
416
410
417
411
ret = device_property_read_u32 (idev -> dev , "fifo-size" ,
@@ -449,7 +443,9 @@ static int altr_i2c_probe(struct platform_device *pdev)
449
443
return ret ;
450
444
}
451
445
446
+ mutex_lock (& idev -> isr_mutex );
452
447
altr_i2c_init (idev );
448
+ mutex_unlock (& idev -> isr_mutex );
453
449
454
450
i2c_set_adapdata (& idev -> adapter , idev );
455
451
strlcpy (idev -> adapter .name , pdev -> name , sizeof (idev -> adapter .name ));
0 commit comments