diff mbox

[04/27] drm/etnaviv: fold __etnaviv_gem_new into caller

Message ID 20171201103624.6565-5-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show

Commit Message

Lucas Stach Dec. 1, 2017, 10:36 a.m. UTC
This function has only one caller and it isn't expected that there will
be any more in the future. Folding this function into the caller is
helping the readability.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 26 +++++---------------------
 1 file changed, 5 insertions(+), 21 deletions(-)

Comments

Philipp Zabel Dec. 1, 2017, 11:34 a.m. UTC | #1
On Fri, 2017-12-01 at 11:36 +0100, Lucas Stach wrote:
> This function has only one caller and it isn't expected that there will
> be any more in the future. Folding this function into the caller is
> helping the readability.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp
Christian Gmeiner Dec. 11, 2017, 10:47 a.m. UTC | #2
2017-12-01 11:36 GMT+01:00 Lucas Stach <l.stach@pengutronix.de>:
> This function has only one caller and it isn't expected that there will
> be any more in the future. Folding this function into the caller is
> helping the readability.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c | 26 +++++---------------------
>  1 file changed, 5 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index 555a331c51a9..f75105b7e1a4 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -643,8 +643,9 @@ static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags,
>         return 0;
>  }
>
> -static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
> -               u32 size, u32 flags)
> +/* convenience method to construct a GEM buffer object, and userspace handle */
> +int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
> +       u32 size, u32 flags, u32 *handle)
>  {
>         struct drm_gem_object *obj = NULL;
>         int ret;
> @@ -665,7 +666,7 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
>                 /*
>                  * Our buffers are kept pinned, so allocating them
>                  * from the MOVABLE zone is a really bad idea, and
> -                * conflicts with CMA.  See coments above new_inode()
> +                * conflicts with CMA. See comments above new_inode()
>                  * why this is required _and_ expected if you're
>                  * going to pin these pages.
>                  */
> @@ -677,24 +678,6 @@ static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
>         if (ret)
>                 goto fail;
>
> -       return obj;
> -
> -fail:
> -       drm_gem_object_put_unlocked(obj);
> -       return ERR_PTR(ret);
> -}
> -
> -/* convenience method to construct a GEM buffer object, and userspace handle */
> -int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
> -               u32 size, u32 flags, u32 *handle)
> -{
> -       struct drm_gem_object *obj;
> -       int ret;
> -
> -       obj = __etnaviv_gem_new(dev, size, flags);
> -       if (IS_ERR(obj))
> -               return PTR_ERR(obj);
> -
>         ret = etnaviv_gem_obj_add(dev, obj);
>         if (ret < 0) {
>                 drm_gem_object_put_unlocked(obj);
> @@ -704,6 +687,7 @@ int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
>         ret = drm_gem_handle_create(file, obj, handle);
>
>         /* drop reference from allocate - handle holds it now */
> +fail:
>         drm_gem_object_put_unlocked(obj);
>
>         return ret;
> --
> 2.11.0
>
diff mbox

Patch

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 555a331c51a9..f75105b7e1a4 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -643,8 +643,9 @@  static int etnaviv_gem_new_impl(struct drm_device *dev, u32 size, u32 flags,
 	return 0;
 }
 
-static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
-		u32 size, u32 flags)
+/* convenience method to construct a GEM buffer object, and userspace handle */
+int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
+	u32 size, u32 flags, u32 *handle)
 {
 	struct drm_gem_object *obj = NULL;
 	int ret;
@@ -665,7 +666,7 @@  static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
 		/*
 		 * Our buffers are kept pinned, so allocating them
 		 * from the MOVABLE zone is a really bad idea, and
-		 * conflicts with CMA.  See coments above new_inode()
+		 * conflicts with CMA. See comments above new_inode()
 		 * why this is required _and_ expected if you're
 		 * going to pin these pages.
 		 */
@@ -677,24 +678,6 @@  static struct drm_gem_object *__etnaviv_gem_new(struct drm_device *dev,
 	if (ret)
 		goto fail;
 
-	return obj;
-
-fail:
-	drm_gem_object_put_unlocked(obj);
-	return ERR_PTR(ret);
-}
-
-/* convenience method to construct a GEM buffer object, and userspace handle */
-int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
-		u32 size, u32 flags, u32 *handle)
-{
-	struct drm_gem_object *obj;
-	int ret;
-
-	obj = __etnaviv_gem_new(dev, size, flags);
-	if (IS_ERR(obj))
-		return PTR_ERR(obj);
-
 	ret = etnaviv_gem_obj_add(dev, obj);
 	if (ret < 0) {
 		drm_gem_object_put_unlocked(obj);
@@ -704,6 +687,7 @@  int etnaviv_gem_new_handle(struct drm_device *dev, struct drm_file *file,
 	ret = drm_gem_handle_create(file, obj, handle);
 
 	/* drop reference from allocate - handle holds it now */
+fail:
 	drm_gem_object_put_unlocked(obj);
 
 	return ret;