msm_dp_display_mode_valid() and msm_edp_bridge_mode_valid() return enum drm_mode_status, yet both returned -EINVAL (-22) on an invalid parameter check for !dp || !mode_pclk_khz || !dp->connector.
Today neither check can trigger because drm_mode_validate_basic() rejects mode->clock == 0 before bridge .mode_valid() runs, and dp and dp->connector are initialized before mode validation. Keep the guard in the shared msm_dp_display_mode_valid() helper but return MODE_ERROR instead of -EINVAL, and drop the unreachable check from the static msm_edp_bridge_mode_valid() callback. Found with Clang's -Wassign-enum on an x86_64 allyesconfig build; Gemini helped analyze the callers and prepare the patch and commit message. Compile-tested on dp_display.o and dp_drm.o with LLVM=1 W=1 (-Werror) and -Wassign-enum; not runtime-tested because Qualcomm Snapdragon DP/eDP hardware is not available. Signed-off-by: Ian Rogers <[email protected]> --- Notes: v2: - Return MODE_ERROR instead of MODE_BAD in msm_dp_display_mode_valid() to match the "invalid params" error (Guodong Xu). - Drop the dead if (!dp || !mode_pclk_khz || !dp->connector) check in the static msm_edp_bridge_mode_valid() callback and drop Fixes tags since the checks are currently unreachable (Guodong Xu). v1: https://lore.kernel.org/r/[email protected] drivers/gpu/drm/msm/dp/dp_display.c | 2 +- drivers/gpu/drm/msm/dp/dp_drm.c | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/dp/dp_display.c b/drivers/gpu/drm/msm/dp/dp_display.c index c0c150e2c575..e01a43b17ca3 100644 --- a/drivers/gpu/drm/msm/dp/dp_display.c +++ b/drivers/gpu/drm/msm/dp/dp_display.c @@ -759,7 +759,7 @@ enum drm_mode_status msm_dp_display_mode_valid(struct msm_dp *dp, if (!dp || !mode_pclk_khz || !dp->connector) { DRM_ERROR("invalid params\n"); - return -EINVAL; + return MODE_ERROR; } msm_dp_display = container_of(dp, struct msm_dp_display_private, msm_dp_display); diff --git a/drivers/gpu/drm/msm/dp/dp_drm.c b/drivers/gpu/drm/msm/dp/dp_drm.c index c1e4147bfef1..c21e2bf4f22c 100644 --- a/drivers/gpu/drm/msm/dp/dp_drm.c +++ b/drivers/gpu/drm/msm/dp/dp_drm.c @@ -249,11 +249,6 @@ static enum drm_mode_status msm_edp_bridge_mode_valid(struct drm_bridge *bridge, dp = to_dp_bridge(bridge)->msm_dp_display; - if (!dp || !mode_pclk_khz || !dp->connector) { - DRM_ERROR("invalid params\n"); - return -EINVAL; - } - if (msm_dp_wide_bus_available(dp)) mode_pclk_khz /= 2; -- 2.56.1.839.g22a8290db9-goog
