From patchwork Thu Sep 26 19:22:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grant Grundler X-Patchwork-Id: 2950971 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 464029F288 for ; Thu, 26 Sep 2013 19:24:14 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5314F201ED for ; Thu, 26 Sep 2013 19:24:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 443FB202F9 for ; Thu, 26 Sep 2013 19:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754254Ab3IZTXq (ORCPT ); Thu, 26 Sep 2013 15:23:46 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:37366 "EHLO mail-pb0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752998Ab3IZTXm (ORCPT ); Thu, 26 Sep 2013 15:23:42 -0400 Received: by mail-pb0-f45.google.com with SMTP id mc17so1550961pbc.18 for ; Thu, 26 Sep 2013 12:23:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RhBtWcfw3kwJwJjlqPD7YsnuZHj50FYzGQQVpMT8tXI=; b=gNBoTJjW6ZcUpI3bnggwDglAT+DvTwPSO5IisevGVZiQ3FjGF4GEfuR+1XIMwf11eD zTC4Xm2II5s2Z1+cK1s9wBIBT67avkcvOKoqtECUitGvzyaqhaWF0Y9f6fpOUPx7MieT DpSlKTtjUkA5IIX8QDs6n4AxqvrNM8RWGxVxk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RhBtWcfw3kwJwJjlqPD7YsnuZHj50FYzGQQVpMT8tXI=; b=mxLDTAHwQu60Lgw1Tdo8gtKSziGw9XiGp11NzOXiiAdz82FEHIjroQNpCS8Jcf+xWq KfoyOFU7zNncFRfN8DZbgP6X1sWTbNI/4ZYszrU/A52wC/n86c+MooWTvDT+J4adWoNC eYNIF2pQvcJBM650c6zJap2790Oy/5wM47XdhoL22K7XJgfIGBjoPGvIKOmtAIu8hM5t l5xa/zyZ4JtNfI5UXZbUchLqD47TJuIsrqWflF2BYAIvFmx54rTMxUytwWU2I81+f43R yAWSmdu8fmh/p1rHF3D9lm7jd4uoHnIGas6IoO7z0axhy4jtY6/T/CI30RBTzxLvPgz7 TqPw== X-Gm-Message-State: ALoCoQnnG5SDJerQhKpQD+CMxPb0seESQlwJZpB+F/L63rltS3xkgS+edtfcBsgx2DiTYU9WXvVY X-Received: by 10.67.3.103 with SMTP id bv7mr7065655pad.15.1380223421594; Thu, 26 Sep 2013 12:23:41 -0700 (PDT) Received: from firesword.mtv.corp.google.com (firesword.mtv.corp.google.com [172.22.73.90]) by mx.google.com with ESMTPSA id ar1sm3900253pbc.34.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 26 Sep 2013 12:23:40 -0700 (PDT) From: Grant Grundler To: Chris Ball , Ulf Hansson , Seungwon Jeon Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org, Grant Grundler Subject: [PATCH 3/7] mmc: core: restructure error handling for start req Date: Thu, 26 Sep 2013 12:22:56 -0700 Message-Id: <1380223380-22451-4-git-send-email-grundler@chromium.org> X-Mailer: git-send-email 1.8.4 In-Reply-To: <1380223380-22451-1-git-send-email-grundler@chromium.org> References: <1380223380-22451-1-git-send-email-grundler@chromium.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-9.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is an intermediate step to fixing the locking around the access to host->areq. Reduce the number of "if (saved_areq) vs "if (areq)" tests in the main code path since I'm going to add references to "host->lock" in the next patch. Signed-off-by: Grant Grundler --- drivers/mmc/core/core.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c index 675139e..4d5de98 100644 --- a/drivers/mmc/core/core.c +++ b/drivers/mmc/core/core.c @@ -556,21 +556,20 @@ struct mmc_async_req *mmc_start_req(struct mmc_host *host, mmc_start_bkops(host->card, true); } - if (!saved_err && areq) + /* Don't start something new if previous one failed. */ + if (!saved_err && areq) { start_err = __mmc_start_data_req(host, areq->mrq); + /* Cancel a prepared request if it was not started. */ + if (start_err) { + mmc_post_req(host, areq->mrq, -EINVAL); + host->areq = NULL; + } else + host->areq = areq; + } if (saved_areq) mmc_post_req(host, saved_areq->mrq, 0); - /* Cancel a prepared request if it was not started. */ - if ((saved_err || start_err) && areq) - mmc_post_req(host, areq->mrq, -EINVAL); - - if (saved_err) - host->areq = NULL; - else - host->areq = areq; - if (error) *error = saved_err; return saved_areq;