Received: by 2002:a4a:311b:0:0:0:0:0 with SMTP id k27-v6csp3645943ooa; Mon, 13 Aug 2018 15:37:32 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxujrGHTTBFfDhFCPJcLrZNnnEU0I2Nstjme5CTZ9T28wsiUrLG7009756RpZBKnfFM7CR9 X-Received: by 2002:a63:c114:: with SMTP id w20-v6mr18433913pgf.234.1534199852542; Mon, 13 Aug 2018 15:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534199852; cv=none; d=google.com; s=arc-20160816; b=tg8n6foIQZmGVrq9jCZRkv/pHCyy21kyceMZFmUiP15OxlZ0PwbowAqH1xYFki9I7n Th0gAgpRFbV7tOwnPbIodeeAsVMyn2qwbPlRsmYDjsIb5DDuIv9E6BP8ggvWR9sNLbjJ sY63Eagj/X971e+o903KdODtcRA2TfiQjbNzuj7Qap+xFt1b3b1B4UJh4HRKQ0AOgSlE C4GrI5McBrkSuaZX1RZd16sAFGvbGE5bArDjBJ6JFg31wrCMMGVaC6hWEPB6dTdTbzOk etI5Mlj3ZXf7OJAMIkdJ7JapTTyCLMyYK8agMh8R3OAPa3wXRkOkG+wkhmPfl9dhpmrD J6eQ== 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=z7PaRe0Kcvcx7hiv+aZ/0LG6vJqsdKc6trNkBzyVvLs=; b=LE62N7USGuGjkE7xpm9sXS/kX/Hs/UYpmxLGqqm2kcTmzE6PifzB7daeodQq4u+9wQ N26VGcnjC3Y2mAgEeafbI/zV+TZZqdslAMC9e2WXd3VicXMVYgcqGl43W7lZnSdAWFHC iW76iC4GZ5mSfQJQpi3kI9v52BVMqLzItvVhKZVNoAJr3DGLZIdk4pYYI3lXRz9ivAsB d7HHjvae23J2kG9b3gWuix0vRQcjaw+j5aztCK0y2xO+oLJ1JX9uckXAiMnkR99WKie0 0XrXMDUA6RUWt2gets+5qm+q9FiNi1wgSzaODmVoyzVSiraXk7ORnvL9tI7nYPNpE5sr tzkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gPe45A5S; 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 r23-v6si18882161pgk.582.2018.08.13.15.37.18; Mon, 13 Aug 2018 15:37:32 -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=gPe45A5S; 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 S1732415AbeHNBTO (ORCPT + 99 others); Mon, 13 Aug 2018 21:19:14 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:39769 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732285AbeHNBTA (ORCPT ); Mon, 13 Aug 2018 21:19:00 -0400 Received: by mail-lf1-f65.google.com with SMTP id a134-v6so12397599lfe.6; Mon, 13 Aug 2018 15:34:46 -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=z7PaRe0Kcvcx7hiv+aZ/0LG6vJqsdKc6trNkBzyVvLs=; b=gPe45A5SUYgSodBEwXYxl4cY6QCuG9T1pS4kZoMPmUX7HhqEw+TaCNXmA0Q8dEIAWk 1QJEDVSuGJjSYTNDXF9uxrf4IUE9RRLR40M8x8GIa3iVpy+0cDxzisccxsztC0wJkJvB cVjrhHA1ndYm/JZHNYaq2Nb9vdSA0ksIJc151Lqi3hoSJiet+sFDTzqMTvYybywgogjx 3EmcNhoCDCIXCSNVu944uGYBAU151rNOkiGxQfRhvKB9Gsd1QzcZnia34iMN3wr1aQHn nntPOTRVm27UhrOhzG+JZId9wb5eQTb8xThnhkgTLUFbEoGaSJ/LJoVB2pEsbPAJX+xQ MsmA== 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=z7PaRe0Kcvcx7hiv+aZ/0LG6vJqsdKc6trNkBzyVvLs=; b=EGzHPkYC04Tjaz4qoi/Z1j2FHQkYhYecEQBiw6wthNB1SmflDaynAVyxpNR5QWxG4O s1+l/4FXXx1ae1bD75oyv6poZ2Kb2GRhis45PWjxZDpOPo/vpGXf/PixND4M3ERR7Aj0 KIvwoZUVOKeCabJqkbTpFAsa7MFmsF3vteEy/ncRlhIrA3p3v5cXf0egHk/3OhvwLPM+ iXOBOixF8v1K4/WTyZ6fltArgBf8gxRqmed1XSp1r/LWKQV3TYsaQx1vqq385ppGJiKJ ZKhfXMMgxS3DwDFxUTRxyTfn5yYiYX/GYl/cyjAgfhNaIQbCMP2kDEfJvxoqt3kWeWZn w9gQ== X-Gm-Message-State: AOUpUlHlexUJv5hVjWeyCOdwZF1qA7lqDu0ie5FqWVrqkHuSedWQoWnJ mVKotgcVqstaFWKNNYn9yfM= X-Received: by 2002:a19:e546:: with SMTP id c67-v6mr12608411lfh.135.1534199685420; Mon, 13 Aug 2018 15:34:45 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id f136-v6sm3572702lfe.71.2018.08.13.15.34.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Aug 2018 15:34:44 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Miquel Raynal Cc: Richard Weinberger , David Woodhouse , Brian Norris , Marek Vasut , Tony Lindgren , Aaro Koskinen , Linus Walleij , linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org, linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Janusz Krzysztofik Subject: [PATCH v3 6/7] mtd: rawnand: ams-delta: Simplify pointer resolution on read/write Date: Tue, 14 Aug 2018 00:34:47 +0200 Message-Id: <20180813223448.21316-7-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180813223448.21316-1-jmkrzyszt@gmail.com> References: <20180806222918.12644-1-jmkrzyszt@gmail.com> <20180813223448.21316-1-jmkrzyszt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simplify data read/write sub-functions by making them accept private structure pointer instead of resolving it again from mtd_info. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon --- drivers/mtd/nand/raw/ams-delta.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index 5f9180fe4f8b..59fc417e8fa9 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -73,10 +73,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); @@ -85,10 +84,8 @@ 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_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; if (priv->data_in) { @@ -96,13 +93,12 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) priv->data_in = false; } - 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); @@ -126,30 +122,34 @@ static u_char ams_delta_read_byte(struct mtd_info *mtd) priv->data_in = true; } - return ams_delta_read_next_byte(mtd); + return ams_delta_read_next_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 = 0; if (len > 0) - ams_delta_write_byte(mtd, buf[i++]); + ams_delta_write_byte(priv, buf[i++]); while (i < len) - 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 = 0; if (len > 0) buf[i++] = ams_delta_read_byte(mtd); while (i < len) - buf[i++] = ams_delta_read_next_byte(mtd); + buf[i++] = ams_delta_read_next_byte(priv); } /* @@ -173,7 +173,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_byte(priv, cmd); } static int ams_delta_nand_ready(struct mtd_info *mtd) -- 2.16.4