1 From 811d9e2268a62b830cfe93cd8bc929afcb8b198b Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Sat, 15 Jul 2017 21:12:38 +0200
4 Subject: kernel: move regmap bloat out of the kernel image if it is only being used in modules
6 lede-commit: 96f39119815028073583e4fca3a9c5fe9141e998
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
9 drivers/base/regmap/Kconfig | 15 ++++++++++-----
10 drivers/base/regmap/Makefile | 12 ++++++++----
11 drivers/base/regmap/regmap.c | 3 +++
12 include/linux/regmap.h | 2 +-
13 4 files changed, 22 insertions(+), 10 deletions(-)
15 --- a/drivers/base/regmap/Kconfig
16 +++ b/drivers/base/regmap/Kconfig
18 # subsystems should select the appropriate symbols.
22 - default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || REGMAP_W1 || REGMAP_AC97 || REGMAP_MMIO || REGMAP_IRQ || REGMAP_SOUNDWIRE || REGMAP_SOUNDWIRE_MBQ || REGMAP_SCCB || REGMAP_I3C || REGMAP_SPI_AVMM || REGMAP_MDIO || REGMAP_FSI)
24 select IRQ_DOMAIN if REGMAP_IRQ
25 select MDIO_BUS if REGMAP_MDIO
27 @@ -19,7 +18,7 @@ config REGMAP
30 tristate "KUnit tests for regmap"
31 - depends on KUNIT && REGMAP
33 default KUNIT_ALL_TESTS
36 @@ -34,60 +33,76 @@ config REGMAP_BUILD
84 config REGMAP_SOUNDWIRE
89 config REGMAP_SOUNDWIRE_MBQ
104 config REGMAP_SPI_AVMM
113 --- a/drivers/base/regmap/Makefile
114 +++ b/drivers/base/regmap/Makefile
116 # For include/trace/define_trace.h to include trace.h
117 CFLAGS_regmap.o := -I$(src)
119 -obj-$(CONFIG_REGMAP) += regmap.o regcache.o
120 -obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o regcache-maple.o
121 -obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
122 +regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-flat.o regcache-maple.o
123 +ifdef CONFIG_DEBUG_FS
124 +regmap-core-objs += regmap-debugfs.o
126 +obj-$(CONFIG_REGMAP) += regmap-core.o
127 obj-$(CONFIG_REGMAP_KUNIT) += regmap-kunit.o
128 obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o
129 obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
130 --- a/drivers/base/regmap/regmap.c
131 +++ b/drivers/base/regmap/regmap.c
133 #include <linux/device.h>
134 #include <linux/slab.h>
135 #include <linux/export.h>
136 +#include <linux/module.h>
137 #include <linux/mutex.h>
138 #include <linux/err.h>
139 #include <linux/property.h>
140 @@ -3433,3 +3434,5 @@ static int __init regmap_initcall(void)
143 postcore_initcall(regmap_initcall);
145 +MODULE_LICENSE("GPL");
146 --- a/include/linux/regmap.h
147 +++ b/include/linux/regmap.h
148 @@ -197,7 +197,7 @@ struct reg_sequence {
152 -#ifdef CONFIG_REGMAP
153 +#if IS_REACHABLE(CONFIG_REGMAP)
156 /* Unspecified -> 0 -> Backwards compatible default */