From: Daniel Golle <daniel@makrotopia.org>
To: Richard Weinberger <richard@nod.at>,
Zhihao Cheng <chengzhihao1@huawei.com>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Vignesh Raghavendra <vigneshr@ti.com>,
Daniel Golle <daniel@makrotopia.org>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: [PATCH] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems
Date: Mon, 26 Feb 2024 18:23:42 +0000 [thread overview]
Message-ID: <186fa96ae25f7033ff8b6f0f7fcfb1e602f556fc.1708971705.git.daniel@makrotopia.org> (raw)
A compiler warning related to sizeof(int) != 8 when calling do_div()
is triggered when building on 32-bit platforms.
Address this by using integer types having a well-defined size where
appropriate.
Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
---
drivers/mtd/ubi/nvmem.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/mtd/ubi/nvmem.c b/drivers/mtd/ubi/nvmem.c
index b7a93c495d172..5820a170d2512 100644
--- a/drivers/mtd/ubi/nvmem.c
+++ b/drivers/mtd/ubi/nvmem.c
@@ -23,14 +23,17 @@ struct ubi_nvmem {
static int ubi_nvmem_reg_read(void *priv, unsigned int from,
void *val, size_t bytes)
{
- int err = 0, lnum = from, offs, bytes_left = bytes, to_read;
+ uint32_t bytes_left, offs, to_read;
struct ubi_nvmem *unv = priv;
struct ubi_volume_desc *desc;
+ uint64_t lnum = from;
+ int err = 0;
desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY);
if (IS_ERR(desc))
return PTR_ERR(desc);
+ bytes_left = bytes;
offs = do_div(lnum, unv->usable_leb_size);
while (bytes_left) {
to_read = unv->usable_leb_size - offs;
--
2.44.0
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2024-02-26 18:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 18:23 Daniel Golle [this message]
2024-02-27 2:23 ` [PATCH] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems Zhihao Cheng
2024-02-27 12:57 ` Daniel Golle
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=186fa96ae25f7033ff8b6f0f7fcfb1e602f556fc.1708971705.git.daniel@makrotopia.org \
--to=daniel@makrotopia.org \
--cc=chengzhihao1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.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 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 read-only IMAP folder(s) and NNTP newsgroup(s).