Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1100769imm; Wed, 18 Jul 2018 16:58:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpec7t7cv7psk8GHNC28u2gX8oFwQlS/spiOebDsgUKsaD7XMU077M7PczK2h+19Hcgn7u/Z X-Received: by 2002:a17:902:a581:: with SMTP id az1-v6mr7876275plb.61.1531958308283; Wed, 18 Jul 2018 16:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531958308; cv=none; d=google.com; s=arc-20160816; b=kKPPWcHMOSttat0lotD4GfUIKSTk7a5/10vgnH2AkUG/VdlmN8QpstYpR4g4SQ7VM6 FY1iJjyUViNnOhniZB8bslTwrYlRvjlUf4CDmB297IiVK+zmhPZPrqLDi8aoilkIs1sz Nk7bPXMWGhln9b7+a8iXkPJ28x87MWT99sV8ZKZC6sE//7pO5Ba9HXojHWLCeFAFtlcn KyzLs43y/AiH2GcXDPZ208Y9qluIb99rBKusx/tBjSZcyYXvFFPuv2gBlRFzkwxBd0B4 XcNexzT/zwGtJKL5tF8V1nFYlx2wTETMPpHJ5dog2GYCUdN73tnjz1qHgVFSxfeX6ueR bHmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=tuXV8yjyIbVo5qy73WEEP0gq4g/1G2BM5l5izBZJp5g=; b=vBQQS65/wZPgaj1IqXqoqbBnJTktRPXZqx59VN7A9Z2tIJDK+NCYoNoghtsxlLhoNP DD46BndchPFZf9kgz/W4+qQqEvfWZGrt+sN+z5FZMm0QopLILGopEjdMoVsEt7Gip1D/ m4g5/qB+6pAUBqE4NOK6mmCW1uwRvIt6yMzfpyPrrM1rxnGEbIwLxpBAB9XvWhp8KJIm nnTxWAyRovfDiJVpfja/+p0irYq0EmurHj5oCwo1LQDj7IAR2Cxn8+ppIseBcLX0qrlp f9MuE4+MZEWAt5AI9jbcMI7fJafY91odBPxJLsMd2pZb56z15qYjN+KcX2VZzg0SyYG0 L1Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YTncU+Cz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p83-v6si4552676pfa.180.2018.07.18.16.58.13; Wed, 18 Jul 2018 16:58:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YTncU+Cz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731041AbeGSAhQ (ORCPT + 99 others); Wed, 18 Jul 2018 20:37:16 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34776 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727635AbeGSAhQ (ORCPT ); Wed, 18 Jul 2018 20:37:16 -0400 Received: by mail-lj1-f196.google.com with SMTP id f8-v6so5622305ljk.1; 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=jEizSyoi4OhF/yLiyY77g6cJSWRaKS9iWmpGk9SA8tzM+4hPXgl1wTr/eOxJ5fNaDs BBedoIwl7xrJU8DLqmI0phgl2kA5pgonBdPfFB72zX99YSz/4grLwSpHl1ai/4umjIRL iQmdM4UvN/P49foOjSa5vv79257mt5AvVrkfA1WhdVUB7JBPxYn2vJipfU+e0WvpStUR RgrjEWo1T/ks2L8DGP/yKHEXm0ErZPHPy2Dm40Myx2LtPt6p+KnQgmd1qeOF1dzblPVY qT0drXnXNzDgZAQS9KlU8QIqOUtfy2wc3eMLsCYYNSEaQg58cUD3ta8+kojmP7fqhxqc n2wg== X-Gm-Message-State: AOUpUlFEFl4eblEabOOyLkXQwx9BiK38MaGLMsXXzzBC37L0Oe2KutME w1k1q9CzrzQFFOFcLnDT1Z4= 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 Cc: Tony Lindgren , Aaro Koskinen , Grygorii Strashko , Santosh Shilimkar , Kevin Hilman , Linus Walleij , Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Artem Bityutskiy , Janusz Krzysztofik 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.16.4