nskb->pkt_type = pkt_type; 
bt_cb(nskb)->pkt_type = pkt_type; 
static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,		int len, int pkt_type){	struct sk_buff *nskb;	u8 hdr[4], chan;	int rel, i;#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC	u16 BCSP_CRC_INIT(bcsp_txmsg_crc);#endif	switch (pkt_type) {	case HCI_ACLDATA_PKT:		chan = 6;	/* BCSP ACL channel */		rel = 1;	/* reliable channel */		break;	case HCI_COMMAND_PKT:		chan = 5;	/* BCSP cmd/evt channel */		rel = 1;	/* reliable channel */		break;	case HCI_SCODATA_PKT:		chan = 7;	/* BCSP SCO channel */		rel = 0;	/* unreliable channel */		break;	case BCSP_LE_PKT:		chan = 1;	/* BCSP LE channel */		rel = 0;	/* unreliable channel */		break;	case BCSP_ACK_PKT:		chan = 0;	/* BCSP internal channel */		rel = 0;	/* unreliable channel */		break;	default:		BT_ERR("Unknown packet type");		return NULL;	}	if (hciextn && chan == 5) {		struct hci_command_hdr *hdr = (struct hci_command_hdr *) data;		if (hci_opcode_ogf(__le16_to_cpu(hdr->opcode)) == OGF_VENDOR_CMD) {			u8 desc = *(data + HCI_COMMAND_HDR_SIZE);			if ((desc & 0xf0) == 0xc0) {				data += HCI_COMMAND_HDR_SIZE + 1;				len  -= HCI_COMMAND_HDR_SIZE + 1;				chan = desc & 0x0f;			}		}	}	/* Max len of packet: (original len +4(bcsp hdr) +2(crc))*2	   (because bytes 0xc0 and 0xdb are escaped, worst case is	   when the packet is all made of 0xc0 and 0xdb :) )	   + 2 (0xc0 delimiters at start and end). */	nskb = alloc_skb((len + 6) * 2 + 2, GFP_ATOMIC);	if (!nskb)		return NULL;	nskb->pkt_type = pkt_type;	bcsp_slip_msgdelim(nskb);	hdr[0] = bcsp->rxseq_txack << 3;	bcsp->txack_req = 0;	BT_DBG("We request packet no %u to card", bcsp->rxseq_txack);	if (rel) {		hdr[0] |= 0x80 + bcsp->msgq_txseq;		BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq);		bcsp->msgq_txseq = ++(bcsp->msgq_txseq) & 0x07;	}#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC	hdr[0] |= 0x40;#endif	hdr[1] = ((len << 4) & 0xff) | chan;	hdr[2] = len >> 4;	hdr[3] = ~(hdr[0] + hdr[1] + hdr[2]);	/* Put BCSP header */	for (i = 0; i < 4; i++) {		bcsp_slip_one_byte(nskb, hdr[i]);#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC		bcsp_crc_update(&bcsp_txmsg_crc, hdr[i]);#endif	}	/* Put payload */	for (i = 0; i < len; i++) {		bcsp_slip_one_byte(nskb, data[i]);#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC		bcsp_crc_update(&bcsp_txmsg_crc, data[i]);#endif	}#ifdef CONFIG_BT_HCIUART_BCSP_TXCRC	/* Put CRC */	bcsp_txmsg_crc = bcsp_crc_reverse(bcsp_txmsg_crc);	bcsp_slip_one_byte(nskb, (u8) ((bcsp_txmsg_crc >> 8) & 0x00ff));	bcsp_slip_one_byte(nskb, (u8) (bcsp_txmsg_crc & 0x00ff));#endif	bcsp_slip_msgdelim(nskb);	return nskb;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/0d48d93947dd9ea21c5cdc76a8581b06a4a39281/hci_bcsp.c/buggy/drivers/bluetooth/hci_bcsp.c