static int bcsp_recv(struct hci_uart *hu, void *data, int count){	struct bcsp_struct *bcsp = hu->priv;	register unsigned char *ptr;	BT_DBG("hu %p count %d rx_state %d rx_count %ld", 		hu, count, bcsp->rx_state, bcsp->rx_count);	ptr = data;	while (count) {		if (bcsp->rx_count) {			if (*ptr == 0xc0) {				BT_ERR("Short BCSP packet");				kfree_skb(bcsp->rx_skb);				bcsp->rx_state = BCSP_W4_PKT_START;				bcsp->rx_count = 0;			} else				bcsp_unslip_one_byte(bcsp, *ptr);			ptr++; count--;			continue;		}		switch (bcsp->rx_state) {		case BCSP_W4_BCSP_HDR:			if ((0xff & (u8) ~ (bcsp->rx_skb->data[0] + bcsp->rx_skb->data[1] +					bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) {				BT_ERR("Error in BCSP hdr checksum");				kfree_skb(bcsp->rx_skb);				bcsp->rx_state = BCSP_W4_PKT_DELIMITER;				bcsp->rx_count = 0;				continue;			}			if (bcsp->rx_skb->data[0] & 0x80	/* reliable pkt */			    		&& (bcsp->rx_skb->data[0] & 0x07) != bcsp->rxseq_txack) {				BT_ERR ("Out-of-order packet arrived, got %u expected %u",					bcsp->rx_skb->data[0] & 0x07, bcsp->rxseq_txack);				kfree_skb(bcsp->rx_skb);				bcsp->rx_state = BCSP_W4_PKT_DELIMITER;				bcsp->rx_count = 0;				continue;			}			bcsp->rx_state = BCSP_W4_DATA;			bcsp->rx_count = (bcsp->rx_skb->data[1] >> 4) + 					(bcsp->rx_skb->data[2] << 4);	/* May be 0 */			continue;		case BCSP_W4_DATA:			if (bcsp->rx_skb->data[0] & 0x40) {	/* pkt with crc */				bcsp->rx_state = BCSP_W4_CRC;				bcsp->rx_count = 2;			} else				bcsp_complete_rx_pkt(hu);			continue;		case BCSP_W4_CRC:			if (bcsp_crc_reverse(bcsp->message_crc) !=					(bcsp->rx_skb->data[bcsp->rx_skb->len - 2] << 8) +					bcsp->rx_skb->data[bcsp->rx_skb->len - 1]) {				BT_ERR ("Checksum failed: computed %04x received %04x",					bcsp_crc_reverse(bcsp->message_crc),				     	(bcsp->rx_skb-> data[bcsp->rx_skb->len - 2] << 8) +				     	bcsp->rx_skb->data[bcsp->rx_skb->len - 1]);				kfree_skb(bcsp->rx_skb);				bcsp->rx_state = BCSP_W4_PKT_DELIMITER;				bcsp->rx_count = 0;				continue;			}			skb_trim(bcsp->rx_skb, bcsp->rx_skb->len - 2);			bcsp_complete_rx_pkt(hu);			continue;		case BCSP_W4_PKT_DELIMITER:			switch (*ptr) {			case 0xc0:				bcsp->rx_state = BCSP_W4_PKT_START;				break;			default:				/*BT_ERR("Ignoring byte %02x", *ptr);*/				break;			}			ptr++; count--;			break;		case BCSP_W4_PKT_START:			switch (*ptr) {			case 0xc0:				ptr++; count--;				break;			default:				bcsp->rx_state = BCSP_W4_BCSP_HDR;				bcsp->rx_count = 4;				bcsp->rx_esc_state = BCSP_ESCSTATE_NOESC;				BCSP_CRC_INIT(bcsp->message_crc);								/* Do not increment ptr or decrement count				 * Allocate packet. Max len of a BCSP pkt= 				 * 0xFFF (payload) +4 (header) +2 (crc) */				bcsp->rx_skb = bt_skb_alloc(0x1005, GFP_ATOMIC);				if (!bcsp->rx_skb) {					BT_ERR("Can't allocate mem for new packet");					bcsp->rx_state = BCSP_W4_PKT_DELIMITER;					bcsp->rx_count = 0;					return 0;				}				bcsp->rx_skb->dev = (void *) hu->hdev;				break;			}			break;		}	}	return count;}
10457	/local/tlutelli/issta_data/temp/c/2005_temp/2005/10457/0372a6627f862f90a2c43772befeecef508cfd7b/hci_bcsp.c/clean/drivers/bluetooth/hci_bcsp.c