From patchwork Tue Sep 20 09:34:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 9341383 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 673B46077A for ; Tue, 20 Sep 2016 09:34:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5591B29DA3 for ; Tue, 20 Sep 2016 09:34:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4893129E10; Tue, 20 Sep 2016 09:34:46 +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=ham 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 81D3A29E06 for ; Tue, 20 Sep 2016 09:34:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753306AbcITJeo (ORCPT ); Tue, 20 Sep 2016 05:34:44 -0400 Received: from mail-lf0-f50.google.com ([209.85.215.50]:34910 "EHLO mail-lf0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751691AbcITJeo (ORCPT ); Tue, 20 Sep 2016 05:34:44 -0400 Received: by mail-lf0-f50.google.com with SMTP id l131so8408098lfl.2 for ; Tue, 20 Sep 2016 02:34:43 -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=n234l1SK5KoLDEC0j6b3x7B1y6TxDLQRNu4CbTuqo5A=; b=MuOXTVuXIt5uGJLWnd/mlOf1bW5+uK2ibSX0PxKe6IfWwrXa1DHXaptnxpYyE0jV5O uhIu18ZE/R3Lm8NfpRmhK9ugwUUFC0DpHhxykWdlXJ7hYnwP95KCz+l7yvoR3lkRA/Mr dOURxR//nQqNsxKWEZNZG0TWiU0nXoO4l0kJY= 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=n234l1SK5KoLDEC0j6b3x7B1y6TxDLQRNu4CbTuqo5A=; b=ME2dg6qHBzhk9eBj/nkJ6ZbUmRJN9N6f89a0RPhMUtlRlzsTKS05DhysFxtqghqxti AqS6c0wxDp1OOgkY3aU1rfYwvYFh7mdn2vVlrJP913lEMyyLhnbps4eFTBetvrePQe63 Gi/axGtb8CS0PcdsZqQ1X2c8FRY3Nq3isFsB1GooW/GPvKA9jwbVgxwxhyE25mpvDX4i XqhOgGKc0qHRe2SARa+V90AXj15yjVwvw75cABLoTbdhY3rTu5ezPhy3NzEciMc7HtT+ SIPj70n5lsE+pYW1XScumAERAjvBZ6DPZEMnsECRy0Y382ycDUkak0+NGlVbmDT1PB4I BXlA== X-Gm-Message-State: AE9vXwOXgdAKp26zZfaLJR2HeYQSNRx0zT4Ekju0PlYxrLY9xHW7USRcE5rr3YS5pak0rLT3 X-Received: by 10.46.1.67 with SMTP id 64mr11718267ljb.24.1474364082443; Tue, 20 Sep 2016 02:34:42 -0700 (PDT) Received: from linuslaptop.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id s3sm5506841lja.49.2016.09.20.02.34.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 20 Sep 2016 02:34:41 -0700 (PDT) From: Linus Walleij To: linux-mmc@vger.kernel.org, Ulf Hansson Cc: Linus Walleij Subject: [PATCH v2] mmc: card: do away with indirection pointer Date: Tue, 20 Sep 2016 11:34:38 +0200 Message-Id: <1474364078-15769-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 X-Virus-Scanned: ClamAV using ClamSMTP 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 --- ChangeLog v1->v2: - Actually commit the new block.h file too, mea culpa. --- drivers/mmc/card/block.c | 3 +-- drivers/mmc/card/block.h | 1 + drivers/mmc/card/queue.c | 4 +++- drivers/mmc/card/queue.h | 2 -- 4 files changed, 5 insertions(+), 5 deletions(-) create mode 100644 drivers/mmc/card/block.h 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/block.h b/drivers/mmc/card/block.h new file mode 100644 index 000000000000..cdabb2ee74be --- /dev/null +++ b/drivers/mmc/card/block.h @@ -0,0 +1 @@ +int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req); 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];