git: cbcb9778dd95 - main - kern/rman: mark rman get functions as taking constants

From: Warner Losh <imp_at_FreeBSD.org>
Date: Tue, 21 May 2024 23:56:24 UTC
The branch main has been updated by imp:

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

commit cbcb9778dd957adf28fac011c6d7b511ca80c469
Author:     Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2024-05-10 16:13:39 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2024-05-21 23:52:29 +0000

    kern/rman: mark rman get functions as taking constants
    
    The arguments are left completely unchanged by these functions.  This
    allows passing constant pointers for verifying ownership, but not
    modifying the contents.
    
    Reviewed by: imp,jhb
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1224
---
 sys/kern/subr_rman.c | 26 +++++++++++++-------------
 sys/sys/rman.h       | 26 +++++++++++++-------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index 508152f74002..dbb09850d049 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -787,28 +787,28 @@ rman_make_alignment_flags(uint32_t size)
 }
 
 rman_res_t
-rman_get_start(struct resource *r)
+rman_get_start(const struct resource *r)
 {
 
 	return (r->__r_i->r_start);
 }
 
 rman_res_t
-rman_get_end(struct resource *r)
+rman_get_end(const struct resource *r)
 {
 
 	return (r->__r_i->r_end);
 }
 
 rman_res_t
-rman_get_size(struct resource *r)
+rman_get_size(const struct resource *r)
 {
 
 	return (r->__r_i->r_end - r->__r_i->r_start + 1);
 }
 
 u_int
-rman_get_flags(struct resource *r)
+rman_get_flags(const struct resource *r)
 {
 
 	return (r->__r_i->r_flags);
@@ -822,7 +822,7 @@ rman_set_virtual(struct resource *r, void *v)
 }
 
 void *
-rman_get_virtual(struct resource *r)
+rman_get_virtual(const struct resource *r)
 {
 
 	return (r->__r_i->r_virtual);
@@ -836,7 +836,7 @@ rman_set_irq_cookie(struct resource *r, void *c)
 }
 
 void *
-rman_get_irq_cookie(struct resource *r)
+rman_get_irq_cookie(const struct resource *r)
 {
 
 	return (r->__r_i->r_irq_cookie);
@@ -850,7 +850,7 @@ rman_set_bustag(struct resource *r, bus_space_tag_t t)
 }
 
 bus_space_tag_t
-rman_get_bustag(struct resource *r)
+rman_get_bustag(const struct resource *r)
 {
 
 	return (r->r_bustag);
@@ -864,7 +864,7 @@ rman_set_bushandle(struct resource *r, bus_space_handle_t h)
 }
 
 bus_space_handle_t
-rman_get_bushandle(struct resource *r)
+rman_get_bushandle(const struct resource *r)
 {
 
 	return (r->r_bushandle);
@@ -882,7 +882,7 @@ rman_set_mapping(struct resource *r, struct resource_map *map)
 }
 
 void
-rman_get_mapping(struct resource *r, struct resource_map *map)
+rman_get_mapping(const struct resource *r, struct resource_map *map)
 {
 
 	map->r_bustag = rman_get_bustag(r);
@@ -899,7 +899,7 @@ rman_set_rid(struct resource *r, int rid)
 }
 
 int
-rman_get_rid(struct resource *r)
+rman_get_rid(const struct resource *r)
 {
 
 	return (r->__r_i->r_rid);
@@ -912,7 +912,7 @@ rman_set_type(struct resource *r, int type)
 }
 
 int
-rman_get_type(struct resource *r)
+rman_get_type(const struct resource *r)
 {
 	return (r->__r_i->r_type);
 }
@@ -925,14 +925,14 @@ rman_set_device(struct resource *r, device_t dev)
 }
 
 device_t
-rman_get_device(struct resource *r)
+rman_get_device(const struct resource *r)
 {
 
 	return (r->__r_i->r_dev);
 }
 
 int
-rman_is_region_manager(struct resource *r, struct rman *rm)
+rman_is_region_manager(const struct resource *r, const struct rman *rm)
 {
 
 	return (r->__r_i->r_rm == rm);
diff --git a/sys/sys/rman.h b/sys/sys/rman.h
index 70655339183b..323da4a62201 100644
--- a/sys/sys/rman.h
+++ b/sys/sys/rman.h
@@ -124,18 +124,18 @@ TAILQ_HEAD(rman_head, rman);
 int	rman_activate_resource(struct resource *r);
 int	rman_adjust_resource(struct resource *r, rman_res_t start, rman_res_t end);
 int	rman_first_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);
-bus_space_handle_t rman_get_bushandle(struct resource *);
-bus_space_tag_t rman_get_bustag(struct resource *);
-rman_res_t	rman_get_end(struct resource *);
-device_t rman_get_device(struct resource *);
-u_int	rman_get_flags(struct resource *);
-void   *rman_get_irq_cookie(struct resource *);
-void	rman_get_mapping(struct resource *, struct resource_map *);
-int	rman_get_rid(struct resource *);
-rman_res_t	rman_get_size(struct resource *);
-rman_res_t	rman_get_start(struct resource *);
-int	rman_get_type(struct resource *);
-void   *rman_get_virtual(struct resource *);
+bus_space_handle_t rman_get_bushandle(const struct resource *);
+bus_space_tag_t rman_get_bustag(const struct resource *);
+rman_res_t	rman_get_end(const struct resource *);
+device_t rman_get_device(const struct resource *);
+u_int	rman_get_flags(const struct resource *);
+void   *rman_get_irq_cookie(const struct resource *);
+void	rman_get_mapping(const struct resource *, struct resource_map *);
+int	rman_get_rid(const struct resource *);
+rman_res_t	rman_get_size(const struct resource *);
+rman_res_t	rman_get_start(const struct resource *);
+int	rman_get_type(const struct resource *);
+void   *rman_get_virtual(const struct resource *);
 int	rman_deactivate_resource(struct resource *r);
 int	rman_fini(struct rman *rm);
 int	rman_init(struct rman *rm);
@@ -143,7 +143,7 @@ int	rman_init_from_resource(struct rman *rm, struct resource *r);
 int	rman_last_free_region(struct rman *rm, rman_res_t *start, rman_res_t *end);
 uint32_t rman_make_alignment_flags(uint32_t size);
 int	rman_manage_region(struct rman *rm, rman_res_t start, rman_res_t end);
-int	rman_is_region_manager(struct resource *r, struct rman *rm);
+int	rman_is_region_manager(const struct resource *r, const struct rman *rm);
 int	rman_release_resource(struct resource *r);
 struct resource *rman_reserve_resource(struct rman *rm, rman_res_t start,
 					rman_res_t end, rman_res_t count,