Message ID | 20230104132646.7100-1-chunfeng.yun@mediatek.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5145102wrt; Wed, 4 Jan 2023 05:33:12 -0800 (PST) X-Google-Smtp-Source: AMrXdXsXfTWSATxqxvp3t3nXtOKdK8LcWYksDEz9mzIF5WGsnqj+dyKEUvBnh3KwMWHP7JzOQyzY X-Received: by 2002:a17:906:191a:b0:7ad:9f03:b330 with SMTP id a26-20020a170906191a00b007ad9f03b330mr42107856eje.62.1672839191969; Wed, 04 Jan 2023 05:33:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672839191; cv=none; d=google.com; s=arc-20160816; b=OVQqFKiyAUkRxITPbKnGa9sAh9DFOs3sI/2vDEfZ8glpwyTFG89gXz66yQ+V2Dg3cy aawylxoxNmikEvy9Kq7yqSE7INdRPbkcNUqvBoIWKyWnvcuHxFgbRe4Db5TwtwLOk/qe gaEhjLYnU0UV/Z/AWQDG1O2B5IeLwRW5mX0tj7ryKq1x/wYqCKzC5ljtxA6XermJvtFt DAgM9v8Bmmw0WXRGgB3iOEsqRSvf09CGThsVD1AVz00cMIjQcOqat6y/LTuH/y89akKF WVk9uky6/ZKRRQcxkec5glhyq9Wlp2Vq6HnufKMTffGDVsmvnyApllNzg5GBweqfbY27 fsaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SJsKDaLisFLP+9xbSgisqMqiIgGxLySDzuXQz0Dj2o8=; b=zBrYVBBUO87tbzMW/ZQUDV5slDjM0r+d+PxuZBXRl0C+pGM3opF697hbCsFz7Xjg4b QsO96t6RKudDIsIs3AyXiuxU/Rh/MD1Km7wJTwiUzjtd/EvByAFte69HglIQXEf+FCIG xAualzuVoETTh92l9H7VBTccxQFQv20Vu0h8Nq1IJo2ufAa5qtTcTuatm8al8TPwNqsx P2Mlw/KwG2vuUrRLMp7Ibz2qk18FPfKGKD6RrRr6kgeLn9UW7J0hUdXaUcEQ33hLhr7Z DuXwurgnAIyChLt5ePvG2cBMIPYwikUZVCjJl/0zn1l0381Lrrdk8rqM8dwV/E4EBZn0 MXdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=qjQVxPuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sb18-20020a1709076d9200b007f5e85a454csi33016390ejc.356.2023.01.04.05.32.48; Wed, 04 Jan 2023 05:33:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=qjQVxPuT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239461AbjADNcH (ORCPT <rfc822;tmhikaru@gmail.com> + 99 others); Wed, 4 Jan 2023 08:32:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231130AbjADNbU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 4 Jan 2023 08:31:20 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3401C29D for <linux-kernel@vger.kernel.org>; Wed, 4 Jan 2023 05:26:54 -0800 (PST) X-UUID: 397022a3233448b4a7656c1b11976c52-20230104 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=SJsKDaLisFLP+9xbSgisqMqiIgGxLySDzuXQz0Dj2o8=; b=qjQVxPuT/DfswfWxw3VXu7B5ODHBCUDRo6puKtkuX/JUn6OK2bsC+QzRtugaZuWzPzDnyvpW4LcXP0eOcuU2DKppoEibz0bP94Lbd1gJ4gA0MmrOM+ROC9cSnS09RgmukbHAuAsMF2JdVLBZ7OuNzaDUc7Pu3Of5WeNz8eXT5gM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.16,REQID:43d699ae-63ea-408b-8743-6ce60bf4af45,IP:0,U RL:0,TC:0,Content:27,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:27 X-CID-META: VersionHash:09771b1,CLOUDID:093b3c8b-8530-4eff-9f77-222cf6e2895b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:4,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 X-CID-BVR: 0 X-UUID: 397022a3233448b4a7656c1b11976c52-20230104 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from <chunfeng.yun@mediatek.com>) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 533636430; Wed, 04 Jan 2023 21:26:48 +0800 Received: from mtkmbs11n1.mediatek.inc (172.21.101.186) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Wed, 4 Jan 2023 21:26:47 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Wed, 4 Jan 2023 21:26:46 +0800 From: Chunfeng Yun <chunfeng.yun@mediatek.com> To: Vinod Koul <vkoul@kernel.org> CC: Chunfeng Yun <chunfeng.yun@mediatek.com>, Kishon Vijay Abraham I <kishon@kernel.org>, Matthias Brugger <matthias.bgg@gmail.com>, "Nathan Chancellor" <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, <linux-arm-kernel@lists.infradead.org>, <linux-mediatek@lists.infradead.org>, <linux-phy@lists.infradead.org>, <linux-kernel@vger.kernel.org>, <llvm@lists.linux.dev>, Eddie Hung <eddie.hung@mediatek.com>, "kernel test robot" <lkp@intel.com> Subject: [PATCH v6 1/3] phy: mediatek: fix build warning caused by clang Date: Wed, 4 Jan 2023 21:26:44 +0800 Message-ID: <20230104132646.7100-1-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754099028279738901?= X-GMAIL-MSGID: =?utf-8?q?1754099028279738901?= |
Series |
[v6,1/3] phy: mediatek: fix build warning caused by clang
|
|
Commit Message
Chunfeng Yun (云春峰)
Jan. 4, 2023, 1:26 p.m. UTC
Remove the temporary @mask_, this may cause build warning when use clang
compiler for powerpc, but can't reproduce it when compile for arm64.
the build warning is -Wtautological-constant-out-of-range-compare, and
caused by
"BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)"
After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run
checkpatch.pl, due to @mask is constant, no reuse problem will happen.
Fixes: 84513eccd678 ("phy: mediatek: fix build warning of FIELD_PREP()")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v6: modify the title
v5: no changes
v4 new patch, I'm not sure it can fix build warning, due to I don't cross compile
it for powerpc using clang in office.
---
drivers/phy/mediatek/phy-mtk-io.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
On 04-01-23, 21:26, Chunfeng Yun wrote: > Remove the temporary @mask_, this may cause build warning when use clang > compiler for powerpc, but can't reproduce it when compile for arm64. > the build warning is -Wtautological-constant-out-of-range-compare, and > caused by > "BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)" > > After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run > checkpatch.pl, due to @mask is constant, no reuse problem will happen. > > Fixes: 84513eccd678 ("phy: mediatek: fix build warning of FIELD_PREP()") > Reported-by: kernel test robot <lkp@intel.com> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > --- > v6: modify the title Title still does not tell what this patch is.. It tells me effect of the patch but not the changes, pls revise... "remove temp mask" can be better title > v5: no changes > v4 new patch, I'm not sure it can fix build warning, due to I don't cross compile > it for powerpc using clang in office. > --- > drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h b/drivers/phy/mediatek/phy-mtk-io.h > index d20ad5e5be81..58f06db822cb 100644 > --- a/drivers/phy/mediatek/phy-mtk-io.h > +++ b/drivers/phy/mediatek/phy-mtk-io.h > @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val) > /* field @mask shall be constant and continuous */ > #define mtk_phy_update_field(reg, mask, val) \ > ({ \ > - typeof(mask) mask_ = (mask); \ > - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ > + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not constant"); \ > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ > }) > > #endif > -- > 2.18.0
On Wed, Jan 4, 2023 at 5:26 AM Chunfeng Yun <chunfeng.yun@mediatek.com> wrote: > > Remove the temporary @mask_, this may cause build warning when use clang > compiler for powerpc, but can't reproduce it when compile for arm64. > the build warning is -Wtautological-constant-out-of-range-compare, and > caused by > "BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)" Can you please include the text of the observed warning? > > After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run > checkpatch.pl, due to @mask is constant, no reuse problem will happen. > > Fixes: 84513eccd678 ("phy: mediatek: fix build warning of FIELD_PREP()") Uh, why was 84513eccd678 sent/reviewed/merged if it didn't fix the issue correctly in the first place? Is the issue perhaps that your mask isn't wide enough in the first place, and should be? See: commit cfd6fb45cfaf ("crypto: ccree - avoid out-of-range warnings from clang") for inspiration. > Reported-by: kernel test robot <lkp@intel.com> Can you please include the Link: tag to the lore URL of the report? > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > --- > v6: modify the title > v5: no changes > v4 new patch, I'm not sure it can fix build warning, due to I don't cross compile > it for powerpc using clang in office. > --- > drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h b/drivers/phy/mediatek/phy-mtk-io.h > index d20ad5e5be81..58f06db822cb 100644 > --- a/drivers/phy/mediatek/phy-mtk-io.h > +++ b/drivers/phy/mediatek/phy-mtk-io.h > @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val) > /* field @mask shall be constant and continuous */ > #define mtk_phy_update_field(reg, mask, val) \ > ({ \ > - typeof(mask) mask_ = (mask); \ > - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ > + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not constant"); \ > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ > }) > > #endif > -- > 2.18.0 >
On Fri, 2023-01-13 at 23:42 +0530, Vinod Koul wrote: > On 04-01-23, 21:26, Chunfeng Yun wrote: > > Remove the temporary @mask_, this may cause build warning when use > > clang > > compiler for powerpc, but can't reproduce it when compile for > > arm64. > > the build warning is -Wtautological-constant-out-of-range-compare, > > and > > caused by > > "BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)" > > > > After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run > > checkpatch.pl, due to @mask is constant, no reuse problem will > > happen. > > > > Fixes: 84513eccd678 ("phy: mediatek: fix build warning of > > FIELD_PREP()") > > Reported-by: kernel test robot <lkp@intel.com> > > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > > --- > > v6: modify the title > > Title still does not tell what this patch is.. It tells me effect of > the > patch but not the changes, pls revise... > > "remove temp mask" can be better title Got it, will modify it in next version, thanks > > > v5: no changes > > v4 new patch, I'm not sure it can fix build warning, due to I don't > > cross compile > > it for powerpc using clang in office. > > --- > > drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > b/drivers/phy/mediatek/phy-mtk-io.h > > index d20ad5e5be81..58f06db822cb 100644 > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void > > __iomem *reg, u32 mask, u32 val) > > /* field @mask shall be constant and continuous */ > > #define mtk_phy_update_field(reg, mask, val) \ > > ({ \ > > - typeof(mask) mask_ = (mask); \ > > - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ > > + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not > > constant"); \ > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ > > }) > > > > #endif > > -- > > 2.18.0 > >
On Fri, 2023-01-13 at 10:36 -0800, Nick Desaulniers wrote: > On Wed, Jan 4, 2023 at 5:26 AM Chunfeng Yun < > chunfeng.yun@mediatek.com> wrote: > > > > Remove the temporary @mask_, this may cause build warning when use > > clang > > compiler for powerpc, but can't reproduce it when compile for > > arm64. > > the build warning is -Wtautological-constant-out-of-range-compare, > > and > > caused by > > "BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)" > > Can you please include the text of the observed warning? Ok, will add more logs > > > > > After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run > > checkpatch.pl, due to @mask is constant, no reuse problem will > > happen. > > > > Fixes: 84513eccd678 ("phy: mediatek: fix build warning of > > FIELD_PREP()") > > Uh, why was 84513eccd678 sent/reviewed/merged if it didn't fix the > issue correctly in the first place? Sorry, I can't reproduce it, but make sure no such issue happens on arm arch using gcc/clang. MTK only uses arm/mips arch, it's difficult for me to set up clang cross compiler for other archs in office. > > Is the issue perhaps that your mask isn't wide enough in the first > place, and should be? the masks are usually created by GENMASK macro; There is no warning when build for arm64 using clang. > See: > commit cfd6fb45cfaf ("crypto: ccree - avoid out-of-range warnings > from clang") > for inspiration. Ok, I'll do it > > > Reported-by: kernel test robot <lkp@intel.com> > > Can you please include the Link: tag to the lore URL of the report? Ok, thanks a lot > > > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > > --- > > v6: modify the title > > v5: no changes > > v4 new patch, I'm not sure it can fix build warning, due to I don't > > cross compile > > it for powerpc using clang in office. > > --- > > drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > b/drivers/phy/mediatek/phy-mtk-io.h > > index d20ad5e5be81..58f06db822cb 100644 > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void > > __iomem *reg, u32 mask, u32 val) > > /* field @mask shall be constant and continuous */ > > #define mtk_phy_update_field(reg, mask, val) \ > > ({ \ > > - typeof(mask) mask_ = (mask); \ > > - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ > > + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not > > constant"); \ > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ > > }) > > > > #endif > > -- > > 2.18.0 > > > >
On Fri, 2023-01-13 at 10:36 -0800, Nick Desaulniers wrote: > On Wed, Jan 4, 2023 at 5:26 AM Chunfeng Yun < > chunfeng.yun@mediatek.com> wrote: > > > > Remove the temporary @mask_, this may cause build warning when use > > clang > > compiler for powerpc, but can't reproduce it when compile for > > arm64. > > the build warning is -Wtautological-constant-out-of-range-compare, > > and > > caused by > > "BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)" > > Can you please include the text of the observed warning? > > > > > After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run > > checkpatch.pl, due to @mask is constant, no reuse problem will > > happen. > > > > Fixes: 84513eccd678 ("phy: mediatek: fix build warning of > > FIELD_PREP()") > > Uh, why was 84513eccd678 sent/reviewed/merged if it didn't fix the > issue correctly in the first place? > > Is the issue perhaps that your mask isn't wide enough in the first > place, and should be? See: > commit cfd6fb45cfaf ("crypto: ccree - avoid out-of-range warnings > from clang") > for inspiration. I look at this patch, it said that " This does not happen in other places that just pass a constant here. " That's indeed true, no such warning before using FIELD_PREP() due to the masks are always constant. So seems that it can fix the waring if avoid using a temporary variable @mask_ in mtk_phy_update_field() macro. Thanks a lot > > > Reported-by: kernel test robot <lkp@intel.com> > > Can you please include the Link: tag to the lore URL of the report? > > > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > > --- > > v6: modify the title > > v5: no changes > > v4 new patch, I'm not sure it can fix build warning, due to I don't > > cross compile > > it for powerpc using clang in office. > > --- > > drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > b/drivers/phy/mediatek/phy-mtk-io.h > > index d20ad5e5be81..58f06db822cb 100644 > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void > > __iomem *reg, u32 mask, u32 val) > > /* field @mask shall be constant and continuous */ > > #define mtk_phy_update_field(reg, mask, val) \ > > ({ \ > > - typeof(mask) mask_ = (mask); \ > > - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ > > + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not > > constant"); \ > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ > > }) > > > > #endif > > -- > > 2.18.0 > > > >
On Fri, 2023-01-13 at 10:36 -0800, Nick Desaulniers wrote: > On Wed, Jan 4, 2023 at 5:26 AM Chunfeng Yun < > chunfeng.yun@mediatek.com> wrote: > > > > Remove the temporary @mask_, this may cause build warning when use > > clang > > compiler for powerpc, but can't reproduce it when compile for > > arm64. > > the build warning is -Wtautological-constant-out-of-range-compare, > > and > > caused by > > "BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask)" > > Can you please include the text of the observed warning? > > > > > After removing @mask_, there is a "CHECK:MACRO_ARG_REUSE" when run > > checkpatch.pl, due to @mask is constant, no reuse problem will > > happen. > > > > Fixes: 84513eccd678 ("phy: mediatek: fix build warning of > > FIELD_PREP()") > > Uh, why was 84513eccd678 sent/reviewed/merged if it didn't fix the > issue correctly in the first place? > > Is the issue perhaps that your mask isn't wide enough in the first > place, and should be? See: > commit cfd6fb45cfaf ("crypto: ccree - avoid out-of-range warnings > from clang") > for inspiration. I look at this patch, it said that " This does not happen in other places that just pass a constant here. " That's indeed true, no such warning before using FIELD_PREP() due to the masks are always constant. So seems that it can fix the waring if avoid using a temporary variable @mask_. Thanks a lot > > > Reported-by: kernel test robot <lkp@intel.com> > > Can you please include the Link: tag to the lore URL of the report? > > > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com> > > --- > > v6: modify the title > > v5: no changes > > v4 new patch, I'm not sure it can fix build warning, due to I don't > > cross compile > > it for powerpc using clang in office. > > --- > > drivers/phy/mediatek/phy-mtk-io.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > b/drivers/phy/mediatek/phy-mtk-io.h > > index d20ad5e5be81..58f06db822cb 100644 > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void > > __iomem *reg, u32 mask, u32 val) > > /* field @mask shall be constant and continuous */ > > #define mtk_phy_update_field(reg, mask, val) \ > > ({ \ > > - typeof(mask) mask_ = (mask); \ > > - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ > > + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not > > constant"); \ > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ > > }) > > > > #endif > > -- > > 2.18.0 > > > >
diff --git a/drivers/phy/mediatek/phy-mtk-io.h b/drivers/phy/mediatek/phy-mtk-io.h index d20ad5e5be81..58f06db822cb 100644 --- a/drivers/phy/mediatek/phy-mtk-io.h +++ b/drivers/phy/mediatek/phy-mtk-io.h @@ -39,8 +39,8 @@ static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val) /* field @mask shall be constant and continuous */ #define mtk_phy_update_field(reg, mask, val) \ ({ \ - typeof(mask) mask_ = (mask); \ - mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \ + BUILD_BUG_ON_MSG(!__builtin_constant_p(mask), "mask is not constant"); \ + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); \ }) #endif