RFC on large number of hacks in mtd core files
Brian Norris
computersforpeace at gmail.com
Fri Jan 29 10:14:29 PST 2016
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 at 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 at 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
More information about the linux-mtd
mailing list