From cdf7c848cfd89e3130426dc7003fce04ba330692 Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Tue, 12 Apr 2005 04:22:17 +0000 Subject: [PATCH] Return the resource created/found in resource_list_add to avoid an extra resouce_list_find in some places. Suggested by: sam Found by: Coventry Analysis tool. --- sys/kern/subr_bus.c | 5 +++-- sys/sys/bus.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index 438209fde3d9..c08d66b6f64f 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -2562,7 +2562,7 @@ resource_list_add_next(struct resource_list *rl, int type, u_long start, * If an existing entry exists with the same type and rid, it will be * modified using the given values of @p start, @p end and @p * count. If no entry exists, a new one will be created using the - * given values. + * given values. The resource list entry that matches is then returned. * * @param rl the resource list to edit * @param type the resource entry type (e.g. SYS_RES_MEMORY) @@ -2571,7 +2571,7 @@ resource_list_add_next(struct resource_list *rl, int type, u_long start, * @param end the end address of the resource * @param count XXX end-start+1 */ -void +struct resource_list_entry * resource_list_add(struct resource_list *rl, int type, int rid, u_long start, u_long end, u_long count) { @@ -2595,6 +2595,7 @@ resource_list_add(struct resource_list *rl, int type, int rid, rle->start = start; rle->end = end; rle->count = count; + return (rle); } /** diff --git a/sys/sys/bus.h b/sys/sys/bus.h index 99c867056bcc..6a54a728fc87 100644 --- a/sys/sys/bus.h +++ b/sys/sys/bus.h @@ -206,7 +206,8 @@ STAILQ_HEAD(resource_list, resource_list_entry); void resource_list_init(struct resource_list *rl); void resource_list_free(struct resource_list *rl); -void resource_list_add(struct resource_list *rl, +struct resource_list_entry * + resource_list_add(struct resource_list *rl, int type, int rid, u_long start, u_long end, u_long count); int resource_list_add_next(struct resource_list *rl,