From patchwork Thu Jan 26 15:04:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9539389 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 630AF601D7 for ; Thu, 26 Jan 2017 15:04:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D2192041F for ; Thu, 26 Jan 2017 15:04:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 51E1227F17; Thu, 26 Jan 2017 15:04:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F40D92041F for ; Thu, 26 Jan 2017 15:04:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753097AbdAZPEm (ORCPT ); Thu, 26 Jan 2017 10:04:42 -0500 Received: from mail-lf0-f42.google.com ([209.85.215.42]:32819 "EHLO mail-lf0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752864AbdAZPEl (ORCPT ); Thu, 26 Jan 2017 10:04:41 -0500 Received: by mail-lf0-f42.google.com with SMTP id x1so60232012lff.0 for ; Thu, 26 Jan 2017 07:04:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=BSi/AvN9bejboIyHezbWIsZouXf1fw6fhevaTvE/DXM=; b=I3dNJLO2GVZbM44aLziGxcMXstrrhLz9vUIAcdo1sspIs46ft5Ov6usFgEDJ8sABa8 EP8cf+EzMVJ2G2bhP3TEwGIa9jucbLK6AM1cAqM+mCmkB3uN/zmFPDgx2EnjKXh2W/BY 8myaBwpL/MPMAjpbnH7H3Ar9LwF8XOC0XwOLk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=BSi/AvN9bejboIyHezbWIsZouXf1fw6fhevaTvE/DXM=; b=XIlfC0RHavDkOyhoef5IhDLJOe7tknlHDuYQDdfbcp7kCdvkGYKMVSOM8Jh3UN50jR B1B2GBtY332jZEUlWqRF4enM5e75spNKwzgEiN8ijvA6ePguNL1AUeooOWSuJpSYxwJC aW7myzUVrh4jF1O0j7Ag8XDQ+B+FeDZBpL1cO5RcuPotrIS1sXcgWeVC4gxv81ddMX8v kd+xjaXqpHi4OpOm0WDgjdxAuhngCxWIO5VvtyWaJXSH+dWWzauHZoE+MDrrVeUdsVeT bvJ+GMIiVkoj0pD+p48XKvPYl/s8m+ekE8aOaM/+Miltq28r7DoHki5UDpe2kRVkTqxO tdNg== X-Gm-Message-State: AIkVDXK8QlS6qN9flANvwbrQSe8X/kHpW1c7nvPrNKy2RxeLWdp67y5d6mAulAS6SL+bSn4r X-Received: by 10.25.203.87 with SMTP id b84mr1024315lfg.158.1485443080234; Thu, 26 Jan 2017 07:04:40 -0800 (PST) Received: from gnarp.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s7sm540332lja.27.2017.01.26.07.04.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jan 2017 07:04:38 -0800 (PST) From: Linus Walleij To: linux-mmc@vger.kernel.org, linux-block@vger.kernel.org, Ulf Hansson Cc: Chunyan Zhang , Baolin Wang , Paolo Valente , Linus Walleij Subject: [PATCH 1/6] mmc: block: inline the command abort and start new goto:s Date: Thu, 26 Jan 2017 16:04:28 +0100 Message-Id: <20170126150433.14038-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.9.3 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The goto statements sprinkled over the mmc_blk_issue_rw_rq() function has grown over the years and makes the code pretty hard to read. Inline the calls such that: goto cmd_abort; -> mmc_blk_rw_cmd_abort(card, req); mmc_blk_rw_start_new(mq, card, rqc); return; goto start_new_req; -> mmc_blk_rw_start_new(mq, card, rqc); return; After this it is more clear how we exit the do {} while loop in this function, and it gets possible to split the code apart. Signed-off-by: Linus Walleij --- drivers/mmc/core/block.c | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index ede759dda395..8f91d7ddfc56 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -1698,10 +1698,15 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) break; case MMC_BLK_CMD_ERR: ret = mmc_blk_cmd_err(md, card, brq, req, ret); - if (mmc_blk_reset(md, card->host, type)) - goto cmd_abort; - if (!ret) - goto start_new_req; + if (mmc_blk_reset(md, card->host, type)) { + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; + } + if (!ret) { + mmc_blk_rw_start_new(mq, card, rqc); + return; + } break; case MMC_BLK_RETRY: retune_retry_done = brq->retune_retry_done; @@ -1711,15 +1716,20 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) case MMC_BLK_ABORT: if (!mmc_blk_reset(md, card->host, type)) break; - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; case MMC_BLK_DATA_ERR: { int err; err = mmc_blk_reset(md, card->host, type); if (!err) break; - if (err == -ENODEV) - goto cmd_abort; + if (err == -ENODEV) { + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; + } /* Fall through */ } case MMC_BLK_ECC_ERR: @@ -1737,15 +1747,21 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) */ ret = blk_end_request(req, -EIO, brq->data.blksz); - if (!ret) - goto start_new_req; + if (!ret) { + mmc_blk_rw_start_new(mq, card, rqc); + return; + } break; case MMC_BLK_NOMEDIUM: - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; default: pr_err("%s: Unhandled return value (%d)", req->rq_disk->disk_name, status); - goto cmd_abort; + mmc_blk_rw_cmd_abort(card, req); + mmc_blk_rw_start_new(mq, card, rqc); + return; } if (ret) { @@ -1760,14 +1776,6 @@ static void mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) mq_rq->brq.retune_retry_done = retune_retry_done; } } while (ret); - - return; - - cmd_abort: - mmc_blk_rw_cmd_abort(card, req); - - start_new_req: - mmc_blk_rw_start_new(mq, card, rqc); } void mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)