Skip to contentSkip to conversation

net: stmmac: xgmac: fix initializer element is not constant error

PATCH In review Mark O'Donovan 3 participants 5 messages Feb 12, 2024 – Feb 15, 2024

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

PATCH 1/1 net: stmmac: xgmac: fix initializer element is not constant error

GCC prior to 8.x gives an "initializer element is not constant" error for the uses of dpp_tx_err in dwxgmac3_dma_dpp_errors. Newer compilers accept either version.

More info here:
https://lore.kernel.org/all/20240103-fix-bq24190_charger-vbus_desc-non-const-v1-1-115ddf798c70@kernel.org

---
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +2 -2
index 323c57f03c93..c02c035b81c0 100644
@@ -830,8 +830,8 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= {
 	{ false, "UNKNOWN", "Unknown Error" }, /* 31 */
 };
 
-static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error";
-static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error";
+#define dpp_rx_err "Read Rx Descriptor Parity checker Error"
+#define dpp_tx_err "Read Tx Descriptor Parity checker Error"
 static const struct dwxgmac3_error_desc dwxgmac3_dma_dpp_errors[32] = {
 	{ true, "TDPES0", dpp_tx_err },
 	{ true, "TDPES1", dpp_tx_err },

base-commit: 841c35169323cd833294798e58b9bf63fa4fa1de

Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Mark O'Donovan

GCC prior to 8.x gives an "initializer element is not constant" error for the uses of dpp_tx_err in dwxgmac3_dma_dpp_errors. Newer compilers accept either version.

More info here:
https://lore.kernel.org/all/20240103-fix-bq24190_charger-vbus_desc-non-const-v1-1-115ddf798c70@kernel.org

---

I'm not sure whether the Linux kernel project has an explicit cutoff for what versions of GCC (or other compilers) are supported. GCC 8 was first released in 2018.

The fix provided here is fairly straight forward, and while I do think the benefit of using builtin types vs using the macros is nice, I don't see that as a strong enough reason to hold up supporting the older compiler.

Quoted 20 lines
 drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +2 -2
index 323c57f03c93..c02c035b81c0 100644
@@ -830,8 +830,8 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= {
 	{ false, "UNKNOWN", "Unknown Error" }, /* 31 */
 };
 
-static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error";
-static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error";
+#define dpp_rx_err "Read Rx Descriptor Parity checker Error"
+#define dpp_tx_err "Read Tx Descriptor Parity checker Error"
 static const struct dwxgmac3_error_desc dwxgmac3_dma_dpp_errors[32] = {
 	{ true, "TDPES0", dpp_tx_err },
 	{ true, "TDPES1", dpp_tx_err },

base-commit: 841c35169323cd833294798e58b9bf63fa4fa1de

#2 lore raw
Quoted 42 lines · Jacob Keller
Quoted 9 lines · Mark O'Donovan

GCC prior to 8.x gives an "initializer element is not constant" error for the uses of dpp_tx_err in dwxgmac3_dma_dpp_errors. Newer compilers accept either version.

More info here:
https://lore.kernel.org/all/20240103-fix-bq24190_charger-vbus_desc-non-const-v1-1-115ddf798c70@kernel.org

---

I'm not sure whether the Linux kernel project has an explicit cutoff for what versions of GCC (or other compilers) are supported. GCC 8 was first released in 2018.

The fix provided here is fairly straight forward, and while I do think the benefit of using builtin types vs using the macros is nice, I don't see that as a strong enough reason to hold up supporting the older compiler.

Quoted 19 lines
  drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +2 -2
index 323c57f03c93..c02c035b81c0 100644
@@ -830,8 +830,8 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= {
  	{ false, "UNKNOWN", "Unknown Error" }, /* 31 */
  };
 
-static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error";
-static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error";
+#define dpp_rx_err "Read Rx Descriptor Parity checker Error"
+#define dpp_tx_err "Read Tx Descriptor Parity checker Error"
  static const struct dwxgmac3_error_desc dwxgmac3_dma_dpp_errors[32] = {
  	{ true, "TDPES0", dpp_tx_err },
  	{ true, "TDPES1", dpp_tx_err },
Quoted 1 line
Quoted 1 line

base-commit: 841c35169323cd833294798e58b9bf63fa4fa1de

Thanks Jacob.

The minimum versions for compilers and other tools are documented here:
https://www.kernel.org/doc/html/latest/process/changes.html

I am using a SLES 15 server to build, the first version of which came out in 2017.

Mark

maintainer
#3 lore raw

Hi,

Quoted 43 lines · Mark O'Donovan
Quoted 42 lines · Jacob Keller
Quoted 9 lines · Mark O'Donovan

GCC prior to 8.x gives an "initializer element is not constant" error for the uses of dpp_tx_err in dwxgmac3_dma_dpp_errors. Newer compilers accept either version.

More info here:
https://lore.kernel.org/all/20240103-fix-bq24190_charger-vbus_desc-non-const-v1-1-115ddf798c70@kernel.org

---

I'm not sure whether the Linux kernel project has an explicit cutoff for what versions of GCC (or other compilers) are supported. GCC 8 was first released in 2018.

The fix provided here is fairly straight forward, and while I do think the benefit of using builtin types vs using the macros is nice, I don't see that as a strong enough reason to hold up supporting the older compiler.

Quoted 19 lines
  drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +2 -2
index 323c57f03c93..c02c035b81c0 100644
@@ -830,8 +830,8 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= {
  	{ false, "UNKNOWN", "Unknown Error" }, /* 31 */
  };
 
-static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error";
-static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error";
+#define dpp_rx_err "Read Rx Descriptor Parity checker Error"
+#define dpp_tx_err "Read Tx Descriptor Parity checker Error"
  static const struct dwxgmac3_error_desc dwxgmac3_dma_dpp_errors[32] = {
  	{ true, "TDPES0", dpp_tx_err },
  	{ true, "TDPES1", dpp_tx_err },
Quoted 8 lines
Quoted 1 line
Quoted 1 line

base-commit: 841c35169323cd833294798e58b9bf63fa4fa1de

Thanks Jacob.

The minimum versions for compilers and other tools are documented here:
https://www.kernel.org/doc/html/latest/process/changes.html

I am using a SLES 15 server to build, the first version of which came out in 2017.

Note that we already have net commit 1692b9775e745f84b69dc8ad0075b0855a43db4e addressing this issue.

Thanks,

Paolo

#4 lore raw
In reply to Mark O'Donovan
Quoted 47 lines · Mark O'Donovan
Quoted 42 lines · Jacob Keller
Quoted 9 lines · Mark O'Donovan

GCC prior to 8.x gives an "initializer element is not constant" error for the uses of dpp_tx_err in dwxgmac3_dma_dpp_errors. Newer compilers accept either version.

More info here:
https://lore.kernel.org/all/20240103-fix-bq24190_charger-vbus_desc-non-const-v1-1-115ddf798c70@kernel.org

---

I'm not sure whether the Linux kernel project has an explicit cutoff for what versions of GCC (or other compilers) are supported. GCC 8 was first released in 2018.

The fix provided here is fairly straight forward, and while I do think the benefit of using builtin types vs using the macros is nice, I don't see that as a strong enough reason to hold up supporting the older compiler.

Quoted 19 lines
  drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwxgmac2_core.c +2 -2
index 323c57f03c93..c02c035b81c0 100644
@@ -830,8 +830,8 @@ static const struct dwxgmac3_error_desc dwxgmac3_dma_errors[32]= {
  	{ false, "UNKNOWN", "Unknown Error" }, /* 31 */
  };
 
-static const char * const dpp_rx_err = "Read Rx Descriptor Parity checker Error";
-static const char * const dpp_tx_err = "Read Tx Descriptor Parity checker Error";
+#define dpp_rx_err "Read Rx Descriptor Parity checker Error"
+#define dpp_tx_err "Read Tx Descriptor Parity checker Error"
  static const struct dwxgmac3_error_desc dwxgmac3_dma_dpp_errors[32] = {
  	{ true, "TDPES0", dpp_tx_err },
  	{ true, "TDPES1", dpp_tx_err },
Quoted 1 line
Quoted 1 line

base-commit: 841c35169323cd833294798e58b9bf63fa4fa1de

Thanks Jacob.

Quoted 6 lines

The minimum versions for compilers and other tools are documented here:
https://www.kernel.org/doc/html/latest/process/changes.html

I am using a SLES 15 server to build, the first version of which came out in 2017.

Mark

Thanks for pointing this out, I failed to find it with grep. Useful to have this as a reference.