git: f40cd4c85485 - stable/13 - intr_event(9): update the example of swi_add()

From: Mitchell Horne <mhorne_at_FreeBSD.org>
Date: Sun, 30 Oct 2022 14:15:51 UTC
The branch stable/13 has been updated by mhorne:

URL: https://cgit.FreeBSD.org/src/commit/?id=f40cd4c854856750457b85489afdb09f94b4896a

commit f40cd4c854856750457b85489afdb09f94b4896a
Author:     Mitchell Horne <mhorne@FreeBSD.org>
AuthorDate: 2022-10-15 18:34:44 +0000
Commit:     Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2022-10-30 14:14:17 +0000

    intr_event(9): update the example of swi_add()
    
    Reviewed by:    jhb
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D33476
    
    (cherry picked from commit 0cec1648b43e176b5b3f1be580bf11e41e79f835)
---
 share/man/man9/intr_event.9 | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/share/man/man9/intr_event.9 b/share/man/man9/intr_event.9
index b735da931f64..621a02e3967b 100644
--- a/share/man/man9/intr_event.9
+++ b/share/man/man9/intr_event.9
@@ -200,39 +200,40 @@ function returns a process priority corresponding to the passed in interrupt
 flags.
 .Sh EXAMPLES
 The
-.Fn swi_add
+.Xr swi_add 9
 function demonstrates the use of
 .Fn intr_event_create
 and
 .Fn intr_event_add_handler .
 .Bd -literal -offset indent
 int
-swi_add(struct ithd **ithdp, const char *name, driver_intr_t handler,
-	    void *arg, int pri, enum intr_type flags, void **cookiep)
+swi_add(struct intr_event **eventp, const char *name, driver_intr_t handler,
+    void *arg, int pri, enum intr_type flags, void **cookiep)
 {
-	struct proc *p;
-	struct ithd *ithd;
-	int error;
+	struct intr_event *ie;
+	int error = 0;
 
 	if (flags & INTR_ENTROPY)
 		return (EINVAL);
 
-	ithd = (ithdp != NULL) ? *ithdp : NULL;
+	ie = (eventp != NULL) ? *eventp : NULL;
 
-	if (ithd != NULL) {
-		if ((ithd->it_flags & IT_SOFT) == 0)
-			return(EINVAL);
+	if (ie != NULL) {
+		if (!(ie->ie_flags & IE_SOFT))
+			return (EINVAL);
 	} else {
-		error = ithread_create(&ithd, pri, IT_SOFT, NULL, NULL,
-		    "swi%d:", pri);
+		error = intr_event_create(&ie, NULL, IE_SOFT, 0,
+		    NULL, NULL, NULL, swi_assign_cpu, "swi%d:", pri);
 		if (error)
 			return (error);
-
-		if (ithdp != NULL)
-			*ithdp = ithd;
+		if (eventp != NULL)
+			*eventp = ie;
+	}
+	if (handler != NULL) {
+		error = intr_event_add_handler(ie, name, NULL, handler, arg,
+		    PI_SWI(pri), flags, cookiep);
 	}
-	return (ithread_add_handler(ithd, name, handler, arg, pri + PI_SOFT,
-		    flags, cookiep));
+	return (error);
 }
 .Ed
 .Sh ERRORS