]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/msm/dp: Drop unnecessary NULL checks after container_of
authorGuenter Roeck <linux@roeck-us.net>
Tue, 25 May 2021 03:20:33 +0000 (20:20 -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 check on the result of container_of() is therefore unnecessary
and misleading. Remove it.

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
...+>

While at it, remove unused but assigned variable hpd in
dp_display_usbpd_attention_cb().

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Link: https://lore.kernel.org/r/20210525032033.453143-1-linux@roeck-us.net
Reviewed-by: Abhinav Kumar <abhinavk@codeaurora.org>
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Rob Clark <robdclark@chromium.org>
drivers/gpu/drm/msm/dp/dp_display.c

index f2079732f697d8e1a10d07fd8eb9a43c94e27258..95ea8155f1ded5ad878ae595338460e3db6524d2 100644 (file)
@@ -208,10 +208,6 @@ static int dp_display_bind(struct device *dev, struct device *master,
 
        dp = container_of(g_dp_display,
                        struct dp_display_private, dp_display);
-       if (!dp) {
-               DRM_ERROR("DP driver bind failed. Invalid driver data\n");
-               return -EINVAL;
-       }
 
        dp->dp_display.drm_dev = drm;
        priv = drm->dev_private;
@@ -252,10 +248,6 @@ static void dp_display_unbind(struct device *dev, struct device *master,
 
        dp = container_of(g_dp_display,
                        struct dp_display_private, dp_display);
-       if (!dp) {
-               DRM_ERROR("Invalid DP driver data\n");
-               return;
-       }
 
        dp_power_client_deinit(dp->power);
        dp_aux_unregister(dp->aux);
@@ -412,11 +404,6 @@ static int dp_display_usbpd_configure_cb(struct device *dev)
 
        dp = container_of(g_dp_display,
                        struct dp_display_private, dp_display);
-       if (!dp) {
-               DRM_ERROR("no driver data found\n");
-               rc = -ENODEV;
-               goto end;
-       }
 
        dp_display_host_init(dp, false);
 
@@ -438,11 +425,6 @@ static int dp_display_usbpd_disconnect_cb(struct device *dev)
 
        dp = container_of(g_dp_display,
                        struct dp_display_private, dp_display);
-       if (!dp) {
-               DRM_ERROR("no driver data found\n");
-               rc = -ENODEV;
-               return rc;
-       }
 
        dp_add_event(dp, EV_USER_NOTIFICATION, false, 0);
 
@@ -511,10 +493,6 @@ static int dp_display_usbpd_attention_cb(struct device *dev)
 
        dp = container_of(g_dp_display,
                        struct dp_display_private, dp_display);
-       if (!dp) {
-               DRM_ERROR("no driver data found\n");
-               return -ENODEV;
-       }
 
        /* check for any test request issued by sink */
        rc = dp_link_process_request(dp->link);