diff options
Diffstat (limited to 'drivers/bluetooth/bluecard_cs.c')
| -rw-r--r-- | drivers/bluetooth/bluecard_cs.c | 103 | 
1 files changed, 33 insertions, 70 deletions
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c index 4104b7feae6..dfa5043e68b 100644 --- a/drivers/bluetooth/bluecard_cs.c +++ b/drivers/bluetooth/bluecard_cs.c @@ -231,12 +231,12 @@ static void bluecard_write_wakeup(bluecard_info_t *info)  	}  	do { -		register unsigned int iobase = info->p_dev->resource[0]->start; -		register unsigned int offset; -		register unsigned char command; -		register unsigned long ready_bit; +		unsigned int iobase = info->p_dev->resource[0]->start; +		unsigned int offset; +		unsigned char command; +		unsigned long ready_bit;  		register struct sk_buff *skb; -		register int len; +		int len;  		clear_bit(XMIT_WAKEUP, &(info->tx_state)); @@ -257,7 +257,8 @@ static void bluecard_write_wakeup(bluecard_info_t *info)  			ready_bit = XMIT_BUF_ONE_READY;  		} -		if (!(skb = skb_dequeue(&(info->txq)))) +		skb = skb_dequeue(&(info->txq)); +		if (!skb)  			break;  		if (bt_cb(skb)->pkt_type & 0x80) { @@ -391,7 +392,8 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)  		if (info->rx_skb == NULL) {  			info->rx_state = RECV_WAIT_PACKET_TYPE;  			info->rx_count = 0; -			if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) { +			info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); +			if (!info->rx_skb) {  				BT_ERR("Can't allocate mem for new packet");  				return;  			} @@ -399,7 +401,6 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)  		if (info->rx_state == RECV_WAIT_PACKET_TYPE) { -			info->rx_skb->dev = (void *) info->hdev;  			bt_cb(info->rx_skb)->pkt_type = buf[i];  			switch (bt_cb(info->rx_skb)->pkt_type) { @@ -477,7 +478,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)  					break;  				case RECV_WAIT_DATA: -					hci_recv_frame(info->rx_skb); +					hci_recv_frame(info->hdev, info->rx_skb);  					info->rx_skb = NULL;  					break; @@ -561,13 +562,14 @@ static irqreturn_t bluecard_interrupt(int irq, void *dev_inst)  static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)  { -	bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); +	bluecard_info_t *info = hci_get_drvdata(hdev);  	struct sk_buff *skb;  	/* Ericsson baud rate command */  	unsigned char cmd[] = { HCI_COMMAND_PKT, 0x09, 0xfc, 0x01, 0x03 }; -	if (!(skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) { +	skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC); +	if (!skb) {  		BT_ERR("Can't allocate mem for new packet");  		return -1;  	} @@ -609,7 +611,7 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)  static int bluecard_hci_flush(struct hci_dev *hdev)  { -	bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); +	bluecard_info_t *info = hci_get_drvdata(hdev);  	/* Drop TX queue */  	skb_queue_purge(&(info->txq)); @@ -620,8 +622,7 @@ static int bluecard_hci_flush(struct hci_dev *hdev)  static int bluecard_hci_open(struct hci_dev *hdev)  { -	bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); -	unsigned int iobase = info->p_dev->resource[0]->start; +	bluecard_info_t *info = hci_get_drvdata(hdev);  	if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state)))  		bluecard_hci_set_baud_rate(hdev, DEFAULT_BAUD_RATE); @@ -630,6 +631,8 @@ static int bluecard_hci_open(struct hci_dev *hdev)  		return 0;  	if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { +		unsigned int iobase = info->p_dev->resource[0]->start; +  		/* Enable LED */  		outb(0x08 | 0x20, iobase + 0x30);  	} @@ -640,8 +643,7 @@ static int bluecard_hci_open(struct hci_dev *hdev)  static int bluecard_hci_close(struct hci_dev *hdev)  { -	bluecard_info_t *info = (bluecard_info_t *)(hdev->driver_data); -	unsigned int iobase = info->p_dev->resource[0]->start; +	bluecard_info_t *info = hci_get_drvdata(hdev);  	if (!test_and_clear_bit(HCI_RUNNING, &(hdev->flags)))  		return 0; @@ -649,6 +651,8 @@ static int bluecard_hci_close(struct hci_dev *hdev)  	bluecard_hci_flush(hdev);  	if (test_bit(CARD_HAS_PCCARD_ID, &(info->hw_state))) { +		unsigned int iobase = info->p_dev->resource[0]->start; +  		/* Disable LED */  		outb(0x00, iobase + 0x30);  	} @@ -657,17 +661,9 @@ static int bluecard_hci_close(struct hci_dev *hdev)  } -static int bluecard_hci_send_frame(struct sk_buff *skb) +static int bluecard_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)  { -	bluecard_info_t *info; -	struct hci_dev *hdev = (struct hci_dev *)(skb->dev); - -	if (!hdev) { -		BT_ERR("Frame for unknown HCI device (hdev=NULL)"); -		return -ENODEV; -	} - -	info = (bluecard_info_t *)(hdev->driver_data); +	bluecard_info_t *info = hci_get_drvdata(hdev);  	switch (bt_cb(skb)->pkt_type) {  	case HCI_COMMAND_PKT: @@ -679,7 +675,7 @@ static int bluecard_hci_send_frame(struct sk_buff *skb)  	case HCI_SCODATA_PKT:  		hdev->stat.sco_tx++;  		break; -	}; +	}  	/* Prepend skb with frame type */  	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); @@ -691,17 +687,6 @@ static int bluecard_hci_send_frame(struct sk_buff *skb)  } -static void bluecard_hci_destruct(struct hci_dev *hdev) -{ -} - - -static int bluecard_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) -{ -	return -ENOIOCTLCMD; -} - -  /* ======================== Card services HCI interaction ======================== */ @@ -734,17 +719,13 @@ static int bluecard_open(bluecard_info_t *info)  	info->hdev = hdev;  	hdev->bus = HCI_PCCARD; -	hdev->driver_data = info; +	hci_set_drvdata(hdev, info);  	SET_HCIDEV_DEV(hdev, &info->p_dev->dev); -	hdev->open     = bluecard_hci_open; -	hdev->close    = bluecard_hci_close; -	hdev->flush    = bluecard_hci_flush; -	hdev->send     = bluecard_hci_send_frame; -	hdev->destruct = bluecard_hci_destruct; -	hdev->ioctl    = bluecard_hci_ioctl; - -	hdev->owner = THIS_MODULE; +	hdev->open  = bluecard_hci_open; +	hdev->close = bluecard_hci_close; +	hdev->flush = bluecard_hci_flush; +	hdev->send  = bluecard_hci_send_frame;  	id = inb(iobase + 0x30); @@ -844,9 +825,7 @@ static int bluecard_close(bluecard_info_t *info)  	/* Turn FPGA off */  	outb(0x80, iobase + 0x30); -	if (hci_unregister_dev(hdev) < 0) -		BT_ERR("Can't unregister HCI device %s", hdev->name); - +	hci_unregister_dev(hdev);  	hci_free_dev(hdev);  	return 0; @@ -857,7 +836,7 @@ static int bluecard_probe(struct pcmcia_device *link)  	bluecard_info_t *info;  	/* Create new info device */ -	info = kzalloc(sizeof(*info), GFP_KERNEL); +	info = devm_kzalloc(&link->dev, sizeof(*info), GFP_KERNEL);  	if (!info)  		return -ENOMEM; @@ -872,10 +851,7 @@ static int bluecard_probe(struct pcmcia_device *link)  static void bluecard_detach(struct pcmcia_device *link)  { -	bluecard_info_t *info = link->priv; -  	bluecard_release(link); -	kfree(info);  } @@ -925,12 +901,12 @@ static void bluecard_release(struct pcmcia_device *link)  	bluecard_close(info); -	del_timer(&(info->timer)); +	del_timer_sync(&(info->timer));  	pcmcia_disable_device(link);  } -static struct pcmcia_device_id bluecard_ids[] = { +static const struct pcmcia_device_id bluecard_ids[] = {  	PCMCIA_DEVICE_PROD_ID12("BlueCard", "LSE041", 0xbaf16fbf, 0x657cc15e),  	PCMCIA_DEVICE_PROD_ID12("BTCFCARD", "LSE139", 0xe3987764, 0x2524b59c),  	PCMCIA_DEVICE_PROD_ID12("WSS", "LSE039", 0x0a0736ec, 0x24e6dfab), @@ -945,17 +921,4 @@ static struct pcmcia_driver bluecard_driver = {  	.remove		= bluecard_detach,  	.id_table	= bluecard_ids,  }; - -static int __init init_bluecard_cs(void) -{ -	return pcmcia_register_driver(&bluecard_driver); -} - - -static void __exit exit_bluecard_cs(void) -{ -	pcmcia_unregister_driver(&bluecard_driver); -} - -module_init(init_bluecard_cs); -module_exit(exit_bluecard_cs); +module_pcmcia_driver(bluecard_driver);  | 
