From patchwork Wed Jul 18 23:57:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10533493 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 A1CE0600F4 for ; Thu, 19 Jul 2018 00:13:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8809528686 for ; Thu, 19 Jul 2018 00:13:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7B16128DEF; Thu, 19 Jul 2018 00:13:17 +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=-2.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, DKIM_VALID, FREEMAIL_FROM, MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1613F28686 for ; Thu, 19 Jul 2018 00:13:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=5WdXFy02Y3v4+KbOeLbvw1q7XmgQhxN7Eq8c7rBjUZI=; b=iFK4TZdssyUbR66IW+O6f7aGgj jhoHTKMSSEWJ2TtnZp9xOflvndq3rK0XRNpYE5Enw9UJIb2XktiLXQDr6/9pp68WMaqt10/Ywwk3o ofVdqaZtWgAhLhJ+Y3NtZMPh8gCbxMAWYnTX7hNJn11RGPNDWJ0Ce8BdO4tYTFUEsyOt9Dp047Nec hHfyZkWQUzaXOE5TbcMP1FqSQeJS6l7KduDN+UyFq29brAkn54MIUignLGdMVgSK3pZTB7yM7IuW2 iDZBt64fvbvQ760nT+umCJtjrA7r+iOxEmGnJkaopGPxqdZpVQETIhxCwfuw9v9OOs/lc+WHWk3vW 4ytaCfEA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffwZH-00060W-4F; Thu, 19 Jul 2018 00:13:15 +0000 Received: from mail-lj1-x244.google.com ([2a00:1450:4864:20::244]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ffwJb-0005mY-5B; Wed, 18 Jul 2018 23:57:05 +0000 Received: by mail-lj1-x244.google.com with SMTP id s12-v6so5617686ljj.0; Wed, 18 Jul 2018 16:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tuXV8yjyIbVo5qy73WEEP0gq4g/1G2BM5l5izBZJp5g=; b=YTncU+Cz8fjHOX08nGx7QM80rift7Gmp3oX57oDpQyWa4hDQHX6HQKsEbGlnd00B2M 7ABB5biLs2rGzkhD43gkE1jXtBWCeog2LR3clFOEs8cocxK5H3ihEBVENEIj+eRcJd13 QHm48x6hP1pDd8LFIv2bvA5rJyS5yARt9dqXukX/QofPtmTxki+1MZxOUM4OJaglc71r XZP7PtPQFRo7hXcATcdrHIMaFoRqsayIdF701KpF7ADFda8UL2uQ+EK0RH1pX9OBMaD0 rrqmc6SHJSsxvoAq9GbzIj/rGy+mIB5ap6eVY7yXnMiu0NlQwg364DyeRXoIrXNvx6Lh zPTQ== 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:in-reply-to :references; bh=tuXV8yjyIbVo5qy73WEEP0gq4g/1G2BM5l5izBZJp5g=; b=FkhnUM6SJ89oPByayCMp8MzSdrqBeq7XxEGDwbyF4tbIlE9yIQ7beRdBVKeZXw2McR Ss9+qnFJ6kv6gdHzmytZ47ONwMlyd7B7bYtJ1h9IK4kjoneAhHghXhoSY4PpJjoNjaVc G9+ip2FWbatkJQiT4vG9fg1USHESU/JUi4usMWjknL/Qhjm+E0vuIQ6QyoKbrN88LkBe DyLVGJkChvCCA2TWjomzQTmMl+MKQFmM7o6aKln2BWtN6Zyl0jg37Kx+lFe3BsSwks3N qfdneAGAGoxoz4nzqfTSkcvXtdtHGCHPWYODmCG9bK/hOrb180CrLDbcuR3qCv5AFST3 ClGA== X-Gm-Message-State: AOUpUlEMgIWTcmVItrr0WNhH1JR+uE3mHPVdbyyX+/+OE1ZOeGDrZWRF 8AdvDpgyhnCNVnmg6oQYT8c= X-Google-Smtp-Source: AAOMgpfi8/ThuJr6oRvAx3cLTBl4r4J2waP3hDMNsu66Ab/VO3PfLwL/2W1dMxW5wnEnbm/o6XEBgQ== X-Received: by 2002:a2e:2f19:: with SMTP id v25-v6mr5777018ljv.113.1531958215494; Wed, 18 Jul 2018 16:56:55 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id h7-v6sm826584ljk.27.2018.07.18.16.56.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 16:56:54 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Miquel Raynal Subject: [RFC PATCH 4/8] mtd: rawnand: ams-delta: Optimize pointer resolution on read/write Date: Thu, 19 Jul 2018 01:57:06 +0200 Message-Id: <20180718235710.18242-5-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180718235710.18242-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180718_165703_199402_5F4B715F X-CRM114-Status: GOOD ( 14.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Grygorii Strashko , Kevin Hilman , Tony Lindgren , Richard Weinberger , Linus Walleij , Aaro Koskinen , Artem Bityutskiy , linux-kernel@vger.kernel.org, Marek Vasut , linux-omap@vger.kernel.org, Janusz Krzysztofik , linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, Santosh Shilimkar , Brian Norris , David Woodhouse , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Further optimize processing speed of read/write callback functions by resolving private structure pointer only once per callback and passing it to all subfunctions instead of mtd_info. Signed-off-by: Janusz Krzysztofik --- drivers/mtd/nand/raw/ams-delta.c | 44 +++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index dfefcd79b420..d7e4c9dbef67 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -72,10 +72,9 @@ static const struct mtd_partition partition_info[] = { .size = 3 * SZ_256K }, }; -static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) +static void ams_delta_write_next_byte(struct ams_delta_nand *priv, u_char byte) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); + struct nand_chip *this = &priv->nand_chip; writew(byte, this->IO_ADDR_W); gpiod_set_value(priv->gpiod_nwe, 0); @@ -83,21 +82,18 @@ static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) gpiod_set_value(priv->gpiod_nwe, 1); } -static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) +static void ams_delta_write_first_byte(struct ams_delta_nand *priv, u_char byte) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); void __iomem *io_base = priv->io_base; writew(0, io_base + OMAP_MPUIO_IO_CNTL); - ams_delta_write_next_byte(mtd, byte); + ams_delta_write_next_byte(priv, byte); } -static u_char ams_delta_read_next_byte(struct mtd_info *mtd) +static u_char ams_delta_read_next_byte(struct ams_delta_nand *priv) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); + struct nand_chip *this = &priv->nand_chip; u_char res; gpiod_set_value(priv->gpiod_nre, 0); @@ -108,36 +104,46 @@ static u_char ams_delta_read_next_byte(struct mtd_info *mtd) return res; } -static u_char ams_delta_read_byte(struct mtd_info *mtd) +static u_char ams_delta_read_first_byte(struct ams_delta_nand *priv) { - struct nand_chip *this = mtd_to_nand(mtd); - struct ams_delta_nand *priv = nand_get_controller_data(this); void __iomem *io_base = priv->io_base; writew(~0, io_base + OMAP_MPUIO_IO_CNTL); - return ams_delta_read_next_byte(mtd); + return ams_delta_read_next_byte(priv); +} + +static u_char ams_delta_read_byte(struct mtd_info *mtd) +{ + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); + + return ams_delta_read_first_byte(priv); } static void ams_delta_write_buf(struct mtd_info *mtd, const u_char *buf, int len) { + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); int i; if (len > 0) - ams_delta_write_byte(mtd, buf[0]); + ams_delta_write_first_byte(priv, buf[0]); for (i = 1; i < len; i++) - ams_delta_write_next_byte(mtd, buf[i]); + ams_delta_write_next_byte(priv, buf[i]); } static void ams_delta_read_buf(struct mtd_info *mtd, u_char *buf, int len) { + struct nand_chip *this = mtd_to_nand(mtd); + struct ams_delta_nand *priv = nand_get_controller_data(this); int i; if (len > 0) - buf[0] = ams_delta_read_byte(mtd); + buf[0] = ams_delta_read_first_byte(priv); for (i = 1; i < len; i++) - buf[i] = ams_delta_read_next_byte(mtd); + buf[i] = ams_delta_read_next_byte(priv); } /* @@ -161,7 +167,7 @@ static void ams_delta_hwcontrol(struct mtd_info *mtd, int cmd, } if (cmd != NAND_CMD_NONE) - ams_delta_write_byte(mtd, cmd); + ams_delta_write_first_byte(priv, cmd); } static int ams_delta_nand_ready(struct mtd_info *mtd)