All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: festevam <festevam@gmail.com>
Cc: david oberhollenzer <david.oberhollenzer@sigma-star.at>,
	 linux-mtd <linux-mtd@lists.infradead.org>,
	 Miquel Raynal <miquel.raynal@bootlin.com>,
	 Marek Vasut <marex@denx.de>, hs <hs@denx.de>
Subject: Re: mtd-utils: Proper way to handle erasize=0
Date: Mon, 19 Jul 2021 21:36:46 +0200 (CEST)	[thread overview]
Message-ID: <323618383.46712.1626723406949.JavaMail.zimbra@nod.at> (raw)
In-Reply-To: <CAOMZO5BX9iYmZwBBGEstbcWpvftRNExtwq+kX_rQff0v_o1P5g@mail.gmail.com>

----- Ursprüngliche Mail -----
> Von: "festevam" <festevam@gmail.com>
> An: "david oberhollenzer" <david.oberhollenzer@sigma-star.at>, "richard" <richard@nod.at>
> CC: "linux-mtd" <linux-mtd@lists.infradead.org>, "Miquel Raynal" <miquel.raynal@bootlin.com>, "Marek Vasut"
> <marex@denx.de>, "hs" <hs@denx.de>
> Gesendet: Montag, 19. Juli 2021 21:12:26
> Betreff: mtd-utils: Proper way to handle erasize=0

> Hi,
> 
> When using a Microchip 48l640 SRAM (drivers/mtd/devices/mchp48l640.c)
> the reported erasesize is 0:
> 
> # cat /proc/mtd
> dev:    size   erasesize  name
> mtd0: 00002000 00000000 "spi0.0"
> 
> This causes a division by zero at libmtd.c, as mtd_get_dev_info1() has:
> 
> mtd->eb_cnt = mtd->size / mtd->eb_size;
> 
> What would be the appropriate way to fix this?

Didn't this commit address that problem?

commit 54d68799b73e755923def1306b4da607ad45bd60
Author: Chris Packham <chris.packham@alliedtelesis.co.nz>
Date:   Fri Nov 27 13:07:08 2020 +1300

    libmtd: avoid divide by zero
    
    The concept of erase blocks doesn't apply to mtd-ram devices. Such
    devices set MTD_NO_ERASE to indicate this and some report 0 for the
    erase block size. Avoid a divide by zero when calculating the erase
    block count for such devices.
    
    Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
    Acked-by: Richard Weinberger <richard@nod.at>
    Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>

Thanks,
//richard

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-07-19 19:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-19 19:12 mtd-utils: Proper way to handle erasize=0 Fabio Estevam
2021-07-19 19:36 ` Richard Weinberger [this message]
2021-07-19 22:20   ` Fabio Estevam
2021-07-19 22:33     ` Richard Weinberger

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=323618383.46712.1626723406949.JavaMail.zimbra@nod.at \
    --to=richard@nod.at \
    --cc=david.oberhollenzer@sigma-star.at \
    --cc=festevam@gmail.com \
    --cc=hs@denx.de \
    --cc=linux-mtd@lists.infradead.org \
    --cc=marex@denx.de \
    --cc=miquel.raynal@bootlin.com \
    /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 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.