From: Brian Norris <computersforpeace@gmail.com>
To: Boris Brezillon <boris.brezillon@free-electrons.com>
Cc: Mason <slash.tmp@free.fr>, Sebastian Frias <sf84@laposte.net>,
David Woodhouse <dwmw2@infradead.org>,
linux-mtd <linux-mtd@lists.infradead.org>
Subject: Re: RFC on large number of hacks in mtd core files
Date: Fri, 29 Jan 2016 10:14:29 -0800 [thread overview]
Message-ID: <20160129181429.GA7968@google.com> (raw)
In-Reply-To: <20160129172717.24a12c3d@bbrezillon>
On Fri, Jan 29, 2016 at 05:27:17PM +0100, Boris Brezillon wrote:
> On Mon, 25 Jan 2016 18:34:50 +0100
> Mason <slash.tmp@free.fr> wrote:
> > @@ -2888,16 +2951,29 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
> > sanitize_string(p->model, sizeof(p->model));
> > if (!mtd->name)
> > mtd->name = p->model;
> > +
> > mtd->writesize = le32_to_cpu(p->byte_per_page);
> > - mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize;
> > +
> > + /*
> > + * pages_per_block and blocks_per_lun may not be a power-of-2 size
> > + * (don't ask me who thought of this...). MTD assumes that these
> > + * dimensions will be power-of-2, so just truncate the remaining area.
> > + */
> > + mtd->erasesize = 1 << (fls(le32_to_cpu(p->pages_per_block)) - 1);
> > + mtd->erasesize *= mtd->writesize;
> > +
>
> Hm, I'd like to have a real example (all the chips I've seen so far
> are using power-of-2 here). And even if that's the case, then this means
> we should patch nand_base to deal with that.
>
> > mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page);
> > - chip->chipsize = le32_to_cpu(p->blocks_per_lun);
> > +
> > + /* See erasesize comment */
> > + chip->chipsize = 1 << (fls(le32_to_cpu(p->blocks_per_lun)) - 1);
>
> Ditto.
It looks like he borrowed these from this commit of mine:
commit 4355b70cf48363c50a9de450b01178c83aba8f6a
Author: Brian Norris <computersforpeace@gmail.com>
Date: Tue Aug 27 18:45:10 2013 -0700
mtd: nand: hack ONFI for non-power-of-2 dimensions
As evidenced in the commit subject ("hack"), it's debatably a shortcut
that could have been dealt with in other ways.
Brian
next prev parent reply other threads:[~2016-01-29 18:14 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-22 15:34 RFC on large number of hacks in mtd core files Mason
2016-01-23 3:16 ` Brian Norris
2016-01-23 10:53 ` Mason
2016-01-25 17:34 ` Mason
2016-01-28 18:05 ` Geert Uytterhoeven
2016-01-28 21:05 ` Mason
2016-01-29 7:50 ` Geert Uytterhoeven
2016-01-29 16:27 ` Boris Brezillon
2016-01-29 18:14 ` Brian Norris [this message]
2016-01-30 11:37 ` Boris Brezillon
2016-01-29 23:25 ` Mason
2016-01-30 11:22 ` Boris Brezillon
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=20160129181429.GA7968@google.com \
--to=computersforpeace@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=sf84@laposte.net \
--cc=slash.tmp@free.fr \
/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).