Skip to content

Commit b3121ea

Browse files
committed
gpio:phytium: Add lock for irq_set_wake function
Add lock for irq_set_wake function to prevent concurrency access register issue. Mainline: Open-Source Signed-off-by: Cui Fulong <cuifulong2112@phytium.com.cn> Signed-off-by: Li Yuze <liyuze@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
1 parent 28fd009 commit b3121ea

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/gpio/gpio-phytium-core.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ int phytium_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
385385
struct phytium_gpio *gpio = gpiochip_get_data(gc);
386386
struct phytium_gpio_ctx *ctx = &gpio->ctx;
387387
irq_hw_number_t bit = irqd_to_hwirq(d);
388+
unsigned long flags;
388389
int ret;
389390

390391
if (gpio->irq[bit])
@@ -395,6 +396,8 @@ int phytium_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
395396
if (ret < 0)
396397
dev_err(gc->parent, "set gpio irq wake failed!\n");
397398

399+
raw_spin_lock_irqsave(&gpio->lock, flags);
400+
398401
if (enable) {
399402
ctx->wake_en |= BIT(bit);
400403
if (gpio->is_resuming == 1) {
@@ -404,6 +407,8 @@ int phytium_gpio_irq_set_wake(struct irq_data *d, unsigned int enable)
404407
} else
405408
ctx->wake_en &= ~BIT(bit);
406409

410+
raw_spin_unlock_irqrestore(&gpio->lock, flags);
411+
407412
return 0;
408413
}
409414
EXPORT_SYMBOL_GPL(phytium_gpio_irq_set_wake);

0 commit comments

Comments
 (0)