summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorgber <gber@FreeBSD.org>2012-09-14 09:36:35 +0000
committergber <gber@FreeBSD.org>2012-09-14 09:36:35 +0000
commit5208b599ffd736e8a218cd75703389f729fa1da2 (patch)
tree63ba1f0f973296b9c2bec198c1b043a99592eb07 /sys/dev
parent5dd175c3fd9e3e14cbf3982b8553df7c3fbb18f3 (diff)
downloadFreeBSD-src-5208b599ffd736e8a218cd75703389f729fa1da2.zip
FreeBSD-src-5208b599ffd736e8a218cd75703389f729fa1da2.tar.gz
Add fdt_get_unit() function.
Obtained from: Semihalf
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/fdt/fdt_common.c11
-rw-r--r--sys/dev/fdt/fdt_common.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/sys/dev/fdt/fdt_common.c b/sys/dev/fdt/fdt_common.c
index cc55c65..706396b 100644
--- a/sys/dev/fdt/fdt_common.c
+++ b/sys/dev/fdt/fdt_common.c
@@ -697,3 +697,14 @@ fdt_get_mem_regions(struct mem_region *mr, int *mrcnt, uint32_t *memsize)
out:
return (rv);
}
+
+int
+fdt_get_unit(device_t dev)
+{
+ const char * name;
+
+ name = ofw_bus_get_name(dev);
+ name = strchr(name, '@') + 1;
+
+ return (strtol(name,NULL,0));
+}
diff --git a/sys/dev/fdt/fdt_common.h b/sys/dev/fdt/fdt_common.h
index 4dea494..4761cd7 100644
--- a/sys/dev/fdt/fdt_common.h
+++ b/sys/dev/fdt/fdt_common.h
@@ -110,5 +110,6 @@ int fdt_pci_route_intr(int, int, int, int, struct fdt_pci_intr *, int *);
int fdt_ranges_verify(pcell_t *, int, int, int, int);
int fdt_reg_to_rl(phandle_t, struct resource_list *);
int fdt_pm(phandle_t);
+int fdt_get_unit(device_t);
#endif /* _FDT_COMMON_H_ */
OpenPOWER on IntegriCloud