* [PATCH] mtd: nand: fix write accessor sanity checks
@ 2017-03-07 11:23 Masahiro Yamada
2017-03-07 11:40 ` Boris Brezillon
0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2017-03-07 11:23 UTC (permalink / raw)
To: linux-mtd
Cc: Masahiro Yamada, linux-kernel, Boris Brezillon, Marek Vasut,
Brian Norris, Richard Weinberger, David Woodhouse,
Cyrille Pitchen
If the higher level accessor chip->write_page() is implemented,
ecc->write_page() and ecc->write_page_raw() are not required.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
drivers/mtd/nand/nand_base.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index a3c0f47..c32e700 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -4585,11 +4585,12 @@ static bool invalid_ecc_page_accessors(struct nand_chip *chip)
* default helpers are not suitable when the core does not
* send the READ0/PAGEPROG commands.
*/
- return (!ecc->read_page || !ecc->write_page ||
- !ecc->read_page_raw || !ecc->write_page_raw ||
+ return !ecc->read_page || !ecc->read_page_raw ||
(NAND_HAS_SUBPAGE_READ(chip) && !ecc->read_subpage) ||
- (NAND_HAS_SUBPAGE_WRITE(chip) && !ecc->write_subpage &&
- ecc->hwctl && ecc->calculate));
+ (!chip->write_page &&
+ (!ecc->write_page || !ecc->write_page_raw ||
+ (NAND_HAS_SUBPAGE_WRITE(chip) && !ecc->write_subpage &&
+ ecc->hwctl && ecc->calculate)));
}
/**
@@ -4699,8 +4700,9 @@ int nand_scan_tail(struct mtd_info *mtd)
if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) &&
(!ecc->read_page ||
ecc->read_page == nand_read_page_hwecc ||
- !ecc->write_page ||
- ecc->write_page == nand_write_page_hwecc)) {
+ (!chip->write_page &&
+ (!ecc->write_page ||
+ ecc->write_page == nand_write_page_hwecc)))) {
WARN(1, "No ECC functions supplied; hardware ECC not possible\n");
ret = -EINVAL;
goto err_free;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: nand: fix write accessor sanity checks
2017-03-07 11:23 [PATCH] mtd: nand: fix write accessor sanity checks Masahiro Yamada
@ 2017-03-07 11:40 ` Boris Brezillon
2017-03-07 13:03 ` Masahiro Yamada
0 siblings, 1 reply; 3+ messages in thread
From: Boris Brezillon @ 2017-03-07 11:40 UTC (permalink / raw)
To: Masahiro Yamada
Cc: linux-mtd, linux-kernel, Marek Vasut, Brian Norris,
Richard Weinberger, David Woodhouse, Cyrille Pitchen
On Tue, 7 Mar 2017 20:23:59 +0900
Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
> If the higher level accessor chip->write_page() is implemented,
> ecc->write_page() and ecc->write_page_raw() are not required.
I'm about to remove the chip->write_page() hook [1], I hope you're not
planning to use it.
[1]https://patchwork.ozlabs.org/patch/729966/
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
>
> drivers/mtd/nand/nand_base.c | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index a3c0f47..c32e700 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -4585,11 +4585,12 @@ static bool invalid_ecc_page_accessors(struct nand_chip *chip)
> * default helpers are not suitable when the core does not
> * send the READ0/PAGEPROG commands.
> */
> - return (!ecc->read_page || !ecc->write_page ||
> - !ecc->read_page_raw || !ecc->write_page_raw ||
> + return !ecc->read_page || !ecc->read_page_raw ||
> (NAND_HAS_SUBPAGE_READ(chip) && !ecc->read_subpage) ||
> - (NAND_HAS_SUBPAGE_WRITE(chip) && !ecc->write_subpage &&
> - ecc->hwctl && ecc->calculate));
> + (!chip->write_page &&
> + (!ecc->write_page || !ecc->write_page_raw ||
> + (NAND_HAS_SUBPAGE_WRITE(chip) && !ecc->write_subpage &&
> + ecc->hwctl && ecc->calculate)));
> }
>
> /**
> @@ -4699,8 +4700,9 @@ int nand_scan_tail(struct mtd_info *mtd)
> if ((!ecc->calculate || !ecc->correct || !ecc->hwctl) &&
> (!ecc->read_page ||
> ecc->read_page == nand_read_page_hwecc ||
> - !ecc->write_page ||
> - ecc->write_page == nand_write_page_hwecc)) {
> + (!chip->write_page &&
> + (!ecc->write_page ||
> + ecc->write_page == nand_write_page_hwecc)))) {
> WARN(1, "No ECC functions supplied; hardware ECC not possible\n");
> ret = -EINVAL;
> goto err_free;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mtd: nand: fix write accessor sanity checks
2017-03-07 11:40 ` Boris Brezillon
@ 2017-03-07 13:03 ` Masahiro Yamada
0 siblings, 0 replies; 3+ messages in thread
From: Masahiro Yamada @ 2017-03-07 13:03 UTC (permalink / raw)
To: Boris Brezillon
Cc: linux-mtd, Linux Kernel Mailing List, Marek Vasut, Brian Norris,
Richard Weinberger, David Woodhouse, Cyrille Pitchen
Hi Boris,
2017-03-07 20:40 GMT+09:00 Boris Brezillon <boris.brezillon@free-electrons.com>:
> On Tue, 7 Mar 2017 20:23:59 +0900
> Masahiro Yamada <yamada.masahiro@socionext.com> wrote:
>
>> If the higher level accessor chip->write_page() is implemented,
>> ecc->write_page() and ecc->write_page_raw() are not required.
>
> I'm about to remove the chip->write_page() hook [1], I hope you're not
> planning to use it.
>
> [1]https://patchwork.ozlabs.org/patch/729966/
>
In fact, I was wondering if I should use chip->write_page()
for denali.c (then I noticed this broken accessor checks).
After all, I decided to not (ab)use chip->write_page(), though.
Anyway, it is good that I am sure about this now.
Thanks!
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-03-07 13:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-07 11:23 [PATCH] mtd: nand: fix write accessor sanity checks Masahiro Yamada
2017-03-07 11:40 ` Boris Brezillon
2017-03-07 13:03 ` Masahiro Yamada
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.