Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/fdt Assign device handles to devices that attach to ...



details:   https://anonhg.NetBSD.org/src/rev/6f4cf1459d24
branches:  trunk
changeset: 959230:6f4cf1459d24
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Feb 05 17:20:32 2021 +0000

description:
Assign device handles to devices that attach to the "fdt" interface attribute
in fdtbus_device_register().

diffstat:

 sys/dev/fdt/fdtbus.c |  19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diffs (39 lines):

diff -r 1861f156b92d -r 6f4cf1459d24 sys/dev/fdt/fdtbus.c
--- a/sys/dev/fdt/fdtbus.c      Fri Feb 05 17:17:59 2021 +0000
+++ b/sys/dev/fdt/fdtbus.c      Fri Feb 05 17:20:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdtbus.c,v 1.39 2021/02/04 22:14:08 thorpej Exp $ */
+/* $NetBSD: fdtbus.c,v 1.40 2021/02/05 17:20:32 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.39 2021/02/04 22:14:08 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdtbus.c,v 1.40 2021/02/05 17:20:32 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -552,7 +552,18 @@
 }
 
 void
-fdtbus_device_register(device_t dev __unused, void *aux __unused)
+fdtbus_device_register(device_t dev, void *aux)
 {
-       /* Placeholder. */
+       /* All we do here is set the devhandle in the device_t. */
+       int phandle = -1;
+
+       if (device_attached_to_iattr(dev, "fdt")) {
+               const struct fdt_attach_args *faa = aux;
+               phandle = faa->faa_phandle;
+       } else {
+               return;
+       }
+       KASSERT(phandle != -1);
+
+       of_device_register(dev, phandle);
 }



Home | Main Index | Thread Index | Old Index