示例#1
0
void rtw_init_mlme_timer(_adapter *padapter)
{
	struct	mlme_priv *pmlmepriv = &padapter->mlmepriv;

#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
	_init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, rtw_join_timeout_handler, padapter);
	_init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, _rtw_scan_timeout_handler, padapter);
	_init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter);
	#ifdef CONFIG_SET_SCAN_DENY_TIMER
	_init_timer(&(pmlmepriv->set_scan_deny_timer), padapter->pnetdev, _rtw_set_scan_deny_timer_hdl, padapter);
	#endif
#else
	timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0);
	timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0);
	timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0);
	#ifdef CONFIG_SET_SCAN_DENY_TIMER
	timer_setup(&pmlmepriv->set_scan_deny_timer, _rtw_set_scan_deny_timer_hdl, 0);
	#endif
#endif

#ifdef RTK_DMP_PLATFORM
	_init_workitem(&(pmlmepriv->Linkup_workitem), Linkup_workitem_callback, padapter);
	_init_workitem(&(pmlmepriv->Linkdown_workitem), Linkdown_workitem_callback, padapter);
#endif

}
static NwGtpv1uRcT gtpv1u_start_timer_wrapper(
  NwGtpv1uTimerMgrHandleT tmrMgrHandle,
  uint32_t                  timeoutSec,
  uint32_t                  timeoutUsec,
  uint32_t                  tmrType,
  void                   *timeoutArg,
  NwGtpv1uTimerHandleT   *hTmr)
{

  NwGtpv1uRcT rc = NW_GTPV1U_OK;
  long        timer_id;

  if (tmrType == NW_GTPV1U_TMR_TYPE_ONE_SHOT) {
    timer_setup(timeoutSec,
                timeoutUsec,
                TASK_GTPV1_U,
                INSTANCE_DEFAULT,
                TIMER_ONE_SHOT,
                timeoutArg,
                &timer_id);
  } else {
    timer_setup(timeoutSec,
                timeoutUsec,
                TASK_GTPV1_U,
                INSTANCE_DEFAULT,
                TIMER_PERIODIC,
                timeoutArg,
                &timer_id);
  }

  return rc;
}
static
NwRcT s11_sgw_start_timer_wrapper(
  NwGtpv2cTimerMgrHandleT tmrMgrHandle,
  uint32_t                  timeoutSec,
  uint32_t                  timeoutUsec,
  uint32_t                  tmrType,
  void                   *timeoutArg,
  NwGtpv2cTimerHandleT   *hTmr)
{
  long        timer_id;
  int         ret = 0;

  if (tmrType == NW_GTPV2C_TMR_TYPE_REPETITIVE) {
    ret = timer_setup(timeoutSec,
                      timeoutUsec,
                      TASK_S11,
                      INSTANCE_DEFAULT,
                      TIMER_PERIODIC,
                      timeoutArg,
                      &timer_id);
  } else {
    ret = timer_setup(timeoutSec,
                      timeoutUsec,
                      TASK_S11,
                      INSTANCE_DEFAULT,
                      TIMER_ONE_SHOT,
                      timeoutArg,
                      &timer_id);
  }

  return ret == 0 ? NW_OK : NW_FAILURE;
}
示例#4
0
void init_mlme_ext_timer(struct adapter *padapter)
{
	struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;

	timer_setup(&pmlmeext->survey_timer, survey_timer_hdl, 0);
	timer_setup(&pmlmeext->link_timer, link_timer_hdl, 0);
}
示例#5
0
文件: rtw_pwrctrl.c 项目: Lyude/linux
void rtw_init_pwrctrl_priv(struct adapter *padapter)
{
	struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter);

	sema_init(&pwrctrlpriv->lock, 1);
	sema_init(&pwrctrlpriv->check_32k_lock, 1);
	pwrctrlpriv->rf_pwrstate = rf_on;
	pwrctrlpriv->ips_enter_cnts = 0;
	pwrctrlpriv->ips_leave_cnts = 0;
	pwrctrlpriv->bips_processing = false;

	pwrctrlpriv->ips_mode = padapter->registrypriv.ips_mode;
	pwrctrlpriv->ips_mode_req = padapter->registrypriv.ips_mode;

	pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL;
	pwrctrlpriv->pwr_state_check_cnts = 0;
	pwrctrlpriv->bInternalAutoSuspend = false;
	pwrctrlpriv->bInSuspend = false;
	pwrctrlpriv->bkeepfwalive = false;

	pwrctrlpriv->LpsIdleCount = 0;
	pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/*  PS_MODE_MIN; */
	pwrctrlpriv->bLeisurePs = pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE;

	pwrctrlpriv->bFwCurrentInPSMode = false;

	pwrctrlpriv->rpwm = 0;
	pwrctrlpriv->cpwm = PS_STATE_S4;

	pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE;
	pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps;
	pwrctrlpriv->bcn_ant_mode = 0;
	pwrctrlpriv->dtim = 0;

	pwrctrlpriv->tog = 0x80;

	rtw_hal_set_hwreg(padapter, HW_VAR_SET_RPWM, (u8 *)(&pwrctrlpriv->rpwm));

	_init_workitem(&pwrctrlpriv->cpwm_event, cpwm_event_callback, NULL);

	pwrctrlpriv->brpwmtimeout = false;
	pwrctrlpriv->adapter = padapter;
	_init_workitem(&pwrctrlpriv->rpwmtimeoutwi, rpwmtimeout_workitem_callback, NULL);
	timer_setup(&pwrctrlpriv->pwr_rpwm_timer, pwr_rpwm_timeout_handler, 0);
	timer_setup(&pwrctrlpriv->pwr_state_check_timer,
		    pwr_state_check_handler, 0);

	pwrctrlpriv->wowlan_mode = false;
	pwrctrlpriv->wowlan_ap_mode = false;

#ifdef CONFIG_PNO_SUPPORT
	pwrctrlpriv->pno_inited = false;
	pwrctrlpriv->pnlo_info = NULL;
	pwrctrlpriv->pscan_info = NULL;
	pwrctrlpriv->pno_ssid_list = NULL;
	pwrctrlpriv->pno_in_resume = true;
#endif
}
示例#6
0
void rtw_init_mlme_timer(struct adapter *padapter)
{
	struct mlme_priv *pmlmepriv = &padapter->mlmepriv;

	timer_setup(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler, 0);
	timer_setup(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler, 0);
	timer_setup(&pmlmepriv->dynamic_chk_timer,
		    rtw_dynamic_check_timer_handlder, 0);
}
示例#7
0
static int rxe_qp_init_req(struct rxe_dev *rxe, struct rxe_qp *qp,
			   struct ib_qp_init_attr *init,
			   struct ib_ucontext *context, struct ib_udata *udata)
{
	int err;
	int wqe_size;

	err = sock_create_kern(&init_net, AF_INET, SOCK_DGRAM, 0, &qp->sk);
	if (err < 0)
		return err;
	qp->sk->sk->sk_user_data = qp;

	qp->sq.max_wr		= init->cap.max_send_wr;
	qp->sq.max_sge		= init->cap.max_send_sge;
	qp->sq.max_inline	= init->cap.max_inline_data;

	wqe_size = max_t(int, sizeof(struct rxe_send_wqe) +
			 qp->sq.max_sge * sizeof(struct ib_sge),
			 sizeof(struct rxe_send_wqe) +
			 qp->sq.max_inline);

	qp->sq.queue = rxe_queue_init(rxe,
				      &qp->sq.max_wr,
				      wqe_size);
	if (!qp->sq.queue)
		return -ENOMEM;

	err = do_mmap_info(rxe, udata, true,
			   context, qp->sq.queue->buf,
			   qp->sq.queue->buf_size, &qp->sq.queue->ip);

	if (err) {
		kvfree(qp->sq.queue->buf);
		kfree(qp->sq.queue);
		return err;
	}

	qp->req.wqe_index	= producer_index(qp->sq.queue);
	qp->req.state		= QP_STATE_RESET;
	qp->req.opcode		= -1;
	qp->comp.opcode		= -1;

	spin_lock_init(&qp->sq.sq_lock);
	skb_queue_head_init(&qp->req_pkts);

	rxe_init_task(rxe, &qp->req.task, qp,
		      rxe_requester, "req");
	rxe_init_task(rxe, &qp->comp.task, qp,
		      rxe_completer, "comp");

	qp->qp_timeout_jiffies = 0; /* Can't be set for UD/UC in modify_qp */
	if (init->qp_type == IB_QPT_RC) {
		timer_setup(&qp->rnr_nak_timer, rnr_nak_timer, 0);
		timer_setup(&qp->retrans_timer, retransmit_timer, 0);
	}
	return 0;
}
示例#8
0
void TSInitialize(struct ieee80211_device *ieee)
{
	struct tx_ts_record     *pTxTS  = ieee->TxTsRecord;
	struct rx_ts_record     *pRxTS  = ieee->RxTsRecord;
	PRX_REORDER_ENTRY	pRxReorderEntry = ieee->RxReorderEntry;
	u8				count = 0;
	IEEE80211_DEBUG(IEEE80211_DL_TS, "==========>%s()\n", __func__);
	// Initialize Tx TS related info.
	INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
	INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
	INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List);

	for(count = 0; count < TOTAL_TS_NUM; count++) {
		//
		pTxTS->num = count;
		// The timers for the operation of Traffic Stream and Block Ack.
		// DLS related timer will be add here in the future!!
		timer_setup(&pTxTS->ts_common_info.setup_timer, TsSetupTimeOut,
			    0);
		timer_setup(&pTxTS->ts_common_info.inact_timer, TsInactTimeout,
			    0);
		timer_setup(&pTxTS->ts_add_ba_timer, TsAddBaProcess, 0);
		timer_setup(&pTxTS->tx_pending_ba_record.timer, BaSetupTimeOut,
			    0);
		timer_setup(&pTxTS->tx_admitted_ba_record.timer,
			    TxBaInactTimeout, 0);
		ResetTxTsEntry(pTxTS);
		list_add_tail(&pTxTS->ts_common_info.list, &ieee->Tx_TS_Unused_List);
		pTxTS++;
	}

	// Initialize Rx TS related info.
	INIT_LIST_HEAD(&ieee->Rx_TS_Admit_List);
	INIT_LIST_HEAD(&ieee->Rx_TS_Pending_List);
	INIT_LIST_HEAD(&ieee->Rx_TS_Unused_List);
	for(count = 0; count < TOTAL_TS_NUM; count++) {
		pRxTS->num = count;
		INIT_LIST_HEAD(&pRxTS->rx_pending_pkt_list);
		timer_setup(&pRxTS->ts_common_info.setup_timer, TsSetupTimeOut,
			    0);
		timer_setup(&pRxTS->ts_common_info.inact_timer, TsInactTimeout,
			    0);
		timer_setup(&pRxTS->rx_admitted_ba_record.timer,
			    RxBaInactTimeout, 0);
		timer_setup(&pRxTS->rx_pkt_pending_timer, RxPktPendingTimeout, 0);
		ResetRxTsEntry(pRxTS);
		list_add_tail(&pRxTS->ts_common_info.list, &ieee->Rx_TS_Unused_List);
		pRxTS++;
	}
	// Initialize unused Rx Reorder List.
	INIT_LIST_HEAD(&ieee->RxReorder_Unused_List);
//#ifdef TO_DO_LIST
	for(count = 0; count < REORDER_ENTRY_NUM; count++) {
		list_add_tail( &pRxReorderEntry->List,&ieee->RxReorder_Unused_List);
		if(count == (REORDER_ENTRY_NUM-1))
			break;
		pRxReorderEntry = &ieee->RxReorderEntry[count+1];
	}
//#endif
}
示例#9
0
void r8712_init_mlme_timer(struct _adapter *padapter)
{
	struct	mlme_priv *pmlmepriv = &padapter->mlmepriv;

	timer_setup(&pmlmepriv->assoc_timer, join_timeout_handler, 0);
	timer_setup(&pmlmepriv->sitesurveyctrl.sitesurvey_ctrl_timer,
		    sitesurvey_ctrl_handler, 0);
	timer_setup(&pmlmepriv->scan_to_timer, _scan_timeout_handler, 0);
	timer_setup(&pmlmepriv->dhcp_timer, dhcp_timeout_handler, 0);
	timer_setup(&pmlmepriv->wdg_timer, wdg_timeout_handler, 0);
}
示例#10
0
文件: main.c 项目: Lyude/linux
static int lbs_init_adapter(struct lbs_private *priv)
{
	int ret;

	eth_broadcast_addr(priv->current_addr);

	priv->connect_status = LBS_DISCONNECTED;
	priv->channel = DEFAULT_AD_HOC_CHANNEL;
	priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
	priv->radio_on = 1;
	priv->psmode = LBS802_11POWERMODECAM;
	priv->psstate = PS_STATE_FULL_POWER;
	priv->is_deep_sleep = 0;
	priv->is_auto_deep_sleep_enabled = 0;
	priv->deep_sleep_required = 0;
	priv->wakeup_dev_required = 0;
	init_waitqueue_head(&priv->ds_awake_q);
	init_waitqueue_head(&priv->scan_q);
	priv->authtype_auto = 1;
	priv->is_host_sleep_configured = 0;
	priv->is_host_sleep_activated = 0;
	init_waitqueue_head(&priv->host_sleep_q);
	init_waitqueue_head(&priv->fw_waitq);
	mutex_init(&priv->lock);

	timer_setup(&priv->command_timer, lbs_cmd_timeout_handler, 0);
	timer_setup(&priv->tx_lockup_timer, lbs_tx_lockup_handler, 0);
	timer_setup(&priv->auto_deepsleep_timer, auto_deepsleep_timer_fn, 0);

	INIT_LIST_HEAD(&priv->cmdfreeq);
	INIT_LIST_HEAD(&priv->cmdpendingq);

	spin_lock_init(&priv->driver_lock);

	/* Allocate the command buffers */
	if (lbs_allocate_cmd_buffer(priv)) {
		pr_err("Out of memory allocating command buffers\n");
		ret = -ENOMEM;
		goto out;
	}
	priv->resp_idx = 0;
	priv->resp_len[0] = priv->resp_len[1] = 0;

	/* Create the event FIFO */
	ret = kfifo_alloc(&priv->event_fifo, sizeof(u32) * 16, GFP_KERNEL);
	if (ret) {
		pr_err("Out of memory allocating event FIFO buffer\n");
		goto out;
	}

out:
	return ret;
}
示例#11
0
文件: bttv-input.c 项目: Lyude/linux
static void bttv_ir_start(struct bttv_ir *ir)
{
	if (ir->polling) {
		timer_setup(&ir->timer, bttv_input_timer, 0);
		ir->timer.expires  = jiffies + msecs_to_jiffies(1000);
		add_timer(&ir->timer);
	} else if (ir->rc5_gpio) {
		/* set timer_end for code completion */
		timer_setup(&ir->timer, bttv_rc5_timer_end, 0);
		ir->shift_by = 1;
		ir->rc5_remote_gap = ir_rc5_remote_gap;
	}
}
示例#12
0
文件: a4.c 项目: chronzz/openiBoot
void platform_init()
{
	arm_setup();
	mmu_setup();
	tasks_setup();

	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();

	// Other devices
	uart_setup();
	i2c_setup();

	dma_setup();

	LeaveCriticalSection();

	displaypipe_init();
	framebuffer_setup();
	framebuffer_setdisplaytext(TRUE);
}
示例#13
0
文件: rtc-test.c 项目: krzk/linux
static int test_probe(struct platform_device *plat_dev)
{
	struct rtc_test_data *rtd;

	rtd = devm_kzalloc(&plat_dev->dev, sizeof(*rtd), GFP_KERNEL);
	if (!rtd)
		return -ENOMEM;

	platform_set_drvdata(plat_dev, rtd);

	rtd->rtc = devm_rtc_allocate_device(&plat_dev->dev);
	if (IS_ERR(rtd->rtc))
		return PTR_ERR(rtd->rtc);

	switch (plat_dev->id) {
	case 0:
		rtd->rtc->ops = &test_rtc_ops_noalm;
		break;
	default:
		rtd->rtc->ops = &test_rtc_ops;
	}

	timer_setup(&rtd->alarm, test_rtc_alarm_handler, 0);
	rtd->alarm.expires = 0;

	return rtc_register_device(rtd->rtc);
}
int main(void)
{
	rcc_clock_setup_in_hse_8mhz_out_72mhz();
	gpio_setup();
	timer_setup();


/*
 * The goal is to let the LED2 glow for a second and then be
 * off for a second.
 */

	while (1) /* Halt. */
	{
/* Update interrupt enable. */
		timer_enable_irq(TIM2, TIM_DIER_UIE);

/* Start timer. */
		timer_enable_counter(TIM2);

//		gpio_toggle(GPIOB, GPIO9);	/* LED on/off */
/* Delay for 1 second LED flashes */
//		int i;
//		for (i = 0; i < 6400000; i++)	/* Wait a bit. */
//			__asm__("nop");
	}

	return 0;
}
示例#15
0
struct cmdq_client *cmdq_mbox_create(struct device *dev, int index, u32 timeout)
{
	struct cmdq_client *client;

	client = kzalloc(sizeof(*client), GFP_KERNEL);
	if (!client)
		return (struct cmdq_client *)-ENOMEM;

	client->timeout_ms = timeout;
	if (timeout != CMDQ_NO_TIMEOUT) {
		spin_lock_init(&client->lock);
		timer_setup(&client->timer, cmdq_client_timeout, 0);
	}
	client->pkt_cnt = 0;
	client->client.dev = dev;
	client->client.tx_block = false;
	client->chan = mbox_request_channel(&client->client, index);

	if (IS_ERR(client->chan)) {
		long err;

		dev_err(dev, "failed to request channel\n");
		err = PTR_ERR(client->chan);
		kfree(client);

		return ERR_PTR(err);
	}

	return client;
}
示例#16
0
const char *
__ieee80211_create_tpt_led_trigger(struct ieee80211_hw *hw,
				   unsigned int flags,
				   const struct ieee80211_tpt_blink *blink_table,
				   unsigned int blink_table_len)
{
	struct ieee80211_local *local = hw_to_local(hw);
	struct tpt_led_trigger *tpt_trig;

	if (WARN_ON(local->tpt_led_trigger))
		return NULL;

	tpt_trig = kzalloc(sizeof(struct tpt_led_trigger), GFP_KERNEL);
	if (!tpt_trig)
		return NULL;

	snprintf(tpt_trig->name, sizeof(tpt_trig->name),
		 "%stpt", wiphy_name(local->hw.wiphy));

	local->tpt_led.name = tpt_trig->name;

	tpt_trig->blink_table = blink_table;
	tpt_trig->blink_table_len = blink_table_len;
	tpt_trig->want = flags;
	tpt_trig->local = local;

	timer_setup(&tpt_trig->timer, tpt_trig_timer, 0);

	local->tpt_led_trigger = tpt_trig;

	return tpt_trig->name;
}
示例#17
0
void mlx4_start_catas_poll(struct mlx4_dev *dev)
{
	struct mlx4_priv *priv = mlx4_priv(dev);
	phys_addr_t addr;

	INIT_LIST_HEAD(&priv->catas_err.list);
	timer_setup(&priv->catas_err.timer, poll_catas, 0);
	priv->catas_err.map = NULL;

	if (!mlx4_is_slave(dev)) {
		addr = pci_resource_start(dev->persist->pdev,
					  priv->fw.catas_bar) +
					  priv->fw.catas_offset;

		priv->catas_err.map = ioremap(addr, priv->fw.catas_size * 4);
		if (!priv->catas_err.map) {
			mlx4_warn(dev, "Failed to map internal error buffer at 0x%llx\n",
				  (unsigned long long)addr);
			return;
		}
	}

	priv->catas_err.timer.expires  =
		round_jiffies(jiffies + MLX4_CATAS_POLL_INTERVAL);
	add_timer(&priv->catas_err.timer);
}
示例#18
0
static int setup_devices() {
	// Basic prerequisites for everything else
	miu_setup();
	power_setup();
	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();
	wdt_setup();

	// Other devices
	usb_shutdown();
	uart_setup();
	i2c_setup();

	dma_setup();

	spi_setup();

	return 0;
}
示例#19
0
int system_setup(){
	SystemInit();
	setvbuf( stdout, 0, _IONBF, 0 );
	timer_setup();
	std_char_out_setup();
	return 0;
}
示例#20
0
static int __init exemple_init (void)
{
	int err;
	struct page * pg = NULL;

	exemple_buffer = kmalloc(PAGE_SIZE, GFP_KERNEL);
	if (exemple_buffer == NULL)
		return -ENOMEM;

	exemple_buffer[0] = '\0';

	pg = virt_to_page(exemple_buffer);
	SetPageReserved(pg);

	err =  misc_register(& exemple_misc_driver);
	if (err != 0) {
		ClearPageReserved(pg);
		kfree(exemple_buffer);
		exemple_buffer = NULL;
		return err;
	}

#if LINUX_VERSION_CODE < KERNEL_VERSION(4,15,0)
	init_timer (& exemple_timer);
	exemple_timer.function = exemple_timer_function;
#else
	timer_setup (& exemple_timer, exemple_timer_function, 0);
#endif
	exemple_timer.expires = jiffies + HZ;
	add_timer(& exemple_timer);

	return 0;
}
示例#21
0
int img_ir_probe_raw(struct img_ir_priv *priv)
{
	struct img_ir_priv_raw *raw = &priv->raw;
	struct rc_dev *rdev;
	int error;

	/* Set up the echo timer */
	timer_setup(&raw->timer, img_ir_echo_timer, 0);

	/* Allocate raw decoder */
	raw->rdev = rdev = rc_allocate_device(RC_DRIVER_IR_RAW);
	if (!rdev) {
		dev_err(priv->dev, "cannot allocate raw input device\n");
		return -ENOMEM;
	}
	rdev->priv = priv;
	rdev->map_name = RC_MAP_EMPTY;
	rdev->device_name = "IMG Infrared Decoder Raw";

	/* Register raw decoder */
	error = rc_register_device(rdev);
	if (error) {
		dev_err(priv->dev, "failed to register raw IR input device\n");
		rc_free_device(rdev);
		raw->rdev = NULL;
		return error;
	}

	return 0;
}
示例#22
0
文件: dl2k.c 项目: Lyude/linux
static int rio_open(struct net_device *dev)
{
	struct netdev_private *np = netdev_priv(dev);
	const int irq = np->pdev->irq;
	int i;

	i = alloc_list(dev);
	if (i)
		return i;

	rio_hw_init(dev);

	i = request_irq(irq, rio_interrupt, IRQF_SHARED, dev->name, dev);
	if (i) {
		rio_hw_stop(dev);
		free_list(dev);
		return i;
	}

	timer_setup(&np->timer, rio_timer, 0);
	np->timer.expires = jiffies + 1 * HZ;
	add_timer(&np->timer);

	netif_start_queue (dev);

	dl2k_enable_int(np);
	return 0;
}
示例#23
0
static int r3964_open(struct tty_struct *tty)
{
	struct r3964_info *pInfo;

	TRACE_L("open");
	TRACE_L("tty=%p, PID=%d, disc_data=%p",
		tty, current->pid, tty->disc_data);

	pInfo = kmalloc(sizeof(struct r3964_info), GFP_KERNEL);
	TRACE_M("r3964_open - info kmalloc %p", pInfo);

	if (!pInfo) {
		printk(KERN_ERR "r3964: failed to alloc info structure\n");
		return -ENOMEM;
	}

	pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL);
	TRACE_M("r3964_open - rx_buf kmalloc %p", pInfo->rx_buf);

	if (!pInfo->rx_buf) {
		printk(KERN_ERR "r3964: failed to alloc receive buffer\n");
		kfree(pInfo);
		TRACE_M("r3964_open - info kfree %p", pInfo);
		return -ENOMEM;
	}

	pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL);
	TRACE_M("r3964_open - tx_buf kmalloc %p", pInfo->tx_buf);

	if (!pInfo->tx_buf) {
		printk(KERN_ERR "r3964: failed to alloc transmit buffer\n");
		kfree(pInfo->rx_buf);
		TRACE_M("r3964_open - rx_buf kfree %p", pInfo->rx_buf);
		kfree(pInfo);
		TRACE_M("r3964_open - info kfree %p", pInfo);
		return -ENOMEM;
	}

	spin_lock_init(&pInfo->lock);
	mutex_init(&pInfo->read_lock);
	pInfo->tty = tty;
	pInfo->priority = R3964_MASTER;
	pInfo->rx_first = pInfo->rx_last = NULL;
	pInfo->tx_first = pInfo->tx_last = NULL;
	pInfo->rx_position = 0;
	pInfo->tx_position = 0;
	pInfo->last_rx = 0;
	pInfo->blocks_in_rx_queue = 0;
	pInfo->firstClient = NULL;
	pInfo->state = R3964_IDLE;
	pInfo->flags = R3964_DEBUG;
	pInfo->nRetry = 0;

	tty->disc_data = pInfo;
	tty->receive_room = 65536;

	timer_setup(&pInfo->tmr, on_timeout, 0);

	return 0;
}
示例#24
0
文件: init.c 项目: grate-driver/linux
static void ath9k_init_misc(struct ath_softc *sc)
{
	struct ath_common *common = ath9k_hw_common(sc->sc_ah);
	int i = 0;

	timer_setup(&common->ani.timer, ath_ani_calibrate, 0);

	common->last_rssi = ATH_RSSI_DUMMY_MARKER;
	eth_broadcast_addr(common->bssidmask);
	sc->beacon.slottime = 9;

	for (i = 0; i < ARRAY_SIZE(sc->beacon.bslot); i++)
		sc->beacon.bslot[i] = NULL;

	if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_ANT_DIV_COMB)
		sc->ant_comb.count = ATH_ANT_DIV_COMB_INIT_COUNT;

	sc->spec_priv.ah = sc->sc_ah;
	sc->spec_priv.spec_config.enabled = 0;
	sc->spec_priv.spec_config.short_repeat = true;
	sc->spec_priv.spec_config.count = 8;
	sc->spec_priv.spec_config.endless = false;
	sc->spec_priv.spec_config.period = 0xFF;
	sc->spec_priv.spec_config.fft_period = 0xF;
}
示例#25
0
static int setup_devices() {
	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

//	gpio_setup(); // Not yet

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();
#ifndef CONFIG_IPHONE_4
	wdt_setup();
#endif

	// Other devices
	usb_shutdown();
#ifndef CONFIG_IPHONE_4
	uart_setup();
	i2c_setup();

	dma_setup();

	spi_setup();
#endif

	return 0;
}
示例#26
0
文件: suni.c 项目: avagin/linux
static int suni_start(struct atm_dev *dev)
{
	unsigned long flags;
	int first;

	spin_lock_irqsave(&sunis_lock,flags);
	first = !sunis;
	PRIV(dev)->next = sunis;
	sunis = PRIV(dev);
	spin_unlock_irqrestore(&sunis_lock,flags);
	memset(&PRIV(dev)->sonet_stats,0,sizeof(struct k_sonet_stats));
	PUT(GET(RSOP_CIE) | SUNI_RSOP_CIE_LOSE,RSOP_CIE);
		/* interrupt on loss of signal */
	poll_los(dev); /* ... and clear SUNI interrupts */
	if (dev->signal == ATM_PHY_SIG_LOST)
		printk(KERN_WARNING "%s(itf %d): no signal\n",dev->type,
		    dev->number);
	PRIV(dev)->loop_mode = ATM_LM_NONE;
	suni_hz(NULL); /* clear SUNI counters */
	(void) fetch_stats(dev,NULL,1); /* clear kernel counters */
	if (first) {
		timer_setup(&poll_timer, suni_hz, 0);
		poll_timer.expires = jiffies+HZ;
#if 0
printk(KERN_DEBUG "[u] p=0x%lx,n=0x%lx\n",(unsigned long) poll_timer.list.prev,
    (unsigned long) poll_timer.list.next);
#endif
		add_timer(&poll_timer);
	}
	return 0;
}
示例#27
0
文件: a4.c 项目: boydcase31/openiBoot
void platform_init()
{
	arm_setup();
	mmu_setup();
	tasks_setup();

	// Basic prerequisites for everything else
	miu_setup();
	power_setup();

	clock_setup();

	// Need interrupts for everything afterwards
	interrupt_setup();

	gpio_setup();

	// For scheduling/sleeping niceties
	timer_setup();
	event_setup();

	// Other devices
	usb_shutdown();
	uart_setup();
	i2c_setup();

	// DMA currently f***s up. Need to check why. -- Bluerise
	// dma_setup();

	LeaveCriticalSection();

	framebuffer_hook(); // TODO: Remove once LCD implemented -- Ricky26
	framebuffer_setdisplaytext(TRUE);
}
示例#28
0
/**
 * tipc_disc_create - create object to send periodic link setup requests
 * @net: the applicable net namespace
 * @b: ptr to bearer issuing requests
 * @dest: destination address for request messages
 * @dest_domain: network domain to which links can be established
 *
 * Returns 0 if successful, otherwise -errno.
 */
int tipc_disc_create(struct net *net, struct tipc_bearer *b,
		     struct tipc_media_addr *dest, struct sk_buff **skb)
{
	struct tipc_link_req *req;

	req = kmalloc(sizeof(*req), GFP_ATOMIC);
	if (!req)
		return -ENOMEM;
	req->buf = tipc_buf_acquire(MAX_H_SIZE, GFP_ATOMIC);
	if (!req->buf) {
		kfree(req);
		return -ENOMEM;
	}

	tipc_disc_init_msg(net, req->buf, DSC_REQ_MSG, b);
	memcpy(&req->dest, dest, sizeof(*dest));
	req->net = net;
	req->bearer_id = b->identity;
	req->domain = b->domain;
	req->num_nodes = 0;
	req->timer_intv = TIPC_LINK_REQ_INIT;
	spin_lock_init(&req->lock);
	timer_setup(&req->timer, disc_timeout, 0);
	mod_timer(&req->timer, jiffies + req->timer_intv);
	b->link_req = req;
	*skb = skb_clone(req->buf, GFP_ATOMIC);
	return 0;
}
示例#29
0
void* timerfd_timer_run_thread(rtdal_timer_t* obj) {
    int s;

    assert(obj->period_function);

    if (timer_setup(obj)) {
        aerror("Setting up timer");
        goto timer_destroy;
    }

    if (obj->wait_futex) {
        futex_wait(obj->wait_futex);
    }
    if (timer_start(obj)) {
        aerror("timer_start");
        goto timer_destroy;
    }

    obj->stop = 0;
    while(!obj->stop) {
        if (timer_wait_period(obj)) {
            aerror("waiting for timer");
            goto timer_destroy;
        }
        obj->period_function(obj->arg, NULL);
    }

    s = 0;

timer_destroy:
    timer_close(obj);
    pthread_exit(&s);
    return NULL;
}
/****************************************************************************
 **                                                                        **
 ** Name:    timer_start()                                             **
 **                                                                        **
 ** Description: Schedules the execution of the given callback function    **
 **      upon expiration of the specified time interval            **
 **                                                                        **
 ** Inputs:  sec:       The value of the time interval in seconds  **
 **      cb:        Function executed upon timer expiration    **
 **      args:      Callback argument parameters               **
 **      Others:    None                                       **
 **                                                                        **
 ** Outputs:     None                                                      **
 **      Return:    The timer identifier when successfully     **
 **             started; NAS_TIMER_INACTIVE_ID otherwise.  **
 **      Others:    None                                       **
 **                                                                        **
 ***************************************************************************/
int nas_timer_start(long sec, nas_timer_callback_t cb, void *args)
{
  int id;
  nas_timer_entry_t *te;
#if defined(ENABLE_ITTI)
  int ret;
  long timer_id;
#endif

  /* Do not start null timer */
  if (sec == 0) {
    return (NAS_TIMER_INACTIVE_ID);
  }

  /* Get an identifier for the new timer entry */
  id = _nas_timer_db_get_id();

  if (id < 0) {
    /* No available timer entry found */
    return (NAS_TIMER_INACTIVE_ID);
  }

  /* Create a new timer entry */
  te = _nas_timer_db_create_entry(sec, cb, args);

  if (te == NULL) {
    return (NAS_TIMER_INACTIVE_ID);
  }

  /* Insert the new entry into the timer queue */
  _nas_timer_db_insert_entry(id, te);
#if defined(ENABLE_ITTI)
# if defined(NAS_MME)
  ret = timer_setup(sec, 0, TASK_NAS_MME, INSTANCE_DEFAULT, TIMER_PERIODIC, args, &timer_id);
# else
  ret = timer_setup(sec, 0, TASK_NAS_UE, INSTANCE_DEFAULT, TIMER_PERIODIC, args, &timer_id);
# endif

  if (ret == -1) {
    return NAS_TIMER_INACTIVE_ID;
  }

  te->timer_id = timer_id;
#endif

  return (id);
}