From patchwork Sun Jul 17 15:38:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Drake X-Patchwork-Id: 984262 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p6HGI7pL004314 for ; Sun, 17 Jul 2011 16:18:07 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755816Ab1GQQSG (ORCPT ); Sun, 17 Jul 2011 12:18:06 -0400 Received: from queueout02-winn.ispmail.ntl.com ([81.103.221.56]:45847 "EHLO queueout02-winn.ispmail.ntl.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753796Ab1GQQSF (ORCPT ); Sun, 17 Jul 2011 12:18:05 -0400 Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20110717153823.DUVC5301.mtaout03-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com>; Sun, 17 Jul 2011 16:38:23 +0100 Received: from zog.reactivated.net ([86.14.215.141]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.3.00.04.00 201-2196-133-20080908) with ESMTP id <20110717153823.KCGJ24017.aamtaout03-winn.ispmail.ntl.com@zog.reactivated.net>; Sun, 17 Jul 2011 16:38:23 +0100 Received: by zog.reactivated.net (Postfix, from userid 1000) id 695FC9D401C; Sun, 17 Jul 2011 16:38:21 +0100 (BST) From: Daniel Drake To: cjb@laptop.org Cc: linux-mmc@vger.kernel.org Cc: ohad@wizery.com Subject: [PATCH] mmc: fix runtime PM with -ENOSYS suspend case Message-Id: <20110717153821.695FC9D401C@zog.reactivated.net> Date: Sun, 17 Jul 2011 16:38:21 +0100 (BST) X-Cloudmark-Analysis: v=1.1 cv=R50lirqlHffDPPkwUlkuVa99MrvKdVWo//yz83qex8g= c=1 sm=0 a=7q_HyDzS4ekA:10 a=vJ1w_8FsMGIA:10 a=2LjLHKtCAAAA:8 a=Op-mwl0xAAAA:8 a=RRYZF_3mqJSqQwSGSfcA:9 a=QGNbvQlZWqOmi0Gz7EgA:7 a=C3PaYh0q9tsA:10 a=d4CUUju0HPYA:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 17 Jul 2011 16:18:07 +0000 (UTC) From: Ohad Ben-Cohen In the case where a driver returns -ENOSYS from its suspend handler to indicate that the device should be powered down over suspend, the remove routine of the driver was not being called, leading to lots of confusion during resume. The problem is that runtime PM is disabled during this process, and when we reach mmc_sdio_remove, calling the runtime PM functions here (validly) return errors, and this was causing us to skip the remove function. Fix this by ignoring the error value of pm_runtime_get_sync(), which can return valid errors. This also matches the behaviour of pci_device_remove(). Signed-off-by: Daniel Drake --- drivers/mmc/core/sdio_bus.c | 8 ++------ 1 files changed, 2 insertions(+), 6 deletions(-) For linux-3.1. diff --git a/drivers/mmc/core/sdio_bus.c b/drivers/mmc/core/sdio_bus.c index d2565df..e4e6822 100644 --- a/drivers/mmc/core/sdio_bus.c +++ b/drivers/mmc/core/sdio_bus.c @@ -167,11 +167,8 @@ static int sdio_bus_remove(struct device *dev) int ret = 0; /* Make sure card is powered before invoking ->remove() */ - if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) { - ret = pm_runtime_get_sync(dev); - if (ret < 0) - goto out; - } + if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) + pm_runtime_get_sync(dev); drv->remove(func); @@ -191,7 +188,6 @@ static int sdio_bus_remove(struct device *dev) if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) pm_runtime_put_sync(dev); -out: return ret; }