407bc72ac8dbd1ef725b84d58a8af31a9aa4788c
[openwrt/staging/stintel.git] / target / linux / generic / hack-6.1 / 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,10 +4,9 @@
18 # subsystems should select the appropriate symbols.
19
20 config REGMAP
21 - 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)
22 select IRQ_DOMAIN if REGMAP_IRQ
23 select MDIO_BUS if REGMAP_MDIO
24 - bool
25 + tristate
26
27 config REGCACHE_COMPRESSED
28 select LZO_COMPRESS
29 @@ -15,53 +14,67 @@ config REGCACHE_COMPRESSED
30 bool
31
32 config REGMAP_AC97
33 + select REGMAP
34 tristate
35
36 config REGMAP_I2C
37 + select REGMAP
38 tristate
39 depends on I2C
40
41 config REGMAP_SLIMBUS
42 + select REGMAP
43 tristate
44 depends on SLIMBUS
45
46 config REGMAP_SPI
47 + select REGMAP
48 tristate
49 depends on SPI
50
51 config REGMAP_SPMI
52 + select REGMAP
53 tristate
54 depends on SPMI
55
56 config REGMAP_W1
57 + select REGMAP
58 tristate
59 depends on W1
60
61 config REGMAP_MDIO
62 + select REGMAP
63 tristate
64
65 config REGMAP_MMIO
66 + select REGMAP
67 tristate
68
69 config REGMAP_IRQ
70 + select REGMAP
71 bool
72
73 config REGMAP_SOUNDWIRE
74 + select REGMAP
75 tristate
76 depends on SOUNDWIRE
77
78 config REGMAP_SOUNDWIRE_MBQ
79 + select REGMAP
80 tristate
81 depends on SOUNDWIRE
82
83 config REGMAP_SCCB
84 + select REGMAP
85 tristate
86 depends on I2C
87
88 config REGMAP_I3C
89 + select REGMAP
90 tristate
91 depends on I3C
92
93 config REGMAP_SPI_AVMM
94 + select REGMAP
95 tristate
96 depends on SPI
97 --- a/drivers/base/regmap/Makefile
98 +++ b/drivers/base/regmap/Makefile
99 @@ -2,10 +2,14 @@
100 # For include/trace/define_trace.h to include trace.h
101 CFLAGS_regmap.o := -I$(src)
102
103 -obj-$(CONFIG_REGMAP) += regmap.o regcache.o
104 -obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o
105 -obj-$(CONFIG_REGCACHE_COMPRESSED) += regcache-lzo.o
106 -obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
107 +regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-flat.o
108 +ifdef CONFIG_DEBUG_FS
109 +regmap-core-objs += regmap-debugfs.o
110 +endif
111 +ifdef CONFIG_REGCACHE_COMPRESSED
112 +regmap-core-objs += regcache-lzo.o
113 +endif
114 +obj-$(CONFIG_REGMAP) += regmap-core.o
115 obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o
116 obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
117 obj-$(CONFIG_REGMAP_SLIMBUS) += regmap-slimbus.o
118 --- a/drivers/base/regmap/regmap.c
119 +++ b/drivers/base/regmap/regmap.c
120 @@ -9,6 +9,7 @@
121 #include <linux/device.h>
122 #include <linux/slab.h>
123 #include <linux/export.h>
124 +#include <linux/module.h>
125 #include <linux/mutex.h>
126 #include <linux/err.h>
127 #include <linux/property.h>
128 @@ -3511,3 +3512,5 @@ static int __init regmap_initcall(void)
129 return 0;
130 }
131 postcore_initcall(regmap_initcall);
132 +
133 +MODULE_LICENSE("GPL");
134 --- a/include/linux/regmap.h
135 +++ b/include/linux/regmap.h
136 @@ -180,7 +180,7 @@ struct reg_sequence {
137 __ret ?: __tmp; \
138 })
139
140 -#ifdef CONFIG_REGMAP
141 +#if IS_REACHABLE(CONFIG_REGMAP)
142
143 enum regmap_endian {
144 /* Unspecified -> 0 -> Backwards compatible default */