Commit a9ca0330 authored by Linus Torvalds's avatar Linus Torvalds

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()
parents b7bc7bce 1cc3542c
...@@ -282,13 +282,15 @@ static void dwapb_irq_enable(struct irq_data *d) ...@@ -282,13 +282,15 @@ static void dwapb_irq_enable(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct dwapb_gpio *gpio = to_dwapb_gpio(gc); struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned long flags; unsigned long flags;
u32 val; u32 val;
raw_spin_lock_irqsave(&gc->bgpio_lock, flags); raw_spin_lock_irqsave(&gc->bgpio_lock, flags);
val = dwapb_read(gpio, GPIO_INTEN); val = dwapb_read(gpio, GPIO_INTEN) | BIT(hwirq);
val |= BIT(irqd_to_hwirq(d));
dwapb_write(gpio, GPIO_INTEN, val); dwapb_write(gpio, GPIO_INTEN, val);
val = dwapb_read(gpio, GPIO_INTMASK) & ~BIT(hwirq);
dwapb_write(gpio, GPIO_INTMASK, val);
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
} }
...@@ -296,12 +298,14 @@ static void dwapb_irq_disable(struct irq_data *d) ...@@ -296,12 +298,14 @@ static void dwapb_irq_disable(struct irq_data *d)
{ {
struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct dwapb_gpio *gpio = to_dwapb_gpio(gc); struct dwapb_gpio *gpio = to_dwapb_gpio(gc);
irq_hw_number_t hwirq = irqd_to_hwirq(d);
unsigned long flags; unsigned long flags;
u32 val; u32 val;
raw_spin_lock_irqsave(&gc->bgpio_lock, flags); raw_spin_lock_irqsave(&gc->bgpio_lock, flags);
val = dwapb_read(gpio, GPIO_INTEN); val = dwapb_read(gpio, GPIO_INTMASK) | BIT(hwirq);
val &= ~BIT(irqd_to_hwirq(d)); dwapb_write(gpio, GPIO_INTMASK, val);
val = dwapb_read(gpio, GPIO_INTEN) & ~BIT(hwirq);
dwapb_write(gpio, GPIO_INTEN, val); dwapb_write(gpio, GPIO_INTEN, val);
raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags); raw_spin_unlock_irqrestore(&gc->bgpio_lock, flags);
} }
......
...@@ -2481,10 +2481,7 @@ static int lineinfo_unwatch(struct gpio_chardev_data *cdev, void __user *ip) ...@@ -2481,10 +2481,7 @@ static int lineinfo_unwatch(struct gpio_chardev_data *cdev, void __user *ip)
return 0; return 0;
} }
/* static long gpio_ioctl_unlocked(struct file *file, unsigned int cmd, unsigned long arg)
* gpio_ioctl() - ioctl handler for the GPIO chardev
*/
static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{ {
struct gpio_chardev_data *cdev = file->private_data; struct gpio_chardev_data *cdev = file->private_data;
struct gpio_device *gdev = cdev->gdev; struct gpio_device *gdev = cdev->gdev;
...@@ -2521,6 +2518,17 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg) ...@@ -2521,6 +2518,17 @@ static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
} }
} }
/*
* gpio_ioctl() - ioctl handler for the GPIO chardev
*/
static long gpio_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
{
struct gpio_chardev_data *cdev = file->private_data;
return call_ioctl_locked(file, cmd, arg, cdev->gdev,
gpio_ioctl_unlocked);
}
#ifdef CONFIG_COMPAT #ifdef CONFIG_COMPAT
static long gpio_ioctl_compat(struct file *file, unsigned int cmd, static long gpio_ioctl_compat(struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment