aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base/regmap/regmap.c
diff options
context:
space:
mode:
authorMichal Simek <michal.simek@xilinx.com>2014-02-10 10:22:33 -0500
committerMark Brown <broonie@linaro.org>2014-02-15 20:53:02 -0500
commit6cfec04bcc05a829179c02584bb55f28fee03795 (patch)
tree717d7055a8c0b445856ddfc56b3d6230f4a590d9 /drivers/base/regmap/regmap.c
parent38dbfb59d1175ef458d006556061adeaa8751b72 (diff)
regmap: Separate regmap dev initialization
Create special function regmap_attach_dev which can be called separately out of regmap_init. Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Mark Brown <broonie@linaro.org>
Diffstat (limited to 'drivers/base/regmap/regmap.c')
-rw-r--r--drivers/base/regmap/regmap.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c
index 6a19515f8a45..43065ceff90f 100644
--- a/drivers/base/regmap/regmap.c
+++ b/drivers/base/regmap/regmap.c
@@ -380,6 +380,28 @@ static void regmap_range_exit(struct regmap *map)
380 kfree(map->selector_work_buf); 380 kfree(map->selector_work_buf);
381} 381}
382 382
383int regmap_attach_dev(struct device *dev, struct regmap *map,
384 const struct regmap_config *config)
385{
386 struct regmap **m;
387
388 map->dev = dev;
389
390 regmap_debugfs_init(map, config->name);
391
392 /* Add a devres resource for dev_get_regmap() */
393 m = devres_alloc(dev_get_regmap_release, sizeof(*m), GFP_KERNEL);
394 if (!m) {
395 regmap_debugfs_exit(map);
396 return -ENOMEM;
397 }
398 *m = map;
399 devres_add(dev, m);
400
401 return 0;
402}
403EXPORT_SYMBOL_GPL(regmap_attach_dev);
404
383/** 405/**
384 * regmap_init(): Initialise register map 406 * regmap_init(): Initialise register map
385 * 407 *
@@ -397,7 +419,7 @@ struct regmap *regmap_init(struct device *dev,
397 void *bus_context, 419 void *bus_context,
398 const struct regmap_config *config) 420 const struct regmap_config *config)
399{ 421{
400 struct regmap *map, **m; 422 struct regmap *map;
401 int ret = -EINVAL; 423 int ret = -EINVAL;
402 enum regmap_endian reg_endian, val_endian; 424 enum regmap_endian reg_endian, val_endian;
403 int i, j; 425 int i, j;
@@ -734,25 +756,18 @@ skip_format_initialization:
734 } 756 }
735 } 757 }
736 758
737 regmap_debugfs_init(map, config->name);
738
739 ret = regcache_init(map, config); 759 ret = regcache_init(map, config);
740 if (ret != 0) 760 if (ret != 0)
741 goto err_range; 761 goto err_range;
742 762
743 /* Add a devres resource for dev_get_regmap() */ 763 if (dev)
744 m = devres_alloc(dev_get_regmap_release, sizeof(*m), GFP_KERNEL); 764 ret = regmap_attach_dev(dev, map, config);
745 if (!m) { 765 if (ret != 0)
746 ret = -ENOMEM; 766 goto err_regcache;
747 goto err_debugfs;
748 }
749 *m = map;
750 devres_add(dev, m);
751 767
752 return map; 768 return map;
753 769
754err_debugfs: 770err_regcache:
755 regmap_debugfs_exit(map);
756 regcache_exit(map); 771 regcache_exit(map);
757err_range: 772err_range:
758 regmap_range_exit(map); 773 regmap_range_exit(map);