Message ID | 20170802075126.17637-5-brgl@bgdev.pl |
---|---|
State | New |
Headers | show |
Hi, On Wednesday 02 August 2017 09:51:24, Bartosz Golaszewski wrote: > Use resource managed variants of irq_alloc_generic_chip() and > irq_setup_generic_chip(). Is this really useful for drivers which can only be built-in? This is probably valid for the other drives as well. Best regards, Alexander -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
2017-08-02 10:09 GMT+02:00 Alexander Stein <alexander.stein@systec-electronic.com>: > Hi, > > On Wednesday 02 August 2017 09:51:24, Bartosz Golaszewski wrote: >> Use resource managed variants of irq_alloc_generic_chip() and >> irq_setup_generic_chip(). > > Is this really useful for drivers which can only be built-in? This is probably > valid for the other drives as well. > > Best regards, > Alexander > gpio-pch and gpio-ml-ioh are loadable and they leak the resources allocated with these routines. Other drivers affected by this series already use other devm_*() functions and these changes just make them more consistent. Thanks, Bartosz -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Aug 2, 2017 at 11:09 AM, Alexander Stein <alexander.stein@systec-electronic.com> wrote: > On Wednesday 02 August 2017 09:51:24, Bartosz Golaszewski wrote: >> Use resource managed variants of irq_alloc_generic_chip() and >> irq_setup_generic_chip(). > > Is this really useful for drivers which can only be built-in? But you still can unbind the driver and its ->remove() will be called (in case of no remove, devres still on the table), right?
On Wed, Aug 2, 2017 at 10:32 AM, Andy Shevchenko <andy.shevchenko@gmail.com> wrote: > On Wed, Aug 2, 2017 at 11:09 AM, Alexander Stein > <alexander.stein@systec-electronic.com> wrote: >> On Wednesday 02 August 2017 09:51:24, Bartosz Golaszewski wrote: >>> Use resource managed variants of irq_alloc_generic_chip() and >>> irq_setup_generic_chip(). >> >> Is this really useful for drivers which can only be built-in? > > But you still can unbind the driver and its ->remove() will be called > (in case of no remove, devres still on the table), right? Maybe the patches need to be combines with a .suppress_bind_attrs = true in the driver struct? I backed out the patches I applied, I thought the series were older, sorry stressed at work today. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
2017-08-02 13:41 GMT+02:00 Linus Walleij <linus.walleij@linaro.org>: > On Wed, Aug 2, 2017 at 10:32 AM, Andy Shevchenko > <andy.shevchenko@gmail.com> wrote: >> On Wed, Aug 2, 2017 at 11:09 AM, Alexander Stein >> <alexander.stein@systec-electronic.com> wrote: >>> On Wednesday 02 August 2017 09:51:24, Bartosz Golaszewski wrote: >>>> Use resource managed variants of irq_alloc_generic_chip() and >>>> irq_setup_generic_chip(). >>> >>> Is this really useful for drivers which can only be built-in? >> >> But you still can unbind the driver and its ->remove() will be called >> (in case of no remove, devres still on the table), right? > > Maybe the patches need to be combines with a > .suppress_bind_attrs = true in the driver struct? > > I backed out the patches I applied, I thought the series were older, > sorry stressed at work today. > gpio-sodaville sets .supress_bind_attrs to true. Other built-in drivers need updates for that, but I think this could go in a separate series as using devres doesn't affect the bind/unbind functionality/issue. Thanks, Bartosz -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c index 3abea3f0b307..d5f3db49f48e 100644 --- a/drivers/gpio/gpio-mxc.c +++ b/drivers/gpio/gpio-mxc.c @@ -66,6 +66,7 @@ struct mxc_gpio_port { int irq_high; struct irq_domain *domain; struct gpio_chip gc; + struct device *dev; u32 both_edges; }; @@ -344,9 +345,10 @@ static int mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) { struct irq_chip_generic *gc; struct irq_chip_type *ct; + int rv; - gc = irq_alloc_generic_chip("gpio-mxc", 1, irq_base, - port->base, handle_level_irq); + gc = devm_irq_alloc_generic_chip(port->dev, "gpio-mxc", 1, irq_base, + port->base, handle_level_irq); if (!gc) return -ENOMEM; gc->private = port; @@ -361,10 +363,11 @@ static int mxc_gpio_init_gc(struct mxc_gpio_port *port, int irq_base) ct->regs.ack = GPIO_ISR; ct->regs.mask = GPIO_IMR; - irq_setup_generic_chip(gc, IRQ_MSK(32), IRQ_GC_INIT_NESTED_LOCK, - IRQ_NOREQUEST, 0); + rv = devm_irq_setup_generic_chip(port->dev, gc, IRQ_MSK(32), + IRQ_GC_INIT_NESTED_LOCK, + IRQ_NOREQUEST, 0); - return 0; + return rv; } static void mxc_gpio_get_hw(struct platform_device *pdev) @@ -418,6 +421,8 @@ static int mxc_gpio_probe(struct platform_device *pdev) if (!port) return -ENOMEM; + port->dev = &pdev->dev; + iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); port->base = devm_ioremap_resource(&pdev->dev, iores); if (IS_ERR(port->base))
Use resource managed variants of irq_alloc_generic_chip() and irq_setup_generic_chip(). Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl> --- drivers/gpio/gpio-mxc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-)