From: Boris Brezillon <boris.brezillon@bootlin.com>
To: Boris Brezillon <boris.brezillon@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Miquel Raynal <miquel.raynal@bootlin.com>,
linux-mtd@lists.infradead.org
Cc: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
Marek Vasut <marek.vasut@gmail.com>,
Jonathan Corbet <corbet@lwn.net>,
linux-doc@vger.kernel.org,
Hartley Sweeten <hsweeten@visionengravers.com>,
Ryan Mallon <rmallon@gmail.com>,
Alexander Shiyan <shc_work@mail.ru>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <kernel@pengutronix.de>,
Fabio Estevam <fabio.estevam@nxp.com>,
NXP Linux Team <linux-imx@nxp.com>,
Imre Kaloz <kaloz@openwrt.org>,
Krzysztof Halasa <khalasa@piap.pl>,
Tony Lindgren <tony@atomide.com>,
linux-omap@vger.kernel.org,
Alexander Clouter <alex@digriz.org.uk>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Gregory CLEMENT <gregory.clement@bootlin.com>,
Jason Cooper <jason@lakedaemon.net>,
Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>,
Andrew Lunn <andrew@lunn.ch>, Daniel Mack <daniel@zonque.org>,
Haojian Zhuang <haojian.zhuang@gmail.com>,
Robert Jarzmik <robert.jarzmik@free.fr>,
Ralf Baechle <ralf@linux-mips.org>,
linux-mips@linux-mips.org,
Yoshinori Sato <ysato@users.sourceforge.jp>,
Rich Felker <dalias@libc.org>,
linux-sh@vger.kernel.org,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
devel@driverdev.osuosl.org
Subject: [PATCH 07/19] mtd: rawnand: Deprecate ->erase()
Date: Fri, 7 Sep 2018 00:38:39 +0200 [thread overview]
Message-ID: <20180906223851.6964-8-boris.brezillon@bootlin.com> (raw)
In-Reply-To: <20180906223851.6964-1-boris.brezillon@bootlin.com>
The ->erase() hook have been overloaded by some drivers for bad reasons:
either the driver was not fitting in the NAND framework and should have
been an MTD driver (docg4), or the driver uses a specific path for the
ERASE operation (denali), instead of implementing it generically.
In any case, we should discourage people from overloading this method
and encourage them to implement ->exec_op() instead.
Move the ->erase() hook to the nand_legacy struct to make it clear.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
---
drivers/mtd/nand/raw/denali.c | 2 +-
drivers/mtd/nand/raw/nand_base.c | 7 +++++--
include/linux/mtd/rawnand.h | 4 ++--
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c
index c14493ef6126..858358027dc9 100644
--- a/drivers/mtd/nand/raw/denali.c
+++ b/drivers/mtd/nand/raw/denali.c
@@ -1275,7 +1275,7 @@ static int denali_attach_chip(struct nand_chip *chip)
chip->ecc.write_page_raw = denali_write_page_raw;
chip->ecc.read_oob = denali_read_oob;
chip->ecc.write_oob = denali_write_oob;
- chip->erase = denali_erase;
+ chip->legacy.erase = denali_erase;
ret = denali_multidev_fixup(denali);
if (ret)
diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c
index d71a3d303903..57c89e275a3a 100644
--- a/drivers/mtd/nand/raw/nand_base.c
+++ b/drivers/mtd/nand/raw/nand_base.c
@@ -4730,7 +4730,11 @@ int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr,
(page + pages_per_block))
chip->pagebuf = -1;
- status = chip->erase(chip, page & chip->pagemask);
+ if (chip->legacy.erase)
+ status = chip->legacy.erase(chip,
+ page & chip->pagemask);
+ else
+ status = single_erase(chip, page & chip->pagemask);
/* See if block erase succeeded */
if (status) {
@@ -5756,7 +5760,6 @@ static int nand_detect(struct nand_chip *chip, struct nand_flash_dev *type)
chip->options |= NAND_ROW_ADDR_3;
chip->badblockbits = 8;
- chip->erase = single_erase;
/* Do not replace user supplied command function! */
if (mtd->writesize > 512 && chip->legacy.cmdfunc == nand_command)
diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h
index aa3e931d0206..97c6ff7d127e 100644
--- a/include/linux/mtd/rawnand.h
+++ b/include/linux/mtd/rawnand.h
@@ -1189,6 +1189,7 @@ int nand_op_parser_exec_op(struct nand_chip *chip,
* @waitfunc: hardware specific function for wait on ready.
* @block_bad: check if a block is bad, using OOB markers
* @block_markbad: mark a block bad
+ * @erase: erase function
*
* If you look at this structure you're already wrong. These fields/hooks are
* all deprecated.
@@ -1207,6 +1208,7 @@ struct nand_legacy {
int (*waitfunc)(struct nand_chip *chip);
int (*block_bad)(struct nand_chip *chip, loff_t ofs);
int (*block_markbad)(struct nand_chip *chip, loff_t ofs);
+ int (*erase)(struct nand_chip *chip, int page);
};
/**
@@ -1228,7 +1230,6 @@ struct nand_legacy {
* @buf_align: minimum buffer alignment required by a platform
* @dummy_controller: dummy controller implementation for drivers that can
* only control a single chip
- * @erase: [REPLACEABLE] erase function
* @chip_delay: [BOARDSPECIFIC] chip dependent delay for transferring
* data from array to read regs (tR).
* @state: [INTERN] the current state of the NAND device
@@ -1308,7 +1309,6 @@ struct nand_chip {
int (*exec_op)(struct nand_chip *chip,
const struct nand_operation *op,
bool check_only);
- int (*erase)(struct nand_chip *chip, int page);
int (*set_features)(struct nand_chip *chip, int feature_addr,
uint8_t *subfeature_para);
int (*get_features)(struct nand_chip *chip, int feature_addr,
--
2.14.1
next prev parent reply other threads:[~2018-09-06 22:39 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-06 22:38 [PATCH 00/19] mtd: rawnand: API cleanup (2nd batch) Boris Brezillon
2018-09-06 22:38 ` [PATCH 01/19] mtd: rawnand: Leave chip->IO_ADDR_{R,W} to NULL when unused Boris Brezillon
2018-09-06 22:38 ` [PATCH 02/19] mtd: rawnand: Create a legacy struct and move ->IO_ADDR_{R,W} there Boris Brezillon
2018-09-06 22:38 ` [PATCH 03/19] mtd: rawnand: Deprecate ->{read,write}_{byte,buf}() hooks Boris Brezillon
2018-09-06 22:38 ` [PATCH 04/19] mtd: rawnand: Deprecate ->cmd_ctrl() and ->cmdfunc() Boris Brezillon
2018-09-06 22:38 ` [PATCH 05/19] mtd: rawnand: Deprecate ->dev_ready() and ->waitfunc() Boris Brezillon
2018-09-06 22:38 ` [PATCH 06/19] mtd: rawnand: Deprecate ->block_{bad,markbad}() hooks Boris Brezillon
2018-09-06 22:38 ` Boris Brezillon [this message]
2018-09-06 22:38 ` [PATCH 08/19] mtd: rawnand: Deprecate ->{set,get}_features() hooks Boris Brezillon
2018-09-06 22:38 ` [PATCH 09/19] mtd: rawnand: Deprecate ->chip_delay Boris Brezillon
2018-09-06 22:38 ` [PATCH 10/19] mtd: rawnand: Move function prototypes after struct declarations Boris Brezillon
2018-09-06 22:38 ` [PATCH 11/19] mtd: rawnand: Get rid of nand_flash_dev forward declation Boris Brezillon
2018-09-06 22:38 ` [PATCH 12/19] mtd: rawnand: Get rid of the duplicate nand_chip forward declaration Boris Brezillon
2018-09-06 22:38 ` [PATCH 13/19] mtd: rawnand: Get rid of a few unused definitions Boris Brezillon
2018-09-06 22:38 ` [PATCH 14/19] mtd: rawnand: Move platform_nand_xxx definitions out of rawnand.h Boris Brezillon
2018-09-06 22:38 ` [PATCH 15/19] mtd: rawnand: Inline onfi_get_async_timing_mode() Boris Brezillon
2018-09-06 22:38 ` [PATCH 16/19] mtd: rawnand: Keep all internal stuff private Boris Brezillon
2018-09-06 22:38 ` [PATCH 17/19] mtd: rawnand: Move legacy code to nand_legacy.c Boris Brezillon
2018-09-06 22:38 ` [PATCH 18/19] mtd: rawnand: Move ONFI code to nand_onfi.c Boris Brezillon
2018-09-06 22:38 ` [PATCH 19/19] mtd: rawnand: Move JEDEC code to nand_jedec.c Boris Brezillon
2018-09-07 8:40 ` Ladislav Michl
2018-09-07 9:13 ` Boris Brezillon
2018-09-15 17:54 ` [PATCH 00/19] mtd: rawnand: API cleanup (2nd batch) Miquel Raynal
2018-09-17 8:29 ` Boris Brezillon
2018-09-19 21:25 ` Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180906223851.6964-8-boris.brezillon@bootlin.com \
--to=boris.brezillon@bootlin.com \
--cc=alex@digriz.org.uk \
--cc=andrew@lunn.ch \
--cc=computersforpeace@gmail.com \
--cc=corbet@lwn.net \
--cc=dalias@libc.org \
--cc=daniel@zonque.org \
--cc=devel@driverdev.osuosl.org \
--cc=dwmw2@infradead.org \
--cc=fabio.estevam@nxp.com \
--cc=gregkh@linuxfoundation.org \
--cc=gregory.clement@bootlin.com \
--cc=haojian.zhuang@gmail.com \
--cc=hsweeten@visionengravers.com \
--cc=jason@lakedaemon.net \
--cc=kaloz@openwrt.org \
--cc=kernel@pengutronix.de \
--cc=khalasa@piap.pl \
--cc=linux-doc@vger.kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-mips@linux-mips.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=marek.vasut@gmail.com \
--cc=miquel.raynal@bootlin.com \
--cc=ralf@linux-mips.org \
--cc=richard@nod.at \
--cc=rmallon@gmail.com \
--cc=robert.jarzmik@free.fr \
--cc=sebastian.hesselbarth@gmail.com \
--cc=shawnguo@kernel.org \
--cc=shc_work@mail.ru \
--cc=thomas.petazzoni@bootlin.com \
--cc=tony@atomide.com \
--cc=ysato@users.sourceforge.jp \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).