Commit 63c7d09c authored by Johan Hedberg's avatar Johan Hedberg Committed by Marcel Holtmann

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: default avatarJohan Hedberg <johan.hedberg@nokia.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 47731de7
...@@ -395,6 +395,9 @@ static int hci_uart_register_dev(struct hci_uart *hu) ...@@ -395,6 +395,9 @@ static int hci_uart_register_dev(struct hci_uart *hu)
if (!reset) if (!reset)
set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks); set_bit(HCI_QUIRK_NO_RESET, &hdev->quirks);
if (test_bit(HCI_UART_RAW_DEVICE, &hu->hdev_flags))
set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
if (hci_register_dev(hdev) < 0) { if (hci_register_dev(hdev) < 0) {
BT_ERR("Can't register HCI device"); BT_ERR("Can't register HCI device");
hci_free_dev(hdev); hci_free_dev(hdev);
...@@ -475,6 +478,15 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file, ...@@ -475,6 +478,15 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
return hu->hdev->id; return hu->hdev->id;
return -EUNATCH; return -EUNATCH;
case HCIUARTSETFLAGS:
if (test_bit(HCI_UART_PROTO_SET, &hu->flags))
return -EBUSY;
hu->hdev_flags = arg;
break;
case HCIUARTGETFLAGS:
return hu->hdev_flags;
default: default:
err = n_tty_ioctl_helper(tty, file, cmd, arg); err = n_tty_ioctl_helper(tty, file, cmd, arg);
break; break;
......
...@@ -31,6 +31,8 @@ ...@@ -31,6 +31,8 @@
#define HCIUARTSETPROTO _IOW('U', 200, int) #define HCIUARTSETPROTO _IOW('U', 200, int)
#define HCIUARTGETPROTO _IOR('U', 201, int) #define HCIUARTGETPROTO _IOR('U', 201, int)
#define HCIUARTGETDEVICE _IOR('U', 202, int) #define HCIUARTGETDEVICE _IOR('U', 202, int)
#define HCIUARTSETFLAGS _IOW('U', 203, int)
#define HCIUARTGETFLAGS _IOR('U', 204, int)
/* UART protocols */ /* UART protocols */
#define HCI_UART_MAX_PROTO 5 #define HCI_UART_MAX_PROTO 5
...@@ -41,6 +43,8 @@ ...@@ -41,6 +43,8 @@
#define HCI_UART_H4DS 3 #define HCI_UART_H4DS 3
#define HCI_UART_LL 4 #define HCI_UART_LL 4
#define HCI_UART_RAW_DEVICE 0
struct hci_uart; struct hci_uart;
struct hci_uart_proto { struct hci_uart_proto {
...@@ -57,6 +61,7 @@ struct hci_uart { ...@@ -57,6 +61,7 @@ struct hci_uart {
struct tty_struct *tty; struct tty_struct *tty;
struct hci_dev *hdev; struct hci_dev *hdev;
unsigned long flags; unsigned long flags;
unsigned long hdev_flags;
struct hci_uart_proto *proto; struct hci_uart_proto *proto;
void *priv; void *priv;
...@@ -66,7 +71,7 @@ struct hci_uart { ...@@ -66,7 +71,7 @@ struct hci_uart {
spinlock_t rx_lock; spinlock_t rx_lock;
}; };
/* HCI_UART flag bits */ /* HCI_UART proto flag bits */
#define HCI_UART_PROTO_SET 0 #define HCI_UART_PROTO_SET 0
/* TX states */ /* TX states */
......
...@@ -604,6 +604,8 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd, ...@@ -604,6 +604,8 @@ static int ioc_settimeout(unsigned int fd, unsigned int cmd,
#define HCIUARTSETPROTO _IOW('U', 200, int) #define HCIUARTSETPROTO _IOW('U', 200, int)
#define HCIUARTGETPROTO _IOR('U', 201, int) #define HCIUARTGETPROTO _IOR('U', 201, int)
#define HCIUARTGETDEVICE _IOR('U', 202, int) #define HCIUARTGETDEVICE _IOR('U', 202, int)
#define HCIUARTSETFLAGS _IOW('U', 203, int)
#define HCIUARTGETFLAGS _IOR('U', 204, int)
#define BNEPCONNADD _IOW('B', 200, int) #define BNEPCONNADD _IOW('B', 200, int)
#define BNEPCONNDEL _IOW('B', 201, int) #define BNEPCONNDEL _IOW('B', 201, int)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment