本文整理汇总了C++中LEAVE函数的典型用法代码示例。如果您正苦于以下问题:C++ LEAVE函数的具体用法?C++ LEAVE怎么用?C++ LEAVE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LEAVE函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _cairo_xynth_surface_composite
static cairo_int_status_t _cairo_xynth_surface_composite (cairo_operator_t cairo_operator, cairo_pattern_t *src_pattern, cairo_pattern_t *mask_pattern, void *abstract_surface, int src_x, int src_y, int mask_x, int mask_y, int dst_x, int dst_y, unsigned int width, unsigned int height)
{
cairo_int_status_t status;
cairo_xynth_surface_t *dst;
cairo_xynth_surface_t *src;
cairo_xynth_surface_t *mask;
cairo_surface_attributes_t src_attr;
cairo_surface_attributes_t mask_attr;
ENTER();
dst = (cairo_xynth_surface_t *) abstract_surface;
status = _cairo_pattern_acquire_surfaces(src_pattern, mask_pattern, &dst->cairo, src_x, src_y, mask_x, mask_y, width, height, (cairo_surface_t **) &src, (cairo_surface_t **) &mask, &src_attr, &mask_attr);
if (status) {
return status;
}
status = _cairo_xynth_surface_set_attributes(src, &src_attr);
if (status) {
goto out;
}
if (mask) {
status = _cairo_xynth_surface_set_attributes(mask, &mask_attr);
if (status) {
goto out;
}
s_render_composite(_cairo_xynth_operator(cairo_operator),
src->render,
mask->render,
dst->render,
src_x + src_attr.x_offset,
src_y + src_attr.y_offset,
mask_x + mask_attr.x_offset,
mask_y + mask_attr.y_offset,
dst_x, dst_y,
width, height);
} else {
s_render_composite(_cairo_xynth_operator(cairo_operator),
src->render,
NULL,
dst->render,
src_x + src_attr.x_offset,
src_y + src_attr.y_offset,
0, 0,
dst_x, dst_y,
width, height);
}
if (!_cairo_operator_bounded_by_source(cairo_operator)) {
status = _cairo_surface_composite_fixup_unbounded(&dst->cairo,
&src_attr, src->render->width, src->render->height,
mask ? &mask_attr : NULL,
mask ? mask->render->width : 0,
mask ? mask->render->height : 0,
src_x, src_y,
mask_x, mask_y,
dst_x, dst_y,
width, height);
}
out: if (mask) {
_cairo_pattern_release_surface(mask_pattern, &mask->cairo, &mask_attr);
}
_cairo_pattern_release_surface(src_pattern, &src->cairo, &src_attr);
LEAVE();
return CAIRO_STATUS_SUCCESS;
}
示例2: woal_sdio_shutdown
/** @brief This function handles client driver shutdown
*
* @param dev A pointer to device structure
* @return N/A
*/
void
woal_sdio_shutdown(struct device *dev)
{
struct sdio_func *func = dev_to_sdio_func(dev);
moal_handle *handle = NULL;
struct sdio_mmc_card *cardp;
mlan_ds_hs_cfg hscfg;
int timeout = 0;
int i;
ENTER();
PRINTM(MCMND, "<--- Enter woal_sdio_shutdown --->\n");
cardp = sdio_get_drvdata(func);
if (!cardp || !cardp->handle) {
PRINTM(MERROR, "Card or moal_handle structure is not valid\n");
LEAVE();
return;
}
handle = cardp->handle;
for (i = 0; i < handle->priv_num; i++)
netif_device_detach(handle->priv[i]->netdev);
if (shutdown_hs) {
memset(&hscfg, 0, sizeof(mlan_ds_hs_cfg));
hscfg.is_invoke_hostcmd = MFALSE;
hscfg.conditions = SHUTDOWN_HOST_SLEEP_DEF_COND;
hscfg.gap = SHUTDOWN_HOST_SLEEP_DEF_GAP;
hscfg.gpio = SHUTDOWN_HOST_SLEEP_DEF_GPIO;
if (woal_set_get_hs_params
(woal_get_priv(handle, MLAN_BSS_ROLE_ANY), MLAN_ACT_SET,
MOAL_IOCTL_WAIT, &hscfg) == MLAN_STATUS_FAILURE) {
PRINTM(MERROR,
"Fail to set HS parameter in shutdown: 0x%x 0x%x 0x%x\n",
hscfg.conditions, hscfg.gap, hscfg.gpio);
goto done;
}
/* Enable Host Sleep */
handle->hs_activate_wait_q_woken = MFALSE;
memset(&hscfg, 0, sizeof(mlan_ds_hs_cfg));
hscfg.is_invoke_hostcmd = MTRUE;
if (woal_set_get_hs_params
(woal_get_priv(handle, MLAN_BSS_ROLE_ANY), MLAN_ACT_SET,
MOAL_NO_WAIT, &hscfg) == MLAN_STATUS_FAILURE) {
PRINTM(MERROR,
"Request HS enable failed in shutdown\n");
goto done;
}
timeout =
wait_event_interruptible_timeout(handle->
hs_activate_wait_q,
handle->
hs_activate_wait_q_woken,
HS_ACTIVE_TIMEOUT);
if (handle->hs_activated == MTRUE)
PRINTM(MMSG, "HS actived in shutdown\n");
else
PRINTM(MMSG, "Fail to enable HS in shutdown\n");
}
done:
PRINTM(MCMND, "<--- Leave woal_sdio_shutdown --->\n");
LEAVE();
return;
}
示例3: bpf_jit_compile
/*
* Function that does the real stuff.
*/
bpf_filter_func
bpf_jit_compile(struct bpf_insn *prog, u_int nins, size_t *size)
{
bpf_bin_stream stream;
struct bpf_insn *ins;
int flags, fret, fpkt, fmem, fjmp, flen;
u_int i, pass;
/*
* NOTE: Do not modify the name of this variable, as it's used by
* the macros to emit code.
*/
emit_func emitm;
flags = bpf_jit_optimize(prog, nins);
fret = (flags & BPF_JIT_FRET) != 0;
fpkt = (flags & BPF_JIT_FPKT) != 0;
fmem = (flags & BPF_JIT_FMEM) != 0;
fjmp = (flags & BPF_JIT_FJMP) != 0;
flen = (flags & BPF_JIT_FLEN) != 0;
if (fret)
nins = 1;
memset(&stream, 0, sizeof(stream));
/* Allocate the reference table for the jumps. */
if (fjmp) {
#ifdef _KERNEL
stream.refs = malloc((nins + 1) * sizeof(u_int), M_BPFJIT,
M_NOWAIT | M_ZERO);
#else
stream.refs = calloc(nins + 1, sizeof(u_int));
#endif
if (stream.refs == NULL)
return (NULL);
}
/*
* The first pass will emit the lengths of the instructions
* to create the reference table.
*/
emitm = emit_length;
for (pass = 0; pass < 2; pass++) {
ins = prog;
/* Create the procedure header. */
if (fmem) {
PUSH(RBP);
MOVrq(RSP, RBP);
SUBib(BPF_MEMWORDS * sizeof(uint32_t), RSP);
}
if (flen)
MOVrd2(ESI, R9D);
if (fpkt) {
MOVrq2(RDI, R8);
MOVrd(EDX, EDI);
}
for (i = 0; i < nins; i++) {
stream.bpf_pc++;
switch (ins->code) {
default:
#ifdef _KERNEL
return (NULL);
#else
abort();
#endif
case BPF_RET|BPF_K:
MOVid(ins->k, EAX);
if (fmem)
LEAVE();
RET();
break;
case BPF_RET|BPF_A:
if (fmem)
LEAVE();
RET();
break;
case BPF_LD|BPF_W|BPF_ABS:
MOVid(ins->k, ESI);
CMPrd(EDI, ESI);
JAb(12);
MOVrd(EDI, ECX);
SUBrd(ESI, ECX);
CMPid(sizeof(int32_t), ECX);
if (fmem) {
JAEb(4);
ZEROrd(EAX);
LEAVE();
} else {
JAEb(3);
//.........这里部分代码省略.........
示例4: SMI_CrtcPrepare
static void
SMI_CrtcPrepare(xf86CrtcPtr crtc)
{
ENTER();
LEAVE();
}
开发者ID:freedesktop-unofficial-mirror,项目名称:xorg__driver__xf86-video-siliconmotion,代码行数:6,代码来源:smi_crtc.c
示例5: wlan_11n_deaggregate_pkt
/**
* @brief Deaggregate the received AMSDU packet
*
* @param priv A pointer to mlan_private structure
* @param pmbuf A pointer to aggregated data packet
*
* @return MLAN_STATUS_SUCCESS --success, otherwise fail
*/
mlan_status
wlan_11n_deaggregate_pkt(mlan_private * priv, pmlan_buffer pmbuf)
{
t_u16 pkt_len;
int total_pkt_len;
t_u8 *data;
int pad;
mlan_status ret = MLAN_STATUS_FAILURE;
RxPacketHdr_t *prx_pkt;
mlan_buffer *daggr_mbuf = MNULL;
mlan_adapter *pmadapter = priv->adapter;
t_u8 rfc1042_eth_hdr[MLAN_MAC_ADDR_LENGTH] = { 0xaa, 0xaa, 0x03,
0x00, 0x00, 0x00
};
ENTER();
data = (t_u8 *) (pmbuf->pbuf + pmbuf->data_offset);
total_pkt_len = pmbuf->data_len;
/* Sanity test */
if (total_pkt_len > MLAN_RX_DATA_BUF_SIZE) {
PRINTM(MERROR, "Total packet length greater than tx buffer"
" size %d\n", total_pkt_len);
goto done;
}
pmbuf->use_count = wlan_11n_get_num_aggrpkts(data, total_pkt_len);
while (total_pkt_len > 0) {
prx_pkt = (RxPacketHdr_t *) data;
/* Length will be in network format, change it to host */
pkt_len = mlan_ntohs((*(t_u16 *) (data + (2 * MLAN_MAC_ADDR_LENGTH))));
if (pkt_len > total_pkt_len) {
PRINTM(MERROR,
"Error in packet length: total_pkt_len = %d, pkt_len = %d\n",
total_pkt_len, pkt_len);
break;
}
pad = (((pkt_len + sizeof(Eth803Hdr_t)) & 3)) ?
(4 - ((pkt_len + sizeof(Eth803Hdr_t)) & 3)) : 0;
total_pkt_len -= pkt_len + pad + sizeof(Eth803Hdr_t);
if (memcmp(pmadapter, &prx_pkt->rfc1042_hdr,
rfc1042_eth_hdr, sizeof(rfc1042_eth_hdr)) == 0) {
memmove(pmadapter, data + LLC_SNAP_LEN, data, (2 *
MLAN_MAC_ADDR_LENGTH));
data += LLC_SNAP_LEN;
pkt_len += sizeof(Eth803Hdr_t) - LLC_SNAP_LEN;
} else {
*(t_u16 *) (data + (2 * MLAN_MAC_ADDR_LENGTH))
= (t_u16) 0;
pkt_len += sizeof(Eth803Hdr_t);
}
daggr_mbuf = wlan_alloc_mlan_buffer(pmadapter, pkt_len, 0, MFALSE);
if (daggr_mbuf == MNULL) {
PRINTM(MERROR, "Error allocating daggr mlan_buffer\n");
LEAVE();
return MLAN_STATUS_FAILURE;
}
daggr_mbuf->bss_index = pmbuf->bss_index;
daggr_mbuf->buf_type = pmbuf->buf_type;
daggr_mbuf->data_len = pkt_len;
daggr_mbuf->in_ts_sec = pmbuf->in_ts_sec;
daggr_mbuf->in_ts_usec = pmbuf->in_ts_usec;
daggr_mbuf->pparent = pmbuf;
daggr_mbuf->priority = pmbuf->priority;
memcpy(pmadapter, daggr_mbuf->pbuf + daggr_mbuf->data_offset, data,
pkt_len);
#ifdef UAP_SUPPORT
if (GET_BSS_ROLE(priv) == MLAN_BSS_ROLE_UAP)
ret = wlan_uap_recv_packet(priv, daggr_mbuf);
else
#endif /* UAP_SUPPORT */
ret =
pmadapter->callbacks.moal_recv_packet(pmadapter->pmoal_handle,
daggr_mbuf);
switch (ret) {
case MLAN_STATUS_PENDING:
break;
case MLAN_STATUS_FAILURE:
PRINTM(MERROR, "Deaggr, send to moal failed\n");
daggr_mbuf->status_code = MLAN_ERROR_PKT_INVALID;
case MLAN_STATUS_SUCCESS:
wlan_recv_packet_complete(pmadapter, daggr_mbuf, ret);
break;
default:
break;
//.........这里部分代码省略.........
示例6: wlan_init_adapter
//.........这里部分代码省略.........
pmadapter->cmd_sent = MFALSE;
pmadapter->data_sent = MFALSE;
pmadapter->cmd_resp_received = MFALSE;
pmadapter->event_received = MFALSE;
pmadapter->data_received = MFALSE;
pmadapter->cmd_timer_is_set = MFALSE;
/* PnP and power profile */
pmadapter->surprise_removed = MFALSE;
/* Status variables */
pmadapter->hw_status = WlanHardwareStatusInitializing;
/* Scan type */
pmadapter->scan_type = HostCmd_SCAN_TYPE_ACTIVE;
/* Scan mode */
pmadapter->scan_mode = HostCmd_BSS_TYPE_ANY;
/* Scan time */
pmadapter->specific_scan_time = MRVDRV_SPECIFIC_SCAN_CHAN_TIME;
pmadapter->active_scan_time = MRVDRV_ACTIVE_SCAN_CHAN_TIME;
pmadapter->passive_scan_time = MRVDRV_PASSIVE_SCAN_CHAN_TIME;
pmadapter->num_in_scan_table = 0;
memset(pmadapter->pscan_table, 0,
(sizeof(BSSDescriptor_t) * MRVDRV_MAX_BSSID_LIST));
pmadapter->scan_probes = 0;
memset(pmadapter->bcn_buf, 0, sizeof(pmadapter->bcn_buf));
pmadapter->pbcn_buf_end = pmadapter->bcn_buf;
pmadapter->radio_on = RADIO_ON;
pmadapter->ps_mode = Wlan802_11PowerModeCAM;
pmadapter->multiple_dtim = MRVDRV_DEFAULT_MULTIPLE_DTIM;
pmadapter->ps_state = PS_STATE_FULL_POWER;
pmadapter->need_to_wakeup = MFALSE;
pmadapter->local_listen_interval = 0; /* default value in firmware
will be used */
pmadapter->pm_wakeup_card_req = MFALSE;
pmadapter->pm_wakeup_fw_try = MFALSE;
pmadapter->max_tx_buf_size = MLAN_TX_DATA_BUF_SIZE_2K;
pmadapter->tx_buf_size = MLAN_TX_DATA_BUF_SIZE_2K;
pmadapter->is_hs_configured = MFALSE;
pmadapter->hs_cfg.conditions = HOST_SLEEP_CFG_CANCEL;
pmadapter->hs_cfg.gpio = 0;
pmadapter->hs_cfg.gap = 0;
pmadapter->hs_activated = MFALSE;
memset(pmadapter->event_body, 0, sizeof(pmadapter->event_body));
pmadapter->hw_dot_11n_dev_cap = 0;
pmadapter->hw_dev_mcs_support = 0;
pmadapter->usr_dot_11n_dev_cap = 0;
pmadapter->usr_dev_mcs_support = 0;
pmadapter->chan_offset = 0;
/* Initialize 802.11d */
wlan_11d_init(pmadapter);
wlan_wmm_init(pmadapter);
util_init_list_head(&pmadapter->rx_data_queue, MTRUE,
pmadapter->callbacks.moal_init_lock);
memset(&pmadapter->sleep_cfm_buf.ps_cfm_sleep, 0,
sizeof(PS_CMD_ConfirmSleep));
pmadapter->sleep_cfm_buf.ps_cfm_sleep.command =
wlan_cpu_to_le16(HostCmd_CMD_802_11_PS_MODE);
pmadapter->sleep_cfm_buf.ps_cfm_sleep.size =
wlan_cpu_to_le16(sizeof(PS_CMD_ConfirmSleep));
pmadapter->sleep_cfm_buf.ps_cfm_sleep.result = 0;
pmadapter->sleep_cfm_buf.ps_cfm_sleep.action =
wlan_cpu_to_le16(HostCmd_SubCmd_Sleep_Confirmed);
memset(&pmadapter->sleep_params, 0, sizeof(pmadapter->sleep_params));
memset(&pmadapter->sleep_period, 0, sizeof(pmadapter->sleep_period));
pmadapter->tx_lock_flag = MFALSE;
pmadapter->null_pkt_interval = 0;
pmadapter->fw_bands = 0;
pmadapter->config_bands = 0;
pmadapter->adhoc_start_band = 0;
pmadapter->pscan_channels = MNULL;
pmadapter->fw_release_number = 0;
pmadapter->fw_cap_info = 0;
memset(&pmadapter->upld_buf, 0, sizeof(pmadapter->upld_buf));
pmadapter->upld_len = 0;
pmadapter->event_cause = 0;
memset(&pmadapter->region_channel, 0, sizeof(pmadapter->region_channel));
pmadapter->region_code = 0;
pmadapter->bcn_miss_time_out = DEFAULT_BCN_MISS_TIMEOUT;
pmadapter->adhoc_awake_period = 0;
memset(&pmadapter->arp_filter, 0, sizeof(pmadapter->arp_filter));
pmadapter->arp_filter_size = 0;
LEAVE();
return;
}
示例7: wlan_init_cmd
//.........这里部分代码省略.........
* @param pmadapter A pointer to mlan_adapter
*
* @return MLAN_STATUS_SUCCESS or error code
*/
mlan_status
wlan_init_cmd(IN pmlan_adapter pmadapter)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
pmlan_private priv = MNULL;
t_s32 i = 0;
t_u16 enable = MTRUE;
mlan_ds_11n_amsdu_aggr_ctrl amsdu_aggr_ctrl;
ENTER();
if (pmadapter->priv[0]) {
priv = pmadapter->priv[0];
/*
* Read MAC address from HW
*/
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_GET_HW_SPEC,
HostCmd_ACT_GEN_GET, 0, MNULL, MNULL);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* Reconfgiure tx buf size */
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_RECONFIGURE_TX_BUFF,
HostCmd_ACT_GEN_SET,
0, MNULL, &pmadapter->tx_buf_size);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
}
for (i = 0; i < MLAN_MAX_BSS_NUM; i++) {
if (pmadapter->priv[i]) {
priv = pmadapter->priv[i];
/* get tx rate */
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_TX_RATE_CFG,
HostCmd_ACT_GEN_GET, 0, MNULL, MNULL);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
priv->data_rate = 0;
/* get tx power */
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_TXPWR_CFG,
HostCmd_ACT_GEN_GET, 0, MNULL, MNULL);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* set ibss coalescing_status */
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_802_11_IBSS_COALESCING_STATUS,
HostCmd_ACT_GEN_SET, 0, MNULL, &enable);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
memset(&amsdu_aggr_ctrl, 0, sizeof(amsdu_aggr_ctrl));
amsdu_aggr_ctrl.enable = MLAN_ACT_ENABLE;
/* Send request to firmware */
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_AMSDU_AGGR_CTRL,
HostCmd_ACT_GEN_SET, 0, MNULL,
(t_void *) & amsdu_aggr_ctrl);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
/* MAC Control must be the last command in init_fw */
/* set MAC Control */
ret = wlan_prepare_cmd(priv,
HostCmd_CMD_MAC_CONTROL,
HostCmd_ACT_GEN_SET,
0, MNULL, &priv->curr_pkt_filter);
if (ret) {
ret = MLAN_STATUS_FAILURE;
goto done;
}
}
}
ret = MLAN_STATUS_PENDING;
done:
LEAVE();
return ret;
}
示例8: wlan_11d_generate_domain_info
/**
* @brief This function generates domain_info from parsed_region_chan
*
* @param pmadapter Pointer to mlan_adapter structure
* @param parsed_region_chan Pointer to parsed_region_chan_11d_t
*
* @return MLAN_STATUS_SUCCESS
*/
static mlan_status
wlan_11d_generate_domain_info(pmlan_adapter pmadapter,
parsed_region_chan_11d_t * parsed_region_chan)
{
t_u8 no_of_sub_band = 0;
t_u8 no_of_chan = parsed_region_chan->no_of_chan;
t_u8 no_of_parsed_chan = 0;
t_u8 first_chan = 0, next_chan = 0, max_pwr = 0;
t_u8 i, flag = MFALSE;
wlan_802_11d_domain_reg_t *domain_info = &pmadapter->domain_reg;
ENTER();
/* Should be only place that clear domain_reg (besides init) */
memset(pmadapter, domain_info, 0, sizeof(wlan_802_11d_domain_reg_t));
/* Set country code */
memcpy(pmadapter, domain_info->country_code,
wlan_11d_code_2_region(pmadapter, (t_u8) pmadapter->region_code),
COUNTRY_CODE_LEN);
PRINTM(MINFO, "11D: Number of channel = %d\n", no_of_chan);
HEXDUMP("11D: parsed_region_chan", (t_u8 *) parsed_region_chan,
sizeof(parsed_region_chan_11d_t));
/* Set channel and power */
for (i = 0; i < no_of_chan; i++) {
if (!flag) {
flag = MTRUE;
next_chan = first_chan =
parsed_region_chan->chan_pwr[i].chan;
max_pwr = parsed_region_chan->chan_pwr[i].pwr;
no_of_parsed_chan = 1;
continue;
}
if (parsed_region_chan->chan_pwr[i].chan == next_chan + 1 &&
parsed_region_chan->chan_pwr[i].pwr == max_pwr) {
next_chan++;
no_of_parsed_chan++;
} else {
domain_info->sub_band[no_of_sub_band].first_chan =
first_chan;
domain_info->sub_band[no_of_sub_band].no_of_chan =
no_of_parsed_chan;
domain_info->sub_band[no_of_sub_band].max_tx_pwr =
max_pwr;
no_of_sub_band++;
no_of_parsed_chan = 1;
next_chan = first_chan =
parsed_region_chan->chan_pwr[i].chan;
max_pwr = parsed_region_chan->chan_pwr[i].pwr;
}
}
if (flag) {
domain_info->sub_band[no_of_sub_band].first_chan = first_chan;
domain_info->sub_band[no_of_sub_band].no_of_chan =
no_of_parsed_chan;
domain_info->sub_band[no_of_sub_band].max_tx_pwr = max_pwr;
no_of_sub_band++;
}
domain_info->no_of_sub_band = no_of_sub_band;
PRINTM(MINFO, "11D: Number of sub-band =0x%x\n",
domain_info->no_of_sub_band);
HEXDUMP("11D: domain_info", (t_u8 *) domain_info,
COUNTRY_CODE_LEN + 1 +
sizeof(IEEEtypes_SubbandSet_t) * no_of_sub_band);
LEAVE();
return MLAN_STATUS_SUCCESS;
}
示例9: wlan_11d_process_country_info
/**
* @brief This function processes the country info present in BSSDescriptor.
*
* @param pmpriv A pointer to mlan_private structure
* @param pbss_desc A pointer to BSSDescriptor_t
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
static mlan_status
wlan_11d_process_country_info(mlan_private * pmpriv,
BSSDescriptor_t * pbss_desc)
{
mlan_adapter *pmadapter = pmpriv->adapter;
parsed_region_chan_11d_t region_chan;
parsed_region_chan_11d_t *parsed_region_chan =
&pmadapter->parsed_region_chan;
t_u16 i, j, num_chan_added = 0;
ENTER();
memset(pmadapter, ®ion_chan, 0, sizeof(parsed_region_chan_11d_t));
/* Parse 11D country info */
if (wlan_11d_parse_domain_info(pmadapter, &pbss_desc->country_info,
(t_u8) pbss_desc->bss_band,
®ion_chan) != MLAN_STATUS_SUCCESS) {
LEAVE();
return MLAN_STATUS_FAILURE;
}
if (parsed_region_chan->no_of_chan != 0) {
/*
* Check if the channel number already exists in the
* chan-power table of parsed_region_chan
*/
for (i = 0; (i < region_chan.no_of_chan && i < MAX_NO_OF_CHAN);
i++) {
for (j = 0;
(j < parsed_region_chan->no_of_chan &&
j < MAX_NO_OF_CHAN); j++) {
/*
* Channel already exists, update the tx power with new tx
* power, since country IE is valid here.
*/
if (region_chan.chan_pwr[i].chan ==
parsed_region_chan->chan_pwr[j].chan &&
region_chan.chan_pwr[i].band ==
parsed_region_chan->chan_pwr[j].band) {
parsed_region_chan->chan_pwr[j].pwr =
region_chan.chan_pwr[i].pwr;
break;
}
}
if (j == parsed_region_chan->no_of_chan &&
j < MAX_NO_OF_CHAN) {
/*
* Channel does not exist in the channel power table,
* update this new chan and tx_power to the channel power table
*/
parsed_region_chan->
chan_pwr[parsed_region_chan->
no_of_chan +
num_chan_added].chan =
region_chan.chan_pwr[i].chan;
parsed_region_chan->
chan_pwr[parsed_region_chan->
no_of_chan +
num_chan_added].band =
region_chan.chan_pwr[i].band;
parsed_region_chan->
chan_pwr[parsed_region_chan->
no_of_chan +
num_chan_added].pwr =
region_chan.chan_pwr[i].pwr;
parsed_region_chan->
chan_pwr[parsed_region_chan->
no_of_chan +
num_chan_added].ap_seen =
MFALSE;
num_chan_added++;
}
}
parsed_region_chan->no_of_chan += num_chan_added;
} else {
/* Parsed region is empty, copy the first one */
memcpy(pmadapter, parsed_region_chan,
®ion_chan, sizeof(parsed_region_chan_11d_t));
}
LEAVE();
return MLAN_STATUS_SUCCESS;
}
示例10: wlan_11d_create_dnld_countryinfo
/**
* @brief This function generates 11D info from user specified regioncode
* and download to FW
*
* @param pmpriv A pointer to mlan_private structure
* @param band Band to create
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status
wlan_11d_create_dnld_countryinfo(mlan_private * pmpriv, t_u8 band)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_adapter *pmadapter = pmpriv->adapter;
region_chan_t *region_chan;
parsed_region_chan_11d_t parsed_region_chan;
t_u8 j;
ENTER();
/* Only valid if 11D is enabled */
if (wlan_11d_is_enabled(pmpriv)) {
PRINTM(MINFO, "11D: Band[%d]\n", band);
/* Update parsed_region_chan; download domain info to FW */
/* Find region channel */
for (j = 0; j < MAX_REGION_CHANNEL_NUM; j++) {
region_chan = &pmadapter->region_channel[j];
PRINTM(MINFO, "11D: [%d] region_chan->Band[%d]\n", j,
region_chan->band);
if (!region_chan || !region_chan->valid ||
!region_chan->pcfp)
continue;
switch (region_chan->band) {
case BAND_A:
switch (band) {
case BAND_A:
case BAND_AN:
case BAND_A | BAND_AN:
case BAND_A | BAND_AN | BAND_AAC:
break;
default:
continue;
}
break;
case BAND_B:
case BAND_G:
switch (band) {
case BAND_B:
case BAND_G:
case BAND_G | BAND_B:
case BAND_GN:
case BAND_G | BAND_GN:
case BAND_B | BAND_G | BAND_GN:
case BAND_B | BAND_G | BAND_GN | BAND_GAC:
break;
default:
continue;
}
break;
default:
continue;
}
break;
}
/* Check if region channel found */
if (j >= MAX_REGION_CHANNEL_NUM) {
PRINTM(MERROR, "11D: region_chan not found. Band[%d]\n",
band);
LEAVE();
return MLAN_STATUS_FAILURE;
}
/* Generate parsed region channel info from region channel */
memset(pmadapter, &parsed_region_chan, 0,
sizeof(parsed_region_chan_11d_t));
wlan_11d_generate_parsed_region_chan(pmadapter, region_chan,
&parsed_region_chan);
/* Generate domain info from parsed region channel info */
wlan_11d_generate_domain_info(pmadapter, &parsed_region_chan);
/* Set domain info */
ret = wlan_11d_send_domain_info(pmpriv, MNULL);
if (ret) {
PRINTM(MERROR,
"11D: Error sending domain info to FW\n");
}
}
LEAVE();
return ret;
}
示例11: wlan_11d_parse_dnld_countryinfo
/**
* @brief This function parses country info from AP and
* download country info to FW
*
* @param pmpriv A pointer to mlan_private structure
* @param pbss_desc A pointer to BSS descriptor
*
* @return MLAN_STATUS_SUCCESS or MLAN_STATUS_FAILURE
*/
mlan_status
wlan_11d_parse_dnld_countryinfo(mlan_private * pmpriv,
BSSDescriptor_t * pbss_desc)
{
mlan_status ret = MLAN_STATUS_SUCCESS;
mlan_adapter *pmadapter = pmpriv->adapter;
parsed_region_chan_11d_t region_chan;
parsed_region_chan_11d_t bssdesc_region_chan;
t_u32 i, j;
ENTER();
/* Only valid if 11D is enabled */
if (wlan_11d_is_enabled(pmpriv)) {
memset(pmadapter, ®ion_chan, 0,
sizeof(parsed_region_chan_11d_t));
memset(pmadapter, &bssdesc_region_chan, 0,
sizeof(parsed_region_chan_11d_t));
memcpy(pmadapter, ®ion_chan,
&pmadapter->parsed_region_chan,
sizeof(parsed_region_chan_11d_t));
if (pbss_desc) {
/* Parse domain info if available */
ret = wlan_11d_parse_domain_info(pmadapter,
&pbss_desc->
country_info,
(t_u8) pbss_desc->
bss_band,
&bssdesc_region_chan);
if (ret == MLAN_STATUS_SUCCESS) {
/* Update the channel-power table */
for (i = 0;
((i < bssdesc_region_chan.no_of_chan)
&& (i < MAX_NO_OF_CHAN)); i++) {
for (j = 0;
((j < region_chan.no_of_chan)
&& (j < MAX_NO_OF_CHAN)); j++) {
/*
* Channel already exists, use minimum of existing
* tx power and tx_power received from
* country info of the current AP
*/
if (region_chan.chan_pwr[i].
chan ==
bssdesc_region_chan.
chan_pwr[j].chan &&
region_chan.chan_pwr[i].
band ==
bssdesc_region_chan.
chan_pwr[j].band) {
region_chan.chan_pwr[j].
pwr =
MIN(region_chan.
chan_pwr[j].
pwr,
bssdesc_region_chan.
chan_pwr[i].
pwr);
break;
}
}
}
}
}
/* Generate domain info */
wlan_11d_generate_domain_info(pmadapter, ®ion_chan);
/* Set domain info */
ret = wlan_11d_send_domain_info(pmpriv, MNULL);
if (ret) {
PRINTM(MERROR,
"11D: Error sending domain info to FW\n");
}
}
LEAVE();
return ret;
}
示例12: bt_proc_init
//.........这里部分代码省略.........
if (!priv->dev_proc[seq].proc_entry) {
PRINTM(ERROR, "BT: Could not mkdir %s!\n", m_dev->name);
ret = BT_STATUS_FAILURE;
goto done;
}
priv->dev_proc[seq].pfiles =
kmalloc(sizeof(proc_files), GFP_ATOMIC);
if (!priv->dev_proc[seq].pfiles) {
PRINTM(ERROR,
"BT: Could not alloc memory for pfile!\n");
ret = BT_STATUS_FAILURE;
goto done;
}
memcpy((u8 *) priv->dev_proc[seq].pfiles, (u8 *) proc_files,
sizeof(proc_files));
priv->dev_proc[seq].num_proc_files = ARRAY_SIZE(proc_files);
for (j = 0; j < priv->dev_proc[seq].num_proc_files; j++)
priv->dev_proc[seq].pfiles[j].pdata = NULL;
for (j = 0; j < priv->dev_proc[seq].num_proc_files; j++) {
priv->dev_proc[seq].pfiles[j].pdata =
kmalloc(priv->dev_proc[seq].pfiles[j].
num_items * sizeof(struct item_data),
GFP_ATOMIC);
if (!priv->dev_proc[seq].pfiles[j].pdata) {
PRINTM(ERROR,
"BT: Could not alloc memory for pdata!\n");
ret = BT_STATUS_FAILURE;
goto done;
}
memcpy((u8 *) priv->dev_proc[seq].pfiles[j].pdata,
(u8 *) proc_files[j].pdata,
priv->dev_proc[seq].pfiles[j].num_items *
sizeof(struct item_data));
for (i = 0; i < priv->dev_proc[seq].pfiles[j].num_items;
i++) {
if (priv->dev_proc[seq].pfiles[j].
pdata[i].flag & OFFSET_BT_DEV)
priv->dev_proc[seq].pfiles[j].pdata[i].
addr =
priv->dev_proc[seq].pfiles[j].
pdata[i].offset +
(t_ptr) & priv->bt_dev;
if (priv->dev_proc[seq].pfiles[j].
pdata[i].flag & OFFSET_BT_ADAPTER)
priv->dev_proc[seq].pfiles[j].pdata[i].
addr =
priv->dev_proc[seq].pfiles[j].
pdata[i].offset +
(t_ptr) priv->adapter;
}
priv->dev_proc[seq].pfiles[j].pbt = priv;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 26)
entry = proc_create_data(proc_files[j].name,
S_IFREG | proc_files[j].
fileflag,
priv->dev_proc[seq].proc_entry,
proc_files[j].fops,
&priv->dev_proc[seq].
pfiles[j]);
if (entry == NULL)
#else
entry = create_proc_entry(proc_files[j].name,
S_IFREG | proc_files[j].
fileflag,
priv->dev_proc[seq].
proc_entry);
if (entry) {
entry->data = &priv->dev_proc[seq].pfiles[j];
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
entry->owner = THIS_MODULE;
#endif
entry->proc_fops = proc_files[j].fops;
} else
#endif
PRINTM(MSG, "BT: Fail to create proc %s\n",
proc_files[j].name);
}
}
done:
if (ret == BT_STATUS_FAILURE) {
if (priv->dev_proc[seq].proc_entry) {
remove_proc_entry(m_dev->name, proc_mbt);
priv->dev_proc[seq].proc_entry = NULL;
}
if (priv->dev_proc[seq].pfiles) {
for (j = 0; j < priv->dev_proc[seq].num_proc_files; j++) {
if (priv->dev_proc[seq].pfiles[j].pdata) {
kfree(priv->dev_proc[seq].pfiles[j].
pdata);
priv->dev_proc[seq].pfiles[j].pdata =
NULL;
}
}
kfree(priv->dev_proc[seq].pfiles);
priv->dev_proc[seq].pfiles = NULL;
}
}
LEAVE();
return ret;
}
示例13: proc_open
/**
* @brief This function handle the generic file open
*
* @param inode A pointer to inode structure
* @param file A pointer to file structure
* @return BT_STATUS_SUCCESS or other error no.
*/
static int
proc_open(struct inode *inode, struct file *file)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 10, 0)
struct proc_private_data *priv = PDE_DATA(inode);
#else
struct proc_private_data *priv = PDE(inode)->data;
#endif
struct proc_data *pdata;
int i;
char *p;
u32 val = 0;
ENTER();
priv->pbt->adapter->skb_pending =
skb_queue_len(&priv->pbt->adapter->tx_queue);
file->private_data = kzalloc(sizeof(struct proc_data), GFP_KERNEL);
if (file->private_data == NULL) {
PRINTM(ERROR, "BT: Can not alloc mem for proc_data\n");
LEAVE();
return -ENOMEM;
}
pdata = (struct proc_data *)file->private_data;
pdata->rdbuf = kmalloc(priv->bufsize, GFP_KERNEL);
if (pdata->rdbuf == NULL) {
PRINTM(ERROR, "BT: Can not alloc mem for rdbuf\n");
kfree(file->private_data);
LEAVE();
return -ENOMEM;
}
if (priv->fileflag == DEFAULT_FILE_PERM) {
pdata->wrbuf = kzalloc(priv->bufsize, GFP_KERNEL);
if (pdata->wrbuf == NULL) {
PRINTM(ERROR, "BT: Can not alloc mem for wrbuf\n");
kfree(pdata->rdbuf);
kfree(file->private_data);
return -ENOMEM;
}
pdata->maxwrlen = priv->bufsize;
pdata->on_close = proc_on_close;
}
p = pdata->rdbuf;
for (i = 0; i < priv->num_items; i++) {
if (priv->pdata[i].size == 1)
val = *((u8 *) priv->pdata[i].addr);
else if (priv->pdata[i].size == 2)
val = *((u16 *) priv->pdata[i].addr);
else if (priv->pdata[i].size == 4)
val = *((u32 *) priv->pdata[i].addr);
if (priv->pdata[i].flag & SHOW_INT)
p += sprintf(p, "%s=%d\n", priv->pdata[i].name, val);
else if (priv->pdata[i].flag & SHOW_HEX)
p += sprintf(p, "%s=0x%x\n", priv->pdata[i].name, val);
else if (priv->pdata[i].flag & SHOW_STRING) {
if (!strncmp
(priv->pdata[i].name, "sdcmd52rw",
strlen("sdcmd52rw"))) {
sd_read_cmd52_val(bpriv);
form_cmd52_string(bpriv);
}
p += sprintf(p, "%s=%s\n", priv->pdata[i].name,
(char *)priv->pdata[i].addr);
}
}
pdata->rdlen = strlen(pdata->rdbuf);
LEAVE();
return BT_STATUS_SUCCESS;
}
示例14: _cairo_xynth_surface_composite_trapezoids
static cairo_int_status_t _cairo_xynth_surface_composite_trapezoids (cairo_operator_t cairo_operator, cairo_pattern_t *pattern, void *abstract_surface, cairo_antialias_t antialias, int src_x, int src_y, int dst_x, int dst_y, unsigned int width, unsigned int height, cairo_trapezoid_t *traps, int num_traps)
{
int i;
int mask_bpp;
int mask_stride;
s_render_t *mask;
unsigned char *mask_data;
cairo_int_status_t status;
cairo_xynth_surface_t *src;
cairo_xynth_surface_t *dst;
s_render_trap_t *render_traps;
S_RENDER_FORMAT render_format;
cairo_surface_attributes_t attributes;
ENTER();
dst = (cairo_xynth_surface_t *) abstract_surface;
if (num_traps > 0) {
render_traps = (s_render_trap_t *) malloc(sizeof(s_render_trap_t) * num_traps);
if (render_traps == NULL) {
LEAVE();
status = CAIRO_STATUS_NO_MEMORY;
goto out0;
}
} else {
num_traps = 0;
render_traps = NULL;
}
for (i = 0; i < num_traps; i++) {
render_traps[i].top = traps[i].top;
render_traps[i].bottom = traps[i].bottom;
render_traps[i].left1x = traps[i].left.p1.x;
render_traps[i].left2x = traps[i].left.p2.x;
render_traps[i].right1x = traps[i].right.p1.x;
render_traps[i].right2x = traps[i].right.p2.x;
render_traps[i].left1y = traps[i].left.p1.y;
render_traps[i].left2y = traps[i].left.p2.y;
render_traps[i].right1y = traps[i].right.p1.y;
render_traps[i].right2y = traps[i].right.p2.y;
}
if (cairo_operator == CAIRO_OPERATOR_ADD &&
_cairo_pattern_is_opaque_solid (pattern) &&
dst->cairo.content == CAIRO_CONTENT_ALPHA &&
!dst->render->has_clip &&
antialias != CAIRO_ANTIALIAS_NONE) {
s_render_add_trapezoid(dst->render, 0, 0, num_traps, render_traps);
free(render_traps);
return CAIRO_STATUS_SUCCESS;
}
status = _cairo_pattern_acquire_surface(pattern, &dst->cairo, src_x, src_y, width, height, (cairo_surface_t **) &src, &attributes);
if (status) {
goto out1;
}
status = _cairo_xynth_surface_set_attributes(src, &attributes);
if (status) {
goto out2;
}
switch (antialias) {
case CAIRO_ANTIALIAS_NONE:
render_format = S_RENDER_FORMAT_A1;
mask_stride = (width + 31) / 8;
mask_bpp = 1;
break;
case CAIRO_ANTIALIAS_GRAY:
case CAIRO_ANTIALIAS_SUBPIXEL:
case CAIRO_ANTIALIAS_DEFAULT:
default:
render_format = S_RENDER_FORMAT_A8;
mask_stride = (width + 3) & ~3;
mask_bpp = 8;
break;
}
mask_data = calloc(1, mask_stride * height);
if (!mask_data) {
status = CAIRO_STATUS_NO_MEMORY;
goto out3;
}
s_render_init_for_data(&mask, mask_data, render_format, width, height, mask_bpp, mask_stride);
s_render_add_trapezoid(mask, - dst_x, - dst_y, num_traps, render_traps);
s_render_composite(_cairo_xynth_operator(cairo_operator),
src->render,
mask,
dst->render,
src_x + attributes.x_offset,
src_y + attributes.y_offset,
0, 0,
dst_x, dst_y,
width, height);
if (!_cairo_operator_bounded_by_mask(cairo_operator)) {
status = _cairo_surface_composite_shape_fixup_unbounded(&dst->cairo,
&attributes, src->render->width, src->render->height,
width, height,
src_x, src_y,
0, 0,
dst_x, dst_y, width, height);
}
s_render_uninit(mask);
out3: free(mask_data);
out2: _cairo_pattern_release_surface(pattern, &src->cairo, &attributes);
out1: free(render_traps);
out0: LEAVE();
return 0;
//.........这里部分代码省略.........
示例15: gnc_dbi_session_begin
template <DbType T> void
gnc_dbi_session_begin (QofBackend* qbe, QofSession* session,
const char* book_id, gboolean ignore_lock,
gboolean create, gboolean force)
{
GncDbiBackend* be = (GncDbiBackend*)qbe;
GncDbiTestResult dbi_test_result = GNC_DBI_PASS;
PairVec options;
g_return_if_fail (qbe != nullptr);
g_return_if_fail (session != nullptr);
g_return_if_fail (book_id != nullptr);
ENTER (" ");
/* Split the book-id
* Format is protocol://username:[email protected]:port/dbname
where username, password and port are optional) */
UriStrings uri(book_id);
if (T == DbType::DBI_PGSQL)
{
if (uri.m_portnum == 0)
uri.m_portnum = PGSQL_DEFAULT_PORT;
/* Postgres's SQL interface coerces identifiers to lower case, but the
* C interface is case-sensitive. This results in a mixed-case dbname
* being created (with a lower case name) but then dbi can't conect to
* it. To work around this, coerce the name to lowercase first. */
auto lcname = g_utf8_strdown (uri.dbname(), -1);
uri.m_dbname = std::string{lcname};
g_free(lcname);
}
be->connect(nullptr);
auto conn = conn_setup<T>(qbe, options, uri);
if (conn == nullptr)
{
LEAVE("Error");
return;
}
be->set_exists(true); //May be unset in the error handler.
auto result = dbi_conn_connect (conn);
if (result == 0)
{
if (T == DbType::DBI_MYSQL)
adjust_sql_options (conn);
if(!conn_test_dbi_library(conn, qbe))
{
dbi_conn_close(conn);
LEAVE("Error");
return;
}
if (create && !force && save_may_clobber_data (conn,
uri.quote_dbname(T)))
{
qof_backend_set_error (qbe, ERR_BACKEND_STORE_EXISTS);
PWARN ("Databse already exists, Might clobber it.");
dbi_conn_close(conn);
LEAVE("Error");
return;
}
}
else
{
if (be->exists())
{
PERR ("Unable to connect to database '%s'\n", uri.dbname());
qof_backend_set_error (qbe, ERR_BACKEND_SERVER_ERR);
dbi_conn_close(conn);
LEAVE("Error");
return;
}
if (create)
{
if (!create_database(T, qbe, conn, uri.quote_dbname(T).c_str()))
{
dbi_conn_close(conn);
LEAVE("Error");
return;
}
conn = conn_setup<T>(qbe, options, uri);
result = dbi_conn_connect (conn);
if (result < 0)
{
PERR ("Unable to create database '%s'\n", uri.dbname());
qof_backend_set_error (qbe, ERR_BACKEND_SERVER_ERR);
dbi_conn_close(conn);
LEAVE("Error");
return;
}
if (T == DbType::DBI_MYSQL)
adjust_sql_options (conn);
if (!conn_test_dbi_library(conn, qbe))
{
if (T == DbType::DBI_PGSQL)
dbi_conn_select_db (conn, "template1");
//.........这里部分代码省略.........