phy: mediatek: fix build warning of FIELD_PREP()

Change the inline function mtk_phy_update_field() into a macro to
avoid check warning of FIELD_PREP() with compiler parameter
-Wtautological-constant-out-of-range-compare

the warning is caused by mask check:
"BUILD_BUG_ON_MSG(__bf_cast_unsigned(_mask, _mask) >     \"

Fixes: 29c0747755 ("phy: mediatek: add a new helper to update bitfield")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220928070746.5393-1-chunfeng.yun@mediatek.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
Chunfeng Yun 2022-09-28 15:07:46 +08:00 committed by Vinod Koul
parent add7000bdd
commit 84513eccd6

View File

@ -36,10 +36,11 @@ static inline void mtk_phy_update_bits(void __iomem *reg, u32 mask, u32 val)
writel(tmp, reg); writel(tmp, reg);
} }
/* field @mask should be constant and continuous */ /* field @mask shall be constant and continuous */
static inline void mtk_phy_update_field(void __iomem *reg, u32 mask, u32 val) #define mtk_phy_update_field(reg, mask, val) \
{ ({ \
mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); typeof(mask) mask_ = (mask); \
} mtk_phy_update_bits(reg, mask_, FIELD_PREP(mask_, val)); \
})
#endif #endif