xref: /freebsd/sys/contrib/openzfs/include/os/linux/kernel/linux/kmap_compat.h (revision 61145dc2b94f12f6a47344fb9aac702321880e43)
1 // SPDX-License-Identifier: CDDL-1.0
2 /*
3  * CDDL HEADER START
4  *
5  * The contents of this file are subject to the terms of the
6  * Common Development and Distribution License (the "License").
7  * You may not use this file except in compliance with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or https://opensource.org/licenses/CDDL-1.0.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 
23 /*
24  * Copyright (c) 2015 by Chunwei Chen. All rights reserved.
25  */
26 
27 #ifndef _ZFS_KMAP_H
28 #define	_ZFS_KMAP_H
29 
30 #include <linux/highmem.h>
31 #include <linux/uaccess.h>
32 
33 #ifdef HAVE_KMAP_LOCAL_PAGE
34 /* 5.11 API change */
35 #define	zfs_kmap_local(page)   kmap_local_page(page)
36 #define	zfs_kunmap_local(addr) kunmap_local(addr)
37 #else
38 /* 2.6.37 API change */
39 #define	zfs_kmap_local(page)   kmap_atomic(page)
40 #define	zfs_kunmap_local(addr) kunmap_atomic(addr)
41 #endif
42 #define	zfs_kmap(page)		kmap(page)
43 #define	zfs_kunmap(page)	kunmap(page)
44 
45 /* 5.0 API change - no more 'type' argument for access_ok() */
46 #ifdef HAVE_ACCESS_OK_TYPE
47 #define	zfs_access_ok(type, addr, size)	access_ok(type, addr, size)
48 #else
49 #define	zfs_access_ok(type, addr, size)	access_ok(addr, size)
50 #endif
51 
52 #endif	/* _ZFS_KMAP_H */
53