git: 3351964c5e5d - main - bhnd: Use rman_get_type in bhndb_find_resource_limits

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 13 Mar 2024 22:13:37 UTC
The branch main has been updated by jhb:

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

commit 3351964c5e5d29ef93b3f26b7fc31a4972aa9af7
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2024-03-13 22:05:53 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2024-03-13 22:05:53 +0000

    bhnd: Use rman_get_type in bhndb_find_resource_limits
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D44126
---
 sys/dev/bhnd/bhndb/bhndb.c         | 2 +-
 sys/dev/bhnd/bhndb/bhndb_private.h | 2 +-
 sys/dev/bhnd/bhndb/bhndb_subr.c    | 8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/sys/dev/bhnd/bhndb/bhndb.c b/sys/dev/bhnd/bhndb/bhndb.c
index 978ad9c3e62b..ea5230bf459b 100644
--- a/sys/dev/bhnd/bhndb/bhndb.c
+++ b/sys/dev/bhnd/bhndb/bhndb.c
@@ -1113,7 +1113,7 @@ bhndb_adjust_resource(device_t dev, device_t child, int type,
 		goto done;
 
 	/* Otherwise, the range is limited by the bridged resource mapping */
-	error = bhndb_find_resource_limits(sc->bus_res, type, r, &mstart,
+	error = bhndb_find_resource_limits(sc->bus_res, r, &mstart,
 	    &mend);
 	if (error)
 		goto done;
diff --git a/sys/dev/bhnd/bhndb/bhndb_private.h b/sys/dev/bhnd/bhndb/bhndb_private.h
index 851cbe82d3a7..7b56f0b05c84 100644
--- a/sys/dev/bhnd/bhndb/bhndb_private.h
+++ b/sys/dev/bhnd/bhndb/bhndb_private.h
@@ -73,7 +73,7 @@ int				 bhndb_add_resource_region(
 				     const struct bhndb_regwin *static_regwin);
 
 int				 bhndb_find_resource_limits(
-				     struct bhndb_resources *br, int type,
+				     struct bhndb_resources *br,
 				     struct resource *r, rman_res_t *start,
 				     rman_res_t *end);
 
diff --git a/sys/dev/bhnd/bhndb/bhndb_subr.c b/sys/dev/bhnd/bhndb/bhndb_subr.c
index f5253b3ecaca..df8f39048201 100644
--- a/sys/dev/bhnd/bhndb/bhndb_subr.c
+++ b/sys/dev/bhnd/bhndb/bhndb_subr.c
@@ -987,7 +987,6 @@ bhndb_find_intr_handler(struct bhndb_resources *br, void *cookiep)
  * returned.
  * 
  * @param	br		The resource state to search.
- * @param	type The resource type (see SYS_RES_*).
  * @param	r The resource to search for in @p br.
  * @param[out]	start	On success, the minimum supported start address.
  * @param[out]	end	On success, the maximum supported end address.
@@ -996,14 +995,14 @@ bhndb_find_intr_handler(struct bhndb_resources *br, void *cookiep)
  * @retval ENOENT	no active mapping found for @p r of @p type
  */
 int
-bhndb_find_resource_limits(struct bhndb_resources *br, int type,
+bhndb_find_resource_limits(struct bhndb_resources *br,
     struct resource *r, rman_res_t *start, rman_res_t *end)
 {
 	struct bhndb_dw_alloc		*dynamic;
 	struct bhndb_region		*sregion;
 	struct bhndb_intr_handler	*ih;
 
-	switch (type) {
+	switch (rman_get_type(r)) {
 	case SYS_RES_IRQ:
 		/* Is this one of ours? */
 		STAILQ_FOREACH(ih, &br->bus_intrs, ih_link) {
@@ -1042,7 +1041,8 @@ bhndb_find_resource_limits(struct bhndb_resources *br, int type,
 	}
 
 	default:
-		device_printf(br->dev, "unknown resource type: %d\n", type);
+		device_printf(br->dev, "unknown resource type: %d\n",
+		    rman_get_type(r));
 		return (ENOENT);
 	}
 }