From patchwork Sat Aug 20 14:50:39 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Namjae Jeon X-Patchwork-Id: 1082672 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 p7KEp4Qq010635 for ; Sat, 20 Aug 2011 14:51:04 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752616Ab1HTOvC (ORCPT ); Sat, 20 Aug 2011 10:51:02 -0400 Received: from mail-iy0-f170.google.com ([209.85.210.170]:49393 "EHLO mail-iy0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752034Ab1HTOvC (ORCPT ); Sat, 20 Aug 2011 10:51:02 -0400 Received: by iye16 with SMTP id 16so7363059iye.1 for ; Sat, 20 Aug 2011 07:51:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=dZTfHhI9pYJZ4p54vLQSxRwc73mGcXxQubEqIYBDV1E=; b=tQaKQF3NrD3H4bDSZZTJ+I+bKdCdfZS3K8WYkELAkbBc5pTpq/QQB8XKQ1PUqt0w4d z3VeJ5JsxwHY1A45j0F588ZT5AJEEfwuF1sTMpJpJx3iSorXcoUqUTqAW98GU8qakrjB DN0LF90YftzAuWoI7mKTYM5mrORRucQykxnHQ= Received: by 10.42.108.132 with SMTP id h4mr590150icp.110.1313851860819; Sat, 20 Aug 2011 07:51:00 -0700 (PDT) Received: from localhost.localdomain ([59.16.241.186]) by mx.google.com with ESMTPS id n14sm2221254ibi.22.2011.08.20.07.50.57 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 20 Aug 2011 07:51:00 -0700 (PDT) From: Namjae Jeon To: linux-mmc@vger.kernel.org Cc: cjb@laptop.org, linus.walleij@linaro.org, linux-kernel@vger.kernel.org, Namjae Jeon Subject: [PATCH] mmc: Use switch() instead of if/else if in mmc_blk_issue_rq. Date: Sat, 20 Aug 2011 23:50:39 +0900 Message-Id: <1313851839-32483-1-git-send-email-linkinjeon@gmail.com> X-Mailer: git-send-email 1.7.4.4 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]); Sat, 20 Aug 2011 14:51:04 +0000 (UTC) This uses a switch statement instead of if/else if statements. It will make to improve clarity and scalability, and offer faster execution through compiler optimization than if/else if statements. Signed-off-by: Namjae Jeon --- drivers/mmc/card/block.c | 38 +++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 15 deletions(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 1ff5486..fe9dd89 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -1191,23 +1191,31 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) goto out; } - if (req && req->cmd_flags & REQ_DISCARD) { - /* complete ongoing async transfer before issuing discard */ - if (card->host->areq) - mmc_blk_issue_rw_rq(mq, NULL); - if (req->cmd_flags & REQ_SECURE) - ret = mmc_blk_issue_secdiscard_rq(mq, req); - else + if (req) { + switch(req->cmd_flags) { + case REQ_DISCARD: + /* complete ongoing async transfer before issuing discard */ + if (card->host->areq) + mmc_blk_issue_rw_rq(mq, NULL); ret = mmc_blk_issue_discard_rq(mq, req); - } else if (req && req->cmd_flags & REQ_FLUSH) { - /* complete ongoing async transfer before issuing flush */ - if (card->host->areq) - mmc_blk_issue_rw_rq(mq, NULL); - ret = mmc_blk_issue_flush(mq, req); - } else { + break; + case REQ_DISCARD | REQ_SECURE: + /* complete ongoing async transfer before issuing discard */ + if (card->host->areq) + mmc_blk_issue_rw_rq(mq, NULL); + ret = mmc_blk_issue_secdiscard_rq(mq, req); + break; + case REQ_FLUSH: + /* complete ongoing async transfer before issuing discard */ + if (card->host->areq) + mmc_blk_issue_rw_rq(mq, NULL); + ret = mmc_blk_issue_flush(mq, req); + break; + } + } + else ret = mmc_blk_issue_rw_rq(mq, req); - } - + out: if (!req) /* release host only when there are no more requests */