From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934170AbcBDU3H (ORCPT ); Thu, 4 Feb 2016 15:29:07 -0500 Received: from smtp05.smtpout.orange.fr ([80.12.242.127]:48087 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933261AbcBDU3E (ORCPT ); Thu, 4 Feb 2016 15:29:04 -0500 X-ME-Helo: belgarion X-ME-Auth: amFyem1pay5yb2JlcnRAb3JhbmdlLmZy X-ME-Date: Thu, 04 Feb 2016 21:29:02 +0100 X-ME-IP: 109.214.175.60 From: Robert Jarzmik To: Ulf Hansson Cc: linux-mmc , "linux-kernel\@vger.kernel.org" Subject: Re: [PATCH] mmc: pxamci: fix the device-tree probe deferral path References: <1454537992-15839-1-git-send-email-robert.jarzmik@free.fr> X-URL: http://belgarath.falguerolles.org/ Date: Thu, 04 Feb 2016 21:28:59 +0100 In-Reply-To: (Ulf Hansson's message of "Thu, 4 Feb 2016 12:11:37 +0100") Message-ID: <87h9ho5ies.fsf@belgarion.home> User-Agent: Gnus/5.130008 (Ma Gnus v0.8) Emacs/24.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ulf Hansson writes: > On 3 February 2016 at 23:19, Robert Jarzmik wrote: >> When the gpio driver is probed after the mmc one, the read/write gpio >> and card detection one return -EPROBE_DEFER. Unfortunately, the memory >> region remains requested, and upon the next probe, the probe will fail >> anyway with -EBUSY. >> >> Fix this by releasing the memory resource upon probe failure. >> >> Signed-off-by: Robert Jarzmik >> --- >> drivers/mmc/host/pxamci.c | 3 +-- >> 1 file changed, 1 insertion(+), 2 deletions(-) >> >> diff --git a/drivers/mmc/host/pxamci.c b/drivers/mmc/host/pxamci.c >> index 28a057fae0a1..405ec339a1b8 100644 >> --- a/drivers/mmc/host/pxamci.c >> +++ b/drivers/mmc/host/pxamci.c >> @@ -657,7 +657,7 @@ static int pxamci_probe(struct platform_device *pdev) >> if (!r || irq < 0) >> return -ENXIO; >> >> - r = request_mem_region(r->start, SZ_4K, DRIVER_NAME); >> + r = devm_request_mem_region(&pdev->dev, r->start, SZ_4K, DRIVER_NAME); > > I suggest you replace also the ioremap call, thus using > devm_ioremap_resource() is convenient. Yes, of course, for v2. >> @@ -840,7 +840,6 @@ out: >> } >> if (mmc) >> mmc_free_host(mmc); >> - release_resource(r); > > This looks wrong. Hum. Why so ? > Perhaps it's just easier to convert the probe function to use all > devm_* functions, as for example irqs isn't freed either. You're very right. Actually the first patch I had was with devm_irq_request(), and then I reverted that chunk, thinking I was overdoing it, and that this didn't belong to this commit. Silly me, hein ? > In that way, you will solve all problems of also leaking memory in one go. Sure. Cheers. -- Robert