提交 5e0a93e4 编写于 作者: L Linus Torvalds

Merge tag 'gpio-fixes-for-v6.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux

Pull gpio fixes from Bartosz Golaszewski:

 - fix a NULL-pointer dereference at driver unbind and a potential
   resource leak in error path in gpio-mockup

 - make the irqchip immutable in gpio-ftgpio010

 - fix dereferencing a potentially uninitialized variable in gpio-tqmx86

 - fix interrupt registering in gpiolib's character device code

* tag 'gpio-fixes-for-v6.0-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux:
  gpiolib: cdev: Set lineevent_state::irq after IRQ register successfully
  gpio: tqmx86: fix uninitialized variable girq
  gpio: ftgpio010: Make irqchip immutable
  gpio: mockup: Fix potential resource leakage when register a chip
  gpio: mockup: fix NULL pointer dereference when removing debugfs
...@@ -41,14 +41,12 @@ ...@@ -41,14 +41,12 @@
* struct ftgpio_gpio - Gemini GPIO state container * struct ftgpio_gpio - Gemini GPIO state container
* @dev: containing device for this instance * @dev: containing device for this instance
* @gc: gpiochip for this instance * @gc: gpiochip for this instance
* @irq: irqchip for this instance
* @base: remapped I/O-memory base * @base: remapped I/O-memory base
* @clk: silicon clock * @clk: silicon clock
*/ */
struct ftgpio_gpio { struct ftgpio_gpio {
struct device *dev; struct device *dev;
struct gpio_chip gc; struct gpio_chip gc;
struct irq_chip irq;
void __iomem *base; void __iomem *base;
struct clk *clk; struct clk *clk;
}; };
...@@ -70,6 +68,7 @@ static void ftgpio_gpio_mask_irq(struct irq_data *d) ...@@ -70,6 +68,7 @@ static void ftgpio_gpio_mask_irq(struct irq_data *d)
val = readl(g->base + GPIO_INT_EN); val = readl(g->base + GPIO_INT_EN);
val &= ~BIT(irqd_to_hwirq(d)); val &= ~BIT(irqd_to_hwirq(d));
writel(val, g->base + GPIO_INT_EN); writel(val, g->base + GPIO_INT_EN);
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
} }
static void ftgpio_gpio_unmask_irq(struct irq_data *d) static void ftgpio_gpio_unmask_irq(struct irq_data *d)
...@@ -78,6 +77,7 @@ static void ftgpio_gpio_unmask_irq(struct irq_data *d) ...@@ -78,6 +77,7 @@ static void ftgpio_gpio_unmask_irq(struct irq_data *d)
struct ftgpio_gpio *g = gpiochip_get_data(gc); struct ftgpio_gpio *g = gpiochip_get_data(gc);
u32 val; u32 val;
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
val = readl(g->base + GPIO_INT_EN); val = readl(g->base + GPIO_INT_EN);
val |= BIT(irqd_to_hwirq(d)); val |= BIT(irqd_to_hwirq(d));
writel(val, g->base + GPIO_INT_EN); writel(val, g->base + GPIO_INT_EN);
...@@ -221,6 +221,16 @@ static int ftgpio_gpio_set_config(struct gpio_chip *gc, unsigned int offset, ...@@ -221,6 +221,16 @@ static int ftgpio_gpio_set_config(struct gpio_chip *gc, unsigned int offset,
return 0; return 0;
} }
static const struct irq_chip ftgpio_irq_chip = {
.name = "FTGPIO010",
.irq_ack = ftgpio_gpio_ack_irq,
.irq_mask = ftgpio_gpio_mask_irq,
.irq_unmask = ftgpio_gpio_unmask_irq,
.irq_set_type = ftgpio_gpio_set_irq_type,
.flags = IRQCHIP_IMMUTABLE,
GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int ftgpio_gpio_probe(struct platform_device *pdev) static int ftgpio_gpio_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
...@@ -277,14 +287,8 @@ static int ftgpio_gpio_probe(struct platform_device *pdev) ...@@ -277,14 +287,8 @@ static int ftgpio_gpio_probe(struct platform_device *pdev)
if (!IS_ERR(g->clk)) if (!IS_ERR(g->clk))
g->gc.set_config = ftgpio_gpio_set_config; g->gc.set_config = ftgpio_gpio_set_config;
g->irq.name = "FTGPIO010";
g->irq.irq_ack = ftgpio_gpio_ack_irq;
g->irq.irq_mask = ftgpio_gpio_mask_irq;
g->irq.irq_unmask = ftgpio_gpio_unmask_irq;
g->irq.irq_set_type = ftgpio_gpio_set_irq_type;
girq = &g->gc.irq; girq = &g->gc.irq;
girq->chip = &g->irq; gpio_irq_chip_set_chip(girq, &ftgpio_irq_chip);
girq->parent_handler = ftgpio_gpio_irq_handler; girq->parent_handler = ftgpio_gpio_irq_handler;
girq->num_parents = 1; girq->num_parents = 1;
girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents), girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
......
...@@ -533,8 +533,10 @@ static int __init gpio_mockup_register_chip(int idx) ...@@ -533,8 +533,10 @@ static int __init gpio_mockup_register_chip(int idx)
} }
fwnode = fwnode_create_software_node(properties, NULL); fwnode = fwnode_create_software_node(properties, NULL);
if (IS_ERR(fwnode)) if (IS_ERR(fwnode)) {
kfree_strarray(line_names, ngpio);
return PTR_ERR(fwnode); return PTR_ERR(fwnode);
}
pdevinfo.name = "gpio-mockup"; pdevinfo.name = "gpio-mockup";
pdevinfo.id = idx; pdevinfo.id = idx;
...@@ -597,9 +599,9 @@ static int __init gpio_mockup_init(void) ...@@ -597,9 +599,9 @@ static int __init gpio_mockup_init(void)
static void __exit gpio_mockup_exit(void) static void __exit gpio_mockup_exit(void)
{ {
gpio_mockup_unregister_pdevs();
debugfs_remove_recursive(gpio_mockup_dbg_dir); debugfs_remove_recursive(gpio_mockup_dbg_dir);
platform_driver_unregister(&gpio_mockup_driver); platform_driver_unregister(&gpio_mockup_driver);
gpio_mockup_unregister_pdevs();
} }
module_init(gpio_mockup_init); module_init(gpio_mockup_init);
......
...@@ -307,6 +307,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) ...@@ -307,6 +307,8 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
girq->default_type = IRQ_TYPE_NONE; girq->default_type = IRQ_TYPE_NONE;
girq->handler = handle_simple_irq; girq->handler = handle_simple_irq;
girq->init_valid_mask = tqmx86_init_irq_valid_mask; girq->init_valid_mask = tqmx86_init_irq_valid_mask;
irq_domain_set_pm_device(girq->domain, dev);
} }
ret = devm_gpiochip_add_data(dev, chip, gpio); ret = devm_gpiochip_add_data(dev, chip, gpio);
...@@ -315,8 +317,6 @@ static int tqmx86_gpio_probe(struct platform_device *pdev) ...@@ -315,8 +317,6 @@ static int tqmx86_gpio_probe(struct platform_device *pdev)
goto out_pm_dis; goto out_pm_dis;
} }
irq_domain_set_pm_device(girq->domain, dev);
dev_info(dev, "GPIO functionality initialized with %d pins\n", dev_info(dev, "GPIO functionality initialized with %d pins\n",
chip->ngpio); chip->ngpio);
......
...@@ -1986,7 +1986,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) ...@@ -1986,7 +1986,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
ret = -ENODEV; ret = -ENODEV;
goto out_free_le; goto out_free_le;
} }
le->irq = irq;
if (eflags & GPIOEVENT_REQUEST_RISING_EDGE) if (eflags & GPIOEVENT_REQUEST_RISING_EDGE)
irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ?
...@@ -2000,7 +1999,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) ...@@ -2000,7 +1999,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
init_waitqueue_head(&le->wait); init_waitqueue_head(&le->wait);
/* Request a thread to read the events */ /* Request a thread to read the events */
ret = request_threaded_irq(le->irq, ret = request_threaded_irq(irq,
lineevent_irq_handler, lineevent_irq_handler,
lineevent_irq_thread, lineevent_irq_thread,
irqflags, irqflags,
...@@ -2009,6 +2008,8 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) ...@@ -2009,6 +2008,8 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip)
if (ret) if (ret)
goto out_free_le; goto out_free_le;
le->irq = irq;
fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC); fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC);
if (fd < 0) { if (fd < 0) {
ret = fd; ret = fd;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册