author | Florian Pose <fp@igh-essen.com> |
Fri, 25 Apr 2014 16:42:36 +0200 | |
branch | stable-1.5 |
changeset 2556 | 674fcdccc0f3 |
parent 2552 | 6e419c23b1b3 |
permissions | -rw-r--r-- |
2552
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
1 |
/** |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
2 |
Network Driver for Beckhoff CCAT communication controller |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
3 |
Copyright (C) 2014 Beckhoff Automation GmbH |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
4 |
Author: Patrick Bruenn <p.bruenn@beckhoff.com> |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
5 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
6 |
This program is free software; you can redistribute it and/or modify |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
7 |
it under the terms of the GNU General Public License as published by |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
8 |
the Free Software Foundation; either version 2 of the License, or |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
9 |
(at your option) any later version. |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
10 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
11 |
This program is distributed in the hope that it will be useful, |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
14 |
GNU General Public License for more details. |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
15 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
16 |
You should have received a copy of the GNU General Public License along |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
17 |
with this program; if not, write to the Free Software Foundation, Inc., |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
18 |
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
19 |
*/ |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
20 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
21 |
#ifndef _CCAT_COMPAT_H_ |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
22 |
#define _CCAT_COMPAT_H_ |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
23 |
#include <linux/dma-mapping.h> |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
24 |
#include <linux/sched.h> |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
25 |
#include <linux/version.h> |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
26 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
27 |
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 32) |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
28 |
#define pr_warn pr_info |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
29 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
30 |
#define netdev_info(DEV, ...) pr_info(__VA_ARGS__) |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
31 |
#define netdev_err netdev_info |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
32 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
33 |
static inline void *dma_zalloc_coherent(struct device *dev, size_t size, |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
34 |
dma_addr_t * dma_handle, gfp_t flag) |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
35 |
{ |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
36 |
void *result = |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
37 |
dma_alloc_coherent(dev, size, dma_handle, flag | __GFP_ZERO); |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
38 |
if (result) |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
39 |
memset(result, 0, size); |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
40 |
return result; |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
41 |
} |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
42 |
|
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
43 |
static inline void usleep_range(unsigned long min, unsigned long max) |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
44 |
{ |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
45 |
msleep(min / 1000); |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
46 |
} |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
47 |
#endif |
6e419c23b1b3
added ccat support for kernel 2.6.32
Patrick Bruenn <p.bruenn@beckhoff.com>
parents:
diff
changeset
|
48 |
#endif /* #ifndef _CCAT_COMPAT_H_ */ |