diff options
-rw-r--r-- | drivers/base/regmap/regmap-debugfs.c | 20 | ||||
-rw-r--r-- | drivers/base/regmap/regmap-mmio.c | 24 | ||||
-rw-r--r-- | drivers/base/regmap/regmap.c | 2 | ||||
-rw-r--r-- | include/linux/regmap.h | 3 |
4 files changed, 47 insertions, 2 deletions
diff --git a/drivers/base/regmap/regmap-debugfs.c b/drivers/base/regmap/regmap-debugfs.c index f3266334063e..87b562e49a43 100644 --- a/drivers/base/regmap/regmap-debugfs.c +++ b/drivers/base/regmap/regmap-debugfs.c | |||
@@ -25,6 +25,7 @@ struct regmap_debugfs_node { | |||
25 | struct list_head link; | 25 | struct list_head link; |
26 | }; | 26 | }; |
27 | 27 | ||
28 | static unsigned int dummy_index; | ||
28 | static struct dentry *regmap_debugfs_root; | 29 | static struct dentry *regmap_debugfs_root; |
29 | static LIST_HEAD(regmap_debugfs_early_list); | 30 | static LIST_HEAD(regmap_debugfs_early_list); |
30 | static DEFINE_MUTEX(regmap_debugfs_early_lock); | 31 | static DEFINE_MUTEX(regmap_debugfs_early_lock); |
@@ -40,6 +41,7 @@ static ssize_t regmap_name_read_file(struct file *file, | |||
40 | loff_t *ppos) | 41 | loff_t *ppos) |
41 | { | 42 | { |
42 | struct regmap *map = file->private_data; | 43 | struct regmap *map = file->private_data; |
44 | const char *name = "nodev"; | ||
43 | int ret; | 45 | int ret; |
44 | char *buf; | 46 | char *buf; |
45 | 47 | ||
@@ -47,7 +49,10 @@ static ssize_t regmap_name_read_file(struct file *file, | |||
47 | if (!buf) | 49 | if (!buf) |
48 | return -ENOMEM; | 50 | return -ENOMEM; |
49 | 51 | ||
50 | ret = snprintf(buf, PAGE_SIZE, "%s\n", map->dev->driver->name); | 52 | if (map->dev && map->dev->driver) |
53 | name = map->dev->driver->name; | ||
54 | |||
55 | ret = snprintf(buf, PAGE_SIZE, "%s\n", name); | ||
51 | if (ret < 0) { | 56 | if (ret < 0) { |
52 | kfree(buf); | 57 | kfree(buf); |
53 | return ret; | 58 | return ret; |
@@ -569,9 +574,20 @@ void regmap_debugfs_init(struct regmap *map, const char *name) | |||
569 | name = devname; | 574 | name = devname; |
570 | } | 575 | } |
571 | 576 | ||
577 | if (!strcmp(name, "dummy")) { | ||
578 | map->debugfs_name = kasprintf(GFP_KERNEL, "dummy%d", | ||
579 | dummy_index); | ||
580 | name = map->debugfs_name; | ||
581 | dummy_index++; | ||
582 | } | ||
583 | |||
572 | map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); | 584 | map->debugfs = debugfs_create_dir(name, regmap_debugfs_root); |
573 | if (!map->debugfs) { | 585 | if (!map->debugfs) { |
574 | dev_warn(map->dev, "Failed to create debugfs directory\n"); | 586 | dev_warn(map->dev, |
587 | "Failed to create %s debugfs directory\n", name); | ||
588 | |||
589 | kfree(map->debugfs_name); | ||
590 | map->debugfs_name = NULL; | ||
575 | return; | 591 | return; |
576 | } | 592 | } |
577 | 593 | ||
diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 5189fd6182f6..5cadfd3394d8 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c | |||
@@ -28,6 +28,8 @@ | |||
28 | struct regmap_mmio_context { | 28 | struct regmap_mmio_context { |
29 | void __iomem *regs; | 29 | void __iomem *regs; |
30 | unsigned val_bytes; | 30 | unsigned val_bytes; |
31 | |||
32 | bool attached_clk; | ||
31 | struct clk *clk; | 33 | struct clk *clk; |
32 | 34 | ||
33 | void (*reg_write)(struct regmap_mmio_context *ctx, | 35 | void (*reg_write)(struct regmap_mmio_context *ctx, |
@@ -363,4 +365,26 @@ struct regmap *__devm_regmap_init_mmio_clk(struct device *dev, | |||
363 | } | 365 | } |
364 | EXPORT_SYMBOL_GPL(__devm_regmap_init_mmio_clk); | 366 | EXPORT_SYMBOL_GPL(__devm_regmap_init_mmio_clk); |
365 | 367 | ||
368 | int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk) | ||
369 | { | ||
370 | struct regmap_mmio_context *ctx = map->bus_context; | ||
371 | |||
372 | ctx->clk = clk; | ||
373 | ctx->attached_clk = true; | ||
374 | |||
375 | return clk_prepare(ctx->clk); | ||
376 | } | ||
377 | EXPORT_SYMBOL_GPL(regmap_mmio_attach_clk); | ||
378 | |||
379 | void regmap_mmio_detach_clk(struct regmap *map) | ||
380 | { | ||
381 | struct regmap_mmio_context *ctx = map->bus_context; | ||
382 | |||
383 | clk_unprepare(ctx->clk); | ||
384 | |||
385 | ctx->attached_clk = false; | ||
386 | ctx->clk = NULL; | ||
387 | } | ||
388 | EXPORT_SYMBOL_GPL(regmap_mmio_detach_clk); | ||
389 | |||
366 | MODULE_LICENSE("GPL v2"); | 390 | MODULE_LICENSE("GPL v2"); |
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 9d042ee8707d..3bc84885eb91 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
@@ -1116,6 +1116,8 @@ skip_format_initialization: | |||
1116 | ret = regmap_attach_dev(dev, map, config); | 1116 | ret = regmap_attach_dev(dev, map, config); |
1117 | if (ret != 0) | 1117 | if (ret != 0) |
1118 | goto err_regcache; | 1118 | goto err_regcache; |
1119 | } else { | ||
1120 | regmap_debugfs_init(map, config->name); | ||
1119 | } | 1121 | } |
1120 | 1122 | ||
1121 | return map; | 1123 | return map; |
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 6a3aeba40e9e..5f7ad0552c03 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
@@ -21,6 +21,7 @@ | |||
21 | #include <linux/lockdep.h> | 21 | #include <linux/lockdep.h> |
22 | 22 | ||
23 | struct module; | 23 | struct module; |
24 | struct clk; | ||
24 | struct device; | 25 | struct device; |
25 | struct i2c_client; | 26 | struct i2c_client; |
26 | struct irq_domain; | 27 | struct irq_domain; |
@@ -905,6 +906,8 @@ bool regmap_ac97_default_volatile(struct device *dev, unsigned int reg); | |||
905 | __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ | 906 | __regmap_lockdep_wrapper(__devm_regmap_init_sdw, #config, \ |
906 | sdw, config) | 907 | sdw, config) |
907 | 908 | ||
909 | int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk); | ||
910 | void regmap_mmio_detach_clk(struct regmap *map); | ||
908 | void regmap_exit(struct regmap *map); | 911 | void regmap_exit(struct regmap *map); |
909 | int regmap_reinit_cache(struct regmap *map, | 912 | int regmap_reinit_cache(struct regmap *map, |
910 | const struct regmap_config *config); | 913 | const struct regmap_config *config); |