git: ecf2106c0701 - main - arm64/amd64/riscv nexus: Use bus_generic_rl_*

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 22 Nov 2023 17:06:47 UTC
The branch main has been updated by jhb:

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

commit ecf2106c0701e522b8c643f8ea37550b3e58ba57
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2023-11-22 17:06:33 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2023-11-22 17:06:33 +0000

    arm64/amd64/riscv nexus: Use bus_generic_rl_*
    
    Reviewed by:    mhorne, imp
    Differential Revision:  https://reviews.freebsd.org/D42716
---
 sys/arm64/arm64/nexus.c | 16 +---------------
 sys/riscv/riscv/nexus.c | 18 +++---------------
 sys/x86/x86/nexus.c     | 48 +++---------------------------------------------
 3 files changed, 7 insertions(+), 75 deletions(-)

diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
index 6ba73cd456ef..dee86bce656a 100644
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -112,7 +112,6 @@ static bus_deactivate_resource_t nexus_deactivate_resource;
 static bus_get_resource_list_t	nexus_get_reslist;
 static bus_map_resource_t	nexus_map_resource;
 static bus_release_resource_t	nexus_release_resource;
-static bus_set_resource_t	nexus_set_resource;
 
 #ifdef SMP
 static bus_bind_intr_t		nexus_bind_intr;
@@ -141,7 +140,7 @@ static device_method_t nexus_methods[] = {
 	DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
 	DEVMETHOD(bus_map_resource,	nexus_map_resource),
 	DEVMETHOD(bus_release_resource,	nexus_release_resource),
-	DEVMETHOD(bus_set_resource,	nexus_set_resource),
+	DEVMETHOD(bus_set_resource,	bus_generic_rl_set_resource),
 #ifdef SMP
 	DEVMETHOD(bus_bind_intr,	nexus_bind_intr),
 #endif
@@ -435,19 +434,6 @@ nexus_get_reslist(device_t dev, device_t child)
 	return (&ndev->nx_resources);
 }
 
-static int
-nexus_set_resource(device_t dev, device_t child, int type, int rid,
-    rman_res_t start, rman_res_t count)
-{
-	struct nexus_device	*ndev = DEVTONX(child);
-	struct resource_list	*rl = &ndev->nx_resources;
-
-	/* XXX this should return a success/failure indicator */
-	resource_list_add(rl, type, rid, start, start + count - 1, count);
-
-	return (0);
-}
-
 static int
 nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
     struct resource *r)
diff --git a/sys/riscv/riscv/nexus.c b/sys/riscv/riscv/nexus.c
index 48878807bb7e..2e693e6cf655 100644
--- a/sys/riscv/riscv/nexus.c
+++ b/sys/riscv/riscv/nexus.c
@@ -86,7 +86,6 @@ static bus_alloc_resource_t	nexus_alloc_resource;
 static bus_deactivate_resource_t nexus_deactivate_resource;
 static bus_get_resource_list_t	nexus_get_reslist;
 static bus_map_resource_t	nexus_map_resource;
-static bus_set_resource_t	nexus_set_resource;
 static bus_release_resource_t	nexus_release_resource;
 
 static bus_config_intr_t	nexus_config_intr;
@@ -113,9 +112,11 @@ static device_method_t nexus_methods[] = {
 	DEVMETHOD(bus_adjust_resource,	nexus_adjust_resource),
 	DEVMETHOD(bus_alloc_resource,	nexus_alloc_resource),
 	DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
+	DEVMETHOD(bus_delete_resource,	bus_generic_rl_delete_resource),
+	DEVMETHOD(bus_get_resource,	bus_generic_rl_get_resource),
 	DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
 	DEVMETHOD(bus_map_resource,	nexus_map_resource),
-	DEVMETHOD(bus_set_resource,	nexus_set_resource),
+	DEVMETHOD(bus_set_resource,	bus_generic_rl_set_resource),
 	DEVMETHOD(bus_release_resource,	nexus_release_resource),
 	DEVMETHOD(bus_config_intr,	nexus_config_intr),
 	DEVMETHOD(bus_describe_intr,	nexus_describe_intr),
@@ -395,19 +396,6 @@ nexus_get_reslist(device_t dev, device_t child)
 	return (&ndev->nx_resources);
 }
 
-static int
-nexus_set_resource(device_t dev, device_t child, int type, int rid,
-    rman_res_t start, rman_res_t count)
-{
-	struct nexus_device	*ndev = DEVTONX(child);
-	struct resource_list	*rl = &ndev->nx_resources;
-
-	/* XXX this should return a success/failure indicator */
-	resource_list_add(rl, type, rid, start, start + count - 1, count);
-
-	return (0);
-}
-
 static int
 nexus_deactivate_resource(device_t bus, device_t child, int type, int rid,
     struct resource *r)
diff --git a/sys/x86/x86/nexus.c b/sys/x86/x86/nexus.c
index c90a8d252845..4896271b92bd 100644
--- a/sys/x86/x86/nexus.c
+++ b/sys/x86/x86/nexus.c
@@ -101,12 +101,9 @@ static bus_activate_resource_t	nexus_activate_resource;
 static bus_adjust_resource_t	nexus_adjust_resource;
 static bus_alloc_resource_t	nexus_alloc_resource;
 static bus_deactivate_resource_t nexus_deactivate_resource;
-static bus_delete_resource_t	nexus_delete_resource;
-static bus_get_resource_t	nexus_get_resource;
 static bus_get_resource_list_t	nexus_get_reslist;
 static bus_map_resource_t	nexus_map_resource;
 static bus_release_resource_t	nexus_release_resource;
-static bus_set_resource_t	nexus_set_resource;
 static bus_unmap_resource_t	nexus_unmap_resource;
 
 #ifdef SMP
@@ -145,12 +142,12 @@ static device_method_t nexus_methods[] = {
 	DEVMETHOD(bus_adjust_resource,	nexus_adjust_resource),
 	DEVMETHOD(bus_alloc_resource,	nexus_alloc_resource),
 	DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
-	DEVMETHOD(bus_get_resource,	nexus_get_resource),
+	DEVMETHOD(bus_get_resource,	bus_generic_rl_get_resource),
 	DEVMETHOD(bus_get_resource_list, nexus_get_reslist),
-	DEVMETHOD(bus_delete_resource,	nexus_delete_resource),
+	DEVMETHOD(bus_delete_resource,	bus_generic_rl_delete_resource),
 	DEVMETHOD(bus_map_resource,	nexus_map_resource),
 	DEVMETHOD(bus_release_resource,	nexus_release_resource),
-	DEVMETHOD(bus_set_resource,	nexus_set_resource),
+	DEVMETHOD(bus_set_resource,	bus_generic_rl_set_resource),
 	DEVMETHOD(bus_unmap_resource,	nexus_unmap_resource),
 #ifdef SMP
 	DEVMETHOD(bus_bind_intr,	nexus_bind_intr),
@@ -645,45 +642,6 @@ nexus_get_reslist(device_t dev, device_t child)
 	return (&ndev->nx_resources);
 }
 
-static int
-nexus_set_resource(device_t dev, device_t child, int type, int rid,
-    rman_res_t start, rman_res_t count)
-{
-	struct nexus_device	*ndev = DEVTONX(child);
-	struct resource_list	*rl = &ndev->nx_resources;
-
-	/* XXX this should return a success/failure indicator */
-	resource_list_add(rl, type, rid, start, start + count - 1, count);
-	return (0);
-}
-
-static int
-nexus_get_resource(device_t dev, device_t child, int type, int rid,
-    rman_res_t *startp, rman_res_t *countp)
-{
-	struct nexus_device	*ndev = DEVTONX(child);
-	struct resource_list	*rl = &ndev->nx_resources;
-	struct resource_list_entry *rle;
-
-	rle = resource_list_find(rl, type, rid);
-	if (!rle)
-		return (ENOENT);
-	if (startp)
-		*startp = rle->start;
-	if (countp)
-		*countp = rle->count;
-	return (0);
-}
-
-static void
-nexus_delete_resource(device_t dev, device_t child, int type, int rid)
-{
-	struct nexus_device	*ndev = DEVTONX(child);
-	struct resource_list	*rl = &ndev->nx_resources;
-
-	resource_list_delete(rl, type, rid);
-}
-
 static int
 nexus_get_cpus(device_t dev, device_t child, enum cpu_sets op, size_t setsize,
     cpuset_t *cpuset)