mtd: rawnand: Bunch of cleanup
Subsystems (6)
cover mtd: rawnand: Bunch of cleanup
Hello,
These are just random cleanups that I did while working on the raw NAND API sanitization (see here [1] for a preview of the upcoming changes).
Regards,
Boris
[1]https://github.com/bbrezillon/linux-0day/commits/nand/api-cleanup
Boris Brezillon (8):
mtd: rawnand: Kill cafe_nand_bug()
mtd: rawnand: Remove nand_do_read() prototype from rawnand.h
mtd: rawnand: Remove forward declaration of mtd_info
mtd: rawnand: Remove forward declaration of device_node
mtd: rawnand: Rename nand_default_bbt() into nand_create_bbt()
mtd: rawnand: Kill the chip->scan_bbt() hook
mtd: rawnand: orion_nand: Kill orion_nand_data.dev_ready()
mtd: rawnand: plat_nand: Kill pdata->ctrl.{hwcontrol,read_byte}()
arch/arm/mach-pxa/balloon3.c | 1 - arch/arm/mach-pxa/em-x270.c | 1 - drivers/mtd/nand/raw/cafe_nand.c | 8 -------- drivers/mtd/nand/raw/diskonchip.c | 4 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 4 +--- drivers/mtd/nand/raw/nand_bbt.c | 10 +++++----- drivers/mtd/nand/raw/nandsim.c | 2 +- drivers/mtd/nand/raw/orion_nand.c | 3 --- drivers/mtd/nand/raw/plat_nand.c | 2 -- include/linux/mtd/rawnand.h | 12 ++---------- include/linux/platform_data/mtd-orion_nand.h | 1 - 12 files changed, 12 insertions(+), 38 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/8 mtd: rawnand: Kill cafe_nand_bug()
Leaving a function pointer to NULL should be enough to trigger a NULL pointer exception, and anyway, if we want to BUG() when some missing hooks are called, this should be done in the core, so let's drop the cafe_nand_bug() dummy function.
--- drivers/mtd/nand/raw/cafe_nand.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/mtd/nand/raw/cafe_nand.c +0 -8
@@ -345,11 +345,6 @@ static irqreturn_t cafe_nand_interrupt(int irq, void *id)return IRQ_HANDLED ; } -static void cafe_nand_bug (struct mtd_info *mtd) -{ -BUG (); -} -static int cafe_nand_write_oob (struct mtd_info *mtd,struct nand_chip *chip,int page) {
@@ -760,9 +755,6 @@ static int cafe_nand_probe(struct pci_dev *pdev, cafe->nand.ecc.size = mtd->writesize; cafe->nand.ecc.bytes =14 ; cafe->nand.ecc.strength =4 ; - cafe->nand.ecc.hwctl = (void *)cafe_nand_bug; - cafe->nand.ecc.calculate = (void *)cafe_nand_bug; - cafe->nand.ecc.correct = (void *)cafe_nand_bug; cafe->nand.ecc.write_page = cafe_nand_write_page_lowlevel; cafe->nand.ecc.write_oob = cafe_nand_write_oob; cafe->nand.ecc.read_page = cafe_nand_read_page;
Signature · 1 line
2.14.1
PATCH 2/8 mtd: rawnand: Remove nand_do_read() prototype from rawnand.h
In reply to Boris Brezillonnand_do_read() is a static function implemented in nand_base.c. There's no good reason to expose its prototype in rawnand.h.
--- include/linux/mtd/rawnand.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/mtd/rawnand.h +0 -2
@@ -1545,8 +1545,6 @@ int nand_isreserved_bbt(struct mtd_info *mtd, loff_t offs);int nand_isbad_bbt (struct mtd_info *mtd,loff_t offs,int allowbbt);int nand_erase_nand (struct mtd_info *mtd,struct erase_info *instr,int allowbbt); -int nand_do_read (struct mtd_info *mtd,loff_t from,size_t len, -size_t *retlen,uint8_t *buf);/** * struct platform_nand_chip - chip level device structure
Signature · 1 line
2.14.1
PATCH 3/8 mtd: rawnand: Remove forward declaration of mtd_info
In reply to Boris Brezillonstruct mtd_info is defined in linux/mtd/mtd.h which is included at the beginning of nand_base.c, there's thus no need for the forward declaration of mtd_info.
--- include/linux/mtd/rawnand.h | 1 - 1 file changed, 1 deletion(-)
include/linux/mtd/rawnand.h +0 -1
@@ -23,7 +23,6 @@#include <linux/mtd/bbm.h> #include <linux/types.h> -struct mtd_info ;struct nand_flash_dev ;struct device_node ;
Signature · 1 line
2.14.1
PATCH 4/8 mtd: rawnand: Remove forward declaration of device_node
In reply to Boris Brezillonstruct device_node is defined in linux/of.h. Let's include this file instead of having a forward declaration of this struct.
--- include/linux/mtd/rawnand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mtd/rawnand.h +1 -1
@@ -21,10 +21,10 @@#include <linux/mtd/mtd.h> #include <linux/mtd/flashchip.h> #include <linux/mtd/bbm.h> +#include <linux/of.h> #include <linux/types.h> struct nand_flash_dev ; -struct device_node ;/* Scan and identify a NAND device */ int nand_scan_with_ids(struct mtd_info *mtd, int max_chips,
Signature · 1 line
2.14.1
PATCH 5/8 mtd: rawnand: Rename nand_default_bbt() into nand_create_bbt()
In reply to Boris BrezillonRename nand_default_bbt() into nand_create_bbt() and pass it a nand_chip object to prepare removal of the chip->scan_bbt() hook.
We add a temporary nand_default_bbt() wrapper which will be dropped after the removal of ->scan_bbt().
--- drivers/mtd/nand/raw/nand_base.c | 5 +++++ drivers/mtd/nand/raw/nand_bbt.c | 10 +++++----- include/linux/mtd/rawnand.h | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-)
drivers/mtd/nand/raw/nand_base.c +5 -0
@@ -4924,6 +4924,11 @@ static void nand_shutdown(struct mtd_info *mtd)nand_get_device (mtd,FL_PM_SUSPENDED ); } +static int nand_default_bbt (struct mtd_info *mtd) +{ +return nand_create_bbt (mtd_to_nand (mtd)); +} +/* Set default functions */ static void nand_set_defaults (struct nand_chip *chip) {
drivers/mtd/nand/raw/nand_bbt.c +5 -5
@@ -1349,15 +1349,14 @@ static int nand_create_badblock_pattern(struct nand_chip *this) }/** -* nand_default_bbt - [NAND Interface] Select a default bad block table for the device -* @mtd: MTD device structure +* nand_create_bbt - [NAND Interface] Select a default bad block table for the device +* @this: NAND chip object * * This function selects the default bad block table support for the device and * calls the nand_scan_bbt function. */ -int nand_default_bbt (struct mtd_info *mtd) +int nand_create_bbt (struct nand_chip *this) { -struct nand_chip *this =mtd_to_nand (mtd);int ret;/* Is a flash based bad block table requested? */
@@ -1383,8 +1382,9 @@ int nand_default_bbt(struct mtd_info *mtd)return ret; } -return nand_scan_bbt (mtd, this->badblock_pattern); +return nand_scan_bbt (nand_to_mtd (this), this->badblock_pattern); } +EXPORT_SYMBOL (nand_create_bbt);/** * nand_isreserved_bbt - [NAND Interface] Check if a block is reserved
include/linux/mtd/rawnand.h +1 -1
@@ -1538,7 +1538,7 @@ extern const struct nand_manufacturer_ops micron_nand_manuf_ops;extern const struct nand_manufacturer_ops amd_nand_manuf_ops;extern const struct nand_manufacturer_ops macronix_nand_manuf_ops; -int nand_default_bbt (struct mtd_info *mtd); +int nand_create_bbt (struct nand_chip *chip);int nand_markbad_bbt (struct mtd_info *mtd,loff_t offs);int nand_isreserved_bbt (struct mtd_info *mtd,loff_t offs);int nand_isbad_bbt (struct mtd_info *mtd,loff_t offs,int allowbbt);
Signature · 1 line
2.14.1
PATCH 6/8 mtd: rawnand: Kill the chip->scan_bbt() hook
In reply to Boris BrezillonNone of the existing drivers are overloading the ->scan_bbt() method, let's get rid of it and replace calls to ->scan_bbt() by nand_create_bbt() ones.
--- drivers/mtd/nand/raw/diskonchip.c | 4 ++-- drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c | 2 +- drivers/mtd/nand/raw/nand_base.c | 9 +-------- drivers/mtd/nand/raw/nandsim.c | 2 +- include/linux/mtd/rawnand.h | 1 - 5 files changed, 5 insertions(+), 13 deletions(-)
drivers/mtd/nand/raw/diskonchip.c +2 -2
@@ -1291,7 +1291,7 @@ static int __init nftl_scan_bbt(struct mtd_info *mtd) this->bbt_md =NULL ; } - ret = this->scan_bbt (mtd); + ret =nand_create_bbt (this);if (ret)return ret;
@@ -1338,7 +1338,7 @@ static int __init inftl_scan_bbt(struct mtd_info *mtd) this->bbt_md->pattern ="TBB_SYSM" ; } - ret = this->scan_bbt (mtd); + ret =nand_create_bbt (this);if (ret)return ret;
drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c +1 -1
@@ -1947,7 +1947,7 @@ static int gpmi_nand_init(struct gpmi_nand_data *this) ret =nand_boot_init (this);if (ret) goto err_nand_cleanup; - ret = chip->scan_bbt (mtd); + ret =nand_create_bbt (chip);if (ret) goto err_nand_cleanup;
drivers/mtd/nand/raw/nand_base.c +1 -8
@@ -4924,11 +4924,6 @@ static void nand_shutdown(struct mtd_info *mtd)nand_get_device (mtd,FL_PM_SUSPENDED ); } -static int nand_default_bbt (struct mtd_info *mtd) -{ -return nand_create_bbt (mtd_to_nand (mtd)); -} -/* Set default functions */ static void nand_set_defaults (struct nand_chip *chip) {
@@ -4970,8 +4965,6 @@ static void nand_set_defaults(struct nand_chip *chip) chip->write_byte = busw ? nand_write_byte16 : nand_write_byte;if (!chip->read_buf || chip->read_buf == nand_read_buf) chip->read_buf = busw ? nand_read_buf16 : nand_read_buf; -if (!chip->scan_bbt) - chip->scan_bbt = nand_default_bbt;if (!chip->controller) { chip->controller = &chip->hwcontrol;
@@ -6673,7 +6666,7 @@ int nand_scan_tail(struct mtd_info *mtd)return 0 ;/* Build bad block table */ - ret = chip->scan_bbt (mtd); + ret =nand_create_bbt (chip);if (ret) goto err_nand_manuf_cleanup;
drivers/mtd/nand/raw/nandsim.c +1 -1
@@ -2337,7 +2337,7 @@ static int __init ns_init_module(void)if ((retval =init_nandsim (nsmtd)) !=0 ) goto err_exit; -if ((retval = chip->scan_bbt (nsmtd)) !=0 ) +if ((retval =nand_create_bbt (chip)) !=0 ) goto err_exit;if ((retval =parse_badblocks (nand, nsmtd)) !=0 )
include/linux/mtd/rawnand.h +0 -1
@@ -1292,7 +1292,6 @@ struct nand_chip {const struct nand_operation *op, bool check_only);int (*erase)(struct mtd_info *mtd,int page); -int (*scan_bbt)(struct mtd_info *mtd);int (*set_features)(struct mtd_info *mtd,struct nand_chip *chip,int feature_addr,uint8_t *subfeature_para); int (*get_features)(struct mtd_info *mtd, struct nand_chip *chip,
Signature · 1 line
2.14.1
PATCH 7/8 mtd: rawnand: orion_nand: Kill orion_nand_data.dev_ready()
In reply to Boris BrezillonNone of the boards seem to overload the ->dev_ready() hook, just drop this field from orion_nand_data.
--- drivers/mtd/nand/raw/orion_nand.c | 3 --- include/linux/platform_data/mtd-orion_nand.h | 1 - 2 files changed, 4 deletions(-)
drivers/mtd/nand/raw/orion_nand.c +0 -3
@@ -153,9 +153,6 @@ static int __init orion_nand_probe(struct platform_device *pdev)if (board->width ==16 ) nc->options |=NAND_BUSWIDTH_16 ; -if (board->dev_ready) - nc->dev_ready = board->dev_ready; -platform_set_drvdata (pdev, info);/* Not all platforms can gate the clock, so it is not
include/linux/platform_data/mtd-orion_nand.h +0 -1
@@ -12,7 +12,6 @@*/ struct orion_nand_data {struct mtd_partition *parts; -int (*dev_ready)(struct mtd_info *mtd);u32 nr_parts;u8 ale;/* address line number connected to ALE */ u8 cle;/* address line number connected to CLE */
Signature · 1 line
2.14.1
PATCH 8/8 mtd: rawnand: plat_nand: Kill pdata->ctrl.{hwcontrol, read_byte}()
In reply to Boris BrezillonNone of the board files are overloading those hooks, so let's drop them from struct platform_nand_ctrl.
--- arch/arm/mach-pxa/balloon3.c | 1 - arch/arm/mach-pxa/em-x270.c | 1 - drivers/mtd/nand/raw/plat_nand.c | 2 -- include/linux/mtd/rawnand.h | 4 ---- 4 files changed, 8 deletions(-)
arch/arm/mach-pxa/balloon3.c +0 -1
@@ -688,7 +688,6 @@ struct platform_nand_data balloon3_nand_pdata = { .chip_delay = 50, }, .ctrl = { - .hwcontrol = 0, .dev_ready = balloon3_nand_dev_ready, .select_chip = balloon3_nand_select_chip, .cmd_ctrl = balloon3_nand_cmd_ctl,
arch/arm/mach-pxa/em-x270.c +0 -1
@@ -346,7 +346,6 @@ struct platform_nand_data em_x270_nand_platdata = { .chip_delay = 20, }, .ctrl = { - .hwcontrol = 0, .dev_ready = em_x270_nand_device_ready, .select_chip = 0, .cmd_ctrl = em_x270_nand_cmd_ctl,
drivers/mtd/nand/raw/plat_nand.c +0 -2
@@ -67,12 +67,10 @@ static int plat_nand_probe(struct platform_device *pdev) data->chip.select_chip = pdata->ctrl.select_chip; data->chip.write_buf = pdata->ctrl.write_buf; data->chip.read_buf = pdata->ctrl.read_buf; - data->chip.read_byte = pdata->ctrl.read_byte; data->chip.chip_delay = pdata->chip.chip_delay; data->chip.options |= pdata->chip.options; data->chip.bbt_options |= pdata->chip.bbt_options; - data->chip.ecc.hwctl = pdata->ctrl.hwcontrol; data->chip.ecc.mode =NAND_ECC_SOFT ; data->chip.ecc.algo =NAND_ECC_HAMMING ;
include/linux/mtd/rawnand.h +0 -4
@@ -1573,14 +1573,12 @@ struct platform_device;* struct platform_nand_ctrl - controller level device structure * @probe: platform specific function to probe/setup hardware * @remove: platform specific function to remove/teardown hardware -* @hwcontrol: platform specific hardware control structure * @dev_ready: platform specific function to read ready/busy pin * @select_chip: platform specific chip select function * @cmd_ctrl: platform specific function for controlling * ALE/CLE/nCE. Also used to write command and address * @write_buf: platform specific function for write buffer * @read_buf: platform specific function for read buffer -* @read_byte: platform specific function to read one byte from chip * @priv: private data to transport driver specific settings * * All fields are optional and depend on the hardware driver requirements
@@ -1588,13 +1586,11 @@ struct platform_device;struct platform_nand_ctrl {int (*probe)(struct platform_device *pdev);void (*remove)(struct platform_device *pdev); -void (*hwcontrol)(struct mtd_info *mtd,int cmd);int (*dev_ready)(struct mtd_info *mtd);void (*select_chip)(struct mtd_info *mtd,int chip);void (*cmd_ctrl)(struct mtd_info *mtd,int dat,unsigned int ctrl);void (*write_buf)(struct mtd_info *mtd,const uint8_t *buf,int len);void (*read_buf)(struct mtd_info *mtd,uint8_t *buf,int len); -unsigned char (*read_byte)(struct mtd_info *mtd);void *priv; };
Signature · 1 line
2.14.1
Robert Jarzmik
maintainerPATCH 8/8 mtd: rawnand: plat_nand: Kill pdata->ctrl.{hwcontrol, read_byte}()
Quoted 4 lines · Boris Brezillon
None of the board files are overloading those hooks, so let's drop them from struct
platform_nand_ctrl.Signed-off-by Boris Brezillon <[email protected]>
For mach-pxa :
Cheers.
--
Robert
Miquel Raynal
maintainercover mtd: rawnand: Bunch of cleanup
In reply to Boris BrezillonHi Boris,
Boris Brezillon <[email protected]> wrote on Thu, 5 Jul 2018 12:27:25 +0200:
Quoted 11 lines
Hello,
These are just random cleanups that I did while working on the raw NAND API sanitization (see here [1] for a preview of the upcoming changes).
Regards,
Boris
[1]https://github.com/bbrezillon/linux-0day/commits/nand/api-cleanup
Quoted 10 lines
Boris Brezillon (8):
mtd: rawnand: Killcafe_nand_bug()
mtd: rawnand: Removenand_do_read()prototype fromrawnand.h
mtd: rawnand: Remove forward declaration ofmtd_info
mtd: rawnand: Remove forward declaration ofdevice_node
mtd: rawnand: Renamenand_default_bbt()intonand_create_bbt()
mtd: rawnand: Kill thechip->scan_bbt()hook
mtd: rawnand:orion_nand: Killorion_nand_data.dev_ready()
mtd: rawnand:plat_nand: Kill pdata->ctrl.{hwcontrol,read_byte}()
Series applied to nand/next,
Thanks,
Miqu?l