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