Add bus_alloc_resource_any(9), which does bus_alloc_resource() with the

appropriate default values.  Document it in the manpage.

Submitted by:	Mark Santcroos <marks@ripe.net>
Reviewed by:	imp, dfr, bde
Abstains:	bde
This commit is contained in:
Nate Lawson 2004-03-17 17:40:34 +00:00
parent 03886b3681
commit bdffb39f34
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=127133
3 changed files with 27 additions and 4 deletions

View file

@ -344,6 +344,7 @@ MLINKS+=atomic.9 atomic_add.9 \
atomic.9 atomic_subtract.9
MLINKS+=buf.9 bp.9
MLINKS+=bus_activate_resource.9 bus_deactivate_resource.9
MLINKS+=bus_alloc_resource.9 bus_alloc_resource_any.9
MLINKS+=bus_dma.9 busdma.9 \
bus_dma.9 bus_dmamap_create.9 \
bus_dma.9 bus_dmamap_destroy.9 \

View file

@ -32,7 +32,8 @@
.Dt BUS_ALLOC_RESOURCE 9
.Os
.Sh NAME
.Nm bus_alloc_resource
.Nm bus_alloc_resource ,
.Nm bus_alloc_resource_any
.Nd allocate resources from a parent bus
.Sh SYNOPSIS
.In sys/param.h
@ -43,13 +44,28 @@
.In machine/resource.h
.Ft struct resource *
.Fn bus_alloc_resource "device_t dev" "int type" "int *rid" "u_long start" "u_long end" "u_long count" "u_int flags"
.Ft struct resource *
.Fn bus_alloc_resource_any "device_t dev" "int type" "int *rid" "u_int flags"
.Sh DESCRIPTION
This is an easy interface to the resource-management functions.
It hides the indirection through the parent's method table.
This function generally should be called in attach, but (except in some
rare cases) never earlier.
.Pp
Its arguments are as follows:
The
.Fn bus_alloc_resource_any
function is a convenience wrapper for
.Fn bus_alloc_resource .
It sets the values for
.Fa start ,
.Fa end ,
and
.Fa count
to the default resource (see description of
.Fa start
below).
.Pp
The arguments are as follows:
.Bl -item
.It
.Fa dev
@ -150,8 +166,8 @@ should be saved in the softc of the device after these calls.
irqid = 0;
portres = bus_alloc_resource(dev, SYS_RES_IOPORT, &portid,
0ul, ~0ul, 32, RF_ACTIVE);
irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &irqid,
0ul, ~0ul, 1, RF_ACTIVE | RF_SHAREABLE);
irqres = bus_alloc_resource_any(dev, SYS_RES_IRQ, &irqid,
RF_ACTIVE | RF_SHAREABLE);
.Ed
.Sh SEE ALSO
.Xr bus_activate_resource 9 ,

View file

@ -309,6 +309,12 @@ int bus_child_present(device_t child);
int bus_child_pnpinfo_str(device_t child, char *buf, size_t buflen);
int bus_child_location_str(device_t child, char *buf, size_t buflen);
static __inline struct resource *
bus_alloc_resource_any(device_t dev, int type, int *rid, u_int flags)
{
return (bus_alloc_resource(dev, type, rid, 0ul, ~0ul, 1, flags));
}
/*
* Access functions for device.
*/