Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp5581071img; Wed, 27 Mar 2019 11:05:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqydwa23IOvaHSo5YxH4Td7zwCV8OnWnI3rlErOtSOotLJhCc+RaLnq6O8N0FOc88k/iGlwA X-Received: by 2002:a17:902:e101:: with SMTP id cc1mr26445157plb.129.1553709952484; Wed, 27 Mar 2019 11:05:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553709952; cv=none; d=google.com; s=arc-20160816; b=kku+DKw6ZF9J2LIbYyIXPONB5pgdizyygmnM7dM8AU0hl3AJ7bAFLOypKs/R0SDgs3 zfi9o8KsUHQ+J8hIdVJPtEjrCi9YWbK3MQDvzz1DcAILc3Xe4MlmPl28+UPUE6afsNWl gx3QnKwFb2yyLYRkcaJlH1yFWL71Gsd+s54/CFes8f4cXEeje4NPLRZuW34rDO+OAkLQ R38Jks1QQdEJTNa55X0uj8DmLitRHNPzInFxhhcZwde/j/qz14nrIiPwW8jEsiZ7orIw CCP/KIECtlrZdXliySt3sP0FWCZ6LKMvaeox3DTLVNHY83rmVyFcGCqBZsilnNbRj9GA /M+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QhqSb7W5TQ2x1+n6FPHJIfMYvIMzvE+7EvQxX9PKSAc=; b=g8zdLorLBOF7nxiokBQJuqj8NFPiHtKo3Kkgg1d/vloSSWmyPQ0YaQ0oQ1Owt9RMe/ A+hIq6QAt3iFsgQIwVUOc/+UkanGNtQw3jtvSI4FWgFQj+9KE+ohtFY3S/Re9BsjG1lk FHEt5XkF++nAiJz8zCm2aoLOHrk3W74r17UXl89463iS9mKxoYy0wmSUk6u+HDgQ8YA2 mMWSasGsWRd1cm+zVbPuq3UGaHqv9AeW3Gw3GQfMMCUpwmmIzzWI5yGPTOxLMjdQ3vhB 7P8ZCq3Kuqox2I+lLycWe5BA2HK6OcfKFD/Jm5qEZMA0lCFKGvhAdVX43mlHD3yVcCQj ba1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YsaHK2IC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si18414473pfe.72.2019.03.27.11.05.36; Wed, 27 Mar 2019 11:05:52 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=YsaHK2IC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733185AbfC0SEM (ORCPT + 99 others); Wed, 27 Mar 2019 14:04:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:44664 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733148AbfC0SEG (ORCPT ); Wed, 27 Mar 2019 14:04:06 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E160E2063F; Wed, 27 Mar 2019 18:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553709845; bh=PS9cLOtuEHtVrC6GCM+3U4hVfZYr9gBjv0rFFMGxhio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YsaHK2ICNwF2Gc9G4ZSxU/M7eFvge+QjAPjSuPN2z3SCsVUOslSf832wBL+djO0zK iyJD2C1QX1ZCXxmHP6mGlEhOpFxheODPEL3hgfWKebYRp7GXF+Bf3APXtZyMlSjvpo pHYiP0LXHSV/X5FVd8tsDPiekman9vqjt3He8E3Y= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Nathan Chancellor , Alex Deucher , Sasha Levin , amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.0 070/262] drm/amd/display: Pass app_tf by value rather than by reference Date: Wed, 27 Mar 2019 13:58:45 -0400 Message-Id: <20190327180158.10245-70-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190327180158.10245-1-sashal@kernel.org> References: <20190327180158.10245-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor [ Upstream commit 672e78cab819ebe31e3b9b8abac367be8a110472 ] Clang warns when an expression that equals zero is used as a null pointer constant (in lieu of NULL): drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm.c:4435:3: warning: expression which evaluates to zero treated as a null pointer constant of type 'const enum color_transfer_func *' [-Wnon-literal-null-conversion] TRANSFER_FUNC_UNKNOWN, ^~~~~~~~~~~~~~~~~~~~~ 1 warning generated. This warning is caused by commit bb47de736661 ("drm/amdgpu: Set FreeSync state using drm VRR properties") and it could be solved by using NULL instead of TRANSFER_FUNC_UNKNOWN or casting TRANSFER_FUNC_UNKNOWN as a pointer. However, after looking into it, there doesn't appear to be a good reason to pass app_tf by reference as it is never mutated along the way. This is the only code path in which app_tf is used: mod_freesync_build_vrr_infopacket -> build_vrr_infopacket_v2 -> build_vrr_infopacket_fs2_data Neither mod_freesync_build_vrr_infopacket or build_vrr_infopacket_v2 modify app_tf's value and build_vrr_infopacket_fs2_data expects just the value so we can avoid dereferencing anything by just passing in app_tf's value to mod_freesync_build_vrr_infopacket and build_vrr_infopacket_v2. There is no functional change because build_vrr_infopacket_fs2_data doesn't do anything if TRANSFER_FUNC_UNKNOWN is passed to it, the same as not calling build_vrr_infopacket_fs2_data at all like before this change when NULL was used for app_tf. Reviewed-by: Harry Wentland Signed-off-by: Nathan Chancellor Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/display/modules/freesync/freesync.c | 7 +++---- drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index 1544ed3f1747..945e845f3358 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c @@ -656,7 +656,7 @@ static void build_vrr_infopacket_v1(enum signal_type signal, static void build_vrr_infopacket_v2(enum signal_type signal, const struct mod_vrr_params *vrr, - const enum color_transfer_func *app_tf, + enum color_transfer_func app_tf, struct dc_info_packet *infopacket) { unsigned int payload_size = 0; @@ -664,8 +664,7 @@ static void build_vrr_infopacket_v2(enum signal_type signal, build_vrr_infopacket_header_v2(signal, infopacket, &payload_size); build_vrr_infopacket_data(vrr, infopacket); - if (app_tf != NULL) - build_vrr_infopacket_fs2_data(*app_tf, infopacket); + build_vrr_infopacket_fs2_data(app_tf, infopacket); build_vrr_infopacket_checksum(&payload_size, infopacket); @@ -676,7 +675,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, const struct dc_stream_state *stream, const struct mod_vrr_params *vrr, enum vrr_packet_type packet_type, - const enum color_transfer_func *app_tf, + enum color_transfer_func app_tf, struct dc_info_packet *infopacket) { /* SPD info packet for FreeSync */ diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h index 949a8b62aa98..063af6258fd9 100644 --- a/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h +++ b/drivers/gpu/drm/amd/display/modules/inc/mod_freesync.h @@ -145,7 +145,7 @@ void mod_freesync_build_vrr_infopacket(struct mod_freesync *mod_freesync, const struct dc_stream_state *stream, const struct mod_vrr_params *vrr, enum vrr_packet_type packet_type, - const enum color_transfer_func *app_tf, + enum color_transfer_func app_tf, struct dc_info_packet *infopacket); void mod_freesync_build_vrr_params(struct mod_freesync *mod_freesync, -- 2.19.1