From patchwork Mon Aug 13 22:34:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10564937 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2855E14C0 for ; Mon, 13 Aug 2018 22:39:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17729293F7 for ; Mon, 13 Aug 2018 22:39:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0B3B3293FE; Mon, 13 Aug 2018 22:39:48 +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 B06B5293F7 for ; Mon, 13 Aug 2018 22:39:47 +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=RQOLOPThdmxJc96nMBPrORmXomq2C1Qi3To8b1hv86I=; b=n79ZxwptLOkW2XJLYgyDAH82lO NJVUIW3dDfZTySA68VZAjVKrMYcEnhJpQB7tc5AOvTJRMr3ZsIUi46hqEdwV8CvudILPyrHDu4u81 EsnyTA8xsri/4lxVnuTfoCoAboQ0IZOiquLXwahxnxxiG2I0qfr9Nb6/pHS5j8j58HYdqB6kar3ah Te9QiqpYuiN9mtsTRS+Hz3fALqwOZ4FQvdMLARjcnZ6RTiamQJi3aLOm98SVPEpHoq0JyUaHcOSwz dqQJJh6r7fskhRMbkW0Mm6a02dJtEjK36YK5FKvGQR3kCDrUns69cfBX9SbGWUvDi4FrbCOzVMwXf +AdZQJjQ==; 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 1fpLV3-0005Dt-2T; Mon, 13 Aug 2018 22:39:45 +0000 Received: from mail-lf1-x142.google.com ([2a00:1450:4864:20::142]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fpLQQ-0008UI-4X; Mon, 13 Aug 2018 22:35:01 +0000 Received: by mail-lf1-x142.google.com with SMTP id f18-v6so12416943lfc.2; 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=RzMHcQsUYV0WG73y55wa3jAAc6hVfN6GOX5gp2RV4sFFT8MyguuzUgGpefs9jAZAMT ji3wJOC64DTOPJhvA3ZPuDZhCTTQismPxjexJCtDOJqy3xHCoQmAGEXGh9zugKa/Fsqm Pjp3jSepgdxxyU5rtZXC2v1aAMyzpSYMcatFz3T38l+tSOYj8c57oKCaFoTToWF3oKbT 96pZzQUcFclLUD/UQWVjrFjOC8BHDICA75+werT1PRg3opXVrfRGHJsjSoNSHCdGRJhT DSbctOvl3ygHU58m7JkkRaTwAYE44aUPy7UgRrHajKean79hpuU9KCx79iyLIp0i1O/V 9q3Q== X-Gm-Message-State: AOUpUlHbfCKlf5MOyO8KbIYi1MUIVM8ub9ZlGxSUCkgTB1L+HMbbbNTT R2Ql5V5IrYvv35+rIv8FqzE= X-Google-Smtp-Source: AA+uWPwavSaEse9bsLkIUaVrmEhHcahOk3am45tTQUsit/zyaY4SG1CIhgEph8o17Upefkm8zjFMJg== 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 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180813_153458_426099_2C4C0B1B X-CRM114-Status: GOOD ( 15.64 ) 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: linux-omap@vger.kernel.org, Aaro Koskinen , Tony Lindgren , Richard Weinberger , Linus Walleij , Janusz Krzysztofik , linux-kernel@vger.kernel.org, Marek Vasut , linux-mtd@lists.infradead.org, linux-gpio@vger.kernel.org, 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 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)