From patchwork Thu May 11 01:30:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fengguang Wu X-Patchwork-Id: 9720803 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E52786035D for ; Thu, 11 May 2017 01:31:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F22432862C for ; Thu, 11 May 2017 01:31:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E709928646; Thu, 11 May 2017 01:31:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A1532862C for ; Thu, 11 May 2017 01:31:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D56B36E42C; Thu, 11 May 2017 01:31:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9711989EA3 for ; Thu, 11 May 2017 01:31:05 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP; 10 May 2017 18:31:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,322,1491289200"; d="scan'208";a="967053784" Received: from bee.sh.intel.com (HELO bee) ([10.239.97.14]) by orsmga003.jf.intel.com with ESMTP; 10 May 2017 18:31:01 -0700 Received: from kbuild by bee with local (Exim 4.84_2) (envelope-from ) id 1d8cyJ-0003YE-Vw; Thu, 11 May 2017 09:32:52 +0800 Date: Thu, 11 May 2017 09:30:28 +0800 From: kbuild test robot To: Rex Zhu Subject: [PATCH] drm/amd/powerplay: fix array_size.cocci warnings Message-ID: <20170511013015.GA105227@lkp-hsx02.intel.com> References: <201705110951.RxZmQVbi%fengguang.wu@intel.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <201705110951.RxZmQVbi%fengguang.wu@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: fengguang.wu@intel.com X-SA-Exim-Scanned: No (on bee); SAEximRunCond expanded to false Cc: Alex Deucher , kbuild-all@01.org, dri-devel@lists.freedesktop.org, Hawking Zhang X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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" X-Virus-Scanned: ClamAV using ClamSMTP drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:75:42-43: WARNING: Use ARRAY_SIZE drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:466:22-23: WARNING: Use ARRAY_SIZE drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:468:22-23: WARNING: Use ARRAY_SIZE drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:470:20-21: WARNING: Use ARRAY_SIZE drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:473:22-23: WARNING: Use ARRAY_SIZE drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:475:21-22: WARNING: Use ARRAY_SIZE drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c:477:21-22: WARNING: Use ARRAY_SIZE Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element Semantic patch information: This makes an effort to find cases where ARRAY_SIZE can be used such as where there is a division of sizeof the array by the sizeof its first element or by any indexed element or the element type. It replaces the division of the two sizeofs by ARRAY_SIZE. Generated by: scripts/coccinelle/misc/array_size.cocci CC: Rex Zhu Signed-off-by: Fengguang Wu --- rv_hwmgr.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) --- a/drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c +++ b/drivers/gpu/drm/amd/amdgpu/../powerplay/hwmgr/rv_hwmgr.c @@ -72,7 +72,7 @@ static int rv_init_vq_budget_table(struc { uint32_t table_size, i; struct phm_vq_budgeting_table *ptable; - uint32_t num_entries = (sizeof(rv_vqtable) / sizeof(*rv_vqtable)); + uint32_t num_entries = ARRAY_SIZE(rv_vqtable); if (hwmgr->dyn_state.vq_budgeting_table != NULL) return 0; @@ -463,18 +463,22 @@ static int rv_populate_clock_table(struc &rv_data->clock_table.MemClocks[0]); } else { rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dcefclk, - sizeof(VddDcfClk)/sizeof(*VddDcfClk), &VddDcfClk[0]); + ARRAY_SIZE(VddDcfClk), + &VddDcfClk[0]); rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_socclk, - sizeof(VddSocClk)/sizeof(*VddSocClk), &VddSocClk[0]); + ARRAY_SIZE(VddSocClk), + &VddSocClk[0]); rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_fclk, - sizeof(VddFClk)/sizeof(*VddFClk), &VddFClk[0]); + ARRAY_SIZE(VddFClk), + &VddFClk[0]); } rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dispclk, - sizeof(VddDispClk)/sizeof(*VddDispClk), &VddDispClk[0]); + ARRAY_SIZE(VddDispClk), + &VddDispClk[0]); rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_dppclk, - sizeof(VddDppClk)/sizeof(*VddDppClk), &VddDppClk[0]); + ARRAY_SIZE(VddDppClk), &VddDppClk[0]); rv_get_clock_voltage_dependency_table(hwmgr, &pinfo->vdd_dep_on_phyclk, - sizeof(VddPhyClk)/sizeof(*VddPhyClk), &VddPhyClk[0]); + ARRAY_SIZE(VddPhyClk), &VddPhyClk[0]); return 0; }