Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Add a device_t parameter to acpi_enter_i2c_devs....



details:   https://anonhg.NetBSD.org/src/rev/be36e9347a64
branches:  trunk
changeset: 958951:be36e9347a64
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Tue Jan 26 00:19:52 2021 +0000

description:
Add a device_t parameter to acpi_enter_i2c_devs. If non-NULL, all child
acpi_devnodes will be claimed by that device so we don't later try to
attach a duplicate device to that node at acpinodebus.

diffstat:

 sys/arch/arm/broadcom/bcm2835_bsc_acpi.c |   6 +++---
 sys/arch/x86/pci/dwiic_pci.c             |   6 +++---
 sys/dev/acpi/acpi_i2c.c                  |  11 ++++++++---
 sys/dev/acpi/acpi_i2c.h                  |   4 ++--
 sys/dev/acpi/acpi_util.c                 |  20 ++++++++++++++++++--
 sys/dev/acpi/acpi_util.h                 |   4 +++-
 sys/dev/acpi/dwiic_acpi.c                |   6 +++---
 sys/dev/acpi/nxpiic_acpi.c               |   6 +++---
 sys/dev/i2c/i2cmux.c                     |   6 +++---
 9 files changed, 46 insertions(+), 23 deletions(-)

diffs (243 lines):

diff -r 66d8638e0a91 -r be36e9347a64 sys/arch/arm/broadcom/bcm2835_bsc_acpi.c
--- a/sys/arch/arm/broadcom/bcm2835_bsc_acpi.c  Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_bsc_acpi.c  Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_bsc_acpi.c,v 1.1 2020/03/31 12:23:17 jmcneill Exp $ */
+/* $NetBSD: bcm2835_bsc_acpi.c,v 1.2 2021/01/26 00:19:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc_acpi.c,v 1.1 2020/03/31 12:23:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_bsc_acpi.c,v 1.2 2021/01/26 00:19:52 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -160,7 +160,7 @@
 
        memset(&iba, 0, sizeof(iba));
        iba.iba_tag = &sc->sc_i2c;
-       iba.iba_child_devices = acpi_enter_i2c_devs(aa->aa_node);
+       iba.iba_child_devices = acpi_enter_i2c_devs(self, aa->aa_node);
        config_found_ia(self, "i2cbus", &iba, iicbus_print);
 
 done:
diff -r 66d8638e0a91 -r be36e9347a64 sys/arch/x86/pci/dwiic_pci.c
--- a/sys/arch/x86/pci/dwiic_pci.c      Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/arch/x86/pci/dwiic_pci.c      Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic_pci.c,v 1.2 2018/09/26 19:06:33 jakllsch Exp $ */
+/* $NetBSD: dwiic_pci.c,v 1.3 2021/01/26 00:19:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.2 2018/09/26 19:06:33 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic_pci.c,v 1.3 2021/01/26 00:19:52 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -170,7 +170,7 @@
 
        if (sc->sc_acpinode) {
                sc->sc_dwiic.sc_iba.iba_child_devices = 
-                   acpi_enter_i2c_devs(sc->sc_acpinode);
+                   acpi_enter_i2c_devs(NULL, sc->sc_acpinode);
        } else {
                aprint_verbose_dev(self, "no matching ACPI node\n");
        }
diff -r 66d8638e0a91 -r be36e9347a64 sys/dev/acpi/acpi_i2c.c
--- a/sys/dev/acpi/acpi_i2c.c   Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/dev/acpi/acpi_i2c.c   Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_i2c.c,v 1.9 2021/01/25 12:15:32 jmcneill Exp $ */
+/* $NetBSD: acpi_i2c.c,v 1.10 2021/01/26 00:19:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.9 2021/01/25 12:15:32 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_i2c.c,v 1.10 2021/01/26 00:19:53 jmcneill Exp $");
 
 #include <dev/acpi/acpireg.h>
 #include <dev/acpi/acpivar.h>
@@ -225,7 +225,7 @@
 
 
 prop_array_t
-acpi_enter_i2c_devs(struct acpi_devnode *devnode)
+acpi_enter_i2c_devs(device_t dev, struct acpi_devnode *devnode)
 {
        struct acpi_devnode *ad;
        prop_array_t array = prop_array_create();
@@ -240,5 +240,10 @@
                        continue;
                acpi_enter_i2c_device(ad, array);
        }
+
+       if (dev != NULL) {
+               acpi_claim_childdevs(dev, devnode);
+       }
+
        return array;
 }
diff -r 66d8638e0a91 -r be36e9347a64 sys/dev/acpi/acpi_i2c.h
--- a/sys/dev/acpi/acpi_i2c.h   Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/dev/acpi/acpi_i2c.h   Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_i2c.h,v 1.1 2017/12/10 16:51:30 bouyer Exp $ */
+/* $NetBSD: acpi_i2c.h,v 1.2 2021/01/26 00:19:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -34,5 +34,5 @@
 #define _SYS_DEV_ACPI_ACPI_I2C_H
 #include <prop/proplib.h>
 
-prop_array_t acpi_enter_i2c_devs(struct acpi_devnode *);
+prop_array_t acpi_enter_i2c_devs(device_t, struct acpi_devnode *);
 #endif /*  _SYS_DEV_ACPI_ACPI_I2C_H */
diff -r 66d8638e0a91 -r be36e9347a64 sys/dev/acpi/acpi_util.c
--- a/sys/dev/acpi/acpi_util.c  Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/dev/acpi/acpi_util.c  Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_util.c,v 1.20 2021/01/14 14:35:53 thorpej Exp $ */
+/*     $NetBSD: acpi_util.c,v 1.21 2021/01/26 00:19:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007, 2021 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.20 2021/01/14 14:35:53 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.21 2021/01/26 00:19:53 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -864,3 +864,19 @@
        return acpi_dsm_typed(handle, uuid, rev, func, arg3, ACPI_TYPE_ANY,
            return_obj);
 }
+
+ACPI_STATUS
+acpi_claim_childdevs(device_t dev, struct acpi_devnode *devnode)
+{
+       struct acpi_devnode *ad;
+
+       SIMPLEQ_FOREACH(ad, &devnode->ad_child_head, ad_child_list) {
+               if (ad->ad_device != NULL)
+                       continue;
+               aprint_debug(dev, "claiming %s\n", acpi_name(ad->ad_handle));
+               ad->ad_device = dev;
+               acpi_claim_childdevs(dev, ad);
+       }
+
+       return AE_OK;
+}
diff -r 66d8638e0a91 -r be36e9347a64 sys/dev/acpi/acpi_util.h
--- a/sys/dev/acpi/acpi_util.h  Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/dev/acpi/acpi_util.h  Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_util.h,v 1.9 2021/01/14 14:35:53 thorpej Exp $ */
+/*     $NetBSD: acpi_util.h,v 1.10 2021/01/26 00:19:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -102,4 +102,6 @@
                        ACPI_INTEGER, const ACPI_OBJECT *,
                        ACPI_INTEGER *);
 
+ACPI_STATUS     acpi_claim_childdevs(device_t, struct acpi_devnode *);
+
 #endif /* !_SYS_DEV_ACPI_ACPI_UTIL_H */
diff -r 66d8638e0a91 -r be36e9347a64 sys/dev/acpi/dwiic_acpi.c
--- a/sys/dev/acpi/dwiic_acpi.c Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/dev/acpi/dwiic_acpi.c Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwiic_acpi.c,v 1.5 2021/01/24 16:33:48 jmcneill Exp $ */
+/* $NetBSD: dwiic_acpi.c,v 1.6 2021/01/26 00:19:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: dwiic_acpi.c,v 1.5 2021/01/24 16:33:48 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwiic_acpi.c,v 1.6 2021/01/26 00:19:53 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -128,7 +128,7 @@
 
        dwiic_acpi_configure(sc, aa->aa_node->ad_handle);
 
-       sc->sc_iba.iba_child_devices = acpi_enter_i2c_devs(aa->aa_node);
+       sc->sc_iba.iba_child_devices = acpi_enter_i2c_devs(self, aa->aa_node);
 
        dwiic_attach(sc);
 
diff -r 66d8638e0a91 -r be36e9347a64 sys/dev/acpi/nxpiic_acpi.c
--- a/sys/dev/acpi/nxpiic_acpi.c        Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/dev/acpi/nxpiic_acpi.c        Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nxpiic_acpi.c,v 1.2 2021/01/25 12:09:58 jmcneill Exp $ */
+/* $NetBSD: nxpiic_acpi.c,v 1.3 2021/01/26 00:19:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nxpiic_acpi.c,v 1.2 2021/01/25 12:09:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nxpiic_acpi.c,v 1.3 2021/01/26 00:19:53 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -151,7 +151,7 @@
        msc->sc_flags |= MOTOI2C_F_ENABLE_INV | MOTOI2C_F_STATUS_W1C;
        msc->sc_iord = nxpiic_acpi_iord;
        msc->sc_iowr = nxpiic_acpi_iowr;
-       msc->sc_child_devices = acpi_enter_i2c_devs(aa->aa_node);
+       msc->sc_child_devices = acpi_enter_i2c_devs(self, aa->aa_node);
 
        motoi2c_attach_common(self, msc, &settings);
 
diff -r 66d8638e0a91 -r be36e9347a64 sys/dev/i2c/i2cmux.c
--- a/sys/dev/i2c/i2cmux.c      Mon Jan 25 20:07:55 2021 +0000
+++ b/sys/dev/i2c/i2cmux.c      Tue Jan 26 00:19:52 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i2cmux.c,v 1.3 2021/01/25 12:18:18 jmcneill Exp $      */
+/*     $NetBSD: i2cmux.c,v 1.4 2021/01/26 00:19:53 jmcneill Exp $      */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.3 2021/01/25 12:18:18 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2cmux.c,v 1.4 2021/01/26 00:19:53 jmcneill Exp $");
 
 #include <sys/types.h>
 #include <sys/device.h>
@@ -199,7 +199,7 @@
                KASSERT(ad != NULL);
                struct i2cbus_attach_args iba = {
                        .iba_tag = &bus->controller,
-                       .iba_child_devices = acpi_enter_i2c_devs(ad)
+                       .iba_child_devices = acpi_enter_i2c_devs(NULL, ad)
                };
                config_found_ia(sc->sc_dev, "i2cbus", &iba, iicbus_print);
        }       break;



Home | Main Index | Thread Index | Old Index