Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp258341ybm; Thu, 28 May 2020 01:55:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxib0weTkBP2xgHUtrQvgtuA7tpYi/FoYIhQuyMMminD0boCWHNK0xbeRgsGWBdIN/muBmJ X-Received: by 2002:a50:a985:: with SMTP id n5mr1998044edc.338.1590656146278; Thu, 28 May 2020 01:55:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590656146; cv=none; d=google.com; s=arc-20160816; b=kLMShVT5IwHqJjRBiZOQH56uW0LSu1/ymtDva7x0YnT4zat9pNuEOHDIWCoRs9iDU1 wexZc/DDKdfw6PlSN5ny4rII4roY2rJGa7Fm76e8NQgjBiyB17AFKw1IXzW/s9ArbZfy sJfstM6UB53x6WgDThVkJ6Y/JezdavVlMsJorzQ7yRxoNpgEw/ntI3pfxN5lW+HV/ev4 5+WmBzV2rtGLQJ4zRj6NIRg559TjaXAL/mg/k6uGVbGSCUFjRtpSjHpI6Q0WZxKSmpWd LItpLOeeJPpHJBE1D5lDyF2TmHQe29slcRfX5KE4k1JgVApErVUCTzXm2YaZqpyUy9et GFQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:ironport-sdr:ironport-sdr; bh=pAMvh7Ql3to63uczydJut2a9SV23DAJn1JxT2cv6+0I=; b=vjyj9KtQ8uXfu27n4gOq1I3UhPo/xbBP2JmmCvq+HPbauxMlwYnL7C2MuTa0vSQ1AS A7dCSG0wu2B/9sQRgiVoKAzPr1HCgZCdzd9AaJ84mcg1dekqOdWV3Zj746OBO1M5syaN uKaMbPPtLXimlypzS6zybmnqNjT6fQuBz9fljoPJfFyfkLNhMCkBhC5HIDtq43dThmTC 1VswbbGTKBqV5ryPqrwqeVmnyqqCq0Ef4JHfL7MDPiy5m/R/SENi82hzR4fkXBe14YC3 rtEBHgqFaGpCOUJS6IxMMj3Mbh0NoS6tX7IkQ0V4ILKskiq3pObKUWx5tTVs+/xtdsUm 7q8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k30si2991355edc.50.2020.05.28.01.55.23; Thu, 28 May 2020 01:55:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727964AbgE1IvU (ORCPT + 99 others); Thu, 28 May 2020 04:51:20 -0400 Received: from mga06.intel.com ([134.134.136.31]:40848 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbgE1IvT (ORCPT ); Thu, 28 May 2020 04:51:19 -0400 IronPort-SDR: +YJpdn432hBN1xQeaVk4+bFzKOrlOwWkWDICqjcPY6ekioQCBXOSmlIqet4BejN/mDvYI/me4l yO4y/FlDWrFg== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2020 01:51:18 -0700 IronPort-SDR: vS7gHEZZyLCDe4Sgm3Yp3klFoGoW/MTi4toI8f5gPnWowX71A1x2JiLRWmCDDTc1EkMnHHnR3C dRfXlhaD3EZw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,444,1583222400"; d="scan'208";a="267149507" Received: from linux.intel.com ([10.54.29.200]) by orsmga003.jf.intel.com with ESMTP; 28 May 2020 01:51:18 -0700 Received: from [10.255.136.206] (ekotax-mobl.gar.corp.intel.com [10.255.136.206]) by linux.intel.com (Postfix) with ESMTP id 5C3345805EF; Thu, 28 May 2020 01:51:16 -0700 (PDT) Subject: Re: [PATCH] phy: intel: fix enum type mismatch warning To: Nathan Chancellor , Arnd Bergmann Cc: Kishon Vijay Abraham I , Vinod Koul , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com References: <20200527134518.908624-1-arnd@arndb.de> <20200527164035.GA1073507@ubuntu-s3-xlarge-x86> From: Dilip Kota Message-ID: Date: Thu, 28 May 2020 16:51:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200527164035.GA1073507@ubuntu-s3-xlarge-x86> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/28/2020 12:40 AM, Nathan Chancellor wrote: > On Wed, May 27, 2020 at 03:45:06PM +0200, Arnd Bergmann wrote: >> clang points out that a local variable is initialized with >> an enum value of the wrong type: >> >> drivers/phy/intel/phy-intel-combo.c:202:34: error: implicit conversion from enumeration type 'enum intel_phy_mode' to different enumeration type 'enum intel_combo_mode' [-Werror,-Wenum-conversion] >> enum intel_combo_mode cb_mode = PHY_PCIE_MODE; >> ~~~~~~~ ^~~~~~~~~~~~~ >> >> From reading the code, it seems that this was not only the >> wrong type, but not even supposed to be a code path that can >> happen in practice. >> >> Change the code to have no default phy mode but instead return an >> error for invalid input. >> >> Fixes: ac0a95a3ea78 ("phy: intel: Add driver support for ComboPhy") >> Signed-off-by: Arnd Bergmann >> --- >> drivers/phy/intel/phy-intel-combo.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/phy/intel/phy-intel-combo.c b/drivers/phy/intel/phy-intel-combo.c >> index c2a35be4cdfb..04f7b0d08742 100644 >> --- a/drivers/phy/intel/phy-intel-combo.c >> +++ b/drivers/phy/intel/phy-intel-combo.c >> @@ -199,7 +199,7 @@ static int intel_cbphy_pcie_dis_pad_refclk(struct intel_cbphy_iphy *iphy) >> >> static int intel_cbphy_set_mode(struct intel_combo_phy *cbphy) >> { >> - enum intel_combo_mode cb_mode = PHY_PCIE_MODE; >> + enum intel_combo_mode cb_mode; >> enum aggregated_mode aggr = cbphy->aggr_mode; >> struct device *dev = cbphy->dev; >> enum intel_phy_mode mode; >> @@ -224,6 +224,8 @@ static int intel_cbphy_set_mode(struct intel_combo_phy *cbphy) >> >> cb_mode = SATA0_SATA1_MODE; >> break; >> + default: >> + return -EINVAL; >> } >> >> ret = regmap_write(cbphy->hsiocfg, REG_COMBO_MODE(cbphy->bid), cb_mode); >> -- >> 2.26.2 >> > I sent an almost identical patch: > > https://lore.kernel.org/lkml/20200523035043.3305846-1-natechancellor@gmail.com/ > > I left out the default case since clang warns when a switch on an enum > does not handle all the values (compile time scream) versus a run time > scream like yours. > > I don't have a preference for either so: > > Reviewed-by: Nathan Chancellor Thanks for fixing it. I wrongly initiated it with PHY_PCIE_MODE instead of PCIE0_PCIE1_MODE to fix the compiler warnings. (On real time use case, cb_mode gets initialized with one of the switch case values, it never hits the default case, so I didn't add the default case.) This patch looks good to fix the warnings. Reviewed-by: Dilip Kota Regards, Dilip