Skip to content

Commit a9ca033

Browse files
committed
Merge tag 'gpio-fixes-for-v6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio fixes from Bartosz Golaszewski: "Here's another round of fixes from the GPIO subsystem for this release cycle. There's one commit adding synchronization to an ioctl() we overlooked previously and another synchronization changeset for one of the drivers: - add protection against GPIO device removal to an overlooked ioctl() - synchronize the interrupt mask register manually in gpio-dwapb" * tag 'gpio-fixes-for-v6.7-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: gpio: dwapb: mask/unmask IRQ when disable/enale it gpiolib: cdev: add gpio_device locking wrapper around gpio_ioctl()
2 parents b7bc7bc + 1cc3542 commit a9ca033

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

drivers/gpio/gpio-dwapb.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,26 +282,30 @@ static void dwapb_irq_enable(struct irq_data *d)
282282
{
283283
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
284284
struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
285+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
285286
unsigned long flags;
286287
u32 val;
287288

288289
raw_spin_lock_irqsave(&gc->bgpio_lock, flags);
289-
val = dwapb_read(gpio, GPIO_INTEN);
290-
val |= BIT(irqd_to_hwirq(d));
290+
val = dwapb_read(gpio, GPIO_INTEN) | BIT(hwirq);
291291
dwapb_write(gpio, GPIO_INTEN, val);
292+
val = dwapb_read(gpio, GPIO_INTMASK) & ~BIT(hwirq);
293+
dwapb_write(gpio, GPIO_INTMASK, val);
292294
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
293295
}
294296

295297
static void dwapb_irq_disable(struct irq_data *d)
296298
{
297299
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
298300
struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
301+
irq_hw_number_t hwirq = irqd_to_hwirq(d);
299302
unsigned long flags;
300303
u32 val;
301304

302305
raw_spin_lock_irqsave(&gc->bgpio_lock, flags);
303-
val = dwapb_read(gpio, GPIO_INTEN);
304-
val &= ~BIT(irqd_to_hwirq(d));
306+
val = dwapb_read(gpio, GPIO_INTMASK) | BIT(hwirq);
307+
dwapb_write(gpio, GPIO_INTMASK, val);
308+
val = dwapb_read(gpio, GPIO_INTEN) & ~BIT(hwirq);
305309
dwapb_write(gpio, GPIO_INTEN, val);
306310
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
307311
}

drivers/gpio/gpiolib-cdev.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2481,10 +2481,7 @@ static int lineinfo_unwatch(struct gpio_chardev_data *cdev, void __user *ip)
24812481
return 0;
24822482
}
24832483

2484-
/*
2485-
* gpio_ioctl() - ioctl handler for the GPIO chardev
2486-
*/
2487-
static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2484+
static long gpio_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg)
24882485
{
24892486
struct gpio_chardev_data *cdev = file->private_data;
24902487
struct gpio_device *gdev = cdev->gdev;
@@ -2521,6 +2518,17 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
25212518
}
25222519
}
25232520

2521+
/*
2522+
* gpio_ioctl() - ioctl handler for the GPIO chardev
2523+
*/
2524+
static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
2525+
{
2526+
struct gpio_chardev_data *cdev = file->private_data;
2527+
2528+
return call_ioctl_locked(file, cmd, arg, cdev->gdev,
2529+
gpio_ioctl_unlocked);
2530+
}
2531+
25242532
#ifdef CONFIG_COMPAT
25252533
static long gpio_ioctl_compat(struct file *file, unsigned int cmd,
25262534
unsigned long arg)

0 commit comments

Comments
 (0)