1 /******************************************************************************
3 * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 ******************************************************************************/
15 #define _OSDEP_SERVICE_C_
17 #include <osdep_service.h>
18 #include <osdep_intf.h>
19 #include <drv_types.h>
20 #include <recv_osdep.h>
21 #include <linux/vmalloc.h>
22 #include <rtw_ioctl_set.h>
25 * Translate the OS dependent @param error_code to OS independent
27 * @return: one of RTW_STATUS_CODE
29 inline int RTW_STATUS_CODE(int error_code)
36 u8 *_rtw_malloc(u32 sz)
38 return kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL);
41 void *rtw_malloc2d(int h, int w, int size)
45 void **a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL);
49 for (j = 0; j < h; j++)
50 a[j] = ((char *)(a + h)) + j * w * size;
55 void _rtw_init_queue(struct __queue *pqueue)
57 INIT_LIST_HEAD(&pqueue->queue);
58 spin_lock_init(&pqueue->lock);
61 struct net_device *rtw_alloc_etherdev_with_old_priv(void *old_priv)
63 struct net_device *pnetdev;
64 struct rtw_netdev_priv_indicator *pnpi;
66 pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4);
70 pnpi = netdev_priv(pnetdev);
71 pnpi->priv = old_priv;
77 void rtw_free_netdev(struct net_device *netdev)
79 struct rtw_netdev_priv_indicator *pnpi;
84 pnpi = netdev_priv(netdev);
96 u64 rtw_modular64(u64 x, u64 y)
101 void rtw_buf_free(u8 **buf, u32 *buf_len)
108 void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len)
114 if (!buf || !buf_len)
117 if (!src || !src_len)
121 dup = rtw_malloc(src_len);
124 memcpy(dup, src, dup_len);
130 /* replace buf with dup */