Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Only OF_* functions should be in fdt_openfirm.c, ...



details:   https://anonhg.NetBSD.org/src/rev/732806d06ac5
branches:  trunk
changeset: 342319:732806d06ac5
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Wed Dec 16 12:17:45 2015 +0000

description:
Only OF_* functions should be in fdt_openfirm.c, move the rest to fdt_subr.c.

diffstat:

 sys/dev/fdt/fdt_gpio.c      |   6 +--
 sys/dev/fdt/fdt_i2c.c       |   6 +--
 sys/dev/fdt/fdt_intr.c      |  10 ++---
 sys/dev/fdt/fdt_openfirm.c  |  81 ++++++++++++--------------------------------
 sys/dev/fdt/fdt_openfirm.h  |  37 --------------------
 sys/dev/fdt/fdt_regulator.c |   6 +--
 sys/dev/fdt/fdt_subr.c      |  54 ++++++++++++++++++++++++++---
 sys/dev/fdt/fdtvar.h        |  49 +++++++++++++++------------
 8 files changed, 107 insertions(+), 142 deletions(-)

diffs (truncated from 537 to 300 lines):

diff -r ef192f93871c -r 732806d06ac5 sys/dev/fdt/fdt_gpio.c
--- a/sys/dev/fdt/fdt_gpio.c    Wed Dec 16 12:03:44 2015 +0000
+++ b/sys/dev/fdt/fdt_gpio.c    Wed Dec 16 12:17:45 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_gpio.c,v 1.1 2015/12/16 12:03:44 jmcneill Exp $ */
+/* $NetBSD: fdt_gpio.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,15 +27,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_gpio.c,v 1.1 2015/12/16 12:03:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_gpio.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
 
 #include <libfdt.h>
-#include <dev/ofw/openfirm.h>
-#include <dev/fdt/fdt_openfirm.h>
 #include <dev/fdt/fdtvar.h>
 
 struct fdtbus_gpio_controller {
diff -r ef192f93871c -r 732806d06ac5 sys/dev/fdt/fdt_i2c.c
--- a/sys/dev/fdt/fdt_i2c.c     Wed Dec 16 12:03:44 2015 +0000
+++ b/sys/dev/fdt/fdt_i2c.c     Wed Dec 16 12:17:45 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_i2c.c,v 1.1 2015/12/16 12:03:44 jmcneill Exp $ */
+/* $NetBSD: fdt_i2c.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,15 +27,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.1 2015/12/16 12:03:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
 
 #include <libfdt.h>
-#include <dev/ofw/openfirm.h>
-#include <dev/fdt/fdt_openfirm.h>
 #include <dev/fdt/fdtvar.h>
 
 struct fdtbus_i2c_controller {
diff -r ef192f93871c -r 732806d06ac5 sys/dev/fdt/fdt_intr.c
--- a/sys/dev/fdt/fdt_intr.c    Wed Dec 16 12:03:44 2015 +0000
+++ b/sys/dev/fdt/fdt_intr.c    Wed Dec 16 12:17:45 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.1 2015/12/16 12:03:44 jmcneill Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,15 +27,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.1 2015/12/16 12:03:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
 
 #include <libfdt.h>
-#include <dev/ofw/openfirm.h>
-#include <dev/fdt/fdt_openfirm.h>
 #include <dev/fdt/fdtvar.h>
 
 struct fdtbus_interrupt_controller {
@@ -71,13 +69,13 @@
 
        interrupt_parent = fdt32_to_cpu(interrupt_parent);
 
-       const void *data = fdt_openfirm_get_data();
+       const void *data = fdtbus_get_data();
        const int off = fdt_node_offset_by_phandle(data, interrupt_parent);
        if (off < 0) {
                return -1;
        }
 
-       return fdt_openfirm_get_phandle(off);
+       return fdtbus_offset2phandle(off);
 }
 
 static struct fdtbus_interrupt_controller *
diff -r ef192f93871c -r 732806d06ac5 sys/dev/fdt/fdt_openfirm.c
--- a/sys/dev/fdt/fdt_openfirm.c        Wed Dec 16 12:03:44 2015 +0000
+++ b/sys/dev/fdt/fdt_openfirm.c        Wed Dec 16 12:17:45 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_openfirm.c,v 1.1 2015/12/13 17:30:40 jmcneill Exp $ */
+/* $NetBSD: fdt_openfirm.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,59 +27,17 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_openfirm.c,v 1.1 2015/12/13 17:30:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_openfirm.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $");
 
 #include <sys/param.h>
 
 #include <libfdt.h>
-#include <dev/ofw/openfirm.h>
-#include <dev/fdt/fdt_openfirm.h>
-
-static const void *fdt_data;
-
-bool
-fdt_openfirm_set_data(const void *data)
-{
-       KASSERT(fdt_data == NULL);
-       if (fdt_check_header(data) != 0) {
-               return false;
-       }
-       fdt_data = data;
-       return true;
-}
-
-const void *
-fdt_openfirm_get_data(void)
-{
-       return fdt_data;
-}
-
-int
-fdt_openfirm_get_phandle(int offset)
-{
-       if (offset < 0)
-               return 0;
-
-       return offset + fdt_off_dt_struct(fdt_data);
-}
-
-int
-fdt_openfirm_get_offset(int phandle)
-{
-       const int dtoff = fdt_off_dt_struct(fdt_data);
-
-       if (phandle == -1)
-               phandle = dtoff;
-
-       if (phandle < dtoff)
-               return -1;
-
-       return phandle - dtoff;
-}
+#include <dev/fdt/fdtvar.h>
 
 int
 OF_peer(int phandle)
 {
+       const void *fdt_data = fdtbus_get_data();
        int off, depth;
 
        if (fdt_data == NULL) {
@@ -87,10 +45,10 @@
        }
 
        if (phandle == 0) {
-               return fdt_openfirm_get_phandle(0);
+               return fdtbus_offset2phandle(0);
        }
 
-       off = fdt_openfirm_get_offset(phandle);
+       off = fdtbus_phandle2offset(phandle);
        if (off < 0) {
                return 0;
        }
@@ -100,7 +58,7 @@
             off >= 0 && depth >= 0;
             off = fdt_next_node(fdt_data, off, &depth)) {
                if (depth == 1) {
-                       return fdt_openfirm_get_phandle(off);
+                       return fdtbus_offset2phandle(off);
                }
        }
 
@@ -110,13 +68,14 @@
 int
 OF_child(int phandle)
 {
+       const void *fdt_data = fdtbus_get_data();
        int off, depth;
 
        if (fdt_data == NULL) {
                return -1;
        }
 
-       off = fdt_openfirm_get_offset(phandle);
+       off = fdtbus_phandle2offset(phandle);
        if (off < 0) {
                return 0;
        }
@@ -126,7 +85,7 @@
             off >= 0 && depth > 0;
             off = fdt_next_node(fdt_data, off, &depth)) {
                if (depth == 1) {
-                       return fdt_openfirm_get_phandle(off);
+                       return fdtbus_offset2phandle(off);
                }
        }
 
@@ -136,13 +95,14 @@
 int
 OF_parent(int phandle)
 {
+       const void *fdt_data = fdtbus_get_data();
        int off;
 
        if (fdt_data == NULL) {
                return -1;
        }
 
-       off = fdt_openfirm_get_offset(phandle);
+       off = fdtbus_phandle2offset(phandle);
        if (off < 0) {
                return -1;
        }
@@ -152,12 +112,13 @@
                return -1;
        }
 
-       return fdt_openfirm_get_phandle(off);
+       return fdtbus_offset2phandle(off);
 }
 
 int
 OF_nextprop(int phandle, const char *prop, void *nextprop)
 {
+       const void *fdt_data = fdtbus_get_data();
        const char *name;
        const void *val;
        int off, len;
@@ -166,7 +127,7 @@
                return -1;
        }
 
-       off = fdt_openfirm_get_offset(phandle);
+       off = fdtbus_phandle2offset(phandle);
        if (off < 0) {
                return -1;
        }
@@ -207,6 +168,7 @@
 int
 OF_getprop(int phandle, const char *prop, void *buf, int buflen)
 {
+       const void *fdt_data = fdtbus_get_data();
        const char *name;
        const void *val;
        int off, len;
@@ -215,7 +177,7 @@
                return -1;
        }
 
-       off = fdt_openfirm_get_offset(phandle);
+       off = fdtbus_phandle2offset(phandle);
        if (off < 0) {
                return -1;
        }
@@ -266,6 +228,7 @@
 int
 OF_getproplen(int phandle, const char *prop)
 {
+       const void *fdt_data = fdtbus_get_data();
        const char *name;
        const void *val;
        int off, len;
@@ -274,7 +237,7 @@
                return -1;
        }
 
-       off = fdt_openfirm_get_offset(phandle);
+       off = fdtbus_phandle2offset(phandle);
        if (off < 0) {
                return -1;
        }
@@ -324,6 +287,7 @@
 int
 OF_finddevice(const char *name)
 {
+       const void *fdt_data = fdtbus_get_data();
        int off;
 
        if (fdt_data == NULL) {
@@ -335,19 +299,20 @@
                return -1;
        }
 
-       return fdt_openfirm_get_phandle(off);



Home | Main Index | Thread Index | Old Index