Skip to content

Commit cd57e43

Browse files
Pei Xiaovinodkoul
authored andcommitted
phy: freescale: fsl-samsung-hdmi: Limit PLL lock detection clock divider to valid range
FIELD_PREP() checks that a value fits into the available bitfield, but the index div equals to 4,is out of range. which gcc complains about: In function ‘fsl_samsung_hdmi_phy_configure_pll_lock_det’, inlined from ‘fsl_samsung_hdmi_phy_configure’ at drivers/phy/freescale/phy-fsl-samsung-hdmi.c :470:2: ././include/linux/compiler_types.h:542:38: error: call to ‘__compiletime_assert_538’ declared with attribute error: FIELD_PREP: value too large for the field 542 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) | ^ ././include/linux/compiler_types.h:523:4: note: in definition of macro ‘__compiletime_assert’ 523 | prefix ## suffix(); | ^~~~~~ ././include/linux/compiler_types.h:542:2: note: in expansion of macro ‘_compiletime_assert’ 542 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) REG12_CK_DIV_MASK only two bit, limit div to range 0~3, so build error will fix. Fixes: d567679 ("phy: freescale: fsl-samsung-hdmi: Clean up fld_tg_code calculation") Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn> Changlog: Reviewed-by: Adam Ford <aford173@gmail.com> Link: https://lore.kernel.org/r/tencent_6F503D43467AA99DD8CC59B8F645F0725B0A@qq.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent e2158c9 commit cd57e43

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/phy/freescale/phy-fsl-samsung-hdmi.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ to_fsl_samsung_hdmi_phy(struct clk_hw *hw)
325325
return container_of(hw, struct fsl_samsung_hdmi_phy, hw);
326326
}
327327

328-
static void
328+
static int
329329
fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,
330330
const struct phy_config *cfg)
331331
{
@@ -341,6 +341,9 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,
341341
break;
342342
}
343343

344+
if (unlikely(div == 4))
345+
return -EINVAL;
346+
344347
writeb(FIELD_PREP(REG12_CK_DIV_MASK, div), phy->regs + PHY_REG(12));
345348

346349
/*
@@ -364,6 +367,8 @@ fsl_samsung_hdmi_phy_configure_pll_lock_det(struct fsl_samsung_hdmi_phy *phy,
364367
FIELD_PREP(REG14_RP_CODE_MASK, 2) |
365368
FIELD_PREP(REG14_TG_CODE_HIGH_MASK, fld_tg_code >> 8),
366369
phy->regs + PHY_REG(14));
370+
371+
return 0;
367372
}
368373

369374
static unsigned long fsl_samsung_hdmi_phy_find_pms(unsigned long fout, u8 *p, u16 *m, u8 *s)
@@ -466,7 +471,11 @@ static int fsl_samsung_hdmi_phy_configure(struct fsl_samsung_hdmi_phy *phy,
466471
writeb(REG21_SEL_TX_CK_INV | FIELD_PREP(REG21_PMS_S_MASK,
467472
cfg->pll_div_regs[2] >> 4), phy->regs + PHY_REG(21));
468473

469-
fsl_samsung_hdmi_phy_configure_pll_lock_det(phy, cfg);
474+
ret = fsl_samsung_hdmi_phy_configure_pll_lock_det(phy, cfg);
475+
if (ret) {
476+
dev_err(phy->dev, "pixclock too large\n");
477+
return ret;
478+
}
470479

471480
writeb(REG33_FIX_DA | REG33_MODE_SET_DONE, phy->regs + PHY_REG(33));
472481

0 commit comments

Comments
 (0)