c62e0a6242d67afa8f35da313ceef3ce4598d74d
[openwrt/staging/981213.git] / target / linux / generic / hack-6.6 / 259-regmap_dynamic.patch
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
5
6 lede-commit: 96f39119815028073583e4fca3a9c5fe9141e998
7 Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 ---
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(-)
14
15 --- a/drivers/base/regmap/Kconfig
16 +++ b/drivers/base/regmap/Kconfig
17 @@ -4,8 +4,7 @@
18 # subsystems should select the appropriate symbols.
19
20 config REGMAP
21 - bool
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)
23 + tristate
24 select IRQ_DOMAIN if REGMAP_IRQ
25 select MDIO_BUS if REGMAP_MDIO
26 help
27 @@ -19,7 +18,7 @@ config REGMAP
28
29 config REGMAP_KUNIT
30 tristate "KUnit tests for regmap"
31 - depends on KUNIT && REGMAP
32 + depends on KUNIT
33 default KUNIT_ALL_TESTS
34 select REGMAP_RAM
35
36 @@ -34,60 +33,76 @@ config REGMAP_BUILD
37 normally enabled.
38
39 config REGMAP_AC97
40 + select REGMAP
41 tristate
42
43 config REGMAP_I2C
44 + select REGMAP
45 tristate
46 depends on I2C
47
48 config REGMAP_SLIMBUS
49 + select REGMAP
50 tristate
51 depends on SLIMBUS
52
53 config REGMAP_SPI
54 + select REGMAP
55 tristate
56 depends on SPI
57
58 config REGMAP_SPMI
59 + select REGMAP
60 tristate
61 depends on SPMI
62
63 config REGMAP_W1
64 + select REGMAP
65 tristate
66 depends on W1
67
68 config REGMAP_MDIO
69 + select REGMAP
70 tristate
71
72 config REGMAP_MMIO
73 + select REGMAP
74 tristate
75
76 config REGMAP_IRQ
77 + select REGMAP
78 bool
79
80 config REGMAP_RAM
81 + select REGMAP
82 tristate
83
84 config REGMAP_SOUNDWIRE
85 + select REGMAP
86 tristate
87 depends on SOUNDWIRE
88
89 config REGMAP_SOUNDWIRE_MBQ
90 + select REGMAP
91 tristate
92 depends on SOUNDWIRE
93
94 config REGMAP_SCCB
95 + select REGMAP
96 tristate
97 depends on I2C
98
99 config REGMAP_I3C
100 + select REGMAP
101 tristate
102 depends on I3C
103
104 config REGMAP_SPI_AVMM
105 + select REGMAP
106 tristate
107 depends on SPI
108
109 config REGMAP_FSI
110 + select REGMAP
111 tristate
112 depends on FSI
113 --- a/drivers/base/regmap/Makefile
114 +++ b/drivers/base/regmap/Makefile
115 @@ -2,9 +2,11 @@
116 # For include/trace/define_trace.h to include trace.h
117 CFLAGS_regmap.o := -I$(src)
118
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
125 +endif
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
132 @@ -9,6 +9,7 @@
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 @@ -3513,3 +3514,5 @@ static int __init regmap_initcall(void)
141 return 0;
142 }
143 postcore_initcall(regmap_initcall);
144 +
145 +MODULE_LICENSE("GPL");
146 --- a/include/linux/regmap.h
147 +++ b/include/linux/regmap.h
148 @@ -180,7 +180,7 @@ struct reg_sequence {
149 __ret ?: __tmp; \
150 })
151
152 -#ifdef CONFIG_REGMAP
153 +#if IS_REACHABLE(CONFIG_REGMAP)
154
155 enum regmap_endian {
156 /* Unspecified -> 0 -> Backwards compatible default */