firmware: vpd: use memunmap instead of iounmap
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
@@ -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
Guenter Roeck
Reviewed-byQuoted 4 lines · Pan Bian
In functions
vpd_sections_init()andvpd_section_init(),iounmap()is used to unmap memory. However, in these cases,memunmap()is better.Signed-off-by Pan Bian <[email protected]>
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@@ -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
Hi Pan,
Quoted 13 lines · Pan Bian
In functions
vpd_sections_init()andvpd_section_init(),iounmap()is used to unmap memory. However, in these cases,memunmap()is better.Signed-off-by Pan Bian <[email protected]>--- drivers/firmware/google/vpd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/firmware/google/vpd.c +0
-0
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
-1return 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