您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ test_and_set_bit函数代码示例

51自学网 2021-06-03 08:44:52
  C++
这篇教程C++ test_and_set_bit函数代码示例写得很实用,希望能帮到您。

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

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

示例1: amd7930_Dchan_l2l1

static voidamd7930_Dchan_l2l1(struct PStack *st, int pr, void *arg){	struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;	struct sk_buff *skb = arg;	char str[64];	switch (pr) {		case (PH_DATA_REQ):			if (cs->tx_skb) {				skb_queue_tail(&cs->sq, skb);#ifdef L2FRAME_DEBUG		/* psa */				if (cs->debug & L1_DEB_LAPD)					Logl2Frame(cs, skb, "PH_DATA Queued", 0);#endif			} else {				if ((cs->dlogflag) && (!(skb->data[2] & 1))) {					/* I-FRAME */					LogFrame(cs, skb->data, skb->len);					sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);					dlogframe(cs, skb->data+4, skb->len-4,						  str);				}				cs->tx_skb = skb;				cs->tx_cnt = 0;#ifdef L2FRAME_DEBUG		/* psa */				if (cs->debug & L1_DEB_LAPD)					Logl2Frame(cs, skb, "PH_DATA", 0);#endif				amd7930_dxmit(0, skb->data, skb->len,					      &amd7930_dxmit_callback, cs);			}			break;		case (PH_PULL_IND):			if (cs->tx_skb) {				if (cs->debug & L1_DEB_WARN)					debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");				skb_queue_tail(&cs->sq, skb);				break;			}			if ((cs->dlogflag) && (!(skb->data[2] & 1))) {	/* I-FRAME */				LogFrame(cs, skb->data, skb->len);				sprintf(str, "Q.931 frame user->network tei %d", st->l2.tei);				dlogframe(cs, skb->data + 4, skb->len - 4,					  str);			}			cs->tx_skb = skb;			cs->tx_cnt = 0;#ifdef L2FRAME_DEBUG		/* psa */			if (cs->debug & L1_DEB_LAPD)				Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);#endif			amd7930_dxmit(0, cs->tx_skb->data, cs->tx_skb->len,				      &amd7930_dxmit_callback, cs);			break;		case (PH_PULL_REQ):#ifdef L2FRAME_DEBUG		/* psa */			if (cs->debug & L1_DEB_LAPD)				debugl1(cs, "-> PH_REQUEST_PULL");#endif			if (!cs->tx_skb) {				test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);				st->l1.l1l2(st, PH_PULL_CNF, NULL);			} else				test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);			break;	}}
开发者ID:fgeraci,项目名称:cs518-sched,代码行数:68,


示例2: bluecard_write_wakeup

static void bluecard_write_wakeup(bluecard_info_t *info){	if (!info) {		printk(KERN_WARNING "bluecard_cs: Call of write_wakeup for unknown device./n");		return;	}	if (!test_bit(XMIT_SENDING_READY, &(info->tx_state)))		return;	if (test_and_set_bit(XMIT_SENDING, &(info->tx_state))) {		set_bit(XMIT_WAKEUP, &(info->tx_state));		return;	}	do {		register unsigned int iobase = info->link.io.BasePort1;		register unsigned int offset;		register unsigned char command;		register unsigned long ready_bit;		register struct sk_buff *skb;		register int len;		clear_bit(XMIT_WAKEUP, &(info->tx_state));		if (!(info->link.state & DEV_PRESENT))			return;		if (test_bit(XMIT_BUFFER_NUMBER, &(info->tx_state))) {			if (!test_bit(XMIT_BUF_TWO_READY, &(info->tx_state)))				break;			offset = 0x10;			command = REG_COMMAND_TX_BUF_TWO;			ready_bit = XMIT_BUF_TWO_READY;		} else {			if (!test_bit(XMIT_BUF_ONE_READY, &(info->tx_state)))				break;			offset = 0x00;			command = REG_COMMAND_TX_BUF_ONE;			ready_bit = XMIT_BUF_ONE_READY;		}		if (!(skb = skb_dequeue(&(info->txq))))			break;		if (skb->pkt_type & 0x80) {			/* Disable RTS */			info->ctrl_reg |= REG_CONTROL_RTS;			outb(info->ctrl_reg, iobase + REG_CONTROL);		}		/* Activate LED */		bluecard_enable_activity_led(info);		/* Send frame */		len = bluecard_write(iobase, offset, skb->data, skb->len);		/* Tell the FPGA to send the data */		outb_p(command, iobase + REG_COMMAND);		/* Mark the buffer as dirty */		clear_bit(ready_bit, &(info->tx_state));		if (skb->pkt_type & 0x80) {			wait_queue_head_t wait;			unsigned char baud_reg;			switch (skb->pkt_type) {			case PKT_BAUD_RATE_460800:				baud_reg = REG_CONTROL_BAUD_RATE_460800;				break;			case PKT_BAUD_RATE_230400:				baud_reg = REG_CONTROL_BAUD_RATE_230400;				break;			case PKT_BAUD_RATE_115200:				baud_reg = REG_CONTROL_BAUD_RATE_115200;				break;			case PKT_BAUD_RATE_57600:				/* Fall through... */			default:				baud_reg = REG_CONTROL_BAUD_RATE_57600;				break;			}			/* Wait until the command reaches the baseband */			init_waitqueue_head(&wait);			interruptible_sleep_on_timeout(&wait, HZ / 10);			/* Set baud on baseband */			info->ctrl_reg &= ~0x03;			info->ctrl_reg |= baud_reg;			outb(info->ctrl_reg, iobase + REG_CONTROL);			/* Enable RTS */			info->ctrl_reg &= ~REG_CONTROL_RTS;			outb(info->ctrl_reg, iobase + REG_CONTROL);			/* Wait before the next HCI packet can be send */			interruptible_sleep_on_timeout(&wait, HZ);//.........这里部分代码省略.........
开发者ID:GunioRobot,项目名称:MI424WR_GEN2_Rev_E-F,代码行数:101,


示例3: hisax_cs_new

static int hisax_cs_new(int cardnr, char *id, struct IsdnCard *card,			struct IsdnCardState **cs_out, int *busy_flag,			struct module *lockowner){	struct IsdnCardState *cs;	*cs_out = NULL;	cs = kzalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);	if (!cs) {		printk(KERN_WARNING		       "HiSax: No memory for IsdnCardState(card %d)/n",		       cardnr + 1);		goto out;	}	card->cs = cs;	spin_lock_init(&cs->statlock);	spin_lock_init(&cs->lock);	cs->chanlimit = 2;	/* maximum B-channel number */	cs->logecho = 0;	/* No echo logging */	cs->cardnr = cardnr;	cs->debug = L1_DEB_WARN;	cs->HW_Flags = 0;	cs->busy_flag = busy_flag;	cs->irq_flags = I4L_IRQ_FLAG;#if TEI_PER_CARD	if (card->protocol == ISDN_PTYPE_NI1)		test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);#else	test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);#endif	cs->protocol = card->protocol;	if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {		printk(KERN_WARNING		       "HiSax: Card Type %d out of range/n", card->typ);		goto outf_cs;	}	if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {		printk(KERN_WARNING		       "HiSax: No memory for dlog(card %d)/n", cardnr + 1);		goto outf_cs;	}	if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {		printk(KERN_WARNING		       "HiSax: No memory for status_buf(card %d)/n",		       cardnr + 1);		goto outf_dlog;	}	cs->stlist = NULL;	cs->status_read = cs->status_buf;	cs->status_write = cs->status_buf;	cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;	cs->typ = card->typ;#ifdef MODULE	cs->iif.owner = lockowner;#endif	strcpy(cs->iif.id, id);	cs->iif.channels = 2;	cs->iif.maxbufsize = MAX_DATA_SIZE;	cs->iif.hl_hdrlen = MAX_HEADER_LEN;	cs->iif.features =		ISDN_FEATURE_L2_X75I |		ISDN_FEATURE_L2_HDLC |		ISDN_FEATURE_L2_HDLC_56K |		ISDN_FEATURE_L2_TRANS |		ISDN_FEATURE_L3_TRANS |#ifdef	CONFIG_HISAX_1TR6		ISDN_FEATURE_P_1TR6 |#endif#ifdef	CONFIG_HISAX_EURO		ISDN_FEATURE_P_EURO |#endif#ifdef	CONFIG_HISAX_NI1		ISDN_FEATURE_P_NI1 |#endif		0;	cs->iif.command = HiSax_command;	cs->iif.writecmd = NULL;	cs->iif.writebuf_skb = HiSax_writebuf_skb;	cs->iif.readstat = HiSax_readstatus;	register_isdn(&cs->iif);	cs->myid = cs->iif.channels;	*cs_out = cs;	return 1;	/* success */outf_dlog:	kfree(cs->dlog);outf_cs:	kfree(cs);	card->cs = NULL;out:	return 0;	/* error */}
开发者ID:eddie-wang,项目名称:linux-2,代码行数:96,


示例4: arcofi_fsm

intarcofi_fsm(struct IsdnCardState *cs, int event, void *data) {	if (cs->debug & L1_DEB_MONITOR) {		debugl1(cs, "arcofi state %d event %d", cs->dc.isac.arcofi_state, event);	}	if (event == ARCOFI_TIMEOUT) {		cs->dc.isac.arcofi_state = ARCOFI_NOP;		test_and_set_bit(FLG_ARCOFI_ERROR, &cs->HW_Flags);		wake_up(&cs->dc.isac.arcofi_wait); 		return(1);	}	switch (cs->dc.isac.arcofi_state) {		case ARCOFI_NOP:			if (event == ARCOFI_START) {				cs->dc.isac.arcofi_list = data;				cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT;				send_arcofi(cs);			}			break;		case ARCOFI_TRANSMIT:			if (event == ARCOFI_TX_END) {				if (cs->dc.isac.arcofi_list->receive) {					add_arcofi_timer(cs);					cs->dc.isac.arcofi_state = ARCOFI_RECEIVE;				} else {					if (cs->dc.isac.arcofi_list->next) {						cs->dc.isac.arcofi_list =							cs->dc.isac.arcofi_list->next;						send_arcofi(cs);					} else {						if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) {							del_timer(&cs->dc.isac.arcofitimer);						}						cs->dc.isac.arcofi_state = ARCOFI_NOP;						wake_up(&cs->dc.isac.arcofi_wait);					}				}			}			break;		case ARCOFI_RECEIVE:			if (event == ARCOFI_RX_END) {				if (cs->dc.isac.arcofi_list->next) {					cs->dc.isac.arcofi_list =						cs->dc.isac.arcofi_list->next;					cs->dc.isac.arcofi_state = ARCOFI_TRANSMIT;					send_arcofi(cs);				} else {					if (test_and_clear_bit(FLG_ARCOFI_TIMER, &cs->HW_Flags)) {						del_timer(&cs->dc.isac.arcofitimer);					}					cs->dc.isac.arcofi_state = ARCOFI_NOP;					wake_up(&cs->dc.isac.arcofi_wait);				}			}			break;		default:			debugl1(cs, "Arcofi unknown state %x", cs->dc.isac.arcofi_state);			return(2);	}	return(0);}
开发者ID:1703011,项目名称:asuswrt-merlin,代码行数:61,


示例5: snd_i2s_alsa_ifx_pcm_trigger

/* * snd_i2s_alsa_ifx_pcm_trigger- stream activities are handled here * This function is called whenever a stream activity is invoked * The Trigger function is called in an atomic context * * Input parameters *		@substream:substream for which the stream function is called *		@cmd:the stream command thats requested from upper layer * * Output parameters *		@ret_val : status, 0 ==> OK * */int snd_i2s_alsa_ifx_pcm_trigger(struct snd_pcm_substream *substream, int cmd){	int ret_val = 0;	struct intel_alsa_ifx_stream_info *str_info;	struct snd_pcm_runtime *pl_runtime;	struct intel_alsa_ssp_dma_buf *pl_dma_buf;	bool trigger_start = true;	WARN(!substream, "ALSA_IFX: ERROR NULL substream/n");	if (!substream)		return -EINVAL;	WARN(!substream->runtime, "ALSA_IFX: ERROR NULL substream->runtime/n");	if (!substream->runtime)		return -EINVAL;	pl_runtime = substream->runtime;	WARN(!pl_runtime->private_data,			"ALSA_IFX: ERROR NULL pl_runtime->private_data/n");	if (!pl_runtime->private_data)		return -EINVAL;	str_info = pl_runtime->private_data;	pl_dma_buf = &(str_info->dma_slot);	pr_debug("ALSA_IFX:  snd_i2s_alsa_ifx_pcm_trigger CMD = 0x%04X/n", cmd);	switch (cmd) {	case SNDRV_PCM_TRIGGER_START:	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:	case SNDRV_PCM_TRIGGER_RESUME:		pr_debug("ALSA_IFX:  SNDRV_PCM_TRIGGER_START for device %d/n",				str_info->device_id);		pr_debug("ALSA_IFX: Trigger Start period_size =%ld/n",				pl_runtime->period_size);		if (!test_and_set_bit(INTEL_ALSA_SSP_STREAM_STARTED,					&str_info->stream_status)) {			if (test_bit(INTEL_ALSA_SSP_STREAM_DROPPED,					&str_info->stream_status)) {				pr_debug("ALSA IFX: Do not restart the trigger, stream running already/n");				trigger_start = false;			} else				trigger_start = true;		} else {			WARN(1, "ALSA IFX: ERROR 2 conscutive TRIGGER_START/n");			return -EBUSY;		}		/* Store the substream locally */		if (trigger_start) {			pl_dma_buf->length = frames_to_bytes(pl_runtime,					pl_runtime->period_size);			pl_dma_buf->addr = pl_runtime->dma_area;			pl_dma_buf->period_index_max = pl_runtime->periods;			queue_work(p_alsa_ifx_snd_card->ssp_wq,					&str_info->ssp_ws);		}		str_info->dbg_cum_bytes += frames_to_bytes(substream->runtime,				substream->runtime->period_size);		break;	case SNDRV_PCM_TRIGGER_STOP:	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:	case SNDRV_PCM_TRIGGER_SUSPEND:		pr_debug("ALSA_IFX:  SNDRV_PCM_TRIGGER_STOP/n");		if (test_and_clear_bit(INTEL_ALSA_SSP_STREAM_STARTED,				&str_info->stream_status))			set_bit(INTEL_ALSA_SSP_STREAM_DROPPED,					&str_info->stream_status);		else {			WARN(1, "ALSA IFX: trigger START/STOP mismatch/n");			return -EBUSY;		}		break;	default:		WARN(1, "ALSA_IFX: snd_i2s_alsa_ifx_pcm_trigger Bad Command/n");		return -EINVAL;		break;	}	return ret_val;}
开发者ID:kamarush,项目名称:ZTE_GXIn_Kernel-3.0.8,代码行数:99,


示例6: nfcwilink_open

static int nfcwilink_open(struct nci_dev *ndev){	struct nfcwilink *drv = nci_get_drvdata(ndev);	unsigned long comp_ret;	int rc;	nfc_dev_dbg(&drv->pdev->dev, "open entry");	if (test_and_set_bit(NFCWILINK_RUNNING, &drv->flags)) {		rc = -EBUSY;		goto exit;	}	nfcwilink_proto.priv_data = drv;	init_completion(&drv->completed);	drv->st_register_cb_status = -EINPROGRESS;	rc = st_register(&nfcwilink_proto);	if (rc < 0) {		if (rc == -EINPROGRESS) {			comp_ret = wait_for_completion_timeout(			&drv->completed,			msecs_to_jiffies(NFCWILINK_REGISTER_TIMEOUT));			nfc_dev_dbg(&drv->pdev->dev,			"wait_for_completion_timeout returned %ld",			comp_ret);			if (comp_ret == 0) {				/* timeout */				rc = -ETIMEDOUT;				goto clear_exit;			} else if (drv->st_register_cb_status != 0) {				rc = drv->st_register_cb_status;				nfc_dev_err(&drv->pdev->dev,				"st_register_cb failed %d", rc);				goto clear_exit;			}		} else {			nfc_dev_err(&drv->pdev->dev,				"st_register failed %d", rc);			goto clear_exit;		}	}	/* st_register MUST fill the write callback */	BUG_ON(nfcwilink_proto.write == NULL);	drv->st_write = nfcwilink_proto.write;	if (nfcwilink_download_fw(drv)) {		nfc_dev_err(&drv->pdev->dev, "nfcwilink_download_fw failed %d",				rc);		/* open should succeed, even if the FW download failed */	}	goto exit;clear_exit:	clear_bit(NFCWILINK_RUNNING, &drv->flags);exit:	return rc;}
开发者ID:03199618,项目名称:linux,代码行数:64,


示例7: W6692B_interrupt

static voidW6692B_interrupt(struct IsdnCardState *cs, u_char bchan){	u_char val;	u_char r;	struct BCState *bcs;	struct sk_buff *skb;	int count;	bcs = (cs->bcs->channel == bchan) ? cs->bcs : (cs->bcs+1);	val = cs->BC_Read_Reg(cs, bchan, W_B_EXIR);	debugl1(cs, "W6692B chan %d B_EXIR 0x%02X", bchan, val);	if (!test_bit(BC_FLG_INIT, &bcs->Flag)) {		debugl1(cs, "W6692B not INIT yet");		return;	}	if (val & W_B_EXI_RME) {	/* RME */		r = cs->BC_Read_Reg(cs, bchan, W_B_STAR);		if (r & (W_B_STAR_RDOV | W_B_STAR_CRCE | W_B_STAR_RMB | W_B_STAR_XDOW)) {			if ((r & W_B_STAR_RDOV) && bcs->mode)				if (cs->debug & L1_DEB_WARN)					debugl1(cs, "W6692 B RDOV mode=%d",						bcs->mode);			if (r & W_B_STAR_CRCE)				if (cs->debug & L1_DEB_WARN)					debugl1(cs, "W6692 B CRC error");			cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_RACK | W_B_CMDR_RRST | W_B_CMDR_RACT);		} else {			count = cs->BC_Read_Reg(cs, bchan, W_B_RBCL) & (W_B_FIFO_THRESH - 1);			if (count == 0)				count = W_B_FIFO_THRESH;			W6692B_empty_fifo(bcs, count);			if ((count = bcs->hw.w6692.rcvidx) > 0) {				if (cs->debug & L1_DEB_HSCX_FIFO)					debugl1(cs, "W6692 Bchan Frame %d", count);				if (!(skb = dev_alloc_skb(count)))					printk(KERN_WARNING "W6692: Bchan receive out of memory/n");				else {					memcpy(skb_put(skb, count), bcs->hw.w6692.rcvbuf, count);					skb_queue_tail(&bcs->rqueue, skb);				}			}		}		bcs->hw.w6692.rcvidx = 0;		W6692B_sched_event(bcs, B_RCVBUFREADY);	}	if (val & W_B_EXI_RMR) {	/* RMR */		W6692B_empty_fifo(bcs, W_B_FIFO_THRESH);		if (bcs->mode == L1_MODE_TRANS) {			/* receive audio data */			if (!(skb = dev_alloc_skb(W_B_FIFO_THRESH)))				printk(KERN_WARNING "HiSax: receive out of memory/n");			else {				memcpy(skb_put(skb, W_B_FIFO_THRESH), bcs->hw.w6692.rcvbuf, W_B_FIFO_THRESH);				skb_queue_tail(&bcs->rqueue, skb);			}			bcs->hw.w6692.rcvidx = 0;			W6692B_sched_event(bcs, B_RCVBUFREADY);		}	}	if (val & W_B_EXI_XFR) {	/* XFR */		if (bcs->tx_skb) {			if (bcs->tx_skb->len) {				W6692B_fill_fifo(bcs);				return;			} else {				if (bcs->st->lli.l1writewakeup &&				 (PACKET_NOACK != bcs->tx_skb->pkt_type))					bcs->st->lli.l1writewakeup(bcs->st, bcs->hw.w6692.count);				dev_kfree_skb_irq(bcs->tx_skb);				bcs->hw.w6692.count = 0;				bcs->tx_skb = NULL;			}		}		if ((bcs->tx_skb = skb_dequeue(&bcs->squeue))) {			bcs->hw.w6692.count = 0;			test_and_set_bit(BC_FLG_BUSY, &bcs->Flag);			W6692B_fill_fifo(bcs);		} else {			test_and_clear_bit(BC_FLG_BUSY, &bcs->Flag);			W6692B_sched_event(bcs, B_XMTBUFREADY);		}	}	if (val & W_B_EXI_XDUN) {	/* XDUN */		if (bcs->mode == 1)			W6692B_fill_fifo(bcs);		else {			/* Here we lost an TX interrupt, so			   * restart transmitting the whole frame.			 */			if (bcs->tx_skb) {				skb_push(bcs->tx_skb, bcs->hw.w6692.count);				bcs->tx_cnt += bcs->hw.w6692.count;				bcs->hw.w6692.count = 0;			}			cs->BC_Write_Reg(cs, bchan, W_B_CMDR, W_B_CMDR_XRST | W_B_CMDR_RACT);			if (cs->debug & L1_DEB_WARN)				debugl1(cs, "W6692 B EXIR %x Lost TX", val);		}//.........这里部分代码省略.........
开发者ID:SimonKagstrom,项目名称:mci500h-linux-2.4.27,代码行数:101,


示例8: restart_t200

static inline voidrestart_t200(struct PStack *st, int i){	FsmRestartTimer(&st->l2.t200, st->l2.T200, EV_L2_T200, NULL, i);	test_and_set_bit(FLG_T200_RUN, &st->l2.flag);}
开发者ID:tch-opensrc,项目名称:TC72XX_LxG1.7.1mp1_OpenSrc,代码行数:6,


示例9: hisax_b_sched_event

static void hisax_b_sched_event(struct BCState *bcs, int event){	test_and_set_bit(event, &bcs->event);	schedule_work(&bcs->tqueue);}
开发者ID:ena30,项目名称:snake-os,代码行数:5,


示例10: wdt_ioctl

static long wdt_ioctl(struct file *file, unsigned int cmd, unsigned long arg){	void __user *argp = (void __user *)arg;	int __user *p = argp;	int new_timeout;	static const struct watchdog_info ident = {		.options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT |							WDIOF_MAGICCLOSE,		.firmware_version = 1,		.identity = "W83627HF WDT",	};	switch (cmd) {	case WDIOC_GETSUPPORT:		if (copy_to_user(argp, &ident, sizeof(ident)))			return -EFAULT;		break;	case WDIOC_GETSTATUS:	case WDIOC_GETBOOTSTATUS:		return put_user(0, p);	case WDIOC_SETOPTIONS:	{		int options, retval = -EINVAL;		if (get_user(options, p))			return -EFAULT;		if (options & WDIOS_DISABLECARD) {			wdt_disable();			retval = 0;		}		if (options & WDIOS_ENABLECARD) {			wdt_ping();			retval = 0;		}		return retval;	}	case WDIOC_KEEPALIVE:		wdt_ping();		break;	case WDIOC_SETTIMEOUT:		if (get_user(new_timeout, p))			return -EFAULT;		if (wdt_set_heartbeat(new_timeout))			return -EINVAL;		wdt_ping();		/* Fall */	case WDIOC_GETTIMEOUT:		return put_user(timeout, p);	default:		return -ENOTTY;	}	return 0;}static int wdt_open(struct inode *inode, struct file *file){	if (test_and_set_bit(0, &wdt_is_open))		return -EBUSY;	/*	 *	Activate	 */	wdt_ping();	return nonseekable_open(inode, file);}static int wdt_close(struct inode *inode, struct file *file){	if (expect_close == 42)		wdt_disable();	else {//		printk(KERN_CRIT PFX;		wdt_ping();	}	expect_close = 0;	clear_bit(0, &wdt_is_open);	return 0;}/* *	Notifier for system down */static int wdt_notify_sys(struct notifier_block *this, unsigned long code,	void *unused){	if (code == SYS_DOWN || code == SYS_HALT)		wdt_disable();	/* Turn the WDT off */	return NOTIFY_DONE;}/* *	Kernel Interfaces */static const struct file_operations wdt_fops = {	.owner		= THIS_MODULE,	.llseek		= no_llseek,//.........这里部分代码省略.........
开发者ID:rrowicki,项目名称:Chrono_Kernel-1,代码行数:101,


示例11: irq_wake_thread

static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action){	/*	 * In case the thread crashed and was killed we just pretend that	 * we handled the interrupt. The hardirq handler has disabled the	 * device interrupt, so no irq storm is lurking.	 */	if (action->thread->flags & PF_EXITING)		return;	/*	 * Wake up the handler thread for this action. If the	 * RUNTHREAD bit is already set, nothing to do.	 */	if (test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags))		return;	/*	 * It's safe to OR the mask lockless here. We have only two	 * places which write to threads_oneshot: This code and the	 * irq thread.	 *	 * This code is the hard irq context and can never run on two	 * cpus in parallel. If it ever does we have more serious	 * problems than this bitmask.	 *	 * The irq threads of this irq which clear their "running" bit	 * in threads_oneshot are serialized via desc->lock against	 * each other and they are serialized against this code by	 * IRQS_INPROGRESS.	 *	 * Hard irq handler:	 *	 *	spin_lock(desc->lock);	 *	desc->state |= IRQS_INPROGRESS;	 *	spin_unlock(desc->lock);	 *	set_bit(IRQTF_RUNTHREAD, &action->thread_flags);	 *	desc->threads_oneshot |= mask;	 *	spin_lock(desc->lock);	 *	desc->state &= ~IRQS_INPROGRESS;	 *	spin_unlock(desc->lock);	 *	 * irq thread:	 *	 * again:	 *	spin_lock(desc->lock);	 *	if (desc->state & IRQS_INPROGRESS) {	 *		spin_unlock(desc->lock);	 *		while(desc->state & IRQS_INPROGRESS)	 *			cpu_relax();	 *		goto again;	 *	}	 *	if (!test_bit(IRQTF_RUNTHREAD, &action->thread_flags))	 *		desc->threads_oneshot &= ~mask;	 *	spin_unlock(desc->lock);	 *	 * So either the thread waits for us to clear IRQS_INPROGRESS	 * or we are waiting in the flow handler for desc->lock to be	 * released before we reach this point. The thread also checks	 * IRQTF_RUNTHREAD under desc->lock. If set it leaves	 * threads_oneshot untouched and runs the thread another time.	 */	desc->threads_oneshot |= action->thread_mask;	/*	 * We increment the threads_active counter in case we wake up	 * the irq thread. The irq thread decrements the counter when	 * it returns from the handler or in the exit path and wakes	 * up waiters which are stuck in synchronize_irq() when the	 * active count becomes zero. synchronize_irq() is serialized	 * against this code (hard irq handler) via IRQS_INPROGRESS	 * like the finalize_oneshot() code. See comment above.	 */	atomic_inc(&desc->threads_active);	wake_up_process(action->thread);}
开发者ID:StarKissed,项目名称:Note-4-AEL-Kernel,代码行数:77,


示例12: ti_st_open

/* Called from HCI core to initialize the device */static int ti_st_open(struct hci_dev *hdev){	unsigned long timeleft;	struct ti_st *hst;	int err, i;	BT_DBG("%s %p", hdev->name, hdev);	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))		return -EBUSY;	/* provide contexts for callbacks from ST */	hst = hdev->driver_data;	for (i = 0; i < MAX_BT_CHNL_IDS; i++) {		ti_st_proto[i].priv_data = hst;		ti_st_proto[i].max_frame_size = HCI_MAX_FRAME_SIZE;		ti_st_proto[i].recv = st_receive;		ti_st_proto[i].reg_complete_cb = st_reg_completion_cb;		/* Prepare wait-for-completion handler */		init_completion(&hst->wait_reg_completion);		/* Reset ST registration callback status flag,		 * this value will be updated in		 * st_reg_completion_cb()		 * function whenever it called from ST driver.		 */		hst->reg_status = -EINPROGRESS;		err = st_register(&ti_st_proto[i]);		if (!err)			goto done;		if (err != -EINPROGRESS) {			clear_bit(HCI_RUNNING, &hdev->flags);			BT_ERR("st_register failed %d", err);			return err;		}		/* ST is busy with either protocol		 * registration or firmware download.		 */		BT_DBG("waiting for registration "				"completion signal from ST");		timeleft = wait_for_completion_timeout			(&hst->wait_reg_completion,			 msecs_to_jiffies(BT_REGISTER_TIMEOUT));		if (!timeleft) {			clear_bit(HCI_RUNNING, &hdev->flags);			BT_ERR("Timeout(%d sec),didn't get reg "					"completion signal from ST",					BT_REGISTER_TIMEOUT / 1000);			return -ETIMEDOUT;		}		/* Is ST registration callback		 * called with ERROR status? */		if (hst->reg_status != 0) {			clear_bit(HCI_RUNNING, &hdev->flags);			BT_ERR("ST registration completed with invalid "					"status %d", hst->reg_status);			return -EAGAIN;		}done:		hst->st_write = ti_st_proto[i].write;		if (!hst->st_write) {			BT_ERR("undefined ST write function");			clear_bit(HCI_RUNNING, &hdev->flags);			for (i = 0; i < MAX_BT_CHNL_IDS; i++) {				/* Undo registration with ST */				err = st_unregister(&ti_st_proto[i]);				if (err)					BT_ERR("st_unregister() failed with "							"error %d", err);				hst->st_write = NULL;			}			return -EIO;		}	}	return 0;}
开发者ID:303750856,项目名称:linux-3.1,代码行数:83,


示例13: flush_to_ldisc

static void flush_to_ldisc(struct work_struct *work){	struct tty_struct *tty =		container_of(work, struct tty_struct, buf.work);	unsigned long 	flags;	struct tty_ldisc *disc;	disc = tty_ldisc_ref(tty);	if (disc == NULL)	/*  !TTY_LDISC */		return;	spin_lock_irqsave(&tty->buf.lock, flags);	if (!test_and_set_bit(TTY_FLUSHING, &tty->flags)) {		struct tty_buffer *head;		while ((head = tty->buf.head) != NULL) {			int count;			char *char_buf;			unsigned char *flag_buf;			count = head->commit - head->read;			if (!count) {				if (head->next == NULL)					break;				tty->buf.head = head->next;				tty_buffer_free(tty, head);				continue;			}			/* Ldisc or user is trying to flush the buffers			   we are feeding to the ldisc, stop feeding the			   line discipline as we want to empty the queue */			if (test_bit(TTY_FLUSHPENDING, &tty->flags))				break;			if (!tty->receive_room)				break;			if (count > tty->receive_room)				count = tty->receive_room;			char_buf = head->char_buf_ptr + head->read;			flag_buf = head->flag_buf_ptr + head->read;			head->read += count;			if (disc->ops->receive_buf) {				spin_unlock_irqrestore(&tty->buf.lock, flags);				disc->ops->receive_buf(tty, char_buf,							flag_buf, count);				spin_lock_irqsave(&tty->buf.lock, flags);			}		}		clear_bit(TTY_FLUSHING, &tty->flags);	}	/* We may have a deferred request to flush the input buffer,	   if so pull the chain under the lock and empty the queue */	if (test_bit(TTY_FLUSHPENDING, &tty->flags)) {		__tty_buffer_flush(tty);		clear_bit(TTY_FLUSHPENDING, &tty->flags);		wake_up(&tty->read_wait);	}	spin_unlock_irqrestore(&tty->buf.lock, flags);	tty_ldisc_deref(disc);}
开发者ID:andy-padavan,项目名称:rt-n56u,代码行数:61,


示例14: checkcard

static int checkcard(int cardnr, char *id, int *busy_flag, struct module *lockowner){	int ret = 0;	struct IsdnCard *card = cards + cardnr;	struct IsdnCardState *cs;	cs = kmalloc(sizeof(struct IsdnCardState), GFP_ATOMIC);	if (!cs) {		printk(KERN_WARNING		       "HiSax: No memory for IsdnCardState(card %d)/n",		       cardnr + 1);		goto out;	}	memset(cs, 0, sizeof(struct IsdnCardState));	card->cs = cs;	spin_lock_init(&cs->statlock);	spin_lock_init(&cs->lock);	cs->chanlimit = 2;	/* maximum B-channel number */	cs->logecho = 0;	/* No echo logging */	cs->cardnr = cardnr;	cs->debug = L1_DEB_WARN;	cs->HW_Flags = 0;	cs->busy_flag = busy_flag;	cs->irq_flags = I4L_IRQ_FLAG;#if TEI_PER_CARD	if (card->protocol == ISDN_PTYPE_NI1)		test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);#else	test_and_set_bit(FLG_TWO_DCHAN, &cs->HW_Flags);#endif	cs->protocol = card->protocol;	if (card->typ <= 0 || card->typ > ISDN_CTYPE_COUNT) {		printk(KERN_WARNING		       "HiSax: Card Type %d out of range/n", card->typ);		goto outf_cs;	}	if (!(cs->dlog = kmalloc(MAX_DLOG_SPACE, GFP_ATOMIC))) {		printk(KERN_WARNING		       "HiSax: No memory for dlog(card %d)/n", cardnr + 1);		goto outf_cs;	}	if (!(cs->status_buf = kmalloc(HISAX_STATUS_BUFSIZE, GFP_ATOMIC))) {		printk(KERN_WARNING		       "HiSax: No memory for status_buf(card %d)/n",		       cardnr + 1);		goto outf_dlog;	}	cs->stlist = NULL;	cs->status_read = cs->status_buf;	cs->status_write = cs->status_buf;	cs->status_end = cs->status_buf + HISAX_STATUS_BUFSIZE - 1;	cs->typ = card->typ;#ifdef MODULE	cs->iif.owner = lockowner;#endif	strcpy(cs->iif.id, id);	cs->iif.channels = 2;	cs->iif.maxbufsize = MAX_DATA_SIZE;	cs->iif.hl_hdrlen = MAX_HEADER_LEN;	cs->iif.features =		ISDN_FEATURE_L2_X75I |		ISDN_FEATURE_L2_HDLC |		ISDN_FEATURE_L2_HDLC_56K |		ISDN_FEATURE_L2_TRANS |		ISDN_FEATURE_L3_TRANS |#ifdef	CONFIG_HISAX_1TR6		ISDN_FEATURE_P_1TR6 |#endif#ifdef	CONFIG_HISAX_EURO		ISDN_FEATURE_P_EURO |#endif#ifdef	CONFIG_HISAX_NI1		ISDN_FEATURE_P_NI1 |#endif		0;	cs->iif.command = HiSax_command;	cs->iif.writecmd = NULL;	cs->iif.writebuf_skb = HiSax_writebuf_skb;	cs->iif.readstat = HiSax_readstatus;	register_isdn(&cs->iif);	cs->myid = cs->iif.channels;	printk(KERN_INFO	       "HiSax: Card %d Protocol %s Id=%s (%d)/n", cardnr + 1,	       (card->protocol == ISDN_PTYPE_1TR6) ? "1TR6" :	       (card->protocol == ISDN_PTYPE_EURO) ? "EDSS1" :	       (card->protocol == ISDN_PTYPE_LEASED) ? "LEASED" :	       (card->protocol == ISDN_PTYPE_NI1) ? "NI1" :	       "NONE", cs->iif.id, cs->myid);	switch (card->typ) {#if CARD_TELES0	case ISDN_CTYPE_16_0:	case ISDN_CTYPE_8_0:		ret = setup_teles0(card);		break;#endif#if CARD_TELES3	case ISDN_CTYPE_16_3:	case ISDN_CTYPE_PNP://.........这里部分代码省略.........
开发者ID:ena30,项目名称:snake-os,代码行数:101,


示例15: rbio_submit

//.........这里部分代码省略.........		}	}out:	ploop_complete_io_request(preq);}static void nfsio_write_result(struct rpc_task *task, void *calldata){	struct nfs_write_data *data = calldata;	struct nfs_writeargs	*argp = &data->args;	struct nfs_writeres	*resp = &data->res;	int status;	status = NFS_PROTO(data->header->inode)->write_done(task, data);	if (status != 0)		return;	if (task->tk_status >= 0 && resp->count < argp->count)		task->tk_status = -EIO;}static void nfsio_write_release(void *calldata){	struct nfs_write_data *nreq = calldata;	struct ploop_request *preq = (struct ploop_request *) nreq->header->req;	int status = nreq->task.tk_status;	if (unlikely(status < 0))		PLOOP_REQ_SET_ERROR(preq, status);	if (!preq->error &&	    nreq->res.verf->committed != NFS_FILE_SYNC) {		if (!test_and_set_bit(PLOOP_REQ_UNSTABLE, &preq->state))			memcpy(&preq->verf, &nreq->res.verf->verifier, 8);	}	nfsio_complete_io_request(preq);	nfsio_wbio_release(calldata);}static const struct rpc_call_ops nfsio_write_ops = {	.rpc_call_done = nfsio_write_result,	.rpc_release = nfsio_write_release,};static struct nfs_write_data *wbio_init(loff_t pos, struct page * page, unsigned int off, unsigned int len,	  void * priv, struct inode * inode){	struct nfs_write_data * nreq;	nreq = nfsio_wbio_alloc(MAX_NBIO_PAGES);	if (unlikely(nreq == NULL))		return NULL;	nreq->args.offset = pos;	nreq->args.pgbase = off;	nreq->args.count = len;	nreq->pages.pagevec[0] = page;	nreq->pages.npages = 1;	nreq->header->req = priv;	nreq->header->inode = inode;	nreq->args.fh = NFS_FH(inode);	nreq->args.pages = nreq->pages.pagevec;	nreq->args.stable = NFS_UNSTABLE;
开发者ID:seyko2,项目名称:openvz_rhel6_kernel_mirror,代码行数:67,


示例16: n_tty_receive_buf

static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,			      char *fp, int count){	const unsigned char *p;	char *f, flags = TTY_NORMAL;	int	i;	char	buf[64];	unsigned long cpuflags;	if (!tty->read_buf)		return;	if (tty->real_raw) {		spin_lock_irqsave(&tty->read_lock, cpuflags);		i = min(N_TTY_BUF_SIZE - tty->read_cnt,			N_TTY_BUF_SIZE - tty->read_head);		i = min(count, i);		memcpy(tty->read_buf + tty->read_head, cp, i);		tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);		tty->read_cnt += i;		cp += i;		count -= i;		i = min(N_TTY_BUF_SIZE - tty->read_cnt,			N_TTY_BUF_SIZE - tty->read_head);		i = min(count, i);		memcpy(tty->read_buf + tty->read_head, cp, i);		tty->read_head = (tty->read_head + i) & (N_TTY_BUF_SIZE-1);		tty->read_cnt += i;		spin_unlock_irqrestore(&tty->read_lock, cpuflags);	} else {		for (i=count, p = cp, f = fp; i; i--, p++) {			if (f)				flags = *f++;			switch (flags) {			case TTY_NORMAL:				n_tty_receive_char(tty, *p);				break;			case TTY_BREAK:				n_tty_receive_break(tty);				break;			case TTY_PARITY:			case TTY_FRAME:				n_tty_receive_parity_error(tty, *p);				break;			case TTY_OVERRUN:				n_tty_receive_overrun(tty);				break;			default:				printk("%s: unknown flag %d/n",				       tty_name(tty, buf), flags);				break;			}		}		if (tty->driver->flush_chars)			tty->driver->flush_chars(tty);	}	if (!tty->icanon && (tty->read_cnt >= tty->minimum_to_wake)) {		kill_fasync(&tty->fasync, SIGIO, POLL_IN);		if (waitqueue_active(&tty->read_wait))			wake_up_interruptible(&tty->read_wait);	}	/*	 * Check the remaining room for the input canonicalization	 * mode.  We don't want to throttle the driver if we're in	 * canonical mode and don't have a newline yet!	 */	if (n_tty_receive_room(tty) < TTY_THRESHOLD_THROTTLE) {		/* check TTY_THROTTLED first so it indicates our state */		if (!test_and_set_bit(TTY_THROTTLED, &tty->flags) &&		    tty->driver->throttle)			tty->driver->throttle(tty);	}}
开发者ID:BackupTheBerlios,项目名称:tuxap,代码行数:76,


示例17: send_pcb

static bool send_pcb(struct net_device *dev, pcb_struct * pcb){	int i;	unsigned long timeout;	elp_device *adapter = netdev_priv(dev);	unsigned long flags;	check_3c505_dma(dev);	if (adapter->dmaing && adapter->current_dma.direction == 0)		return false;	/* Avoid contention */	if (test_and_set_bit(1, &adapter->send_pcb_semaphore)) {		if (elp_debug >= 3) {			pr_debug("%s: send_pcb entered while threaded/n", dev->name);		}		return false;	}	/*	 * load each byte into the command register and	 * wait for the HCRE bit to indicate the adapter	 * had read the byte	 */	set_hsf(dev, 0);	if (send_pcb_slow(dev->base_addr, pcb->command))		goto abort;	spin_lock_irqsave(&adapter->lock, flags);	if (send_pcb_fast(dev->base_addr, pcb->length))		goto sti_abort;	for (i = 0; i < pcb->length; i++) {		if (send_pcb_fast(dev->base_addr, pcb->data.raw[i]))			goto sti_abort;	}	outb_control(adapter->hcr_val | 3, dev);	/* signal end of PCB */	outb_command(2 + pcb->length, dev->base_addr);	/* now wait for the acknowledgement */	spin_unlock_irqrestore(&adapter->lock, flags);	for (timeout = jiffies + 5*HZ/100; time_before(jiffies, timeout);) {		switch (GET_ASF(dev->base_addr)) {		case ASF_PCB_ACK:			adapter->send_pcb_semaphore = 0;			return true;		case ASF_PCB_NAK:#ifdef ELP_DEBUG			pr_debug("%s: send_pcb got NAK/n", dev->name);#endif			goto abort;		}	}	if (elp_debug >= 1)		pr_debug("%s: timeout waiting for PCB acknowledge (status %02x)/n",			dev->name, inb_status(dev->base_addr));	goto abort;      sti_abort:	spin_unlock_irqrestore(&adapter->lock, flags);      abort:	adapter->send_pcb_semaphore = 0;	return false;}
开发者ID:AdrianHuang,项目名称:uclinux-robutest,代码行数:70,


示例18: W6692_l1hw

static voidW6692_l1hw(struct PStack *st, int pr, void *arg){	struct IsdnCardState *cs = (struct IsdnCardState *) st->l1.hardware;	struct sk_buff *skb = arg;	int val;	switch (pr) {		case (PH_DATA | REQUEST):			if (cs->debug & DEB_DLOG_HEX)				LogFrame(cs, skb->data, skb->len);			if (cs->debug & DEB_DLOG_VERBOSE)				dlogframe(cs, skb, 0);			if (cs->tx_skb) {				skb_queue_tail(&cs->sq, skb);#ifdef L2FRAME_DEBUG		/* psa */				if (cs->debug & L1_DEB_LAPD)					Logl2Frame(cs, skb, "PH_DATA Queued", 0);#endif			} else {				cs->tx_skb = skb;				cs->tx_cnt = 0;#ifdef L2FRAME_DEBUG		/* psa */				if (cs->debug & L1_DEB_LAPD)					Logl2Frame(cs, skb, "PH_DATA", 0);#endif				W6692_fill_fifo(cs);			}			break;		case (PH_PULL | INDICATION):			if (cs->tx_skb) {				if (cs->debug & L1_DEB_WARN)					debugl1(cs, " l2l1 tx_skb exist this shouldn't happen");				skb_queue_tail(&cs->sq, skb);				break;			}			if (cs->debug & DEB_DLOG_HEX)				LogFrame(cs, skb->data, skb->len);			if (cs->debug & DEB_DLOG_VERBOSE)				dlogframe(cs, skb, 0);			cs->tx_skb = skb;			cs->tx_cnt = 0;#ifdef L2FRAME_DEBUG		/* psa */			if (cs->debug & L1_DEB_LAPD)				Logl2Frame(cs, skb, "PH_DATA_PULLED", 0);#endif			W6692_fill_fifo(cs);			break;		case (PH_PULL | REQUEST):#ifdef L2FRAME_DEBUG		/* psa */			if (cs->debug & L1_DEB_LAPD)				debugl1(cs, "-> PH_REQUEST_PULL");#endif			if (!cs->tx_skb) {				test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);				st->l1.l1l2(st, PH_PULL | CONFIRM, NULL);			} else				test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);			break;		case (HW_RESET | REQUEST):			if ((cs->dc.w6692.ph_state == W_L1IND_DRD))				ph_command(cs, W_L1CMD_ECK);			else {				ph_command(cs, W_L1CMD_RST);				cs->dc.w6692.ph_state = W_L1CMD_RST;				W6692_new_ph(cs);			}			break;		case (HW_ENABLE | REQUEST):			ph_command(cs, W_L1CMD_ECK);			break;		case (HW_INFO3 | REQUEST):			ph_command(cs, W_L1CMD_AR8);			break;		case (HW_TESTLOOP | REQUEST):			val = 0;			if (1 & (long) arg)				val |= 0x0c;			if (2 & (long) arg)				val |= 0x3;			/* !!! not implemented yet */			break;		case (HW_DEACTIVATE | RESPONSE):			skb_queue_purge(&cs->rq);			skb_queue_purge(&cs->sq);			if (cs->tx_skb) {				dev_kfree_skb_any(cs->tx_skb);				cs->tx_skb = NULL;			}			if (test_and_clear_bit(FLG_DBUSY_TIMER, &cs->HW_Flags))				del_timer(&cs->dbusytimer);			if (test_and_clear_bit(FLG_L1_DBUSY, &cs->HW_Flags))				W6692_sched_event(cs, D_CLEARBUSY);			break;		default:			if (cs->debug & L1_DEB_WARN)				debugl1(cs, "W6692_l1hw unknown %04x", pr);			break;	}}
开发者ID:SimonKagstrom,项目名称:mci500h-linux-2.4.27,代码行数:100,


示例19: receive_pcb

static bool receive_pcb(struct net_device *dev, pcb_struct * pcb){	int i, j;	int total_length;	int stat;	unsigned long timeout;	unsigned long flags;	elp_device *adapter = netdev_priv(dev);	set_hsf(dev, 0);	/* get the command code */	timeout = jiffies + 2*HZ/100;	while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && time_before(jiffies, timeout));	if (time_after_eq(jiffies, timeout)) {		TIMEOUT_MSG(__LINE__);		return false;	}	pcb->command = inb_command(dev->base_addr);	/* read the data length */	timeout = jiffies + 3*HZ/100;	while (((stat = get_status(dev->base_addr)) & ACRF) == 0 && time_before(jiffies, timeout));	if (time_after_eq(jiffies, timeout)) {		TIMEOUT_MSG(__LINE__);		pr_info("%s: status %02x/n", dev->name, stat);		return false;	}	pcb->length = inb_command(dev->base_addr);	if (pcb->length > MAX_PCB_DATA) {		INVALID_PCB_MSG(pcb->length);		adapter_reset(dev);		return false;	}	/* read the data */	spin_lock_irqsave(&adapter->lock, flags);	for (i = 0; i < MAX_PCB_DATA; i++) {		for (j = 0; j < 20000; j++) {			stat = get_status(dev->base_addr);			if (stat & ACRF)				break;		}		pcb->data.raw[i] = inb_command(dev->base_addr);		if ((stat & ASF_PCB_MASK) == ASF_PCB_END || j >= 20000)			break;	}	spin_unlock_irqrestore(&adapter->lock, flags);	if (i >= MAX_PCB_DATA) {		INVALID_PCB_MSG(i);		return false;	}	if (j >= 20000) {		TIMEOUT_MSG(__LINE__);		return false;	}	/* the last "data" byte was really the length! */	total_length = pcb->data.raw[i];	/* safety check total length vs data length */	if (total_length != (pcb->length + 2)) {		if (elp_debug >= 2)			pr_warning("%s: mangled PCB received/n", dev->name);		set_hsf(dev, HSF_PCB_NAK);		return false;	}	if (pcb->command == CMD_RECEIVE_PACKET_COMPLETE) {		if (test_and_set_bit(0, (void *) &adapter->busy)) {			if (backlog_next(adapter->rx_backlog.in) == adapter->rx_backlog.out) {				set_hsf(dev, HSF_PCB_NAK);				pr_warning("%s: PCB rejected, transfer in progress and backlog full/n", dev->name);				pcb->command = 0;				return true;			} else {				pcb->command = 0xff;			}		}	}	set_hsf(dev, HSF_PCB_ACK);	return true;}
开发者ID:AdrianHuang,项目名称:uclinux-robutest,代码行数:83,


示例20: send_packet

static netdev_tx_t send_packet(struct net_device *dev, struct sk_buff *skb){	elp_device *adapter = netdev_priv(dev);	unsigned long target;	unsigned long flags;	/*	 * make sure the length is even and no shorter than 60 bytes	 */	unsigned int nlen = (((skb->len < 60) ? 60 : skb->len) + 1) & (~1);	if (test_and_set_bit(0, (void *) &adapter->busy)) {		if (elp_debug >= 2)			pr_debug("%s: transmit blocked/n", dev->name);		return false;	}	dev->stats.tx_bytes += nlen;	/*	 * send the adapter a transmit packet command. Ignore segment and offset	 * and make sure the length is even	 */	adapter->tx_pcb.command = CMD_TRANSMIT_PACKET;	adapter->tx_pcb.length = sizeof(struct Xmit_pkt);	adapter->tx_pcb.data.xmit_pkt.buf_ofs	    = adapter->tx_pcb.data.xmit_pkt.buf_seg = 0;	/* Unused */	adapter->tx_pcb.data.xmit_pkt.pkt_len = nlen;	if (!send_pcb(dev, &adapter->tx_pcb)) {		adapter->busy = 0;		return false;	}	/* if this happens, we die */	if (test_and_set_bit(0, (void *) &adapter->dmaing))		pr_debug("%s: tx: DMA %d in progress/n", dev->name, adapter->current_dma.direction);	adapter->current_dma.direction = 1;	adapter->current_dma.start_time = jiffies;	if ((unsigned long)(skb->data + nlen) >= MAX_DMA_ADDRESS || nlen != skb->len) {		skb_copy_from_linear_data(skb, adapter->dma_buffer, nlen);		memset(adapter->dma_buffer+skb->len, 0, nlen-skb->len);		target = isa_virt_to_bus(adapter->dma_buffer);	}	else {		target = isa_virt_to_bus(skb->data);	}	adapter->current_dma.skb = skb;	flags=claim_dma_lock();	disable_dma(dev->dma);	clear_dma_ff(dev->dma);	set_dma_mode(dev->dma, 0x48);	/* dma memory -> io */	set_dma_addr(dev->dma, target);	set_dma_count(dev->dma, nlen);	outb_control(adapter->hcr_val | DMAE | TCEN, dev);	enable_dma(dev->dma);	release_dma_lock(flags);	if (elp_debug >= 3)		pr_debug("%s: DMA transfer started/n", dev->name);	return true;}
开发者ID:AdrianHuang,项目名称:uclinux-robutest,代码行数:65,


示例21: irq_wake_thread

static void irq_wake_thread(struct irq_desc *desc, struct irqaction *action){	/*	 * Wake up the handler thread for this action. In case the	 * thread crashed and was killed we just pretend that we	 * handled the interrupt. The hardirq handler has disabled the	 * device interrupt, so no irq storm is lurking. If the	 * RUNTHREAD bit is already set, nothing to do.	 */	if (test_bit(IRQTF_DIED, &action->thread_flags) ||	    test_and_set_bit(IRQTF_RUNTHREAD, &action->thread_flags))		return;	/*	 * It's safe to OR the mask lockless here. We have only two	 * places which write to threads_oneshot: This code and the	 * irq thread.	 *	 * This code is the hard irq context and can never run on two	 * cpus in parallel. If it ever does we have more serious	 * problems than this bitmask.	 *	 * The irq threads of this irq which clear their "running" bit	 * in threads_oneshot are serialized via desc->lock against	 * each other and they are serialized against this code by	 * IRQS_INPROGRESS.	 *	 * Hard irq handler:	 *	 *	spin_lock(desc->lock);	 *	desc->state |= IRQS_INPROGRESS;	 *	spin_unlock(desc->lock);	 *	set_bit(IRQTF_RUNTHREAD, &action->thread_flags);	 *	desc->threads_oneshot |= mask;	 *	spin_lock(desc->lock);	 *	desc->state &= ~IRQS_INPROGRESS;	 *	spin_unlock(desc->lock);	 *	 * irq thread:	 *	 * again:	 *	spin_lock(desc->lock);	 *	if (desc->state & IRQS_INPROGRESS) {	 *		spin_unlock(desc->lock);	 *		while(desc->state & IRQS_INPROGRESS)	 *			cpu_relax();	 *		goto again;	 *	}	 *	if (!test_bit(IRQTF_RUNTHREAD, &action->thread_flags))	 *		desc->threads_oneshot &= ~mask;	 *	spin_unlock(desc->lock);	 *	 * So either the thread waits for us to clear IRQS_INPROGRESS	 * or we are waiting in the flow handler for desc->lock to be	 * released before we reach this point. The thread also checks	 * IRQTF_RUNTHREAD under desc->lock. If set it leaves	 * threads_oneshot untouched and runs the thread another time.	 */	desc->threads_oneshot |= action->thread_mask;	wake_up_process(action->thread);}
开发者ID:InhyukYee,项目名称:PeanutButterWolf,代码行数:61,


示例22: priv_ev_loop_run

/*---------------------------------------------------------------------------*/int priv_ev_loop_run(void *loop_hndl){	struct xio_ev_loop	*loop = loop_hndl;	struct xio_ev_data	*tev;	struct llist_node	*node;	int cpu;	clear_bit(XIO_EV_LOOP_STOP, &loop->states);	switch (loop->flags) {	case XIO_LOOP_GIVEN_THREAD:		if (loop->ctx->worker != (uint64_t) get_current()) {			ERROR_LOG("worker kthread(%p) is not current(%p)./n",				  (void *) loop->ctx->worker, get_current());			goto cleanup0;		}		/* no need to disable preemption */		cpu = raw_smp_processor_id();		if (loop->ctx->cpuid != cpu) {			TRACE_LOG("worker on core(%d) scheduled to(%d)./n",				  cpu, loop->ctx->cpuid);			set_cpus_allowed_ptr(get_current(),					     cpumask_of(loop->ctx->cpuid));		}		break;	case XIO_LOOP_TASKLET:		/* were events added to list while in STOP state ? */		if (!llist_empty(&loop->ev_llist))			priv_kick_tasklet(loop_hndl);		return 0;	case XIO_LOOP_WORKQUEUE:		/* were events added to list while in STOP state ? */		while ((node = llist_del_all(&loop->ev_llist)) != NULL) {			node = llist_reverse_order(node);			while (node) {				tev = llist_entry(node, struct xio_ev_data,						  ev_llist);				node = llist_next(node);				tev->work.func = priv_ev_loop_run_work;				queue_work_on(loop->ctx->cpuid, loop->workqueue,					      &tev->work);			}		}		return 0;	default:		/* undo */		set_bit(XIO_EV_LOOP_STOP, &loop->states);		return -1;	}retry_wait:	wait_event_interruptible(loop->wait,				 test_bit(XIO_EV_LOOP_WAKE, &loop->states));retry_dont_wait:	while ((node = llist_del_all(&loop->ev_llist)) != NULL) {		node = llist_reverse_order(node);		while (node) {			tev = llist_entry(node, struct xio_ev_data, ev_llist);			node = llist_next(node);			tev->handler(tev->data);		}	}	/* "race point" */	clear_bit(XIO_EV_LOOP_WAKE, &loop->states);	if (unlikely(test_bit(XIO_EV_LOOP_STOP, &loop->states)))		return 0;	/* if a new entry was added while we were at "race point"	 * than wait event might block forever as condition is false */	if (llist_empty(&loop->ev_llist))		goto retry_wait;	/* race detected */	if (!test_and_set_bit(XIO_EV_LOOP_WAKE, &loop->states))		goto retry_dont_wait;	/* was one wakeup was called */	goto retry_wait;cleanup0:	set_bit(XIO_EV_LOOP_STOP, &loop->states);	return -1;}
开发者ID:maxgurtovoy,项目名称:accelio,代码行数:88,


示例23: igbvf_set_ringparam

static int igbvf_set_ringparam(struct net_device *netdev,                               struct ethtool_ringparam *ring){	struct igbvf_adapter *adapter = netdev_priv(netdev);	struct igbvf_ring *temp_ring;	int err = 0;	u32 new_rx_count, new_tx_count;	if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending))		return -EINVAL;	new_rx_count = max(ring->rx_pending, (u32)IGBVF_MIN_RXD);	new_rx_count = min(new_rx_count, (u32)IGBVF_MAX_RXD);	new_rx_count = ALIGN(new_rx_count, REQ_RX_DESCRIPTOR_MULTIPLE);	new_tx_count = max(ring->tx_pending, (u32)IGBVF_MIN_TXD);	new_tx_count = min(new_tx_count, (u32)IGBVF_MAX_TXD);	new_tx_count = ALIGN(new_tx_count, REQ_TX_DESCRIPTOR_MULTIPLE);	if ((new_tx_count == adapter->tx_ring->count) &&	    (new_rx_count == adapter->rx_ring->count)) {				return 0;	}	while (test_and_set_bit(__IGBVF_RESETTING, &adapter->state))		msleep(1);	if (!netif_running(adapter->netdev)) {		adapter->tx_ring->count = new_tx_count;		adapter->rx_ring->count = new_rx_count;		goto clear_reset;	}	temp_ring = vmalloc(sizeof(struct igbvf_ring));	if (!temp_ring) {		err = -ENOMEM;		goto clear_reset;	}	igbvf_down(adapter);	if (new_tx_count != adapter->tx_ring->count) {		memcpy(temp_ring, adapter->tx_ring, sizeof(struct igbvf_ring));		temp_ring->count = new_tx_count;		err = igbvf_setup_tx_resources(adapter, temp_ring);		if (err)			goto err_setup;		igbvf_free_tx_resources(adapter->tx_ring);		memcpy(adapter->tx_ring, temp_ring, sizeof(struct igbvf_ring));	}	if (new_rx_count != adapter->rx_ring->count) {		memcpy(temp_ring, adapter->rx_ring, sizeof(struct igbvf_ring));		temp_ring->count = new_rx_count;		err = igbvf_setup_rx_resources(adapter, temp_ring);		if (err)			goto err_setup;		igbvf_free_rx_resources(adapter->rx_ring);		memcpy(adapter->rx_ring, temp_ring,sizeof(struct igbvf_ring));	}err_setup:	igbvf_up(adapter);	vfree(temp_ring);clear_reset:	clear_bit(__IGBVF_RESETTING, &adapter->state);	return err;}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:74,


示例24: acq_ioctl

static long acq_ioctl(struct file *file, unsigned int cmd, unsigned long arg){	int options, retval = -EINVAL;	void __user *argp = (void __user *)arg;	int __user *p = argp;	static const struct watchdog_info ident = {		.options = WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,		.firmware_version = 1,		.identity = WATCHDOG_NAME,	};	switch (cmd) {	case WDIOC_GETSUPPORT:		return copy_to_user(argp, &ident, sizeof(ident)) ? -EFAULT : 0;	case WDIOC_GETSTATUS:	case WDIOC_GETBOOTSTATUS:		return put_user(0, p);	case WDIOC_SETOPTIONS:	{		if (get_user(options, p))			return -EFAULT;		if (options & WDIOS_DISABLECARD) {			acq_stop();			retval = 0;		}		if (options & WDIOS_ENABLECARD) {			acq_keepalive();			retval = 0;		}		return retval;	}	case WDIOC_KEEPALIVE:		acq_keepalive();		return 0;	case WDIOC_GETTIMEOUT:		return put_user(WATCHDOG_HEARTBEAT, p);	default:		return -ENOTTY;	}}static int acq_open(struct inode *inode, struct file *file){	if (test_and_set_bit(0, &acq_is_open))		return -EBUSY;	if (nowayout)		__module_get(THIS_MODULE);		acq_keepalive();	return nonseekable_open(inode, file);}static int acq_close(struct inode *inode, struct file *file){	if (expect_close == 42) {		acq_stop();	} else {		pr_crit("Unexpected close, not stopping watchdog!/n");		acq_keepalive();	}	clear_bit(0, &acq_is_open);	expect_close = 0;	return 0;}static const struct file_operations acq_fops = {	.owner		= THIS_MODULE,	.llseek		= no_llseek,	.write		= acq_write,	.unlocked_ioctl	= acq_ioctl,	.open		= acq_open,	.release	= acq_close,};static struct miscdevice acq_miscdev = {	.minor	= WATCHDOG_MINOR,	.name	= "watchdog",	.fops	= &acq_fops,};static int __devinit acq_probe(struct platform_device *dev){	int ret;	if (wdt_stop != wdt_start) {		if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {			pr_err("I/O address 0x%04x already in use/n", wdt_stop);			ret = -EIO;			goto out;		}	}//.........这里部分代码省略.........
开发者ID:MiniBlu,项目名称:cm11_kernel_htc_msm8974a3ul,代码行数:101,


示例25: hisax_sched_event

static void hisax_sched_event(struct IsdnCardState *cs, int event){	test_and_set_bit(event, &cs->event);	schedule_work(&cs->tqueue);}
开发者ID:eddie-wang,项目名称:linux-2,代码行数:5,


示例26: cachefiles_has_space

/* * see if we have space for a number of pages and/or a number of files in the * cache */int cachefiles_has_space(struct cachefiles_cache *cache,			 unsigned fnr, unsigned bnr){	struct kstatfs stats;	int ret;	//_enter("{%llu,%llu,%llu,%llu,%llu,%llu},%u,%u",	//       (unsigned long long) cache->frun,	//       (unsigned long long) cache->fcull,	//       (unsigned long long) cache->fstop,	//       (unsigned long long) cache->brun,	//       (unsigned long long) cache->bcull,	//       (unsigned long long) cache->bstop,	//       fnr, bnr);	/* find out how many pages of blockdev are available */	memset(&stats, 0, sizeof(stats));	ret = vfs_statfs(cache->mnt->mnt_root, &stats);	if (ret < 0) {		if (ret == -EIO)			cachefiles_io_error(cache, "statfs failed");		_leave(" = %d", ret);		return ret;	}	stats.f_bavail >>= cache->bshift;	//_debug("avail %llu,%llu",	//       (unsigned long long) stats.f_ffree,	//       (unsigned long long) stats.f_bavail);	/* see if there is sufficient space */	if (stats.f_ffree > fnr)		stats.f_ffree -= fnr;	else		stats.f_ffree = 0;	if (stats.f_bavail > bnr)		stats.f_bavail -= bnr;	else		stats.f_bavail = 0;	ret = -ENOBUFS;	if (stats.f_ffree < cache->fstop ||	    stats.f_bavail < cache->bstop)		goto begin_cull;	ret = 0;	if (stats.f_ffree < cache->fcull ||	    stats.f_bavail < cache->bcull)		goto begin_cull;	if (test_bit(CACHEFILES_CULLING, &cache->flags) &&	    stats.f_ffree >= cache->frun &&	    stats.f_bavail >= cache->brun &&	    test_and_clear_bit(CACHEFILES_CULLING, &cache->flags)	    ) {		_debug("cease culling");		cachefiles_state_changed(cache);	}	//_leave(" = 0");	return 0;begin_cull:	if (!test_and_set_bit(CACHEFILES_CULLING, &cache->flags)) {		_debug("### CULL CACHE ###");		cachefiles_state_changed(cache);	}	_leave(" = %d", ret);	return ret;}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:78,



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


C++ test_assert_false函数代码示例
C++ test_and_clear_bit函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。