diff options
| author | Johan Hedberg <johan.hedberg@nokia.com> | 2010-07-12 10:37:04 -0400 |
|---|---|---|
| committer | Marcel Holtmann <marcel@holtmann.org> | 2010-07-21 13:39:11 -0400 |
| commit | 63c7d09cd52fe23ad2baee26bcc10a590944cfa4 (patch) | |
| tree | 0d9d12e077f2f9612c6736fad45a69fda4b182d5 | |
| parent | 47731de789749c9ed3c54751db28fd9c9eeaf019 (diff) | |
Bluetooth: Add HCIUARTSETFLAGS and HCIUARTGETFLAGS ioctls
This patch introduces two new ioctls: HCIUARTSETFLAGS and
HCIUARTGETFLAGS. The only flag available for now is HCI_UART_RAW_DEVICE
which allows to initialize a UART device into RAW mode from userspace.
This is particularly useful for experimenting with Bluetooth controllers
that don't yet have proper support in BlueZ.
Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
| -rw-r--r-- | drivers/bluetooth/hci_ldisc.c | 12 | ||||
| -rw-r--r-- | drivers/bluetooth/hci_uart.h | 7 | ||||
| -rw-r--r-- | fs/compat_ioctl.c | 2 |
3 files changed, 20 insertions, 1 deletions
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c index e8beffe80b31..a57dbfccb3fb 100644 --- a/drivers/bluetooth/hci_ldisc.c +++ b/drivers/bluetooth/hci_ldisc.c | |||
| @@ -395,6 +395,9 @@ static int hci_uart_register_dev(struct hci_uart *hu) | |||
| 395 | if (!reset) | 395 | if (!reset) |
| 396 | set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); | 396 | set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); |
| 397 | 397 | ||
| 398 | if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags)) | ||
| 399 | set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks); | ||
| 400 | |||
| 398 | if (hci_register_dev(hdev) < 0) { | 401 | if (hci_register_dev(hdev) < 0) { |
| 399 | BT_ERR("Can't register HCI device"); | 402 | BT_ERR("Can't register HCI device"); |
| 400 | hci_free_dev(hdev); | 403 | hci_free_dev(hdev); |
| @@ -475,6 +478,15 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, | |||
| 475 | return hu->hdev->id; | 478 | return hu->hdev->id; |
| 476 | return -EUNATCH; | 479 | return -EUNATCH; |
| 477 | 480 | ||
| 481 | case HCIUARTSETFLAGS: | ||
| 482 | if (test_bit(HCI_UART_PROTO_SET, &hu->flags)) | ||
| 483 | return -EBUSY; | ||
| 484 | hu->hdev_flags = arg; | ||
| 485 | break; | ||
| 486 | |||
| 487 | case HCIUARTGETFLAGS: | ||
| 488 | return hu->hdev_flags; | ||
| 489 | |||
| 478 | default: | 490 | default: |
| 479 | err = n_tty_ioctl_helper(tty, file, cmd, arg); | 491 | err = n_tty_ioctl_helper(tty, file, cmd, arg); |
| 480 | break; | 492 | break; |
diff --git a/drivers/bluetooth/hci_uart.h b/drivers/bluetooth/hci_uart.h index 50113db06b9f..9694d9d60905 100644 --- a/drivers/bluetooth/hci_uart.h +++ b/drivers/bluetooth/hci_uart.h | |||
| @@ -31,6 +31,8 @@ | |||
| 31 | #define HCIUARTSETPROTO _IOW('U', 200, int) | 31 | #define HCIUARTSETPROTO _IOW('U', 200, int) |
| 32 | #define HCIUARTGETPROTO _IOR('U', 201, int) | 32 | #define HCIUARTGETPROTO _IOR('U', 201, int) |
| 33 | #define HCIUARTGETDEVICE _IOR('U', 202, int) | 33 | #define HCIUARTGETDEVICE _IOR('U', 202, int) |
| 34 | #define HCIUARTSETFLAGS _IOW('U', 203, int) | ||
| 35 | #define HCIUARTGETFLAGS _IOR('U', 204, int) | ||
| 34 | 36 | ||
| 35 | /* UART protocols */ | 37 | /* UART protocols */ |
| 36 | #define HCI_UART_MAX_PROTO 5 | 38 | #define HCI_UART_MAX_PROTO 5 |
| @@ -41,6 +43,8 @@ | |||
| 41 | #define HCI_UART_H4DS 3 | 43 | #define HCI_UART_H4DS 3 |
| 42 | #define HCI_UART_LL 4 | 44 | #define HCI_UART_LL 4 |
| 43 | 45 | ||
| 46 | #define HCI_UART_RAW_DEVICE 0 | ||
| 47 | |||
| 44 | struct hci_uart; | 48 | struct hci_uart; |
| 45 | 49 | ||
| 46 | struct hci_uart_proto { | 50 | struct hci_uart_proto { |
| @@ -57,6 +61,7 @@ struct hci_uart { | |||
| 57 | struct tty_struct *tty; | 61 | struct tty_struct *tty; |
| 58 | struct hci_dev *hdev; | 62 | struct hci_dev *hdev; |
| 59 | unsigned long flags; | 63 | unsigned long flags; |
| 64 | unsigned long hdev_flags; | ||
| 60 | 65 | ||
| 61 | struct hci_uart_proto *proto; | 66 | struct hci_uart_proto *proto; |
| 62 | void *priv; | 67 | void *priv; |
| @@ -66,7 +71,7 @@ struct hci_uart { | |||
| 66 | spinlock_t rx_lock; | 71 | spinlock_t rx_lock; |
| 67 | }; | 72 | }; |
| 68 | 73 | ||
| 69 | /* HCI_UART flag bits */ | 74 | /* HCI_UART proto flag bits */ |
| 70 | #define HCI_UART_PROTO_SET 0 | 75 | #define HCI_UART_PROTO_SET 0 |
| 71 | 76 | ||
| 72 | /* TX states */ | 77 | /* TX states */ |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 547452de5ca2..8ea5e3374507 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
| @@ -604,6 +604,8 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd, | |||
| 604 | #define HCIUARTSETPROTO _IOW('U', 200, int) | 604 | #define HCIUARTSETPROTO _IOW('U', 200, int) |
| 605 | #define HCIUARTGETPROTO _IOR('U', 201, int) | 605 | #define HCIUARTGETPROTO _IOR('U', 201, int) |
| 606 | #define HCIUARTGETDEVICE _IOR('U', 202, int) | 606 | #define HCIUARTGETDEVICE _IOR('U', 202, int) |
| 607 | #define HCIUARTSETFLAGS _IOW('U', 203, int) | ||
| 608 | #define HCIUARTGETFLAGS _IOR('U', 204, int) | ||
| 607 | 609 | ||
| 608 | #define BNEPCONNADD _IOW('B', 200, int) | 610 | #define BNEPCONNADD _IOW('B', 200, int) |
| 609 | #define BNEPCONNDEL _IOW('B', 201, int) | 611 | #define BNEPCONNDEL _IOW('B', 201, int) |
