Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755176AbbESIUL (ORCPT ); Tue, 19 May 2015 04:20:11 -0400 Received: from down.free-electrons.com ([37.187.137.238]:51613 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755022AbbESIUD (ORCPT ); Tue, 19 May 2015 04:20:03 -0400 Date: Tue, 19 May 2015 10:16:37 +0200 From: Maxime Ripard To: Chen-Yu Tsai Cc: Jens Kuske , Emilio =?iso-8859-1?Q?L=F3pez?= , Mike Turquette , Linus Walleij , Rob Herring , Vishnu Patekar , Hans de Goede , devicetree , linux-arm-kernel , linux-kernel , linux-sunxi Subject: Re: [PATCH v2 04/10] pinctrl: sunxi: Prepare for building SoC specific drivers as modules Message-ID: <20150519081637.GV4004@lukather> References: <1431707940-19372-1-git-send-email-jenskuske@gmail.com> <1431707940-19372-5-git-send-email-jenskuske@gmail.com> <20150517141922.GE4004@lukather> <5559B1AF.2010200@gmail.com> <20150519075537.GU4004@lukather> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LznoD+qmdO0FySBL" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5034 Lines: 138 --LznoD+qmdO0FySBL Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, May 19, 2015 at 04:02:39PM +0800, Chen-Yu Tsai wrote: > On Tue, May 19, 2015 at 3:55 PM, Maxime Ripard > wrote: > > On Mon, May 18, 2015 at 11:32:31AM +0200, Jens Kuske wrote: > >> 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/pinctr= l/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 =3D 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 =3D devm_clk_get(&pdev->dev, NULL); > >> >> - if (IS_ERR(clk)) { > >> >> - ret =3D PTR_ERR(clk); > >> >> + pctl->clk =3D devm_clk_get(&pdev->dev, NULL); > >> >> + if (IS_ERR(pctl->clk)) { > >> >> + ret =3D PTR_ERR(pctl->clk); > >> >> goto gpiochip_error; > >> >> } > >> >> > >> >> - ret =3D clk_prepare_enable(clk); > >> >> + ret =3D clk_prepare_enable(pctl->clk); > >> >> if (ret) > >> >> goto gpiochip_error; > >> >> > >> >> @@ -1015,10 +1014,24 @@ int sunxi_pinctrl_init(struct platform_devi= ce *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 =3D 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 removi= ng > >> 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. > > > > pinctrl_unregister doesn't look like it cares about whether or not > > there's users left in the system. > > > > Maybe the easiest path would be to just make this builtin like Paul > > suggested then ... :/ >=20 > Is there a way to mark modules as not removable? At least we can keep > the multi-platform kernel image small. If there's no module_exit, the module will only be removable through a rmmod -f, which seems like an acceptable solution. Maxime --=20 Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com --LznoD+qmdO0FySBL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJVWvFlAAoJEBx+YmzsjxAgxUoQAI9AYrUTYZqijgT0JCSPcTTe fh4fbKtVlMuIHB9FEYfRMIJHuby/5/TjjVxQuDpMVyYCJuBLzs71nEfQ495Uy3r5 maAj+qacOT/urPZeL1Lvb6AFz5GV48iUp/cdv8ooyVkDCz29soKN17YUtz+KThjJ tEmMKhujA9yUWPcFMv/rlncq7ttMpFC3siBj+z1vOJnPXTJ/cHvsC+iyMIvxPUYa 3LFkMPl3adQKW45/WjxMvVisL1j3Bxh+IocFwafc6DO6WX8cI34pCG88mu5+l4Il PqSqxAxSj++aliKGKNqPMccsI9iIGkT/WDCJMJDQeQATJHrYZomJLBBxTH6a2IYN M6en1T5S/z60AXL5SbeQkqR1JVtQ7+F578eRhI3H6bv+FXJzai6uKloTUfZ4hCXa +UnOvgtjIGxcLzUIMD2Rxo5QECpvF2Kn+aPyL0NX/4B4mnSXShf5BwsLx3rlHZU5 /IouWiaS+Nrt8z8fvtTjkG9jCfAJ5Pq/ERXwVGuQKmq+b1o/jXZQwn+XY9R5/YGk og59AsM+h+awA1KyX2HjJo68ivk8OJBv7UiydLOEANlB2a/Og4XOFbHPjk+MYns7 48zjh+fSOFp0/VIjajpu+F7xAQEsGo+uijXxFhsb1T7fV5aR4BL3WOMWUa73d5DE 7fl1xmyh4bST5rgMlc1F =WA94 -----END PGP SIGNATURE----- --LznoD+qmdO0FySBL-- -- 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/