aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/bus_if.m
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2021-11-15 16:29:49 +0000
committerMark Johnston <markj@FreeBSD.org>2021-11-15 18:01:30 +0000
commit1fb99e97e959a51306fd216a41977079d4689665 (patch)
tree2fc05bbf465ae5c09ae1ce89936dfecc1d40757f /sys/kern/bus_if.m
parent728f2c61312aaf550f0a761bdbcdcbd4977e23f0 (diff)
downloadsrc-1fb99e97e959a51306fd216a41977079d4689665.tar.gz
src-1fb99e97e959a51306fd216a41977079d4689665.zip
bus: Make BUS_TRANSLATE_RESOURCE behave more like other bus methods
- Return an errno value upon failure, instead of 1. - Provide a bus_translate_resource() wrapper. - Implement the generic version, which traverses the hierarchy until a bus driver with a non-trivial implementation is found, in subr_bus.c like other similar default implementations. - Make ofw_pcib_translate_resource() return an error if a matching PCI address range is not found. - Make generic_pcie_translate_resource_common() return an int instead of a bool. Fix up callers. No functional change intended. Reviewed by: imp, jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32855
Diffstat (limited to 'sys/kern/bus_if.m')
-rw-r--r--sys/kern/bus_if.m18
1 files changed, 4 insertions, 14 deletions
diff --git a/sys/kern/bus_if.m b/sys/kern/bus_if.m
index 0bd7056019ab..0f673c983d08 100644
--- a/sys/kern/bus_if.m
+++ b/sys/kern/bus_if.m
@@ -77,18 +77,6 @@ CODE {
return (0);
}
- static int
- null_translate_resource(device_t bus, int type, rman_res_t start,
- rman_res_t *newstart)
- {
- if (device_get_parent(bus) != NULL)
- return (BUS_TRANSLATE_RESOURCE(device_get_parent(bus),
- type, start, newstart));
-
- *newstart = start;
- return (0);
- }
-
static ssize_t
null_get_property(device_t dev, device_t child, const char *propname,
void *propvalue, size_t size)
@@ -425,10 +413,12 @@ METHOD int adjust_resource {
rman_res_t _end;
};
-
/**
* @brief translate a resource value
*
+ * Give a bus driver the opportunity to translate resource ranges. If
+ * successful, the host's view of the resource starting at @p _start is
+ * returned in @p _newstart, otherwise an error is returned.
*
* @param _dev the device associated with the resource
* @param _type the type of resource
@@ -440,7 +430,7 @@ METHOD int translate_resource {
int _type;
rman_res_t _start;
rman_res_t *_newstart;
-} DEFAULT null_translate_resource;
+} DEFAULT bus_generic_translate_resource;
/**
* @brief Release a resource