Skip to content

Commit

Permalink
Merge tag 'regmap-3.5' of git://git.kernel.org/pub/scm/linux/kernel/g…
Browse files Browse the repository at this point in the history
…it/broonie/regmap

Pull regmap fixes from Mark Brown:
 "Nothing too exciting - a cleanup for debugfs in error handling and a
  fix for the padding (which has only just acquired real use) and
  exporting a function that's supposed to be usable by drivers."

* tag 'regmap-3.5' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap:
  regmap: Export regmap_reinit_cache()
  regmap: Fix the size calculation for map->format.buf_size
  regmap: clean up debugfs if regmap_init fails
  • Loading branch information
Linus Torvalds committed Jun 11, 2012
2 parents 68d7d76 + 752a6a5 commit b0a4c6f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/base/regmap/regmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,11 @@ struct regmap *regmap_init(struct device *dev,
map->lock = regmap_lock_mutex;
map->unlock = regmap_unlock_mutex;
}
map->format.buf_size = (config->reg_bits + config->val_bits) / 8;
map->format.reg_bytes = DIV_ROUND_UP(config->reg_bits, 8);
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->format.buf_size = DIV_ROUND_UP(config->reg_bits +
config->val_bits + config->pad_bits, 8);
map->reg_shift = config->pad_bits % 8;
if (config->reg_stride)
map->reg_stride = config->reg_stride;
Expand Down Expand Up @@ -368,7 +368,7 @@ struct regmap *regmap_init(struct device *dev,

ret = regcache_init(map, config);
if (ret < 0)
goto err_free_workbuf;
goto err_debugfs;

/* Add a devres resource for dev_get_regmap() */
m = devres_alloc(dev_get_regmap_release, sizeof(*m), GFP_KERNEL);
Expand All @@ -383,7 +383,8 @@ struct regmap *regmap_init(struct device *dev,

err_cache:
regcache_exit(map);
err_free_workbuf:
err_debugfs:
regmap_debugfs_exit(map);
kfree(map->work_buf);
err_map:
kfree(map);
Expand Down Expand Up @@ -471,6 +472,7 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)

return ret;
}
EXPORT_SYMBOL_GPL(regmap_reinit_cache);

/**
* regmap_exit(): Free a previously allocated register map
Expand Down

0 comments on commit b0a4c6f

Please sign in to comment.