当前位置: 首页>>代码示例>>C++>>正文


C++ rtw_zmalloc函数代码示例

本文整理汇总了C++中rtw_zmalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ rtw_zmalloc函数的具体用法?C++ rtw_zmalloc怎么用?C++ rtw_zmalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rtw_zmalloc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: usb_bulkout_zero

static u32 usb_bulkout_zero(struct intf_hdl *pintfhdl, u32 addr)
{
	int pipe, status, len;
	u32 ret;
	unsigned char *pbuf;
	struct zero_bulkout_context *pcontext;
	PURB	purb = NULL;
	_adapter *padapter = (_adapter *)pintfhdl->padapter;
	struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
	struct pwrctrl_priv *pwrctl = dvobj_to_pwrctl(pdvobj);
	struct usb_device *pusbd = pdvobj->pusbdev;

	if (RTW_CANNOT_TX(padapter))
		return _FAIL;

	pcontext = (struct zero_bulkout_context *)rtw_zmalloc(sizeof(struct zero_bulkout_context));
	if (pcontext == NULL)
		return _FAIL;

	pbuf = (unsigned char *)rtw_zmalloc(sizeof(int));
	if (!pbuf) {
		kfree(pcontext);
		return _FAIL;
	}
	purb = usb_alloc_urb(0, GFP_ATOMIC);

	//translate DMA FIFO addr to pipehandle
	pipe = ffaddr2pipehdl(pdvobj, addr);

	len = 0;
	pcontext->pbuf = pbuf;
	pcontext->purb = purb;
	pcontext->pirp = NULL;
	pcontext->padapter = padapter;

	usb_fill_bulk_urb(purb, pusbd, pipe,
				pbuf,
				len,
				usb_bulkout_zero_complete,
				pcontext);//context is pcontext

	status = usb_submit_urb(purb, GFP_ATOMIC);

	if (!status)
		ret= _SUCCESS;
	else
		ret= _FAIL;
	return ret;
}
开发者ID:dosgo,项目名称:rtl8723bu,代码行数:49,代码来源:usb_ops_linux.c

示例2: rtw_os_xmit_resource_alloc

int rtw_os_xmit_resource_alloc(_adapter *padapter, struct xmit_buf *pxmitbuf,u32 alloc_sz)
{
#ifdef CONFIG_USB_HCI
	int i;
	struct dvobj_priv	*pdvobjpriv = adapter_to_dvobj(padapter);
	struct usb_device	*pusbd = pdvobjpriv->pusbdev;

#ifdef CONFIG_USE_USB_BUFFER_ALLOC_TX
	pxmitbuf->pallocated_buf = rtw_usb_buffer_alloc(pusbd, (size_t)alloc_sz, &pxmitbuf->dma_transfer_addr);
	pxmitbuf->pbuf = pxmitbuf->pallocated_buf;
	if(pxmitbuf->pallocated_buf == NULL)
		return _FAIL;
#else // CONFIG_USE_USB_BUFFER_ALLOC_TX

	pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
	if (pxmitbuf->pallocated_buf == NULL)
	{
		return _FAIL;
	}

	pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
	pxmitbuf->dma_transfer_addr = 0;

#endif // CONFIG_USE_USB_BUFFER_ALLOC_TX

	for(i=0; i<8; i++)
	{
		pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
		if(pxmitbuf->pxmit_urb[i] == NULL)
		{
			DBG_871X("pxmitbuf->pxmit_urb[i]==NULL");
			return _FAIL;
		}

	}
#endif
#if defined(CONFIG_PCI_HCI) || defined(CONFIG_SDIO_HCI)
	pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
	if (pxmitbuf->pallocated_buf == NULL)
	{
		return _FAIL;
	}

	pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
#endif

	return _SUCCESS;
}
开发者ID:1nfused,项目名称:RemoteAccess,代码行数:48,代码来源:xmit_linux.c

示例3: rtl8723bs_c2h_packet_handler

static void rtl8723bs_c2h_packet_handler(PADAPTER padapter, u8 *pbuf, u16 length)
{
	u8 *tmpBuf =NULL;
	u8 res = false;

	if (length == 0)
		return;

	/* DBG_871X("+%s() length =%d\n", __func__, length); */

	tmpBuf = rtw_zmalloc(length);
	if (tmpBuf == NULL)
		return;

	memcpy(tmpBuf, pbuf, length);

	res = rtw_c2h_packet_wk_cmd(padapter, tmpBuf, length);

	if (res == false)
		kfree(tmpBuf);

	/* DBG_871X("-%s res(%d)\n", __func__, res); */

	return;
}
开发者ID:jasonabele,项目名称:rtl8723bs,代码行数:25,代码来源:rtl8723bs_recv.c

示例4: rtl8723bs_c2h_packet_handler

static void rtl8723bs_c2h_packet_handler(PADAPTER padapter, u8 *pbuf, u16 length)
{
	u8 *tmpBuf=NULL;
	u8 res = _FALSE;

	if(length == 0)
		return;
	
	//DBG_871X("+%s() length=%d\n", __func__, length);

	tmpBuf = rtw_zmalloc(length);
	if (tmpBuf == NULL)
		return;

	_rtw_memcpy(tmpBuf, pbuf, length);

	res = rtw_c2h_packet_wk_cmd(padapter, tmpBuf, length);

	if (res == _FALSE && tmpBuf != NULL)
			rtw_mfree(tmpBuf, length);

	//DBG_871X("-%s res(%d)\n", __func__, res);

	return;
}
开发者ID:STPJ,项目名称:linux-3.4-sunxi,代码行数:25,代码来源:rtl8723bs_recv.c

示例5: rtw_os_xmit_resource_alloc

int rtw_os_xmit_resource_alloc(_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag)
{
	if (alloc_sz > 0) {
		pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
		if (pxmitbuf->pallocated_buf == NULL)
		{
			return _FAIL;
		}

		pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
	}

	if (flag) {
		int i;

		for(i=0; i<8; i++) {
			pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
			if(pxmitbuf->pxmit_urb[i] == NULL) {
				DBG_871X("pxmitbuf->pxmit_urb[i]==NULL");
				return _FAIL;
			}
		}
	}

	return _SUCCESS;
}
开发者ID:lwfinger,项目名称:rtl8723bu,代码行数:26,代码来源:xmit_linux.c

示例6: usb_bulkout_zero

static u32 usb_bulkout_zero(struct intf_hdl *pintfhdl, u32 addr)
{
	int pipe, status, len;
	u32 ret;
	unsigned char *pbuf;
	struct zero_bulkout_context *pcontext;
	PURB	purb = NULL;
	_adapter *padapter = (_adapter *)pintfhdl->padapter;
	struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
	struct usb_device *pusbd = pdvobj->pusbdev;

	//DBG_88E("%s\n", __func__);


	if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) ||(padapter->pwrctrlpriv.pnp_bstop_trx))
		return _FAIL;

	pcontext = (struct zero_bulkout_context *)rtw_zmalloc(sizeof(struct zero_bulkout_context));

	pbuf = (unsigned char *)rtw_zmalloc(sizeof(int));
	purb = usb_alloc_urb(0, GFP_ATOMIC);

	len = 0;
	pcontext->pbuf = pbuf;
	pcontext->purb = purb;
	pcontext->pirp = NULL;
	pcontext->padapter = padapter;

	//translate DMA FIFO addr to pipehandle

	usb_fill_bulk_urb(purb, pusbd, pipe,
				pbuf,
				len,
				usb_bulkout_zero_complete,
				pcontext);//context is pcontext

	status = usb_submit_urb(purb, GFP_ATOMIC);

	if (!status)
		ret= _SUCCESS;
	else
		ret= _FAIL;

	return ret;

}
开发者ID:tivolist,项目名称:rtl8188eu,代码行数:46,代码来源:usb_ops_linux.c

示例7: sizeof

static struct dvobj_priv *gspi_dvobj_init(struct spi_device *spi)
{
	int status = _FAIL;
	struct dvobj_priv *dvobj = NULL;
	PGSPI_DATA pgspi;

_func_enter_;

	dvobj = (struct dvobj_priv*)rtw_zmalloc(sizeof(*dvobj));
	if (NULL == dvobj) {
		goto exit;
	}

	//spi init
	/* This is the only SPI value that we need to set here, the rest
	 * comes from the board-peripherals file */
	spi->bits_per_word = 32;
	spi->max_speed_hz = 48 * 1000 * 1000;
	//here mode 0 and 3 all ok,
	//3 can run under 48M clock when SPI_CTL4 bit14 IS_FST set to 1
	//0 can run under 24M clock, but can run under 48M when SPI_CTL4 bit14 IS_FST set to 1 and Ctl0_reg[1:0] set to 3.
	spi->mode = SPI_MODE_3;
	spi_setup(spi);

#if 1
	//DBG_8192C("set spi ==========================%d \n", spi_setup(spi));

	DBG_871X("%s, mode = %d \n", __func__, spi->mode);
	DBG_871X("%s, bit_per_word = %d \n", __func__, spi->bits_per_word);
	DBG_871X("%s, speed = %d \n", __func__, spi->max_speed_hz);
	DBG_871X("%s, chip_select = %d \n", __func__, spi->chip_select);
	DBG_871X("%s, controller_data = %d \n", __func__, *(int *)spi->controller_data);
	DBG_871X("%s, irq= %d \n", __func__, oob_irq);
#endif

	spi_set_drvdata(spi, dvobj);
	pgspi = &dvobj->intf_data;
	pgspi->func = spi;

	if (gspi_init(dvobj) != _SUCCESS) {
		DBG_871X("%s: initialize GSPI Failed!\n", __FUNCTION__);
		goto free_dvobj;
	}

	status = _SUCCESS;

free_dvobj:
	if (status != _SUCCESS && dvobj) {
		spi_set_drvdata(spi, NULL);
		rtw_mfree((u8*)dvobj, sizeof(*dvobj));
		dvobj = NULL;
	}

exit:
_func_exit_;

	return dvobj;
}
开发者ID:32743069,项目名称:amlogic_common_3050,代码行数:58,代码来源:gspi_intf.c

示例8: _usbctrl_vendorreq_async_write

static int _usbctrl_vendorreq_async_write(struct usb_device *udev, u8 request,
	u16 value, u16 index, void *pdata, u16 len, u8 requesttype)
{
	int rc;
	unsigned int pipe;
	u8 reqtype;
	struct usb_ctrlrequest *dr;
	struct urb *urb;
	struct rtl819x_async_write_data {
		u8 data[VENDOR_CMD_MAX_DATA_LEN];
		struct usb_ctrlrequest dr;
	} *buf;


	if (requesttype == VENDOR_READ) {
		pipe = usb_rcvctrlpipe(udev, 0);//read_in
		reqtype =  REALTEK_USB_VENQT_READ;
	}
	else {
		pipe = usb_sndctrlpipe(udev, 0);//write_out
		reqtype =  REALTEK_USB_VENQT_WRITE;
	}
	
	buf = (struct rtl819x_async_write_data *)rtw_zmalloc(sizeof(*buf));
	if (!buf) {
		rc = -ENOMEM;
		goto exit;
	}

	urb = usb_alloc_urb(0, GFP_ATOMIC);
	if (!urb) {
		rtw_mfree((u8*)buf, sizeof(*buf));
		rc = -ENOMEM;
		goto exit;
	}

	dr = &buf->dr;

	dr->bRequestType = reqtype;
	dr->bRequest = request;
	dr->wValue = cpu_to_le16(value);
	dr->wIndex = cpu_to_le16(index);
	dr->wLength = cpu_to_le16(len);

	_rtw_memcpy(buf, pdata, len);

	usb_fill_control_urb(urb, udev, pipe, (unsigned char *)dr, buf, len,
		_usbctrl_vendorreq_async_callback, buf);

	rc = usb_submit_urb(urb, GFP_ATOMIC);
	if (rc < 0) {
		rtw_mfree((u8*)buf, sizeof(*buf));
		usb_free_urb(urb);
	}

exit:
	return rc;
}
开发者ID:GREYFOXRGR,项目名称:BPI-M3-bsp,代码行数:58,代码来源:usb_ops_linux.c

示例9: rtw_os_xmit_resource_alloc

int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag)
{
	if (alloc_sz > 0) {
		pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
		if (pxmitbuf->pallocated_buf == NULL)
			return _FAIL;

		pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
	}

	return _SUCCESS;
}
开发者ID:krzk,项目名称:linux,代码行数:12,代码来源:xmit_linux.c

示例10: rtw_report_sec_ie

void rtw_report_sec_ie(_adapter *adapter,u8 authmode,u8 *sec_ie)
{
	uint	len;
	u8	*buff,*p,i;
	union iwreq_data wrqu;

_func_enter_;

	RT_TRACE(_module_mlme_osdep_c_,_drv_info_,("+rtw_report_sec_ie, authmode=%d\n", authmode));

	buff = NULL;
	if(authmode==_WPA_IE_ID_)
	{
		RT_TRACE(_module_mlme_osdep_c_,_drv_info_,("rtw_report_sec_ie, authmode=%d\n", authmode));

		buff = rtw_zmalloc(IW_CUSTOM_MAX);
		if (NULL == buff) {
			DBG_871X(FUNC_ADPT_FMT ": alloc memory FAIL!!\n",
				FUNC_ADPT_ARG(adapter));
			return;
		}
		p = buff;

		p+=sprintf(p,"ASSOCINFO(ReqIEs=");

		len = sec_ie[1]+2;
		len = (len < IW_CUSTOM_MAX) ? len:IW_CUSTOM_MAX;
			
		for(i=0;i<len;i++){
			p+=sprintf(p,"%02x",sec_ie[i]);
		}

		p+=sprintf(p,")");

		_rtw_memset(&wrqu,0,sizeof(wrqu));

		wrqu.data.length=p-buff;

		wrqu.data.length = (wrqu.data.length<IW_CUSTOM_MAX) ? wrqu.data.length:IW_CUSTOM_MAX;

#ifndef CONFIG_IOCTL_CFG80211
		wireless_send_event(adapter->pnetdev,IWEVCUSTOM,&wrqu,buff);
#endif

		rtw_mfree(buff, IW_CUSTOM_MAX);
	}

exit:

_func_exit_;

}
开发者ID:NextThingCo,项目名称:RTL8723BS,代码行数:52,代码来源:mlme_linux.c

示例11:

void *rtw_malloc2d(int h, int w, int size)
{
	int j;

	void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size);
	if (a == NULL) {
		pr_info("%s: alloc memory fail!\n", __func__);
		return NULL;
	}

	for (j = 0; j < h; j++)
		a[j] = ((char *)(a+h)) + j*w*size;

	return a;
}
开发者ID:thoemy,项目名称:android_kernel_htc_endeavoru-new,代码行数:15,代码来源:osdep_service.c

示例12: rtl8195as_init_recv_priv

/*
 * Initialize recv private variable for hardware dependent
 * 1. recv buf
 * 2. recv tasklet
 *
 */
s32 rtl8195as_init_recv_priv(PADAPTER padapter)
{
	s32			res;
	u32			i, n;
	struct recv_buf		*precvbuf;
	struct recv_priv	*precvpriv = &padapter->recvpriv;

	res = _SUCCESS;

	//3 1. init recv buffer
	_rtw_init_queue(&precvpriv->free_recv_buf_queue);
	_rtw_init_queue(&precvpriv->recv_buf_pending_queue);

	n = NR_RECVBUFF * sizeof(struct recv_buf) + 4;
	precvpriv->pallocated_recv_buf = rtw_zmalloc(n);
	if (precvpriv->pallocated_recv_buf == NULL) {
		res = _FAIL;
		goto exit;
	}

	precvpriv->precv_buf = (u8*)N_BYTE_ALIGMENT((SIZE_PTR)(precvpriv->pallocated_recv_buf), 4);

	// init each recv buffer
	precvbuf = (struct recv_buf*)precvpriv->precv_buf;
	for (i = 0; i < NR_RECVBUFF; i++)
	{
		_rtw_init_listhead(&precvbuf->list);

		precvbuf->adapter = padapter;

		rtw_list_insert_tail(&precvbuf->list, &precvpriv->free_recv_buf_queue.queue);

		precvbuf++;
	}
	precvpriv->free_recv_buf_queue_cnt = i;

	//3 2. init tasklet
	tasklet_init(&precvpriv->recv_tasklet,
	     (void(*)(unsigned long))rtl8195as_recv_tasklet,
	     (unsigned long)padapter);

	goto exit;

exit:
	return res;
}
开发者ID:yangkunming99,项目名称:linux_inic,代码行数:52,代码来源:rtl8195as_recv.c

示例13: clearinterrupt8723bsdio

void clearinterrupt8723bsdio(struct adapter *adapter)
{
	struct hal_com_data *haldata;
	u8 *clear;

	if (adapter->bSurpriseRemoved)
		return;

	haldata = GET_HAL_DATA(adapter);
	clear = rtw_zmalloc(4);

	/*  Clear corresponding HISR Content if needed */
	*(__le32 *)clear = cpu_to_le32(haldata->sdio_hisr & MASK_SDIO_HISR_CLEAR);
	if (*(__le32 *)clear) {
		/*  Perform write one clear operation */
		sdio_local_write(padapter, SDIO_REG_HISR, 4, clear);
	}

	kfree(clear);
}
开发者ID:Lyude,项目名称:linux,代码行数:20,代码来源:sdio_ops.c

示例14: rtw_os_xmit_resource_alloc

int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz)
{
	int i;

	pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
	if (pxmitbuf->pallocated_buf == NULL)
		return _FAIL;

	pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
	pxmitbuf->dma_transfer_addr = 0;

	for (i = 0; i < 8; i++) {
		pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
		if (pxmitbuf->pxmit_urb[i] == NULL) {
			DBG_88E("pxmitbuf->pxmit_urb[i]==NULL");
			return _FAIL;
		}
	}
	return _SUCCESS;
}
开发者ID:Adri9102,项目名称:rtl8188eu,代码行数:20,代码来源:xmit_linux.c

示例15: rtw_report_sec_ie

void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
{
	uint	len;
	u8 *buff,*p, i;
	union iwreq_data wrqu;

	RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("+rtw_report_sec_ie, authmode =%d\n", authmode));

	buff = NULL;
	if (authmode == _WPA_IE_ID_)
	{
		RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("rtw_report_sec_ie, authmode =%d\n", authmode));

		buff = rtw_zmalloc(IW_CUSTOM_MAX);
		if (NULL == buff) {
			DBG_871X(FUNC_ADPT_FMT ": alloc memory FAIL!!\n",
				FUNC_ADPT_ARG(adapter));
			return;
		}
		p = buff;

		p+=sprintf(p,"ASSOCINFO(ReqIEs =");

		len = sec_ie[1]+2;
		len = (len < IW_CUSTOM_MAX) ? len:IW_CUSTOM_MAX;

		for (i = 0;i<len;i++) {
			p+=sprintf(p,"%02x", sec_ie[i]);
		}

		p+=sprintf(p,")");

		memset(&wrqu, 0, sizeof(wrqu));

		wrqu.data.length =p-buff;

		wrqu.data.length = (wrqu.data.length<IW_CUSTOM_MAX) ? wrqu.data.length:IW_CUSTOM_MAX;

		kfree(buff);
	}
}
开发者ID:mkrufky,项目名称:linux,代码行数:41,代码来源:mlme_linux.c


注:本文中的rtw_zmalloc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。