本文整理汇总了C++中down_timeout函数的典型用法代码示例。如果您正苦于以下问题:C++ down_timeout函数的具体用法?C++ down_timeout怎么用?C++ down_timeout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了down_timeout函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wait
/*****************************************************************************
Function : VOS_SmP
Description: Lock the resource for synchronization, if the resource is none
then block, otherwise the number of the resource --
Input : ulSmID -- the ID of the resource to lock
ulTimeOutInMillSec -- the time to wait(0 for ever)
Return : VOS_OK on success and errno on failure
*****************************************************************************/
VOS_UINT32 VOS_SmP( VOS_SEM Sm_ID, VOS_UINT32 ulTimeOutInMillSec )
{
SEM_CONTROL_BLOCK *temp_Ptr;
VOS_INT32 timeintick;
VOS_INT lRetValue;
temp_Ptr = (SEM_CONTROL_BLOCK *)Sm_ID;
if ( temp_Ptr != temp_Ptr->SemId )
{
VOS_SetErrorNo(VOS_ERRNO_SEMA4_P_IDERR);
return (VOS_ERRNO_SEMA4_P_IDERR);
}
if (VOS_SEM_CTRL_BLK_IDLE == temp_Ptr->Flag)
{
VOS_SetErrorNo(VOS_ERRNO_SEMA4_P_NOTACTIVE);
return(VOS_ERRNO_SEMA4_P_NOTACTIVE);
}
if (ulTimeOutInMillSec == 0)
{
down(&(temp_Ptr->sem));
return VOS_OK;
}
timeintick = ((ulTimeOutInMillSec*HZ)/1000);
lRetValue = down_timeout(&(temp_Ptr->sem), timeintick);
if ( VOS_OK == lRetValue )
{
return VOS_OK;
}
else if ( -ETIME == lRetValue )
{
VOS_SetErrorNo(VOS_ERRNO_SEMA4_P_TIMEOUT);
return VOS_ERRNO_SEMA4_P_TIMEOUT;
}
else
{
}
VOS_SetErrorNo (VOS_ERRNO_SEMA4_P_CANOTP);
return VOS_ERRNO_SEMA4_P_CANOTP;
}
开发者ID:XePeleato,项目名称:android_kernel_huawei_venus,代码行数:56,代码来源:linux_sem.c
示例2: hwSimIsDone
int hwSimIsDone(int timeout)
{
long jeffies;
if(timeout == -1)
{
if(down_interruptible(&hwSimInfo.simIsDone) == 0)
return DV_OK;
else
return DV_ERROR;
}
jeffies = msecs_to_jiffies(timeout);
if(down_timeout(&hwSimInfo.simIsDone, jeffies) == 0)
return DV_OK;
else
return DV_ERROR;
}
开发者ID:abgoyal,项目名称:alcatel_ot_4020D_kernel,代码行数:18,代码来源:hw_sim.c
示例3: ath6kl_sdio_init_msm
void ath6kl_sdio_init_msm(void)
{
int ret;
sema_init(&wifi_control_sem, 1);
down(&wifi_control_sem);
ret = platform_driver_register(&ath6kl_sdio_device);
/* Waiting callback after platform_driver_register */
if (down_timeout(&wifi_control_sem, msecs_to_jiffies(5000)) != 0) {
ret = -EINVAL;
printk(KERN_INFO "platform_driver_register timeout\n");
return;
}
return;
}
开发者ID:ShawnOfMisfit,项目名称:ambarella,代码行数:18,代码来源:msm.c
示例4: connection_read_data
size_t connection_read_data(struct connection *conn, void *buffer, uint32_t len,
int32_t timeout)
{
size_t ret = 0;
MCDRV_ASSERT(buffer != NULL);
MCDRV_ASSERT(conn->socket_descriptor != NULL);
MCDRV_DBG_VERBOSE(mc_kapi, "read data len = %u for PID = %u",
len, conn->sequence_magic);
do {
/*
* Wait until data is available or timeout
* msecs_to_jiffies(-1) -> wait forever for the sem
*/
if (down_timeout(&(conn->data_available_sem),
msecs_to_jiffies(timeout))) {
MCDRV_DBG_VERBOSE(mc_kapi,
"Timeout reading the data sem");
ret = -2;
break;
}
if (mutex_lock_interruptible(&(conn->data_lock))) {
MCDRV_DBG_ERROR(mc_kapi,
"interrupted reading the data sem");
ret = -1;
break;
}
/* Have data, use it */
if (conn->data_len > 0)
ret = connection_read_data_msg(conn, buffer, len);
mutex_unlock(&(conn->data_lock));
/* There is still some data left */
if (conn->data_len > 0)
up(&conn->data_available_sem);
} while (0);
return ret;
}
开发者ID:CobraJet93,项目名称:kernel-3.10.54,代码行数:44,代码来源:connection.c
示例5: KREE_ServSemaphoreDownTimeout
TZ_RESULT KREE_ServSemaphoreDownTimeout(u32 op, u8 param[REE_SERVICE_BUFFER_SIZE])
{
struct semaphore *sema;
u32 *in;
long jiffies;
int *out;
int ret;
in = (u32 *) ¶m[0];
sema = (struct semaphore *)in[0];
jiffies = (long)in[1];
ret = down_timeout(sema, jiffies);
out = (int *)¶m[0];
*out = ret;
return TZ_RESULT_SUCCESS;
}
开发者ID:Scorpio92,项目名称:mediatek,代码行数:19,代码来源:tz_sys_ipc.c
示例6: wl_android_wifictrl_func_add
int wl_android_wifictrl_func_add(void)
{
int ret = 0;
sema_init(&wifi_control_sem, 0);
ret = wifi_add_dev();
if (ret) {
DHD_ERROR(("%s: platform_driver_register failed\n", __FUNCTION__));
return ret;
}
g_wifidev_registered = 1;
if (down_timeout(&wifi_control_sem, msecs_to_jiffies(1000)) != 0) {
ret = -EINVAL;
DHD_ERROR(("%s: platform_driver_register timeout\n", __FUNCTION__));
}
return ret;
}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:20,代码来源:wl_android.c
示例7: rtw_android_wifictrl_func_add
int rtw_android_wifictrl_func_add(void)
{
int ret = 0;
sema_init(&wifi_control_sem, 0);
ret = wifi_add_dev();
if (ret) {
DBG_871X("%s: platform_driver_register failed\n", __FUNCTION__);
return ret;
}
g_wifidev_registered = 1;
/* Waiting callback after platform_driver_register is done or exit with error */
if (down_timeout(&wifi_control_sem, msecs_to_jiffies(1000)) != 0) {
ret = -EINVAL;
DBG_871X("%s: platform_driver_register timeout\n", __FUNCTION__);
}
return ret;
}
开发者ID:Whiteha,项目名称:rtl8812au,代码行数:20,代码来源:rtw_android.c
示例8: tmsi_release
static int tmsi_release(struct inode *inode, struct file *file) {
struct tmsi_data* dev;
int retval = 0;
info("Tmsi Release\n");
dev = (struct tmsi_data*) file->private_data;
if (!dev)
return -ENODEV;
dev->releasing = 1;
if (dev->fei)
{
//We have front end info, so just to be sure, we send a stop message
info("Sending stop request\n");
retval = tmsi_write_data(dev, dev->fei, dev->fei_size);
//We are waiting for stop confirmation, for a while....
down_timeout(dev->release_sem, HZ);
//It will be deallocated in write callback
dev->fei=NULL;
}
tmsi_release_dev(dev);
return retval;
}
开发者ID:niklasrogers,项目名称:openbci,代码行数:21,代码来源:tmsi.c
示例9: ve_spc_read_sys_cfg
static int ve_spc_read_sys_cfg(int func, int offset, uint32_t *data)
{
int ret;
if (down_timeout(&info->sem, usecs_to_jiffies(TIMEOUT_US)))
return -ETIME;
init_completion(&info->done);
info->cur_rsp_mask = RESPONSE_MASK(SPC_SYS_CFG);
/* Set the control value */
writel(SYSCFG_START | func | offset >> 2, info->baseaddr + COMMS);
ret = ve_spc_waitforcompletion(SPC_SYS_CFG);
if (ret == 0)
*data = readl(info->baseaddr + SYSCFG_RDATA);
info->cur_rsp_mask = 0;
up(&info->sem);
return ret;
}
开发者ID:BinVul,项目名称:linux2.6.32,代码行数:22,代码来源:spc.c
示例10: tmsi_read
static ssize_t tmsi_read(struct file *file, char *buffer, size_t count, loff_t *ppos) {
struct tmsi_data* dev;
char* temp_buffer = NULL;
int retval = 0;
size_t true_count;
dev = (struct tmsi_data*) file->private_data;
if (down_timeout(dev->fifo_sem, HZ / 2) != 0)
return -ETIME;
while (down_trylock(dev->fifo_sem) == 0);
temp_buffer = kmalloc(count, GFP_KERNEL);
if (!temp_buffer) {
retval = -ENOMEM;
goto exit;
}
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,35)
true_count = kfifo_out_spinlocked(dev->packet_buffer, temp_buffer, count, &dev->buffer_lock);
#elif LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32)
true_count = kfifo_out_locked(dev->packet_buffer, temp_buffer, count, &dev->buffer_lock);
#else
true_count = kfifo_get(dev->packet_buffer, temp_buffer, count);
#endif
/* if the read was successful, copy the data to userspace */
if (copy_to_user(buffer, temp_buffer, true_count))
retval = -EFAULT;
else
retval = true_count;
kfree(temp_buffer);
exit:
if (kfifo_len(dev->packet_buffer) > 0)
up(dev->fifo_sem);
return retval;
}
开发者ID:niklasrogers,项目名称:openbci,代码行数:39,代码来源:tmsi.c
示例11: ttyio_in
static unsigned char ttyio_in(int timeout)
{
struct spk_ldisc_data *ldisc_data = speakup_tty->disc_data;
char rv;
if (down_timeout(&ldisc_data->sem, usecs_to_jiffies(timeout)) == -ETIME) {
if (timeout)
pr_warn("spk_ttyio: timeout (%d) while waiting for input\n",
timeout);
return 0xff;
}
rv = ldisc_data->buf;
/* Make sure we have read buf before we set buf_free to let
* the producer overwrite it */
mb();
ldisc_data->buf_free = true;
/* Let TTY push more characters */
tty_schedule_flip(speakup_tty->port);
return rv;
}
开发者ID:mkrufky,项目名称:linux,代码行数:22,代码来源:spk_ttyio.c
示例12: acpi_os_wait_semaphore
/*
* TODO: Support for units > 1?
*/
acpi_status acpi_os_wait_semaphore(acpi_handle handle, u32 units, u16 timeout)
{
acpi_status status = AE_OK;
struct semaphore *sem = (struct semaphore *)handle;
long jiffies;
int ret = 0;
if (!sem || (units < 1))
return AE_BAD_PARAMETER;
if (units > 1)
return AE_SUPPORT;
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Waiting for semaphore[%p|%d|%d]\n",
handle, units, timeout));
if (timeout == ACPI_WAIT_FOREVER)
jiffies = MAX_SCHEDULE_TIMEOUT;
else
jiffies = msecs_to_jiffies(timeout);
ret = down_timeout(sem, jiffies);
if (ret)
status = AE_TIME;
if (ACPI_FAILURE(status)) {
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Failed to acquire semaphore[%p|%d|%d], %s",
handle, units, timeout,
acpi_format_exception(status)));
} else {
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX,
"Acquired semaphore[%p|%d|%d]", handle,
units, timeout));
}
return status;
}
开发者ID:AiWinters,项目名称:linux,代码行数:41,代码来源:osl.c
示例13: spin_lock_irqsave
static struct sk_buff *dequeue_rx_queue(struct rx_queue *q, long timeout) {
unsigned long flags;
struct sk_buff *skb = NULL;
if (timeout == 0) {
if (0==down_interruptible(&q->rx_sem)) {
spin_lock_irqsave(&q->spin, flags);
skb = q->skb;
q->skb = NULL;
while(!down_trylock(&q->rx_sem));
spin_unlock_irqrestore(&q->spin, flags);
}
} else if (0==down_timeout(&q->rx_sem, msecs_to_jiffies(timeout))) {
spin_lock_irqsave(&q->spin, flags);
skb = q->skb;
q->skb = NULL;
while(!down_trylock(&q->rx_sem)){
printk(KERN_ERR "Spinning\n");
}
spin_unlock_irqrestore(&q->spin, flags);
}
return skb;
}
开发者ID:dantard,项目名称:unizar-rt-wmp-ros-pkg,代码行数:23,代码来源:rt_wmp.c
示例14: WILC_SemaphoreAcquire
WILC_ErrNo WILC_SemaphoreAcquire(WILC_SemaphoreHandle* pHandle,
tstrWILC_SemaphoreAttrs* pstrAttrs)
{
WILC_ErrNo s32RetStatus = WILC_SUCCESS;
#ifndef CONFIG_WILC_SEMAPHORE_TIMEOUT
while(down_interruptible(pHandle)); //jude
#else
if(pstrAttrs == WILC_NULL)
{
down(pHandle);
}
else
{
s32RetStatus = down_timeout(pHandle, msecs_to_jiffies(pstrAttrs->u32TimeOut));
}
#endif
if(s32RetStatus == 0)
{
return WILC_SUCCESS;
}
else if (s32RetStatus == -ETIME)
{
return WILC_TIMEOUT;
}
else
{
return WILC_FAIL;
}
return WILC_SUCCESS;
}
开发者ID:demo4sc,项目名称:patch,代码行数:36,代码来源:wilc_semaphore.c
示例15: validate_lbr
void validate_lbr(void) {
#ifdef ARMOR_JIT
uint8_t hash[DIGEST_LENGTH];
int i;
struct lbr_t lbr;
struct timeval time;
unsigned long jit_start_j, jit_stop_j, jit_delta_j;
printk("total validate lbr state %ld\n",total_count++);
get_cpu();
get_lbr(&lbr);
dump_lbr(&lbr);
put_cpu();
if (disable_jit) {
printk("[validation] -- WARNING -- JIT disabled!\n");
return;
}
printdj(true,"[validation] JIT: Acquiring lock...\n");
mutex_lock(&validation_lock);
printdj(true,"[validation] JIT: Lookup\n");
ARMOR_STAT_INC(jit_lookups);
/* Compute a hash of the lbr and look it up in the cache. */
hash_lbr(hash,&lbr);
for (i = 0; i < jit_cache.hashes; i++) {
if (memcmp(jit_cache.hash[i], hash, DIGEST_LENGTH) == 0) {
ARMOR_STAT_INC(jit_cache_hits);
#ifdef ARMOR_DEBUG_JIT
printk("[validation] LBR state is valid (found in JIT cache)\n");
#endif
mutex_unlock(&validation_lock);
return;
}
}
/* Not found in cache. Let's ask Dennis. Using Enes' semaphore design. */
ARMOR_STAT_INC(jit_requests);
jit_work = &lbr;
printdj(true, "[validation] JIT: Request\n");
/* Start the timers. */
jit_start_j = jiffies;
up(&jit_work_cond);
printdj(true, "[validation] JIT: Waiting\n");
if (down_timeout(&jit_result_cond, jit_waittime) < 0) {
printk("[validation] JIT: Timeout\n");
ARMOR_STAT_INC(jit_timeouts);
disable_jit = 1;
mutex_unlock(&validation_lock);
return;
}
/* Stop the timers. */
jit_stop_j = jiffies;
jit_delta_j = jit_stop_j - jit_start_j;
/* JIT may be faster than we can measure jiffies. If this happens, assume a
* half jiffie was used.
* http://stackoverflow.com/questions/10392735/am-i-too-fast-to-count-jiffies
*/
if (jit_delta_j == 0) jit_delta_j = stats.jit_lookups % 2;
printdj(true, "That took us %lu jiffies\n", jit_delta_j);
jiffies_to_timeval(jit_delta_j, &time);
ARMOR_STAT_ADD(jit_sec, time.tv_sec);
ARMOR_STAT_ADD(jit_usec, time.tv_usec);
printdj(true, "[validation] JIT: Processing result\n");
if (jit_result == 0) {
printk("[validation] -- WARNING -- LBR state rendered *INVALID* by jit-analyzer\n");
ARMOR_STAT_INC(jit_misses);
// kill_pid(task_pid(current), SIGKILL, 1);
printk("[validation] -- WARNING -- ASSUMING VALID\n");
goto assume_valid;
}
if (jit_result == 2) {
printk("[validation] -- WARNING -- LBR state not validated due to uninstrumentable function\n");
ARMOR_STAT_INC(jit_unsupported);
printk("[validation] -- WARNING -- ASSUMING VALID\n");
goto assume_valid;
}
if (jit_result == 1) {
ARMOR_STAT_INC(jit_hits);
assume_valid:
/* Dennis' says it is ok. Let's add it to the - circular - cache so he
* can take some time off next time. */
/* TODO, this should probably be a sorted linked list so that we can do a binary search? */
memcpy(jit_cache.hash[jit_cache.hashes], hash, DIGEST_LENGTH);
jit_cache.hashes = (jit_cache.hashes + 1) % JIT_CACHE_SIZE;
#ifdef ARMOR_DEBUG_JIT
//.........这里部分代码省略.........
开发者ID:aiaxun,项目名称:KernelModule,代码行数:101,代码来源:lbr.c
示例16: cshell_recv_thread
/*lint --e{713}*/
static int cshell_recv_thread(void *arg)
{
cshell_ctx_t *cshell_ctx = &g_cshell_ctx;
u32 write_size = 0;
u32 free_buf_size = 0;
u32 send_sz = 0;
long sem_wait_jeff = SEM_WAIT_MAX_JIF;
int icc_ret = CSHELL_OK;
ACM_WR_ASYNC_INFO acm_wt_info = {0};
/* coverity[no_escape] */
while (1)
{
if(0 != down_timeout(&(cshell_ctx->cshell_recv_sem), sem_wait_jeff))
cshell_log.a2c_sem_timeout_times++;
if ((!cshell_ctx->icc_chan_opened) || (0 == g_cshell_ctx.ccshell_work_flg) || !cshell_get_bit(USB_CSHELL))
{
sem_wait_jeff = SEM_WAIT_MAX_JIF;
continue;
}
if(0 == bsp_acm_ioctl(cshell_ctx->cshell_acm_fd, (u32)ACM_IOCTL_GET_RD_BUFF, &acm_wt_info))
{
/* 获取剩余buffer长度 */
free_buf_size = CSHELL_BUFFER_SIZE - cshell_ctx->recv_mem.buf_size;
/* 获取可写入buffer的数据长度,多余部分丢弃 */
write_size = (free_buf_size < (u32)acm_wt_info.u32Size) ? free_buf_size : acm_wt_info.u32Size;
/* 将数据拷贝至缓冲buffer并更新buffer长度 */
#ifdef FEATURE_USB_ZERO_COPY
memcpy(cshell_ctx->recv_mem.buf + cshell_ctx->recv_mem.buf_size, acm_wt_info.pVirAddr, write_size);
#else
memcpy(cshell_ctx->recv_mem.buf + cshell_ctx->recv_mem.buf_size, acm_wt_info.pBuffer, write_size);
#endif
cshell_ctx->recv_mem.buf_size += write_size;
(void)bsp_acm_ioctl(cshell_ctx->cshell_acm_fd, ACM_IOCTL_RETURN_BUFF, &acm_wt_info);
}
while(cshell_ctx->recv_mem.buf_size)
{
send_sz = cshell_ctx->recv_mem.buf_size > CSHELL_MAX_SEND_SZ ? CSHELL_MAX_SEND_SZ : cshell_ctx->recv_mem.buf_size;
icc_ret = (int)bsp_icc_send((u32)ICC_CPU_MODEM, (cshell_ctx->icc_channel_id << 16), cshell_ctx->recv_mem.buf, send_sz);
if((icc_ret > (int)send_sz) || (icc_ret < 0))
{
cshell_log.a2c_send_fail_times++;
sem_wait_jeff = SEM_WAIT_JIF;
break;
}
else if(icc_ret < (int)send_sz)
{
cshell_ctx->recv_mem.buf_size -= (u32)icc_ret;
memcpy(cshell_ctx->recv_buf, cshell_ctx->recv_mem.buf+icc_ret,(cshell_ctx->recv_mem.buf_size));
memcpy(cshell_ctx->recv_mem.buf, cshell_ctx->recv_buf, (cshell_ctx->recv_mem.buf_size));
sem_wait_jeff = SEM_WAIT_JIF;
break;
}
else
{
cshell_ctx->recv_mem.buf_size -= (u32)icc_ret;
sem_wait_jeff = SEM_WAIT_MAX_JIF;
}
}
cshell_log.bluetooth_send_cmd_times += 1;
}
return 0;
}
开发者ID:fly2436732935,项目名称:android_kernel_honor7_PLK-AL10_PLK-TL01H_PLK-UL00_PLK-CL00_PLK-TL00,代码行数:67,代码来源:cshell.c
示例17: dhd_wifi_platform_load_sdio
static int dhd_wifi_platform_load_sdio(void)
{
int i;
int err = 0;
wifi_adapter_info_t *adapter;
BCM_REFERENCE(i);
BCM_REFERENCE(adapter);
/* Sanity check on the module parameters
* - Both watchdog and DPC as tasklets are ok
* - If both watchdog and DPC are threads, TX must be deferred
*/
if (!(dhd_watchdog_prio < 0 && dhd_dpc_prio < 0) &&
!(dhd_watchdog_prio >= 0 && dhd_dpc_prio >= 0 && dhd_deferred_tx))
return -EINVAL;
#if defined(BCMLXSDMMC)
if (dhd_wifi_platdata == NULL) {
DHD_ERROR(("DHD wifi platform data is required for Android build\n"));
return -EINVAL;
}
sema_init(&dhd_registration_sem, 0);
/* power up all adapters */
for (i = 0; i < dhd_wifi_platdata->num_adapters; i++) {
bool chip_up = FALSE;
int retry = POWERUP_MAX_RETRY;
struct semaphore dhd_chipup_sem;
adapter = &dhd_wifi_platdata->adapters[i];
DHD_ERROR(("Power-up adapter '%s'\n", adapter->name));
DHD_INFO((" - irq %d [flags %d], firmware: %s, nvram: %s\n",
adapter->irq_num, adapter->intr_flags, adapter->fw_path, adapter->nv_path));
DHD_INFO((" - bus type %d, bus num %d, slot num %d\n\n",
adapter->bus_type, adapter->bus_num, adapter->slot_num));
do {
sema_init(&dhd_chipup_sem, 0);
err = dhd_bus_reg_sdio_notify(&dhd_chipup_sem);
if (err) {
DHD_ERROR(("%s dhd_bus_reg_sdio_notify fail(%d)\n\n",
__FUNCTION__, err));
return err;
}
err = wifi_platform_set_power(adapter, TRUE, WIFI_TURNON_DELAY);
if (err) {
/* WL_REG_ON state unknown, Power off forcely */
wifi_platform_set_power(adapter, FALSE, WIFI_TURNOFF_DELAY);
continue;
} else {
wifi_platform_bus_enumerate(adapter, TRUE);
err = 0;
}
if (down_timeout(&dhd_chipup_sem, msecs_to_jiffies(POWERUP_WAIT_MS)) == 0) {
dhd_bus_unreg_sdio_notify();
chip_up = TRUE;
break;
}
DHD_ERROR(("failed to power up %s, %d retry left\n", adapter->name, retry));
dhd_bus_unreg_sdio_notify();
wifi_platform_set_power(adapter, FALSE, WIFI_TURNOFF_DELAY);
wifi_platform_bus_enumerate(adapter, FALSE);
} while (retry--);
if (!chip_up) {
DHD_ERROR(("failed to power up %s, max retry reached**\n", adapter->name));
return -ENODEV;
}
}
err = dhd_bus_register();
if (err) {
DHD_ERROR(("%s: sdio_register_driver failed\n", __FUNCTION__));
goto fail;
}
/*
* Wait till MMC sdio_register_driver callback called and made driver attach.
* It's needed to make sync up exit from dhd insmod and
* Kernel MMC sdio device callback registration
*/
err = down_timeout(&dhd_registration_sem, msecs_to_jiffies(DHD_REGISTRATION_TIMEOUT));
if (err) {
DHD_ERROR(("%s: sdio_register_driver timeout or error \n", __FUNCTION__));
dhd_bus_unregister();
goto fail;
}
return err;
fail:
/* power down all adapters */
for (i = 0; i < dhd_wifi_platdata->num_adapters; i++) {
adapter = &dhd_wifi_platdata->adapters[i];
//.........这里部分代码省略.........
开发者ID:TeamElevate,项目名称:edison,代码行数:101,代码来源:dhd_linux_platdev.c
示例18: test_rproc_msg_send
int test_rproc_msg_send(unsigned int sync_id,
unsigned char rp_id,
unsigned int msg_len,
unsigned int msg_num,
struct test_rproc_cb *rproc_cb)
{
int ret = 0;
rproc_msg_t tx_buffer[8] = {0};
rproc_msg_t ack_buffer[8] = {0};
struct semaphore *complete_sema;
unsigned int start_slice = 0;
unsigned int end_slice = 0;
unsigned int sync_task_cnt = 0;
if (sync_id > 0x3) {
printk(KERN_ERR "wrong sync id!\n");
return -1;
}
if (msg_len > 8) {
printk(KERN_ERR "illegal message length!\n");
return -1;
}
if(rproc_cb) {
down(&task_mutex_sema);
rproc_cb->sync_task_cnt--;
sync_task_cnt = rproc_cb->sync_task_cnt;
up(&task_mutex_sema);
if ((0 == sync_task_cnt)
&& (TEST_RPROC_NULL != rproc_cb->sync_sema)) {
rproc_cb->start_slice = test_rproc_get_slice();
up(rproc_cb->sync_sema);
}
/*进程同步*/
if (TEST_RPROC_NULL != rproc_cb->sync_sema) {
down(rproc_cb->sync_sema);
up(rproc_cb->sync_sema);
}
}
tx_buffer[0] = (OBJ_TEST << 16) | (CMD_TEST << 8)/*0x00120500*/;
memcpy((void*)&tx_buffer[1], (void*)&data_buf[0], sizeof(tx_buffer) - sizeof(tx_buffer[0]));
switch(sync_id)
{
case 0:/*同步发送同步消息*/
while(msg_num--){
ret = RPROC_SYNC_SEND(rp_id,tx_buffer, msg_len,SYNC_MSG,ack_buffer,msg_len);
if (ret || (((OBJ_TEST << 16) | (CMD_TEST << 8)) != ack_buffer[0]) || (0x12345678 != ack_buffer[1])) {
printk(KERN_ERR "rproc send error, ret %d, rp %d, sync %d, ack[0x%x][0x%x]!\r\n",
ret, rp_id, sync_id, ack_buffer[0], ack_buffer[1]);
return -1;
}
if(rproc_cb)
rproc_cb->msg_count++;
}
break;
case 1:/*同步发送异步消息*/
while(msg_num--){
ret = RPROC_SYNC_SEND(rp_id ,tx_buffer, msg_len,ASYNC_MSG,NULL,0);
if (ret) {
printk(KERN_ERR "rproc send error, ret %d, rp %d, sync %d!\r\n", ret, rp_id, sync_id);
return -1;
}
if(rproc_cb)
rproc_cb->msg_count++;
}
break;
case 2:/*异步发送同步消息*/
while (msg_num--) {
complete_sema = (struct semaphore*)kmalloc(sizeof(struct semaphore), GFP_KERNEL);
sema_init(complete_sema, 0);
ret = RPROC_ASYNC_SEND(rp_id,tx_buffer,msg_len,SYNC_MSG,rporc_async_callback,complete_sema);
if (ret) {
printk(KERN_ERR "rproc send error, ret %d, rp %d, sync %d!\r\n", ret, rp_id, sync_id);
kfree(complete_sema);
return -1;
}
start_slice = test_rproc_get_slice();
if (0 != down_timeout(complete_sema, msecs_to_jiffies(1000)))
{
printk(KERN_ERR "msg_send timeout rp_id:%d rproc async send err!\r\n", rp_id);
/*如果超时,不能释放内存*/
/*kfree(complete_sema);*/
return -1;
}
end_slice = test_rproc_get_slice();
printk(KERN_INFO "async send sync msg spend %d slice!\r\n",
test_rproc_slice_diff(start_slice, end_slice));
kfree(complete_sema);
if(rproc_cb)
rproc_cb->msg_count++;
}
break;
case 3:/*异步发送异步消息*/
while (msg_num--) {
//.........这里部分代码省略.........
开发者ID:HuaweiHonor4C,项目名称:kernel_hi6210sft_mm,代码行数:101,代码来源:hisi_rproc_test.c
示例19: hifireset_task
/*****************************************************************************
函 数 名 : hifireset_task
功能描述 : 用于处理HIFI复位。
输入参数 : 无
输出参数 : 无
返 回 值 : int
*****************************************************************************/
int hifireset_task(void *arg)
{
int iresult = BSP_RESET_OK;
#ifdef _DRV_LLT_
#else
for ( ; ; )
#endif
{
down(&(g_reset_assistant_hifi.sem_wait_hifireset));
printk(KERN_INFO "%s: enter hifireset_task\n", __FUNCTION__);
printk(KERN_INFO "%s: hifi reset int is coming!\n", __FUNCTION__);
reset_for_savelog("\n=============hifi reset=============\n");
/*调用回调函数*/
iresult = hifireset_runcbfun(MDRV_RESET_CB_BEFORE);
if (BSP_RESET_OK != iresult)
{
printk(KERN_ERR "%s: fail to run cb func before hifi reset\n", __FUNCTION__);
/*复位系统*/
do_reset_system(RESET_TYPE_HIFIRESET_RUNCB_STEP1_FAIL);
return BSP_RESET_ERROR;
}
#ifdef _DRV_LLT_
#else
if (0 != down_timeout(&(g_reset_assistant_hifi.sem_wait_mcu_msg_hifireset), msecs_to_jiffies(RESET_WAIT_TIMEOUT_MAILMSG)))
{
/*复位系统*/
printk(KERN_ERR "%s: fail to get mail from mcu,reset system\n", __FUNCTION__);
/*do_reset_system(RESET_TYPE_FAILGET_MSG_FROM_MCU);*/
return BSP_RESET_ERROR;
}
printk(KERN_INFO "%s: to load hifi bin!\n", __FUNCTION__);
reset_for_savelog("To load hifi bin\n");
/*重新加载HIFI映像*/
iresult = hifireset_loadhifibin();
if (BSP_RESET_OK != iresult)
{
reset_for_savelog("fail to load hifi bin\n");
printk(KERN_ERR "%s: fail to load hifi bin! reset system\n", __FUNCTION__);
/*复位系统*/
do_reset_system(RESET_TYPE_HIFIRESET_LOAD_BIN_FAIL);
return BSP_RESET_ERROR;
}
#endif
printk(KERN_INFO "%s: to run cb fun after hifi reset!\n", __FUNCTION__);
reset_for_savelog("To run cb func after hifi reset\n");
/*HIFI加载完毕后,调用回调函数*/
iresult = hifireset_runcbfun(MDRV_RESET_CB_AFTER);
/*恢复中断使能*/
finish_reset_sub();
if (BSP_RESET_OK != iresult)
{
printk(KERN_ERR "%s: fail to run cb fun after hifi reset! reset system\n", __FUNCTION__);
/*复位系统*/
do_reset_system(RESET_TYPE_HIFIRESET_RUNCB_STEP2_FAIL);
return BSP_RESET_ERROR;
}
printk(KERN_INFO "%s: reset hifi successfully!\n", __FUNCTION__);
reset_for_savelog("hifi reset ok\n");
#ifndef _DRV_LLT_
check_doreset_for_noc();
#endif
}
}
开发者ID:debbiche,项目名称:android_kernel_huawei_p8,代码行数:87,代码来源:reset_sub_hifi.c
示例20: esp_sdio_init
static int /*__init*/ esp_sdio_init(void)
{
#define ESP_WAIT_UP_TIME_MS 11000
int err;
u64 ver;
int retry = 3;
bool powerup = false;
int edf_ret = 0;
esp_dbg(ESP_DBG_TRACE, "%s \n", __func__);
#ifdef DRIVER_VER
ver = DRIVER_VER;
esp_dbg(ESP_SHOW, "\n***** EAGLE DRIVER VER:%llx*****\n\n", ver);
#endif
edf_ret = esp_debugfs_init();
request_init_conf();
esp_wakelock_init();
esp_wake_lock();
do {
sema_init(&esp_powerup_sem, 0);
sif_platform_target_poweron();
sif_platform_rescan_card(1);
err = sdio_register_driver(&esp_sdio_dummy_driver);
if (err) {
esp_dbg(ESP_DBG_ERROR, "eagle sdio driver registration failed, error code: %d\n", err);
goto _fail;
}
if (down_timeout(&esp_powerup_sem,
msecs_to_jiffies(ESP_WAIT_UP_TIME_MS)) == 0)
{
powerup = true;
msleep(200);
break;
}
esp_dbg(ESP_SHOW, "%s ------ RETRY ------ \n", __func__);
sif_record_retry_config();
sdio_unregister_driver(&esp_sdio_dummy_driver);
sif_platform_rescan_card(0);
sif_platform_target_poweroff();
} while (retry--);
if (!powerup) {
esp_dbg(ESP_DBG_ERROR, "eagle sdio can not power up!\n");
err = -ENODEV;
goto _fail;
}
esp_dbg(ESP_SHOW, "%s power up OK\n", __func__);
sdio_unregister_driver(&esp_sdio_dummy_driver);
sif_sdio_state = ESP_SDIO_STATE_FIRST_INIT;
sema_init(&esp_powerup_sem, 0);
sdio_register_driver(&esp_sdio_driver);
if ((down_timeout(&esp_powerup_sem,
msecs_to_jiffies(ESP_WAIT_UP_TIME_MS)) == 0 ) && sif_get_ate_config() == 0) {
if(sif_sdio_state == ESP_SDIO_STATE_FIRST_NORMAL_EXIT){
sdio_unregister_driver(&esp_sdio_driver);
sif_platform_rescan_card(0);
msleep(100);
sif_platform_rescan_card(1);
sif_sdio_state = ESP_SDIO_STATE_SECOND_INIT;
sdio_register_driver(&esp_sdio_driver);
}
}
esp_register_early_suspend();
esp_wake_unlock();
return err;
_fail:
esp_wake_unlock();
esp_wakelock_destroy();
return err;
//.........这里部分代码省略.........
开发者ID:Icenowy,项目名称:esp8089,代码行数:101,代码来源:sdio_sif_esp.c
注:本文中的down_timeout函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论