Andrew Lunn | 5beef3c | 2009-11-09 21:20:10 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: |
| 3 | * |
| 4 | * Marek Lindner, Simon Wunderlich |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of version 2 of the GNU General Public |
| 8 | * License as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, but |
| 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| 18 | * 02110-1301, USA |
| 19 | * |
| 20 | * |
| 21 | * This file contains macros for maintaining compatibility with older versions |
| 22 | * of the Linux kernel. |
| 23 | */ |
| 24 | |
| 25 | #include <linux/version.h> /* LINUX_VERSION_CODE */ |
| 26 | |
| 27 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) |
| 28 | |
| 29 | #define skb_set_network_header(_skb, _offset) \ |
| 30 | do { (_skb)->nh.raw = (_skb)->data + (_offset); } while (0) |
| 31 | |
| 32 | #define skb_reset_mac_header(_skb) \ |
| 33 | do { (_skb)->mac.raw = (_skb)->data; } while (0) |
| 34 | |
| 35 | #define list_first_entry(ptr, type, member) \ |
| 36 | list_entry((ptr)->next, type, member) |
| 37 | |
| 38 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) */ |
| 39 | |
| 40 | |
| 41 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) |
| 42 | |
| 43 | #define device_create(_cls, _parent, _devt, _device, _fmt) \ |
| 44 | class_device_create(_cls, _parent, _devt, _device, _fmt) |
| 45 | |
| 46 | #define device_destroy(_cls, _device) \ |
| 47 | class_device_destroy(_cls, _device) |
| 48 | |
| 49 | #else |
| 50 | |
| 51 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) |
| 52 | |
| 53 | #define device_create(_cls, _parent, _devt, _device, _fmt) \ |
| 54 | device_create_drvdata(_cls, _parent, _devt, _device, _fmt) |
| 55 | |
| 56 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) */ |
| 57 | |
| 58 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) */ |
| 59 | |
| 60 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) |
| 61 | |
| 62 | #define cancel_delayed_work_sync(wq) cancel_rearming_delayed_work(wq) |
| 63 | |
| 64 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 23) */ |
| 65 | #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) |
| 66 | #define strict_strtoul(cp, base, res) \ |
| 67 | ({ \ |
| 68 | int ret = 0; \ |
| 69 | char *endp; \ |
| 70 | *res = simple_strtoul(cp, &endp, base); \ |
| 71 | if (cp == endp) \ |
| 72 | ret = -EINVAL; \ |
| 73 | ret; \ |
| 74 | }) |
| 75 | #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25) */ |