drm/msm/dpu: Drop unnecessary NULL checks after container_of in dpu_encoder
authorGuenter Roeck <linux@roeck-us.net>
Tue, 25 May 2021 11:29:04 +0000 (04:29 -0700)
committerRob Clark <robdclark@chromium.org>
Wed, 23 Jun 2021 14:33:53 +0000 (07:33 -0700)
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>
Link: https://lore.kernel.org/r/20210525112904.1747066-1-linux@roeck-us.net
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
[DB: fixed patch subject]
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c

index 7f06238..1c04b7c 100644 (file)
@@ -1429,11 +1429,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);
 
@@ -1777,11 +1772,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;