Пример #1
0
void mips_scroll_message(void)
{
	del_timer_sync(&mips_scroll_timer);
	max_display_count = strlen(display_string) + 1 - 8;
	mod_timer(&mips_scroll_timer, jiffies + 1);
}
Пример #2
0
static void pvc_proc_cleanup(void)
{
	remove_proc_subtree(DISPLAY_DIR_NAME, NULL);
	del_timer_sync(&timer);
}
Пример #3
0
static void gf_timer_work(struct work_struct *work)
{
    unsigned char value[4] = { 0 };
    unsigned char* p_fw = GF_FW;
    struct gf_dev *gf_dev = NULL;
    int ret = 0;
    u8 mode = 0xFF;

    GF_LOG_INFO("start\n");
    if (work == NULL) {
		GF_LOG_INFO("wrong work\n");
		return;
    }
    gf_dev = container_of(work, struct gf_dev, spi_work);

    if(gf_dev->mode == GF_FF_MODE)
		goto exit;

    mutex_lock(&gf_dev->buf_lock);
    gf_dev->spi->max_speed_hz = 960000;//SPI_SPEED_MIN;
    spi_setup(gf_dev->spi);
    mutex_unlock(&gf_dev->buf_lock);

    gf_spi_read_byte(gf_dev, 0x8040, &value[0]);
    gf_spi_read_byte(gf_dev, 0x8000, &value[1]);
    gf_spi_read_byte(gf_dev, 0x8043, &value[2]);

    if (value[0] == 0xC6 && value[1] == 0x47) {
		gf_spi_write_byte(gf_dev, 0x8040, 0xAA);
		mdelay(1);
    } else {
		gf_spi_read_byte(gf_dev, 0x8040, &value[0]);
		gf_spi_read_byte(gf_dev, 0x8000, &value[1]);
		gf_spi_read_byte(gf_dev, 0x8043, &value[2]);
		if ((value[0] == 0xC6) && (value[1] == 0x47)) {
		    gf_spi_write_byte(gf_dev, 0x8040, 0xAA);
		    mdelay(1);
		} else {
		    GF_LOG_INFO("hardware works abnormal,do reset! 0x8040 = 0x%x \
				0x8000 = 0x%x 0x8046 = 0x%x\n", value[0], value[1], value[2]);
			gf_irq_disable(gf_dev);
		    gf_reset(gf_dev);

		    gf_spi_read_byte(gf_dev, 0x41e4, &value[0]);
		    gf_spi_read_byte(gf_dev, 0x8000, &value[1]);
		    GF_LOG_INFO("read 0x41e4 finish value = 0x%x, 0x8000=0x%x\n",
				value[0], value[1]);

		    if (value[0] != 0xbe) {
				gf_spi_read_byte(gf_dev, 0x41e4, &value[0]);
				if (value[0] != 0xbe) {
				    /*******************firmware update*********************/
				    GF_LOG_INFO("firmware update start\n");
				    del_timer_sync(&gf_dev->gf_timer);
				    if (gf_fw_update_init(gf_dev)) {
						gf_fw_update(gf_dev, p_fw, FW_LENGTH);
						gf_reset();
				    }
				    gf_dev->gf_timer.expires = jiffies + 2 * HZ;
				    add_timer(&gf_dev->gf_timer);
				}
		    }
		    /**********************update config*************************/
		    ret = gf_spi_write_byte(gf_dev, 0x8040, 0xAA);
		    if (!ret)
				GF_LOG_INFO("write 0x8040 fail\n");

		    if (!hw_config(gf_dev))
				GF_LOG_INFO("write config fail\n");
		    gf_irq_enable(gf_dev);
		}
    }
    /* if mode was changed by reset, we should set the mode  back to the primary mode */
    gf_spi_read_byte(gf_dev, GF_MODE_STATUS, &mode);
    if (mode != gf_dev->mode) {
		GF_LOG_INFO("set mode back\n");
		gf_spi_write_byte(gf_dev, GF_MODE_STATUS, gf_dev->mode);
		gf_spi_read_byte(gf_dev, GF_MODE_STATUS, &mode);
		GF_LOG_INFO("mode444 = %d\n", mode);
    }

exit:
    mod_timer(&gf_dev->gf_timer, jiffies + 2*HZ);
    GF_LOG_INFO("end\n");
}
Пример #4
0
static void ath9k_htc_stop(struct ieee80211_hw *hw)
{
	struct ath9k_htc_priv *priv = hw->priv;
	struct ath_hw *ah = priv->ah;
	struct ath_common *common = ath9k_hw_common(ah);
	int ret __attribute__ ((unused));
	u8 cmd_rsp;

	mutex_lock(&priv->mutex);

	if (priv->op_flags & OP_INVALID) {
		ath_dbg(common, ATH_DBG_ANY, "Device not present\n");
		mutex_unlock(&priv->mutex);
		return;
	}

	ath9k_htc_ps_wakeup(priv);

	WMI_CMD(WMI_DISABLE_INTR_CMDID);
	WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
	WMI_CMD(WMI_STOP_RECV_CMDID);

	tasklet_kill(&priv->rx_tasklet);

	del_timer_sync(&priv->tx.cleanup_timer);
	ath9k_htc_tx_drain(priv);
	ath9k_wmi_event_drain(priv);

	mutex_unlock(&priv->mutex);

	/* Cancel all the running timers/work .. */
	cancel_work_sync(&priv->fatal_work);
	cancel_work_sync(&priv->ps_work);

#ifdef CONFIG_MAC80211_LEDS
	cancel_work_sync(&priv->led_work);
#endif
	ath9k_htc_stop_ani(priv);

	mutex_lock(&priv->mutex);

	if (ah->btcoex_hw.enabled) {
		ath9k_hw_btcoex_disable(ah);
		if (ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
			ath_htc_cancel_btcoex_work(priv);
	}

	/* Remove a monitor interface if it's present. */
	if (priv->ah->is_monitoring)
		ath9k_htc_remove_monitor_interface(priv);

	ath9k_hw_phy_disable(ah);
	ath9k_hw_disable(ah);
	ath9k_htc_ps_restore(priv);
	ath9k_htc_setpower(priv, ATH9K_PM_FULL_SLEEP);

	priv->op_flags |= OP_INVALID;

	ath_dbg(common, ATH_DBG_CONFIG, "Driver halt\n");
	mutex_unlock(&priv->mutex);
}
Пример #5
0
static int __devinit gpio_keys_probe(struct platform_device *pdev)
{
	struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
	struct gpio_keys_drvdata *ddata;
	struct device *dev = &pdev->dev;
	struct input_dev *input;
	int i, error;
	int wakeup = 0;

	ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
			pdata->nbuttons * sizeof(struct gpio_button_data),
			GFP_KERNEL);
	input = input_allocate_device();
	if (!ddata || !input) {
		dev_err(dev, "failed to allocate state\n");
		error = -ENOMEM;
		goto fail1;
	}

	ddata->input = input;
	ddata->n_buttons = pdata->nbuttons;
	ddata->enable = pdata->enable;
	ddata->disable = pdata->disable;
	mutex_init(&ddata->disable_lock);

	platform_set_drvdata(pdev, ddata);
	input_set_drvdata(input, ddata);

	input->name = pdev->name;
	input->phys = "gpio-keys/input0";
	input->dev.parent = &pdev->dev;
	input->open = gpio_keys_open;
	input->close = gpio_keys_close;

	input->id.bustype = BUS_HOST;
	input->id.vendor = 0x0001;
	input->id.product = 0x0001;
	input->id.version = 0x0100;

	/* Enable auto repeat feature of Linux input subsystem */
	if (pdata->rep)
		__set_bit(EV_REP, input->evbit);

	for (i = 0; i < pdata->nbuttons; i++) {
		struct gpio_keys_button *button = &pdata->buttons[i];
		struct gpio_button_data *bdata = &ddata->data[i];
		unsigned int type = button->type ?: EV_KEY;

		bdata->input = input;
		bdata->button = button;

		error = gpio_keys_setup_key(pdev, bdata, button);
		if (error)
			goto fail2;

		if (button->wakeup)
			wakeup = 1;

		input_set_capability(input, type, button->code);
	}

	error = sysfs_create_group(&pdev->dev.kobj, &gpio_keys_attr_group);
	if (error) {
		dev_err(dev, "Unable to export keys/switches, error: %d\n",
			error);
		goto fail2;
	}

	error = input_register_device(input);
	if (error) {
		dev_err(dev, "Unable to register input device, error: %d\n",
			error);
		goto fail3;
	}

	/* get current state of buttons */
	for (i = 0; i < pdata->nbuttons; i++)
		gpio_keys_report_event(&ddata->data[i]);
	input_sync(input);

	device_init_wakeup(&pdev->dev, wakeup);

	return 0;

 fail3:
	sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
 fail2:
	while (--i >= 0) {
		free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
		if (ddata->data[i].timer_debounce)
			del_timer_sync(&ddata->data[i].timer);
		cancel_work_sync(&ddata->data[i].work);
		gpio_free(pdata->buttons[i].gpio);
	}

	platform_set_drvdata(pdev, NULL);
 fail1:
	input_free_device(input);
	kfree(ddata);

	return error;
}
Пример #6
0
/*  using pstapriv->sta_hash_lock to protect */
u32	rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta)
{
    int i;
    struct __queue *pfree_sta_queue;
    struct recv_reorder_ctrl *preorder_ctrl;
    struct	sta_xmit_priv	*pstaxmitpriv;
    struct	xmit_priv	*pxmitpriv = &padapter->xmitpriv;
    struct	sta_priv *pstapriv = &padapter->stapriv;


    if (psta == NULL)
        goto exit;

    pfree_sta_queue = &pstapriv->free_sta_queue;

    pstaxmitpriv = &psta->sta_xmitpriv;

    spin_lock_bh(&pxmitpriv->lock);

    rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q);
    psta->sleepq_len = 0;

    rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending);

    list_del_init(&(pstaxmitpriv->vo_q.tx_pending));

    rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending);

    list_del_init(&(pstaxmitpriv->vi_q.tx_pending));

    rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending);

    list_del_init(&(pstaxmitpriv->bk_q.tx_pending));

    rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending);

    list_del_init(&(pstaxmitpriv->be_q.tx_pending));

    spin_unlock_bh(&pxmitpriv->lock);

    list_del_init(&psta->hash_list);
    RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo  with hwaddr=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", pstapriv->asoc_sta_count , psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5]));
    pstapriv->asoc_sta_count--;

    /*  re-init sta_info; 20061114 */
    _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv);
    _rtw_init_sta_recv_priv(&psta->sta_recvpriv);

    del_timer_sync(&psta->addba_retry_timer);

    /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */
    for (i = 0; i < 16; i++) {
        struct list_head *phead, *plist;
        struct recv_frame *prhdr;
        struct recv_frame *prframe;
        struct __queue *ppending_recvframe_queue;
        struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;

        preorder_ctrl = &psta->recvreorder_ctrl[i];

        del_timer_sync(&preorder_ctrl->reordering_ctrl_timer);

        ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue;

        spin_lock_bh(&ppending_recvframe_queue->lock);

        phead =		get_list_head(ppending_recvframe_queue);
        plist = phead->next;

        while (!list_empty(phead)) {
            prhdr = container_of(plist, struct recv_frame, list);
            prframe = (struct recv_frame *)prhdr;

            plist = plist->next;

            list_del_init(&(prframe->list));

            rtw_free_recvframe(prframe, pfree_recv_queue);
        }

        spin_unlock_bh(&ppending_recvframe_queue->lock);
    }

    if (!(psta->state & WIFI_AP_STATE))
        rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, false);

#ifdef CONFIG_88EU_AP_MODE

    spin_lock_bh(&pstapriv->auth_list_lock);
    if (!list_empty(&psta->auth_list)) {
        list_del_init(&psta->auth_list);
        pstapriv->auth_list_cnt--;
    }
    spin_unlock_bh(&pstapriv->auth_list_lock);

    psta->expire_to = 0;

    psta->sleepq_ac_len = 0;
    psta->qos_info = 0;

    psta->max_sp_len = 0;
    psta->uapsd_bk = 0;
    psta->uapsd_be = 0;
    psta->uapsd_vi = 0;
    psta->uapsd_vo = 0;
    psta->has_legacy_ac = 0;

    pstapriv->sta_dz_bitmap &= ~BIT(psta->aid);
    pstapriv->tim_bitmap &= ~BIT(psta->aid);

    if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) {
        pstapriv->sta_aid[psta->aid - 1] = NULL;
        psta->aid = 0;
    }

    psta->under_exist_checking = 0;

#endif	/*  CONFIG_88EU_AP_MODE */

    spin_lock_bh(&(pfree_sta_queue->lock));
    list_add_tail(&psta->list, get_list_head(pfree_sta_queue));
    spin_unlock_bh(&pfree_sta_queue->lock);

exit:


    return _SUCCESS;
}
Пример #7
0
static void __exit hangcheck_exit(void)
{
	del_timer_sync(&hangcheck_ticktock);
        printk("Hangcheck: Stopped hangcheck timer.\n");
}
Пример #8
0
int ___ieee80211_stop_tx_ba_session(struct sta_info *sta, u16 tid,
				    enum ieee80211_back_parties initiator,
				    bool tx)
{
	struct ieee80211_local *local = sta->local;
	struct tid_ampdu_tx *tid_tx;
	int ret;

	lockdep_assert_held(&sta->ampdu_mlme.mtx);

	spin_lock_bh(&sta->lock);

	tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
	if (!tid_tx) {
		spin_unlock_bh(&sta->lock);
		return -ENOENT;
	}

	/* if we're already stopping ignore any new requests to stop */
	if (test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) {
		spin_unlock_bh(&sta->lock);
		return -EALREADY;
	}

	if (test_bit(HT_AGG_STATE_WANT_START, &tid_tx->state)) {
		/* not even started yet! */
		ieee80211_assign_tid_tx(sta, tid, NULL);
		spin_unlock_bh(&sta->lock);
		kfree_rcu(tid_tx, rcu_head);
		return 0;
	}

	set_bit(HT_AGG_STATE_STOPPING, &tid_tx->state);

	spin_unlock_bh(&sta->lock);

#ifdef CONFIG_MAC80211_HT_DEBUG
	printk(KERN_DEBUG "Tx BA session stop requested for %pM tid %u\n",
	       sta->sta.addr, tid);
#endif /* CONFIG_MAC80211_HT_DEBUG */

	del_timer_sync(&tid_tx->addba_resp_timer);

	/*
	 * After this packets are no longer handed right through
	 * to the driver but are put onto tid_tx->pending instead,
	 * with locking to ensure proper access.
	 */
	clear_bit(HT_AGG_STATE_OPERATIONAL, &tid_tx->state);

	/*
	 * There might be a few packets being processed right now (on
	 * another CPU) that have already gotten past the aggregation
	 * check when it was still OPERATIONAL and consequently have
	 * IEEE80211_TX_CTL_AMPDU set. In that case, this code might
	 * call into the driver at the same time or even before the
	 * TX paths calls into it, which could confuse the driver.
	 *
	 * Wait for all currently running TX paths to finish before
	 * telling the driver. New packets will not go through since
	 * the aggregation session is no longer OPERATIONAL.
	 */
	synchronize_net();

	tid_tx->stop_initiator = initiator;
	tid_tx->tx_stop = tx;

	ret = drv_ampdu_action(local, sta->sdata,
			       IEEE80211_AMPDU_TX_STOP,
			       &sta->sta, tid, NULL, 0);

	/* HW shall not deny going back to legacy */
	if (WARN_ON(ret)) {
		/*
		 * We may have pending packets get stuck in this case...
		 * Not bothering with a workaround for now.
		 */
	}

	return ret;
}
Пример #9
0
void ieee80211_process_addba_resp(struct ieee80211_local *local,
				  struct sta_info *sta,
				  struct ieee80211_mgmt *mgmt,
				  size_t len)
{
	struct tid_ampdu_tx *tid_tx;
	u16 capab, tid;
	u8 buf_size;

	capab = le16_to_cpu(mgmt->u.action.u.addba_resp.capab);
	tid = (capab & IEEE80211_ADDBA_PARAM_TID_MASK) >> 2;
	buf_size = (capab & IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK) >> 6;

	mutex_lock(&sta->ampdu_mlme.mtx);

	tid_tx = rcu_dereference_protected_tid_tx(sta, tid);
	if (!tid_tx)
		goto out;

	if (mgmt->u.action.u.addba_resp.dialog_token != tid_tx->dialog_token) {
#ifdef CONFIG_MAC80211_HT_DEBUG
		printk(KERN_DEBUG "wrong addBA response token, tid %d\n", tid);
#endif
		goto out;
	}

	del_timer_sync(&tid_tx->addba_resp_timer);

#ifdef CONFIG_MAC80211_HT_DEBUG
	printk(KERN_DEBUG "switched off addBA timer for tid %d\n", tid);
#endif

	/*
	 * addba_resp_timer may have fired before we got here, and
	 * caused WANT_STOP to be set. If the stop then was already
	 * processed further, STOPPING might be set.
	 */
	if (test_bit(HT_AGG_STATE_WANT_STOP, &tid_tx->state) ||
	    test_bit(HT_AGG_STATE_STOPPING, &tid_tx->state)) {
#ifdef CONFIG_MAC80211_HT_DEBUG
		printk(KERN_DEBUG
		       "got addBA resp for tid %d but we already gave up\n",
		       tid);
#endif
		goto out;
	}

	/*
	 * IEEE 802.11-2007 7.3.1.14:
	 * In an ADDBA Response frame, when the Status Code field
	 * is set to 0, the Buffer Size subfield is set to a value
	 * of at least 1.
	 */
	if (le16_to_cpu(mgmt->u.action.u.addba_resp.status)
			== WLAN_STATUS_SUCCESS && buf_size) {
		if (test_and_set_bit(HT_AGG_STATE_RESPONSE_RECEIVED,
				     &tid_tx->state)) {
			/* ignore duplicate response */
			goto out;
		}

		tid_tx->buf_size = buf_size;

		if (test_bit(HT_AGG_STATE_DRV_READY, &tid_tx->state))
			ieee80211_agg_tx_operational(local, sta, tid);

		sta->ampdu_mlme.addba_req_num[tid] = 0;
	} else {
		___ieee80211_stop_tx_ba_session(sta, tid, WLAN_BACK_INITIATOR,
						true);
	}

 out:
	mutex_unlock(&sta->ampdu_mlme.mtx);
}
Пример #10
0
static int
bnad_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coalesce)
{
	struct bnad *bnad = netdev_priv(netdev);
	unsigned long flags;
	int to_del = 0;

	if (coalesce->rx_coalesce_usecs == 0 ||
	    coalesce->rx_coalesce_usecs >
	    BFI_MAX_COALESCING_TIMEO * BFI_COALESCING_TIMER_UNIT)
		return -EINVAL;

	if (coalesce->tx_coalesce_usecs == 0 ||
	    coalesce->tx_coalesce_usecs >
	    BFI_MAX_COALESCING_TIMEO * BFI_COALESCING_TIMER_UNIT)
		return -EINVAL;

	mutex_lock(&bnad->conf_mutex);
	/*
	 * Do not need to store rx_coalesce_usecs here
	 * Every time DIM is disabled, we can get it from the
	 * stack.
	 */
	spin_lock_irqsave(&bnad->bna_lock, flags);
	if (coalesce->use_adaptive_rx_coalesce) {
		if (!(bnad->cfg_flags & BNAD_CF_DIM_ENABLED)) {
			bnad->cfg_flags |= BNAD_CF_DIM_ENABLED;
			bnad_dim_timer_start(bnad);
		}
	} else {
		if (bnad->cfg_flags & BNAD_CF_DIM_ENABLED) {
			bnad->cfg_flags &= ~BNAD_CF_DIM_ENABLED;
			if (bnad->cfg_flags & BNAD_CF_DIM_ENABLED &&
			    test_bit(BNAD_RF_DIM_TIMER_RUNNING,
			    &bnad->run_flags)) {
				clear_bit(BNAD_RF_DIM_TIMER_RUNNING,
							&bnad->run_flags);
				to_del = 1;
			}
			spin_unlock_irqrestore(&bnad->bna_lock, flags);
			if (to_del)
				del_timer_sync(&bnad->dim_timer);
			spin_lock_irqsave(&bnad->bna_lock, flags);
			bnad_rx_coalescing_timeo_set(bnad);
		}
	}
	if (bnad->tx_coalescing_timeo != coalesce->tx_coalesce_usecs /
					BFI_COALESCING_TIMER_UNIT) {
		bnad->tx_coalescing_timeo = coalesce->tx_coalesce_usecs /
						BFI_COALESCING_TIMER_UNIT;
		bnad_tx_coalescing_timeo_set(bnad);
	}

	if (bnad->rx_coalescing_timeo != coalesce->rx_coalesce_usecs /
					BFI_COALESCING_TIMER_UNIT) {
		bnad->rx_coalescing_timeo = coalesce->rx_coalesce_usecs /
						BFI_COALESCING_TIMER_UNIT;

		if (!(bnad->cfg_flags & BNAD_CF_DIM_ENABLED))
			bnad_rx_coalescing_timeo_set(bnad);

	}

	/* Add Tx Inter-pkt DMA count?  */

	spin_unlock_irqrestore(&bnad->bna_lock, flags);

	mutex_unlock(&bnad->conf_mutex);
	return 0;
}
Пример #11
0
static int aml_callkey_earlysuspend(struct early_suspend *handler)
{
	del_timer_sync(&gp_call_key_workdata->timer);
	return 0;
}
Пример #12
0
static int aml_pcm_trigger(struct snd_pcm_substream *substream,
	int cmd)
{
	struct snd_pcm_runtime *rtd = substream->runtime;
	struct aml_runtime_data *prtd = rtd->private_data;
	audio_stream_t *s = &prtd->s;
	int ret = 0;
	
	spin_lock(&s->lock);
	switch (cmd) {
	case SNDRV_PCM_TRIGGER_START:
		
		del_timer_sync(&prtd->timer);
		
		prtd->timer.expires = jiffies + 1;
    del_timer(&prtd->timer);
    add_timer(&prtd->timer);
        
		// TODO
    	if ((aml_soc_platform.pcm_pdata) && ((struct pcm_platform_data *) (aml_soc_platform.pcm_pdata))->mute_func)
        	((struct pcm_platform_data *) (aml_soc_platform.pcm_pdata))->mute_func(0);

		if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
		    printk("aml_pcm_trigger: playback start\n");
			audio_enable_ouput(1);
		}else{
		//	printk("aml_pcm_trigger: capture start\n");
			audio_in_i2s_enable(1);
            {
              int * ppp = (int*)(rtd->dma_area+rtd->dma_bytes*2-8);
			  ppp[0] = 0x78787878;
			  ppp[1] = 0x78787878;
            }

		}
		
		s->active = 1;
		
		break;		/* SNDRV_PCM_TRIGGER_START */
	case SNDRV_PCM_TRIGGER_SUSPEND:
	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
	case SNDRV_PCM_TRIGGER_STOP:
		// TODO
		s->active = 0;
		if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
            printk("aml_pcm_trigger: playback stop\n");
				audio_enable_ouput(0);
		}else{
        //    printk("aml_pcm_trigger: capture stop\n");
				audio_in_i2s_enable(0);
		}
		break;

	case SNDRV_PCM_TRIGGER_RESUME:
	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
		// TODO
		s->active = 1;
		if(substream->stream == SNDRV_PCM_STREAM_PLAYBACK){
        //    printk("aml_pcm_trigger: playback resume\n");
				audio_enable_ouput(1);
		}else{
        //    printk("aml_pcm_trigger: capture resume\n");
			  audio_in_i2s_enable(1);
              {
                int * ppp = (int*)(rtd->dma_area+rtd->dma_bytes*2-8);
			    ppp[0] = 0x78787878;
			    ppp[1] = 0x78787878;
              }
		}
		
		break;

	default:
		ret = -EINVAL;
	}
	spin_unlock(&s->lock);
	return ret;
}
Пример #13
0
static void cisco_stop(struct net_device *dev)
{
	del_timer_sync(&dev_to_hdlc(dev)->state.cisco.timer);
	if (netif_carrier_ok(dev))
		netif_carrier_off(dev);
}
Пример #14
0
static void
xpc_stop_hb_beater(void)
{
	del_timer_sync(&xpc_hb_timer);
	xpc_arch_ops.heartbeat_exit();
}
static void wl_cfg80211_bt_handler(struct work_struct *work)
{
    struct btcoex_info *btcx_inf;

    btcx_inf = container_of(work, struct btcoex_info, work);

    if (btcx_inf->timer_on) {
        btcx_inf->timer_on = 0;
        del_timer_sync(&btcx_inf->timer);
    }

    switch (btcx_inf->bt_state) {
    case BT_DHCP_START:
        /* DHCP started
         * provide OPPORTUNITY window to get DHCP address
         */
        WL_TRACE(("%s bt_dhcp stm: started \n",
                  __FUNCTION__));
        btcx_inf->bt_state = BT_DHCP_OPPR_WIN;
        mod_timer(&btcx_inf->timer,
                  jiffies + BT_DHCP_OPPR_WIN_TIME*HZ/1000);
        btcx_inf->timer_on = 1;
        break;

    case BT_DHCP_OPPR_WIN:
        if (btcx_inf->dhcp_done) {
            WL_TRACE(("%s DHCP Done before T1 expiration\n",
                      __FUNCTION__));
            goto btc_coex_idle;
        }

        /* DHCP is not over yet, start lowering BT priority
         * enforce btc_params + flags if necessary
         */
        WL_TRACE(("%s DHCP T1:%d expired\n", __FUNCTION__,
                  BT_DHCP_OPPR_WIN_TIME));
        if (btcx_inf->dev)
            wl_cfg80211_bt_setflag(btcx_inf->dev, TRUE);
        btcx_inf->bt_state = BT_DHCP_FLAG_FORCE_TIMEOUT;
        mod_timer(&btcx_inf->timer,
                  jiffies + BT_DHCP_FLAG_FORCE_TIME*HZ/1000);
        btcx_inf->timer_on = 1;
        break;

    case BT_DHCP_FLAG_FORCE_TIMEOUT:
        if (btcx_inf->dhcp_done) {
            WL_TRACE(("%s DHCP Done before T2 expiration\n",
                      __FUNCTION__));
        } else {
            /* Noo dhcp during T1+T2, restore BT priority */
            WL_TRACE(("%s DHCP wait interval T2:%d"
                      "msec expired\n", __FUNCTION__,
                      BT_DHCP_FLAG_FORCE_TIME));
        }

        /* Restoring default bt priority */
        if (btcx_inf->dev)
            wl_cfg80211_bt_setflag(btcx_inf->dev, FALSE);
btc_coex_idle:
        btcx_inf->bt_state = BT_DHCP_IDLE;
        btcx_inf->timer_on = 0;
        break;

    default:
        WL_ERR(("%s error g_status=%d !!!\n", __FUNCTION__,
                btcx_inf->bt_state));
        if (btcx_inf->dev)
            wl_cfg80211_bt_setflag(btcx_inf->dev, FALSE);
        btcx_inf->bt_state = BT_DHCP_IDLE;
        btcx_inf->timer_on = 0;
        break;
    }

    net_os_wake_unlock(btcx_inf->dev);
}
Пример #16
0
static int clamp_thread(void *arg)
{
	int cpunr = (unsigned long)arg;
	DEFINE_TIMER(wakeup_timer, noop_timer, 0, 0);
	static const struct sched_param param = {
		.sched_priority = MAX_USER_RT_PRIO/2,
	};
	unsigned int count = 0;
	unsigned int target_ratio;

	set_bit(cpunr, cpu_clamping_mask);
	set_freezable();
	init_timer_on_stack(&wakeup_timer);
	sched_setscheduler(current, SCHED_FIFO, &param);

	while (true == clamping && !kthread_should_stop() &&
		cpu_online(cpunr)) {
		int sleeptime;
		unsigned long target_jiffies;
		unsigned int guard;
		unsigned int compensation = 0;
		int interval; /* jiffies to sleep for each attempt */
		unsigned int duration_jiffies = msecs_to_jiffies(duration);
		unsigned int window_size_now;

		try_to_freeze();
		/*
		 * make sure user selected ratio does not take effect until
		 * the next round. adjust target_ratio if user has changed
		 * target such that we can converge quickly.
		 */
		target_ratio = set_target_ratio;
		guard = 1 + target_ratio/20;
		window_size_now = window_size;
		count++;

		/*
		 * systems may have different ability to enter package level
		 * c-states, thus we need to compensate the injected idle ratio
		 * to achieve the actual target reported by the HW.
		 */
		compensation = get_compensation(target_ratio);
		interval = duration_jiffies*100/(target_ratio+compensation);

		/* align idle time */
		target_jiffies = roundup(jiffies, interval);
		sleeptime = target_jiffies - jiffies;
		if (sleeptime <= 0)
			sleeptime = 1;
		schedule_timeout_interruptible(sleeptime);
		/*
		 * only elected controlling cpu can collect stats and update
		 * control parameters.
		 */
		if (cpunr == control_cpu && !(count%window_size_now)) {
			should_skip =
				powerclamp_adjust_controls(target_ratio,
							guard, window_size_now);
			smp_mb();
		}

		if (should_skip)
			continue;

		target_jiffies = jiffies + duration_jiffies;
		mod_timer(&wakeup_timer, target_jiffies);
		if (unlikely(local_softirq_pending()))
			continue;
		/*
		 * stop tick sched during idle time, interrupts are still
		 * allowed. thus jiffies are updated properly.
		 */
		preempt_disable();
		/* mwait until target jiffies is reached */
		while (time_before(jiffies, target_jiffies)) {
			unsigned long ecx = 1;
			unsigned long eax = target_mwait;

			/*
			 * REVISIT: may call enter_idle() to notify drivers who
			 * can save power during cpu idle. same for exit_idle()
			 */
			local_touch_nmi();
			stop_critical_timings();
			mwait_idle_with_hints(eax, ecx);
			start_critical_timings();
			atomic_inc(&idle_wakeup_counter);
		}
		preempt_enable();
	}
	del_timer_sync(&wakeup_timer);
	clear_bit(cpunr, cpu_clamping_mask);

	return 0;
}

/*
 * 1 HZ polling while clamping is active, useful for userspace
 * to monitor actual idle ratio.
 */
static void poll_pkg_cstate(struct work_struct *dummy);
static DECLARE_DELAYED_WORK(poll_pkg_cstate_work, poll_pkg_cstate);
static void poll_pkg_cstate(struct work_struct *dummy)
{
	static u64 msr_last;
	static u64 tsc_last;
	static unsigned long jiffies_last;

	u64 msr_now;
	unsigned long jiffies_now;
	u64 tsc_now;
	u64 val64;

	msr_now = pkg_state_counter();
	rdtscll(tsc_now);
	jiffies_now = jiffies;

	/* calculate pkg cstate vs tsc ratio */
	if (!msr_last || !tsc_last)
		pkg_cstate_ratio_cur = 1;
	else {
		if (tsc_now - tsc_last) {
			val64 = 100 * (msr_now - msr_last);
			do_div(val64, (tsc_now - tsc_last));
			pkg_cstate_ratio_cur = val64;
		}
	}

	/* update record */
	msr_last = msr_now;
	jiffies_last = jiffies_now;
	tsc_last = tsc_now;

	if (true == clamping)
		schedule_delayed_work(&poll_pkg_cstate_work, HZ);
}

static int start_power_clamp(void)
{
	unsigned long cpu;
	struct task_struct *thread;

	/* check if pkg cstate counter is completely 0, abort in this case */
	if (!has_pkg_state_counter()) {
		pr_err("pkg cstate counter not functional, abort\n");
		return -EINVAL;
	}

	set_target_ratio = clamp(set_target_ratio, 0U, MAX_TARGET_RATIO - 1);
	/* prevent cpu hotplug */
	get_online_cpus();

	/* prefer BSP */
	control_cpu = 0;
	if (!cpu_online(control_cpu))
		control_cpu = smp_processor_id();

	clamping = true;
	schedule_delayed_work(&poll_pkg_cstate_work, 0);

	/* start one thread per online cpu */
	for_each_online_cpu(cpu) {
		struct task_struct **p =
			per_cpu_ptr(powerclamp_thread, cpu);

		thread = kthread_create_on_node(clamp_thread,
						(void *) cpu,
						cpu_to_node(cpu),
						"kidle_inject/%ld", cpu);
		/* bind to cpu here */
		if (likely(!IS_ERR(thread))) {
			kthread_bind(thread, cpu);
			wake_up_process(thread);
			*p = thread;
		}

	}
	put_online_cpus();

	return 0;
}
int wl_cfg80211_set_btcoex_dhcp(struct net_device *dev, char *command)
{

    struct wl_priv *wl = wlcfg_drv_priv;
    char powermode_val = 0;
    char buf_reg66va_dhcp_on[8] = { 66, 00, 00, 00, 0x10, 0x27, 0x00, 0x00 };
    char buf_reg41va_dhcp_on[8] = { 41, 00, 00, 00, 0x33, 0x00, 0x00, 0x00 };
    char buf_reg68va_dhcp_on[8] = { 68, 00, 00, 00, 0x90, 0x01, 0x00, 0x00 };

    uint32 regaddr;
    static uint32 saved_reg66;
    static uint32 saved_reg41;
    static uint32 saved_reg68;
    static bool saved_status = FALSE;

#ifdef COEX_DHCP
    char buf_flag7_default[8] =   { 7, 00, 00, 00, 0x0, 0x00, 0x00, 0x00};
    struct btcoex_info *btco_inf = wl->btcoex_info;
#endif /* COEX_DHCP */

    /* Figure out powermode 1 or o command */
    strncpy((char *)&powermode_val, command + strlen("BTCOEXMODE") +1, 1);

    if (strnicmp((char *)&powermode_val, "1", strlen("1")) == 0) {

        WL_TRACE(("%s: DHCP session starts\n", __FUNCTION__));

        /* Retrieve and saved orig regs value */
        if ((saved_status == FALSE) &&
                (!dev_wlc_intvar_get_reg(dev, "btc_params", 66,  &saved_reg66)) &&
                (!dev_wlc_intvar_get_reg(dev, "btc_params", 41,  &saved_reg41)) &&
                (!dev_wlc_intvar_get_reg(dev, "btc_params", 68,  &saved_reg68)))   {
            saved_status = TRUE;
            WL_TRACE(("Saved 0x%x 0x%x 0x%x\n",
                      saved_reg66, saved_reg41, saved_reg68));

            /* Disable PM mode during dhpc session */

            /* Disable PM mode during dhpc session */
#ifdef COEX_DHCP
            /* Start  BT timer only for SCO connection */
            if (btcoex_is_sco_active(dev)) {
                /* btc_params 66 */
                dev_wlc_bufvar_set(dev, "btc_params",
                                   (char *)&buf_reg66va_dhcp_on[0],
                                   sizeof(buf_reg66va_dhcp_on));
                /* btc_params 41 0x33 */
                dev_wlc_bufvar_set(dev, "btc_params",
                                   (char *)&buf_reg41va_dhcp_on[0],
                                   sizeof(buf_reg41va_dhcp_on));
                /* btc_params 68 0x190 */
                dev_wlc_bufvar_set(dev, "btc_params",
                                   (char *)&buf_reg68va_dhcp_on[0],
                                   sizeof(buf_reg68va_dhcp_on));
                saved_status = TRUE;

                btco_inf->bt_state = BT_DHCP_START;
                btco_inf->timer_on = 1;
                mod_timer(&btco_inf->timer, btco_inf->timer.expires);
                WL_TRACE(("%s enable BT DHCP Timer\n",
                          __FUNCTION__));
            }
#endif /* COEX_DHCP */
        }
        else if (saved_status == TRUE) {
            WL_ERR(("%s was called w/o DHCP OFF. Continue\n", __FUNCTION__));
        }
    }
    else if (strnicmp((char *)&powermode_val, "2", strlen("2")) == 0) {


        /* Restoring PM mode */

#ifdef COEX_DHCP
        /* Stop any bt timer because DHCP session is done */
        WL_TRACE(("%s disable BT DHCP Timer\n", __FUNCTION__));
        if (btco_inf->timer_on) {
            btco_inf->timer_on = 0;
            del_timer_sync(&btco_inf->timer);

            if (btco_inf->bt_state != BT_DHCP_IDLE) {
                /* need to restore original btc flags & extra btc params */
                WL_TRACE(("%s bt->bt_state:%d\n",
                          __FUNCTION__, btco_inf->bt_state));
                /* wake up btcoex thread to restore btlags+params  */
                schedule_work(&btco_inf->work);
            }
        }

        /* Restoring btc_flag paramter anyway */
        if (saved_status == TRUE)
            dev_wlc_bufvar_set(dev, "btc_flags",
                               (char *)&buf_flag7_default[0], sizeof(buf_flag7_default));
#endif /* COEX_DHCP */

        /* Restore original values */
        if (saved_status == TRUE) {
            regaddr = 66;
            dev_wlc_intvar_set_reg(dev, "btc_params",
                                   (char *)&regaddr, (char *)&saved_reg66);
            regaddr = 41;
            dev_wlc_intvar_set_reg(dev, "btc_params",
                                   (char *)&regaddr, (char *)&saved_reg41);
            regaddr = 68;
            dev_wlc_intvar_set_reg(dev, "btc_params",
                                   (char *)&regaddr, (char *)&saved_reg68);

            WL_TRACE(("restore regs {66,41,68} <- 0x%x 0x%x 0x%x\n",
                      saved_reg66, saved_reg41, saved_reg68));
        }
        saved_status = FALSE;

    }
    else {
        WL_ERR(("%s Unkwown yet power setting, ignored\n",
                __FUNCTION__));
    }

    snprintf(command, 3, "OK");

    return (strlen("OK"));
}
Пример #18
0
static
int axusbnet_stop (struct net_device *net)
{
	struct usbnet		*dev = netdev_priv(net);
	struct driver_info	*info = dev->driver_info;
	int			temp;
	int			retval;
#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18)
	DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup);
#else
	DECLARE_WAIT_QUEUE_HEAD (unlink_wakeup);
#endif
	DECLARE_WAITQUEUE (wait, current);

	netif_stop_queue (net);

	if (netif_msg_ifdown (dev))
		devinfo (dev, "stop stats: rx/tx %ld/%ld, errs %ld/%ld",
			dev->stats.rx_packets, dev->stats.tx_packets,
			dev->stats.rx_errors, dev->stats.tx_errors
			);

	/* allow minidriver to stop correctly (wireless devices to turn off
	 * radio etc) */
	if (info->stop) {
		retval = info->stop(dev);
		if (retval < 0 && netif_msg_ifdown(dev))
			devinfo(dev,
				"stop fail (%d) usbnet usb-%s-%s, %s",
				retval,
				dev->udev->bus->bus_name, dev->udev->devpath,
				info->description);
	}

	if (!(info->flags & FLAG_AVOID_UNLINK_URBS)) {
		/* ensure there are no more active urbs */
		add_wait_queue(&unlink_wakeup, &wait);
		dev->wait = &unlink_wakeup;
		temp = unlink_urbs(dev, &dev->txq) +
			unlink_urbs(dev, &dev->rxq);

		/* maybe wait for deletions to finish. */
		while (!skb_queue_empty(&dev->rxq)
				&& !skb_queue_empty(&dev->txq)
				&& !skb_queue_empty(&dev->done)) {
			msleep(UNLINK_TIMEOUT_MS);
			if (netif_msg_ifdown(dev))
				devdbg(dev, "waited for %d urb completions",
					temp);
		}
		dev->wait = NULL;
		remove_wait_queue(&unlink_wakeup, &wait);
	}

	usb_kill_urb(dev->interrupt);

	/* deferred work (task, timer, softirq) must also stop.
	 * can't flush_scheduled_work() until we drop rtnl (later),
	 * else workers could deadlock; so make workers a NOP.
	 */
	dev->flags = 0;
	del_timer_sync (&dev->delay);
	tasklet_kill (&dev->bh);

	return 0;
}
Пример #19
0
static void wdt_shutdown(void)
{
	del_timer_sync(&timer);
	wdt_disable();
}
Пример #20
0
int
del_timer(struct timer_list *t)
{
	del_timer_sync(t);
	return 0;
}
Пример #21
0
static int ath9k_htc_set_channel(struct ath9k_htc_priv *priv,
				 struct ieee80211_hw *hw,
				 struct ath9k_channel *hchan)
{
	struct ath_hw *ah = priv->ah;
	struct ath_common *common = ath9k_hw_common(ah);
	struct ieee80211_conf *conf = &common->hw->conf;
	bool fastcc;
	struct ieee80211_channel *channel = hw->conf.channel;
	struct ath9k_hw_cal_data *caldata = NULL;
	enum htc_phymode mode;
	__be16 htc_mode;
	u8 cmd_rsp;
	int ret;

	if (priv->op_flags & OP_INVALID)
		return -EIO;

	fastcc = !!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL);

	ath9k_htc_ps_wakeup(priv);

	del_timer_sync(&priv->tx.cleanup_timer);
	ath9k_htc_tx_drain(priv);

	WMI_CMD(WMI_DISABLE_INTR_CMDID);
	WMI_CMD(WMI_DRAIN_TXQ_ALL_CMDID);
	WMI_CMD(WMI_STOP_RECV_CMDID);

	ath9k_wmi_event_drain(priv);

	ath_dbg(common, ATH_DBG_CONFIG,
		"(%u MHz) -> (%u MHz), HT: %d, HT40: %d fastcc: %d\n",
		priv->ah->curchan->channel,
		channel->center_freq, conf_is_ht(conf), conf_is_ht40(conf),
		fastcc);

	if (!fastcc)
		caldata = &priv->caldata;

	ret = ath9k_hw_reset(ah, hchan, caldata, fastcc);
	if (ret) {
		ath_err(common,
			"Unable to reset channel (%u Mhz) reset status %d\n",
			channel->center_freq, ret);
		goto err;
	}

	ath9k_cmn_update_txpow(ah, priv->curtxpow, priv->txpowlimit,
			       &priv->curtxpow);

	WMI_CMD(WMI_START_RECV_CMDID);
	if (ret)
		goto err;

	ath9k_host_rx_init(priv);

	mode = ath9k_htc_get_curmode(priv, hchan);
	htc_mode = cpu_to_be16(mode);
	WMI_CMD_BUF(WMI_SET_MODE_CMDID, &htc_mode);
	if (ret)
		goto err;

	WMI_CMD(WMI_ENABLE_INTR_CMDID);
	if (ret)
		goto err;

	htc_start(priv->htc);

	if (!(priv->op_flags & OP_SCANNING) &&
	    !(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL))
		ath9k_htc_vif_reconfig(priv);

	mod_timer(&priv->tx.cleanup_timer,
		  jiffies + msecs_to_jiffies(ATH9K_HTC_TX_CLEANUP_INTERVAL));

err:
	ath9k_htc_ps_restore(priv);
	return ret;
}
Пример #22
0
static void cm4040_stop_poll(struct reader_dev *dev)
{
	del_timer_sync(&dev->poll_timer);
}
Пример #23
0
/**
 *      suspend_wdclr - clear suspend watchdog timer.
 *
 */
static void suspend_wdclr(void)
{
	del_timer_sync(&suspend_wd);
}
Пример #24
0
/*
 *  Send or receive packet.
 */
static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size,
		int msg_flags)
{
	struct socket *sock = lo->sock;
	int result;
	struct msghdr msg;
	struct kvec iov;
	sigset_t blocked, oldset;

	if (unlikely(!sock)) {
		dev_err(disk_to_dev(lo->disk),
			"Attempted %s on closed socket in sock_xmit\n",
			(send ? "send" : "recv"));
		return -EINVAL;
	}

	/* Allow interception of SIGKILL only
	 * Don't allow other signals to interrupt the transmission */
	siginitsetinv(&blocked, sigmask(SIGKILL));
	sigprocmask(SIG_SETMASK, &blocked, &oldset);

	do {
		sock->sk->sk_allocation = GFP_NOIO;
		iov.iov_base = buf;
		iov.iov_len = size;
		msg.msg_name = NULL;
		msg.msg_namelen = 0;
		msg.msg_control = NULL;
		msg.msg_controllen = 0;
		msg.msg_flags = msg_flags | MSG_NOSIGNAL;

		if (send) {
			struct timer_list ti;

			if (lo->xmit_timeout) {
				init_timer(&ti);
				ti.function = nbd_xmit_timeout;
				ti.data = (unsigned long)current;
				ti.expires = jiffies + lo->xmit_timeout;
				add_timer(&ti);
			}
			result = kernel_sendmsg(sock, &msg, &iov, 1, size);
			if (lo->xmit_timeout)
				del_timer_sync(&ti);
		} else
			result = kernel_recvmsg(sock, &msg, &iov, 1, size,
						msg.msg_flags);

		if (signal_pending(current)) {
			siginfo_t info;
			printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n",
				task_pid_nr(current), current->comm,
				dequeue_signal_lock(current, &current->blocked, &info));
			result = -EINTR;
			sock_shutdown(lo, !send);
			break;
		}

		if (result <= 0) {
			if (result == 0)
				result = -EPIPE; /* short read */
			break;
		}
		size -= result;
		buf += result;
	} while (size > 0);

	sigprocmask(SIG_SETMASK, &oldset, NULL);

	return result;
}
Пример #25
0
static void on_receive_block(struct r3964_info *pInfo)
{
	unsigned int length;
	struct r3964_client_info *pClient;
	struct r3964_block_header *pBlock;

	length = pInfo->rx_position;

	/* compare byte checksum characters: */
	if (pInfo->flags & R3964_BCC) {
		if (pInfo->bcc != pInfo->last_rx) {
			TRACE_PE("checksum error - got %x but expected %x",
				 pInfo->last_rx, pInfo->bcc);
			pInfo->flags |= R3964_CHECKSUM;
		}
	}

	/* check for errors (parity, overrun,...): */
	if (pInfo->flags & R3964_ERROR) {
		TRACE_PE("on_receive_block - transmission failed error %x",
			 pInfo->flags & R3964_ERROR);

		put_char(pInfo, NAK);
		flush(pInfo);
		if (pInfo->nRetry < R3964_MAX_RETRIES) {
			pInfo->state = R3964_WAIT_FOR_RX_REPEAT;
			pInfo->nRetry++;
			mod_timer(&pInfo->tmr, jiffies + R3964_TO_RX_PANIC);
		} else {
			TRACE_PE("on_receive_block - failed after max retries");
			pInfo->state = R3964_IDLE;
		}
		return;
	}

	/* received block; submit DLE: */
	put_char(pInfo, DLE);
	flush(pInfo);
	del_timer_sync(&pInfo->tmr);
	TRACE_PS(" rx success: got %d chars", length);

	/* prepare struct r3964_block_header: */
	pBlock = kmalloc(length + sizeof(struct r3964_block_header),
			GFP_KERNEL);
	TRACE_M("on_receive_block - kmalloc %p", pBlock);

	if (pBlock == NULL)
		return;

	pBlock->length = length;
	pBlock->data = ((unsigned char *)pBlock) +
			sizeof(struct r3964_block_header);
	pBlock->locks = 0;
	pBlock->next = NULL;
	pBlock->owner = NULL;

	memcpy(pBlock->data, pInfo->rx_buf, length);

	/* queue block into rx_queue: */
	add_rx_queue(pInfo, pBlock);

	/* notify attached client processes: */
	for (pClient = pInfo->firstClient; pClient; pClient = pClient->next) {
		if (pClient->sig_flags & R3964_SIG_DATA) {
			add_msg(pClient, R3964_MSG_DATA, length, R3964_OK,
				pBlock);
		}
	}
	wake_up_interruptible(&pInfo->read_wait);

	pInfo->state = R3964_IDLE;

	trigger_transmit(pInfo);
}
Пример #26
0
/********************************************************************************************************************
 *function:  deactivate BA entry, including its timer.
 *   input:  PBA_RECORD 		pBA  //BA entry to be disabled
 *  output:  none
********************************************************************************************************************/
void DeActivateBAEntry( struct ieee80211_device* ieee, PBA_RECORD pBA)
{
	pBA->bValid = false;
	del_timer_sync(&pBA->Timer);
}
Пример #27
0
/*
 * This function is used to shutdown the driver.
 *
 * The following operations are performed sequentially -
 *      - Check if already shut down
 *      - Make sure the main process has stopped
 *      - Clean up the Tx and Rx queues
 *      - Delete BSS priority tables
 *      - Free the adapter
 *      - Notify completion
 */
int
mwifiex_shutdown_drv(struct mwifiex_adapter *adapter)
{
	int ret = -EINPROGRESS;
	struct mwifiex_private *priv;
	s32 i;
	unsigned long flags;
	struct sk_buff *skb;

	/* mwifiex already shutdown */
	if (adapter->hw_status == MWIFIEX_HW_STATUS_NOT_READY)
		return 0;

	adapter->hw_status = MWIFIEX_HW_STATUS_CLOSING;
	/* wait for mwifiex_process to complete */
	if (adapter->mwifiex_processing) {
		mwifiex_dbg(adapter, WARN,
			    "main process is still running\n");
		return ret;
	}

	/* cancel current command */
	if (adapter->curr_cmd) {
		mwifiex_dbg(adapter, WARN,
			    "curr_cmd is still in processing\n");
		del_timer_sync(&adapter->cmd_timer);
		mwifiex_recycle_cmd_node(adapter, adapter->curr_cmd);
		adapter->curr_cmd = NULL;
	}

	/* shut down mwifiex */
	mwifiex_dbg(adapter, MSG,
		    "info: shutdown mwifiex...\n");

	/* Clean up Tx/Rx queues and delete BSS priority table */
	for (i = 0; i < adapter->priv_num; i++) {
		if (adapter->priv[i]) {
			priv = adapter->priv[i];

			mwifiex_clean_auto_tdls(priv);
			mwifiex_abort_cac(priv);
			mwifiex_clean_txrx(priv);
			mwifiex_delete_bss_prio_tbl(priv);
		}
	}

	atomic_set(&adapter->tx_queued, 0);
	while ((skb = skb_dequeue(&adapter->tx_data_q)))
		mwifiex_write_data_complete(adapter, skb, 0, 0);

	spin_lock_irqsave(&adapter->rx_proc_lock, flags);

	while ((skb = skb_dequeue(&adapter->rx_data_q))) {
		struct mwifiex_rxinfo *rx_info = MWIFIEX_SKB_RXCB(skb);

		atomic_dec(&adapter->rx_pending);
		priv = adapter->priv[rx_info->bss_num];
		if (priv)
			priv->stats.rx_dropped++;

		dev_kfree_skb_any(skb);
	}

	spin_unlock_irqrestore(&adapter->rx_proc_lock, flags);

	spin_lock(&adapter->mwifiex_lock);

	mwifiex_adapter_cleanup(adapter);

	spin_unlock(&adapter->mwifiex_lock);

	/* Notify completion */
	ret = mwifiex_shutdown_fw_complete(adapter);

	return ret;
}
Пример #28
0
/********************************************************************************************************************
 *function: RX DELBA
 *   input:  struct sk_buff *   skb	//incoming ADDBAReq skb.
 *  return:  0(pass), other(fail)
 *  notice:  As this function need support of QOS, I comment some code out. And when qos is ready, this code need to be support.
********************************************************************************************************************/
int ieee80211_rx_DELBA(struct ieee80211_device* ieee,struct sk_buff *skb)
{
	 struct ieee80211_hdr_3addr* delba = NULL;
	PDELBA_PARAM_SET	pDelBaParamSet = NULL;
	u16*			pReasonCode = NULL;
	u8*			dst = NULL;

	if (skb->len < sizeof( struct ieee80211_hdr_3addr) + 6)
	{
		IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %d)\n", skb->len, 	(sizeof( struct ieee80211_hdr_3addr) + 6));
		return -1;
	}

	if(ieee->current_network.qos_data.active == 0 ||
		ieee->pHTInfo->bCurrentHTSupport == false )
	{
		IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport);
		return -1;
	}

	IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
	delba = ( struct ieee80211_hdr_3addr*)skb->data;
	dst = (u8*)(&delba->addr2[0]);
	delba += sizeof( struct ieee80211_hdr_3addr);
	pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2);
	pReasonCode = (u16*)(delba+4);

	if(pDelBaParamSet->field.Initiator == 1)
	{
		PRX_TS_RECORD 	pRxTs;

		if( !GetTs(
				ieee,
				(PTS_COMMON_INFO*)&pRxTs,
				dst,
				(u8)pDelBaParamSet->field.TID,
				RX_DIR,
				false)	)
		{
			IEEE80211_DEBUG(IEEE80211_DL_ERR,  "can't get TS for RXTS in %s()\n", __FUNCTION__);
			return -1;
		}

		RxTsDeleteBA(ieee, pRxTs);
	}
	else
	{
		PTX_TS_RECORD	pTxTs;

		if(!GetTs(
			ieee,
			(PTS_COMMON_INFO*)&pTxTs,
			dst,
			(u8)pDelBaParamSet->field.TID,
			TX_DIR,
			false)	)
		{
			IEEE80211_DEBUG(IEEE80211_DL_ERR,  "can't get TS for TXTS in %s()\n", __FUNCTION__);
			return -1;
		}

		pTxTs->bUsingBa = false;
		pTxTs->bAddBaReqInProgress = false;
		pTxTs->bAddBaReqDelayed = false;
		del_timer_sync(&pTxTs->TsAddBaTimer);
		//PlatformCancelTimer(Adapter, &pTxTs->TsAddBaTimer);
		TxTsDeleteBA(ieee, pTxTs);
	}
	return 0;
}
Пример #29
0
static void
sa1100_set_termios(struct uart_port *port, struct termios *termios,
		   struct termios *old)
{
	struct sa1100_port *sport = (struct sa1100_port *)port;
	unsigned long flags;
	unsigned int utcr0, old_utcr3, baud, quot;
	unsigned int old_csize = old ? old->c_cflag & CSIZE : CS8;

	/*
	 * We only support CS7 and CS8.
	 */
	while ((termios->c_cflag & CSIZE) != CS7 &&
	       (termios->c_cflag & CSIZE) != CS8) {
		termios->c_cflag &= ~CSIZE;
		termios->c_cflag |= old_csize;
		old_csize = CS8;
	}

	if ((termios->c_cflag & CSIZE) == CS8)
		utcr0 = UTCR0_DSS;
	else
		utcr0 = 0;

	if (termios->c_cflag & CSTOPB)
		utcr0 |= UTCR0_SBS;
	if (termios->c_cflag & PARENB) {
		utcr0 |= UTCR0_PE;
		if (!(termios->c_cflag & PARODD))
			utcr0 |= UTCR0_OES;
	}

	/*
	 * Ask the core to calculate the divisor for us.
	 */
	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16); 
	quot = uart_get_divisor(port, baud);

	spin_lock_irqsave(&sport->port.lock, flags);

	sport->port.read_status_mask &= UTSR0_TO_SM(UTSR0_TFS);
	sport->port.read_status_mask |= UTSR1_TO_SM(UTSR1_ROR);
	if (termios->c_iflag & INPCK)
		sport->port.read_status_mask |=
				UTSR1_TO_SM(UTSR1_FRE | UTSR1_PRE);
	if (termios->c_iflag & (BRKINT | PARMRK))
		sport->port.read_status_mask |=
				UTSR0_TO_SM(UTSR0_RBB | UTSR0_REB);

	/*
	 * Characters to ignore
	 */
	sport->port.ignore_status_mask = 0;
	if (termios->c_iflag & IGNPAR)
		sport->port.ignore_status_mask |=
				UTSR1_TO_SM(UTSR1_FRE | UTSR1_PRE);
	if (termios->c_iflag & IGNBRK) {
		sport->port.ignore_status_mask |=
				UTSR0_TO_SM(UTSR0_RBB | UTSR0_REB);
		/*
		 * If we're ignoring parity and break indicators,
		 * ignore overruns too (for real raw support).
		 */
		if (termios->c_iflag & IGNPAR)
			sport->port.ignore_status_mask |=
				UTSR1_TO_SM(UTSR1_ROR);
	}

	del_timer_sync(&sport->timer);

	/*
	 * Update the per-port timeout.
	 */
	uart_update_timeout(port, termios->c_cflag, baud);

	/*
	 * disable interrupts and drain transmitter
	 */
	old_utcr3 = UART_GET_UTCR3(sport);
	UART_PUT_UTCR3(sport, old_utcr3 & ~(UTCR3_RIE | UTCR3_TIE));

	while (UART_GET_UTSR1(sport) & UTSR1_TBY)
		barrier();

	/* then, disable everything */
	UART_PUT_UTCR3(sport, 0);

	/* set the parity, stop bits and data size */
	UART_PUT_UTCR0(sport, utcr0);

	/* set the baud rate */
	quot -= 1;
	UART_PUT_UTCR1(sport, ((quot & 0xf00) >> 8));
	UART_PUT_UTCR2(sport, (quot & 0xff));

	UART_PUT_UTSR0(sport, -1);

	UART_PUT_UTCR3(sport, old_utcr3);

	if (UART_ENABLE_MS(&sport->port, termios->c_cflag))
		sa1100_enable_ms(&sport->port);

	spin_unlock_irqrestore(&sport->port.lock, flags);
}
Пример #30
0
static int __devinit gpio_keys_probe(struct platform_device *pdev)
{
	struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
	struct gpio_keys_drvdata *ddata;
	struct input_dev *input;
	int i, error;
	int wakeup = 0;

	ddata = kzalloc(sizeof(struct gpio_keys_drvdata) +
			pdata->nbuttons * sizeof(struct gpio_button_data),
			GFP_KERNEL);
	input = input_allocate_device();
	if (!ddata || !input) {
		error = -ENOMEM;
		goto fail1;
	}

	platform_set_drvdata(pdev, ddata);

	input->name = pdev->name;
	input->phys = "gpio-keys/input0";
	input->dev.parent = &pdev->dev;

	input->id.bustype = BUS_HOST;
	input->id.vendor = 0x0001;
	input->id.product = 0x0001;
	input->id.version = 0x0100;

	/* Enable auto repeat feature of Linux input subsystem */
	if (pdata->rep)
		__set_bit(EV_REP, input->evbit);

	ddata->input = input;

#if 1 /* TERRY(2010-0401): Save the address of input */
	input_device = input;
#endif

	for (i = 0; i < pdata->nbuttons; i++) {
		struct gpio_keys_button *button = &pdata->buttons[i];
		struct gpio_button_data *bdata = &ddata->data[i];
		int irq;
		unsigned int type = button->type ?: EV_KEY;

		bdata->input = input;
		bdata->button = button;
		setup_timer(&bdata->timer,
			    gpio_check_button, (unsigned long)bdata);
#if 1 /* 2009-0903, added by CVKK(JC) */
		if (button->code == MULTI_FUN_KEY_DEF)
			setup_timer(&cv_handle_multi_key_timer, cv_handle_multi_key, (unsigned long)bdata);
		if (button->code == MULTI_FUN_KEY_DEF_02)
			setup_timer(&cv_handle_multi_key_02_timer, cv_handle_multi_key_02, (unsigned long)bdata);
	        if (button->code == MULTI_FUN_KEY_PLUS)
	            setup_timer(&cv_handle_multi_key_plus_timer, cv_handle_multi_key_plus, 
			                  (unsigned long)bdata);
#endif	   

		error = gpio_request(button->gpio, button->desc ?: "gpio_keys");
		if (error < 0) {
			pr_err("gpio-keys: failed to request GPIO %d,"
				" error %d\n", button->gpio, error);
			goto fail2;
		}

		error = gpio_direction_input(button->gpio);
		if (error < 0) {
			pr_err("gpio-keys: failed to configure input"
				" direction for GPIO %d, error %d\n",
				button->gpio, error);
			gpio_free(button->gpio);
			goto fail2;
		}

		irq = gpio_to_irq(button->gpio);
		if (irq < 0) {
			error = irq;
			pr_err("gpio-keys: Unable to get irq number"
				" for GPIO %d, error %d\n",
				button->gpio, error);
			gpio_free(button->gpio);
			goto fail2;
		}

		error = request_irq(irq, gpio_keys_isr,
				    IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
					IRQF_TRIGGER_FALLING,
				    button->desc ? button->desc : "gpio_keys",
				    bdata);
		if (error) {
			pr_err("gpio-keys: Unable to claim irq %d; error %d\n",
				irq, error);
			gpio_free(button->gpio);
			goto fail2;
		}

		if (button->wakeup)
			wakeup = 1;

		input_set_capability(input, type, button->code);
#if 1 /* 2009-0903 , added by CVKK(JC) */
		if (button->code == MULTI_FUN_KEY_DEF)
			input_set_capability(input, type, MULTI_FUN_KEY_OTH);
		if (button->code == MULTI_FUN_KEY_DEF_02)
			input_set_capability(input, type, MULTI_FUN_KEY_OTH_02);
	        if (button->code == MULTI_FUN_KEY_PLUS)
	                input_set_capability(input, type, MULTI_FUN_KEY_PLUS2);
#endif	   
	}

	error = input_register_device(input);
	if (error) {
		pr_err("gpio-keys: Unable to register input device, "
			"error: %d\n", error);
		goto fail2;
	}

	device_init_wakeup(&pdev->dev, wakeup);

	return 0;

 fail2:
	while (--i >= 0) {
		free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
		if (pdata->buttons[i].debounce_interval)
			del_timer_sync(&ddata->data[i].timer);
		gpio_free(pdata->buttons[i].gpio);
	}

	platform_set_drvdata(pdev, NULL);
 fail1:
	input_free_device(input);
	kfree(ddata);

	return error;
}