mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems
authorDaniel Golle <daniel@makrotopia.org>
Thu, 29 Feb 2024 03:47:24 +0000 (03:47 +0000)
committerRichard Weinberger <richard@nod.at>
Sun, 10 Mar 2024 21:14:28 +0000 (22:14 +0100)
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.

Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes")
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/nvmem.c

index b7a93c495d17286e7d063362e9ff9808d4d8385d..8aeb9c428e51011cfc146c30339d96bfdda2ea50 100644 (file)
@@ -23,9 +23,12 @@ 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;
+       size_t to_read, bytes_left = bytes;
        struct ubi_nvmem *unv = priv;
        struct ubi_volume_desc *desc;
+       uint32_t offs;
+       uint64_t lnum = from;
+       int err = 0;
 
        desc = ubi_open_volume(unv->ubi_num, unv->vol_id, UBI_READONLY);
        if (IS_ERR(desc))