Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/samsung arm/samsung: Don't abuse child's dv_pri...
details: https://anonhg.NetBSD.org/src/rev/3d500093303b
branches: trunk
changeset: 361135:3d500093303b
user: riastradh <riastradh%NetBSD.org@localhost>
date: Fri Feb 11 23:48:50 2022 +0000
description:
arm/samsung: Don't abuse child's dv_private for the parent's uses.
dv_private belongs to the device itself, i.e., the child here.
This overwrote the child's softc pointer, causing all kinds of havoc;
if this worked it was by an amazing accident.
diffstat:
sys/arch/arm/samsung/exynos_gpio.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diffs (58 lines):
diff -r ef1d1441b399 -r 3d500093303b sys/arch/arm/samsung/exynos_gpio.c
--- a/sys/arch/arm/samsung/exynos_gpio.c Fri Feb 11 23:48:41 2022 +0000
+++ b/sys/arch/arm/samsung/exynos_gpio.c Fri Feb 11 23:48:50 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos_gpio.c,v 1.32 2021/08/07 16:18:45 thorpej Exp $ */
+/* $NetBSD: exynos_gpio.c,v 1.33 2022/02/11 23:48:50 riastradh Exp $ */
/*-
* Copyright (c) 2014, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
#include "gpio.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exynos_gpio.c,v 1.32 2021/08/07 16:18:45 thorpej Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exynos_gpio.c,v 1.33 2022/02/11 23:48:50 riastradh Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -398,7 +398,6 @@
bank->bank_sc = sc;
bank->bank_dev =
config_found(parent->sc_dev, &gba, exynos_gpio_cfprint, CFARGS_NONE);
- bank->bank_dev->dv_private = sc;
/* read in our initial settings */
bank->bank_cfg.cfg = GPIO_READ(bank, EXYNOS_GPIO_CON);
@@ -451,7 +450,14 @@
static void *
exynos_gpio_fdt_acquire(device_t dev, const void *data, size_t len, int flags)
{
+ device_t parent = device_parent(dev);
+ struct exynos_pinctrl_softc *sc = device_private(parent);
+ const struct exynos_pinctrl_banks *epb = sc->sc_epb;
+ struct exynos_gpio_bank *bank = NULL;
struct exynos_gpio_pin *gpin;
+ u_int n;
+
+ KASSERT(device_is_a(parent, "exyopctl"));
if (len != 12)
return NULL;
@@ -460,8 +466,14 @@
const int pin = be32toh(cells[1]) & 0x0f;
const int actlo = be32toh(cells[2]) & 0x01;
- struct exynos_gpio_softc *bank_sc = device_private(dev);
- struct exynos_gpio_bank * const bank = bank_sc->sc_bank;
+ for (n = 0; n < epb->epb_nbanks; n++) {
+ if (epb->epb_banks[n].bank_dev == dev) {
+ bank = &epb->epb_banks[n];
+ break;
+ }
+ }
+ KASSERTMSG(bank != NULL, "no such gpio bank child of %s @ %p: %s @ %p",
+ device_xname(parent), parent, device_xname(dev), dev);
gpin = kmem_alloc(sizeof(*gpin), KM_SLEEP);
gpin->pin_sc = bank->bank_sc;
Home |
Main Index |
Thread Index |
Old Index