From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751748AbdINJZ5 (ORCPT ); Thu, 14 Sep 2017 05:25:57 -0400 Received: from mail-wm0-f46.google.com ([74.125.82.46]:46708 "EHLO mail-wm0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751699AbdINJZz (ORCPT ); Thu, 14 Sep 2017 05:25:55 -0400 X-Google-Smtp-Source: AOwi7QAbN9muoavMkjrbd2VB7YvRKBB1boucMjmn+KjOetdJrERpG8MLs8fjoZXilKFn+N94W46tYg== Date: Thu, 14 Sep 2017 10:25:51 +0100 From: Lee Jones To: Martin Kaiser Cc: kernel@pengutronix.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] mfd: fsl-imx25: clean up irq settings during removal Message-ID: <20170914092551.shsyujrj4obtepjh@dell> References: <1505205256-6828-1-git-send-email-martin@kaiser.cx> <1505205256-6828-2-git-send-email-martin@kaiser.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1505205256-6828-2-git-send-email-martin@kaiser.cx> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Sep 2017, Martin Kaiser wrote: > When fsl-imx25-tsadc is compiled as a module, unloading and reloading > the module will lead to a crash. > > Add a removal function which clears the irq handler and removes the irq > domain. With this cleanup in place, it's possible to unload and reload > the module. More information please. What is it specifically that causes the crash? Why is this code not required? What's stopping this causing a leak? > Signed-off-by: Martin Kaiser > --- > drivers/mfd/fsl-imx25-tsadc.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/drivers/mfd/fsl-imx25-tsadc.c b/drivers/mfd/fsl-imx25-tsadc.c > index 14189ef..a6423bd 100644 > --- a/drivers/mfd/fsl-imx25-tsadc.c > +++ b/drivers/mfd/fsl-imx25-tsadc.c > @@ -179,6 +179,19 @@ static int mx25_tsadc_probe(struct platform_device *pdev) > return devm_of_platform_populate(dev); > } > > +static int __exit mx25_tsadc_remove(struct platform_device *pdev) > +{ > + struct mx25_tsadc *tsadc = platform_get_drvdata(pdev); > + int irq = platform_get_irq(pdev, 0); > + > + if (irq) { > + irq_set_chained_handler_and_data(irq, NULL, NULL); > + irq_domain_remove(tsadc->domain); > + } > + > + return 0; > +} > + > static const struct of_device_id mx25_tsadc_ids[] = { > { .compatible = "fsl,imx25-tsadc" }, > { /* Sentinel */ } > @@ -191,6 +204,7 @@ static struct platform_driver mx25_tsadc_driver = { > .of_match_table = of_match_ptr(mx25_tsadc_ids), > }, > .probe = mx25_tsadc_probe, > + .remove = __exit_p(mx25_tsadc_remove), > }; > module_platform_driver(mx25_tsadc_driver); > -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog