From patchwork Mon Aug 29 13:35:58 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Per Forlin X-Patchwork-Id: 3766 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 959E123F41 for ; Mon, 29 Aug 2011 13:36:43 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 8A468A18365 for ; Mon, 29 Aug 2011 13:36:43 +0000 (UTC) Received: by mail-fx0-f52.google.com with SMTP id 18so6543455fxd.11 for ; Mon, 29 Aug 2011 06:36:43 -0700 (PDT) Received: by 10.223.4.133 with SMTP id 5mr7213831far.81.1314625003443; Mon, 29 Aug 2011 06:36:43 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.11.8 with SMTP id m8cs97193lab; Mon, 29 Aug 2011 06:36:43 -0700 (PDT) Received: by 10.204.141.133 with SMTP id m5mr227277bku.299.1314625003028; Mon, 29 Aug 2011 06:36:43 -0700 (PDT) Received: from mail-bw0-f50.google.com (mail-bw0-f50.google.com [209.85.214.50]) by mx.google.com with ESMTPS id x3si121821bkd.143.2011.08.29.06.36.42 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Aug 2011 06:36:43 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) client-ip=209.85.214.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.214.50 is neither permitted nor denied by best guess record for domain of per.forlin@linaro.org) smtp.mail=per.forlin@linaro.org Received: by mail-bw0-f50.google.com with SMTP id zu5so5582992bkb.37 for ; Mon, 29 Aug 2011 06:36:42 -0700 (PDT) Received: by 10.204.13.69 with SMTP id b5mr2039878bka.289.1314625002258; Mon, 29 Aug 2011 06:36:42 -0700 (PDT) Received: from localhost.localdomain (c-c37f71d5.029-82-6c756e10.cust.bredbandsbolaget.se [213.113.127.195]) by mx.google.com with ESMTPS id m18sm1220341bkt.51.2011.08.29.06.36.40 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 29 Aug 2011 06:36:41 -0700 (PDT) From: Per Forlin To: linaro-dev@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-mmc@vger.kernel.org, Venkatraman S , Russell King - ARM Linux , Santosh , Balaji T Krishnamoorthy , Sourav Poddar Cc: Chris Ball , Per Forlin Subject: [PATCH 1/2] mmc: core: clarify how to use post_req in case of errors Date: Mon, 29 Aug 2011 15:35:58 +0200 Message-Id: <1314624959-4634-2-git-send-email-per.forlin@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314624959-4634-1-git-send-email-per.forlin@linaro.org> References: <1314624959-4634-1-git-send-email-per.forlin@linaro.org> The err condition in post_req() is set to undo a call made to pre_req() that hasn't been started yet. The err condition is not set if an MMC request returns error. Signed-off-by: Per Forlin --- drivers/mmc/core/core.c | 6 ++++++ include/linux/mmc/host.h | 3 +++ 2 files changed, 9 insertions(+), 0 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 91a0a74..542aa06 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -279,8 +279,14 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host, mmc_wait_for_req_done(host, host->areq->mrq); err = host->areq->err_check(host->card, host->areq); if (err) { + /* post process the completed failed request */ mmc_post_req(host, host->areq->mrq, 0); if (areq) + /* + * Cancel the new prepared request, because + * it can't run until the failed + * request has been properly handled. + */ mmc_post_req(host, areq->mrq, -EINVAL); host->areq = NULL; diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h index 1d09562..7896fb4 100644 --- a/include/linux/mmc/host.h +++ b/include/linux/mmc/host.h @@ -108,6 +108,9 @@ struct mmc_host_ops { * It is optional for the host to implement pre_req and post_req in * order to support double buffering of requests (prepare one * request while another request is active). + * pre_req() must always be followed by a post_req(). + * To undo a call made to pre_req(), call post_req() with + * a nonzero err condition. */ void (*post_req)(struct mmc_host *host, struct mmc_request *req, int err);