[i-g-t,v6,01/10] igt: fb: Refactor dumb buffer allocation path

Submitted by Maxime Ripard on Feb. 8, 2019, 1:18 p.m.

Details

Message ID 20190208131901.1400-2-maxime.ripard@bootlin.com
State New
Series "igt: chamelium: Test YUV buffers using the Chamelium"
Headers show

Commit Message

Maxime Ripard Feb. 8, 2019, 1:18 p.m.
The else condition is not needed, since all the other conditions return
when they are done.

Move the KMS dumb buffer allocation outside of the outer else condition,
this will also allow to ease later changes.

Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
 lib/igt_fb.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

Patch hide | download patch | download mbox

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 5d8c187a9ac9..c61e6805ff7a 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -559,15 +559,14 @@  static int create_bo_for_fb(struct igt_fb *fb)
 			igt_require(driver_has_gem_api);
 			return -EINVAL;
 		}
-	} else {
-		fb->is_dumb = true;
-
-		fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height,
-						     fb->plane_bpp[0],
-						     &fb->strides[0], &fb->size);
-
-		return fb->gem_handle;
 	}
+
+	fb->is_dumb = true;
+	fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height,
+					     fb->plane_bpp[0],
+					     &fb->strides[0], &fb->size);
+
+	return fb->gem_handle;
 }
 
 /**

Comments

Deepak Singh Rawat Feb. 8, 2019, 4:52 p.m.
Hi Maxime,

Thanks for doing this.

Reviewed-by: Deepak Rawat <drawat@vmware.com>

On Fri, 2019-02-08 at 14:18 +0100, Maxime Ripard wrote:
> The else condition is not needed, since all the other conditions
> return
> when they are done.
> 
> Move the KMS dumb buffer allocation outside of the outer else
> condition,
> this will also allow to ease later changes.
> 
> Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>  lib/igt_fb.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 5d8c187a9ac9..c61e6805ff7a 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -559,15 +559,14 @@ static int create_bo_for_fb(struct igt_fb *fb)
>  			igt_require(driver_has_gem_api);
>  			return -EINVAL;
>  		}
> -	} else {
> -		fb->is_dumb = true;
> -
> -		fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb-
> >height,
> -						     fb->plane_bpp[0],
> -						     &fb->strides[0],
> &fb->size);
> -
> -		return fb->gem_handle;
>  	}
> +
> +	fb->is_dumb = true;
> +	fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height,
> +					     fb->plane_bpp[0],
> +					     &fb->strides[0], &fb-
> >size);
> +
> +	return fb->gem_handle;
>  }
>  
>  /**
Lyude Paul Feb. 8, 2019, 5:52 p.m.
Reviewed-by: Lyude Paul <lyude@redhat.com>

On Fri, 2019-02-08 at 14:18 +0100, Maxime Ripard wrote:
> The else condition is not needed, since all the other conditions return
> when they are done.
> 
> Move the KMS dumb buffer allocation outside of the outer else condition,
> this will also allow to ease later changes.
> 
> Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
> ---
>  lib/igt_fb.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)
> 
> diff --git a/lib/igt_fb.c b/lib/igt_fb.c
> index 5d8c187a9ac9..c61e6805ff7a 100644
> --- a/lib/igt_fb.c
> +++ b/lib/igt_fb.c
> @@ -559,15 +559,14 @@ static int create_bo_for_fb(struct igt_fb *fb)
>  			igt_require(driver_has_gem_api);
>  			return -EINVAL;
>  		}
> -	} else {
> -		fb->is_dumb = true;
> -
> -		fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb-
> >height,
> -						     fb->plane_bpp[0],
> -						     &fb->strides[0], &fb-
> >size);
> -
> -		return fb->gem_handle;
>  	}
> +
> +	fb->is_dumb = true;
> +	fb->gem_handle = kmstest_dumb_create(fd, fb->width, fb->height,
> +					     fb->plane_bpp[0],
> +					     &fb->strides[0], &fb->size);
> +
> +	return fb->gem_handle;
>  }
>  
>  /**