return b[0];
}
+ +static void regmap_lock_mutex(struct regmap *map)
+ +{
+ + mutex_lock(&map->mutex);
+ +}
+ +
+ +static void regmap_unlock_mutex(struct regmap *map)
+ +{
+ + mutex_unlock(&map->mutex);
+ +}
+ +
+ +static void regmap_lock_spinlock(struct regmap *map)
+ +{
+ + spin_lock(&map->spinlock);
+ +}
+ +
+ +static void regmap_unlock_spinlock(struct regmap *map)
+ +{
+ + spin_unlock(&map->spinlock);
+ +}
+ +
++ +static void dev_get_regmap_release(struct device *dev, void *res)
++ +{
++ + /*
++ + * We don't actually have anything to do here; the goal here
++ + * is not to manage the regmap but to provide a simple way to
++ + * get the regmap back given a struct device.
++ + */
++ +}
++ +
/**
* regmap_init(): Initialise register map
*
*/
struct regmap *regmap_init(struct device *dev,
const struct regmap_bus *bus,
+ + void *bus_context,
const struct regmap_config *config)
{
-- - struct regmap *map;
++ + struct regmap *map, **m;
int ret = -EINVAL;
if (!bus || !config)
map->format.pad_bytes = config->pad_bits / 8;
map->format.val_bytes = DIV_ROUND_UP(config->val_bits, 8);
map->format.buf_size += map->format.pad_bytes;
++ map->reg_shift = config->pad_bits % 8;
+ ++ if (config->reg_stride)
+ ++ map->reg_stride = config->reg_stride;
+ ++ else
+ ++ map->reg_stride = 1;
+ ++ map->use_single_rw = config->use_single_rw;
map->dev = dev;
map->bus = bus;
+ + map->bus_context = bus_context;
map->max_register = config->max_register;
map->writeable_reg = config->writeable_reg;
map->readable_reg = config->readable_reg;
{
int ret;
- - mutex_lock(&map->lock);
+ ++ if (reg % map->reg_stride)
+ ++ return -EINVAL;
+ ++
+ + map->lock(map);
ret = _regmap_write(map, reg, val);
{
int ret;
- - mutex_lock(&map->lock);
+ + if (val_len % map->format.val_bytes)
+ + return -EINVAL;
+ ++ if (reg % map->reg_stride)
+ ++ return -EINVAL;
+ +
+ + map->lock(map);
ret = _regmap_raw_write(map, reg, val, val_len);
if (!map->format.parse_val)
return -EINVAL;
+ ++ if (reg % map->reg_stride)
+ ++ return -EINVAL;
- - mutex_lock(&map->lock);
+ + map->lock(map);
/* No formatting is require if val_byte is 1 */
if (val_bytes == 1) {
{
int ret;
- - mutex_lock(&map->lock);
+ ++ if (reg % map->reg_stride)
+ ++ return -EINVAL;
+ ++
+ + map->lock(map);
ret = _regmap_read(map, reg, val);
unsigned int v;
int ret, i;
- - mutex_lock(&map->lock);
+ + if (val_len % map->format.val_bytes)
+ + return -EINVAL;
+ ++ if (reg % map->reg_stride)
+ ++ return -EINVAL;
+ +
+ + map->lock(map);
if (regmap_volatile_range(map, reg, val_count) || map->cache_bypass ||
map->cache_type == REGCACHE_NONE) {
u8 read_flag_mask;
u8 write_flag_mask;
+ ++
+ ++ bool use_single_rw;
};
- -typedef int (*regmap_hw_write)(struct device *dev, const void *data,
+ +typedef int (*regmap_hw_write)(void *context, const void *data,
size_t count);
- -typedef int (*regmap_hw_gather_write)(struct device *dev,
+ +typedef int (*regmap_hw_gather_write)(void *context,
const void *reg, size_t reg_len,
const void *val, size_t val_len);
- -typedef int (*regmap_hw_read)(struct device *dev,
+ +typedef int (*regmap_hw_read)(void *context,
const void *reg_buf, size_t reg_size,
void *val_buf, size_t val_size);
+ +typedef void (*regmap_hw_free_context)(void *context);
/**
* Description of a hardware bus for the register map infrastructure.