]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
firmware: google: memconsole: Use devm_memremap()
authorStephen Boyd <swboyd@chromium.org>
Fri, 10 May 2019 21:24:53 +0000 (14:24 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 24 May 2019 18:55:04 +0000 (20:55 +0200)
Use the devm version of memremap so that we can delete the unmapping
code in driver remove, but more importantly so that we can unmap this
memory region if memconsole_sysfs_init() errors out for some reason.

Cc: Wei-Ning Huang <wnhuang@chromium.org>
Cc: Julius Werner <jwerner@chromium.org>
Cc: Brian Norris <briannorris@chromium.org>
Cc: Samuel Holland <samuel@sholland.org>
Cc: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/google/memconsole-coreboot.c

index 86331807f1d5e3c35e0582b86aa6d5622a90fddb..cc3797f1ba85e3db5c5785204f469d941204887d 100644 (file)
@@ -85,13 +85,13 @@ static int memconsole_probe(struct coreboot_device *dev)
 
        /* Read size only once to prevent overrun attack through /dev/mem. */
        cbmem_console_size = tmp_cbmc->size_dont_access_after_boot;
-       cbmem_console = memremap(dev->cbmem_ref.cbmem_addr,
+       cbmem_console = devm_memremap(&dev->dev, dev->cbmem_ref.cbmem_addr,
                                 cbmem_console_size + sizeof(*cbmem_console),
                                 MEMREMAP_WB);
        memunmap(tmp_cbmc);
 
-       if (!cbmem_console)
-               return -ENOMEM;
+       if (IS_ERR(cbmem_console))
+               return PTR_ERR(cbmem_console);
 
        memconsole_setup(memconsole_coreboot_read);
 
@@ -102,9 +102,6 @@ static int memconsole_remove(struct coreboot_device *dev)
 {
        memconsole_exit();
 
-       if (cbmem_console)
-               memunmap(cbmem_console);
-
        return 0;
 }