From patchwork Thu Sep 21 06:33:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Meyer X-Patchwork-Id: 9965283 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 2F2D86057C for ; Fri, 22 Sep 2017 07:33:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 218D926E69 for ; Fri, 22 Sep 2017 07:33:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 165BF296DB; Fri, 22 Sep 2017 07:33:12 +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 B976529748 for ; Fri, 22 Sep 2017 07:33:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BD28E89F97; Fri, 22 Sep 2017 07:32:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from www17.your-server.de (www17.your-server.de [213.133.104.17]) by gabe.freedesktop.org (Postfix) with ESMTPS id B046889FA9; Thu, 21 Sep 2017 06:43:33 +0000 (UTC) Received: from [95.222.26.195] (helo=olymp) by www17.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1duvCt-0004rc-My; Thu, 21 Sep 2017 08:43:31 +0200 Subject: [PATCH 1/4] drm/amd/powerplay: Cocci spatch "alloc_cast" From: Thomas Meyer To: alexander.deucher@amd.com, christian.koenig@amd.com, airlied@linux.ie, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Mime-Version: 1.0 Message-ID: <1505975570447-1553434828-1-diffsplit-thomas@m3y3r.de> References: <1505975570447-826702259-0-diffsplit-thomas@m3y3r.de> In-Reply-To: <1505975570447-826702259-0-diffsplit-thomas@m3y3r.de> Date: Thu, 21 Sep 2017 08:33:46 +0200 X-Mailer: Evolution 3.22.6-1 X-Authenticated-Sender: thomas@m3y3r.de X-Virus-Scanned: Clear (ClamAV 0.99.2/23858/Thu Sep 21 02:46:36 2017) X-Mailman-Approved-At: Fri, 22 Sep 2017 07:32:36 +0000 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 Remove casting the values returned by memory allocation functions like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc." Found by coccinelle spatch "api/alloc/alloc_cast.cocci" Signed-off-by: Thomas Meyer diff -u -p a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c --- a/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c @@ -291,7 +291,7 @@ static int get_mm_clock_voltage_table( table_size = sizeof(uint32_t) + sizeof(phm_ppt_v1_mm_clock_voltage_dependency_record) * mm_dependency_table->ucNumEntries; - mm_table = (phm_ppt_v1_mm_clock_voltage_dependency_table *) + mm_table = kzalloc(table_size, GFP_KERNEL); if (!mm_table) @@ -519,7 +519,7 @@ static int get_socclk_voltage_dependency sizeof(phm_ppt_v1_clock_voltage_dependency_record) * clk_dep_table->ucNumEntries; - clk_table = (phm_ppt_v1_clock_voltage_dependency_table *) + clk_table = kzalloc(table_size, GFP_KERNEL); if (!clk_table) @@ -554,7 +554,7 @@ static int get_mclk_voltage_dependency_t sizeof(phm_ppt_v1_clock_voltage_dependency_record) * mclk_dep_table->ucNumEntries; - mclk_table = (phm_ppt_v1_clock_voltage_dependency_table *) + mclk_table = kzalloc(table_size, GFP_KERNEL); if (!mclk_table) @@ -596,7 +596,7 @@ static int get_gfxclk_voltage_dependency sizeof(phm_ppt_v1_clock_voltage_dependency_record) * clk_dep_table->ucNumEntries; - clk_table = (struct phm_ppt_v1_clock_voltage_dependency_table *) + clk_table = kzalloc(table_size, GFP_KERNEL); if (!clk_table) @@ -663,7 +663,7 @@ static int get_pix_clk_voltage_dependenc sizeof(phm_ppt_v1_clock_voltage_dependency_record) * clk_dep_table->ucNumEntries; - clk_table = (struct phm_ppt_v1_clock_voltage_dependency_table *) + clk_table = kzalloc(table_size, GFP_KERNEL); if (!clk_table) @@ -728,7 +728,7 @@ static int get_dcefclk_voltage_dependenc sizeof(phm_ppt_v1_clock_voltage_dependency_record) * num_entries; - clk_table = (struct phm_ppt_v1_clock_voltage_dependency_table *) + clk_table = kzalloc(table_size, GFP_KERNEL); if (!clk_table) @@ -772,7 +772,7 @@ static int get_pcie_table(struct pp_hwmg sizeof(struct phm_ppt_v1_pcie_record) * atom_pcie_table->ucNumEntries; - pcie_table = (struct phm_ppt_v1_pcie_table *) + pcie_table = kzalloc(table_size, GFP_KERNEL); if (!pcie_table) @@ -1026,7 +1026,7 @@ static int get_vddc_lookup_table( table_size = sizeof(uint32_t) + sizeof(phm_ppt_v1_voltage_lookup_record) * max_levels; - table = (phm_ppt_v1_voltage_lookup_table *) + table = kzalloc(table_size, GFP_KERNEL); if (NULL == table)