Skip to contentSkip to conversation

soc: mediatek: Let PMIC Wrapper and SCPSYS depend on OF

PATCH Applied Jean Delvare 2 participants 2 messages Jul 30, 2022 – Aug 25, 2022 Arm MediaTek

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 soc: mediatek: Let PMIC Wrapper and SCPSYS depend on OF

With the following configuration options:
CONFIG_OF is not set
CONFIG_MTK_PMIC_WRAP=y
CONFIG_MTK_SCPSYS=y
we get the following build warnings:

CC drivers/soc/mediatek/mtk-pmic-wrap.o
drivers/soc/mediatek/mtk-pmic-wrap.c:2138:34: warning: ‘of_pwrap_match_tbl’ defined but not used [-Wunused-const-variable=] drivers/soc/mediatek/mtk-pmic-wrap.c:1953:34: warning: ‘of_slave_match_tbl’ defined but not used [-Wunused-const-variable=]
CC drivers/soc/mediatek/mtk-scpsys.o
drivers/soc/mediatek/mtk-scpsys.c:1084:34: warning: ‘of_scpsys_match_tbl’ defined but not used [-Wunused-const-variable=]

Looking at the code, both drivers can only bind to OF-defined device nodes, so these drivers are useless without OF and should therefore depend on it.

Also drop of_match_ptr() from both drivers. We already know what it will resolve to, so we might as well save cpp some work.

Developers or QA teams who wish to test-build the code can still do so by enabling CONFIG_OF, which is available on all architectures and has no dependencies.

---
Changes since v1:
* Drop of_match_ptr() (suggested by AngeloGioacchino Del Regno

 drivers/soc/mediatek/Kconfig         |    2 ++
 drivers/soc/mediatek/mtk-pmic-wrap.c |    2 +-
 drivers/soc/mediatek/mtk-scpsys.c    |    2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)
drivers/soc/mediatek/Kconfig +2 -0
@@ -37,6 +37,7 @@ config MTK_INFRACFG
 config MTK_PMIC_WRAP
 	tristate "MediaTek PMIC Wrapper Support"
 	depends on RESET_CONTROLLER
+	depends on OF
 	select REGMAP
 	help
 	  Say yes here to add support for MediaTek PMIC Wrapper found
@@ -46,6 +47,7 @@ config MTK_PMIC_WRAP
 config MTK_SCPSYS
 	bool "MediaTek SCPSYS Support"
 	default ARCH_MEDIATEK
+	depends on OF
 	select REGMAP
 	select MTK_INFRACFG
 	select PM_GENERIC_DOMAINS if PM
drivers/soc/mediatek/mtk-pmic-wrap.c +1 -1
@@ -2347,7 +2347,7 @@ static int pwrap_probe(struct platform_d
 static struct platform_driver pwrap_drv = {
 	.driver = {
 		.name = "mt-pmic-pwrap",
-		.of_match_table = of_match_ptr(of_pwrap_match_tbl),
+		.of_match_table = of_pwrap_match_tbl,
 	},
 	.probe = pwrap_probe,
 };
drivers/soc/mediatek/mtk-scpsys.c +1 -1
@@ -1141,7 +1141,7 @@ static struct platform_driver scpsys_drv
 		.name = "mtk-scpsys",
 		.suppress_bind_attrs = true,
 		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(of_scpsys_match_tbl),
+		.of_match_table = of_scpsys_match_tbl,
 	},
 };
 builtin_platform_driver(scpsys_drv);
Signature · 2 lines
Jean Delvare
SUSE L3 Support
maintainer Applied
#1 lore raw
Quoted 23 lines · Jean Delvare

With the following configuration options:
CONFIG_OF is not set
CONFIG_MTK_PMIC_WRAP=y
CONFIG_MTK_SCPSYS=y
we get the following build warnings:

CC drivers/soc/mediatek/mtk-pmic-wrap.o
drivers/soc/mediatek/mtk-pmic-wrap.c:2138:34: warning: ‘of_pwrap_match_tbl’ defined but not used [-Wunused-const-variable=] drivers/soc/mediatek/mtk-pmic-wrap.c:1953:34: warning: ‘of_slave_match_tbl’ defined but not used [-Wunused-const-variable=]
CC drivers/soc/mediatek/mtk-scpsys.o
drivers/soc/mediatek/mtk-scpsys.c:1084:34: warning: ‘of_scpsys_match_tbl’ defined but not used [-Wunused-const-variable=]

Looking at the code, both drivers can only bind to OF-defined device nodes, so these drivers are useless without OF and should therefore depend on it.

Also drop of_match_ptr() from both drivers. We already know what it will resolve to, so we might as well save cpp some work.

Developers or QA teams who wish to test-build the code can still do so by enabling CONFIG_OF, which is available on all architectures and has no dependencies.

Quoted 5 lines

Applied, thanks!

Quoted 50 lines

---
Changes since v1:
* Drop of_match_ptr() (suggested by AngeloGioacchino Del Regno

  drivers/soc/mediatek/Kconfig         |    2 ++
  drivers/soc/mediatek/mtk-pmic-wrap.c |    2 +-
  drivers/soc/mediatek/mtk-scpsys.c    |    2 +-
  3 files changed, 4 insertions(+), 2 deletions(-)
drivers/soc/mediatek/Kconfig +2 -0
@@ -37,6 +37,7 @@ config MTK_INFRACFG
  config MTK_PMIC_WRAP
  	tristate "MediaTek PMIC Wrapper Support"
  	depends on RESET_CONTROLLER
+	depends on OF
  	select REGMAP
  	help
  	  Say yes here to add support for MediaTek PMIC Wrapper found
@@ -46,6 +47,7 @@ config MTK_PMIC_WRAP
  config MTK_SCPSYS
  	bool "MediaTek SCPSYS Support"
  	default ARCH_MEDIATEK
+	depends on OF
  	select REGMAP
  	select MTK_INFRACFG
  	select PM_GENERIC_DOMAINS if PM
drivers/soc/mediatek/mtk-pmic-wrap.c +1 -1
@@ -2347,7 +2347,7 @@ static int pwrap_probe(struct platform_d
  static struct platform_driver pwrap_drv = {
  	.driver = {
  		.name = "mt-pmic-pwrap",
-		.of_match_table = of_match_ptr(of_pwrap_match_tbl),
+		.of_match_table = of_pwrap_match_tbl,
  	},
  	.probe = pwrap_probe,
  };
drivers/soc/mediatek/mtk-scpsys.c +1 -1
@@ -1141,7 +1141,7 @@ static struct platform_driver scpsys_drv
  		.name = "mtk-scpsys",
  		.suppress_bind_attrs = true,
  		.owner = THIS_MODULE,
-		.of_match_table = of_match_ptr(of_scpsys_match_tbl),
+		.of_match_table = of_scpsys_match_tbl,
  	},
  };
  builtin_platform_driver(scpsys_drv);