diff mbox

[v3] drm/ttm: Delete an unnecessary check before the function call "ttm_tt_destroy"

Message ID 54338f58-830c-a8b4-4554-5d4459bcd321@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring July 18, 2016, 2:10 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 18 Jul 2016 16:06:18 +0200

The ttm_tt_destroy() function tests whether its argument is NULL
and then returns immediately. Thus the test around the call is not needed.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Daniel Vetter July 18, 2016, 2:45 p.m. UTC | #1
On Mon, Jul 18, 2016 at 04:10:36PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Mon, 18 Jul 2016 16:06:18 +0200
> 
> The ttm_tt_destroy() function tests whether its argument is NULL
> and then returns immediately. Thus the test around the call is not needed.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

When resending pls describe what changed (and why). Also I'd still like
that smatch included in the commit message.
-Daniel

> ---
>  drivers/gpu/drm/ttm/ttm_bo.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
> index 39386f5..4e55863 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -146,9 +146,7 @@ static void ttm_bo_release_list(struct kref *list_kref)
>  	BUG_ON(bo->mem.mm_node != NULL);
>  	BUG_ON(!list_empty(&bo->lru));
>  	BUG_ON(!list_empty(&bo->ddestroy));
> -
> -	if (bo->ttm)
> -		ttm_tt_destroy(bo->ttm);
> +	ttm_tt_destroy(bo->ttm);
>  	atomic_dec(&bo->glob->bo_count);
>  	if (bo->resv == &bo->ttm_resv)
>  		reservation_object_fini(&bo->ttm_resv);
> -- 
> 2.9.2
>
SF Markus Elfring July 18, 2016, 5 p.m. UTC | #2
> When resending pls describe what changed (and why).

v3: A bit of reformatting with current software

v2: Broken patch where I managed to delete a "t" too much in a source code
    line somehow.

v1: See also a similar update suggestion
    https://lkml.org/lkml/2015/11/16/416


Would you like to pick such a software adjustment up?

Regards,
Markus
Geert Uytterhoeven July 19, 2016, 8:14 a.m. UTC | #3
On Mon, Jul 18, 2016 at 4:45 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> On Mon, Jul 18, 2016 at 04:10:36PM +0200, SF Markus Elfring wrote:
>> From: Markus Elfring <elfring@users.sourceforge.net>
>> Date: Mon, 18 Jul 2016 16:06:18 +0200
>>
>> The ttm_tt_destroy() function tests whether its argument is NULL
>> and then returns immediately. Thus the test around the call is not needed.
>>
>> This issue was detected by using the Coccinelle software.
>>
>> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
>
> When resending pls describe what changed (and why). Also I'd still like
> that smatch included in the commit message.

A similar change was made in drm-next, causing a merge conflict
between the drm-next and drm-misc trees.

commit 4279cb1423d96e53b6b98ae9f2b41003b013a31f
Author: Christian König <christian.koenig@amd.com>
Date:   Mon Jun 6 10:17:51 2016 +0200

    drm/ttm: remove NULL checks when calling ttm_tt_destroy

    The function is a no-op with a NULL pointer.

    Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
    Signed-off-by: Christian König <christian.koenig@amd.com>
    Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Daniel Vetter July 19, 2016, 8:21 a.m. UTC | #4
On Tue, Jul 19, 2016 at 10:14:07AM +0200, Geert Uytterhoeven wrote:
> On Mon, Jul 18, 2016 at 4:45 PM, Daniel Vetter <daniel@ffwll.ch> wrote:
> > On Mon, Jul 18, 2016 at 04:10:36PM +0200, SF Markus Elfring wrote:
> >> From: Markus Elfring <elfring@users.sourceforge.net>
> >> Date: Mon, 18 Jul 2016 16:06:18 +0200
> >>
> >> The ttm_tt_destroy() function tests whether its argument is NULL
> >> and then returns immediately. Thus the test around the call is not needed.
> >>
> >> This issue was detected by using the Coccinelle software.
> >>
> >> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> >
> > When resending pls describe what changed (and why). Also I'd still like
> > that smatch included in the commit message.
> 
> A similar change was made in drm-next, causing a merge conflict
> between the drm-next and drm-misc trees.
> 
> commit 4279cb1423d96e53b6b98ae9f2b41003b013a31f
> Author: Christian König <christian.koenig@amd.com>
> Date:   Mon Jun 6 10:17:51 2016 +0200
> 
>     drm/ttm: remove NULL checks when calling ttm_tt_destroy
> 
>     The function is a no-op with a NULL pointer.
> 
>     Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>     Signed-off-by: Christian König <christian.koenig@amd.com>
>     Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

Yeah, realized that too but then drm-misc is a non-rebasing tree now, so
can't take this out.
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 39386f5..4e55863 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -146,9 +146,7 @@  static void ttm_bo_release_list(struct kref *list_kref)
 	BUG_ON(bo->mem.mm_node != NULL);
 	BUG_ON(!list_empty(&bo->lru));
 	BUG_ON(!list_empty(&bo->ddestroy));
-
-	if (bo->ttm)
-		ttm_tt_destroy(bo->ttm);
+	ttm_tt_destroy(bo->ttm);
 	atomic_dec(&bo->glob->bo_count);
 	if (bo->resv == &bo->ttm_resv)
 		reservation_object_fini(&bo->ttm_resv);