Loading drivers/base/regmap/Kconfig +3 −0 Original line number Diff line number Diff line Loading @@ -14,5 +14,8 @@ config REGMAP_I2C config REGMAP_SPI tristate config REGMAP_MMIO tristate config REGMAP_IRQ bool drivers/base/regmap/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -3,4 +3,5 @@ obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o obj-$(CONFIG_REGMAP_MMIO) += regmap-mmio.o obj-$(CONFIG_REGMAP_IRQ) += regmap-irq.o drivers/base/regmap/internal.h +16 −5 Original line number Diff line number Diff line Loading @@ -26,21 +26,29 @@ struct regmap_format { size_t val_bytes; void (*format_write)(struct regmap *map, unsigned int reg, unsigned int val); void (*format_reg)(void *buf, unsigned int reg); void (*format_val)(void *buf, unsigned int val); void (*format_reg)(void *buf, unsigned int reg, unsigned int shift); void (*format_val)(void *buf, unsigned int val, unsigned int shift); unsigned int (*parse_val)(void *buf); }; typedef void (*regmap_lock)(struct regmap *map); typedef void (*regmap_unlock)(struct regmap *map); struct regmap { struct mutex lock; struct mutex mutex; spinlock_t spinlock; regmap_lock lock; regmap_unlock unlock; struct device *dev; /* Device we do I/O on */ void *work_buf; /* Scratch buffer used to format I/O */ struct regmap_format format; /* Buffer format */ const struct regmap_bus *bus; void *bus_context; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs; const char *debugfs_name; #endif unsigned int max_register; Loading @@ -52,6 +60,9 @@ struct regmap { u8 read_flag_mask; u8 write_flag_mask; /* number of bits to (left) shift the reg value when formatting*/ int reg_shift; /* regcache specific members */ const struct regcache_ops *cache_ops; enum regcache_type cache_type; Loading Loading @@ -101,11 +112,11 @@ int _regmap_write(struct regmap *map, unsigned int reg, #ifdef CONFIG_DEBUG_FS extern void regmap_debugfs_initcall(void); extern void regmap_debugfs_init(struct regmap *map); extern void regmap_debugfs_init(struct regmap *map, const char *name); extern void regmap_debugfs_exit(struct regmap *map); #else static inline void regmap_debugfs_initcall(void) { } static inline void regmap_debugfs_init(struct regmap *map) { } static inline void regmap_debugfs_init(struct regmap *map, const char *name) { } static inline void regmap_debugfs_exit(struct regmap *map) { } #endif Loading drivers/base/regmap/regcache-rbtree.c +2 −2 Original line number Diff line number Diff line Loading @@ -140,7 +140,7 @@ static int rbtree_show(struct seq_file *s, void *ignored) int registers = 0; int average; mutex_lock(&map->lock); map->lock(map); for (node = rb_first(&rbtree_ctx->root); node != NULL; node = rb_next(node)) { Loading @@ -161,7 +161,7 @@ static int rbtree_show(struct seq_file *s, void *ignored) seq_printf(s, "%d nodes, %d registers, average %d registers\n", nodes, registers, average); mutex_unlock(&map->lock); map->unlock(map); return 0; } Loading drivers/base/regmap/regcache.c +10 −10 Original line number Diff line number Diff line Loading @@ -264,7 +264,7 @@ int regcache_sync(struct regmap *map) BUG_ON(!map->cache_ops || !map->cache_ops->sync); mutex_lock(&map->lock); map->lock(map); /* Remember the initial bypass state */ bypass = map->cache_bypass; dev_dbg(map->dev, "Syncing %s cache\n", Loading Loading @@ -296,7 +296,7 @@ out: trace_regcache_sync(map->dev, name, "stop"); /* Restore the bypass state */ map->cache_bypass = bypass; mutex_unlock(&map->lock); map->unlock(map); return ret; } Loading @@ -323,7 +323,7 @@ int regcache_sync_region(struct regmap *map, unsigned int min, BUG_ON(!map->cache_ops || !map->cache_ops->sync); mutex_lock(&map->lock); map->lock(map); /* Remember the initial bypass state */ bypass = map->cache_bypass; Loading @@ -342,7 +342,7 @@ out: trace_regcache_sync(map->dev, name, "stop region"); /* Restore the bypass state */ map->cache_bypass = bypass; mutex_unlock(&map->lock); map->unlock(map); return ret; } Loading @@ -362,11 +362,11 @@ EXPORT_SYMBOL_GPL(regcache_sync_region); */ void regcache_cache_only(struct regmap *map, bool enable) { mutex_lock(&map->lock); map->lock(map); WARN_ON(map->cache_bypass && enable); map->cache_only = enable; trace_regmap_cache_only(map->dev, enable); mutex_unlock(&map->lock); map->unlock(map); } EXPORT_SYMBOL_GPL(regcache_cache_only); Loading @@ -381,9 +381,9 @@ EXPORT_SYMBOL_GPL(regcache_cache_only); */ void regcache_mark_dirty(struct regmap *map) { mutex_lock(&map->lock); map->lock(map); map->cache_dirty = true; mutex_unlock(&map->lock); map->unlock(map); } EXPORT_SYMBOL_GPL(regcache_mark_dirty); Loading @@ -400,11 +400,11 @@ EXPORT_SYMBOL_GPL(regcache_mark_dirty); */ void regcache_cache_bypass(struct regmap *map, bool enable) { mutex_lock(&map->lock); map->lock(map); WARN_ON(map->cache_only && enable); map->cache_bypass = enable; trace_regmap_cache_bypass(map->dev, enable); mutex_unlock(&map->lock); map->unlock(map); } EXPORT_SYMBOL_GPL(regcache_cache_bypass); Loading Loading
drivers/base/regmap/Kconfig +3 −0 Original line number Diff line number Diff line Loading @@ -14,5 +14,8 @@ config REGMAP_I2C config REGMAP_SPI tristate config REGMAP_MMIO tristate config REGMAP_IRQ bool
drivers/base/regmap/Makefile +1 −0 Original line number Diff line number Diff line Loading @@ -3,4 +3,5 @@ obj-$(CONFIG_REGMAP) += regcache-rbtree.o regcache-lzo.o obj-$(CONFIG_DEBUG_FS) += regmap-debugfs.o obj-$(CONFIG_REGMAP_I2C) += regmap-i2c.o obj-$(CONFIG_REGMAP_SPI) += regmap-spi.o obj-$(CONFIG_REGMAP_MMIO) += regmap-mmio.o obj-$(CONFIG_REGMAP_IRQ) += regmap-irq.o
drivers/base/regmap/internal.h +16 −5 Original line number Diff line number Diff line Loading @@ -26,21 +26,29 @@ struct regmap_format { size_t val_bytes; void (*format_write)(struct regmap *map, unsigned int reg, unsigned int val); void (*format_reg)(void *buf, unsigned int reg); void (*format_val)(void *buf, unsigned int val); void (*format_reg)(void *buf, unsigned int reg, unsigned int shift); void (*format_val)(void *buf, unsigned int val, unsigned int shift); unsigned int (*parse_val)(void *buf); }; typedef void (*regmap_lock)(struct regmap *map); typedef void (*regmap_unlock)(struct regmap *map); struct regmap { struct mutex lock; struct mutex mutex; spinlock_t spinlock; regmap_lock lock; regmap_unlock unlock; struct device *dev; /* Device we do I/O on */ void *work_buf; /* Scratch buffer used to format I/O */ struct regmap_format format; /* Buffer format */ const struct regmap_bus *bus; void *bus_context; #ifdef CONFIG_DEBUG_FS struct dentry *debugfs; const char *debugfs_name; #endif unsigned int max_register; Loading @@ -52,6 +60,9 @@ struct regmap { u8 read_flag_mask; u8 write_flag_mask; /* number of bits to (left) shift the reg value when formatting*/ int reg_shift; /* regcache specific members */ const struct regcache_ops *cache_ops; enum regcache_type cache_type; Loading Loading @@ -101,11 +112,11 @@ int _regmap_write(struct regmap *map, unsigned int reg, #ifdef CONFIG_DEBUG_FS extern void regmap_debugfs_initcall(void); extern void regmap_debugfs_init(struct regmap *map); extern void regmap_debugfs_init(struct regmap *map, const char *name); extern void regmap_debugfs_exit(struct regmap *map); #else static inline void regmap_debugfs_initcall(void) { } static inline void regmap_debugfs_init(struct regmap *map) { } static inline void regmap_debugfs_init(struct regmap *map, const char *name) { } static inline void regmap_debugfs_exit(struct regmap *map) { } #endif Loading
drivers/base/regmap/regcache-rbtree.c +2 −2 Original line number Diff line number Diff line Loading @@ -140,7 +140,7 @@ static int rbtree_show(struct seq_file *s, void *ignored) int registers = 0; int average; mutex_lock(&map->lock); map->lock(map); for (node = rb_first(&rbtree_ctx->root); node != NULL; node = rb_next(node)) { Loading @@ -161,7 +161,7 @@ static int rbtree_show(struct seq_file *s, void *ignored) seq_printf(s, "%d nodes, %d registers, average %d registers\n", nodes, registers, average); mutex_unlock(&map->lock); map->unlock(map); return 0; } Loading
drivers/base/regmap/regcache.c +10 −10 Original line number Diff line number Diff line Loading @@ -264,7 +264,7 @@ int regcache_sync(struct regmap *map) BUG_ON(!map->cache_ops || !map->cache_ops->sync); mutex_lock(&map->lock); map->lock(map); /* Remember the initial bypass state */ bypass = map->cache_bypass; dev_dbg(map->dev, "Syncing %s cache\n", Loading Loading @@ -296,7 +296,7 @@ out: trace_regcache_sync(map->dev, name, "stop"); /* Restore the bypass state */ map->cache_bypass = bypass; mutex_unlock(&map->lock); map->unlock(map); return ret; } Loading @@ -323,7 +323,7 @@ int regcache_sync_region(struct regmap *map, unsigned int min, BUG_ON(!map->cache_ops || !map->cache_ops->sync); mutex_lock(&map->lock); map->lock(map); /* Remember the initial bypass state */ bypass = map->cache_bypass; Loading @@ -342,7 +342,7 @@ out: trace_regcache_sync(map->dev, name, "stop region"); /* Restore the bypass state */ map->cache_bypass = bypass; mutex_unlock(&map->lock); map->unlock(map); return ret; } Loading @@ -362,11 +362,11 @@ EXPORT_SYMBOL_GPL(regcache_sync_region); */ void regcache_cache_only(struct regmap *map, bool enable) { mutex_lock(&map->lock); map->lock(map); WARN_ON(map->cache_bypass && enable); map->cache_only = enable; trace_regmap_cache_only(map->dev, enable); mutex_unlock(&map->lock); map->unlock(map); } EXPORT_SYMBOL_GPL(regcache_cache_only); Loading @@ -381,9 +381,9 @@ EXPORT_SYMBOL_GPL(regcache_cache_only); */ void regcache_mark_dirty(struct regmap *map) { mutex_lock(&map->lock); map->lock(map); map->cache_dirty = true; mutex_unlock(&map->lock); map->unlock(map); } EXPORT_SYMBOL_GPL(regcache_mark_dirty); Loading @@ -400,11 +400,11 @@ EXPORT_SYMBOL_GPL(regcache_mark_dirty); */ void regcache_cache_bypass(struct regmap *map, bool enable) { mutex_lock(&map->lock); map->lock(map); WARN_ON(map->cache_only && enable); map->cache_bypass = enable; trace_regmap_cache_bypass(map->dev, enable); mutex_unlock(&map->lock); map->unlock(map); } EXPORT_SYMBOL_GPL(regcache_cache_bypass); Loading