[OpenWrt-Devel] [PATCH] kernel: modules: fix kmod-regmap

Christian Lamparter chunkeey at gmail.com
Wed Aug 1 16:44:01 EDT 2018


On Wednesday, August 1, 2018 3:21:00 PM CEST Jonas Gorski wrote:
> On 30 July 2018 at 22:35, John Crispin <john at phrozen.org> wrote:
> > On 30/07/18 22:33, Christian Lamparter wrote:
> >>
> >> This patch fixes the a compile issue that was triggered by
> >> apm821xx/sata when kmod-regmap was selected.
> >>
> >> The CONFIG_REGMAP is declared in drivers/base/regmap/Kconfig
> >> as type "bool" and not "tristate". Hence the symbol should
> >> never be set to module, as this confuses the #if CONFIG_REGMAP
> >> guards in include/linux/regmap.h:
> >>
> >> |.../drivers/regulator/core.c:4041: undefined reference to
> >> `dev_get_regmap'
> >> |.../drivers/regulator/core.c:4042: undefined reference to
> >> `dev_get_regmap'
> >> |.../drivers/regulator/core.c:4044: undefined reference to
> >> `dev_get_regmap'
> >> |.../drivers/regulator/helpers.o: In function
> >> `regulator_is_enabled_regmap':
> >> |.../drivers/regulator/helpers.c:36: undefined reference to `regmap_read'
> >> |...
> >
> > i started a test build 2 minutes ago to figure this one out :-) thanks !
> 
> This is actually the wrong fix and papers over an issue in one of our
> local patches.
> 
> We intentionally allow regmap to be built as a module, see
> 
> https://github.com/openwrt/openwrt/blob/master/target/linux/generic/hack-4.14/259-regmap_dynamic.patch
> 
> So there are likely some additional EXPORT_SYMBOL_GPL()s required instead.

Thanks for FYI, I missed this patch completely.

I found that the issue lies in the upstream regulator core code.
It is using these regmap's functions. And the CONFIG_REGULATOR symbol that pulls
in the core's code is sadly a bool menuconfig option... so CONFIG_REGMAP pretty
much becomes a requirement/select for the REGULATOR.

---
diff --git a/target/linux/generic/hack-4.14/259-regmap_dynamic.patch b/target/linux/generic/hack-4.14/259-regmap_dynamic.patch
index 1c6e78df30..35803c3181 100644
--- a/target/linux/generic/hack-4.14/259-regmap_dynamic.patch
+++ b/target/linux/generic/hack-4.14/259-regmap_dynamic.patch
@@ -9,8 +9,9 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
  drivers/base/regmap/Kconfig  | 15 ++++++++++-----
  drivers/base/regmap/Makefile | 12 ++++++++----
  drivers/base/regmap/regmap.c |  3 +++
+ drivers/regulator/Kconfig    |  1 +
  include/linux/regmap.h       |  2 +-
- 4 files changed, 22 insertions(+), 10 deletions(-)
+ 5 files changed, 23 insertions(+), 10 deletions(-)
 
 --- a/drivers/base/regmap/Kconfig
 +++ b/drivers/base/regmap/Kconfig
@@ -96,6 +97,15 @@ Signed-off-by: Felix Fietkau <nbd at nbd.name>
  postcore_initcall(regmap_initcall);
 +
 +MODULE_LICENSE("GPL");
+--- a/drivers/regulator/Kconfig
++++ b/drivers/regulator/Kconfig
+@@ -1,5 +1,6 @@
+ menuconfig REGULATOR
+ 	bool "Voltage and Current Regulator Support"
++	select REGMAP
+ 	help
+ 	  Generic Voltage and Current Regulator support.
+ 
 --- a/include/linux/regmap.h
 +++ b/include/linux/regmap.h
 @@ -139,7 +139,7 @@ struct reg_sequence {
---

or alternatively, I could just add the
CONFIG_REGMAP=y
(This is possible thanks to the changes in 259-regmap_dynamic.patch)
to the apm821xx/sata config:

---
diff --git a/target/linux/apm821xx/sata/config-default b/target/linux/apm821xx/sata/config-default
index 5af8c338f5..c267e7cddc 100644
--- a/target/linux/apm821xx/sata/config-default
+++ b/target/linux/apm821xx/sata/config-default
@@ -45,5 +45,6 @@ CONFIG_PPC_EARLY_DEBUG_44x=y
 # CONFIG_PPC_EARLY_DEBUG_MEMCONS is not set
 CONFIG_PPC_EARLY_DEBUG_44x_PHYSHIGH=0x4
 CONFIG_PPC_EARLY_DEBUG_44x_PHYSLOW=0xef600300
+CONFIG_REGMAP=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
---

What is prefered? I like the first patch more, since it would avoid such
a error in the future. But it does add to the pile of hacks.

Regards,
Christian



_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list