From patchwork Tue Sep 20 09:33:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 76595 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp1385903qgf; Tue, 20 Sep 2016 02:33:43 -0700 (PDT) X-Received: by 10.66.249.134 with SMTP id yu6mr54864051pac.44.1474364023714; Tue, 20 Sep 2016 02:33:43 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i8si34186098pap.189.2016.09.20.02.33.43; Tue, 20 Sep 2016 02:33:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753180AbcITJdm (ORCPT + 3 others); Tue, 20 Sep 2016 05:33:42 -0400 Received: from mail-lf0-f44.google.com ([209.85.215.44]:32814 "EHLO mail-lf0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752758AbcITJdm (ORCPT ); Tue, 20 Sep 2016 05:33:42 -0400 Received: by mail-lf0-f44.google.com with SMTP id h127so8422884lfh.0 for ; Tue, 20 Sep 2016 02:33:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=RLRgMW/XrKBqvL1J9QScKvl2tRmb8qHs9jr2AQw5mYY=; b=bIZflSFL5q0IXWakXV35UNTr+rldisM2DO8HF2TtJokjG/EbCyliXzwg0bx8kmLhQF pChh9COyz5UR2MUjBY8+lLsHY0ak5ExKpNueBEzVtvde3nGKHoCyIY7MvBw218DScXKZ JM8ygtVJ/SGdB2aFsZtg3vekolPo06IvHO/6k= 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; bh=RLRgMW/XrKBqvL1J9QScKvl2tRmb8qHs9jr2AQw5mYY=; b=CXxwlqSSDfS0rRkZq4thZ8wd7BPtZKxZkY41WOtwUP/v6ePYgMlT13gZkxjzUkjbdK dICb9EaqTY1PsQrjcRrL1mLIHM+rK3E9nb7Pm4CFARWO5yzWkXpXiIGRKS6GN5VK6IdM VcPpBjtj8ZY3I7jihEbHiWnLdCsBVZAtwaClDo/JFF6gZyGLR9c9sU5R5OCD/FEegJ0B 6H6WVT4NIy5f8a7SZLMi15aWBbQT9u3AYR+/fFuQ5XEuD59EFvyixK8OWrU/G/GUccmj HXyN+PQtlVH/Uu0zi28+kdT2ZP3QnMTRIidAdmgFTyuWPEfCLuof3V777wkH4bnFw9B2 IyZg== X-Gm-Message-State: AE9vXwOLI10THcJ4dsMFE2VahYTSFLV8aj6MXvphIlKLHi2xmtyLzSuUA4GBfAFkgXyCydVM X-Received: by 10.25.158.66 with SMTP id h63mr10631575lfe.155.1474364019832; Tue, 20 Sep 2016 02:33:39 -0700 (PDT) Received: from linuslaptop.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f41sm5558250lfi.39.2016.09.20.02.33.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Sep 2016 02:33:39 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij Subject: [PATCH] mmc: card: do away with indirection pointer Date: Tue, 20 Sep 2016 11:33:35 +0200 Message-Id: <1474364015-15585-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org We have enough vtables in the kernel as it is, we don't need this one to create even more artificial separation of concerns. As is proved by the Makefile: obj-$(CONFIG_MMC_BLOCK) += mmc_block.o mmc_block-objs := block.o queue.o block.c and queue.c are baked into the same mmc_block.o object. So why would one of these objects access a function in the other object by dereferencing a pointer? Create a new block.h header file for the single shared function from block to queue and remove the function pointer and just call the queue request function. Apart from making the code more readable, this also makes link optimizations possible and probably speeds up the call as well. Signed-off-by: Linus Walleij --- drivers/mmc/card/block.c | 3 +-- drivers/mmc/card/queue.c | 4 +++- drivers/mmc/card/queue.h | 2 -- 3 files changed, 4 insertions(+), 5 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-mmc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 2206d4477dbb..15acf96147f3 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -2144,7 +2144,7 @@ static int mmc_blk_issue_rw_rq(struct mmc_queue *mq, struct request *rqc) return 0; } -static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) +int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req) { int ret; struct mmc_blk_data *md = mq->data; @@ -2265,7 +2265,6 @@ again: if (ret) goto err_putdisk; - md->queue.issue_fn = mmc_blk_issue_rq; md->queue.data = md; md->disk->major = MMC_BLOCK_MAJOR; diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 708057261b38..8037f73a109a 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -19,7 +19,9 @@ #include #include + #include "queue.h" +#include "block.h" #define MMC_QUEUE_BOUNCESZ 65536 @@ -68,7 +70,7 @@ static int mmc_queue_thread(void *d) bool req_is_special = mmc_req_is_special(req); set_current_state(TASK_RUNNING); - mq->issue_fn(mq, req); + mmc_blk_issue_rq(mq, req); cond_resched(); if (mq->flags & MMC_QUEUE_NEW_REQUEST) { mq->flags &= ~MMC_QUEUE_NEW_REQUEST; diff --git a/drivers/mmc/card/queue.h b/drivers/mmc/card/queue.h index fee5e1271465..3c15a75bae86 100644 --- a/drivers/mmc/card/queue.h +++ b/drivers/mmc/card/queue.h @@ -57,8 +57,6 @@ struct mmc_queue { unsigned int flags; #define MMC_QUEUE_SUSPENDED (1 << 0) #define MMC_QUEUE_NEW_REQUEST (1 << 1) - - int (*issue_fn)(struct mmc_queue *, struct request *); void *data; struct request_queue *queue; struct mmc_queue_req mqrq[2];