From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Victor Fusco <victor@cartesi.io>
Cc: linux-mtd@lists.infradead.org
Subject: Re: [PATCH] mtd: physmap: Fix mtd device size
Date: Mon, 27 Apr 2020 15:17:39 +0200 [thread overview]
Message-ID: <20200427151739.20422167@xps13> (raw)
In-Reply-To: <20200319144129.24849-1-victor@cartesi.io>
Hi Victor,
Victor Fusco <victor@cartesi.io> wrote on Thu, 19 Mar 2020 14:41:29
+0000:
> This patch fixes the mtd device size calculation when there is no gpio
s/mtd/MTD/
S/gpio/GPIO/
> defined. The previous size calculation could return values lower than
> those defined on the 'reg' field of the Device Tree, rasing 'attempt to
s/rasing/raising/ ?
> access beyond end of device' errors during device access.
>
> Signed-off-by: Victor Fusco <victor@cartesi.io>
> ---
> drivers/mtd/maps/physmap-core.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c
> index 8f7f966fa9a7..27cc6ac01ea8 100644
> --- a/drivers/mtd/maps/physmap-core.c
> +++ b/drivers/mtd/maps/physmap-core.c
> @@ -520,17 +520,19 @@ static int physmap_flash_probe(struct platform_device *dev)
> if (!info->maps[i].phys)
> info->maps[i].phys = res->start;
>
> - info->win_order = get_bitmask_order(resource_size(res)) - 1;
> - info->maps[i].size = BIT(info->win_order +
> - (info->gpios ?
> - info->gpios->ndescs : 0));
> -
> info->maps[i].map_priv_1 = (unsigned long)dev;
>
> if (info->gpios) {
> + info->win_order = get_bitmask_order(resource_size(res)) - 1;
> + info->maps[i].size = BIT(info->win_order +
> + info->gpios->ndescs);
> +
> err = physmap_addr_gpios_map_init(&info->maps[i]);
> if (err)
> goto err_out;
> + } else {
> + info->maps[i].size = resource_size(res);
I didn't check the driver but are you sure info->win_order and
maps[i].map_priv_1 do not need to be initialized? Also are these fields
still needed if you stop using them? (just asking)
> +
Extra new line
> }
>
> #ifdef CONFIG_MTD_COMPLEX_MAPPINGS
>
> base-commit: 5076190daded2197f62fe92cf69674488be44175
Thanks,
Miquèl
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
prev parent reply other threads:[~2020-04-27 13:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 14:41 [PATCH] mtd: physmap: Fix mtd device size Victor Fusco
2020-04-27 13:17 ` Miquel Raynal [this message]
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=20200427151739.20422167@xps13 \
--to=miquel.raynal@bootlin.com \
--cc=linux-mtd@lists.infradead.org \
--cc=victor@cartesi.io \
/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