335ec4afc581c62779cbf86306fcb0e668833988
[librecmc/librecmc.git] / target / linux / generic / hack-4.19 / 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,9 +4,8 @@
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)
22         select IRQ_DOMAIN if REGMAP_IRQ
23 -       bool
24 +       tristate
25  
26  config REGCACHE_COMPRESSED
27         select LZO_COMPRESS
28 @@ -18,6 +17,7 @@ config REGMAP_AC97
29  
30  config REGMAP_I2C
31         tristate
32 +       select REGMAP
33         depends on I2C
34  
35  config REGMAP_SLIMBUS
36 @@ -26,20 +26,26 @@ config REGMAP_SLIMBUS
37  
38  config REGMAP_SPI
39         tristate
40 +       select REGMAP
41 +       depends on SPI_MASTER
42         depends on SPI
43  
44  config REGMAP_SPMI
45 +       select REGMAP
46         tristate
47         depends on SPMI
48  
49  config REGMAP_W1
50 +       select REGMAP
51         tristate
52         depends on W1
53  
54  config REGMAP_MMIO
55         tristate
56 +       select REGMAP
57  
58  config REGMAP_IRQ
59 +       select REGMAP
60         bool
61  
62  config REGMAP_SOUNDWIRE
63 --- a/drivers/base/regmap/Makefile
64 +++ b/drivers/base/regmap/Makefile
65 @@ -2,10 +2,14 @@
66  # For include/trace/define_trace.h to include trace.h
67  CFLAGS_regmap.o := -I$(src)
68  
69 -obj-$(CONFIG_REGMAP) += regmap.o regcache.o
70 -obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o
71 -obj-$(CONFIG_REGCACHE_COMPRESSED) += regcache-lzo.o
72 -obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
73 +regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-flat.o
74 +ifdef CONFIG_DEBUG_FS
75 +regmap-core-objs += regmap-debugfs.o
76 +endif
77 +ifdef CONFIG_REGCACHE_COMPRESSED
78 +regmap-core-objs += regcache-lzo.o
79 +endif
80 +obj-$(CONFIG_REGMAP) += regmap-core.o
81  obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o
82  obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
83  obj-$(CONFIG_REGMAP_SLIMBUS) += regmap-slimbus.o
84 --- a/drivers/base/regmap/regmap.c
85 +++ b/drivers/base/regmap/regmap.c
86 @@ -13,6 +13,7 @@
87  #include <linux/device.h>
88  #include <linux/slab.h>
89  #include <linux/export.h>
90 +#include <linux/module.h>
91  #include <linux/mutex.h>
92  #include <linux/err.h>
93  #include <linux/of.h>
94 @@ -3037,3 +3038,5 @@ static int __init regmap_initcall(void)
95         return 0;
96  }
97  postcore_initcall(regmap_initcall);
98 +
99 +MODULE_LICENSE("GPL");
100 --- a/include/linux/regmap.h
101 +++ b/include/linux/regmap.h
102 @@ -187,7 +187,7 @@ struct reg_sequence {
103         pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
104  })
105  
106 -#ifdef CONFIG_REGMAP
107 +#if IS_REACHABLE(CONFIG_REGMAP)
108  
109  enum regmap_endian {
110         /* Unspecified -> 0 -> Backwards compatible default */