Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Mar 2024 22:13:33 GMT
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: b30a80b65587 - main - rman: Add rman_get/set_type
Message-ID:  <202403132213.42DMDXdj074741@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by jhb:

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

commit b30a80b65587fb9fd4a5f012d606dbd0c6239a46
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

    rman: Add rman_get/set_type
    
    This permits associating a resource type (e.g. SYS_RES_MEMORY) with a
    struct resource.
    
    I considered adding a new field to struct rman to store the type and
    only providing rman_get_type as an accessor.  However, changing
    'struct rman' is an ABI breakage.  I might revisit this in main, but
    the current approach is MFC'able.
    
    Reviewed by:    imp
    Differential Revision:  https://reviews.freebsd.org/D44122
---
 share/man/man9/Makefile |  2 ++
 share/man/man9/rman.9   | 18 ++++++++++++++++--
 sys/kern/subr_rman.c    | 13 +++++++++++++
 sys/sys/rman.h          |  2 ++
 4 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/share/man/man9/Makefile b/share/man/man9/Makefile
index c98849b42a7b..d6732a4e15f7 100644
--- a/share/man/man9/Makefile
+++ b/share/man/man9/Makefile
@@ -1869,6 +1869,7 @@ MLINKS+=rman.9 rman_activate_resource.9 \
 	rman.9 rman_get_rid.9 \
 	rman.9 rman_get_size.9 \
 	rman.9 rman_get_start.9 \
+	rman.9 rman_get_type.9 \
 	rman.9 rman_get_virtual.9 \
 	rman.9 rman_init.9 \
 	rman.9 rman_init_from_resource.9 \
@@ -1883,6 +1884,7 @@ MLINKS+=rman.9 rman_activate_resource.9 \
 	rman.9 rman_set_bustag.9 \
 	rman.9 rman_set_mapping.9 \
 	rman.9 rman_set_rid.9 \
+	rman.9 rman_set_type.9 \
 	rman.9 rman_set_virtual.9
 MLINKS+=rmlock.9 rm_assert.9 \
 	rmlock.9 rm_destroy.9 \
diff --git a/share/man/man9/rman.9 b/share/man/man9/rman.9
index 095cd2760b8c..35a2d176233c 100644
--- a/share/man/man9/rman.9
+++ b/share/man/man9/rman.9
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 20, 2016
+.Dd March 13, 2024
 .Dt RMAN 9
 .Os
 .Sh NAME
@@ -56,7 +56,9 @@
 .Nm rman_set_bushandle ,
 .Nm rman_get_bushandle ,
 .Nm rman_set_rid ,
-.Nm rman_get_rid
+.Nm rman_get_rid ,
+.Nm rman_set_type ,
+.Nm rman_get_type
 .Nd resource management functions
 .Sh SYNOPSIS
 .In sys/types.h
@@ -125,6 +127,10 @@
 .Fn rman_set_rid "struct resource *r" "int rid"
 .Ft int
 .Fn rman_get_rid "struct resource *r"
+.Ft void
+.Fn rman_set_type "struct resource *r" "int type"
+.Ft int
+.Fn rman_get_type "struct resource *r"
 .Sh DESCRIPTION
 The
 .Nm
@@ -457,6 +463,14 @@ The
 function retrieves this RID.
 .Pp
 The
+.Fn rman_set_type
+function associates a resource type with a resource
+.Fa r .
+The
+.Fn rman_get_type
+function retrieves this type.
+.Pp
+The
 .Fn rman_get_device
 function returns a pointer to the device which reserved the resource
 .Fa r .
diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c
index 792d03726c74..1393781a66fe 100644
--- a/sys/kern/subr_rman.c
+++ b/sys/kern/subr_rman.c
@@ -91,6 +91,7 @@ struct resource_i {
 	device_t r_dev;	/* device which has allocated this resource */
 	struct rman *r_rm;	/* resource manager from whence this came */
 	int	r_rid;		/* optional rid for this resource. */
+	int	r_type;		/* optional type for this resource. */
 };
 
 static int rman_debug = 0;
@@ -927,6 +928,18 @@ rman_get_rid(struct resource *r)
 	return (r->__r_i->r_rid);
 }
 
+void
+rman_set_type(struct resource *r, int type)
+{
+	r->__r_i->r_type = type;
+}
+
+int
+rman_get_type(struct resource *r)
+{
+	return (r->__r_i->r_type);
+}
+
 void
 rman_set_device(struct resource *r, device_t dev)
 {
diff --git a/sys/sys/rman.h b/sys/sys/rman.h
index 9e8e3b878c5a..b8b2016cc94a 100644
--- a/sys/sys/rman.h
+++ b/sys/sys/rman.h
@@ -134,6 +134,7 @@ 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 *);
 int	rman_deactivate_resource(struct resource *r);
 int	rman_fini(struct rman *rm);
@@ -156,6 +157,7 @@ void	rman_set_device(struct resource *_r, device_t _dev);
 void	rman_set_irq_cookie(struct resource *_r, void *_c);
 void	rman_set_mapping(struct resource *, struct resource_map *);
 void	rman_set_rid(struct resource *_r, int _rid);
+void	rman_set_type(struct resource *_r, int _type);
 void	rman_set_virtual(struct resource *_r, void *_v);
 
 extern	struct rman_head rman_head;



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