summaryrefslogtreecommitdiffstats
path: root/cpukit/libdrvmgr/drvmgr_translate_check.c
blob: c882b88f27ceb158bd8c305d6d9b83075b083845 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* Driver Manager Driver Translate Interface Implementation
 *
 * COPYRIGHT (c) 2010.
 * Cobham Gaisler AB.
 *
 * The license and distribution terms for this file may be
 * found in the file LICENSE in this distribution or at
 * http://www.rtems.com/license/LICENSE.
 */

#include <drvmgr/drvmgr.h>

/* Calls drvmgr_translate() to translate an address range and check the result,
 * a printout is generated if the check fails. See paramters of
 * drvmgr_translate().
 * If size=0 only the starting address is not checked.
 */
int drvmgr_translate_check(
	struct drvmgr_dev *dev,
	unsigned int options,
	void *src_address,
	void **dst_address,
	unsigned int size)
{
	unsigned int max;

	max = drvmgr_translate(dev, options, src_address, dst_address);
	if (max == 0 || (max < size && (size != 0))) {
		printk(" ### dev %p (%s) failed mapping %p\n",
			dev, dev->name ? dev->name : "unnamed", src_address);
		return -1;
	}

	return 0;
}