Skip to contentSkip to conversation

drm/msm/dsi: fix 32-bit clang warning

PATCH In review Arnd Bergmann 3 participants 3 messages May 14, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/dsi: fix 32-bit clang warning

From: Arnd Bergmann <[email protected]>

clang is a little overzealous with warning about a constant conversion in an untaken branch of a ternary expression:

drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c:975:48: error: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 5000000000 to 705032704 [-Werror,-Wconstant-conversion]

        .max_pll_rate = (5000000000ULL < ULONG_MAX) ? 5000000000UL : ULONG_MAX,
                                                      ^~~~~~~~~~~~

Rewrite this to use a preprocessor conditional instead to avoid the warning.

Fixes 076437c9e360 ("drm/msm/dsi: move min/max PLL rate to phy config")

---
As found with another patch, using __builtin_choose_expr() would likely also work here, but doesn't seem any more readable.

---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -1
index e76ce40a12ab..accd6b4eb7c2 100644
@@ -972,7 +972,11 @@ const struct msm_dsi_phy_cfg dsi_phy_7nm_cfgs = {
 		.restore_pll_state = dsi_7nm_pll_restore_state,
 	},
 	.min_pll_rate = 600000000UL,
-	.max_pll_rate = (5000000000ULL < ULONG_MAX) ? 5000000000ULL : ULONG_MAX,
+#ifdef CONFIG_64BIT
+	.max_pll_rate = 5000000000UL,
+#else
+	.max_pll_rate = ULONG_MAX,
+#endif
 	.io_start = { 0xae94400, 0xae96400 },
 	.num_dsi_phy = 2,
 	.quirks = DSI_PHY_7NM_QUIRK_V4_1,
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang is a little overzealous with warning about a constant conversion in an untaken branch of a ternary expression:

drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c:975:48: error: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 5000000000 to 705032704 [-Werror,-Wconstant-conversion]

Quoted 8 lines
         .max_pll_rate = (5000000000ULL < ULONG_MAX) ? 5000000000UL : ULONG_MAX,
                                                       ^~~~~~~~~~~~

Rewrite this to use a preprocessor conditional instead to avoid the warning.

Fixes 076437c9e360 ("drm/msm/dsi: move min/max PLL rate to phy config")
Quoted 25 lines

---
As found with another patch, using __builtin_choose_expr() would likely also work here, but doesn't seem any more readable.

---
  drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -1
index e76ce40a12ab..accd6b4eb7c2 100644
@@ -972,7 +972,11 @@ const struct msm_dsi_phy_cfg dsi_phy_7nm_cfgs = {
  		.restore_pll_state = dsi_7nm_pll_restore_state,
  	},
  	.min_pll_rate = 600000000UL,
-	.max_pll_rate = (5000000000ULL < ULONG_MAX) ? 5000000000ULL : ULONG_MAX,
+#ifdef CONFIG_64BIT
+	.max_pll_rate = 5000000000UL,
+#else
+	.max_pll_rate = ULONG_MAX,
+#endif
  	.io_start = { 0xae94400, 0xae96400 },
  	.num_dsi_phy = 2,
  	.quirks = DSI_PHY_7NM_QUIRK_V4_1,
Reviewed-by on v1 1/1
#2 lore raw
In reply to Arnd Bergmann
Quoted 7 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

clang is a little overzealous with warning about a constant conversion in an untaken branch of a ternary expression:

drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c:975:48: error: implicit conversion from 'unsigned long long' to 'unsigned long' changes value from 5000000000 to 705032704 [-Werror,-Wconstant-conversion]

Quoted 8 lines
        .max_pll_rate = (5000000000ULL < ULONG_MAX) ? 5000000000UL : ULONG_MAX,
                                                      ^~~~~~~~~~~~

Rewrite this to use a preprocessor conditional instead to avoid the warning.

Fixes 076437c9e360 ("drm/msm/dsi: move min/max PLL rate to phy config")
Quoted 27 lines

---
As found with another patch, using __builtin_choose_expr() would likely also work here, but doesn't seem any more readable.

---
 drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/dsi/phy/dsi_phy_7nm.c +5 -2
index e76ce40a12ab..accd6b4eb7c2 100644
@@ -972,7 +972,11 @@ const struct msm_dsi_phy_cfg dsi_phy_7nm_cfgs = {
                .restore_pll_state = dsi_7nm_pll_restore_state,
        },
        .min_pll_rate = 600000000UL,
-       .max_pll_rate = (5000000000ULL < ULONG_MAX) ? 5000000000ULL : ULONG_MAX,
+#ifdef CONFIG_64BIT
+       .max_pll_rate = 5000000000UL,
+#else
+       .max_pll_rate = ULONG_MAX,
+#endif
        .io_start = { 0xae94400, 0xae96400 },
        .num_dsi_phy = 2,
        .quirks = DSI_PHY_7NM_QUIRK_V4_1,
--

2.29.2

Signature · 2 lines
With best wishes
Dmitry