video: ARM CLCD: Use of_address_to_resource()

Message ID 20230319163241.226984-1-robh@kernel.org
State New
Headers
Series video: ARM CLCD: Use of_address_to_resource() |

Commit Message

Rob Herring March 19, 2023, 4:32 p.m. UTC
  Replace of_get_address() and of_translate_address() with single call
to of_address_to_resource(). With this, use ioremap() instead of
of_iomap() which would parse "reg" a second time.

Signed-off-by: Rob Herring <robh@kernel.org>
---
 drivers/video/fbdev/amba-clcd.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
  

Comments

Helge Deller March 19, 2023, 5:27 p.m. UTC | #1
On 3/19/23 17:32, Rob Herring wrote:
> Replace of_get_address() and of_translate_address() with single call
> to of_address_to_resource(). With this, use ioremap() instead of
> of_iomap() which would parse "reg" a second time.
>
> Signed-off-by: Rob Herring <robh@kernel.org>

applied.

Thanks!
Helge


> ---
>   drivers/video/fbdev/amba-clcd.c | 24 +++++++++++++-----------
>   1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
> index f65c96d1394d..1289bfe6e872 100644
> --- a/drivers/video/fbdev/amba-clcd.c
> +++ b/drivers/video/fbdev/amba-clcd.c
> @@ -759,7 +759,7 @@ static int clcdfb_of_vram_setup(struct clcd_fb *fb)
>   {
>   	int err;
>   	struct device_node *memory;
> -	u64 size;
> +	struct resource res;
>
>   	err = clcdfb_of_init_display(fb);
>   	if (err)
> @@ -769,18 +769,20 @@ static int clcdfb_of_vram_setup(struct clcd_fb *fb)
>   	if (!memory)
>   		return -ENODEV;
>
> -	fb->fb.screen_base = of_iomap(memory, 0);
> -	if (!fb->fb.screen_base) {
> -		of_node_put(memory);
> -		return -ENOMEM;
> -	}
>
> -	fb->fb.fix.smem_start = of_translate_address(memory,
> -			of_get_address(memory, 0, &size, NULL));
> -	fb->fb.fix.smem_len = size;
> -	of_node_put(memory);
> +	err = of_address_to_resource(memory, 0, &res);
> +	if (err)
> +		goto out;
>
> -	return 0;
> +	fb->fb.screen_base = ioremap(res.start, resource_size(&res));
> +	if (!fb->fb.screen_base)
> +		goto out;
> +
> +	fb->fb.fix.smem_start = res.start;
> +	fb->fb.fix.smem_len = resource_size(&res);
> +out:
> +	of_node_put(memory);
> +	return err;
>   }
>
>   static int clcdfb_of_vram_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
  

Patch

diff --git a/drivers/video/fbdev/amba-clcd.c b/drivers/video/fbdev/amba-clcd.c
index f65c96d1394d..1289bfe6e872 100644
--- a/drivers/video/fbdev/amba-clcd.c
+++ b/drivers/video/fbdev/amba-clcd.c
@@ -759,7 +759,7 @@  static int clcdfb_of_vram_setup(struct clcd_fb *fb)
 {
 	int err;
 	struct device_node *memory;
-	u64 size;
+	struct resource res;
 
 	err = clcdfb_of_init_display(fb);
 	if (err)
@@ -769,18 +769,20 @@  static int clcdfb_of_vram_setup(struct clcd_fb *fb)
 	if (!memory)
 		return -ENODEV;
 
-	fb->fb.screen_base = of_iomap(memory, 0);
-	if (!fb->fb.screen_base) {
-		of_node_put(memory);
-		return -ENOMEM;
-	}
 
-	fb->fb.fix.smem_start = of_translate_address(memory,
-			of_get_address(memory, 0, &size, NULL));
-	fb->fb.fix.smem_len = size;
-	of_node_put(memory);
+	err = of_address_to_resource(memory, 0, &res);
+	if (err)
+		goto out;
 
-	return 0;
+	fb->fb.screen_base = ioremap(res.start, resource_size(&res));
+	if (!fb->fb.screen_base)
+		goto out;
+
+	fb->fb.fix.smem_start = res.start;
+	fb->fb.fix.smem_len = resource_size(&res);
+out:
+	of_node_put(memory);
+	return err;
 }
 
 static int clcdfb_of_vram_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)