Commit 9cde5fcd435fd929db7b0b486efb435cdb1ddca4

Authored by Mark Brown
1 parent 028a01e601

regmap: Add stub regmap calls as a build crutch for infrastructure users

Make life easier for subsystems which build infrastructure on top of the
regmap API by providing stub definitions for most of the API so that users
can at least build even if the regmap API is not enabled without having to
add ifdefs if they don't want to.

These stubs are not expected to be useful and should never actually get
called, they just exist so that we can link so there are WARN_ONCE()s in
the stubs.

Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>

Showing 1 changed file with 106 additions and 0 deletions Side-by-side Diff

include/linux/regmap.h
... ... @@ -16,6 +16,8 @@
16 16 #include <linux/device.h>
17 17 #include <linux/list.h>
18 18  
  19 +#ifdef CONFIG_REGMAP
  20 +
19 21 struct module;
20 22 struct i2c_client;
21 23 struct spi_device;
... ... @@ -198,6 +200,110 @@
198 200 struct regmap_irq_chip_data **data);
199 201 void regmap_del_irq_chip(int irq, struct regmap_irq_chip_data *data);
200 202 int regmap_irq_chip_get_base(struct regmap_irq_chip_data *data);
  203 +
  204 +#else
  205 +
  206 +/*
  207 + * These stubs should only ever be called by generic code which has
  208 + * regmap based facilities, if they ever get called at runtime
  209 + * something is going wrong and something probably needs to select
  210 + * REGMAP.
  211 + */
  212 +
  213 +static inline int regmap_write(struct regmap *map, unsigned int reg,
  214 + unsigned int val)
  215 +{
  216 + WARN_ONCE(1, "regmap API is disabled");
  217 + return -EINVAL;
  218 +}
  219 +
  220 +static inline int regmap_raw_write(struct regmap *map, unsigned int reg,
  221 + const void *val, size_t val_len)
  222 +{
  223 + WARN_ONCE(1, "regmap API is disabled");
  224 + return -EINVAL;
  225 +}
  226 +
  227 +static inline int regmap_bulk_write(struct regmap *map, unsigned int reg,
  228 + const void *val, size_t val_count)
  229 +{
  230 + WARN_ONCE(1, "regmap API is disabled");
  231 + return -EINVAL;
  232 +}
  233 +
  234 +static inline int regmap_read(struct regmap *map, unsigned int reg,
  235 + unsigned int *val)
  236 +{
  237 + WARN_ONCE(1, "regmap API is disabled");
  238 + return -EINVAL;
  239 +}
  240 +
  241 +static inline int regmap_raw_read(struct regmap *map, unsigned int reg,
  242 + void *val, size_t val_len)
  243 +{
  244 + WARN_ONCE(1, "regmap API is disabled");
  245 + return -EINVAL;
  246 +}
  247 +
  248 +static inline int regmap_bulk_read(struct regmap *map, unsigned int reg,
  249 + void *val, size_t val_count)
  250 +{
  251 + WARN_ONCE(1, "regmap API is disabled");
  252 + return -EINVAL;
  253 +}
  254 +
  255 +static inline int regmap_update_bits(struct regmap *map, unsigned int reg,
  256 + unsigned int mask, unsigned int val)
  257 +{
  258 + WARN_ONCE(1, "regmap API is disabled");
  259 + return -EINVAL;
  260 +}
  261 +
  262 +static inline int regmap_update_bits_check(struct regmap *map,
  263 + unsigned int reg,
  264 + unsigned int mask, unsigned int val,
  265 + bool *change)
  266 +{
  267 + WARN_ONCE(1, "regmap API is disabled");
  268 + return -EINVAL;
  269 +}
  270 +
  271 +static inline int regmap_get_val_bytes(struct regmap *map)
  272 +{
  273 + WARN_ONCE(1, "regmap API is disabled");
  274 + return -EINVAL;
  275 +}
  276 +
  277 +static inline int regcache_sync(struct regmap *map)
  278 +{
  279 + WARN_ONCE(1, "regmap API is disabled");
  280 + return -EINVAL;
  281 +}
  282 +
  283 +static inline void regcache_cache_only(struct regmap *map, bool enable)
  284 +{
  285 + WARN_ONCE(1, "regmap API is disabled");
  286 +}
  287 +
  288 +static inline void regcache_cache_bypass(struct regmap *map, bool enable)
  289 +{
  290 + WARN_ONCE(1, "regmap API is disabled");
  291 +}
  292 +
  293 +static inline void regcache_mark_dirty(struct regmap *map)
  294 +{
  295 + WARN_ONCE(1, "regmap API is disabled");
  296 +}
  297 +
  298 +static inline int regmap_register_patch(struct regmap *map,
  299 + const struct reg_default *regs,
  300 + int num_regs)
  301 +{
  302 + WARN_ONCE(1, "regmap API is disabled");
  303 + return -EINVAL;
  304 +}
  305 +
  306 +#endif
201 307  
202 308 #endif