Module Name:    src
Committed By:   jmcneill
Date:           Fri Oct 23 10:59:37 UTC 2020

Modified Files:
        src/sys/dev/acpi: acpi_intr.h acpi_util.c

Log Message:
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).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/acpi/acpi_intr.h
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/acpi/acpi_util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/acpi/acpi_intr.h
diff -u src/sys/dev/acpi/acpi_intr.h:1.4 src/sys/dev/acpi/acpi_intr.h:1.5
--- src/sys/dev/acpi/acpi_intr.h:1.4	Sun Dec 22 15:57:07 2019
+++ src/sys/dev/acpi/acpi_intr.h	Fri Oct 23 10:59:37 2020
@@ -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 *);

Index: src/sys/dev/acpi/acpi_util.c
diff -u src/sys/dev/acpi/acpi_util.c:1.18 src/sys/dev/acpi/acpi_util.c:1.19
--- src/sys/dev/acpi/acpi_util.c:1.18	Tue Dec 31 09:10:15 2019
+++ src/sys/dev/acpi/acpi_util.c	Fri Oct 23 10:59:37 2020
@@ -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 @@ out:
 }
 
 struct acpi_irq_handler {
-	ACPI_HANDLE aih_hdl;
 	uint32_t aih_irq;
 	void *aih_ih;
 };
@@ -563,8 +562,7 @@ acpi_intr_establish(device_t dev, uint64
 	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 @@ acpi_intr_establish(device_t dev, uint64
 	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;
 }
 

Reply via email to