]> git.baikalelectronics.ru Git - kernel.git/commitdiff
mtd: slram: use memremap() instead of ioremap()
authorRoy Franz <rfranz@cavium.com>
Thu, 19 Oct 2017 22:55:49 +0000 (15:55 -0700)
committerRichard Weinberger <richard@nod.at>
Mon, 13 Nov 2017 20:39:16 +0000 (21:39 +0100)
Convert slram to use memremap() to map the memory it uses to back an MTD
device, as this is the proper interface for mapping memory. This change
enables normal memory to be used to back an MTD device on arm64, as arm64
prevents ioremap() being used on normal memory.

Signed-off-by: Roy Franz <roy.franz@cavium.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Tested-by: David Daney <david.daney@cavium.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/devices/slram.c

index 8087c36dc6935a8d6caf6d4b770be4fba60e1319..0ec85f316d24c04e8503c8ca7625a3c16399a97b 100644 (file)
@@ -163,8 +163,9 @@ static int register_device(char *name, unsigned long start, unsigned long length
        }
 
        if (!(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start =
-                               ioremap(start, length))) {
-               E("slram: ioremap failed\n");
+               memremap(start, length,
+                        MEMREMAP_WB | MEMREMAP_WT | MEMREMAP_WC))) {
+               E("slram: memremap failed\n");
                return -EIO;
        }
        ((slram_priv_t *)(*curmtd)->mtdinfo->priv)->end =
@@ -186,7 +187,7 @@ static int register_device(char *name, unsigned long start, unsigned long length
 
        if (mtd_device_register((*curmtd)->mtdinfo, NULL, 0))   {
                E("slram: Failed to register new device\n");
-               iounmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
+               memunmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start);
                kfree((*curmtd)->mtdinfo->priv);
                kfree((*curmtd)->mtdinfo);
                return(-EAGAIN);
@@ -206,7 +207,7 @@ static void unregister_devices(void)
        while (slram_mtdlist) {
                nextitem = slram_mtdlist->next;
                mtd_device_unregister(slram_mtdlist->mtdinfo);
-               iounmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
+               memunmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start);
                kfree(slram_mtdlist->mtdinfo->priv);
                kfree(slram_mtdlist->mtdinfo);
                kfree(slram_mtdlist);