Add luci mirror repository
[librecmc/librecmc.git] / target / linux / generic / hack-4.9 / 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 @@ -3,9 +3,8 @@
18  # subsystems should select the appropriate symbols.
19  
20  config REGMAP
21 -       default y if (REGMAP_I2C || REGMAP_SPI || REGMAP_SPMI || 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 @@ -17,18 +16,24 @@ config REGMAP_AC97
29  
30  config REGMAP_I2C
31         tristate
32 +       select REGMAP
33         depends on I2C
34  
35  config REGMAP_SPI
36         tristate
37 +       select REGMAP
38 +       depends on SPI_MASTER
39         depends on SPI
40  
41  config REGMAP_SPMI
42 +       select REGMAP
43         tristate
44         depends on SPMI
45  
46  config REGMAP_MMIO
47         tristate
48 +       select REGMAP
49  
50  config REGMAP_IRQ
51 +       select REGMAP
52         bool
53 --- a/drivers/base/regmap/Makefile
54 +++ b/drivers/base/regmap/Makefile
55 @@ -1,10 +1,14 @@
56  # For include/trace/define_trace.h to include trace.h
57  CFLAGS_regmap.o := -I$(src)
58  
59 -obj-$(CONFIG_REGMAP) += regmap.o regcache.o
60 -obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-flat.o
61 -obj-$(CONFIG_REGCACHE_COMPRESSED) += regcache-lzo.o
62 -obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o
63 +regmap-core-objs = regmap.o regcache.o regcache-rbtree.o regcache-flat.o
64 +ifdef CONFIG_DEBUG_FS
65 +regmap-core-objs += regmap-debugfs.o
66 +endif
67 +ifdef CONFIG_REGCACHE_COMPRESSED
68 +regmap-core-objs += regcache-lzo.o
69 +endif
70 +obj-$(CONFIG_REGMAP) += regmap-core.o
71  obj-$(CONFIG_REGMAP_AC97) += regmap-ac97.o
72  obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o
73  obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o
74 --- a/drivers/base/regmap/regmap.c
75 +++ b/drivers/base/regmap/regmap.c
76 @@ -13,6 +13,7 @@
77  #include <linux/device.h>
78  #include <linux/slab.h>
79  #include <linux/export.h>
80 +#include <linux/module.h>
81  #include <linux/mutex.h>
82  #include <linux/err.h>
83  #include <linux/of.h>
84 @@ -2913,3 +2914,5 @@ static int __init regmap_initcall(void)
85         return 0;
86  }
87  postcore_initcall(regmap_initcall);
88 +
89 +MODULE_LICENSE("GPL");
90 --- a/include/linux/regmap.h
91 +++ b/include/linux/regmap.h
92 @@ -135,7 +135,7 @@ struct reg_sequence {
93         pollret ?: ((cond) ? 0 : -ETIMEDOUT); \
94  })
95  
96 -#ifdef CONFIG_REGMAP
97 +#if IS_ENABLED(CONFIG_REGMAP)
98  
99  enum regmap_endian {
100         /* Unspecified -> 0 -> Backwards compatible default */