Skip to contentSkip to conversation

ddr:fsl: Fix warnings on gcc-6.x

PATCH New Tom Rini 2 participants 3 messages Feb 9, 2017 – Feb 10, 2017

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 ddr:fsl: Fix warnings on gcc-6.x

With gcc-6.x we will see many warnings like:
warning: ?dual_0S? defined but not used [-Wunused-const-variable=]

Depending on exactly what DDR choices are or are not enabled when we use this file. So we use slightly more exact #ifdef tests in order to silence the warnings.

---
 drivers/ddr/fsl/options.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
drivers/ddr/fsl/options.c +24 -3
index d6a8fcb216a4..7f7c16ced6f3 100644
@@ -29,10 +29,12 @@ struct dynamic_odt {
 	unsigned int odt_rtt_wr;
 };
 
-#ifdef CONFIG_SYS_FSL_DDR4
+#if defined(CONFIG_SYS_FSL_DDR4) && defined(CONFIG_DIMM_SLOTS_PER_CTLR)
 /* Quad rank is not verified yet due availability.
  * Replacing 20 OHM with 34 OHM since DDR4 doesn't have 20 OHM option
  */
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) || ((CONFIG_DIMM_SLOTS_PER_CTLR == 2) && \
+				defined(CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE))
 static const struct dynamic_odt single_Q[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -59,7 +61,9 @@ static const struct dynamic_odt single_Q[4] = {
 		DDR4_RTT_120_OHM
 	}
 };
+#endif
 
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1)
 static const struct dynamic_odt single_D[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -89,6 +93,8 @@ static const struct dynamic_odt single_S[4] = {
 	{0, 0, 0, 0},
 };
 
+#elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2)
+
 static const struct dynamic_odt dual_DD[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -235,6 +241,7 @@ static const struct dynamic_odt dual_0S[4] = {
 	{0, 0, 0, 0}
 
 };
+#endif
 
 static const struct dynamic_odt odt_unknown[4] = {
 	{	/* cs0 */
@@ -262,7 +269,9 @@ static const struct dynamic_odt odt_unknown[4] = {
 		DDR4_RTT_OFF
 	}
 };
-#elif defined(CONFIG_SYS_FSL_DDR3)
+#elif defined(CONFIG_SYS_FSL_DDR3) && defined(CONFIG_DIMM_SLOTS_PER_CTLR)
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) || ((CONFIG_DIMM_SLOTS_PER_CTLR == 2) && \
+				defined(CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE))
 static const struct dynamic_odt single_Q[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -289,7 +298,9 @@ static const struct dynamic_odt single_Q[4] = {
 		DDR3_RTT_120_OHM
 	}
 };
+#endif
 
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1)
 static const struct dynamic_odt single_D[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -319,6 +330,8 @@ static const struct dynamic_odt single_S[4] = {
 	{0, 0, 0, 0},
 };
 
+#elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2)
+
 static const struct dynamic_odt dual_DD[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -465,6 +478,7 @@ static const struct dynamic_odt dual_0S[4] = {
 	{0, 0, 0, 0}
 
 };
+#endif
 
 static const struct dynamic_odt odt_unknown[4] = {
 	{	/* cs0 */
@@ -492,14 +506,18 @@ static const struct dynamic_odt odt_unknown[4] = {
 		DDR3_RTT_OFF
 	}
 };
-#else	/* CONFIG_SYS_FSL_DDR3 */
+#elif defined(CONFIG_SYS_FSL_DDR2) && defined(CONFIG_DIMM_SLOTS_PER_CTLR)
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) || ((CONFIG_DIMM_SLOTS_PER_CTLR == 2) && \
+				defined(CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE))
 static const struct dynamic_odt single_Q[4] = {
 	{0, 0, 0, 0},
 	{0, 0, 0, 0},
 	{0, 0, 0, 0},
 	{0, 0, 0, 0}
 };
+#endif
 
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1)
 static const struct dynamic_odt single_D[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -529,6 +547,8 @@ static const struct dynamic_odt single_S[4] = {
 	{0, 0, 0, 0},
 };
 
+#elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2)
+
 static const struct dynamic_odt dual_DD[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_OTHER_DIMM,
@@ -676,6 +696,7 @@ static const struct dynamic_odt dual_0S[4] = {
 	{0, 0, 0, 0}
 
 };
+#endif
 
 static const struct dynamic_odt odt_unknown[4] = {
 	{	/* cs0 */
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 ddr:fsl: Fix warnings on gcc-6.x

Quoted 43 lines · Tom Rini

With gcc-6.x we will see many warnings like:
warning: ?dual_0S? defined but not used [-Wunused-const-variable=]

Depending on exactly what DDR choices are or are not enabled when we use this file. So we use slightly more exact #ifdef tests in order to silence the warnings.

---
 drivers/ddr/fsl/options.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
drivers/ddr/fsl/options.c +5 -1
index d6a8fcb216a4..7f7c16ced6f3 100644
@@ -29,10 +29,12 @@ struct dynamic_odt {
 	unsigned int odt_rtt_wr;
 };
 
-#ifdef CONFIG_SYS_FSL_DDR4
+#if defined(CONFIG_SYS_FSL_DDR4) && defined(CONFIG_DIMM_SLOTS_PER_CTLR)
 /* Quad rank is not verified yet due availability.
  * Replacing 20 OHM with 34 OHM since DDR4 doesn't have 20 OHM option
  */
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) || ((CONFIG_DIMM_SLOTS_PER_CTLR == 2) && \
+				defined(CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE))
 static const struct dynamic_odt single_Q[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -59,7 +61,9 @@ static const struct dynamic_odt single_Q[4] = {
 		DDR4_RTT_120_OHM
 	}
 };
+#endif
 
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1)
 static const struct dynamic_odt single_D[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,

drivers/ddr/fsl/options.c static const struct dynamic_odt single_S[4] = { · line 97

Quoted 5 lines
drivers/ddr/fsl/options.c +2 -0
@@ -89,6 +93,8 @@ static const struct dynamic_odt single_S[4] = {
 	{0, 0, 0, 0},
 };
 
+#elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2)
+

<snip>

Tom,

What do you think about using __maybe_unused instead? As Thomas Schaefer has verified that GCC optimized out unused constants.

York

author
#2 lore raw

PATCH 1/1 ddr:fsl: Fix warnings on gcc-6.x

Quoted 52 lines · york sun
Quoted 48 lines · Tom Rini

With gcc-6.x we will see many warnings like:
warning: ?dual_0S? defined but not used [-Wunused-const-variable=]

Depending on exactly what DDR choices are or are not enabled when we use this file. So we use slightly more exact #ifdef tests in order to silence the warnings.

---
 drivers/ddr/fsl/options.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)
drivers/ddr/fsl/options.c +7 -1
index d6a8fcb216a4..7f7c16ced6f3 100644
@@ -29,10 +29,12 @@ struct dynamic_odt {
 	unsigned int odt_rtt_wr;
 };
 
-#ifdef CONFIG_SYS_FSL_DDR4
+#if defined(CONFIG_SYS_FSL_DDR4) && defined(CONFIG_DIMM_SLOTS_PER_CTLR)
 /* Quad rank is not verified yet due availability.
  * Replacing 20 OHM with 34 OHM since DDR4 doesn't have 20 OHM option
  */
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1) || ((CONFIG_DIMM_SLOTS_PER_CTLR == 2) && \
+				defined(CONFIG_FSL_DDR_FIRST_SLOT_QUAD_CAPABLE))
 static const struct dynamic_odt single_Q[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -59,7 +61,9 @@ static const struct dynamic_odt single_Q[4] = {
 		DDR4_RTT_120_OHM
 	}
 };
+#endif
 
+#if (CONFIG_DIMM_SLOTS_PER_CTLR == 1)
 static const struct dynamic_odt single_D[4] = {
 	{	/* cs0 */
 		FSL_DDR_ODT_NEVER,
@@ -89,6 +93,8 @@ static const struct dynamic_odt single_S[4] = {
 	{0, 0, 0, 0},
 };
 
+#elif (CONFIG_DIMM_SLOTS_PER_CTLR == 2)
+

<snip>

Quoted 4 lines

Tom,

What do you think about using __maybe_unused instead? As Thomas Schaefer has verified that GCC optimized out unused constants.

Yeah, that ends up being clearer I think esp since we're not concerned with the data being included by accident. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20170210/2c92f466/attachment.sig>