From patchwork Thu Jul 4 05:52:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 11031121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 948DA14DB for ; Thu, 4 Jul 2019 07:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EFB528A33 for ; Thu, 4 Jul 2019 07:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 731F528A3F; Thu, 4 Jul 2019 07:26:39 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,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 2ACD828A33 for ; Thu, 4 Jul 2019 07:26:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DBFDB6E290; Thu, 4 Jul 2019 07:25:22 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 190806E25C; Thu, 4 Jul 2019 05:52:50 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id p15so4220687eds.8; Wed, 03 Jul 2019 22:52:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uzHsVfpI34IYG5D0jQtkbgHPoBjsvNWNqyndhQSAU9M=; b=TKDEmoaU8uPUsQZEY/Pfg2Nj965BUZPRuM+oZdpZJzwN4YY+KLKRmSHUXs+EZJa+v5 Rlj6yUMQ11MBv7S/se6SfM7qM9MOCuM2ShVHfeL1e1/GEIno1KFDpq1IfvvQGFbdo1kV dOS5y1TFXgy2FLlIX2fNzmf2+pKN4RmLmxZ6CdU+bEofq0xRSzDOu+UTK7Zqucx5Jrai 1W8XilMVf3elFB09kQ+o46wy4mxM1TTIkANeUxbFiyoLrux47euMGSKK0V/FFVa6A9U1 psNcHCz4ffCxI1t9lZSMayn1WlsUHxwjWCdPVR6gacP8MHCGrRZ+LMvKY2KvgFJqsVex Eiog== X-Gm-Message-State: APjAAAXLInybuNymFlnANU4m3qm16n10Jw8dPH06UsimTZzbc/RI9dZQ gJgDaeSMxb3xMr+ttAp2jR0= X-Google-Smtp-Source: APXvYqwFYrv5eXZXck3JkVT8qdGEMw5ozUGNhEk+KRFvqZ4OkLwZGS9mGnTiQdTrdefs/dFt8Tq6mA== X-Received: by 2002:a17:906:9416:: with SMTP id q22mr37733050ejx.153.1562219568656; Wed, 03 Jul 2019 22:52:48 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id j30sm1343532edb.8.2019.07.03.22.52.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 03 Jul 2019 22:52:48 -0700 (PDT) From: Nathan Chancellor To: Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "David (ChunMing) Zhou" , Harry Wentland , Leo Li , Rex Zhu , Evan Quan Subject: [PATCH 2/7] drm/amd/powerplay: Use memset to initialize metrics structs Date: Wed, 3 Jul 2019 22:52:13 -0700 Message-Id: <20190704055217.45860-3-natechancellor@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190704055217.45860-1-natechancellor@gmail.com> References: <20190704055217.45860-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uzHsVfpI34IYG5D0jQtkbgHPoBjsvNWNqyndhQSAU9M=; b=Km5gFDAIGiqRxX8AZ+jvqa6iEfdaxMBPKdgoPBf4kY9yM68/OKn8OsBp8g0DiCIsxX +WNqxpotA864maNIE1jUYuKd5icSwIXwdwge1btb9P6GHrkQxzXVIWpaSK3im63cZ7r5 boQG+kz8yZe8kMaIfHCD+pbFgPU3SS7tWpjQPjc4zhpNZZlMP+n9gY+KEbEMrSN1e183 7/X77+kGmZ+sLVOz+BFJfSqd6TV9BC1Kbq45CZcaw63RV1aRRvKdFXyQajIta+j7ZMGS nWAs59N930jc6q6LZzoOjRwMvJWYiYi0waGWikb+IYsEXFD0Pi9bgSHi3inhu3nG8giT lNRA== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, clang-built-linux@googlegroups.com, amd-gfx@lists.freedesktop.org, Nathan Chancellor Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP clang warns: drivers/gpu/drm/amd/amdgpu/../powerplay/navi10_ppt.c:601:33: warning: suggest braces around initialization of subobject [-Wmissing-braces] static SmuMetrics_t metrics = {0}; ^ {} drivers/gpu/drm/amd/amdgpu/../powerplay/navi10_ppt.c:905:26: warning: suggest braces around initialization of subobject [-Wmissing-braces] SmuMetrics_t metrics = {0}; ^ {} 2 warnings generated. One way to fix these warnings is to add additional braces like clang suggests; however, there has been a bit of push back from some maintainers[1][2], who just prefer memset as it is unambiguous, doesn't depend on a particular compiler version[3], and properly initializes all subobjects. Do that here so there are no more warnings. [1]: https://lore.kernel.org/lkml/022e41c0-8465-dc7a-a45c-64187ecd9684@amd.com/ [2]: https://lore.kernel.org/lkml/20181128.215241.702406654469517539.davem@davemloft.net/ [3]: https://lore.kernel.org/lkml/20181116150432.2408a075@redhat.com/ Fixes: 98e1a543c7b1 ("drm/amd/powerplay: add function get current clock freq interface for navi10") Fixes: ab43c4bf1cc8 ("drm/amd/powerplay: fix fan speed show error (for hwmon pwm)") Link: https://github.com/ClangBuiltLinux/linux/issues/583 Signed-off-by: Nathan Chancellor --- drivers/gpu/drm/amd/powerplay/navi10_ppt.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c index e00397f84b2f..f5d2ada05bc6 100644 --- a/drivers/gpu/drm/amd/powerplay/navi10_ppt.c +++ b/drivers/gpu/drm/amd/powerplay/navi10_ppt.c @@ -598,12 +598,14 @@ static int navi10_get_current_clk_freq_by_table(struct smu_context *smu, enum smu_clk_type clk_type, uint32_t *value) { - static SmuMetrics_t metrics = {0}; + static SmuMetrics_t metrics; int ret = 0, clk_id = 0; if (!value) return -EINVAL; + memset(&metrics, 0, sizeof(metrics)); + ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics, false); if (ret) return ret; @@ -902,12 +904,14 @@ static bool navi10_is_dpm_running(struct smu_context *smu) static int navi10_get_fan_speed(struct smu_context *smu, uint16_t *value) { - SmuMetrics_t metrics = {0}; + SmuMetrics_t metrics; int ret = 0; if (!value) return -EINVAL; + memset(&metrics, 0, sizeof(metrics)); + ret = smu_update_table(smu, SMU_TABLE_SMU_METRICS, (void *)&metrics, false); if (ret)