phy: mediatek: rework the floating point comparisons to fixed point
Subsystems (4)
PATCH v2 1/1 phy: mediatek: rework the floating point comparisons to fixed point
gcc on aarch64 reportsdrivers/phy/mediatek/phy-mtk-hdmi-mt8195.c: In function ‘mtk_hdmi_pll_set_rate’:drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c:240:52: error: ‘-mgeneral-regs-only’
is incompatible with the use of floating-point types
240 | else if (tmds_clk >= 54 * MEGA && tmds_clk < 148.35 * MEGA)
Floating point should not be used, so rework the floating point comparisons to fixed point.
---
v2: silence robot by casting types to u64
---drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c +5 -5
@@ -237,11 +237,11 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw,*/ if (tmds_clk <54 *MEGA ) txposdiv =8 ; -else if (tmds_clk >=54 *MEGA && tmds_clk <148.35 *MEGA ) +else if (tmds_clk >=54 *MEGA && (tmds_clk *100 ) <14835 *MEGA ) txposdiv =4 ; -else if (tmds_clk >=148.35 *MEGA && tmds_clk <296.7 *MEGA ) +else if ((tmds_clk *100 ) >=14835 *MEGA && (tmds_clk *10 ) <2967 *MEGA ) txposdiv =2 ; -else if (tmds_clk >=296.7 *MEGA && tmds_clk <=594 *MEGA ) +else if ((tmds_clk *10 ) >=2967 *MEGA && tmds_clk <=594 *MEGA ) txposdiv =1 ;else return -EINVAL ;
@@ -328,12 +328,12 @@ static int mtk_hdmi_pll_drv_setting(struct clk_hw *hw) clk_channel_bias =0x34 ;/* 20mA */ impedance_en =0xf ; impedance =0x36 ;/* 100ohm */ - }else if (pixel_clk >=74.175 *MEGA && pixel_clk <=300 *MEGA ) { + }else if (((u64 )pixel_clk *1000 ) >=74175 *MEGA && pixel_clk <=300 *MEGA ) { data_channel_bias =0x34 ;/* 20mA */ clk_channel_bias =0x2c ;/* 16mA */ impedance_en =0xf ; impedance =0x36 ;/* 100ohm */ - }else if (pixel_clk >=27 *MEGA && pixel_clk <74.175 *MEGA ) { + }else if (pixel_clk >=27 *MEGA && ((u64 )pixel_clk *1000 ) <74175 *MEGA ) { data_channel_bias =0x14 ;/* 10mA */ clk_channel_bias =0x14 ;/* 10mA */ impedance_en =0x0 ;
Signature · 7 lines
2.27.0 -- linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Quoted 66 lines · Tom Rix
External email : Please do not click links or open attachments until you have verified the sender or the content.
gcc on aarch64 reports
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c: In function ‘mtk_hdmi_pll_set_rate’:drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c:240:52: error: ‘-mgeneral- regs-only’
is incompatible with the use of floating-point types
240 | else if (tmds_clk>= 54 * MEGA &&tmds_clk< 148.35 *
MEGA)Floating point should not be used, so rework the floating point comparisons
to fixed point.Signed-off-by Tom Rix <[email protected]>---
v2: silence robot by casting types to u64---
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c| 10 +++++-----1 file changed, 5 insertions(+), 5 deletions(-)drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c +3
-3@@ -237,11 +237,11 @@ static int mtk_hdmi_pll_calc(structmtk_hdmi_phy *hdmi_phy, struct clk_hw *hw, */ if (tmds_clk <54 *MEGA ) txposdiv =8 ; -else if (tmds_clk >=54 *MEGA && tmds_clk <148.35 *MEGA ) +else if (tmds_clk >=54 *MEGA && (tmds_clk *100 ) <14835 *MEGA ) txposdiv =4 ; -else if (tmds_clk >=148.35 *MEGA && tmds_clk <296.7 * MEGA) + else if ((tmds_clk * 100) >= 14835 * MEGA && (tmds_clk * 10) <2967 *MEGA ) txposdiv =2 ; -else if (tmds_clk >=296.7 *MEGA && tmds_clk <=594 *MEGA ) + else if ((tmds_clk * 10) >= 2967 * MEGA && tmds_clk <= 594 *MEGA)
txposdiv = 1; else return -EINVAL;drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c +1
-2@@ -328,12 +328,12 @@ static int mtk_hdmi_pll_drv_setting(struct clk_hw *hw) clk_channel_bias =0x34 ;/* 20mA */ impedance_en =0xf ; impedance =0x36 ;/* 100ohm */ - }else if (pixel_clk >=74.175 *MEGA && pixel_clk <=300 * MEGA) { + } else if (((u64)pixel_clk * 1000) >= 74175 * MEGA && pixel_clk <= 300 * MEGA) { data_channel_bias =0x34 ;/* 20mA */ clk_channel_bias =0x2c ;/* 16mA */ impedance_en =0xf ; impedance =0x36 ;/* 100ohm */ - } else if (pixel_clk >= 27 * MEGA && pixel_clk < 74.175 *MEGA) {
+ } else if (pixel_clk>= 27 * MEGA && ((u64)pixel_clk * 1000)
Quoted 6 lines
< 74175 * MEGA) { data_channel_bias = 0x14; /* 10mA */ clk_channel_bias = 0x14; /* 10mA */ impedance_en = 0x0;--
2.27.0
Thanks
Quoted 1 line
Signature · 3 lines
linux-phy mailing list [email protected] https://lists.infradead.org/mailman/listinfo/linux-phy
Matthias Brugger
maintainerQuoted 10 lines · Tom Rix
gcc on aarch64 reports
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c: In function ‘mtk_hdmi_pll_set_rate’:drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c:240:52: error: ‘-mgeneral-regs-only’
is incompatible with the use of floating-point types
240 | else if (tmds_clk>= 54 * MEGA &&tmds_clk< 148.35 * MEGA)Floating point should not be used, so rework the floating point comparisons to fixed point.
Signed-off-by Tom Rix <[email protected]>
I think this is worth a fixes tag.
Regards,
Matthias
Quoted 41 lines
---
v2: silence robot by casting types to u64---
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c| 10 +++++-----1 file changed, 5 insertions(+), 5 deletions(-)drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c +5
-5@@ -237,11 +237,11 @@ static int mtk_hdmi_pll_calc(struct mtk_hdmi_phy *hdmi_phy, struct clk_hw *hw,*/ if (tmds_clk <54 *MEGA ) txposdiv =8 ; -else if (tmds_clk >=54 *MEGA && tmds_clk <148.35 *MEGA ) +else if (tmds_clk >=54 *MEGA && (tmds_clk *100 ) <14835 *MEGA ) txposdiv =4 ; -else if (tmds_clk >=148.35 *MEGA && tmds_clk <296.7 *MEGA ) +else if ((tmds_clk *100 ) >=14835 *MEGA && (tmds_clk *10 ) <2967 *MEGA ) txposdiv =2 ; -else if (tmds_clk >=296.7 *MEGA && tmds_clk <=594 *MEGA ) +else if ((tmds_clk *10 ) >=2967 *MEGA && tmds_clk <=594 *MEGA ) txposdiv =1 ;else return -EINVAL ;@@ -328,12 +328,12 @@ static int mtk_hdmi_pll_drv_setting(struct clk_hw *hw) clk_channel_bias =0x34 ;/* 20mA */ impedance_en =0xf ; impedance =0x36 ;/* 100ohm */ - }else if (pixel_clk >=74.175 *MEGA && pixel_clk <=300 *MEGA ) { + }else if (((u64 )pixel_clk *1000 ) >=74175 *MEGA && pixel_clk <=300 *MEGA ) { data_channel_bias =0x34 ;/* 20mA */ clk_channel_bias =0x2c ;/* 16mA */ impedance_en =0xf ; impedance =0x36 ;/* 100ohm */ - }else if (pixel_clk >=27 *MEGA && pixel_clk <74.175 *MEGA ) { + }else if (pixel_clk >=27 *MEGA && ((u64 )pixel_clk *1000 ) <74175 *MEGA ) { data_channel_bias =0x14 ;/* 10mA */ clk_channel_bias =0x14 ;/* 10mA */ impedance_en =0x0 ;
Quoted 8 lines · Tom Rix
gcc on aarch64 reports
drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c: In function ‘mtk_hdmi_pll_set_rate’:drivers/phy/mediatek/phy-mtk-hdmi-mt8195.c:240:52: error: ‘-mgeneral-regs-only’
is incompatible with the use of floating-point types
240 | else if (tmds_clk>= 54 * MEGA &&tmds_clk< 148.35 * MEGA)Floating point should not be used, so rework the floating point comparisons to fixed point.
Applied, thanks
Signature · 1 line
~Vinod