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