Skip to contentSkip to conversation

firmware: vpd: use memunmap instead of iounmap

PATCH Pan Bian 3 participants 3 messages Aug 8, 2017

lore
Share & tools
lore

Pan Bian

author
#0 lore raw

In functions vpd_sections_init() and vpd_section_init(), iounmap() is used to unmap memory. However, in these cases, memunmap() is better.

---
 drivers/firmware/google/vpd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/firmware/google/vpd.c +3 -3
index 7894572..ac6400f 100644
@@ -234,7 +234,7 @@ static int vpd_section_init(const char *name, struct vpd_section *sec,
 err_free_raw_name:
 	kfree(sec->raw_name);
 err_iounmap:
-	iounmap(sec->baseaddr);
+	memunmap(sec->baseaddr);
 	return err;
 }
 
@@ -245,7 +245,7 @@ static int vpd_section_destroy(struct vpd_section *sec)
 		kobject_put(sec->kobj);
 		sysfs_remove_bin_file(vpd_kobj, &sec->bin_attr);
 		kfree(sec->raw_name);
-		iounmap(sec->baseaddr);
+		memunmap(sec->baseaddr);
 	}
 
 	return 0;
@@ -262,7 +262,7 @@ static int vpd_sections_init(phys_addr_t physaddr)
 		return -ENOMEM;
 
 	memcpy_fromio(&header, temp, sizeof(struct vpd_cbmem));
-	iounmap(temp);
+	memunmap(temp);
 
 	if (header.magic != VPD_CBMEM_MAGIC)
 		return -ENODEV;
Signature · 1 line
1.9.1
Reviewed-by
#1 lore raw
Quoted 4 lines · Pan Bian

In functions vpd_sections_init() and vpd_section_init(), iounmap() is used to unmap memory. However, in these cases, memunmap() is better.

The code uses memremap(), so that seems reasonable.

Quoted 39 lines
---
 drivers/firmware/google/vpd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/firmware/google/vpd.c +3 -4
index 7894572..ac6400f 100644
@@ -234,7 +234,7 @@ static int vpd_section_init(const char *name, struct vpd_section *sec,
 err_free_raw_name:
        kfree(sec->raw_name);
 err_iounmap:
-       iounmap(sec->baseaddr);
+       memunmap(sec->baseaddr);
        return err;
 }
 
@@ -245,7 +245,7 @@ static int vpd_section_destroy(struct vpd_section *sec)
                kobject_put(sec->kobj);
                sysfs_remove_bin_file(vpd_kobj, &sec->bin_attr);
                kfree(sec->raw_name);
-               iounmap(sec->baseaddr);
+               memunmap(sec->baseaddr);
        }
 
        return 0;
@@ -262,7 +262,7 @@ static int vpd_sections_init(phys_addr_t physaddr)
                return -ENOMEM;
 
        memcpy_fromio(&header, temp, sizeof(struct vpd_cbmem));
-       iounmap(temp);
+       memunmap(temp);
 
        if (header.magic != VPD_CBMEM_MAGIC)
                return -ENODEV;
--

1.9.1

#2 lore raw
In reply to Pan Bian

Hi Pan,

Quoted 13 lines · Pan Bian

In functions vpd_sections_init() and vpd_section_init(), iounmap() is used to unmap memory. However, in these cases, memunmap() is better.

---
 drivers/firmware/google/vpd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/firmware/google/vpd.c +0 -0
index 7894572..ac6400f 100644

drivers/firmware/google/vpd.c static int vpd_section_init(const char *name, struct vpd_section *sec, · line 237

Quoted 5 lines
drivers/firmware/google/vpd.c +1 -1
@@ -234,7 +234,7 @@ static int vpd_section_init(const char *name, struct vpd_section *sec,
 err_free_raw_name:
        kfree(sec->raw_name);
 err_iounmap:
-       iounmap(sec->baseaddr);
+       memunmap(sec->baseaddr);

It would be great if you also adjusted the name of the error label.

Quoted 13 lines
drivers/firmware/google/vpd.c +1 -1
        return err;
 }
 
@@ -245,7 +245,7 @@ static int vpd_section_destroy(struct vpd_section *sec)
                kobject_put(sec->kobj);
                sysfs_remove_bin_file(vpd_kobj, &sec->bin_attr);
                kfree(sec->raw_name);
-               iounmap(sec->baseaddr);
+               memunmap(sec->baseaddr);
        }
 
        return 0;

drivers/firmware/google/vpd.c static int vpd_sections_init(phys_addr_t physaddr) · line 268

Quoted 8 lines
drivers/firmware/google/vpd.c +1 -1
@@ -262,7 +262,7 @@ static int vpd_sections_init(phys_addr_t physaddr)
                return -ENOMEM;
 
        memcpy_fromio(&header, temp, sizeof(struct vpd_cbmem));
-       iounmap(temp);
+       memunmap(temp);
 
        if (header.magic != VPD_CBMEM_MAGIC)
                return -ENODEV;

I think there is more confusion with memremap/iounmap and type of the header data structure. I think I need to refresh
https://lkml.org/lkml/2017/5/23/1445

Thanks.

Signature · 1 line
Dmitry