From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3A194ECAAD8 for ; Fri, 23 Sep 2022 06:03:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbiIWGDs (ORCPT ); Fri, 23 Sep 2022 02:03:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiIWGDo (ORCPT ); Fri, 23 Sep 2022 02:03:44 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AA1FAA3F5 for ; Thu, 22 Sep 2022 23:03:43 -0700 (PDT) X-UUID: 7b71bd66c7894af6bb8a13f03fbb95b4-20220923 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=whEo3FlJzvrCgsZU2Vky7sq+5FTXkctNcdlBeQtXQAo=; b=gSGirSlJfwnn1YUrcEkshxTt6ZFu6sBBZWKGmBhBlVUb3OznoLDEsrGzGI3mCqmYj2wUpZBB4EnlW62PY85dmLpf8b+Tu7WiEGYUvp5zyo6aCtd45sX2w5UygLeLlKRyC5MSP5lz2/ydVMWIbECot4evBKhxWh9RcdYCy+tEQtA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:41bf1696-eca2-48a3-96f8-ebf9d2ff84b7,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:45,FILE:0,BULK:28,RULE:Release_Ham,ACTIO N:release,TS:73 X-CID-INFO: VERSION:1.1.11,REQID:41bf1696-eca2-48a3-96f8-ebf9d2ff84b7,IP:0,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:45,FILE:0,BULK:28,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:73 X-CID-META: VersionHash:39a5ff1,CLOUDID:8606c506-1cee-4c38-b21b-a45f9682fdc0,B ulkID:220922103633QJL9KCK0,BulkQuantity:135,Recheck:0,SF:28|17|19|48|823|8 24,TC:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40|20,QS:nil,BEC: nil,COL:0 X-UUID: 7b71bd66c7894af6bb8a13f03fbb95b4-20220923 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 375317930; Fri, 23 Sep 2022 14:03:37 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 23 Sep 2022 14:03:36 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 23 Sep 2022 14:03:35 +0800 Message-ID: <50c77b7b4854037f927880dc8775392a7b2e59fc.camel@mediatek.com> Subject: Re: [PATCH 01/18] phy: mediatek: add a new helper to update bitfield From: Chunfeng Yun To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Vinod Koul CC: Philipp Zabel , Kishon Vijay Abraham I , Matthias Brugger , , , , , , Jitao Shi , "Stanley Chu" Date: Fri, 23 Sep 2022 14:03:35 +0800 In-Reply-To: <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> References: <20220920090038.15133-1-chunfeng.yun@mediatek.com> <20220920090038.15133-2-chunfeng.yun@mediatek.com> <2d13b383-7d25-240b-bdbb-e53848df4d47@collabora.com> <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2022-09-22 at 09:17 +0200, AngeloGioacchino Del Regno wrote: > Il 22/09/22 04:36, Chunfeng Yun ha scritto: > > On Wed, 2022-09-21 at 10:15 +0200, AngeloGioacchino Del Regno > > wrote: > > > Il 20/09/22 11:00, Chunfeng Yun ha scritto: > > > > Due to FIELD_PREP() macro can be used to prepare a bitfield > > > > value, > > > > local ones can be remove; add the new helper to make bitfield > > > > update > > > > easier. > > > > > > > > Signed-off-by: Chunfeng Yun > > > > --- > > > > drivers/phy/mediatek/phy-mtk-io.h | 7 +++++++ > > > > 1 file changed, 7 insertions(+) > > > > > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > > > b/drivers/phy/mediatek/phy-mtk-io.h > > > > index 500fcdab165d..a723d4afc9b4 100644 > > > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > > > @@ -8,6 +8,7 @@ > > > > #ifndef __PHY_MTK_H__ > > > > #define __PHY_MTK_H__ > > > > > > > > +#include > > > > #include > > > > > > > > static inline void mtk_phy_clear_bits(void __iomem *reg, u32 > > > > bits) > > > > @@ -35,4 +36,10 @@ static inline void mtk_phy_update_bits(void > > > > __iomem *reg, u32 mask, u32 val) > > > > writel(tmp, reg); > > > > } > > > > > > > > +/* field @mask should be constant and continuous */ > > > > > > "Field @mask shall be [...]" > > > ^^^^^ > > > > Ok, will modify it > > > > > > > > > +static inline void mtk_phy_update_field(void __iomem *reg, u32 > > > > mask, u32 val) > > > > > > ...so, (void __iomem *reg, const u32 mask, u32 val) > > > > Maybe no need const, @mask will be checked it in compile time when > > use FIELD_PREP(), means @mask is a constant value, but not a > > variable. > > > > Adding const is not *required*, but `mask` is, effectively, a > constant, hence > it fully makes sense to add const. Prefer to leave it unchanged, there is no 'const' in function mtk_phy_update_bits(), if add 'const', will cause build warning. and FIELD_PREP() already do many checks in compile time. Thanks > > > Thanks > > > > > > > > > +{ > > > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); > > > > +} > > > > + > > > > #endif > > > > > > > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B7EEC6FA82 for ; Fri, 23 Sep 2022 06:03:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 084F210E3C2; Fri, 23 Sep 2022 06:03:46 +0000 (UTC) Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by gabe.freedesktop.org (Postfix) with ESMTPS id A6CB610E3C2 for ; Fri, 23 Sep 2022 06:03:43 +0000 (UTC) X-UUID: 7b71bd66c7894af6bb8a13f03fbb95b4-20220923 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=whEo3FlJzvrCgsZU2Vky7sq+5FTXkctNcdlBeQtXQAo=; b=gSGirSlJfwnn1YUrcEkshxTt6ZFu6sBBZWKGmBhBlVUb3OznoLDEsrGzGI3mCqmYj2wUpZBB4EnlW62PY85dmLpf8b+Tu7WiEGYUvp5zyo6aCtd45sX2w5UygLeLlKRyC5MSP5lz2/ydVMWIbECot4evBKhxWh9RcdYCy+tEQtA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11, REQID:41bf1696-eca2-48a3-96f8-ebf9d2ff84b7, IP:0, U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:45,FILE:0,BULK:28,RULE:Release_Ham,ACTIO N:release,TS:73 X-CID-INFO: VERSION:1.1.11, REQID:41bf1696-eca2-48a3-96f8-ebf9d2ff84b7, IP:0, URL :0,TC:0,Content:0,EDM:0,RT:0,SF:45,FILE:0,BULK:28,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:73 X-CID-META: VersionHash:39a5ff1, CLOUDID:8606c506-1cee-4c38-b21b-a45f9682fdc0, B ulkID:220922103633QJL9KCK0,BulkQuantity:135,Recheck:0,SF:28|17|19|48|823|8 24,TC:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:40|20,QS:nil,BEC: nil,COL:0 X-UUID: 7b71bd66c7894af6bb8a13f03fbb95b4-20220923 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 375317930; Fri, 23 Sep 2022 14:03:37 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 23 Sep 2022 14:03:36 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 23 Sep 2022 14:03:35 +0800 Message-ID: <50c77b7b4854037f927880dc8775392a7b2e59fc.camel@mediatek.com> Subject: Re: [PATCH 01/18] phy: mediatek: add a new helper to update bitfield From: Chunfeng Yun To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Vinod Koul Date: Fri, 23 Sep 2022 14:03:35 +0800 In-Reply-To: <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> References: <20220920090038.15133-1-chunfeng.yun@mediatek.com> <20220920090038.15133-2-chunfeng.yun@mediatek.com> <2d13b383-7d25-240b-bdbb-e53848df4d47@collabora.com> <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-MTK: N X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jitao Shi , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Kishon Vijay Abraham I , linux-phy@lists.infradead.org, linux-mediatek@lists.infradead.org, Matthias Brugger , Stanley Chu , linux-arm-kernel@lists.infradead.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Thu, 2022-09-22 at 09:17 +0200, AngeloGioacchino Del Regno wrote: > Il 22/09/22 04:36, Chunfeng Yun ha scritto: > > On Wed, 2022-09-21 at 10:15 +0200, AngeloGioacchino Del Regno > > wrote: > > > Il 20/09/22 11:00, Chunfeng Yun ha scritto: > > > > Due to FIELD_PREP() macro can be used to prepare a bitfield > > > > value, > > > > local ones can be remove; add the new helper to make bitfield > > > > update > > > > easier. > > > > > > > > Signed-off-by: Chunfeng Yun > > > > --- > > > > drivers/phy/mediatek/phy-mtk-io.h | 7 +++++++ > > > > 1 file changed, 7 insertions(+) > > > > > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > > > b/drivers/phy/mediatek/phy-mtk-io.h > > > > index 500fcdab165d..a723d4afc9b4 100644 > > > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > > > @@ -8,6 +8,7 @@ > > > > #ifndef __PHY_MTK_H__ > > > > #define __PHY_MTK_H__ > > > > > > > > +#include > > > > #include > > > > > > > > static inline void mtk_phy_clear_bits(void __iomem *reg, u32 > > > > bits) > > > > @@ -35,4 +36,10 @@ static inline void mtk_phy_update_bits(void > > > > __iomem *reg, u32 mask, u32 val) > > > > writel(tmp, reg); > > > > } > > > > > > > > +/* field @mask should be constant and continuous */ > > > > > > "Field @mask shall be [...]" > > > ^^^^^ > > > > Ok, will modify it > > > > > > > > > +static inline void mtk_phy_update_field(void __iomem *reg, u32 > > > > mask, u32 val) > > > > > > ...so, (void __iomem *reg, const u32 mask, u32 val) > > > > Maybe no need const, @mask will be checked it in compile time when > > use FIELD_PREP(), means @mask is a constant value, but not a > > variable. > > > > Adding const is not *required*, but `mask` is, effectively, a > constant, hence > it fully makes sense to add const. Prefer to leave it unchanged, there is no 'const' in function mtk_phy_update_bits(), if add 'const', will cause build warning. and FIELD_PREP() already do many checks in compile time. Thanks > > > Thanks > > > > > > > > > +{ > > > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); > > > > +} > > > > + > > > > #endif > > > > > > > > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 24A24C6FA82 for ; Fri, 23 Sep 2022 06:37:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:CC:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=XMexJZvIwf1tFS9ChKxUoit6Dv2pBQ3wAyAl3ecCTzs=; b=nnI6LMG3YjKspE g50srbNkeJy2vveeV/rFBfrZkFSjNRvu9DoTM6fZAESO9qhPx1zduxKxmKC2BSHVrU+QII323kehJ MbFkxO82EPUwMsaMuHc8V1ulVYi+RvSN19U8toNxGuU1sJw1Wq5C18RnGcD5SYtzI2K1nJ3ZeaBHR EG7FeLxYCigL/acVKsB0qN47/dB+1QYi99S938D961jWv/23PRyCVadZOqytr2qq3IokuZ2y3MjX2 iz96pGrKd13UAp8YdBc8YC52gNMgwnqtULLoU27xh0lPtAKsqq6yIZtriYeRiFafDUYCExMFR6Jlj AnXMEVkvzjN1d+xkSEHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obcJQ-002XEo-Tw; Fri, 23 Sep 2022 06:37:24 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1obcGS-002Vjc-Rd; Fri, 23 Sep 2022 06:34:22 +0000 X-UUID: df9162e938de4efbac52a834b44b2004-20220922 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=whEo3FlJzvrCgsZU2Vky7sq+5FTXkctNcdlBeQtXQAo=; b=gSGirSlJfwnn1YUrcEkshxTt6ZFu6sBBZWKGmBhBlVUb3OznoLDEsrGzGI3mCqmYj2wUpZBB4EnlW62PY85dmLpf8b+Tu7WiEGYUvp5zyo6aCtd45sX2w5UygLeLlKRyC5MSP5lz2/ydVMWIbECot4evBKhxWh9RcdYCy+tEQtA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:cd31a035-e039-4b26-bf6c-2429f83cc4c3,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:39a5ff1,CLOUDID:fe7cfae3-87f9-4bb0-97b6-34957dc0fbbe,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: df9162e938de4efbac52a834b44b2004-20220922 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1565659900; Thu, 22 Sep 2022 23:34:13 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 23 Sep 2022 14:03:36 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 23 Sep 2022 14:03:35 +0800 Message-ID: <50c77b7b4854037f927880dc8775392a7b2e59fc.camel@mediatek.com> Subject: Re: [PATCH 01/18] phy: mediatek: add a new helper to update bitfield From: Chunfeng Yun To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Vinod Koul CC: Philipp Zabel , Kishon Vijay Abraham I , Matthias Brugger , , , , , , Jitao Shi , "Stanley Chu" Date: Fri, 23 Sep 2022 14:03:35 +0800 In-Reply-To: <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> References: <20220920090038.15133-1-chunfeng.yun@mediatek.com> <20220920090038.15133-2-chunfeng.yun@mediatek.com> <2d13b383-7d25-240b-bdbb-e53848df4d47@collabora.com> <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220922_233420_944264_1BA8BB24 X-CRM114-Status: GOOD ( 23.80 ) X-BeenThere: linux-phy@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux Phy Mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-phy" Errors-To: linux-phy-bounces+linux-phy=archiver.kernel.org@lists.infradead.org On Thu, 2022-09-22 at 09:17 +0200, AngeloGioacchino Del Regno wrote: > Il 22/09/22 04:36, Chunfeng Yun ha scritto: > > On Wed, 2022-09-21 at 10:15 +0200, AngeloGioacchino Del Regno > > wrote: > > > Il 20/09/22 11:00, Chunfeng Yun ha scritto: > > > > Due to FIELD_PREP() macro can be used to prepare a bitfield > > > > value, > > > > local ones can be remove; add the new helper to make bitfield > > > > update > > > > easier. > > > > > > > > Signed-off-by: Chunfeng Yun > > > > --- > > > > drivers/phy/mediatek/phy-mtk-io.h | 7 +++++++ > > > > 1 file changed, 7 insertions(+) > > > > > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > > > b/drivers/phy/mediatek/phy-mtk-io.h > > > > index 500fcdab165d..a723d4afc9b4 100644 > > > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > > > @@ -8,6 +8,7 @@ > > > > #ifndef __PHY_MTK_H__ > > > > #define __PHY_MTK_H__ > > > > > > > > +#include > > > > #include > > > > > > > > static inline void mtk_phy_clear_bits(void __iomem *reg, u32 > > > > bits) > > > > @@ -35,4 +36,10 @@ static inline void mtk_phy_update_bits(void > > > > __iomem *reg, u32 mask, u32 val) > > > > writel(tmp, reg); > > > > } > > > > > > > > +/* field @mask should be constant and continuous */ > > > > > > "Field @mask shall be [...]" > > > ^^^^^ > > > > Ok, will modify it > > > > > > > > > +static inline void mtk_phy_update_field(void __iomem *reg, u32 > > > > mask, u32 val) > > > > > > ...so, (void __iomem *reg, const u32 mask, u32 val) > > > > Maybe no need const, @mask will be checked it in compile time when > > use FIELD_PREP(), means @mask is a constant value, but not a > > variable. > > > > Adding const is not *required*, but `mask` is, effectively, a > constant, hence > it fully makes sense to add const. Prefer to leave it unchanged, there is no 'const' in function mtk_phy_update_bits(), if add 'const', will cause build warning. and FIELD_PREP() already do many checks in compile time. Thanks > > > Thanks > > > > > > > > > +{ > > > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); > > > > +} > > > > + > > > > #endif > > > > > > > > > -- linux-phy mailing list linux-phy@lists.infradead.org https://lists.infradead.org/mailman/listinfo/linux-phy From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 410C2C6FA82 for ; Fri, 23 Sep 2022 06:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Date:CC:To:From:Subject:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hrESFFfUC7hQiIHMAeWkllN/Jik2g4c+amkFdRAPZUY=; b=CkicwQc/oi8TYB zIuxLPO5+EVgvZuHcrp6XT53vpZUtYxVt290fQt/OYwrS0YC3lOXy5P7Zv9EWdW0QEGz3zf5Fu5Bg I6IOgS+YtYi3cVadRkVPCHX1m3LGACuQFuHgR9p1X0OW7tWkhebSebXUfiDvL0hl6IgYo4FpNzpIV 9bD5j1fll5/g6+6iTowtOhTS7FbA6RIlpROhh1xZ9G+W4PuBsXCO7TqS4745REne7yIg9rgLZ5q+U KawByEUuIzJoSUDF17DlNxrvCGD+Qi3Tt44e6QBH5IrOiRphcCp4YrD8oAuiiQav80ssjicGaK1n+ iLkmCioxYWbLvxBTeGBw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obcJV-002XF6-CW; Fri, 23 Sep 2022 06:37:30 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1obcGS-002Vjc-Rd; Fri, 23 Sep 2022 06:34:22 +0000 X-UUID: df9162e938de4efbac52a834b44b2004-20220922 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:MIME-Version:Content-Type:References:In-Reply-To:Date:CC:To:From:Subject:Message-ID; bh=whEo3FlJzvrCgsZU2Vky7sq+5FTXkctNcdlBeQtXQAo=; b=gSGirSlJfwnn1YUrcEkshxTt6ZFu6sBBZWKGmBhBlVUb3OznoLDEsrGzGI3mCqmYj2wUpZBB4EnlW62PY85dmLpf8b+Tu7WiEGYUvp5zyo6aCtd45sX2w5UygLeLlKRyC5MSP5lz2/ydVMWIbECot4evBKhxWh9RcdYCy+tEQtA=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.11,REQID:cd31a035-e039-4b26-bf6c-2429f83cc4c3,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:39a5ff1,CLOUDID:fe7cfae3-87f9-4bb0-97b6-34957dc0fbbe,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 X-UUID: df9162e938de4efbac52a834b44b2004-20220922 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1565659900; Thu, 22 Sep 2022 23:34:13 -0700 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.15; Fri, 23 Sep 2022 14:03:36 +0800 Received: from mhfsdcap04 (10.17.3.154) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 23 Sep 2022 14:03:35 +0800 Message-ID: <50c77b7b4854037f927880dc8775392a7b2e59fc.camel@mediatek.com> Subject: Re: [PATCH 01/18] phy: mediatek: add a new helper to update bitfield From: Chunfeng Yun To: AngeloGioacchino Del Regno , Chun-Kuang Hu , Vinod Koul CC: Philipp Zabel , Kishon Vijay Abraham I , Matthias Brugger , , , , , , Jitao Shi , "Stanley Chu" Date: Fri, 23 Sep 2022 14:03:35 +0800 In-Reply-To: <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> References: <20220920090038.15133-1-chunfeng.yun@mediatek.com> <20220920090038.15133-2-chunfeng.yun@mediatek.com> <2d13b383-7d25-240b-bdbb-e53848df4d47@collabora.com> <3d8fdcf5-c2cb-be63-48d5-d84d50aeace3@collabora.com> X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220922_233420_944264_1BA8BB24 X-CRM114-Status: GOOD ( 23.80 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, 2022-09-22 at 09:17 +0200, AngeloGioacchino Del Regno wrote: > Il 22/09/22 04:36, Chunfeng Yun ha scritto: > > On Wed, 2022-09-21 at 10:15 +0200, AngeloGioacchino Del Regno > > wrote: > > > Il 20/09/22 11:00, Chunfeng Yun ha scritto: > > > > Due to FIELD_PREP() macro can be used to prepare a bitfield > > > > value, > > > > local ones can be remove; add the new helper to make bitfield > > > > update > > > > easier. > > > > > > > > Signed-off-by: Chunfeng Yun > > > > --- > > > > drivers/phy/mediatek/phy-mtk-io.h | 7 +++++++ > > > > 1 file changed, 7 insertions(+) > > > > > > > > diff --git a/drivers/phy/mediatek/phy-mtk-io.h > > > > b/drivers/phy/mediatek/phy-mtk-io.h > > > > index 500fcdab165d..a723d4afc9b4 100644 > > > > --- a/drivers/phy/mediatek/phy-mtk-io.h > > > > +++ b/drivers/phy/mediatek/phy-mtk-io.h > > > > @@ -8,6 +8,7 @@ > > > > #ifndef __PHY_MTK_H__ > > > > #define __PHY_MTK_H__ > > > > > > > > +#include > > > > #include > > > > > > > > static inline void mtk_phy_clear_bits(void __iomem *reg, u32 > > > > bits) > > > > @@ -35,4 +36,10 @@ static inline void mtk_phy_update_bits(void > > > > __iomem *reg, u32 mask, u32 val) > > > > writel(tmp, reg); > > > > } > > > > > > > > +/* field @mask should be constant and continuous */ > > > > > > "Field @mask shall be [...]" > > > ^^^^^ > > > > Ok, will modify it > > > > > > > > > +static inline void mtk_phy_update_field(void __iomem *reg, u32 > > > > mask, u32 val) > > > > > > ...so, (void __iomem *reg, const u32 mask, u32 val) > > > > Maybe no need const, @mask will be checked it in compile time when > > use FIELD_PREP(), means @mask is a constant value, but not a > > variable. > > > > Adding const is not *required*, but `mask` is, effectively, a > constant, hence > it fully makes sense to add const. Prefer to leave it unchanged, there is no 'const' in function mtk_phy_update_bits(), if add 'const', will cause build warning. and FIELD_PREP() already do many checks in compile time. Thanks > > > Thanks > > > > > > > > > +{ > > > > + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); > > > > +} > > > > + > > > > #endif > > > > > > > > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel