2 * Register cache access API - flat caching support
4 * Copyright 2012 Wolfson Microelectronics plc
6 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
13 #include <linux/slab.h>
14 #include <linux/device.h>
15 #include <linux/seq_file.h>
19 static int regcache_flat_init(struct regmap
*map
)
24 map
->cache
= kzalloc(sizeof(unsigned int) * (map
->max_register
+ 1),
31 for (i
= 0; i
< map
->num_reg_defaults
; i
++)
32 cache
[map
->reg_defaults
[i
].reg
] = map
->reg_defaults
[i
].def
;
37 static int regcache_flat_exit(struct regmap
*map
)
45 static int regcache_flat_read(struct regmap
*map
,
46 unsigned int reg
, unsigned int *value
)
48 unsigned int *cache
= map
->cache
;
55 static int regcache_flat_write(struct regmap
*map
, unsigned int reg
,
58 unsigned int *cache
= map
->cache
;
65 struct regcache_ops regcache_flat_ops
= {
66 .type
= REGCACHE_FLAT
,
68 .init
= regcache_flat_init
,
69 .exit
= regcache_flat_exit
,
70 .read
= regcache_flat_read
,
71 .write
= regcache_flat_write
,