From patchwork Tue Mar 12 08:44:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 160064 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12851551jad; Tue, 12 Mar 2019 01:46:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkF+80ms6QKyIN7kSI+456mo9XVdluwL0FE5qSs1367zIAVwhq4y/ApO/+GGAvV9v6HDHk X-Received: by 2002:a17:902:1029:: with SMTP id b38mr38166656pla.204.1552380394976; Tue, 12 Mar 2019 01:46:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552380394; cv=none; d=google.com; s=arc-20160816; b=PWRV79OaMSdH7FOiLeRigdVbBBCwaphufWP4DI4eZpW+iWiknwc3N5lifMza5DWn42 YjI3FxWKcsxD6uER0bp99G3jb3z9dYfuI85psml4M6HzmOD71ZJmSQ8Gbyc+16fIQOmj 50icBxvbADh2hl8sfEd7L3S434Xxh/FgEOZCUwtbUnaBvA9qfSjKJEOVDm7Q2XQwG/QG f0LJmLCxJfU39W6pud3JcGp+716h6UcrI70KI67uCPHZ1KI1PWw22lj3mCPKpi5V54Dv fAnwBu1UA6uC7hz8Zc/7Y0U7nrfoYPv0JclxGjys3kW+Pews+25D4Ep/4Nyu7PK6lPxY ox7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=MinjXs9WfxXNw/WhixNrKF1bXjFSVX8kaFj4Ql7Lrqw=; b=0l+JI7OkQSahx0tc12KKWFFyj6UFdiQ7zwUETUaywph6wdWJGolVCylWTwhJhc5orQ oIs1/EQDzX5Q9++ACbWRynojkWWpHJMRuQgLzHm1OcRgysGptgOS0LDiDw8Upi7eBekU casu8EUUgFoc9P5pPw2FqnV7Tv1zVhkiixjbfPO+wBynccSM2mNf0QZBloe+Em/2Fw+L jYkkR5uXw1xM2OeCVfsPTfq3twvx0TPzRIrnTFiQOfc1f2iHv2MeThO3xIy91IOyxPRp EMPetVpV8Nn2+PhBj9o+cmrE4jkNqu5p9t3zyMJby4qFx8PdymXf/EzHotmu/1l/PDBY 2ArQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=dXNEUYr4; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=AehNnrTG; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id x4si6733113pgp.370.2019.03.12.01.46.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 01:46:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=dXNEUYr4; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=AehNnrTG; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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=MinjXs9WfxXNw/WhixNrKF1bXjFSVX8kaFj4Ql7Lrqw=; b=dXNEUYr4m9uMy3hIRnGO1MhrUG rouN7VDU9QGm0XmcfVAA9IK0DfeZ/HucTTgrskusMNNY55a6xOoEcYlou9De2G8k1rqNdrh88LXZO 1N27jqfBoITFuFjE3adQBg9rz/I73LGtm9pwxOZB+YuXLULpVcz5pOTz9F0DX4sCxAnIg7nm5+uCg BDmrQ47ofSMLxORM5InjIFujEksgFaNQ3fN1nVnhdLqhvShEEjSqNgADSnA5fV6wzZb8An3fHfqY4 jAH4PVNrkcW2CyDRhmb3+Fx7ESUuRzsCW/hzn8KqfSVUfqza95h2UYFn2RM8+JY64GZdTDR9RofPY 39Xp6Psg==; 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 1h3d3L-00017q-2M; Tue, 12 Mar 2019 08:46:27 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3d2e-000076-Id for linux-mtd@lists.infradead.org; Tue, 12 Mar 2019 08:45:48 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x2C8j6Zb004092; Tue, 12 Mar 2019 17:45:15 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x2C8j6Zb004092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552380316; bh=/fdtXUQ1tDw8khieyu/bhW6CDbduWdbRweP4Qu1RY0A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AehNnrTGCTGIr5GTCikJJbGnpaN5TEyLtekhMhjmfDI8t4qTfErnf+Yol3EVjVw/h NcF6FWVtw28SEbx1cEzRNcdK1E/g5gLwjR9GE96j/LEpZBnFKeygwvf1uZDHn+8rB3 gpbQgUyWTfBPE4WuMrgCzHSnivQADaI/NJ8VbKeqYNSKLSU436/fEOeOIGjv3/amc7 wOk0o24qF5wT71IDktmHnk6TwQrRxg0qtHGbGqpHFhtMTqUsqL2J9lrgMVgf5sbB/p qDSzwiUjV5f08MnC3xJdAc0xvZKt6lSK6OuV2yNkpTQkdCrNTZ8aGnR24fjEGmQ43I EWZ31/QZ+9mvg== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH v3 1/9] mtd: rawnand: denali: use nand_chip pointer more for internal functions Date: Tue, 12 Mar 2019 17:44:42 +0900 Message-Id: <1552380290-19951-2-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> References: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_014545_012215_492C25AF X-CRM114-Status: GOOD ( 15.85 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.76 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org With the recent refactoring, the NAND driver hooks now take a pointer to nand_chip. Add to_denali() in order to convert (struct nand_chip *) to (struct denali_nand_info *) directly. It is more useful than the current mtd_to_denali(). I changed some helper functions to take (struct nand_chip *). This will avoid pointer conversion back and forth, and ease further development. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None drivers/mtd/nand/raw/denali.c | 57 ++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 25 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 24aeafc..4ac1314 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -47,6 +47,11 @@ static inline struct denali_nand_info *mtd_to_denali(struct mtd_info *mtd) return container_of(mtd_to_nand(mtd), struct denali_nand_info, nand); } +static struct denali_nand_info *to_denali(struct nand_chip *chip) +{ + return container_of(chip, struct denali_nand_info, nand); +} + /* * Direct Addressing - the slave address forms the control information (command * type, bank, block, and page address). The slave data is the actual data to @@ -282,12 +287,12 @@ static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl) denali->host_write(denali, DENALI_BANK(denali) | type, dat); } -static int denali_check_erased_page(struct mtd_info *mtd, - struct nand_chip *chip, uint8_t *buf, +static int denali_check_erased_page(struct nand_chip *chip, + struct denali_nand_info *denali, u8 *buf, unsigned long uncor_ecc_flags, unsigned int max_bitflips) { - struct denali_nand_info *denali = mtd_to_denali(mtd); + struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; uint8_t *ecc_code = chip->oob_poi + denali->oob_skip_bytes; int ecc_steps = chip->ecc.steps; int ecc_size = chip->ecc.size; @@ -303,9 +308,9 @@ static int denali_check_erased_page(struct mtd_info *mtd, NULL, 0, chip->ecc.strength); if (stat < 0) { - mtd->ecc_stats.failed++; + ecc_stats->failed++; } else { - mtd->ecc_stats.corrected += stat; + ecc_stats->corrected += stat; max_bitflips = max_t(unsigned int, max_bitflips, stat); } @@ -316,11 +321,11 @@ static int denali_check_erased_page(struct mtd_info *mtd, return max_bitflips; } -static int denali_hw_ecc_fixup(struct mtd_info *mtd, +static int denali_hw_ecc_fixup(struct nand_chip *chip, struct denali_nand_info *denali, unsigned long *uncor_ecc_flags) { - struct nand_chip *chip = mtd_to_nand(mtd); + struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; int bank = denali->active_bank; uint32_t ecc_cor; unsigned int max_bitflips; @@ -346,16 +351,17 @@ static int denali_hw_ecc_fixup(struct mtd_info *mtd, * Unfortunately, we can not know the total number of corrected bits in * the page. Increase the stats by max_bitflips. (compromised solution) */ - mtd->ecc_stats.corrected += max_bitflips; + ecc_stats->corrected += max_bitflips; return max_bitflips; } -static int denali_sw_ecc_fixup(struct mtd_info *mtd, +static int denali_sw_ecc_fixup(struct nand_chip *chip, struct denali_nand_info *denali, unsigned long *uncor_ecc_flags, uint8_t *buf) { - unsigned int ecc_size = denali->nand.ecc.size; + struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; + unsigned int ecc_size = chip->ecc.size; unsigned int bitflips = 0; unsigned int max_bitflips = 0; uint32_t err_addr, err_cor_info; @@ -404,7 +410,7 @@ static int denali_sw_ecc_fixup(struct mtd_info *mtd, /* correct the ECC error */ flips_in_byte = hweight8(buf[offset] ^ err_cor_value); buf[offset] ^= err_cor_value; - mtd->ecc_stats.corrected += flips_in_byte; + ecc_stats->corrected += flips_in_byte; bitflips += flips_in_byte; max_bitflips = max(max_bitflips, bitflips); @@ -587,9 +593,11 @@ static int denali_dma_xfer(struct denali_nand_info *denali, void *buf, return ret; } -static int denali_data_xfer(struct denali_nand_info *denali, void *buf, - size_t size, int page, int raw, int write) +static int denali_data_xfer(struct nand_chip *chip, void *buf, size_t size, + int page, int raw, int write) { + struct denali_nand_info *denali = to_denali(chip); + iowrite32(raw ? 0 : ECC_ENABLE__FLAG, denali->reg + ECC_ENABLE); iowrite32(raw ? TRANSFER_SPARE_REG__FLAG : 0, denali->reg + TRANSFER_SPARE_REG); @@ -678,7 +686,7 @@ static int denali_read_page_raw(struct nand_chip *chip, uint8_t *buf, size_t size = writesize + oobsize; int ret, i, pos, len; - ret = denali_data_xfer(denali, tmp_buf, size, page, 1, 0); + ret = denali_data_xfer(chip, tmp_buf, size, page, 1, 0); if (ret) return ret; @@ -766,14 +774,14 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf, int stat = 0; int ret; - ret = denali_data_xfer(denali, buf, mtd->writesize, page, 0, 0); + ret = denali_data_xfer(chip, buf, mtd->writesize, page, 0, 0); if (ret && ret != -EBADMSG) return ret; if (denali->caps & DENALI_CAP_HW_ECC_FIXUP) - stat = denali_hw_ecc_fixup(mtd, denali, &uncor_ecc_flags); + stat = denali_hw_ecc_fixup(chip, denali, &uncor_ecc_flags); else if (ret == -EBADMSG) - stat = denali_sw_ecc_fixup(mtd, denali, &uncor_ecc_flags, buf); + stat = denali_sw_ecc_fixup(chip, denali, &uncor_ecc_flags, buf); if (stat < 0) return stat; @@ -783,7 +791,7 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf, if (ret) return ret; - stat = denali_check_erased_page(mtd, chip, buf, + stat = denali_check_erased_page(chip, denali, buf, uncor_ecc_flags, stat); } @@ -866,17 +874,16 @@ static int denali_write_page_raw(struct nand_chip *chip, const uint8_t *buf, memcpy(tmp_buf + size - len, oob, len); } - return denali_data_xfer(denali, tmp_buf, size, page, 1, 1); + return denali_data_xfer(chip, tmp_buf, size, page, 1, 1); } static int denali_write_page(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page) { struct mtd_info *mtd = nand_to_mtd(chip); - struct denali_nand_info *denali = mtd_to_denali(mtd); - return denali_data_xfer(denali, (void *)buf, mtd->writesize, - page, 0, 1); + return denali_data_xfer(chip, (void *)buf, mtd->writesize, page, + 0, 1); } static void denali_select_chip(struct nand_chip *chip, int cs) @@ -1092,9 +1099,9 @@ static const struct mtd_ooblayout_ops denali_ooblayout_ops = { .free = denali_ooblayout_free, }; -static int denali_multidev_fixup(struct denali_nand_info *denali) +static int denali_multidev_fixup(struct nand_chip *chip) { - struct nand_chip *chip = &denali->nand; + struct denali_nand_info *denali = to_denali(chip); struct mtd_info *mtd = nand_to_mtd(chip); /* @@ -1222,7 +1229,7 @@ static int denali_attach_chip(struct nand_chip *chip) chip->ecc.read_oob = denali_read_oob; chip->ecc.write_oob = denali_write_oob; - ret = denali_multidev_fixup(denali); + ret = denali_multidev_fixup(chip); if (ret) return ret; From patchwork Tue Mar 12 08:44:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 160066 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12851703jad; Tue, 12 Mar 2019 01:46:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwdDzMz3dfVse87vATqh3wz2Y98bWSrNOS5/FAQq/3i9R+0DhPY/DfJ8m3IAr/VM0026NfX X-Received: by 2002:a17:902:1744:: with SMTP id i62mr38211381pli.24.1552380409344; Tue, 12 Mar 2019 01:46:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552380409; cv=none; d=google.com; s=arc-20160816; b=rQHGFZ0NLJq/oV+Wp/GQTIJl+CGT59bJaM84bPzXmCWPgEm8uAKk9E1x7gQgpAX2bh HzTP+eaJ0YlJ6b3Z6KuDJBeakV/pg/lt9/7+QU0fbHjsBzNjxyKSPftQqNW3RSYxmQx9 OpBivpHq4xTmwLsH7dIW2jf/Vl3gEJWnN6hIISrY9CdiuQtjVFasOtuBVdV70lnQb3G6 005Nefc7nse/2HG4126XTZDmMhSkvAtNuaw/gGCOqTmXrEG7L7wuQWOe3KmHxPYFyPSV mbrd5EsKxBSXbDdMosZqe0rL4tpsBn3d0Jy+HPNfue/6tsgTqjywGxZcP5+NOBapZxDc QRLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=zneTJ3QwGPOWKGJGeeQIx6zZWMikCj25VHRf9HUF+tw=; b=mqE5gPv6ctwK99Eag6c8W1ao1Pq3ExeIj9bEkmS2jSXjX9VPmRDBgWLNdbbseNpm6l A5Lm3yyCSXYL6jIm16fQrVBLqwnI0ZlMvh5ArZ7JxXRXdMCLt4j37fQ9NfiC21noqC8M 8YWXTd0PJz5f2CeCqMIJUG9jKdG6XJr657t/MXXW0ZE3XV1lqsZfld7ujXtAs4eL/1RN zrWY/Zz1y1tdvqzYcZfC5df2Qhg/AHq0a0X2/VC8/YFISA796E/T+iZAz8KZ9xn7jSKp JpyS9PX2vW+E7Gh2IV0RbTW4oGar3RuCV6qJFCP67y1ajpHcF9RKhzdfuCcCtVsF7HCh VIgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=MtOLdY8L; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=D8w+qk0l; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id i29si4040280pgi.95.2019.03.12.01.46.49 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 01:46:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=MtOLdY8L; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=D8w+qk0l; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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=zneTJ3QwGPOWKGJGeeQIx6zZWMikCj25VHRf9HUF+tw=; b=MtOLdY8LRoe2LL6o5LaD+gP2BX HAxQs9H/378TxDx8ENyLblluYZX3Z459bADNPnrf1B4Y6Ocfs9+i4Q3xvW1VxTNWDRzqY2mm+yu4F v0gaP3PbpT1RTksFx3xYzDil3WjJOCADYYtU+CerD627JmUazLiMQ5eY9bBPnNMmV94AMBQ9JXcVK t/sGfrX9Hx18kORQjVrd2M7yGux0SFMfRsjm3QxeEo0DXWn8JQwOaG5I7nudaCLTy2FsdY/An3zBE g5QWZgDmlS3plIRh573YVQODqFDKt9dxGv1hPeOakXKC8LIvtPpP4sav8iErDhGE8ZJ2CWM1rruUu ZsdipyTg==; 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 1h3d3U-0001KB-6m; Tue, 12 Mar 2019 08:46:36 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3d2e-00007B-IY for linux-mtd@lists.infradead.org; Tue, 12 Mar 2019 08:45:48 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x2C8j6Zc004092; Tue, 12 Mar 2019 17:45:17 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x2C8j6Zc004092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552380317; bh=OB+Je34CBXvI/Tvi8MqBviuF5fgs6TuosjQ9uD7FCmk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D8w+qk0lIXCyXCh9jmGAMWnAVjt5BelAUCKxXBnkYu1ElNeSbaubThuxsBNHT0kTp HU4iXE6uqauQYpRj5++f+ZzULKGaMWPcfHgEhPBD0ScGxHwmqgESvIHqVjWKyvT+Um IJ7umZOOIFC2cC2m9U97aCJsrWWB3Hs1kZNIuxifBmMRWf90Y1y7LzYZy3ZElK76oR W3VKBlny6O9jC5H7hypPJuItLHn9EpZNgW8CMGkwSFeoiwiBTzXqMe4tQLMltMM7Pf iPEQYvXlCtl3coNlpdmBtbCGlNQ2qnv/Rpd/eWiyWywI2aHN3B3gyHrh1F7fvZoY8O IDl3vfPNFUIgA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH v3 2/9] mtd: rawnand: denali: refactor syndrome layout handling for raw access Date: Tue, 12 Mar 2019 17:44:43 +0900 Message-Id: <1552380290-19951-3-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> References: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_014544_988304_2D99366D X-CRM114-Status: GOOD ( 22.03 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.76 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org The Denali IP adopts the syndrome page layout (payload and ECC are interleaved). The *_page_raw() and *_oob() callbacks are complicated because they must hide the underlying layout used by the hardware, and always return contiguous in-band and out-of-band data. Currently, similar code is duplicated to reorganize the data layout. For example, denali_read_page_raw() and denali_write_page_raw() look almost the same. The idea for refactoring is to split the code into two parts: [1] conversion of page layout [2] what to do at every ECC chunk boundary For [1], I wrote denali_raw_payload_op() and denali_raw_oob_op(). They manipulate data for the Denali controller's specific page layout of in-band, out-of-band, respectively. The difference between write and read is just the operation at ECC chunk boundaries. For example, denali_read_oob() calls nand_change_read_column_op(), whereas denali_write_oob() calls nand_change_write_column_op(). So, I implemented [2] as a callback passed into [1]. Signed-off-by: Masahiro Yamada --- Changes in v3: - Add comments to denali_raw_payload_op() and denali_oob_payload_op() Changes in v2: None drivers/mtd/nand/raw/denali.c | 380 +++++++++++++++++++++--------------------- 1 file changed, 189 insertions(+), 191 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 4ac1314..ebeedbd 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -608,159 +608,236 @@ static int denali_data_xfer(struct nand_chip *chip, void *buf, size_t size, return denali_pio_xfer(denali, buf, size, page, write); } -static void denali_oob_xfer(struct mtd_info *mtd, struct nand_chip *chip, - int page, int write) +typedef int denali_change_column_callback(void *buf, unsigned int offset, + unsigned int len, void *priv); + +/** + * denali_raw_payload_op() - arrange the payload data for syndrome layout + * + * The NAND framework passes the payload and ECC separately, but the Denali ECC + * engine cannot handle it directly because it writes/reads page data in the + * syndrome layout (payload and ECC are interleaved). This helper is useful to + * convert the layout between the two formats. + * + * @chip: NAND chip structure + * @buf: buffer passed from the NAND framework + * @cb: callback invoked whenever the column address is changed + * @priv: private data passed to @cb + */ +static int denali_raw_payload_op(struct nand_chip *chip, void *buf, + denali_change_column_callback *cb, void *priv) { - struct denali_nand_info *denali = mtd_to_denali(mtd); + struct denali_nand_info *denali = to_denali(chip); + struct mtd_info *mtd = nand_to_mtd(chip); + struct nand_ecc_ctrl *ecc = &chip->ecc; + int writesize = mtd->writesize; + int oob_skip = denali->oob_skip_bytes; + int ret, i, pos, len; + + for (i = 0; i < ecc->steps; i++) { + pos = i * (ecc->size + ecc->bytes); + len = ecc->size; + + if (pos >= writesize) { + pos += oob_skip; + } else if (pos + len > writesize) { + /* This chunk overwraps the BBM area. Must be split */ + ret = cb(buf, pos, writesize - pos, priv); + if (ret) + return ret; + + buf += writesize - pos; + len -= writesize - pos; + pos = writesize + oob_skip; + } + + ret = cb(buf, pos, len, priv); + if (ret) + return ret; + + buf += len; + } + + return 0; +} + +/** + * denali_raw_oob_op() - arrange the oob data for syndrome layout + * + * The NAND framework passes the payload and ECC separately, but the Denali ECC + * engine cannot handle it directly because it writes/reads page data in the + * syndrome layout (payload and ECC are interleaved). This helper is useful to + * convert the layout between the two formats. + * + * @chip: NAND chip structure + * @buf: buffer passed from the NAND framework + * @cb: callback invoked whenever the column address is changed + * @priv: private data passed to @cb + */ +static int denali_raw_oob_op(struct nand_chip *chip, void *buf, + denali_change_column_callback *cb, void *priv) +{ + struct denali_nand_info *denali = to_denali(chip); + struct mtd_info *mtd = nand_to_mtd(chip); + struct nand_ecc_ctrl *ecc = &chip->ecc; int writesize = mtd->writesize; int oobsize = mtd->oobsize; - uint8_t *bufpoi = chip->oob_poi; - int ecc_steps = chip->ecc.steps; - int ecc_size = chip->ecc.size; - int ecc_bytes = chip->ecc.bytes; int oob_skip = denali->oob_skip_bytes; - size_t size = writesize + oobsize; - int i, pos, len; + int ret, i, pos, len; /* BBM at the beginning of the OOB area */ - if (write) - nand_prog_page_begin_op(chip, page, writesize, bufpoi, - oob_skip); - else - nand_read_page_op(chip, page, writesize, bufpoi, oob_skip); - bufpoi += oob_skip; + ret = cb(buf, writesize, oob_skip, priv); + if (ret) + return ret; - /* OOB ECC */ - for (i = 0; i < ecc_steps; i++) { - pos = ecc_size + i * (ecc_size + ecc_bytes); - len = ecc_bytes; + buf += oob_skip; - if (pos >= writesize) - pos += oob_skip; - else if (pos + len > writesize) - len = writesize - pos; + for (i = 0; i < ecc->steps; i++) { + pos = ecc->size + i * (ecc->size + ecc->bytes); - if (write) - nand_change_write_column_op(chip, pos, bufpoi, len, - false); + if (i == ecc->steps - 1) + /* The last chunk includes OOB free */ + len = writesize + oobsize - pos - oob_skip; else - nand_change_read_column_op(chip, pos, bufpoi, len, - false); - bufpoi += len; - if (len < ecc_bytes) { - len = ecc_bytes - len; - if (write) - nand_change_write_column_op(chip, writesize + - oob_skip, bufpoi, - len, false); - else - nand_change_read_column_op(chip, writesize + - oob_skip, bufpoi, - len, false); - bufpoi += len; + len = ecc->bytes; + + if (pos >= writesize) { + pos += oob_skip; + } else if (pos + len > writesize) { + /* This chunk overwraps the BBM area. Must be split */ + ret = cb(buf, pos, writesize - pos, priv); + if (ret) + return ret; + + buf += writesize - pos; + len -= writesize - pos; + pos = writesize + oob_skip; } + + ret = cb(buf, pos, len, priv); + if (ret) + return ret; + + buf += len; } - /* OOB free */ - len = oobsize - (bufpoi - chip->oob_poi); - if (write) - nand_change_write_column_op(chip, size - len, bufpoi, len, - false); - else - nand_change_read_column_op(chip, size - len, bufpoi, len, - false); + return 0; +} + +static int denali_memcpy_in(void *buf, unsigned int offset, unsigned int len, + void *priv) +{ + memcpy(buf, priv + offset, len); + return 0; } static int denali_read_page_raw(struct nand_chip *chip, uint8_t *buf, int oob_required, int page) { + struct denali_nand_info *denali = to_denali(chip); struct mtd_info *mtd = nand_to_mtd(chip); - struct denali_nand_info *denali = mtd_to_denali(mtd); - int writesize = mtd->writesize; - int oobsize = mtd->oobsize; - int ecc_steps = chip->ecc.steps; - int ecc_size = chip->ecc.size; - int ecc_bytes = chip->ecc.bytes; void *tmp_buf = denali->buf; - int oob_skip = denali->oob_skip_bytes; - size_t size = writesize + oobsize; - int ret, i, pos, len; + size_t size = mtd->writesize + mtd->oobsize; + int ret; + + if (!buf) + return -EINVAL; ret = denali_data_xfer(chip, tmp_buf, size, page, 1, 0); if (ret) return ret; - /* Arrange the buffer for syndrome payload/ecc layout */ - if (buf) { - for (i = 0; i < ecc_steps; i++) { - pos = i * (ecc_size + ecc_bytes); - len = ecc_size; - - if (pos >= writesize) - pos += oob_skip; - else if (pos + len > writesize) - len = writesize - pos; - - memcpy(buf, tmp_buf + pos, len); - buf += len; - if (len < ecc_size) { - len = ecc_size - len; - memcpy(buf, tmp_buf + writesize + oob_skip, - len); - buf += len; - } - } - } + ret = denali_raw_payload_op(chip, buf, denali_memcpy_in, tmp_buf); + if (ret) + return ret; if (oob_required) { - uint8_t *oob = chip->oob_poi; - - /* BBM at the beginning of the OOB area */ - memcpy(oob, tmp_buf + writesize, oob_skip); - oob += oob_skip; - - /* OOB ECC */ - for (i = 0; i < ecc_steps; i++) { - pos = ecc_size + i * (ecc_size + ecc_bytes); - len = ecc_bytes; - - if (pos >= writesize) - pos += oob_skip; - else if (pos + len > writesize) - len = writesize - pos; - - memcpy(oob, tmp_buf + pos, len); - oob += len; - if (len < ecc_bytes) { - len = ecc_bytes - len; - memcpy(oob, tmp_buf + writesize + oob_skip, - len); - oob += len; - } - } - - /* OOB free */ - len = oobsize - (oob - chip->oob_poi); - memcpy(oob, tmp_buf + size - len, len); + ret = denali_raw_oob_op(chip, chip->oob_poi, denali_memcpy_in, + tmp_buf); + if (ret) + return ret; } return 0; } -static int denali_read_oob(struct nand_chip *chip, int page) +static int denali_memcpy_out(void *buf, unsigned int offset, unsigned int len, + void *priv) { + memcpy(priv + offset, buf, len); + return 0; +} + +static int denali_write_page_raw(struct nand_chip *chip, const uint8_t *buf, + int oob_required, int page) +{ + struct denali_nand_info *denali = to_denali(chip); struct mtd_info *mtd = nand_to_mtd(chip); + void *tmp_buf = denali->buf; + size_t size = mtd->writesize + mtd->oobsize; + int ret; - denali_oob_xfer(mtd, chip, page, 0); + if (!buf) + return -EINVAL; - return 0; + /* + * Fill the buffer with 0xff first except the full page transfer. + * This simplifies the logic. + */ + if (!oob_required) + memset(tmp_buf, 0xff, size); + + ret = denali_raw_payload_op(chip, (void *)buf, denali_memcpy_out, + tmp_buf); + if (ret) + return ret; + + if (oob_required) { + ret = denali_raw_oob_op(chip, chip->oob_poi, denali_memcpy_out, + tmp_buf); + if (ret) + return ret; + } + + return denali_data_xfer(chip, tmp_buf, size, page, 1, 1); +} + +static int denali_change_read_column_op(void *buf, unsigned int offset, + unsigned int len, void *priv) +{ + return nand_change_read_column_op(priv, offset, buf, len, false); +} + +static int denali_read_oob(struct nand_chip *chip, int page) +{ + int ret; + + ret = nand_read_page_op(chip, page, 0, NULL, 0); + if (ret) + return ret; + + return denali_raw_oob_op(chip, chip->oob_poi, + denali_change_read_column_op, chip); +} + +static int denali_change_write_column_op(void *buf, unsigned int offset, + unsigned int len, void *priv) +{ + return nand_change_write_column_op(priv, offset, buf, len, false); } static int denali_write_oob(struct nand_chip *chip, int page) { - struct mtd_info *mtd = nand_to_mtd(chip); + int ret; + + ret = nand_prog_page_begin_op(chip, page, 0, NULL, 0); + if (ret) + return ret; - denali_oob_xfer(mtd, chip, page, 1); + ret = denali_raw_oob_op(chip, chip->oob_poi, + denali_change_write_column_op, chip); + if (ret) + return ret; return nand_prog_page_end_op(chip); } @@ -798,85 +875,6 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf, return stat; } -static int denali_write_page_raw(struct nand_chip *chip, const uint8_t *buf, - int oob_required, int page) -{ - struct mtd_info *mtd = nand_to_mtd(chip); - struct denali_nand_info *denali = mtd_to_denali(mtd); - int writesize = mtd->writesize; - int oobsize = mtd->oobsize; - int ecc_steps = chip->ecc.steps; - int ecc_size = chip->ecc.size; - int ecc_bytes = chip->ecc.bytes; - void *tmp_buf = denali->buf; - int oob_skip = denali->oob_skip_bytes; - size_t size = writesize + oobsize; - int i, pos, len; - - /* - * Fill the buffer with 0xff first except the full page transfer. - * This simplifies the logic. - */ - if (!buf || !oob_required) - memset(tmp_buf, 0xff, size); - - /* Arrange the buffer for syndrome payload/ecc layout */ - if (buf) { - for (i = 0; i < ecc_steps; i++) { - pos = i * (ecc_size + ecc_bytes); - len = ecc_size; - - if (pos >= writesize) - pos += oob_skip; - else if (pos + len > writesize) - len = writesize - pos; - - memcpy(tmp_buf + pos, buf, len); - buf += len; - if (len < ecc_size) { - len = ecc_size - len; - memcpy(tmp_buf + writesize + oob_skip, buf, - len); - buf += len; - } - } - } - - if (oob_required) { - const uint8_t *oob = chip->oob_poi; - - /* BBM at the beginning of the OOB area */ - memcpy(tmp_buf + writesize, oob, oob_skip); - oob += oob_skip; - - /* OOB ECC */ - for (i = 0; i < ecc_steps; i++) { - pos = ecc_size + i * (ecc_size + ecc_bytes); - len = ecc_bytes; - - if (pos >= writesize) - pos += oob_skip; - else if (pos + len > writesize) - len = writesize - pos; - - memcpy(tmp_buf + pos, oob, len); - oob += len; - if (len < ecc_bytes) { - len = ecc_bytes - len; - memcpy(tmp_buf + writesize + oob_skip, oob, - len); - oob += len; - } - } - - /* OOB free */ - len = oobsize - (oob - chip->oob_poi); - memcpy(tmp_buf + size - len, oob, len); - } - - return denali_data_xfer(chip, tmp_buf, size, page, 1, 1); -} - static int denali_write_page(struct nand_chip *chip, const uint8_t *buf, int oob_required, int page) { From patchwork Tue Mar 12 08:44:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 160063 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12851410jad; Tue, 12 Mar 2019 01:46:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqxSKn+YQMO78IRT0A+5x8OsxWH63Ptkjzu2yK8cfp1roJmwZSQsiCSNSMEHCmAvXE6IiGjk X-Received: by 2002:a63:fb16:: with SMTP id o22mr33266365pgh.209.1552380382988; Tue, 12 Mar 2019 01:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552380382; cv=none; d=google.com; s=arc-20160816; b=hvj5lmrDNPYuAXlPu10LqDoX6U/A5CWkw42AjlU9cm4dYHz4C8VlAYHS2YX0a2Onz/ l4zrkX6ry0zxY8moT+B87i8BC2Y3kYtG/C7/1e8gJMalDufJdA4Eksj5kRlxOz3a81ue rRS44PMDPnfo5LbavGa7MSnvLAltOXT8YUKc9dzOK06nXIlamaQDIS/Mng2xYRw1a/Xi vegeLNBTMCYftEK1ibg8e+ZD+QHSQ/25WYVxriOBjyv6PT+OZMKGnfKB7CKiswArWuHi WuroxqnnWzWTQ0DqgMgeB5xtpgyEU6jcaaLgjIjVcuz2Zh4EclC9FQp+jvjUVfd6Zakz ir+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=qj2vC+02pCPgm9enQANKf11hLz/ynK7J54G/44siBtY=; b=g+ZDJRLgAGQrio5F1YQLzrHczCjfRV9CLxIahEiBCmnGWmaxSf9x4EGSeueMiAu9wb AydWZLf7vgGnjY/T5pG0oBscHEuywJ3Cw23B24MhAbfI5Mibtm7/4E5jYDbkLN2Dognj tYMPJTgW6J65EJKRJZuRu5Pn0dJNDlHonuGlvuiPq67ZqIvV3Tz0RanTk/z1X+5+qSXE svw4jcKcBC8jVzja/BNgtxXW+1psW3GaZk8ir665y8LMXgpXZ5D9ZPXGAJZ5qbdz6gTE 7eD7adgDZ7lZaEv14i3e80fq55+fhsnv+gu8bUPQfC5/ajz/PSwnieUDlxQXWzh8zeLa +RwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=WOyIp8xk; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="NORy5/8b"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id x61si7734730plb.197.2019.03.12.01.46.22 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 01:46:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=WOyIp8xk; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b="NORy5/8b"; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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=qj2vC+02pCPgm9enQANKf11hLz/ynK7J54G/44siBtY=; b=WOyIp8xk4rfjYQOG1LH6Iz37jD fUvq/BperaBc2toM0uWT4NuA2P4bxlam2L9dTC6ynR6dVLbTUM62MuVsnY6e/WCkWV3SeFcI+jtXG KCG7Svg21BxusqRh17HkDHMzGtzuPsiYiEuq2tM/mfFQfwxsURdol0KjPxD2Rg4EFuoH3LPBGUb7x zBUpB+wbh3sEnrQMHw0uQY3b4N42owzozy3WpK2v3EcqI9FKvusd0cgCzltDrKUhfSUv2Bu7fU3zZ X08CdV9G85KCbZxptTQ3tokwcNJMSlI3geaO+PmkckUj+PocGnhwh6XEWEmPS4zGvwRkTYDwZ5IA3 gwIgigYg==; 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 1h3d39-0000no-O6; Tue, 12 Mar 2019 08:46:15 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3d2e-000074-IW for linux-mtd@lists.infradead.org; Tue, 12 Mar 2019 08:45:47 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x2C8j6Zd004092; Tue, 12 Mar 2019 17:45:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x2C8j6Zd004092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552380318; bh=qWRjILUJ5jjZY9FFH+5ZJYFjW1Di+opuV2JZeSRLmxM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NORy5/8bdn8Lkj/xBxzJVLbdu4wKQmDJUa7pWwu9BQgl5fN6jzQLlUeEsV4rGrTnv nqDHbOH/aXTOuFsl1GePMvdWrJeRoHTEAlUrIlE1wC5BE87hVSH61Nz8krg0rf1Y+R WxNnAjLL5G7REQ/OpZYjmIcmgEQ8pr2FVTi50rMCQbdDbxuJ6nRJZCYVqgnrTkgsX+ CRMJoAt0XC0BTImMtYETULmyaa2f8jrGiRrTINzyj6dp9nNRrGSr99ummQCkEhiUbF 6CJ0jbOTovxDo2mmcPo43S6IrzA6JJaMvWxzVhVKDCqnYRcRD0ks2C1dWhcA7vYtyA o2fROoHmL4rSQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH v3 3/9] mtd: rawnand: denali: remove unneeded casts in denali_{read, write}_pio Date: Tue, 12 Mar 2019 17:44:44 +0900 Message-Id: <1552380290-19951-4-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> References: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_014544_932059_E1740D86 X-CRM114-Status: GOOD ( 11.02 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.76 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Since (u32 *) can accept an opaque pointer, the explicit casting from (void *) to (u32 *) is redundant. Change the function argument type to remove the casts. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None drivers/mtd/nand/raw/denali.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index ebeedbd..d2040b7 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -478,11 +478,10 @@ static void denali_setup_dma32(struct denali_nand_info *denali, denali->host_write(denali, mode | 0x14000, 0x2400); } -static int denali_pio_read(struct denali_nand_info *denali, void *buf, +static int denali_pio_read(struct denali_nand_info *denali, u32 *buf, size_t size, int page) { u32 addr = DENALI_MAP01 | DENALI_BANK(denali) | page; - uint32_t *buf32 = (uint32_t *)buf; uint32_t irq_status, ecc_err_mask; int i; @@ -494,7 +493,7 @@ static int denali_pio_read(struct denali_nand_info *denali, void *buf, denali_reset_irq(denali); for (i = 0; i < size / 4; i++) - *buf32++ = denali->host_read(denali, addr); + buf[i] = denali->host_read(denali, addr); irq_status = denali_wait_for_irq(denali, INTR__PAGE_XFER_INC); if (!(irq_status & INTR__PAGE_XFER_INC)) @@ -506,18 +505,17 @@ static int denali_pio_read(struct denali_nand_info *denali, void *buf, return irq_status & ecc_err_mask ? -EBADMSG : 0; } -static int denali_pio_write(struct denali_nand_info *denali, - const void *buf, size_t size, int page) +static int denali_pio_write(struct denali_nand_info *denali, const u32 *buf, + size_t size, int page) { u32 addr = DENALI_MAP01 | DENALI_BANK(denali) | page; - const uint32_t *buf32 = (uint32_t *)buf; uint32_t irq_status; int i; denali_reset_irq(denali); for (i = 0; i < size / 4; i++) - denali->host_write(denali, addr, *buf32++); + denali->host_write(denali, addr, buf[i]); irq_status = denali_wait_for_irq(denali, INTR__PROGRAM_COMP | INTR__PROGRAM_FAIL); From patchwork Tue Mar 12 08:44:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 160067 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12851782jad; Tue, 12 Mar 2019 01:46:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwNdOjKYSimpW5ZOkQk/uIjWYVLnlRvvguuEK9pLhEMuxGD6ImgV9Hy0Tf1KDeoTXYQbyIc X-Received: by 2002:a65:5c01:: with SMTP id u1mr34148137pgr.197.1552380415857; Tue, 12 Mar 2019 01:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552380415; cv=none; d=google.com; s=arc-20160816; b=WmwgHkodiplR1oSa7LQpcMdxjWLNSneFcv+YccBaQQBf7TFIhyQF6eZBZZq+dqz71i WTO0zfSFS4unAOz/TwDWgF2wmtTpKV/JJqcCmT3l8JDimatiTq4Z3tdaQzXpJx7YAtyx an9I+FM9UKu+lNggc7X9obwL8fi26vL4GVHQNyCuoPK87Fy+l8JOZDfWy9n8tWJ696+1 oxWmy5Z8s5j/MziBS9Imx+mtvhO4Y9R/mK7M0Bc90nd1wFfXqXUDhJE1PDtY9lq85XM5 qC5BsfBC4YvWAuzii4vgpElh/N2U+8+WSnDcgRpaZwmSyGurX+aUaZ0FT9ZJ0ZcFgHfH qx5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=M55VsNAkfAuCY705CpYunkeePCIbZ0BEIUvbg9cMiNo=; b=hOZ+rqFHCeY/C2RO7KRSamr5C0yJkrPa0P8IhDnj8KLJRaxc7TueyRiWU2HFKLYrH0 XgI2tNcTv9Awv32QspjC32OA03+aLPuuYzl/pOfs91dbMq+q9/5dmFPxfMOo5zcDbzFM edb8yJoNH13fHOWTiJhlUxMYCN1+vCCO/w8sKAVyP7C1SHjXuzHt334RNoPwfezz8zUj iEZiepajRoZZJJIQ2UR2Ia01HY0LLIHDXIFsJhrOygzmlAB63NqQzbETgO36YBcy7KmW 0hnNL4y0Ci9Y3vDzmndFZgFPXPkd8QpZQbaF3bkGlFMQECGcgSDaDNibj7urw+cBA++V 2mwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=fD8HTSJM; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=0uv4NW+i; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id q14si7526637pls.204.2019.03.12.01.46.55 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 01:46:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=fD8HTSJM; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=0uv4NW+i; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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=M55VsNAkfAuCY705CpYunkeePCIbZ0BEIUvbg9cMiNo=; b=fD8HTSJMoXEic5WEV20q3hzXHW RTAwrwTOoviGCnkqFSPab3CQjMJ6hNcR0D/bOTXBNjAi3Zmpf65fUPH4p9qySAtUuPffNv0UqwxZx 0F0PHJyNAYQCnAdQkGobEHAJjgTgWigHhlQKJwenn7QAhdUa1iOf8Ecua4uKP8e4Mcq66NDXUxuVV 9fg4Kb+syXn+RMzoPbL71uB5vspVzTeFn//1ry6s4AVGDTU+jhnwC0zdAiCV/mgydf5l49pKbAZO9 s44oJdjLG6Mi977DlLqP+x6bwrkE3hE51EyMf/q9d6lWyXctw8LOrRJgo95ogB3XWSXJSRG9tHelq kDpe2mHg==; 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 1h3d3e-0001YQ-SS; Tue, 12 Mar 2019 08:46:46 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3d2e-00007A-IZ for linux-mtd@lists.infradead.org; Tue, 12 Mar 2019 08:45:49 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x2C8j6Ze004092; Tue, 12 Mar 2019 17:45:18 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x2C8j6Ze004092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552380319; bh=KGgK5J0tXA9Al1V3agKvDoj8rMsm3PIh3N0483clLxg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0uv4NW+iVshaqTjpAwcLfLbMg+LQiJ0GASbpGK9l/TV3MOeqOOeVSXlF23ZC+f9j0 75pUIjtDlZ73b54tbsj0iw5RTXZCUIJKwGoUQ6W1LMFFui7bddA64aQpIHRZq+pGuz 8qlWQB6PGy8oBv0iIpV9wsYvsxOqf3hxxcZ/hkRc55yS9nm6EgJTVXLcPAbqD+Y9I5 hAeQEtzX6WbmkBbrfQH+2MEm5F9UZXY2VUMK6iMdxw90abeY4XCIfqSC0Qfi/Chl/S Hh8RzqzVFugqM56ldmQZS9mOdG3gquKCvVHC1PUqh5k+7S9+QC2KaR/5xL1z1o3KZU j7UwSbt9riwYA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH v3 4/9] mtd: rawnand: denali: switch over to ->exec_op() from legacy hooks Date: Tue, 12 Mar 2019 17:44:45 +0900 Message-Id: <1552380290-19951-5-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> References: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_014545_000659_19844329 X-CRM114-Status: GOOD ( 18.22 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.76 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Implement ->exec_op(), and remove the deprecated hooks. Signed-off-by: Masahiro Yamada --- Changes in v3: - Fix byte-swap in denali_exec_in16() Changes in v2: None drivers/mtd/nand/raw/denali.c | 234 +++++++++++++++++++++++------------------- 1 file changed, 126 insertions(+), 108 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index d2040b7..2c7dc9b 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -206,85 +206,11 @@ static uint32_t denali_wait_for_irq(struct denali_nand_info *denali, return denali->irq_status; } -static void denali_read_buf(struct nand_chip *chip, uint8_t *buf, int len) +static void denali_select_target(struct nand_chip *chip, int cs) { - struct mtd_info *mtd = nand_to_mtd(chip); - struct denali_nand_info *denali = mtd_to_denali(mtd); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - int i; - - for (i = 0; i < len; i++) - buf[i] = denali->host_read(denali, addr); -} - -static void denali_write_buf(struct nand_chip *chip, const uint8_t *buf, - int len) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - int i; - - for (i = 0; i < len; i++) - denali->host_write(denali, addr, buf[i]); -} - -static void denali_read_buf16(struct nand_chip *chip, uint8_t *buf, int len) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - uint16_t *buf16 = (uint16_t *)buf; - int i; - - for (i = 0; i < len / 2; i++) - buf16[i] = denali->host_read(denali, addr); -} - -static void denali_write_buf16(struct nand_chip *chip, const uint8_t *buf, - int len) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - u32 addr = DENALI_MAP11_DATA | DENALI_BANK(denali); - const uint16_t *buf16 = (const uint16_t *)buf; - int i; - - for (i = 0; i < len / 2; i++) - denali->host_write(denali, addr, buf16[i]); -} - -static uint8_t denali_read_byte(struct nand_chip *chip) -{ - uint8_t byte; - - denali_read_buf(chip, &byte, 1); - - return byte; -} - -static void denali_write_byte(struct nand_chip *chip, uint8_t byte) -{ - denali_write_buf(chip, &byte, 1); -} - -static void denali_cmd_ctrl(struct nand_chip *chip, int dat, unsigned int ctrl) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - uint32_t type; - - if (ctrl & NAND_CLE) - type = DENALI_MAP11_CMD; - else if (ctrl & NAND_ALE) - type = DENALI_MAP11_ADDR; - else - return; - - /* - * Some commands are followed by chip->legacy.waitfunc. - * irq_status must be cleared here to catch the R/B# interrupt later. - */ - if (ctrl & NAND_CTRL_CHANGE) - denali_reset_irq(denali); + struct denali_nand_info *denali = to_denali(chip); - denali->host_write(denali, DENALI_BANK(denali) | type, dat); + denali->active_bank = cs; } static int denali_check_erased_page(struct nand_chip *chip, @@ -596,6 +522,8 @@ static int denali_data_xfer(struct nand_chip *chip, void *buf, size_t size, { struct denali_nand_info *denali = to_denali(chip); + denali_select_target(chip, chip->cur_cs); + iowrite32(raw ? 0 : ECC_ENABLE__FLAG, denali->reg + ECC_ENABLE); iowrite32(raw ? TRANSFER_SPARE_REG__FLAG : 0, denali->reg + TRANSFER_SPARE_REG); @@ -882,24 +810,6 @@ static int denali_write_page(struct nand_chip *chip, const uint8_t *buf, 0, 1); } -static void denali_select_chip(struct nand_chip *chip, int cs) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - - denali->active_bank = cs; -} - -static int denali_waitfunc(struct nand_chip *chip) -{ - struct denali_nand_info *denali = mtd_to_denali(nand_to_mtd(chip)); - uint32_t irq_status; - - /* R/B# pin transitioned from low to high? */ - irq_status = denali_wait_for_irq(denali, INTR__INT_ACT); - - return irq_status & INTR__INT_ACT ? 0 : NAND_STATUS_FAIL; -} - static int denali_setup_data_interface(struct nand_chip *chip, int chipnr, const struct nand_data_interface *conf) { @@ -1211,13 +1121,6 @@ static int denali_attach_chip(struct nand_chip *chip) mtd_set_ooblayout(mtd, &denali_ooblayout_ops); - if (chip->options & NAND_BUSWIDTH_16) { - chip->legacy.read_buf = denali_read_buf16; - chip->legacy.write_buf = denali_write_buf16; - } else { - chip->legacy.read_buf = denali_read_buf; - chip->legacy.write_buf = denali_write_buf; - } chip->ecc.read_page = denali_read_page; chip->ecc.read_page_raw = denali_read_page_raw; chip->ecc.write_page = denali_write_page; @@ -1249,9 +1152,130 @@ static void denali_detach_chip(struct nand_chip *chip) kfree(denali->buf); } +static void denali_exec_in8(struct denali_nand_info *denali, u32 type, + u8 *buf, unsigned int len) +{ + int i; + + for (i = 0; i < len; i++) + buf[i] = denali->host_read(denali, type | DENALI_BANK(denali)); +} + +static void denali_exec_in16(struct denali_nand_info *denali, u32 type, + u8 *buf, unsigned int len) +{ + u32 data; + int i; + + for (i = 0; i < len; i += 2) { + data = denali->host_read(denali, type | DENALI_BANK(denali)); + /* bit 31:24 and 15:8 are used for DDR */ + buf[i] = data; + buf[i + 1] = data >> 16; + } +} + +static void denali_exec_out8(struct denali_nand_info *denali, u32 type, + const u8 *buf, unsigned int len) +{ + int i; + + for (i = 0; i < len; i++) + denali->host_write(denali, type | DENALI_BANK(denali), buf[i]); +} + +static void denali_exec_out16(struct denali_nand_info *denali, u32 type, + const u8 *buf, unsigned int len) +{ + int i; + + for (i = 0; i < len; i += 2) + denali->host_write(denali, type | DENALI_BANK(denali), + buf[i + 1] << 16 | buf[i]); +} + +static int denali_exec_waitrdy(struct denali_nand_info *denali) +{ + u32 irq_stat; + + /* R/B# pin transitioned from low to high? */ + irq_stat = denali_wait_for_irq(denali, INTR__INT_ACT); + + /* Just in case nand_operation has multiple NAND_OP_WAITRDY_INSTR. */ + denali_reset_irq(denali); + + return irq_stat & INTR__INT_ACT ? 0 : -EIO; +} + +static int denali_exec_instr(struct nand_chip *chip, + const struct nand_op_instr *instr) +{ + struct denali_nand_info *denali = to_denali(chip); + bool width16 = chip->options & NAND_BUSWIDTH_16; + + switch (instr->type) { + case NAND_OP_CMD_INSTR: + denali_exec_out8(denali, DENALI_MAP11_CMD, + &instr->ctx.cmd.opcode, 1); + return 0; + case NAND_OP_ADDR_INSTR: + denali_exec_out8(denali, DENALI_MAP11_ADDR, + instr->ctx.addr.addrs, + instr->ctx.addr.naddrs); + return 0; + case NAND_OP_DATA_IN_INSTR: + (!instr->ctx.data.force_8bit && width16 ? + denali_exec_in16 : + denali_exec_in8)(denali, DENALI_MAP11_DATA, + instr->ctx.data.buf.in, + instr->ctx.data.len); + return 0; + case NAND_OP_DATA_OUT_INSTR: + (!instr->ctx.data.force_8bit && width16 ? + denali_exec_out16 : + denali_exec_out8)(denali, DENALI_MAP11_DATA, + instr->ctx.data.buf.out, + instr->ctx.data.len); + return 0; + case NAND_OP_WAITRDY_INSTR: + return denali_exec_waitrdy(denali); + default: + WARN_ONCE(1, "unsupported NAND instruction type: %d\n", + instr->type); + + return -EINVAL; + } +} + +static int denali_exec_op(struct nand_chip *chip, + const struct nand_operation *op, bool check_only) +{ + int i, ret; + + if (check_only) + return 0; + + denali_select_target(chip, op->cs); + + /* + * Some commands contain NAND_OP_WAITRDY_INSTR. + * irq must be cleared here to catch the R/B# interrupt there. + */ + denali_reset_irq(to_denali(chip)); + + for (i = 0; i < op->ninstrs; i++) { + ret = denali_exec_instr(chip, &op->instrs[i]); + if (ret) + return ret; + } + + return 0; +} + static const struct nand_controller_ops denali_controller_ops = { .attach_chip = denali_attach_chip, .detach_chip = denali_detach_chip, + .exec_op = denali_exec_op, .setup_data_interface = denali_setup_data_interface, }; @@ -1286,12 +1310,6 @@ int denali_init(struct denali_nand_info *denali) if (!mtd->name) mtd->name = "denali-nand"; - chip->legacy.select_chip = denali_select_chip; - chip->legacy.read_byte = denali_read_byte; - chip->legacy.write_byte = denali_write_byte; - chip->legacy.cmd_ctrl = denali_cmd_ctrl; - chip->legacy.waitfunc = denali_waitfunc; - if (features & FEATURES__INDEX_ADDR) { denali->host_read = denali_indexed_read; denali->host_write = denali_indexed_write; From patchwork Tue Mar 12 08:44:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 160061 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12851201jad; Tue, 12 Mar 2019 01:46:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqz50YaMvawXBz+B2OyRGWO6oTLULwg465YJlkYIqdN0Obeu57ARAWmq7viSigIqmCWjNTaV X-Received: by 2002:a65:4244:: with SMTP id d4mr34439833pgq.419.1552380363272; Tue, 12 Mar 2019 01:46:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552380363; cv=none; d=google.com; s=arc-20160816; b=szsA7toMC7XjFs9vlAIx5H3zSLhA1zWA4INpjiqVaPhpYj8Q4r/4RMhi8U249cTqpI 6XxYLH+bzQSvdn336D3O1cd6DBICo6Z8uP/ZPYbXSCsGb+wo3znPXHE5VyITsmTohdNu g8nGSpEJFKAY4b0kFzskZhbS4OHb9y2jiilyvG7W8kfnRC8SfsXkY3Ci0PAWtdsXkclL MhNFDHi9kNdrEfWW2krzaEm1uEaBZz+1WxooatuGAi7u0uBP2VpN95bx1nfSyCqCkqec BMxdn/iR3+FNnXd2Tts9OnAzer22IuK8YK5a+Xi4OpPKt5Id6mshEUJ+SBHbnpCPxsr6 y+FA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=VvZexAzc5bc29uNfvht+5rnO3SWZj17nuYw/wqj3LpY=; b=rwiXGQiwUfP24Iv00LixJKGeTa7cE2HcIbMhwptJt+ZWp9UgZtkDkK9+L3zBQ2F20e 1HWBBz1lALB9lj4EulHViK6KksxYeXXTGPLNVVPaTkQqNISq7RcZVmFSjwrXc3d7AaGX OvQtfPSBqtLDDY1IgFU1rIOn6T+8CVFlc4SzAO+awbbwiFfKEBf0TdEoHW4DAawkzAEw F2qWjx5A/wb8SVWfkx9K6C0ztwel7v2LtL5RYnbs23ceZzrnseXPNgEUH55+oUgmBda1 Bw9lhXBF5rLH8xa3O1pivydRBECe0pu4rRRbn1mbI/tpgwBzYpSoVuOAJNeshPLQKTAZ QHDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=qFZ30U31; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=f60oHmXc; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id c2si1042306pll.317.2019.03.12.01.46.03 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 01:46:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=qFZ30U31; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=f60oHmXc; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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=VvZexAzc5bc29uNfvht+5rnO3SWZj17nuYw/wqj3LpY=; b=qFZ30U31L78HTFGZgZtnDSivQs vuMSKADANO+dvmUJjZWggOelobPmdoqGbxq5FF6f2jv8u81KjlGovaJf6vtYOx4AKucn7gsNtDt/a 1QmN6R+rjLV4T7I1VsjSKKrWzcTKvZSuZOCBqnbuXlTHV0ax+OTyHMJ3Nsq6NGSAJO81uWila9rn5 IKQF66XZ4L3RIfputCRn6PYFDGt9YeuetZoI7266PGY3R/lnk3EbPEk/V2jSGJBluBJgzSiBwpwTa 5rt79GYVb+5F8MKvWptPqF4KS4FlqMSzu8NJRjRwpxvJwGaxoDOUA5vn4k56b3K2hlIVnDxGbJZTK wHhpeSJQ==; 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 1h3d2i-0000A8-Kr; Tue, 12 Mar 2019 08:45:48 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3d2e-000075-IV for linux-mtd@lists.infradead.org; Tue, 12 Mar 2019 08:45:46 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x2C8j6Zg004092; Tue, 12 Mar 2019 17:45:20 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x2C8j6Zg004092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552380321; bh=/HYOG6Znx3tjMAy9o8VQey5HBdroa+Gr+dhg2Ya6JXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=f60oHmXc6d/J1BcGZuZ+ww2rj+8Hnvq1sLh94PruRHLVGt8yaHlZjshFOg8TOyH0e na2Ca3Du4Up5H+TCAlUqN/33pYIXGZxuO7iNNfxGDCFco+W8idhtgvIa9r7EmHBlAI VU+Z4+8XqsLiyz7F8TyS+etj1lOplPtCUVSLh2cke0Defh1Rc/La9aoqxvQ7tFuUq+ Eg8i8Pee9+fbk7hSBDCsklumJ2XTkf9YjP49RxYYIum1nmxwFHNhfOAxjxGooghe39 yKZhWgowpvZLtX6DekWaQbXROoO1OelRVIZAhzrG5OqDSX7YceI7zOwN62Ssvz0SU+ dbqWARCGnau5w== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH v3 6/9] mtd: rawnand: denali_pci: rename goto labels Date: Tue, 12 Mar 2019 17:44:47 +0900 Message-Id: <1552380290-19951-7-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> References: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_014544_932059_CD122823 X-CRM114-Status: GOOD ( 11.39 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.76 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org As Documentation/process/coding-style.rst says, choose label names which say what the goto does. The out_ label style is already used in denali_dt.c. Rename likewise for denali_pci.c Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None drivers/mtd/nand/raw/denali_pci.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali_pci.c b/drivers/mtd/nand/raw/denali_pci.c index 48e9ac5..02eb599 100644 --- a/drivers/mtd/nand/raw/denali_pci.c +++ b/drivers/mtd/nand/raw/denali_pci.c @@ -84,20 +84,20 @@ static int denali_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) if (!denali->host) { dev_err(&dev->dev, "Spectra: ioremap_nocache failed!"); ret = -ENOMEM; - goto failed_remap_reg; + goto out_unmap_reg; } ret = denali_init(denali); if (ret) - goto failed_remap_mem; + goto out_unmap_host; pci_set_drvdata(dev, denali); return 0; -failed_remap_mem: +out_unmap_host: iounmap(denali->host); -failed_remap_reg: +out_unmap_reg: iounmap(denali->reg); return ret; } From patchwork Tue Mar 12 08:44:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 160062 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12851370jad; Tue, 12 Mar 2019 01:46:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwrZlQzXUDPIv40frFPRsJyPCGmGMln+y5+vueFt3Ko5YzqYvaIZCRBIppoUpGzhl7aJCbr X-Received: by 2002:a17:902:2a27:: with SMTP id i36mr8339837plb.334.1552380379895; Tue, 12 Mar 2019 01:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552380379; cv=none; d=google.com; s=arc-20160816; b=RcU8pXE1g8rRsK2b3Ft97u295m4tidRVOWV5KvvZUK5OmHIp0vxTx0/jdwtTqUbQ+q RBf3ptVVqAiMevoNxSJltdf7TupAlra0wKDxVcJxdiCuu+fkKwa7mh4IrqOh56rS+E61 vaXssvS5V50aIz1iz7paKf2q+udI5/cfVZQI8M5Uz5GS8dhLCb6BDCnyiTD9xY5kYYMR s+jaa++LNNcHMUAOkwA2Dd2qJlTwmM4bM/b2ur1SehLKXWZtabvUioPSB1iD0y0N/9eX o6DEnVlc/piirrykXrdIybU9P37YzLVHEt+pJaGayLntj13WfSDok3zJ+iI5njUkNRcE XJlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=nB6WyYc/vPjFBHB1KEH1e4Uli8n96s+WwDgJQyty90A=; b=n11a9IUBILgysdQ7QZ8mz86k4zPF97vPsUTUF8lttjUJel8uM/udmBlCe29XIAX7ft 2Yu4iMGHdgAR1Rw/jWli60SxtxyTFVKwNqzhRTGNI54k37+xTSrXovgjJqmTI8Ruyc6r VyIsXZwSNkg69g7UsuJ3twL4kPfbUjyAzXBJSeIT1c0YarSOFZlCYHa/PjFpTb/F9Up0 XLWZ+Bo954zAJz5ZjZapP4Tsp/N1rq8zE2+mxBWXOBOC4g19BHFbtESdpFMJ85B+7rsG yxHFLKucAQVJXZrOEq3QBtAm33TzaQgH9AgW89KT3a/9T+jmRIYlfLz+4/GURir840Kw GYaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=MVbk9xJS; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=OON98J3F; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id i37si7897814plb.188.2019.03.12.01.46.19 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 01:46:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=MVbk9xJS; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=OON98J3F; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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=nB6WyYc/vPjFBHB1KEH1e4Uli8n96s+WwDgJQyty90A=; b=MVbk9xJSJHMb8T+CscIylXa6x6 1272UOVhwSXUeSe0n1qeGhkloMMHZc5fVhiUZ6WUKDtvFUe4l7AxvqLHxbDonsRjWdnXY0gntuX0n DjAyLwZuauqTm/MPBJvCGbbiJh6n9Vj88YmBuCnQrpLU0bILE49eviyuqcvW/BM/KGkw9nKYCa9BH CZpmxZSFxEQOoBFfjrNaPjy3Q99R1sDp1VPbK2bTM5UYc123KwTVfbcSwd2zu0bIZ8Tuc+98bJfeJ DOmae0Iw0/na8QnE0BCl3eajqqyTwdRLyDzTeJHKqnqV3md6dmmIIBemx0lVFbV5qY8vo1B7xTV3o U4ojGuAg==; 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 1h3d30-0000a2-DT; Tue, 12 Mar 2019 08:46:06 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3d2e-000079-Ia for linux-mtd@lists.infradead.org; Tue, 12 Mar 2019 08:45:47 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x2C8j6Zi004092; Tue, 12 Mar 2019 17:45:22 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x2C8j6Zi004092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552380322; bh=mQR7r33kBKitXzpLskswUugSgJVShOOSmdtp2U7FsBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OON98J3FEZh2Hac6J3ryrNkBWKlixGE5hrR/QiFztrKdj6rCq9lLwnv26WQIwELj5 BGmAq+P00Gdp2Fp7YytELfpeyjqvVECZ/eriemWyCZUVOjaSCaW8//qPMRRiziOtan UPYNmYa5HvLe1tVAU8jASrOJk98zAonzc2E+SmEyW42APZ/87f/KHlwIgNHa182yIP G8zhl6udnZwEGut/FlYHS4qkYYuskWNtDuVDlH1ztTxGl6gT1/26TEVUYkwCjSDyyw mQWPmGstMSuWR1geG9w4TKfiDskowoZVbBjhROfmpv4/s4NhpnA3LNCb2gVk2QH49M 6YcN6UVsdT9bw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH v3 8/9] mtd: rawnand: denali: remove DENALI_NR_BANKS macro Date: Tue, 12 Mar 2019 17:44:49 +0900 Message-Id: <1552380290-19951-9-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> References: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_014544_990093_B3B97BCA X-CRM114-Status: GOOD ( 10.88 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.76 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Use the runtime-detected denali->nbanks instead of hard-coded DENALI_NR_BANKS (=4). The actual number of banks depends on the IP configuration, and can be less than DENALI_NR_BANKS. It is pointless to touch registers of unsupported banks. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None drivers/mtd/nand/raw/denali.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index 0c47c56..b1a4d9c 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -40,7 +40,6 @@ #define DENALI_BANK(denali) ((denali)->active_bank << 24) #define DENALI_INVALID_BANK -1 -#define DENALI_NR_BANKS 4 static struct denali_chip *to_denali_chip(struct nand_chip *chip) { @@ -92,7 +91,7 @@ static void denali_enable_irq(struct denali_controller *denali) { int i; - for (i = 0; i < DENALI_NR_BANKS; i++) + for (i = 0; i < denali->nbanks; i++) iowrite32(U32_MAX, denali->reg + INTR_EN(i)); iowrite32(GLOBAL_INT_EN_FLAG, denali->reg + GLOBAL_INT_ENABLE); } @@ -101,7 +100,7 @@ static void denali_disable_irq(struct denali_controller *denali) { int i; - for (i = 0; i < DENALI_NR_BANKS; i++) + for (i = 0; i < denali->nbanks; i++) iowrite32(0, denali->reg + INTR_EN(i)); iowrite32(0, denali->reg + GLOBAL_INT_ENABLE); } @@ -117,7 +116,7 @@ static void denali_clear_irq_all(struct denali_controller *denali) { int i; - for (i = 0; i < DENALI_NR_BANKS; i++) + for (i = 0; i < denali->nbanks; i++) denali_clear_irq(denali, i, U32_MAX); } @@ -130,7 +129,7 @@ static irqreturn_t denali_isr(int irq, void *dev_id) spin_lock(&denali->irq_lock); - for (i = 0; i < DENALI_NR_BANKS; i++) { + for (i = 0; i < denali->nbanks; i++) { irq_status = ioread32(denali->reg + INTR_STATUS(i)); if (irq_status) ret = IRQ_HANDLED; From patchwork Tue Mar 12 08:44:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 160060 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp12851155jad; Tue, 12 Mar 2019 01:45:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOVNVuno3z/yxEZDsiulrZ8HrnkFa4MjkrowdI0GgoJE8fxt0PrJv8wAmo7f6iTvFZ8clZ X-Received: by 2002:aa7:811a:: with SMTP id b26mr1432831pfi.250.1552380359949; Tue, 12 Mar 2019 01:45:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552380359; cv=none; d=google.com; s=arc-20160816; b=pg+32CmeZbOWW4AGJbqxIxVnFsuKPZLv6TWnmSB9/0Aj41zujq/FhjeKZEc4sCfVXs ZcFRjbDbYsnnqXr8oqVplp4mV0mNQkHDwUgVVl22WFP51FZ2/+9kaJsiiA3BTCDfBQ2L fsfSNNY9+lPg379yMAiJIdtle/D5CvkSIqhlPkN9doJwAYF9AspUxAbIQ8/kS0Qm8W6o dItFTNygMhSAEOWZ3GOi8TfjRHVO6hRQf0m8RafMiMVRJFnsgxFPrHrRbFDISBUeBjVG f0cdZtJ4alB4ESrqNBJyE3MWvl59suU4TeHOvhaHMdwCA2rg8Nh5ZsivAZAO6t+xSAWj UT8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature; bh=HKFbS+WwpLKi43EPGoBMDbXS4P5175CsANNlyjE6Z04=; b=tbNdZszPYwaIttnSXvmu3eifjv8HSznX2ksI9J8rmGVMh+ffpLSyocD/WosfugZ5Ol sJkTOwCRROoGBaUQ3ETTFHCpUl844JJjuIVTGk8Ka623OJeZ7qTX7IGGt5mv/U5lXC0Y lL+b+yHfIWuyp4r/QhmbKWQTYiF8euDFco3bCDc7/i+6XrWSCGLHYzWIOWEqnz4yoeAp R3wBUnwX1G5cfkWwrZ07UObF1JHCCnE5Ymkr799lZJcqC0lE+DkIYVK1Tx4Oh8R+bf/c 7O1nTEZKO9BKAV3Y00s4MHF6NNbZVhsDQTY6VzlVJNnOSRRWHPVygg2ScMXU4WXzRe/N nT/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=GcAbJQxd; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=FMybTB7o; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id f7si6816949pgo.569.2019.03.12.01.45.59 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 12 Mar 2019 01:45:59 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20170209 header.b=GcAbJQxd; dkim=neutral (body hash did not verify) header.i=@nifty.com header.s=dec2015msa header.b=FMybTB7o; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org" 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=HKFbS+WwpLKi43EPGoBMDbXS4P5175CsANNlyjE6Z04=; b=GcAbJQxddlPBNUPRwTW0WHGcLn jJZ59HsXjbmvdZih3aj0PXS6VzQ8l4c3nYvd911fEE2ri5cE7KeUVBj2IZ82YacT1iNV4I3HGDW3i l0l4nJ+6YdYjGx89txMbHJ02HI4AfHwoJR2bM3zfjtlw3yyv/CA7allNzQeB47O5FF4mGBqvom/uF CnQM87tZGv3nBJqe/WY6cyjq11u4zDJjUGo5i41oD/l00S1PFEbY87TVRKa5qwPwEBKN7TwFdAE6z Hsoz4dw1hmLghS+dx9yKNY9wGLowtOP4NVIazAI/pIA1VyjPN3FDoLkT+SFj9R710soxDbYhlfuPN cwcEA/VA==; 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 1h3d2p-0000J1-M8; Tue, 12 Mar 2019 08:45:55 +0000 Received: from conuserg-09.nifty.com ([210.131.2.76]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h3d2e-000077-Ic for linux-mtd@lists.infradead.org; Tue, 12 Mar 2019 08:45:47 +0000 Received: from pug.e01.socionext.com (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-09.nifty.com with ESMTP id x2C8j6Zj004092; Tue, 12 Mar 2019 17:45:23 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com x2C8j6Zj004092 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1552380323; bh=ShHSByMNYa082jMRN+t65B3dsZw6dbeo+qSq8gXccxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FMybTB7oL9KUvb7i8asFa39iJrF3MtdsxA2lvIaBic9bxfm/uf6CN7EDG92N2aOei y3GP5XeGQnRIA6Beloa9TOBq2V6mzIqsSvC9xJIwdDCewxuEstfQkQ9N7VLrEqshRK 4XQupwVl9N2wb2P351ugQUQsB8xt1iwGHyldYEebDyEfh6Zf/AN1LpEKXdV3SFAv6w /gb2BC3aq6TR5miadPLfaIlNEgZ+8Lpehp0hD8enMETKyGSdQnlROe9JyxMbrpdaRb pkz7ECWF8SEd39gwQ9DrA37MMilYPWxWC1DUJL0UzJ3+rRxJXOs1UAQ8tFiuapbqCQ +ZrH2qmXNpcpw== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-mtd@lists.infradead.org, Miquel Raynal Subject: [PATCH v3 9/9] mtd: rawnand: denali: clean up coding style Date: Tue, 12 Mar 2019 17:44:50 +0900 Message-Id: <1552380290-19951-10-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> References: <1552380290-19951-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190312_014544_932187_B2625440 X-CRM114-Status: GOOD ( 12.81 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.2 on bombadil.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [210.131.2.76 listed in list.dnswl.org] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Masahiro Yamada , Richard Weinberger , Boris Brezillon , linux-kernel@vger.kernel.org, Marek Vasut , Brian Norris , David Woodhouse MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org Eliminate the following reports from 'scripts/checkpatch.pl --strict'. CHECK: Prefer kernel type 'u8' over 'uint8_t' CHECK: Prefer kernel type 'u32' over 'uint32_t' CHECK: Alignment should match open parenthesis I slightly changed denali_check_erased_page() to make it shorter. Signed-off-by: Masahiro Yamada --- Changes in v3: None Changes in v2: None drivers/mtd/nand/raw/denali.c | 53 ++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 28 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c index b1a4d9c..9c30e744 100644 --- a/drivers/mtd/nand/raw/denali.c +++ b/drivers/mtd/nand/raw/denali.c @@ -124,7 +124,7 @@ static irqreturn_t denali_isr(int irq, void *dev_id) { struct denali_controller *denali = dev_id; irqreturn_t ret = IRQ_NONE; - uint32_t irq_status; + u32 irq_status; int i; spin_lock(&denali->irq_lock); @@ -163,7 +163,7 @@ static void denali_reset_irq(struct denali_controller *denali) static u32 denali_wait_for_irq(struct denali_controller *denali, u32 irq_mask) { unsigned long time_left, flags; - uint32_t irq_status; + u32 irq_status; spin_lock_irqsave(&denali->irq_lock, flags); @@ -235,20 +235,17 @@ static int denali_check_erased_page(struct nand_chip *chip, unsigned int max_bitflips) { struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; - uint8_t *ecc_code = chip->oob_poi + denali->oob_skip_bytes; - int ecc_steps = chip->ecc.steps; - int ecc_size = chip->ecc.size; - int ecc_bytes = chip->ecc.bytes; + struct nand_ecc_ctrl *ecc = &chip->ecc; + u8 *ecc_code = chip->oob_poi + denali->oob_skip_bytes; int i, stat; - for (i = 0; i < ecc_steps; i++) { + for (i = 0; i < ecc->steps; i++) { if (!(uncor_ecc_flags & BIT(i))) continue; - stat = nand_check_erased_ecc_chunk(buf, ecc_size, - ecc_code, ecc_bytes, - NULL, 0, - chip->ecc.strength); + stat = nand_check_erased_ecc_chunk(buf, ecc->size, ecc_code, + ecc->bytes, NULL, 0, + ecc->strength); if (stat < 0) { ecc_stats->failed++; } else { @@ -256,8 +253,8 @@ static int denali_check_erased_page(struct nand_chip *chip, max_bitflips = max_t(unsigned int, max_bitflips, stat); } - buf += ecc_size; - ecc_code += ecc_bytes; + buf += ecc->size; + ecc_code += ecc->bytes; } return max_bitflips; @@ -269,7 +266,7 @@ static int denali_hw_ecc_fixup(struct nand_chip *chip, { struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; int bank = denali->active_bank; - uint32_t ecc_cor; + u32 ecc_cor; unsigned int max_bitflips; ecc_cor = ioread32(denali->reg + ECC_COR_INFO(bank)); @@ -300,17 +297,17 @@ static int denali_hw_ecc_fixup(struct nand_chip *chip, static int denali_sw_ecc_fixup(struct nand_chip *chip, struct denali_controller *denali, - unsigned long *uncor_ecc_flags, uint8_t *buf) + unsigned long *uncor_ecc_flags, u8 *buf) { struct mtd_ecc_stats *ecc_stats = &nand_to_mtd(chip)->ecc_stats; unsigned int ecc_size = chip->ecc.size; unsigned int bitflips = 0; unsigned int max_bitflips = 0; - uint32_t err_addr, err_cor_info; + u32 err_addr, err_cor_info; unsigned int err_byte, err_sector, err_device; - uint8_t err_cor_value; + u8 err_cor_value; unsigned int prev_sector = 0; - uint32_t irq_status; + u32 irq_status; denali_reset_irq(denali); @@ -375,7 +372,7 @@ static int denali_sw_ecc_fixup(struct nand_chip *chip, static void denali_setup_dma64(struct denali_controller *denali, dma_addr_t dma_addr, int page, bool write) { - uint32_t mode; + u32 mode; const int page_count = 1; mode = DENALI_MAP10 | DENALI_BANK(denali) | page; @@ -400,7 +397,7 @@ static void denali_setup_dma64(struct denali_controller *denali, static void denali_setup_dma32(struct denali_controller *denali, dma_addr_t dma_addr, int page, bool write) { - uint32_t mode; + u32 mode; const int page_count = 1; mode = DENALI_MAP10 | DENALI_BANK(denali); @@ -425,7 +422,7 @@ static int denali_pio_read(struct denali_controller *denali, u32 *buf, size_t size, int page) { u32 addr = DENALI_MAP01 | DENALI_BANK(denali) | page; - uint32_t irq_status, ecc_err_mask; + u32 irq_status, ecc_err_mask; int i; if (denali->caps & DENALI_CAP_HW_ECC_FIXUP) @@ -452,7 +449,7 @@ static int denali_pio_write(struct denali_controller *denali, const u32 *buf, size_t size, int page) { u32 addr = DENALI_MAP01 | DENALI_BANK(denali) | page; - uint32_t irq_status; + u32 irq_status; int i; denali_reset_irq(denali); @@ -481,7 +478,7 @@ static int denali_dma_xfer(struct denali_controller *denali, void *buf, size_t size, int page, bool write) { dma_addr_t dma_addr; - uint32_t irq_mask, irq_status, ecc_err_mask; + u32 irq_mask, irq_status, ecc_err_mask; enum dma_data_direction dir = write ? DMA_TO_DEVICE : DMA_FROM_DEVICE; int ret = 0; @@ -674,7 +671,7 @@ static int denali_memcpy_in(void *buf, unsigned int offset, unsigned int len, return 0; } -static int denali_read_page_raw(struct nand_chip *chip, uint8_t *buf, +static int denali_read_page_raw(struct nand_chip *chip, u8 *buf, int oob_required, int page) { struct denali_chip *dchip = to_denali_chip(chip); @@ -711,7 +708,7 @@ static int denali_memcpy_out(void *buf, unsigned int offset, unsigned int len, return 0; } -static int denali_write_page_raw(struct nand_chip *chip, const uint8_t *buf, +static int denali_write_page_raw(struct nand_chip *chip, const u8 *buf, int oob_required, int page) { struct denali_chip *dchip = to_denali_chip(chip); @@ -785,7 +782,7 @@ static int denali_write_oob(struct nand_chip *chip, int page) return nand_prog_page_end_op(chip); } -static int denali_read_page(struct nand_chip *chip, uint8_t *buf, +static int denali_read_page(struct nand_chip *chip, u8 *buf, int oob_required, int page) { struct denali_controller *denali = to_denali_controller(chip); @@ -818,7 +815,7 @@ static int denali_read_page(struct nand_chip *chip, uint8_t *buf, return stat; } -static int denali_write_page(struct nand_chip *chip, const uint8_t *buf, +static int denali_write_page(struct nand_chip *chip, const u8 *buf, int oob_required, int page) { struct mtd_info *mtd = nand_to_mtd(chip); @@ -837,7 +834,7 @@ static int denali_setup_data_interface(struct nand_chip *chip, int chipnr, int acc_clks, re_2_we, re_2_re, we_2_re, addr_2_data; int rdwr_en_lo, rdwr_en_hi, rdwr_en_lo_hi, cs_setup; int addr_2_data_mask; - uint32_t tmp; + u32 tmp; timings = nand_get_sdr_timings(conf); if (IS_ERR(timings))