linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/msm/disp/dpu1/dpu_encoder: Drop unnecessary NULL checks after container_of
@ 2021-05-25 11:29 Guenter Roeck
  2021-05-25 16:18 ` Bjorn Andersson
  2021-05-26  1:00 ` Dmitry Baryshkov
  0 siblings, 2 replies; 3+ messages in thread
From: Guenter Roeck @ 2021-05-25 11:29 UTC (permalink / raw)
  To: Rob Clark
  Cc: Sean Paul, David Airlie, Daniel Vetter, linux-arm-msm, dri-devel,
	freedreno, linux-kernel, Guenter Roeck

The result of container_of() operations is never NULL unless the embedded
element is the first element of the structure. This is not the case here.
The NULL checks on the result of container_of() are therefore unnecessary
and misleading. Remove them.

This change was made automatically with the following Coccinelle script.

@@
type t;
identifier v;
statement s;
@@

<+...
(
  t v = container_of(...);
|
  v = container_of(...);
)
  ...
  when != v
- if (\( !v \| v == NULL \) ) s
...+>

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 10 ----------
 1 file changed, 10 deletions(-)

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
index 8d942052db8a..a573fe211375 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
@@ -1453,11 +1453,6 @@ static void dpu_encoder_off_work(struct work_struct *work)
 	struct dpu_encoder_virt *dpu_enc = container_of(work,
 			struct dpu_encoder_virt, delayed_off_work.work);
 
-	if (!dpu_enc) {
-		DPU_ERROR("invalid dpu encoder\n");
-		return;
-	}
-
 	dpu_encoder_resource_control(&dpu_enc->base,
 						DPU_ENC_RC_EVENT_ENTER_IDLE);
 
@@ -1797,11 +1792,6 @@ static void dpu_encoder_vsync_event_work_handler(struct kthread_work *work)
 			struct dpu_encoder_virt, vsync_event_work);
 	ktime_t wakeup_time;
 
-	if (!dpu_enc) {
-		DPU_ERROR("invalid dpu encoder\n");
-		return;
-	}
-
 	if (dpu_encoder_vsync_time(&dpu_enc->base, &wakeup_time))
 		return;
 
-- 
2.25.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm/disp/dpu1/dpu_encoder: Drop unnecessary NULL checks after container_of
  2021-05-25 11:29 [PATCH] drm/msm/disp/dpu1/dpu_encoder: Drop unnecessary NULL checks after container_of Guenter Roeck
@ 2021-05-25 16:18 ` Bjorn Andersson
  2021-05-26  1:00 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Bjorn Andersson @ 2021-05-25 16:18 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Rob Clark, Sean Paul, David Airlie, Daniel Vetter, linux-arm-msm,
	dri-devel, freedreno, linux-kernel

On Tue 25 May 06:29 CDT 2021, Guenter Roeck wrote:

> The result of container_of() operations is never NULL unless the embedded
> element is the first element of the structure. This is not the case here.
> The NULL checks on the result of container_of() are therefore unnecessary
> and misleading. Remove them.
> 
> This change was made automatically with the following Coccinelle script.
> 
> @@
> type t;
> identifier v;
> statement s;
> @@
> 
> <+...
> (
>   t v = container_of(...);
> |
>   v = container_of(...);
> )
>   ...
>   when != v
> - if (\( !v \| v == NULL \) ) s
> ...+>
> 

Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 10 ----------
>  1 file changed, 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index 8d942052db8a..a573fe211375 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -1453,11 +1453,6 @@ static void dpu_encoder_off_work(struct work_struct *work)
>  	struct dpu_encoder_virt *dpu_enc = container_of(work,
>  			struct dpu_encoder_virt, delayed_off_work.work);
>  
> -	if (!dpu_enc) {
> -		DPU_ERROR("invalid dpu encoder\n");
> -		return;
> -	}
> -
>  	dpu_encoder_resource_control(&dpu_enc->base,
>  						DPU_ENC_RC_EVENT_ENTER_IDLE);
>  
> @@ -1797,11 +1792,6 @@ static void dpu_encoder_vsync_event_work_handler(struct kthread_work *work)
>  			struct dpu_encoder_virt, vsync_event_work);
>  	ktime_t wakeup_time;
>  
> -	if (!dpu_enc) {
> -		DPU_ERROR("invalid dpu encoder\n");
> -		return;
> -	}
> -
>  	if (dpu_encoder_vsync_time(&dpu_enc->base, &wakeup_time))
>  		return;
>  
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/msm/disp/dpu1/dpu_encoder: Drop unnecessary NULL checks after container_of
  2021-05-25 11:29 [PATCH] drm/msm/disp/dpu1/dpu_encoder: Drop unnecessary NULL checks after container_of Guenter Roeck
  2021-05-25 16:18 ` Bjorn Andersson
@ 2021-05-26  1:00 ` Dmitry Baryshkov
  1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Baryshkov @ 2021-05-26  1:00 UTC (permalink / raw)
  To: Guenter Roeck, Rob Clark
  Cc: Sean Paul, David Airlie, Daniel Vetter, linux-arm-msm, dri-devel,
	freedreno, linux-kernel

On 25/05/2021 14:29, Guenter Roeck wrote:
> The result of container_of() operations is never NULL unless the embedded
> element is the first element of the structure. This is not the case here.
> The NULL checks on the result of container_of() are therefore unnecessary
> and misleading. Remove them.
> 
> This change was made automatically with the following Coccinelle script.
> 
> @@
> type t;
> identifier v;
> statement s;
> @@
> 
> <+...
> (
>    t v = container_of(...);
> |
>    v = container_of(...);
> )
>    ...
>    when != v
> - if (\( !v \| v == NULL \) ) s
> ...+>
> 
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>


Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>

> ---
>   drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 10 ----------
>   1 file changed, 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> index 8d942052db8a..a573fe211375 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c
> @@ -1453,11 +1453,6 @@ static void dpu_encoder_off_work(struct work_struct *work)
>   	struct dpu_encoder_virt *dpu_enc = container_of(work,
>   			struct dpu_encoder_virt, delayed_off_work.work);
>   
> -	if (!dpu_enc) {
> -		DPU_ERROR("invalid dpu encoder\n");
> -		return;
> -	}
> -
>   	dpu_encoder_resource_control(&dpu_enc->base,
>   						DPU_ENC_RC_EVENT_ENTER_IDLE);
>   
> @@ -1797,11 +1792,6 @@ static void dpu_encoder_vsync_event_work_handler(struct kthread_work *work)
>   			struct dpu_encoder_virt, vsync_event_work);
>   	ktime_t wakeup_time;
>   
> -	if (!dpu_enc) {
> -		DPU_ERROR("invalid dpu encoder\n");
> -		return;
> -	}
> -
>   	if (dpu_encoder_vsync_time(&dpu_enc->base, &wakeup_time))
>   		return;
>   
> 


-- 
With best wishes
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-26  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-25 11:29 [PATCH] drm/msm/disp/dpu1/dpu_encoder: Drop unnecessary NULL checks after container_of Guenter Roeck
2021-05-25 16:18 ` Bjorn Andersson
2021-05-26  1:00 ` Dmitry Baryshkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).