From patchwork Mon Aug 6 22:29:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Janusz Krzysztofik X-Patchwork-Id: 10558001 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 8D7EC13AC for ; Mon, 6 Aug 2018 22:30:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7AA722986E for ; Mon, 6 Aug 2018 22:30:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C63229877; Mon, 6 Aug 2018 22:30:50 +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 155652986E for ; Mon, 6 Aug 2018 22:30:50 +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=iGEmHuEjtu7yQ52rEvDL1rRBr7CzKFa1UfciqTdmGZo=; b=FgMOzruOnFsig5ZT0761fTqA32 YbGS+nl86p5ULP8k+ss6bmEWr0qU2enAcyrN8rF93uLLaNPNFAMyRsUmok6lBu6Yt4AzuMt1yT87Y v0VmvDftWMffWvoj52giGmiX0f6PDuMBpFsO76Q4eiqYG5umrq7zvS7z11jqx18yiW5sdInYDLl7e 0xwaEECk4lqRXJvvddEsEwPtgRt0ZlFdK3Cal5+F8mwSrv7dRk5kkM+oog7SaDUfjqOd1NNFh+CMw olBJeUo2lBWZgDW+kfCk3rDJP1DqHoZzsMiI93NaWVOf23Izrs9SybcNDuUldvS2wnlI+v2aj5BQw lFgbXcBw==; 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 1fmo1S-00071g-OJ; Mon, 06 Aug 2018 22:30:42 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fmo0Y-0005S2-99; Mon, 06 Aug 2018 22:29:50 +0000 Received: by mail-lf1-x144.google.com with SMTP id v22-v6so10200924lfe.8; Mon, 06 Aug 2018 15:29:40 -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=4e/NwWX8gPdhcOi4ymtYKpIzD8tGLix7YzF3NFcH+jE=; b=VSk24Lf11fISUKBVBalTBrkygdyEiRw+2NBUCIf7HMFRpwZbhciE7EQse8VY8vAjmS JLJ2wZr7G+u30e0OlVgwZKVGYeHTHgnCPxYsuzl+tdcCZR4zj9zU/o4ndDnyr8PpN+E8 4KBvTZa3raeWY87i32JIiXzbyLYJTzgwSr1NsyCSuDIhxsgLjetfdxVuiK1Ij7xTOR3Q FzNKFaMgy6UteO25l/wkolUXbcDypWSnKLPjrLmv9lp30taqmNXt4V+X2mMPeDhq0OCC voBnXuZZeqt8pfgSN6BXAKm+iVXZNKmJw1dbj3UNoTculPG3y8i/zfRXLHK6u7Le8rQt VEDQ== 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=4e/NwWX8gPdhcOi4ymtYKpIzD8tGLix7YzF3NFcH+jE=; b=YGxZFvNvwEmwWRs7HdOaEkKTV6W6d4QOQlr8wq86pVERP+EV5oVkgxPwk2Cc2vFN4j KggP5DGXnWtuyfoml77VMpZXDyb21Ff0D2mSYz17tEd7crAa0MK2ePBvW4Ff+ydmIUa8 k22I8R47pExr8VoED/LigN5y8FB++2HC38z4YvMpRumYwfsCJ0JR3PVXFxAKNAMZ9fpb VyVeKSnqirrBEx1sfXR9S85ciXeJB/p/Aq1pPLCVhpidzAJziyDfgvywHnxqrIoAWzBK YJlwnxq9QSmDGcURlNhuFrB85Aw3y8QJuR6jrTrHazQD2P6MhT5qO3iPyBQEa5YJVGlw B/6Q== X-Gm-Message-State: AOUpUlG3XCjADmSw6q2h8WmjZgYVUFCTI1J4BFS8M2jOITy/xn9begAj K4p4KhwTtbpRbUYvl4vsbRE= X-Google-Smtp-Source: AAOMgpddBt3OviQvsIPmqSEfWASOM2oWUiaQyCmIbh57aYMBUm8SYN9CxOmsoM9b9ESTsH3Foa+b3Q== X-Received: by 2002:a19:c3c7:: with SMTP id t190-v6mr11873113lff.108.1533594578952; Mon, 06 Aug 2018 15:29:38 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id o4-v6sm2438561ljc.67.2018.08.06.15.29.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 15:29:38 -0700 (PDT) From: Janusz Krzysztofik To: Boris Brezillon , Linus Walleij Subject: [RFC PATCH v2 08/12] mtd: rawnand: ams-delta: Simplify pointer resolution on read/write Date: Tue, 7 Aug 2018 00:29:14 +0200 Message-Id: <20180806222918.12644-9-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180806222918.12644-1-jmkrzyszt@gmail.com> References: <20180718235710.18242-1-jmkrzyszt@gmail.com> <20180806222918.12644-1-jmkrzyszt@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180806_152946_623964_9DBCD9F6 X-CRM114-Status: GOOD ( 13.83 ) 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, Jonathan Corbet , Tony Lindgren , Richard Weinberger , linux-gpio@vger.kernel.org, Aaro Koskinen , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Marek Vasut , Janusz Krzysztofik , linux-mtd@lists.infradead.org, Miquel Raynal , 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 changing their APIs so they accept driver private structure pointer instead of mtd_info. Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon --- drivers/mtd/nand/raw/ams-delta.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/nand/raw/ams-delta.c b/drivers/mtd/nand/raw/ams-delta.c index d02c48c013e8..30c461138195 100644 --- a/drivers/mtd/nand/raw/ams-delta.c +++ b/drivers/mtd/nand/raw/ams-delta.c @@ -76,10 +76,8 @@ static void ams_delta_write_commit(struct ams_delta_nand *priv) gpiod_set_value(priv->gpiod_nwe, 1); } -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 gpio_descs *data_gpiods = priv->data_gpiods; unsigned long bits = byte; int i, value_array[data_gpiods->ndescs]; @@ -93,10 +91,8 @@ static void ams_delta_write_next_byte(struct mtd_info *mtd, u_char byte) ams_delta_write_commit(priv); } -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); struct gpio_descs *data_gpiods = priv->data_gpiods; unsigned long bits = byte; int i; @@ -108,10 +104,8 @@ static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) ams_delta_write_commit(priv); } -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 gpio_descs *data_gpiods = priv->data_gpiods; unsigned long bits = 0; int i, value_array[data_gpiods->ndescs]; @@ -131,38 +125,48 @@ static u_char ams_delta_read_next_byte(struct mtd_info *mtd) return bits; } -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); struct gpio_descs *data_gpiods = priv->data_gpiods; int i; for (i = 0; i < data_gpiods->ndescs; i++) gpiod_direction_input(data_gpiods->desc[i]); - 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); } /* @@ -186,7 +190,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)