pinctrl: mediatek: convert most definitions to const
There exists a situation of the mediatek pinctrl driver that may return
wrong pin function value for the pinmux driver:
- All pin function arrays are defined without const
- Some pin function arrays contain all-zero value, e.g.:
static int mt7622_spi_funcs[] = { 0, 0, 0, 0, 0, 0, };
- These arrays will be put into .bss section during compilation
- .bss section has no "a" attribute and does not exist in the final binary
file after objcopy.
- FDT binary blob is appended to the u-boot binary, which occupies the
.bss section.
- During board_f stage, .bss has not been initialized, and contains the
data of FDT, which is not full-zero data.
- pinctrl driver is initialized in board_f stage, and it will get wrong
data if another driver is going to set default pinctrl.
Since pinmux information and soc data are only meant to be read-only, thus
should be declared as const. This will force all pinctrl data being put
into .rodata section. Since .rodata has "a" attribute, even the all-zero
data will be allocated and filled with correct value in to u-boot binary.
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8516.c b/drivers/pinctrl/mediatek/pinctrl-mt8516.c
index 6f94f76..7487d6f 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt8516.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt8516.c
@@ -326,12 +326,12 @@
*/
/* UART */
-static int mt8516_uart0_0_rxd_txd_pins[] = { 62, 63, };
-static int mt8516_uart0_0_rxd_txd_funcs[] = { 1, 1, };
-static int mt8516_uart1_0_rxd_txd_pins[] = { 64, 65, };
-static int mt8516_uart1_0_rxd_txd_funcs[] = { 1, 1, };
-static int mt8516_uart2_0_rxd_txd_pins[] = { 34, 35, };
-static int mt8516_uart2_0_rxd_txd_funcs[] = { 1, 1, };
+static const int mt8516_uart0_0_rxd_txd_pins[] = { 62, 63, };
+static const int mt8516_uart0_0_rxd_txd_funcs[] = { 1, 1, };
+static const int mt8516_uart1_0_rxd_txd_pins[] = { 64, 65, };
+static const int mt8516_uart1_0_rxd_txd_funcs[] = { 1, 1, };
+static const int mt8516_uart2_0_rxd_txd_pins[] = { 34, 35, };
+static const int mt8516_uart2_0_rxd_txd_funcs[] = { 1, 1, };
/* Joint those groups owning the same capability in user point of view which
* allows that people tend to use through the device tree.
@@ -341,9 +341,9 @@
"uart2_0_rxd_txd", };
/* MMC0 */
-static int mt8516_msdc0_pins[] = { 110, 111, 112, 113, 114, 115, 116, 117, 118,
- 119, 120, };
-static int mt8516_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
+static const int mt8516_msdc0_pins[] = { 110, 111, 112, 113, 114, 115, 116, 117,
+ 118, 119, 120, };
+static const int mt8516_msdc0_funcs[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, };
static const struct mtk_group_desc mt8516_groups[] = {
PINCTRL_PIN_GROUP("uart0_0_rxd_txd", mt8516_uart0_0_rxd_txd),