Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753465AbbERKHY (ORCPT ); Mon, 18 May 2015 06:07:24 -0400 Received: from mail-wg0-f46.google.com ([74.125.82.46]:33311 "EHLO mail-wg0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753253AbbERKHF (ORCPT ); Mon, 18 May 2015 06:07:05 -0400 Message-ID: <5559B1AF.2010200@gmail.com> Date: Mon, 18 May 2015 11:32:31 +0200 From: Jens Kuske User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Maxime Ripard CC: =?windows-1252?Q?Emilio_L=F3pez?= , Mike Turquette , Linus Walleij , Rob Herring , Chen-Yu Tsai , Vishnu Patekar , Hans de Goede , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: Re: [PATCH v2 04/10] pinctrl: sunxi: Prepare for building SoC specific drivers as modules References: <1431707940-19372-1-git-send-email-jenskuske@gmail.com> <1431707940-19372-5-git-send-email-jenskuske@gmail.com> <20150517141922.GE4004@lukather> In-Reply-To: <20150517141922.GE4004@lukather> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2692 Lines: 81 Hi, On 05/17/15 16:19, Maxime Ripard wrote: > On Fri, May 15, 2015 at 06:38:54PM +0200, Jens Kuske wrote: >> Add a remove function and export the init and remove function >> to allow us to build the SoC specific drivers as modules. >> >> Signed-off-by: Jens Kuske >> --- >> drivers/pinctrl/sunxi/pinctrl-sunxi.c | 25 +++++++++++++++++++------ >> drivers/pinctrl/sunxi/pinctrl-sunxi.h | 2 ++ >> 2 files changed, 21 insertions(+), 6 deletions(-) >> >> diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c >> index f8e171b..4ef6b3d 100644 >> --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c >> +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c >> @@ -856,7 +856,6 @@ int sunxi_pinctrl_init(struct platform_device *pdev, >> struct sunxi_pinctrl *pctl; >> struct resource *res; >> int i, ret, last_pin; >> - struct clk *clk; >> >> pctl = devm_kzalloc(&pdev->dev, sizeof(*pctl), GFP_KERNEL); >> if (!pctl) >> @@ -954,13 +953,13 @@ int sunxi_pinctrl_init(struct platform_device *pdev, >> goto gpiochip_error; >> } >> >> - clk = devm_clk_get(&pdev->dev, NULL); >> - if (IS_ERR(clk)) { >> - ret = PTR_ERR(clk); >> + pctl->clk = devm_clk_get(&pdev->dev, NULL); >> + if (IS_ERR(pctl->clk)) { >> + ret = PTR_ERR(pctl->clk); >> goto gpiochip_error; >> } >> >> - ret = clk_prepare_enable(clk); >> + ret = clk_prepare_enable(pctl->clk); >> if (ret) >> goto gpiochip_error; >> >> @@ -1015,10 +1014,24 @@ int sunxi_pinctrl_init(struct platform_device *pdev, >> return 0; >> >> clk_error: >> - clk_disable_unprepare(clk); >> + clk_disable_unprepare(pctl->clk); >> gpiochip_error: >> gpiochip_remove(pctl->chip); >> pinctrl_error: >> pinctrl_unregister(pctl->pctl_dev); >> return ret; >> } >> +EXPORT_SYMBOL(sunxi_pinctrl_init); >> + >> +int sunxi_pinctrl_remove(struct platform_device *pdev) >> +{ >> + struct sunxi_pinctrl *pctl = platform_get_drvdata(pdev); >> + >> + gpiochip_remove(pctl->chip); >> + pinctrl_unregister(pctl->pctl_dev); >> + >> + clk_disable_unprepare(pctl->clk); > > We should also remove the domain and the interrupt mapping here. Ouch, I missed that. Only looked at the *_error: labels. Apart from that, currently the kernel panics some seconds after removing the pinctrl module because mmc wants to access a gpio. Can this be prevented somehow? I think pinctrl must not be removed once other devices use any pin-related things. Jens -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/