25
25
#define IRQS_PER_BANK 32
26
26
27
27
#define HWSPNLCK_TIMEOUT 1000 /* usec */
28
- #define HWSPNLCK_RETRY_DELAY 100 /* usec */
29
28
30
29
struct stm32_exti_bank {
31
30
u32 imr_ofst ;
@@ -277,55 +276,24 @@ static int stm32_exti_set_type(struct irq_data *d,
277
276
return 0 ;
278
277
}
279
278
280
- static int stm32_exti_hwspin_lock (struct stm32_exti_chip_data * chip_data )
281
- {
282
- int ret , timeout = 0 ;
283
-
284
- if (!chip_data -> host_data -> hwlock )
285
- return 0 ;
286
-
287
- /*
288
- * Use the x_raw API since we are under spin_lock protection.
289
- * Do not use the x_timeout API because we are under irq_disable
290
- * mode (see __setup_irq())
291
- */
292
- do {
293
- ret = hwspin_trylock_raw (chip_data -> host_data -> hwlock );
294
- if (!ret )
295
- return 0 ;
296
-
297
- udelay (HWSPNLCK_RETRY_DELAY );
298
- timeout += HWSPNLCK_RETRY_DELAY ;
299
- } while (timeout < HWSPNLCK_TIMEOUT );
300
-
301
- if (ret == - EBUSY )
302
- ret = - ETIMEDOUT ;
303
-
304
- if (ret )
305
- pr_err ("%s can't get hwspinlock (%d)\n" , __func__ , ret );
306
-
307
- return ret ;
308
- }
309
-
310
- static void stm32_exti_hwspin_unlock (struct stm32_exti_chip_data * chip_data )
311
- {
312
- if (chip_data -> host_data -> hwlock )
313
- hwspin_unlock_raw (chip_data -> host_data -> hwlock );
314
- }
315
-
316
279
static int stm32_irq_set_type (struct irq_data * d , unsigned int type )
317
280
{
318
281
struct irq_chip_generic * gc = irq_data_get_irq_chip_data (d );
319
282
struct stm32_exti_chip_data * chip_data = gc -> private ;
320
283
const struct stm32_exti_bank * stm32_bank = chip_data -> reg_bank ;
284
+ struct hwspinlock * hwlock = chip_data -> host_data -> hwlock ;
321
285
u32 rtsr , ftsr ;
322
286
int err ;
323
287
324
288
irq_gc_lock (gc );
325
289
326
- err = stm32_exti_hwspin_lock (chip_data );
327
- if (err )
328
- goto unlock ;
290
+ if (hwlock ) {
291
+ err = hwspin_lock_timeout_in_atomic (hwlock , HWSPNLCK_TIMEOUT );
292
+ if (err ) {
293
+ pr_err ("%s can't get hwspinlock (%d)\n" , __func__ , err );
294
+ goto unlock ;
295
+ }
296
+ }
329
297
330
298
rtsr = irq_reg_readl (gc , stm32_bank -> rtsr_ofst );
331
299
ftsr = irq_reg_readl (gc , stm32_bank -> ftsr_ofst );
@@ -338,7 +306,8 @@ static int stm32_irq_set_type(struct irq_data *d, unsigned int type)
338
306
irq_reg_writel (gc , ftsr , stm32_bank -> ftsr_ofst );
339
307
340
308
unspinlock :
341
- stm32_exti_hwspin_unlock (chip_data );
309
+ if (hwlock )
310
+ hwspin_unlock_in_atomic (hwlock );
342
311
unlock :
343
312
irq_gc_unlock (gc );
344
313
@@ -504,15 +473,20 @@ static int stm32_exti_h_set_type(struct irq_data *d, unsigned int type)
504
473
{
505
474
struct stm32_exti_chip_data * chip_data = irq_data_get_irq_chip_data (d );
506
475
const struct stm32_exti_bank * stm32_bank = chip_data -> reg_bank ;
476
+ struct hwspinlock * hwlock = chip_data -> host_data -> hwlock ;
507
477
void __iomem * base = chip_data -> host_data -> base ;
508
478
u32 rtsr , ftsr ;
509
479
int err ;
510
480
511
481
raw_spin_lock (& chip_data -> rlock );
512
482
513
- err = stm32_exti_hwspin_lock (chip_data );
514
- if (err )
515
- goto unlock ;
483
+ if (hwlock ) {
484
+ err = hwspin_lock_timeout_in_atomic (hwlock , HWSPNLCK_TIMEOUT );
485
+ if (err ) {
486
+ pr_err ("%s can't get hwspinlock (%d)\n" , __func__ , err );
487
+ goto unlock ;
488
+ }
489
+ }
516
490
517
491
rtsr = readl_relaxed (base + stm32_bank -> rtsr_ofst );
518
492
ftsr = readl_relaxed (base + stm32_bank -> ftsr_ofst );
@@ -525,7 +499,8 @@ static int stm32_exti_h_set_type(struct irq_data *d, unsigned int type)
525
499
writel_relaxed (ftsr , base + stm32_bank -> ftsr_ofst );
526
500
527
501
unspinlock :
528
- stm32_exti_hwspin_unlock (chip_data );
502
+ if (hwlock )
503
+ hwspin_unlock_in_atomic (hwlock );
529
504
unlock :
530
505
raw_spin_unlock (& chip_data -> rlock );
531
506
0 commit comments