diff options
| author | jmcneill <jmcneill@NetBSD.org> | 2018-06-30 20:34:43 +0000 |
|---|---|---|
| committer | jmcneill <jmcneill@NetBSD.org> | 2018-06-30 20:34:43 +0000 |
| commit | 2797fbda62f306be77f74bfee1b10dee10def0f7 (patch) | |
| tree | 6ddbd5f15a1e655018bdd4d5d264a3879dd4ebcf /sys/dev/fdt | |
| parent | 15f6951151bfbf24bfe7d72bb3ca9fa61602bf83 (diff) | |
Use queue(3) API to manage lists. NFCI.
Diffstat (limited to 'sys/dev/fdt')
| -rw-r--r-- | sys/dev/fdt/fdt_clock.c | 20 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_dai.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_dma.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_gpio.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_i2c.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_intr.c | 20 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_mmc_pwrseq.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_phy.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_pinctrl.c | 16 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_power.c | 17 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_pwm.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_regulator.c | 18 | ||||
| -rw-r--r-- | sys/dev/fdt/fdt_reset.c | 18 |
13 files changed, 119 insertions, 116 deletions
diff --git a/sys/dev/fdt/fdt_clock.c b/sys/dev/fdt/fdt_clock.c index 09505427d27..f82e2c86b63 100644 --- a/sys/dev/fdt/fdt_clock.c +++ b/sys/dev/fdt/fdt_clock.c @@ -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> @@ -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 @@ struct fdtbus_clock_controller { 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 @@ fdtbus_register_clock_controller(device_t dev, int phandle, 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 @@ fdtbus_get_clock_controller(int phandle) { 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 @@ fdtbus_clock_byname(const char *clkname) 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 --git a/sys/dev/fdt/fdt_dai.c b/sys/dev/fdt/fdt_dai.c index c3eaa09946c..21c3a344a31 100644 --- a/sys/dev/fdt/fdt_dai.c +++ b/sys/dev/fdt/fdt_dai.c @@ -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> @@ -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 @@ struct fdtbus_dai_controller { 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 @@ fdtbus_register_dai_controller(device_t dev, int phandle, 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 @@ fdtbus_get_dai_controller(int phandle) { 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 --git a/sys/dev/fdt/fdt_dma.c b/sys/dev/fdt/fdt_dma.c index a9d45b096c4..7b44b0de8d1 100644 --- a/sys/dev/fdt/fdt_dma.c +++ b/sys/dev/fdt/fdt_dma.c @@ -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> @@ -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 @@ struct fdtbus_dma_controller { 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 @@ fdtbus_register_dma_controller(device_t dev, int phandle, 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 @@ fdtbus_get_dma_controller(int phandle) { 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 --git a/sys/dev/fdt/fdt_gpio.c b/sys/dev/fdt/fdt_gpio.c index 7b636ca6881..2987f11902f 100644 --- a/sys/dev/fdt/fdt_gpio.c +++ b/sys/dev/fdt/fdt_gpio.c @@ -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> @@ -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 @@ struct fdtbus_gpio_controller { 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 @@ fdtbus_register_gpio_controller(device_t dev, int phandle, 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 @@ fdtbus_get_gpio_controller(int phandle) { 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 --git a/sys/dev/fdt/fdt_i2c.c b/sys/dev/fdt/fdt_i2c.c index 09c6b7b9170..6dedd6d2978 100644 --- a/sys/dev/fdt/fdt_i2c.c +++ b/sys/dev/fdt/fdt_i2c.c @@ -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> @@ -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 @@ struct fdtbus_i2c_controller { 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 @@ fdtbus_register_i2c_controller(device_t dev, int phandle, 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 @@ fdtbus_get_i2c_controller(int phandle) { struct fdtbus_i2c_controller *i2c; - for (i2c = fdtbus_i2c; i2c; i2c = i2c->i2c_next) { - if (i2c->i2c_phandle == phandle) { + LIST_FOREACH(i2c, &fdtbus_i2c_controllers, i2c_next) { + if (i2c->i2c_phandle == phandle) return i2c; - } } return NULL; diff --git a/sys/dev/fdt/fdt_intr.c b/sys/dev/fdt/fdt_intr.c index 9896e313a51..6d648f1e4e1 100644 --- a/sys/dev/fdt/fdt_intr.c +++ b/sys/dev/fdt/fdt_intr.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_intr.c,v 1.11 2017/06/11 12:56:36 jmcneill Exp $ */ +/* $NetBSD: fdt_intr.c,v 1.12 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,11 +27,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.11 2017/06/11 12:56:36 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.12 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,16 +42,17 @@ struct fdtbus_interrupt_controller { int ic_phandle; const struct fdtbus_interrupt_controller_func *ic_funcs; - struct fdtbus_interrupt_controller *ic_next; + LIST_ENTRY(fdtbus_interrupt_controller) ic_next; }; +static LIST_HEAD(, fdtbus_interrupt_controller) fdtbus_interrupt_controllers = + LIST_HEAD_INITIALIZER(fdtbus_interrupt_controllers); + struct fdtbus_interrupt_cookie { struct fdtbus_interrupt_controller *c_ic; void *c_ih; }; -static struct fdtbus_interrupt_controller *fdtbus_ic = NULL; - static bool has_interrupt_map(int); static u_int * get_specifier_by_index(int, int, int *); static u_int * get_specifier_from_map(int, int, int *); @@ -87,10 +89,9 @@ static struct fdtbus_interrupt_controller * fdtbus_get_interrupt_controller(int phandle) { struct fdtbus_interrupt_controller * ic; - for (ic = fdtbus_ic; ic; ic = ic->ic_next) { - if (ic->ic_phandle == phandle) { + LIST_FOREACH(ic, &fdtbus_interrupt_controllers, ic_next) { + if (ic->ic_phandle == phandle) return ic; - } } return NULL; } @@ -106,8 +107,7 @@ fdtbus_register_interrupt_controller(device_t dev, int phandle, ic->ic_phandle = phandle; ic->ic_funcs = funcs; - ic->ic_next = fdtbus_ic; - fdtbus_ic = ic; + LIST_INSERT_HEAD(&fdtbus_interrupt_controllers, ic, ic_next); return 0; } diff --git a/sys/dev/fdt/fdt_mmc_pwrseq.c b/sys/dev/fdt/fdt_mmc_pwrseq.c index 7d96fd21b18..a7c3a144ef7 100644 --- a/sys/dev/fdt/fdt_mmc_pwrseq.c +++ b/sys/dev/fdt/fdt_mmc_pwrseq.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_mmc_pwrseq.c,v 1.1 2017/10/22 13:56:49 jmcneill Exp $ */ +/* $NetBSD: fdt_mmc_pwrseq.c,v 1.2 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> @@ -27,11 +27,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_mmc_pwrseq.c,v 1.1 2017/10/22 13:56:49 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_mmc_pwrseq.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 @@ struct fdtbus_mmc_pwrseq { int mps_phandle; const struct fdtbus_mmc_pwrseq_func *mps_funcs; - struct fdtbus_mmc_pwrseq *mps_next; + LIST_ENTRY(fdtbus_mmc_pwrseq) mps_next; }; -static struct fdtbus_mmc_pwrseq *fdtbus_mps = NULL; +static LIST_HEAD(, fdtbus_mmc_pwrseq) fdtbus_mmc_pwrseqs = + LIST_HEAD_INITIALIZER(fdtbus_mmc_pwrseqs); int fdtbus_register_mmc_pwrseq(device_t dev, int phandle, @@ -57,8 +59,7 @@ fdtbus_register_mmc_pwrseq(device_t dev, int phandle, mps->mps_phandle = phandle; mps->mps_funcs = funcs; - mps->mps_next = fdtbus_mps; - fdtbus_mps = mps; + LIST_INSERT_HEAD(&fdtbus_mmc_pwrseqs, mps, mps_next); return 0; } @@ -68,10 +69,9 @@ fdtbus_get_mmc_pwrseq(int phandle) { struct fdtbus_mmc_pwrseq *mps; - for (mps = fdtbus_mps; mps; mps = mps->mps_next) { - if (mps->mps_phandle == phandle) { + LIST_FOREACH(mps, &fdtbus_mmc_pwrseqs, mps_next) { + if (mps->mps_phandle == phandle) return mps; - } } return NULL; diff --git a/sys/dev/fdt/fdt_phy.c b/sys/dev/fdt/fdt_phy.c index d26738c62ab..bdcf306626f 100644 --- a/sys/dev/fdt/fdt_phy.c +++ b/sys/dev/fdt/fdt_phy.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_phy.c,v 1.1 2017/06/29 17:04:17 jmcneill Exp $ */ +/* $NetBSD: fdt_phy.c,v 1.2 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill <jmcneill@invisible.ca> @@ -27,11 +27,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_phy.c,v 1.1 2017/06/29 17:04:17 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_phy.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 @@ struct fdtbus_phy_controller { int pc_phandle; const struct fdtbus_phy_controller_func *pc_funcs; - struct fdtbus_phy_controller *pc_next; + LIST_ENTRY(fdtbus_phy_controller) pc_next; }; -static struct fdtbus_phy_controller *fdtbus_pc = NULL; +static LIST_HEAD(, fdtbus_phy_controller) fdtbus_phy_controllers = + LIST_HEAD_INITIALIZER(fdtbus_phy_controllers); int fdtbus_register_phy_controller(device_t dev, int phandle, @@ -57,8 +59,7 @@ fdtbus_register_phy_controller(device_t dev, int phandle, pc->pc_phandle = phandle; pc->pc_funcs = funcs; - pc->pc_next = fdtbus_pc; - fdtbus_pc = pc; + LIST_INSERT_HEAD(&fdtbus_phy_controllers, pc, pc_next); return 0; } @@ -68,10 +69,9 @@ fdtbus_get_phy_controller(int phandle) { struct fdtbus_phy_controller *pc; - for (pc = fdtbus_pc; pc; pc = pc->pc_next) { - if (pc->pc_phandle == phandle) { + LIST_FOREACH(pc, &fdtbus_phy_controllers, pc_next) { + if (pc->pc_phandle == phandle) return pc; - } } return NULL; diff --git a/sys/dev/fdt/fdt_pinctrl.c b/sys/dev/fdt/fdt_pinctrl.c index 70720114d16..e23e778590a 100644 --- a/sys/dev/fdt/fdt_pinctrl.c +++ b/sys/dev/fdt/fdt_pinctrl.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_pinctrl.c,v 1.4 2017/07/02 15:27:58 jmcneill Exp $ */ +/* $NetBSD: fdt_pinctrl.c,v 1.5 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> @@ -28,11 +28,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_pinctrl.c,v 1.4 2017/07/02 15:27:58 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_pinctrl.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> @@ -42,10 +43,11 @@ struct fdtbus_pinctrl_controller { int pc_phandle; const struct fdtbus_pinctrl_controller_func *pc_funcs; - struct fdtbus_pinctrl_controller *pc_next; + LIST_ENTRY(fdtbus_pinctrl_controller) pc_next; }; -static struct fdtbus_pinctrl_controller *fdtbus_pc = NULL; +static LIST_HEAD(, fdtbus_pinctrl_controller) fdtbus_pinctrl_controllers = + LIST_HEAD_INITIALIZER(fdtbus_pinctrl_controllers); int fdtbus_register_pinctrl_config(device_t dev, int phandle, @@ -58,8 +60,7 @@ fdtbus_register_pinctrl_config(device_t dev, int phandle, pc->pc_phandle = phandle; pc->pc_funcs = funcs; - pc->pc_next = fdtbus_pc; - fdtbus_pc = pc; + LIST_INSERT_HEAD(&fdtbus_pinctrl_controllers, pc, pc_next); return 0; } @@ -69,9 +70,10 @@ fdtbus_pinctrl_lookup(int phandle) { struct fdtbus_pinctrl_controller *pc; - for (pc = fdtbus_pc; pc; pc = pc->pc_next) + LIST_FOREACH(pc, &fdtbus_pinctrl_controllers, pc_next) { if (pc->pc_phandle == phandle) return pc; + } return NULL; } diff --git a/sys/dev/fdt/fdt_power.c b/sys/dev/fdt/fdt_power.c index 3fca76433e6..b9fa739c0ad 100644 --- a/sys/dev/fdt/fdt_power.c +++ b/sys/dev/fdt/fdt_power.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_power.c,v 1.1 2017/05/28 15:55:11 jmcneill Exp $ */ +/* $NetBSD: fdt_power.c,v 1.2 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2017 Jared McNeill <jmcneill@invisible.ca> @@ -27,11 +27,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_power.c,v 1.1 2017/05/28 15:55:11 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_power.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 @@ struct fdtbus_power_controller { int power_phandle; const struct fdtbus_power_controller_func *power_funcs; - struct fdtbus_power_controller *power_next; + LIST_ENTRY(fdtbus_power_controller) power_next; }; -static struct fdtbus_power_controller *fdtbus_power = NULL; +static LIST_HEAD(, fdtbus_power_controller) fdtbus_power_controllers = + LIST_HEAD_INITIALIZER(fdtbus_power_controllers); int fdtbus_register_power_controller(device_t dev, int phandle, @@ -57,8 +59,7 @@ fdtbus_register_power_controller(device_t dev, int phandle, power->power_phandle = phandle; power->power_funcs = funcs; - power->power_next = fdtbus_power; - fdtbus_power = power; + LIST_INSERT_HEAD(&fdtbus_power_controllers, power, power_next); return 0; } @@ -68,7 +69,7 @@ fdtbus_power_reset(void) { struct fdtbus_power_controller *power; - for (power = fdtbus_power; power; power = power->power_next) { + LIST_FOREACH(power, &fdtbus_power_controllers, power_next) { if (power->power_funcs->reset) power->power_funcs->reset(power->power_dev); } @@ -79,7 +80,7 @@ fdtbus_power_poweroff(void) { struct fdtbus_power_controller *power; - for (power = fdtbus_power; power; power = power->power_next) { + LIST_FOREACH(power, &fdtbus_power_controllers, power_next) { if (power->power_funcs->poweroff) power->power_funcs->poweroff(power->power_dev); } diff --git a/sys/dev/fdt/fdt_pwm.c b/sys/dev/fdt/fdt_pwm.c index 53d2cb852d9..4921338667b 100644 --- a/sys/dev/fdt/fdt_pwm.c +++ b/sys/dev/fdt/fdt_pwm.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_pwm.c,v 1.1 2018/05/06 10:33:21 jmcneill Exp $ */ +/* $NetBSD: fdt_pwm.c,v 1.2 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2018 Jared McNeill <jmcneill@invisible.ca> @@ -27,11 +27,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_pwm.c,v 1.1 2018/05/06 10:33:21 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_pwm.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 @@ struct fdtbus_pwm_controller { int pc_phandle; const struct fdtbus_pwm_controller_func *pc_funcs; - struct fdtbus_pwm_controller *pc_next; + LIST_ENTRY(fdtbus_pwm_controller) pc_next; }; -static struct fdtbus_pwm_controller *fdtbus_pc = NULL; +static LIST_HEAD(, fdtbus_pwm_controller) fdtbus_pwm_controllers = + LIST_HEAD_INITIALIZER(fdtbus_pwm_controllers); int fdtbus_register_pwm_controller(device_t dev, int phandle, @@ -57,8 +59,7 @@ fdtbus_register_pwm_controller(device_t dev, int phandle, pc->pc_phandle = phandle; pc->pc_funcs = funcs; - pc->pc_next = fdtbus_pc; - fdtbus_pc = pc; + LIST_INSERT_HEAD(&fdtbus_pwm_controllers, pc, pc_next); return 0; } @@ -68,10 +69,9 @@ fdtbus_get_pwm_controller(int phandle) { struct fdtbus_pwm_controller *pc; - for (pc = fdtbus_pc; pc; pc = pc->pc_next) { - if (pc->pc_phandle == phandle) { + LIST_FOREACH(pc, &fdtbus_pwm_controllers, pc_next) { + if (pc->pc_phandle == phandle) return pc; - } } return NULL; diff --git a/sys/dev/fdt/fdt_regulator.c b/sys/dev/fdt/fdt_regulator.c index 7dec3e7d80b..9d8be848bfd 100644 --- a/sys/dev/fdt/fdt_regulator.c +++ b/sys/dev/fdt/fdt_regulator.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_regulator.c,v 1.5 2018/03/06 17:24:57 bouyer Exp $ */ +/* $NetBSD: fdt_regulator.c,v 1.6 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,11 +27,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_regulator.c,v 1.5 2018/03/06 17:24:57 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_regulator.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 @@ struct fdtbus_regulator_controller { int rc_phandle; const struct fdtbus_regulator_controller_func *rc_funcs; - struct fdtbus_regulator_controller *rc_next; + LIST_ENTRY(fdtbus_regulator_controller) rc_next; }; -static struct fdtbus_regulator_controller *fdtbus_rc = NULL; +static LIST_HEAD(, fdtbus_regulator_controller) fdtbus_regulator_controllers = + LIST_HEAD_INITIALIZER(fdtbus_regulator_controllers); int fdtbus_register_regulator_controller(device_t dev, int phandle, @@ -57,8 +59,7 @@ fdtbus_register_regulator_controller(device_t dev, int phandle, rc->rc_phandle = phandle; rc->rc_funcs = funcs; - rc->rc_next = fdtbus_rc; - fdtbus_rc = rc; + LIST_INSERT_HEAD(&fdtbus_regulator_controllers, rc, rc_next); return 0; } @@ -68,10 +69,9 @@ fdtbus_get_regulator_controller(int phandle) { struct fdtbus_regulator_controller *rc; - for (rc = fdtbus_rc; rc; rc = rc->rc_next) { - if (rc->rc_phandle == phandle) { + LIST_FOREACH(rc, &fdtbus_regulator_controllers, rc_next) { + if (rc->rc_phandle == phandle) return rc; - } } return NULL; diff --git a/sys/dev/fdt/fdt_reset.c b/sys/dev/fdt/fdt_reset.c index ca14d6ff5bc..d802d65b28e 100644 --- a/sys/dev/fdt/fdt_reset.c +++ b/sys/dev/fdt/fdt_reset.c @@ -1,4 +1,4 @@ -/* $NetBSD: fdt_reset.c,v 1.1 2015/12/22 21:42:11 jmcneill Exp $ */ +/* $NetBSD: fdt_reset.c,v 1.2 2018/06/30 20:34:43 jmcneill Exp $ */ /*- * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca> @@ -27,11 +27,12 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: fdt_reset.c,v 1.1 2015/12/22 21:42:11 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: fdt_reset.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 @@ struct fdtbus_reset_controller { int rc_phandle; const struct fdtbus_reset_controller_func *rc_funcs; - struct fdtbus_reset_controller *rc_next; + LIST_ENTRY(fdtbus_reset_controller) rc_next; }; -static struct fdtbus_reset_controller *fdtbus_rc = NULL; +static LIST_HEAD(, fdtbus_reset_controller) fdtbus_reset_controllers = + LIST_HEAD_INITIALIZER(fdtbus_reset_controllers); int fdtbus_register_reset_controller(device_t dev, int phandle, @@ -57,8 +59,7 @@ fdtbus_register_reset_controller(device_t dev, int phandle, rc->rc_phandle = phandle; rc->rc_funcs = funcs; - rc->rc_next = fdtbus_rc; - fdtbus_rc = rc; + LIST_INSERT_HEAD(&fdtbus_reset_controllers, rc, rc_next); return 0; } @@ -68,10 +69,9 @@ fdtbus_get_reset_controller(int phandle) { struct fdtbus_reset_controller *rc; - for (rc = fdtbus_rc; rc; rc = rc->rc_next) { - if (rc->rc_phandle == phandle) { + LIST_FOREACH(rc, &fdtbus_reset_controllers, rc_next) { + if (rc->rc_phandle == phandle) return rc; - } } return NULL; |
