* [PATCH 01/12] nand: docg4: use nand_base's default BBT scan
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-05 20:09 ` Mike Dunn
2013-09-04 18:25 ` [PATCH 02/12] mtd: nand: lpc32xx_slc: don't call nand_default_bbt directly Brian Norris
` (11 subsequent siblings)
12 siblings, 1 reply; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
There's no point in the low level driver doing the work that nand_base
already is doing; just let nand_base set the default BBT scanning
function.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/docg4.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index 548db23..7c38b8a 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -1239,7 +1239,6 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
nand->block_markbad = docg4_block_markbad;
nand->read_buf = docg4_read_buf;
nand->write_buf = docg4_write_buf16;
- nand->scan_bbt = nand_default_bbt;
nand->erase_cmd = docg4_erase_block;
nand->ecc.read_page = docg4_read_page;
nand->ecc.write_page = docg4_write_page;
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 01/12] nand: docg4: use nand_base's default BBT scan
2013-09-04 18:25 ` [PATCH 01/12] nand: docg4: use nand_base's default BBT scan Brian Norris
@ 2013-09-05 20:09 ` Mike Dunn
0 siblings, 0 replies; 18+ messages in thread
From: Mike Dunn @ 2013-09-05 20:09 UTC (permalink / raw)
To: Brian Norris; +Cc: linux-mtd
On 09/04/2013 11:25 AM, Brian Norris wrote:
> There's no point in the low level driver doing the work that nand_base
> already is doing; just let nand_base set the default BBT scanning
> function.
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> ---
> drivers/mtd/nand/docg4.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
> index 548db23..7c38b8a 100644
> --- a/drivers/mtd/nand/docg4.c
> +++ b/drivers/mtd/nand/docg4.c
> @@ -1239,7 +1239,6 @@ static void __init init_mtd_structs(struct mtd_info *mtd)
> nand->block_markbad = docg4_block_markbad;
> nand->read_buf = docg4_read_buf;
> nand->write_buf = docg4_write_buf16;
> - nand->scan_bbt = nand_default_bbt;
> nand->erase_cmd = docg4_erase_block;
> nand->ecc.read_page = docg4_read_page;
> nand->ecc.write_page = docg4_write_page;
>
Acked-by: Mike Dunn <mikedunn@newsguy.com>
Not sure why I explicitly set that. Thanks!
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 02/12] mtd: nand: lpc32xx_slc: don't call nand_default_bbt directly
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
2013-09-04 18:25 ` [PATCH 01/12] nand: docg4: use nand_base's default BBT scan Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 03/12] mtd: nandsim: don't call nand_default_bbt() directly Brian Norris
` (10 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
This driver is doing some strange logic here. If it doesn't have
flash-based BBT enabled, it allows nand_scan_tail() to scan the BBT. But
if it is using flash-based BBT, it tells nand_scan_tail() to skip
scanning, then it immediately calls the default BBT scanning function
itself.
As I read it, this logic is equivalent to the default nand_scan_tail()
behavior without interfering with NAND_SKIP_BBTSCAN or calling
nand_default_bbt() directly at all.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/lpc32xx_slc.c | 8 --------
1 file changed, 8 deletions(-)
diff --git a/drivers/mtd/nand/lpc32xx_slc.c b/drivers/mtd/nand/lpc32xx_slc.c
index add7570..6d5f8c5 100644
--- a/drivers/mtd/nand/lpc32xx_slc.c
+++ b/drivers/mtd/nand/lpc32xx_slc.c
@@ -893,7 +893,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
/* Avoid extra scan if using BBT, setup BBT support */
if (host->ncfg->use_bbt) {
- chip->options |= NAND_SKIP_BBTSCAN;
chip->bbt_options |= NAND_BBT_USE_FLASH;
/*
@@ -915,13 +914,6 @@ static int lpc32xx_nand_probe(struct platform_device *pdev)
goto err_exit3;
}
- /* Standard layout in FLASH for bad block tables */
- if (host->ncfg->use_bbt) {
- if (nand_default_bbt(mtd) < 0)
- dev_err(&pdev->dev,
- "Error initializing default bad block tables\n");
- }
-
mtd->name = "nxp_lpc3220_slc";
ppdata.of_node = pdev->dev.of_node;
res = mtd_device_parse_register(mtd, NULL, &ppdata, host->ncfg->parts,
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 03/12] mtd: nandsim: don't call nand_default_bbt() directly
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
2013-09-04 18:25 ` [PATCH 01/12] nand: docg4: use nand_base's default BBT scan Brian Norris
2013-09-04 18:25 ` [PATCH 02/12] mtd: nand: lpc32xx_slc: don't call nand_default_bbt directly Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 04/12] mtd: nand: stop exporting nand_default_bbt Brian Norris
` (9 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
We want the default nand_chip.scan_bbt() function, so just use the
proper indirection.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/nandsim.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
index bdc1d15..fdcc5bd 100644
--- a/drivers/mtd/nand/nandsim.c
+++ b/drivers/mtd/nand/nandsim.c
@@ -2372,7 +2372,7 @@ static int __init ns_init_module(void)
if ((retval = init_nandsim(nsmtd)) != 0)
goto err_exit;
- if ((retval = nand_default_bbt(nsmtd)) != 0)
+ if ((retval = chip->scan_bbt(nsmtd)) != 0)
goto err_exit;
if ((retval = parse_badblocks(nand, nsmtd)) != 0)
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 04/12] mtd: nand: stop exporting nand_default_bbt
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (2 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 03/12] mtd: nandsim: don't call nand_default_bbt() directly Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 05/12] mtd: dataflash: remove unused field Brian Norris
` (8 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
I removed the last non-nand_base users of this, and we shouldn't have
any more modules that need to access it. It's only non-static to share
between nand_base and nand_bbt.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/nand_bbt.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c
index bc06196..c75b6a7 100644
--- a/drivers/mtd/nand/nand_bbt.c
+++ b/drivers/mtd/nand/nand_bbt.c
@@ -1392,4 +1392,3 @@ int nand_markbad_bbt(struct mtd_info *mtd, loff_t offs)
}
EXPORT_SYMBOL(nand_scan_bbt);
-EXPORT_SYMBOL(nand_default_bbt);
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 05/12] mtd: dataflash: remove unused field
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (3 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 04/12] mtd: nand: stop exporting nand_default_bbt Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 06/12] mtd: denali: make init function static Brian Norris
` (7 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: David Brownell, Brian Norris
struct dataflash's 'partition' field is unused. Just remove it.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: David Brownell <david-b@pacbell.net>
---
drivers/mtd/devices/mtd_dataflash.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/drivers/mtd/devices/mtd_dataflash.c b/drivers/mtd/devices/mtd_dataflash.c
index 0e8cbfe..1cfbfcf 100644
--- a/drivers/mtd/devices/mtd_dataflash.c
+++ b/drivers/mtd/devices/mtd_dataflash.c
@@ -88,8 +88,6 @@ struct dataflash {
uint8_t command[4];
char name[24];
- unsigned partitioned:1;
-
unsigned short page_offset; /* offset in flash address */
unsigned int page_size; /* of bytes per page */
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 06/12] mtd: denali: make init function static
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (4 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 05/12] mtd: dataflash: remove unused field Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 07/12] mtd: nand: return failure when failing to get ECC from ONFI Brian Norris
` (6 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
It's only used in this file.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/denali.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
index 2ed2bb3..154b033 100644
--- a/drivers/mtd/nand/denali.c
+++ b/drivers/mtd/nand/denali.c
@@ -1394,7 +1394,7 @@ static struct nand_bbt_descr bbt_mirror_descr = {
};
/* initialize driver data structures */
-void denali_drv_init(struct denali_nand_info *denali)
+static void denali_drv_init(struct denali_nand_info *denali)
{
denali->idx = 0;
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 07/12] mtd: nand: return failure when failing to get ECC from ONFI
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (5 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 06/12] mtd: denali: make init function static Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-05 2:34 ` Huang Shijie
2013-09-04 18:25 ` [PATCH 08/12] mtd: nand: don't print ONFI buswidth errors unless we need to Brian Norris
` (5 subsequent siblings)
12 siblings, 1 reply; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Huang Shijie, Brian Norris
If ONFI fails to provide ECC information, we should not use it. Print
appropriate error messages and return.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Huang Shijie <b32955@freescale.com>
---
drivers/mtd/nand/nand_base.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 7ed4841..38b8dd4 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -3010,8 +3010,13 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
chip->cmdfunc = nand_command_lp;
/* The Extended Parameter Page is supported since ONFI 2.1. */
- if (nand_flash_detect_ext_param_page(mtd, chip, p))
- pr_info("Failed to detect the extended param page.\n");
+ if (nand_flash_detect_ext_param_page(mtd, chip, p)) {
+ pr_info("Failed to detect ONFI extended param page\n");
+ return 0;
+ }
+ } else {
+ pr_err("Could not retrieve ONFI ECC requirements\n");
+ return 0;
}
pr_info("ONFI flash detected\n");
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 07/12] mtd: nand: return failure when failing to get ECC from ONFI
2013-09-04 18:25 ` [PATCH 07/12] mtd: nand: return failure when failing to get ECC from ONFI Brian Norris
@ 2013-09-05 2:34 ` Huang Shijie
2013-09-11 21:43 ` Brian Norris
0 siblings, 1 reply; 18+ messages in thread
From: Huang Shijie @ 2013-09-05 2:34 UTC (permalink / raw)
To: Brian Norris; +Cc: linux-mtd
于 2013年09月05日 02:25, Brian Norris 写道:
> If ONFI fails to provide ECC information, we should not use it. Print
> appropriate error messages and return.
>
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> Cc: Huang Shijie <b32955@freescale.com>
> ---
> drivers/mtd/nand/nand_base.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index 7ed4841..38b8dd4 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3010,8 +3010,13 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
> chip->cmdfunc = nand_command_lp;
>
> /* The Extended Parameter Page is supported since ONFI 2.1. */
> - if (nand_flash_detect_ext_param_page(mtd, chip, p))
> - pr_info("Failed to detect the extended param page.\n");
> + if (nand_flash_detect_ext_param_page(mtd, chip, p)) {
> + pr_info("Failed to detect ONFI extended param page\n");
> + return 0;
> + }
> + } else {
> + pr_err("Could not retrieve ONFI ECC requirements\n");
> + return 0;
This return will skips the message "ONFI flash detected", could we
remove the 'return' from this patch?
most of the drivers will not use the ECC info, so i think even we fail
to detect the ECC info
we do not need to skip the message "ONFI flash detected".
My suggestion is to use the pr_warn() to just print out the warning,
such as:
pr_warn("Could not retrieve ONFI ECC requirements\n");
thanks
Huang Shijie
> }
>
> pr_info("ONFI flash detected\n");
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 07/12] mtd: nand: return failure when failing to get ECC from ONFI
2013-09-05 2:34 ` Huang Shijie
@ 2013-09-11 21:43 ` Brian Norris
2013-09-11 23:02 ` Ezequiel Garcia
0 siblings, 1 reply; 18+ messages in thread
From: Brian Norris @ 2013-09-11 21:43 UTC (permalink / raw)
To: Huang Shijie; +Cc: linux-mtd
On Thu, Sep 05, 2013 at 10:34:21AM +0800, Huang Shijie wrote:
> 于 2013年09月05日 02:25, Brian Norris 写道:
> > If ONFI fails to provide ECC information, we should not use it. Print
> > appropriate error messages and return.
> >
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > Cc: Huang Shijie <b32955@freescale.com>
> > ---
> > drivers/mtd/nand/nand_base.c | 9 +++++++--
> > 1 file changed, 7 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > index 7ed4841..38b8dd4 100644
> > --- a/drivers/mtd/nand/nand_base.c
> > +++ b/drivers/mtd/nand/nand_base.c
> > @@ -3010,8 +3010,13 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
> > chip->cmdfunc = nand_command_lp;
> >
> > /* The Extended Parameter Page is supported since ONFI 2.1. */
> > - if (nand_flash_detect_ext_param_page(mtd, chip, p))
> > - pr_info("Failed to detect the extended param page.\n");
> > + if (nand_flash_detect_ext_param_page(mtd, chip, p)) {
> > + pr_info("Failed to detect ONFI extended param page\n");
> > + return 0;
> > + }
> > + } else {
> > + pr_err("Could not retrieve ONFI ECC requirements\n");
> > + return 0;
> This return will skips the message "ONFI flash detected", could we
> remove the 'return' from this patch?
Well, the "ONFI flash detected" message is not significant at all. In
fact, it is pretty useless and should just be dropped, I think. The real
question is whether we signal ONFI detected (return 1) or failed (return
0) when ONFI doesn't report ECC properly.
There are two "return"s in my patch. Are you suggesting removing both of
them, and just warning the user of the failure?
> most of the drivers will not use the ECC info, so i think even we fail
> to detect the ECC info
> we do not need to skip the message "ONFI flash detected".
You do have a point here, that most drivers don't (yet) use the ECC
info.
> My suggestion is to use the pr_warn() to just print out the warning,
> such as:
> pr_warn("Could not retrieve ONFI ECC requirements\n");
I may turn both prints into warnings, drop both of the 'return 0' (at
least until ONFI ECC detection is more heavily relied on), and drop all
the prints that are done for the success case ("ONFI flash detected" and
"ONFI param page X valid").
> > }
> >
> > pr_info("ONFI flash detected\n");
Brian
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: [PATCH 07/12] mtd: nand: return failure when failing to get ECC from ONFI
2013-09-11 21:43 ` Brian Norris
@ 2013-09-11 23:02 ` Ezequiel Garcia
0 siblings, 0 replies; 18+ messages in thread
From: Ezequiel Garcia @ 2013-09-11 23:02 UTC (permalink / raw)
To: Brian Norris; +Cc: Huang Shijie, linux-mtd
On Wed, Sep 11, 2013 at 02:43:19PM -0700, Brian Norris wrote:
> On Thu, Sep 05, 2013 at 10:34:21AM +0800, Huang Shijie wrote:
> > 于 2013年09月05日 02:25, Brian Norris 写道:
> > > If ONFI fails to provide ECC information, we should not use it. Print
> > > appropriate error messages and return.
> > >
> > > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> > > Cc: Huang Shijie <b32955@freescale.com>
> > > ---
> > > drivers/mtd/nand/nand_base.c | 9 +++++++--
> > > 1 file changed, 7 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> > > index 7ed4841..38b8dd4 100644
> > > --- a/drivers/mtd/nand/nand_base.c
> > > +++ b/drivers/mtd/nand/nand_base.c
> > > @@ -3010,8 +3010,13 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
> > > chip->cmdfunc = nand_command_lp;
> > >
> > > /* The Extended Parameter Page is supported since ONFI 2.1. */
> > > - if (nand_flash_detect_ext_param_page(mtd, chip, p))
> > > - pr_info("Failed to detect the extended param page.\n");
> > > + if (nand_flash_detect_ext_param_page(mtd, chip, p)) {
> > > + pr_info("Failed to detect ONFI extended param page\n");
> > > + return 0;
> > > + }
> > > + } else {
> > > + pr_err("Could not retrieve ONFI ECC requirements\n");
> > > + return 0;
> > This return will skips the message "ONFI flash detected", could we
> > remove the 'return' from this patch?
>
> Well, the "ONFI flash detected" message is not significant at all. In
> fact, it is pretty useless and should just be dropped, I think. The real
> question is whether we signal ONFI detected (return 1) or failed (return
> 0) when ONFI doesn't report ECC properly.
>
> There are two "return"s in my patch. Are you suggesting removing both of
> them, and just warning the user of the failure?
>
> > most of the drivers will not use the ECC info, so i think even we fail
> > to detect the ECC info
> > we do not need to skip the message "ONFI flash detected".
>
> You do have a point here, that most drivers don't (yet) use the ECC
> info.
>
> > My suggestion is to use the pr_warn() to just print out the warning,
> > such as:
> > pr_warn("Could not retrieve ONFI ECC requirements\n");
>
> I may turn both prints into warnings, drop both of the 'return 0' (at
> least until ONFI ECC detection is more heavily relied on), and drop all
> the prints that are done for the success case ("ONFI flash detected" and
> "ONFI param page X valid").
>
FWIW, I second the "drop all prints for the success case".
We're being too verbose in MTD, printing all sorts of useless information.
Or, if some 'notification' message is considered important, then let's make
it a pr_debug and be available for the only use case that will need it:
debugging/development.
--
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 08/12] mtd: nand: don't print ONFI buswidth errors unless we need to
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (6 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 07/12] mtd: nand: return failure when failing to get ECC from ONFI Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 09/12] mtd: onenand: remove redundant offset check Brian Norris
` (4 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
There are a few things wrong with this error message.
First, it is unnecessary to print until after the READID (address 20h)
command. READID *has* to work properly in whatever bus width
configuration we are in, or else no identification mode works. So we can
silence some useless warnings on systems which come up in 16-bit mode
and do not even respond with an O-N-F-I string.
Second, it doesn't read very well, and it has an extraneous exclamation.
Third, it doesn't have proper multiline comment style.
So, I move the whole block below the READID check and rewrite it.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/nand_base.c | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 38b8dd4..8599096 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -2937,17 +2937,21 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
int i;
int val;
- /* ONFI need to be probed in 8 bits mode, and 16 bits should be selected with NAND_BUSWIDTH_AUTO */
- if (chip->options & NAND_BUSWIDTH_16) {
- pr_err("Trying ONFI probe in 16 bits mode, aborting !\n");
- return 0;
- }
/* Try ONFI for unknown chip or LP */
chip->cmdfunc(mtd, NAND_CMD_READID, 0x20, -1);
if (chip->read_byte(mtd) != 'O' || chip->read_byte(mtd) != 'N' ||
chip->read_byte(mtd) != 'F' || chip->read_byte(mtd) != 'I')
return 0;
+ /*
+ * ONFI must be probed in 8-bit mode or with NAND_BUSWIDTH_AUTO, not
+ * with NAND_BUSWIDTH_16
+ */
+ if (chip->options & NAND_BUSWIDTH_16) {
+ pr_err("ONFI cannot be probed in 16-bit mode; aborting\n");
+ return 0;
+ }
+
chip->cmdfunc(mtd, NAND_CMD_PARAM, 0, -1);
for (i = 0; i < 3; i++) {
chip->read_buf(mtd, (uint8_t *)p, sizeof(*p));
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 09/12] mtd: onenand: remove redundant offset check
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (7 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 08/12] mtd: nand: don't print ONFI buswidth errors unless we need to Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 10/12] mtd: nand: remove obsolete 'ecclayout' field Brian Norris
` (3 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
The mtd_block_isbad() interface already checks for this.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/onenand/onenand_base.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index b3f41f2..7b7c1d2 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -2556,10 +2556,6 @@ static int onenand_block_isbad(struct mtd_info *mtd, loff_t ofs)
{
int ret;
- /* Check for invalid offset */
- if (ofs > mtd->size)
- return -EINVAL;
-
onenand_get_device(mtd, FL_READING);
ret = onenand_block_isbad_nolock(mtd, ofs, 0);
onenand_release_device(mtd);
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 10/12] mtd: nand: remove obsolete 'ecclayout' field
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (8 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 09/12] mtd: onenand: remove redundant offset check Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 11/12] mtd: onenand: remove unused variable assignments Brian Norris
` (2 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
This field is never used, except to print it out.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/nand/fsl_elbc_nand.c | 2 --
drivers/mtd/nand/fsl_ifc_nand.c | 2 --
include/linux/mtd/nand.h | 1 -
3 files changed, 5 deletions(-)
diff --git a/drivers/mtd/nand/fsl_elbc_nand.c b/drivers/mtd/nand/fsl_elbc_nand.c
index 2065720..c6ef9f1 100644
--- a/drivers/mtd/nand/fsl_elbc_nand.c
+++ b/drivers/mtd/nand/fsl_elbc_nand.c
@@ -650,8 +650,6 @@ static int fsl_elbc_chip_init_tail(struct mtd_info *mtd)
chip->page_shift);
dev_dbg(priv->dev, "fsl_elbc_init: nand->phys_erase_shift = %d\n",
chip->phys_erase_shift);
- dev_dbg(priv->dev, "fsl_elbc_init: nand->ecclayout = %p\n",
- chip->ecclayout);
dev_dbg(priv->dev, "fsl_elbc_init: nand->ecc.mode = %d\n",
chip->ecc.mode);
dev_dbg(priv->dev, "fsl_elbc_init: nand->ecc.steps = %d\n",
diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c
index 317a771..47acda6 100644
--- a/drivers/mtd/nand/fsl_ifc_nand.c
+++ b/drivers/mtd/nand/fsl_ifc_nand.c
@@ -718,8 +718,6 @@ static int fsl_ifc_chip_init_tail(struct mtd_info *mtd)
chip->page_shift);
dev_dbg(priv->dev, "%s: nand->phys_erase_shift = %d\n", __func__,
chip->phys_erase_shift);
- dev_dbg(priv->dev, "%s: nand->ecclayout = %p\n", __func__,
- chip->ecclayout);
dev_dbg(priv->dev, "%s: nand->ecc.mode = %d\n", __func__,
chip->ecc.mode);
dev_dbg(priv->dev, "%s: nand->ecc.steps = %d\n", __func__,
diff --git a/include/linux/mtd/nand.h b/include/linux/mtd/nand.h
index ac8e89d..1ef18f9 100644
--- a/include/linux/mtd/nand.h
+++ b/include/linux/mtd/nand.h
@@ -572,7 +572,6 @@ struct nand_chip {
uint8_t *oob_poi;
struct nand_hw_control *controller;
- struct nand_ecclayout *ecclayout;
struct nand_ecc_ctrl ecc;
struct nand_buffers *buffers;
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 11/12] mtd: onenand: remove unused variable assignments
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (9 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 10/12] mtd: nand: remove obsolete 'ecclayout' field Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-04 18:25 ` [PATCH 12/12] mtd: lpddr_cmds: make function static Brian Norris
2013-09-11 22:27 ` [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Kyungmin Park, Brian Norris
These variable assignments are never used (the variables are either
never used or are overwritten before use). This resolves some compiler
warnings like the following:
drivers/mtd/onenand/onenand_base.c: In function 'flexonenand_get_boundary':
drivers/mtd/onenand/onenand_base.c:3532:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
drivers/mtd/onenand/onenand_base.c: In function 'onenand_probe':
drivers/mtd/onenand/onenand_base.c:3838:6: warning: variable 'maf_id' set but not used [-Wunused-but-set-variable]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
---
drivers/mtd/onenand/onenand_base.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 7b7c1d2..1de33b5 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -3525,7 +3525,7 @@ static int flexonenand_get_boundary(struct mtd_info *mtd)
{
struct onenand_chip *this = mtd->priv;
unsigned die, bdry;
- int ret, syscfg, locked;
+ int syscfg, locked;
/* Disable ECC */
syscfg = this->read_word(this->base + ONENAND_REG_SYS_CFG1);
@@ -3536,7 +3536,7 @@ static int flexonenand_get_boundary(struct mtd_info *mtd)
this->wait(mtd, FL_SYNCING);
this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
- ret = this->wait(mtd, FL_READING);
+ this->wait(mtd, FL_READING);
bdry = this->read_word(this->base + ONENAND_DATARAM);
if ((bdry >> FLEXONENAND_PI_UNLOCK_SHIFT) == 3)
@@ -3546,7 +3546,7 @@ static int flexonenand_get_boundary(struct mtd_info *mtd)
this->boundary[die] = bdry & FLEXONENAND_PI_MASK;
this->command(mtd, ONENAND_CMD_RESET, 0, 0);
- ret = this->wait(mtd, FL_RESETING);
+ this->wait(mtd, FL_RESETING);
printk(KERN_INFO "Die %d boundary: %d%s\n", die,
this->boundary[die], locked ? "(Locked)" : "(Unlocked)");
@@ -3730,7 +3730,7 @@ static int flexonenand_set_boundary(struct mtd_info *mtd, int die,
/* Check is boundary is locked */
this->command(mtd, FLEXONENAND_CMD_READ_PI, die, 0);
- ret = this->wait(mtd, FL_READING);
+ this->wait(mtd, FL_READING);
thisboundary = this->read_word(this->base + ONENAND_DATARAM);
if ((thisboundary >> FLEXONENAND_PI_UNLOCK_SHIFT) != 3) {
@@ -3831,7 +3831,7 @@ static int onenand_chip_probe(struct mtd_info *mtd)
static int onenand_probe(struct mtd_info *mtd)
{
struct onenand_chip *this = mtd->priv;
- int maf_id, dev_id, ver_id;
+ int dev_id, ver_id;
int density;
int ret;
@@ -3839,8 +3839,7 @@ static int onenand_probe(struct mtd_info *mtd)
if (ret)
return ret;
- /* Read manufacturer and device IDs from Register */
- maf_id = this->read_word(this->base + ONENAND_REG_MANUFACTURER_ID);
+ /* Device and version IDs from Register */
dev_id = this->read_word(this->base + ONENAND_REG_DEVICE_ID);
ver_id = this->read_word(this->base + ONENAND_REG_VERSION_ID);
this->technology = this->read_word(this->base + ONENAND_REG_TECHNOLOGY);
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 12/12] mtd: lpddr_cmds: make function static
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (10 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 11/12] mtd: onenand: remove unused variable assignments Brian Norris
@ 2013-09-04 18:25 ` Brian Norris
2013-09-11 22:27 ` [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-04 18:25 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris
do_xxlock() is only used locally. This silences a sparse warning:
drivers/mtd/lpddr/lpddr_cmds.c:706:5: warning: no previous prototype for 'do_xxlock' [-Wmissing-prototypes]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
drivers/mtd/lpddr/lpddr_cmds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c
index d3cfe26b..2ef19aa 100644
--- a/drivers/mtd/lpddr/lpddr_cmds.c
+++ b/drivers/mtd/lpddr/lpddr_cmds.c
@@ -703,7 +703,7 @@ static int lpddr_erase(struct mtd_info *mtd, struct erase_info *instr)
#define DO_XXLOCK_LOCK 1
#define DO_XXLOCK_UNLOCK 2
-int do_xxlock(struct mtd_info *mtd, loff_t adr, uint32_t len, int thunk)
+static int do_xxlock(struct mtd_info *mtd, loff_t adr, uint32_t len, int thunk)
{
int ret = 0;
struct map_info *map = mtd->priv;
--
1.8.4
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: [PATCH 00/12] mtd: miscellaneous fixes
2013-09-04 18:25 [PATCH 00/12] mtd: miscellaneous fixes Brian Norris
` (11 preceding siblings ...)
2013-09-04 18:25 ` [PATCH 12/12] mtd: lpddr_cmds: make function static Brian Norris
@ 2013-09-11 22:27 ` Brian Norris
12 siblings, 0 replies; 18+ messages in thread
From: Brian Norris @ 2013-09-11 22:27 UTC (permalink / raw)
To: linux-mtd; +Cc: David Brownell, Huang Shijie, Kyungmin Park
On Wed, Sep 04, 2013 at 11:25:14AM -0700, Brian Norris wrote:
> Hi all,
>
> In poking around various drivers for my own work and for (sub)maintaining
> MTD stuff, I found an assortment of fixes to make. Most of these should be
> trivial and obvious, but they could use a glance by a few people. They have
> generally been compile tested only.
>
> Brian
>
> Brian Norris (12):
> nand: docg4: use nand_base's default BBT scan
> mtd: nand: lpc32xx_slc: don't call nand_default_bbt directly
> mtd: nandsim: don't call nand_default_bbt() directly
> mtd: nand: stop exporting nand_default_bbt
> mtd: dataflash: remove unused field
> mtd: denali: make init function static
> mtd: nand: return failure when failing to get ECC from ONFI
> mtd: nand: don't print ONFI buswidth errors unless we need to
> mtd: onenand: remove redundant offset check
> mtd: nand: remove obsolete 'ecclayout' field
> mtd: onenand: remove unused variable assignments
> mtd: lpddr_cmds: make function static
>
> drivers/mtd/devices/mtd_dataflash.c | 2 --
> drivers/mtd/lpddr/lpddr_cmds.c | 2 +-
> drivers/mtd/nand/denali.c | 2 +-
> drivers/mtd/nand/docg4.c | 1 -
> drivers/mtd/nand/fsl_elbc_nand.c | 2 --
> drivers/mtd/nand/fsl_ifc_nand.c | 2 --
> drivers/mtd/nand/lpc32xx_slc.c | 8 --------
> drivers/mtd/nand/nand_base.c | 23 ++++++++++++++++-------
> drivers/mtd/nand/nand_bbt.c | 1 -
> drivers/mtd/nand/nandsim.c | 2 +-
> drivers/mtd/onenand/onenand_base.c | 17 ++++++-----------
> include/linux/mtd/nand.h | 1 -
> 12 files changed, 25 insertions(+), 38 deletions(-)
Pushed everything but the ONFI stuff to l2-mtd.git. I will follow up
with a separate patch for that one.
Brian
^ permalink raw reply [flat|nested] 18+ messages in thread