From patchwork Mon Jun 24 03:11:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiapeng Chong X-Patchwork-Id: 13708878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CD086C27C4F for ; Mon, 24 Jun 2024 03:12:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7B59210E046; Mon, 24 Jun 2024 03:12:09 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="vIfJJrs7"; dkim-atps=neutral Received: from out30-100.freemail.mail.aliyun.com (out30-100.freemail.mail.aliyun.com [115.124.30.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4E15710E046; Mon, 24 Jun 2024 03:12:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1719198723; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=h/k/C2qs1pKcv+sRC2nv2zMOr9MwmxizBcFEz86gVOo=; b=vIfJJrs74daCYzuJYPBgBtiXpu2034gGcur61/mfBsFVk5JSUll2YwbhphqVmymVbLMiDp18CU9E0L6QMZtgTAOLofGBXl8G2YkwWvyXryxGC7JY06UA2+xPGO6Aiq/kfb39RLmkXA6oUsRsTsad4jYgn34zMoG28n2ZZshKUjU= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R211e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=maildocker-contentspam033045075189; MF=jiapeng.chong@linux.alibaba.com; NM=1; PH=DS; RN=13; SR=0; TI=SMTPD_---0W916qKp_1719198719; Received: from localhost(mailfrom:jiapeng.chong@linux.alibaba.com fp:SMTPD_---0W916qKp_1719198719) by smtp.aliyun-inc.com; Mon, 24 Jun 2024 11:12:02 +0800 From: Jiapeng Chong To: harry.wentland@amd.com Cc: sunpeng.li@amd.com, Rodrigo.Siqueira@amd.com, alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@gmail.com, daniel@ffwll.ch, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Jiapeng Chong , Abaci Robot Subject: [PATCH] drm/amd/display: Use ARRAY_SIZE for array length Date: Mon, 24 Jun 2024 11:11:58 +0800 Message-Id: <20240624031158.98502-1-jiapeng.chong@linux.alibaba.com> X-Mailer: git-send-email 2.20.1.7.g153144c MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Use of macro ARRAY_SIZE to calculate array size minimizes the redundant code and improves code reusability. ./drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c:164:45-46: WARNING: Use ARRAY_SIZE. ./drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c:183:47-48: WARNING: Use ARRAY_SIZE. ./drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c:237:45-46: WARNING: Use ARRAY_SIZE. ./drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c:257:47-48: WARNING: Use ARRAY_SIZE. Reported-by: Abaci Robot Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=9405 Signed-off-by: Jiapeng Chong --- drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c index 1b2df97226a3..7ecf76aea950 100644 --- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c +++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c @@ -161,8 +161,7 @@ static enum mod_hdcp_status read(struct mod_hdcp *hdcp, return MOD_HDCP_STATUS_DDC_FAILURE; if (is_dp_hdcp(hdcp)) { - int num_dpcd_addrs = sizeof(hdcp_dpcd_addrs) / - sizeof(hdcp_dpcd_addrs[0]); + int num_dpcd_addrs = ARRAY_SIZE(hdcp_dpcd_addrs); if (msg_id >= num_dpcd_addrs) return MOD_HDCP_STATUS_DDC_FAILURE; @@ -180,8 +179,7 @@ static enum mod_hdcp_status read(struct mod_hdcp *hdcp, data_offset += cur_size; } } else { - int num_i2c_offsets = sizeof(hdcp_i2c_offsets) / - sizeof(hdcp_i2c_offsets[0]); + int num_i2c_offsets = ARRAY_SIZE(hdcp_i2c_offsets); if (msg_id >= num_i2c_offsets) return MOD_HDCP_STATUS_DDC_FAILURE; @@ -234,8 +232,7 @@ static enum mod_hdcp_status write(struct mod_hdcp *hdcp, return MOD_HDCP_STATUS_DDC_FAILURE; if (is_dp_hdcp(hdcp)) { - int num_dpcd_addrs = sizeof(hdcp_dpcd_addrs) / - sizeof(hdcp_dpcd_addrs[0]); + int num_dpcd_addrs = ARRAY_SIZE(hdcp_dpcd_addrs); if (msg_id >= num_dpcd_addrs) return MOD_HDCP_STATUS_DDC_FAILURE; @@ -254,8 +251,7 @@ static enum mod_hdcp_status write(struct mod_hdcp *hdcp, data_offset += cur_size; } } else { - int num_i2c_offsets = sizeof(hdcp_i2c_offsets) / - sizeof(hdcp_i2c_offsets[0]); + int num_i2c_offsets = ARRAY_SIZE(hdcp_i2c_offsets); if (msg_id >= num_i2c_offsets) return MOD_HDCP_STATUS_DDC_FAILURE;