summaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/regmap-i2c.c
diff options
context:
space:
mode:
authorMark Brown <broonie@opensource.wolfsonmicro.com>2012-01-30 20:56:52 +0100
committerMark Brown <broonie@opensource.wolfsonmicro.com>2012-01-30 22:06:43 +0100
commitc0eb46766d395da8d62148bda2e59bad5e6ee2f2 (patch)
tree9b808ba04041f4f10d08b384b4ad8c608a86df4c /drivers/base/regmap/regmap-i2c.c
parentMerge branches 'sched-urgent-for-linus', 'perf-urgent-for-linus' and 'x86-urg... (diff)
downloadlinux-c0eb46766d395da8d62148bda2e59bad5e6ee2f2.tar.xz
linux-c0eb46766d395da8d62148bda2e59bad5e6ee2f2.zip
regmap: Implement managed regmap_init()
Save error handling and unwinding code in drivers by providing managed versions of the regmap init functions, simplifying usage. Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/base/regmap/regmap-i2c.c')
-rw-r--r--drivers/base/regmap/regmap-i2c.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/base/regmap/regmap-i2c.c b/drivers/base/regmap/regmap-i2c.c
index 38621ec87c05..9a3a8c564389 100644
--- a/drivers/base/regmap/regmap-i2c.c
+++ b/drivers/base/regmap/regmap-i2c.c
@@ -111,4 +111,21 @@ struct regmap *regmap_init_i2c(struct i2c_client *i2c,
}
EXPORT_SYMBOL_GPL(regmap_init_i2c);
+/**
+ * devm_regmap_init_i2c(): Initialise managed register map
+ *
+ * @i2c: Device that will be interacted with
+ * @config: Configuration for register map
+ *
+ * The return value will be an ERR_PTR() on error or a valid pointer
+ * to a struct regmap. The regmap will be automatically freed by the
+ * device management code.
+ */
+struct regmap *devm_regmap_init_i2c(struct i2c_client *i2c,
+ const struct regmap_config *config)
+{
+ return devm_regmap_init(&i2c->dev, &regmap_i2c, config);
+}
+EXPORT_SYMBOL_GPL(devm_regmap_init_i2c);
+
MODULE_LICENSE("GPL");