Skip to contentSkip to conversation

drm: bridge: dw_hdmi: Fix constant truncation warning on phy_mask

PATCH Applied Sean Chang 2 participants 3 messages Aug 19 – Sep 2

Subsystems (3)
lore
Share & tools
lore

Sean Chang

author
#0 lore raw

PATCH 1/1 drm: bridge: dw_hdmi: Fix constant truncation warning on phy_mask

In dw_hdmi_probe(), casting the bitwise complement of (HDMI_PHY_HPD | HDMI_PHY_RX_SENSE) directly to u8 triggers a compiler warning (-Wconstant-conversion).

Due to C integer promotion rules, the bitwise OR and bitwise NOT are evaluated as 32-bit signed integers, producing 0xFFFFFF0D before being cast down to u8.

Fix this by explicitly masking the inverted 32-bit result with 0xFF to keep only the lower byte and prevent implicit upper-bit truncation.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -1
index 34c5f583e910..937d61c42b58 100644
@@ -3353,7 +3353,7 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
 	hdmi->channels = 2;
 	hdmi->disabled = true;
 	hdmi->rxsense = true;
-	hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE);
+	hdmi->phy_mask = ~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE) & 0xff;
 	hdmi->mc_clkdis = 0x7f;
 	hdmi->last_connector_result = connector_status_disconnected;
 
Signature · 1 line
2.43.0
reviewer Reviewed-by on v1 1/1
#1 lore raw
Quoted 4 lines · Sean Chang

In dw_hdmi_probe(), casting the bitwise complement of (HDMI_PHY_HPD | HDMI_PHY_RX_SENSE) directly to u8 triggers a compiler warning (-Wconstant-conversion).

Quoted 8 lines

Due to C integer promotion rules, the bitwise OR and bitwise NOT are evaluated as 32-bit signed integers, producing 0xFFFFFF0D before being cast down to u8.

Fix this by explicitly masking the inverted 32-bit result with 0xFF to keep only the lower byte and prevent implicit upper-bit truncation.

--
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

reviewer Applied
#2 lore raw
In reply to Sean Chang
Quoted 9 lines · Sean Chang

In dw_hdmi_probe(), casting the bitwise complement of (HDMI_PHY_HPD | HDMI_PHY_RX_SENSE) directly to u8 triggers a compiler warning (-Wconstant-conversion).

Due to C integer promotion rules, the bitwise OR and bitwise NOT are evaluated as 32-bit signed integers, producing 0xFFFFFF0D before being cast down to u8.

[...]

Applied, thanks!

[1/1] drm: bridge: dw_hdmi: Fix constant truncation warning on phy_mask

      commit: cb6a133bc75bc4c5b25f7c278b6c74bf46a3d71b

Best regards,

Signature · 3 lines
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com