Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/acpi Add acpi_intr_establish_irq, which is like acpi...



details:   https://anonhg.NetBSD.org/src/rev/157d50545386
branches:  trunk
changeset: 945170:157d50545386
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Fri Oct 23 10:59:37 2020 +0000

description:
Add acpi_intr_establish_irq, which is like acpi_intr_establish except
it takes a struct acpi_irq * instead of ACPI_HANDLE. Useful if a device
has more than one IRQ resource (acpi_intr_establish always picks the
first).

diffstat:

 sys/dev/acpi/acpi_intr.h |   4 +++-
 sys/dev/acpi/acpi_util.c |  29 ++++++++++++++++++++---------
 2 files changed, 23 insertions(+), 10 deletions(-)

diffs (90 lines):

diff -r de27230db92e -r 157d50545386 sys/dev/acpi/acpi_intr.h
--- a/sys/dev/acpi/acpi_intr.h  Fri Oct 23 09:05:20 2020 +0000
+++ b/sys/dev/acpi/acpi_intr.h  Fri Oct 23 10:59:37 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_intr.h,v 1.4 2019/12/22 15:57:07 thorpej Exp $ */
+/* $NetBSD: acpi_intr.h,v 1.5 2020/10/23 10:59:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -34,6 +34,8 @@
 
 void *         acpi_intr_establish(device_t, uint64_t, int, bool,
                    int (*intr)(void *), void *, const char *);
+void *         acpi_intr_establish_irq(device_t, struct acpi_irq *, int,
+                   bool, int (*intr)(void *), void *, const char *);
 void           acpi_intr_mask(void *);
 void           acpi_intr_unmask(void *);
 void           acpi_intr_disestablish(void *);
diff -r de27230db92e -r 157d50545386 sys/dev/acpi/acpi_util.c
--- a/sys/dev/acpi/acpi_util.c  Fri Oct 23 09:05:20 2020 +0000
+++ b/sys/dev/acpi/acpi_util.c  Fri Oct 23 10:59:37 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: acpi_util.c,v 1.18 2019/12/31 09:10:15 mlelstv Exp $ */
+/*     $NetBSD: acpi_util.c,v 1.19 2020/10/23 10:59:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2003, 2007 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.18 2019/12/31 09:10:15 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_util.c,v 1.19 2020/10/23 10:59:37 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -550,7 +550,6 @@
 }
 
 struct acpi_irq_handler {
-       ACPI_HANDLE aih_hdl;
        uint32_t aih_irq;
        void *aih_ih;
 };
@@ -563,8 +562,7 @@
        ACPI_HANDLE hdl = (void *)(uintptr_t)c;
        struct acpi_resources res;
        struct acpi_irq *irq;
-       struct acpi_irq_handler *aih = NULL;
-       void *ih;
+       void *aih = NULL;
 
        rv = acpi_resource_parse(dev, hdl, "_CRS", &res,
            &acpi_resource_parse_ops_quiet);
@@ -575,18 +573,31 @@
        if (irq == NULL)
                goto end;
 
+       aih = acpi_intr_establish_irq(dev, irq, ipl, mpsafe,
+           intr, iarg, xname);
+
+end:
+       acpi_resource_cleanup(&res);
+
+       return aih;
+}
+
+void *
+acpi_intr_establish_irq(device_t dev, struct acpi_irq *irq, int ipl,
+    bool mpsafe, int (*intr)(void *), void *iarg, const char *xname)
+{
+       struct acpi_irq_handler *aih;
+       void *ih;
+
        const int type = (irq->ar_type == ACPI_EDGE_SENSITIVE) ? IST_EDGE : IST_LEVEL;
        ih = acpi_md_intr_establish(irq->ar_irq, ipl, type, intr, iarg, mpsafe, xname);
        if (ih == NULL)
-               goto end;
+               return NULL;
 
        aih = kmem_alloc(sizeof(struct acpi_irq_handler), KM_SLEEP);
-       aih->aih_hdl = hdl;
        aih->aih_irq = irq->ar_irq;
        aih->aih_ih = ih;
 
-end:
-       acpi_resource_cleanup(&res);
        return aih;
 }
 



Home | Main Index | Thread Index | Old Index