diff options
Diffstat (limited to 'drivers/bluetooth/btuart_cs.c')
| -rw-r--r-- | drivers/bluetooth/btuart_cs.c | 83 | 
1 files changed, 21 insertions, 62 deletions
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c index f8a0708e231..fb948f02eda 100644 --- a/drivers/bluetooth/btuart_cs.c +++ b/drivers/bluetooth/btuart_cs.c @@ -38,7 +38,6 @@  #include <linux/serial.h>  #include <linux/serial_reg.h>  #include <linux/bitops.h> -#include <asm/system.h>  #include <asm/io.h>  #include <pcmcia/cistpl.h> @@ -141,16 +140,17 @@ static void btuart_write_wakeup(btuart_info_t *info)  	}  	do { -		register unsigned int iobase = info->p_dev->resource[0]->start; +		unsigned int iobase = info->p_dev->resource[0]->start;  		register struct sk_buff *skb; -		register int len; +		int len;  		clear_bit(XMIT_WAKEUP, &(info->tx_state));  		if (!pcmcia_dev_present(info->p_dev))  			return; -		if (!(skb = skb_dequeue(&(info->txq)))) +		skb = skb_dequeue(&(info->txq)); +		if (!skb)  			break;  		/* Send frame */ @@ -191,7 +191,8 @@ static void btuart_receive(btuart_info_t *info)  		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;  			} @@ -199,7 +200,6 @@ static void btuart_receive(btuart_info_t *info)  		if (info->rx_state == RECV_WAIT_PACKET_TYPE) { -			info->rx_skb->dev = (void *) info->hdev;  			bt_cb(info->rx_skb)->pkt_type = inb(iobase + UART_RX);  			switch (bt_cb(info->rx_skb)->pkt_type) { @@ -266,7 +266,7 @@ static void btuart_receive(btuart_info_t *info)  					break;  				case RECV_WAIT_DATA: -					hci_recv_frame(info->rx_skb); +					hci_recv_frame(info->hdev, info->rx_skb);  					info->rx_skb = NULL;  					break; @@ -397,7 +397,7 @@ static void btuart_change_speed(btuart_info_t *info, unsigned int speed)  static int btuart_hci_flush(struct hci_dev *hdev)  { -	btuart_info_t *info = (btuart_info_t *)(hdev->driver_data); +	btuart_info_t *info = hci_get_drvdata(hdev);  	/* Drop TX queue */  	skb_queue_purge(&(info->txq)); @@ -425,17 +425,9 @@ static int btuart_hci_close(struct hci_dev *hdev)  } -static int btuart_hci_send_frame(struct sk_buff *skb) +static int btuart_hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)  { -	btuart_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 = (btuart_info_t *)(hdev->driver_data); +	btuart_info_t *info = hci_get_drvdata(hdev);  	switch (bt_cb(skb)->pkt_type) {  	case HCI_COMMAND_PKT: @@ -447,7 +439,7 @@ static int btuart_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); @@ -459,17 +451,6 @@ static int btuart_hci_send_frame(struct sk_buff *skb)  } -static void btuart_hci_destruct(struct hci_dev *hdev) -{ -} - - -static int btuart_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) -{ -	return -ENOIOCTLCMD; -} - -  /* ======================== Card services HCI interaction ======================== */ @@ -498,17 +479,13 @@ static int btuart_open(btuart_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     = btuart_hci_open; -	hdev->close    = btuart_hci_close; -	hdev->flush    = btuart_hci_flush; -	hdev->send     = btuart_hci_send_frame; -	hdev->destruct = btuart_hci_destruct; -	hdev->ioctl    = btuart_hci_ioctl; - -	hdev->owner = THIS_MODULE; +	hdev->open  = btuart_hci_open; +	hdev->close = btuart_hci_close; +	hdev->flush = btuart_hci_flush; +	hdev->send  = btuart_hci_send_frame;  	spin_lock_irqsave(&(info->lock), flags); @@ -565,9 +542,7 @@ static int btuart_close(btuart_info_t *info)  	spin_unlock_irqrestore(&(info->lock), flags); -	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; @@ -578,7 +553,7 @@ static int btuart_probe(struct pcmcia_device *link)  	btuart_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; @@ -594,17 +569,14 @@ static int btuart_probe(struct pcmcia_device *link)  static void btuart_detach(struct pcmcia_device *link)  { -	btuart_info_t *info = link->priv; -  	btuart_release(link); -	kfree(info);  }  static int btuart_check_config(struct pcmcia_device *p_dev, void *priv_data)  {  	int *try = priv_data; -	if (try == 0) +	if (!try)  		p_dev->io_lines = 16;  	if ((p_dev->resource[0]->end != 8) || (p_dev->resource[0]->start == 0)) @@ -689,7 +661,7 @@ static void btuart_release(struct pcmcia_device *link)  	pcmcia_disable_device(link);  } -static struct pcmcia_device_id btuart_ids[] = { +static const struct pcmcia_device_id btuart_ids[] = {  	/* don't use this driver. Use serial_cs + hci_uart instead */  	PCMCIA_DEVICE_NULL  }; @@ -702,17 +674,4 @@ static struct pcmcia_driver btuart_driver = {  	.remove		= btuart_detach,  	.id_table	= btuart_ids,  }; - -static int __init init_btuart_cs(void) -{ -	return pcmcia_register_driver(&btuart_driver); -} - - -static void __exit exit_btuart_cs(void) -{ -	pcmcia_unregister_driver(&btuart_driver); -} - -module_init(init_btuart_cs); -module_exit(exit_btuart_cs); +module_pcmcia_driver(btuart_driver);  | 
