aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSamuel Holland <samuel.holland@sifive.com>2024-11-11 14:02:52 -0800
committerAnup Patel <anup@brainfault.org>2024-11-28 17:45:29 +0530
commit1f8db2f18ffb4babb27c2070419b7100f998c7f4 (patch)
tree2b14189ecee17fb0214444f1b35a006426396a0f /lib
parent5fa510c5f69f42d3b700e86c0db9e5bcebd3921c (diff)
downloadopensbi-1f8db2f18ffb4babb27c2070419b7100f998c7f4.zip
opensbi-1f8db2f18ffb4babb27c2070419b7100f998c7f4.tar.gz
opensbi-1f8db2f18ffb4babb27c2070419b7100f998c7f4.tar.bz2
lib: utils/regmap: Use fdt_driver for initialization
The regmap driver subsystem does not need any extra data, so it can use `struct fdt_driver` directly. It always initializes the driver for a specific DT node. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/utils/regmap/fdt_regmap.c28
-rw-r--r--lib/utils/regmap/fdt_regmap_drivers.carray2
-rw-r--r--lib/utils/regmap/fdt_regmap_syscon.c2
3 files changed, 5 insertions, 27 deletions
diff --git a/lib/utils/regmap/fdt_regmap.c b/lib/utils/regmap/fdt_regmap.c
index ab991c4..2e8c214 100644
--- a/lib/utils/regmap/fdt_regmap.c
+++ b/lib/utils/regmap/fdt_regmap.c
@@ -13,30 +13,7 @@
#include <sbi_utils/regmap/fdt_regmap.h>
/* List of FDT regmap drivers generated at compile time */
-extern struct fdt_regmap *const fdt_regmap_drivers[];
-
-static int fdt_regmap_init(const void *fdt, int nodeoff)
-{
- int pos, rc;
- struct fdt_regmap *drv;
- const struct fdt_match *match;
-
- /* Try all I2C drivers one-by-one */
- for (pos = 0; fdt_regmap_drivers[pos]; pos++) {
- drv = fdt_regmap_drivers[pos];
- match = fdt_match_node(fdt, nodeoff, drv->match_table);
- if (match && drv->init) {
- rc = drv->init(fdt, nodeoff, match);
- if (rc == SBI_ENODEV)
- continue;
- if (rc)
- return rc;
- return 0;
- }
- }
-
- return SBI_ENOSYS;
-}
+extern const struct fdt_driver *const fdt_regmap_drivers[];
static int fdt_regmap_find(const void *fdt, int nodeoff,
struct regmap **out_rmap)
@@ -46,7 +23,8 @@ static int fdt_regmap_find(const void *fdt, int nodeoff,
if (!rmap) {
/* Regmap not found so initialize matching driver */
- rc = fdt_regmap_init(fdt, nodeoff);
+ rc = fdt_driver_init_by_offset(fdt, nodeoff,
+ fdt_regmap_drivers);
if (rc)
return rc;
diff --git a/lib/utils/regmap/fdt_regmap_drivers.carray b/lib/utils/regmap/fdt_regmap_drivers.carray
index c2f1c9d..d19a932 100644
--- a/lib/utils/regmap/fdt_regmap_drivers.carray
+++ b/lib/utils/regmap/fdt_regmap_drivers.carray
@@ -1,3 +1,3 @@
HEADER: sbi_utils/regmap/fdt_regmap.h
-TYPE: struct fdt_regmap
+TYPE: const struct fdt_driver
NAME: fdt_regmap_drivers
diff --git a/lib/utils/regmap/fdt_regmap_syscon.c b/lib/utils/regmap/fdt_regmap_syscon.c
index ba55908..1309a55 100644
--- a/lib/utils/regmap/fdt_regmap_syscon.c
+++ b/lib/utils/regmap/fdt_regmap_syscon.c
@@ -263,7 +263,7 @@ static const struct fdt_match regmap_syscon_match[] = {
{ },
};
-struct fdt_regmap fdt_regmap_syscon = {
+const struct fdt_driver fdt_regmap_syscon = {
.match_table = regmap_syscon_match,
.init = regmap_syscon_init,
};