Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phy: mediatek: add a new helper to update bitfield

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 <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/20220920090038.15133-2-chunfeng.yun@mediatek.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Chunfeng Yun and committed by
Vinod Koul
29c07477 9d943961

+7
+7
drivers/phy/mediatek/phy-mtk-io.h
··· 8 8 #ifndef __PHY_MTK_H__ 9 9 #define __PHY_MTK_H__ 10 10 11 + #include <linux/bitfield.h> 11 12 #include <linux/io.h> 12 13 13 14 static inline void mtk_phy_clear_bits(void __iomem *reg, u32 bits) ··· 34 33 tmp &= ~mask; 35 34 tmp |= val & mask; 36 35 writel(tmp, reg); 36 + } 37 + 38 + /* field @mask should be constant and continuous */ 39 + static inline void mtk_phy_update_field(void __iomem *reg, u32 mask, u32 val) 40 + { 41 + mtk_phy_update_bits(reg, mask, FIELD_PREP(mask, val)); 37 42 } 38 43 39 44 #endif