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