Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1706502 > unrolled thread

firmware: vpd: use memunmap instead of iounmap

Started byPan Bian <bianpan2016@163.com>
First post2017-08-08 14:50 +0200
Last post2017-08-08 18:30 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  firmware: vpd: use memunmap instead of iounmap Pan Bian <bianpan2016@163.com> - 2017-08-08 14:50 +0200
    Re: firmware: vpd: use memunmap instead of iounmap Guenter Roeck <groeck@google.com> - 2017-08-08 16:40 +0200
    Re: firmware: vpd: use memunmap instead of iounmap Dmitry Torokhov <dmitry.torokhov@gmail.com> - 2017-08-08 18:30 +0200

#1706502 — firmware: vpd: use memunmap instead of iounmap

FromPan Bian <bianpan2016@163.com>
Date2017-08-08 14:50 +0200
Subjectfirmware: vpd: use memunmap instead of iounmap
Message-ID<ucc7o-8sm-15@gated-at.bofh.it>
In functions vpd_sections_init() and vpd_section_init(), iounmap() is
used to unmap memory. However, in these cases, memunmap() is better.

Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/firmware/google/vpd.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
index 7894572..ac6400f 100644
--- a/drivers/firmware/google/vpd.c
+++ b/drivers/firmware/google/vpd.c
@@ -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

[toc] | [next] | [standalone]


#1706619

FromGuenter Roeck <groeck@google.com>
Date2017-08-08 16:40 +0200
Message-ID<ucdPR-1fE-33@gated-at.bofh.it>
In reply to#1706502
On Tue, Aug 8, 2017 at 5:45 AM, Pan Bian <bianpan2016@163.com> wrote:
> In functions vpd_sections_init() and vpd_section_init(), iounmap() is
> used to unmap memory. However, in these cases, memunmap() is better.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>

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

Reviewed-by: Guenter Roeck <groeck@chromium.org>

> ---
>  drivers/firmware/google/vpd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
> index 7894572..ac6400f 100644
> --- a/drivers/firmware/google/vpd.c
> +++ b/drivers/firmware/google/vpd.c
> @@ -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
>
>

[toc] | [prev] | [next] | [standalone]


#1706744

FromDmitry Torokhov <dmitry.torokhov@gmail.com>
Date2017-08-08 18:30 +0200
Message-ID<ucfyj-2uV-53@gated-at.bofh.it>
In reply to#1706502
Hi Pan,

On Tue, Aug 8, 2017 at 5:45 AM, Pan Bian <bianpan2016@163.com> wrote:
> In functions vpd_sections_init() and vpd_section_init(), iounmap() is
> used to unmap memory. However, in these cases, memunmap() is better.
>
> Signed-off-by: Pan Bian <bianpan2016@163.com>
> ---
>  drivers/firmware/google/vpd.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/firmware/google/vpd.c b/drivers/firmware/google/vpd.c
> index 7894572..ac6400f 100644
> --- a/drivers/firmware/google/vpd.c
> +++ b/drivers/firmware/google/vpd.c
> @@ -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.

>         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;

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.

-- 
Dmitry

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web