Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Jul 2020 12:07:28 +0000 (UTC)
From:      Andrew Turner <andrew@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r362834 - head/sys/kern
Message-ID:  <202007011207.061C7SIW066006@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: andrew
Date: Wed Jul  1 12:07:28 2020
New Revision: 362834
URL: https://svnweb.freebsd.org/changeset/base/362834

Log:
  Simplify the flow when getting/setting an isrc
  
  Rather than unlocking and returning we can just perform the needed action
  only when the interrupt source is valid and reuse the unlock in both the
  valid irq and invalid irq cases.
  
  Sponsored by:	Innovate UK

Modified:
  head/sys/kern/subr_intr.c

Modified: head/sys/kern/subr_intr.c
==============================================================================
--- head/sys/kern/subr_intr.c	Wed Jul  1 10:37:08 2020	(r362833)
+++ head/sys/kern/subr_intr.c	Wed Jul  1 12:07:28 2020	(r362834)
@@ -1517,13 +1517,12 @@ intr_map_get_isrc(u_int res_id)
 {
 	struct intr_irqsrc *isrc;
 
+	isrc = NULL;
 	mtx_lock(&irq_map_lock);
-	if ((res_id >= irq_map_count) || (irq_map[res_id] == NULL)) {
-		mtx_unlock(&irq_map_lock);
-		return (NULL);
-	}
-	isrc = irq_map[res_id]->isrc;
+	if (res_id < irq_map_count && irq_map[res_id] != NULL)
+		isrc = irq_map[res_id]->isrc;
 	mtx_unlock(&irq_map_lock);
+
 	return (isrc);
 }
 
@@ -1532,11 +1531,8 @@ intr_map_set_isrc(u_int res_id, struct intr_irqsrc *is
 {
 
 	mtx_lock(&irq_map_lock);
-	if ((res_id >= irq_map_count) || (irq_map[res_id] == NULL)) {
-		mtx_unlock(&irq_map_lock);
-		return;
-	}
-	irq_map[res_id]->isrc = isrc;
+	if (res_id < irq_map_count && irq_map[res_id] != NULL)
+		irq_map[res_id]->isrc = isrc;
 	mtx_unlock(&irq_map_lock);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202007011207.061C7SIW066006>