Date: Fri, 19 Jun 2020 18:54:55 +0000 (UTC) From: Emmanuel Vadot <manu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r362411 - stable/12/sys/arm64/rockchip Message-ID: <202006191854.05JIstQ0081434@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: manu Date: Fri Jun 19 18:54:55 2020 New Revision: 362411 URL: https://svnweb.freebsd.org/changeset/base/362411 Log: MFC r360311: arm64: rockchip: rk805: Use a tailq for the attached regulator Store the attached regulator in a tailq to later find them in ofw_map. While here, do not attempt to attach a regulator without a name, a node might exists but if it doesn't have a name the regulator is unused. Modified: stable/12/sys/arm64/rockchip/rk805.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm64/rockchip/rk805.c ============================================================================== --- stable/12/sys/arm64/rockchip/rk805.c Fri Jun 19 18:53:32 2020 (r362410) +++ stable/12/sys/arm64/rockchip/rk805.c Fri Jun 19 18:54:55 2020 (r362411) @@ -86,6 +86,11 @@ struct rk805_reg_sc { struct regnode_std_param *param; }; +struct reg_list { + TAILQ_ENTRY(reg_list) next; + struct rk805_reg_sc *reg; +}; + struct rk805_softc { device_t dev; struct mtx mtx; @@ -94,7 +99,7 @@ struct rk805_softc { struct intr_config_hook intr_hook; enum rk_pmic_type type; - struct rk805_reg_sc **regs; + TAILQ_HEAD(, reg_list) regs; int nregs; }; @@ -620,6 +625,7 @@ rk805_attach(device_t dev) struct rk805_softc *sc; struct rk805_reg_sc *reg; struct rk805_regdef *regdefs; + struct reg_list *regp; phandle_t rnode, child; int i; @@ -646,8 +652,7 @@ rk805_attach(device_t dev) return (ENXIO); } - sc->regs = malloc(sizeof(struct rk805_reg_sc *) * sc->nregs, - M_RK805_REG, M_WAITOK | M_ZERO); + TAILQ_INIT(&sc->regs); rnode = ofw_bus_find_child(ofw_bus_get_node(dev), "regulators"); if (rnode > 0) { @@ -656,6 +661,8 @@ rk805_attach(device_t dev) regdefs[i].name); if (child == 0) continue; + if (OF_hasprop(child, "regulator-name") != 1) + continue; reg = rk805_reg_attach(dev, child, ®defs[i]); if (reg == NULL) { device_printf(dev, @@ -663,7 +670,9 @@ rk805_attach(device_t dev) regdefs[i].name); continue; } - sc->regs[i] = reg; + regp = malloc(sizeof(*regp), M_DEVBUF, M_WAITOK | M_ZERO); + regp->reg = reg; + TAILQ_INSERT_TAIL(&sc->regs, regp, next); if (bootverbose) device_printf(dev, "Regulator %s attached\n", regdefs[i].name); @@ -686,13 +695,13 @@ rk805_map(device_t dev, phandle_t xref, int ncells, pcell_t *cells, intptr_t *id) { struct rk805_softc *sc; - int i; + struct reg_list *regp; sc = device_get_softc(dev); - for (i = 0; i < sc->nregs; i++) { - if (sc->regs[i]->xref == xref) { - *id = sc->regs[i]->def->id; + TAILQ_FOREACH(regp, &sc->regs, next) { + if (regp->reg->xref == xref) { + *id = regp->reg->def->id; return (0); } }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202006191854.05JIstQ0081434>