Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/fdt Use queue(3) API to manage lists. NFCI.



details:   https://anonhg.NetBSD.org/src/rev/c292eefb0ec0
branches:  trunk
changeset: 320308:c292eefb0ec0
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat Jun 30 20:34:43 2018 +0000

description:
Use queue(3) API to manage lists. NFCI.

diffstat:

 sys/dev/fdt/fdt_clock.c      |  20 ++++++++++----------
 sys/dev/fdt/fdt_dai.c        |  18 +++++++++---------
 sys/dev/fdt/fdt_dma.c        |  18 +++++++++---------
 sys/dev/fdt/fdt_gpio.c       |  18 +++++++++---------
 sys/dev/fdt/fdt_i2c.c        |  18 +++++++++---------
 sys/dev/fdt/fdt_intr.c       |  20 ++++++++++----------
 sys/dev/fdt/fdt_mmc_pwrseq.c |  18 +++++++++---------
 sys/dev/fdt/fdt_phy.c        |  18 +++++++++---------
 sys/dev/fdt/fdt_pinctrl.c    |  16 +++++++++-------
 sys/dev/fdt/fdt_power.c      |  17 +++++++++--------
 sys/dev/fdt/fdt_pwm.c        |  18 +++++++++---------
 sys/dev/fdt/fdt_regulator.c  |  18 +++++++++---------
 sys/dev/fdt/fdt_reset.c      |  18 +++++++++---------
 13 files changed, 119 insertions(+), 116 deletions(-)

diffs (truncated from 800 to 300 lines):

diff -r 71fdf84aaf51 -r c292eefb0ec0 sys/dev/fdt/fdt_clock.c
--- a/sys/dev/fdt/fdt_clock.c   Sat Jun 30 20:16:56 2018 +0000
+++ b/sys/dev/fdt/fdt_clock.c   Sat Jun 30 20:34:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_clock.c,v 1.4 2018/06/16 00:12:35 jmcneill Exp $ */
+/* $NetBSD: fdt_clock.c,v 1.5 2018/06/30 20:34:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,11 +27,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.4 2018/06/16 00:12:35 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_clock.c,v 1.5 2018/06/30 20:34:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
+#include <sys/queue.h>
 
 #include <libfdt.h>
 #include <dev/fdt/fdtvar.h>
@@ -43,10 +44,11 @@
        int cc_phandle;
        const struct fdtbus_clock_controller_func *cc_funcs;
 
-       struct fdtbus_clock_controller *cc_next;
+       LIST_ENTRY(fdtbus_clock_controller) cc_next;
 };
 
-static struct fdtbus_clock_controller *fdtbus_cc = NULL;
+static LIST_HEAD(, fdtbus_clock_controller) fdtbus_clock_controllers =
+    LIST_HEAD_INITIALIZER(fdtbus_clock_controller);
 
 int
 fdtbus_register_clock_controller(device_t dev, int phandle,
@@ -59,8 +61,7 @@
        cc->cc_phandle = phandle;
        cc->cc_funcs = funcs;
 
-       cc->cc_next = fdtbus_cc;
-       fdtbus_cc = cc;
+       LIST_INSERT_HEAD(&fdtbus_clock_controllers, cc, cc_next);
 
        fdtbus_clock_assign(phandle);
 
@@ -72,10 +73,9 @@
 {
        struct fdtbus_clock_controller *cc;
 
-       for (cc = fdtbus_cc; cc; cc = cc->cc_next) {
-               if (cc->cc_phandle == phandle) {
+       LIST_FOREACH(cc, &fdtbus_clock_controllers, cc_next) {
+               if (cc->cc_phandle == phandle)
                        return cc;
-               }
        }
 
        return NULL;
@@ -185,7 +185,7 @@
        u_int len, resid, index, clock_cells;
        const char *p;
 
-       for (cc = fdtbus_cc; cc; cc = cc->cc_next) {
+       LIST_FOREACH(cc, &fdtbus_clock_controllers, cc_next) {
                if (!of_hasprop(cc->cc_phandle, "clock-output-names"))
                        continue;
                p = fdtbus_get_prop(cc->cc_phandle, "clock-output-names", &len);
diff -r 71fdf84aaf51 -r c292eefb0ec0 sys/dev/fdt/fdt_dai.c
--- a/sys/dev/fdt/fdt_dai.c     Sat Jun 30 20:16:56 2018 +0000
+++ b/sys/dev/fdt/fdt_dai.c     Sat Jun 30 20:34:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_dai.c,v 1.2 2018/06/03 01:08:55 jmcneill Exp $ */
+/* $NetBSD: fdt_dai.c,v 1.3 2018/06/30 20:34:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,11 +27,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_dai.c,v 1.2 2018/06/03 01:08:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_dai.c,v 1.3 2018/06/30 20:34:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
+#include <sys/queue.h>
 
 #include <libfdt.h>
 #include <dev/fdt/fdtvar.h>
@@ -41,10 +42,11 @@
        int dc_phandle;
        const struct fdtbus_dai_controller_func *dc_funcs;
 
-       struct fdtbus_dai_controller *dc_next;
+       LIST_ENTRY(fdtbus_dai_controller) dc_next;
 };
 
-static struct fdtbus_dai_controller *fdtbus_dc = NULL;
+static LIST_HEAD(, fdtbus_dai_controller) fdtbus_dai_controllers =
+    LIST_HEAD_INITIALIZER(fdtbus_dai_controllers);
 
 int
 fdtbus_register_dai_controller(device_t dev, int phandle,
@@ -57,8 +59,7 @@
        dc->dc_phandle = phandle;
        dc->dc_funcs = funcs;
 
-       dc->dc_next = fdtbus_dc;
-       fdtbus_dc = dc;
+       LIST_INSERT_HEAD(&fdtbus_dai_controllers, dc, dc_next);
 
        return 0;
 }
@@ -68,10 +69,9 @@
 {
        struct fdtbus_dai_controller *dc;
 
-       for (dc = fdtbus_dc; dc; dc = dc->dc_next) {
-               if (dc->dc_phandle == phandle) {
+       LIST_FOREACH(dc, &fdtbus_dai_controllers, dc_next) {
+               if (dc->dc_phandle == phandle)
                        return dc;
-               }
        }
 
        return NULL;
diff -r 71fdf84aaf51 -r c292eefb0ec0 sys/dev/fdt/fdt_dma.c
--- a/sys/dev/fdt/fdt_dma.c     Sat Jun 30 20:16:56 2018 +0000
+++ b/sys/dev/fdt/fdt_dma.c     Sat Jun 30 20:34:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_dma.c,v 1.1 2017/04/29 11:00:56 jmcneill Exp $ */
+/* $NetBSD: fdt_dma.c,v 1.2 2018/06/30 20:34:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,11 +27,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_dma.c,v 1.1 2017/04/29 11:00:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_dma.c,v 1.2 2018/06/30 20:34:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
+#include <sys/queue.h>
 
 #include <libfdt.h>
 #include <dev/fdt/fdtvar.h>
@@ -41,10 +42,11 @@
        int dma_phandle;
        const struct fdtbus_dma_controller_func *dma_funcs;
 
-       struct fdtbus_dma_controller *dma_next;
+       LIST_ENTRY(fdtbus_dma_controller) dma_next;
 };
 
-static struct fdtbus_dma_controller *fdtbus_dma = NULL;
+static LIST_HEAD(, fdtbus_dma_controller) fdtbus_dma_controllers =
+    LIST_HEAD_INITIALIZER(fdtbus_dma_controllers);
 
 int
 fdtbus_register_dma_controller(device_t dev, int phandle,
@@ -57,8 +59,7 @@
        dma->dma_phandle = phandle;
        dma->dma_funcs = funcs;
 
-       dma->dma_next = fdtbus_dma;
-       fdtbus_dma = dma;
+       LIST_INSERT_HEAD(&fdtbus_dma_controllers, dma, dma_next);
 
        return 0;
 }
@@ -68,10 +69,9 @@
 {
        struct fdtbus_dma_controller *dma;
 
-       for (dma = fdtbus_dma; dma; dma = dma->dma_next) {
-               if (dma->dma_phandle == phandle) {
+       LIST_FOREACH(dma, &fdtbus_dma_controllers, dma_next) {
+               if (dma->dma_phandle == phandle)
                        return dma;
-               }
        }
 
        return NULL;
diff -r 71fdf84aaf51 -r c292eefb0ec0 sys/dev/fdt/fdt_gpio.c
--- a/sys/dev/fdt/fdt_gpio.c    Sat Jun 30 20:16:56 2018 +0000
+++ b/sys/dev/fdt/fdt_gpio.c    Sat Jun 30 20:34:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_gpio.c,v 1.5 2017/08/13 18:27:11 jmcneill Exp $ */
+/* $NetBSD: fdt_gpio.c,v 1.6 2018/06/30 20:34:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,11 +27,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_gpio.c,v 1.5 2017/08/13 18:27:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_gpio.c,v 1.6 2018/06/30 20:34:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
+#include <sys/queue.h>
 
 #include <libfdt.h>
 #include <dev/fdt/fdtvar.h>
@@ -41,10 +42,11 @@
        int gc_phandle;
        const struct fdtbus_gpio_controller_func *gc_funcs;
 
-       struct fdtbus_gpio_controller *gc_next;
+       LIST_ENTRY(fdtbus_gpio_controller) gc_next;
 };
 
-static struct fdtbus_gpio_controller *fdtbus_gc = NULL;
+static LIST_HEAD(, fdtbus_gpio_controller) fdtbus_gpio_controllers =
+    LIST_HEAD_INITIALIZER(fdtbus_gpio_controllers);
 
 int
 fdtbus_register_gpio_controller(device_t dev, int phandle,
@@ -57,8 +59,7 @@
        gc->gc_phandle = phandle;
        gc->gc_funcs = funcs;
 
-       gc->gc_next = fdtbus_gc;
-       fdtbus_gc = gc;
+       LIST_INSERT_HEAD(&fdtbus_gpio_controllers, gc, gc_next);
 
        return 0;
 }
@@ -68,10 +69,9 @@
 {
        struct fdtbus_gpio_controller *gc;
 
-       for (gc = fdtbus_gc; gc; gc = gc->gc_next) {
-               if (gc->gc_phandle == phandle) {
+       LIST_FOREACH(gc, &fdtbus_gpio_controllers, gc_next) {
+               if (gc->gc_phandle == phandle)
                        return gc;
-               }
        }
 
        return NULL;
diff -r 71fdf84aaf51 -r c292eefb0ec0 sys/dev/fdt/fdt_i2c.c
--- a/sys/dev/fdt/fdt_i2c.c     Sat Jun 30 20:16:56 2018 +0000
+++ b/sys/dev/fdt/fdt_i2c.c     Sat Jun 30 20:34:43 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_i2c.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $ */
+/* $NetBSD: fdt_i2c.c,v 1.3 2018/06/30 20:34:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,11 +27,12 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_i2c.c,v 1.3 2018/06/30 20:34:43 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
 #include <sys/kmem.h>
+#include <sys/queue.h>
 
 #include <libfdt.h>
 #include <dev/fdt/fdtvar.h>
@@ -41,10 +42,11 @@
        int i2c_phandle;
        const struct fdtbus_i2c_controller_func *i2c_funcs;
 
-       struct fdtbus_i2c_controller *i2c_next;
+       LIST_ENTRY(fdtbus_i2c_controller) i2c_next;
 };
 
-static struct fdtbus_i2c_controller *fdtbus_i2c = NULL;
+static LIST_HEAD(, fdtbus_i2c_controller) fdtbus_i2c_controllers =
+    LIST_HEAD_INITIALIZER(fdtbus_i2c_controllers);
 
 int
 fdtbus_register_i2c_controller(device_t dev, int phandle,
@@ -57,8 +59,7 @@
        i2c->i2c_phandle = phandle;
        i2c->i2c_funcs = funcs;
 
-       i2c->i2c_next = fdtbus_i2c;
-       fdtbus_i2c = i2c;
+       LIST_INSERT_HEAD(&fdtbus_i2c_controllers, i2c, i2c_next);
 
        return 0;
 }
@@ -68,10 +69,9 @@
 {
        struct fdtbus_i2c_controller *i2c;
 



Home | Main Index | Thread Index | Old Index