1
These changes are required to backport blueooth. A lot can be optimized
2
here still, but for now we keep this here.
4
--- a/drivers/bluetooth/hci_ldisc.c
5
+++ b/drivers/bluetooth/hci_ldisc.c
6
@@ -302,8 +302,13 @@ static int hci_uart_tty_open(struct tty_
7
/* FIXME: why is this needed. Note don't use ldisc_ref here as the
8
open path is before the ldisc is referencable */
10
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
11
if (tty->ldisc->ops->flush_buffer)
12
tty->ldisc->ops->flush_buffer(tty);
14
+ if (tty->ldisc.ops->flush_buffer)
15
+ tty->ldisc.ops->flush_buffer(tty);
17
tty_driver_flush_buffer(tty);
20
@@ -529,7 +534,11 @@ static int hci_uart_tty_ioctl(struct tty
21
return hu->hdev_flags;
24
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
25
err = n_tty_ioctl_helper(tty, file, cmd, arg);
27
+ err = n_tty_ioctl(tty, file, cmd, arg);
32
--- a/net/bluetooth/af_bluetooth.c
33
+++ b/net/bluetooth/af_bluetooth.c
34
@@ -111,8 +111,12 @@ int bt_sock_unregister(int proto)
36
EXPORT_SYMBOL(bt_sock_unregister);
38
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
39
static int bt_sock_create(struct net *net, struct socket *sock, int proto,
42
+static int bt_sock_create(struct net *net, struct socket *sock, int proto)
47
@@ -130,7 +134,11 @@ static int bt_sock_create(struct net *ne
48
read_lock(&bt_proto_lock);
50
if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) {
51
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
52
err = bt_proto[proto]->create(net, sock, proto, kern);
54
+ err = bt_proto[proto]->create(net, sock, proto);
57
bt_sock_reclassify_lock(sock->sk, proto);
58
module_put(bt_proto[proto]->owner);
59
@@ -463,7 +471,11 @@ int bt_sock_ioctl(struct socket *sock, u
60
if (sk->sk_state == BT_LISTEN)
63
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
64
amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
66
+ amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
70
err = put_user(amount, (int __user *) arg);
71
--- a/net/bluetooth/cmtp/capi.c
72
+++ b/net/bluetooth/cmtp/capi.c
73
@@ -384,7 +384,11 @@ static void cmtp_reset_ctr(struct capi_c
75
BT_DBG("ctrl %p", ctrl);
77
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
80
+ capi_ctr_reseted(ctrl);
83
atomic_inc(&session->terminate);
84
wake_up_process(session->task);
85
--- a/net/bluetooth/hci_sock.c
86
+++ b/net/bluetooth/hci_sock.c
87
@@ -884,8 +884,13 @@ drop:
91
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
92
static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
93
char __user *optval, unsigned int len)
95
+static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
96
+ char __user *optval, int len)
99
struct hci_ufilter uf = { .opcode = 0 };
100
struct sock *sk = sock->sk;
101
@@ -1059,8 +1064,12 @@ static struct proto hci_sk_proto = {
102
.obj_size = sizeof(struct hci_pinfo)
105
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
106
static int hci_sock_create(struct net *net, struct socket *sock, int protocol,
109
+static int hci_sock_create(struct net *net, struct socket *sock, int protocol)
114
--- a/net/bluetooth/hci_sysfs.c
115
+++ b/net/bluetooth/hci_sysfs.c
116
@@ -71,7 +71,11 @@ static struct attribute_group bt_link_gr
117
.attrs = bt_link_attrs,
120
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
121
static const struct attribute_group *bt_link_groups[] = {
123
+static struct attribute_group *bt_link_groups[] = {
128
@@ -140,7 +144,11 @@ void hci_conn_del_sysfs(struct hci_conn
129
dev = device_find_child(&conn->dev, NULL, __match_tty);
132
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
133
device_move(dev, NULL, DPM_ORDER_DEV_LAST);
135
+ device_move(dev, NULL);
140
@@ -378,7 +386,11 @@ static struct attribute_group bt_host_gr
141
.attrs = bt_host_attrs,
144
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
145
static const struct attribute_group *bt_host_groups[] = {
147
+static struct attribute_group *bt_host_groups[] = {
152
--- a/net/bluetooth/hidp/core.c
153
+++ b/net/bluetooth/hidp/core.c
154
@@ -380,6 +380,7 @@ err:
158
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
159
static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count,
160
unsigned char report_type)
162
@@ -438,6 +439,16 @@ err:
163
mutex_unlock(&session->report_mutex);
166
+#elif (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
167
+static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count)
169
+ if (hidp_send_ctrl_message(hid->driver_data,
170
+ HIDP_TRANS_SET_REPORT | HIDP_DATA_RTYPE_FEATURE,
177
static void hidp_idle_timeout(unsigned long arg)
179
@@ -739,8 +750,14 @@ static int hidp_session(void *arg)
183
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
184
hid_destroy_device(session->hid);
187
+ if (session->hid->claimed & HID_CLAIMED_INPUT)
188
+ hidinput_disconnect(session->hid);
189
+ hid_free_device(session->hid);
193
/* Wakeup user-space polling for socket errors */
194
@@ -851,6 +868,70 @@ static void hidp_close(struct hid_device
198
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
199
+static const struct {
203
+} hidp_blacklist[] = {
204
+ /* Apple wireless Mighty Mouse */
205
+ { 0x05ac, 0x030c, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },
207
+ { } /* Terminating entry */
209
+static void hidp_setup_quirks(struct hid_device *hid)
213
+ for (n = 0; hidp_blacklist[n].idVendor; n++)
214
+ if (hidp_blacklist[n].idVendor == le16_to_cpu(hid->vendor) &&
215
+ hidp_blacklist[n].idProduct == le16_to_cpu(hid->product))
216
+ hid->quirks = hidp_blacklist[n].quirks;
219
+static void hidp_setup_hid(struct hidp_session *session,
220
+ struct hidp_connadd_req *req)
222
+ struct hid_device *hid = session->hid;
223
+ struct hid_report *report;
226
+ session->hid = hid;
228
+ hid->driver_data = session;
230
+ baswap(&src, &bt_sk(session->ctrl_sock->sk)->src);
231
+ baswap(&dst, &bt_sk(session->ctrl_sock->sk)->dst);
233
+ hid->bus = BUS_BLUETOOTH;
234
+ hid->vendor = req->vendor;
235
+ hid->product = req->product;
236
+ hid->version = req->version;
237
+ hid->country = req->country;
239
+ strncpy(hid->name, req->name, 128);
240
+ strncpy(hid->phys, batostr(&src), 64);
241
+ strncpy(hid->uniq, batostr(&dst), 64);
243
+ hid->dev = hidp_get_device(session);
244
+ hid->hid_open = hidp_open;
245
+ hid->hid_close = hidp_close;
247
+ hid->hidinput_input_event = hidp_hidinput_event;
249
+ hidp_setup_quirks(hid);
251
+ list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list)
252
+ hidp_send_report(session, report);
254
+ list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
255
+ hidp_send_report(session, report);
257
+ if (hidinput_connect(hid) == 0)
258
+ hid->claimed |= HID_CLAIMED_INPUT;
262
static int hidp_parse(struct hid_device *hid)
264
struct hidp_session *session = hid->driver_data;
265
@@ -938,7 +1019,9 @@ static int hidp_setup_hid(struct hidp_se
266
hid->dev.parent = &session->conn->dev;
267
hid->ll_driver = &hidp_hid_driver;
269
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
270
hid->hid_get_raw_report = hidp_get_raw_report;
272
hid->hid_output_raw_report = hidp_output_raw_report;
275
@@ -949,6 +1032,7 @@ fault:
281
int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
283
@@ -964,6 +1048,39 @@ int hidp_add_connection(struct hidp_conn
285
BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size);
287
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
288
+ if (req->rd_size > 0) {
289
+ unsigned char *buf = kmalloc(req->rd_size, GFP_KERNEL);
296
+ if (copy_from_user(buf, req->rd_data, req->rd_size)) {
302
+ session->hid = hid_parse_report(buf, req->rd_size);
306
+ if (!session->hid) {
312
+ if (!session->hid) {
313
+ session->input = input_allocate_device();
314
+ if (!session->input) {
320
down_write(&hidp_session_sem);
322
s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst);
323
@@ -1011,6 +1128,7 @@ int hidp_add_connection(struct hidp_conn
325
__hidp_link_session(session);
327
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
328
if (req->rd_size > 0) {
329
err = hidp_setup_hid(session, req);
331
@@ -1022,6 +1140,16 @@ int hidp_add_connection(struct hidp_conn
336
+ if (session->input) {
337
+ err = hidp_setup_input(session, req);
343
+ hidp_setup_hid(session, req);
346
hidp_set_timer(session);
348
@@ -1080,6 +1208,7 @@ unlink:
349
session->input = NULL;
352
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
354
hid_destroy_device(session->hid);
356
@@ -1093,10 +1222,15 @@ purge:
358
skb_queue_purge(&session->ctrl_transmit);
359
skb_queue_purge(&session->intr_transmit);
363
up_write(&hidp_session_sem);
365
+#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
367
+ hid_free_device(session->hid);
372
--- a/net/bluetooth/rfcomm/sock.c
373
+++ b/net/bluetooth/rfcomm/sock.c
374
@@ -306,8 +306,13 @@ static struct sock *rfcomm_sock_alloc(st
378
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
379
static int rfcomm_sock_create(struct net *net, struct socket *sock,
380
int protocol, int kern)
382
+static int rfcomm_sock_create(struct net *net, struct socket *sock,
388
@@ -662,7 +667,11 @@ static int rfcomm_sock_setsockopt_old(st
392
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
393
static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
395
+static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
398
struct sock *sk = sock->sk;
399
struct bt_security sec;
400
--- a/net/bluetooth/rfcomm/tty.c
401
+++ b/net/bluetooth/rfcomm/tty.c
402
@@ -713,8 +713,12 @@ static int rfcomm_tty_open(struct tty_st
403
remove_wait_queue(&dev->wait, &wait);
406
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
407
device_move(dev->tty_dev, rfcomm_get_device(dev),
408
DPM_ORDER_DEV_AFTER_PARENT);
410
+ device_move(dev->tty_dev, rfcomm_get_device(dev));
413
rfcomm_tty_copy_pending(dev);
415
@@ -738,7 +742,11 @@ static void rfcomm_tty_close(struct tty_
416
if (!--dev->port.count) {
417
spin_unlock_irqrestore(&dev->port.lock, flags);
418
if (dev->tty_dev->parent)
419
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
420
device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
422
+ device_move(dev->tty_dev, NULL);
425
/* Close DLC and dettach TTY */
426
rfcomm_dlc_close(dev->dlc, 0);
427
@@ -814,7 +822,11 @@ static int rfcomm_tty_write_room(struct
431
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
432
static int rfcomm_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
434
+static int rfcomm_tty_ioctl(struct tty_struct *tty, struct file *filp, unsigned int cmd, unsigned long arg)
437
BT_DBG("tty %p cmd 0x%02x", tty, cmd);
439
@@ -1073,7 +1085,11 @@ static void rfcomm_tty_hangup(struct tty
443
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
444
static int rfcomm_tty_tiocmget(struct tty_struct *tty)
446
+static int rfcomm_tty_tiocmget(struct tty_struct *tty, struct file *filp)
449
struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
451
@@ -1082,7 +1098,11 @@ static int rfcomm_tty_tiocmget(struct tt
452
return dev->modem_status;
455
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,38))
456
static int rfcomm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear)
458
+static int rfcomm_tty_tiocmset(struct tty_struct *tty, struct file *filp, unsigned int set, unsigned int clear)
461
struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
462
struct rfcomm_dlc *dlc = dev->dlc;
463
--- a/net/bluetooth/sco.c
464
+++ b/net/bluetooth/sco.c
465
@@ -432,8 +432,12 @@ static struct sock *sco_sock_alloc(struc
469
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
470
static int sco_sock_create(struct net *net, struct socket *sock, int protocol,
473
+static int sco_sock_create(struct net *net, struct socket *sock, int protocol)
478
@@ -662,7 +666,11 @@ static int sco_sock_sendmsg(struct kiocb
482
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
483
static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
485
+static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
488
struct sock *sk = sock->sk;
490
--- a/net/bluetooth/bnep/sock.c
491
+++ b/net/bluetooth/bnep/sock.c
492
@@ -180,8 +180,12 @@ static struct proto bnep_proto = {
493
.obj_size = sizeof(struct bt_sock)
496
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
497
static int bnep_sock_create(struct net *net, struct socket *sock, int protocol,
500
+static int bnep_sock_create(struct net *net, struct socket *sock, int protocol)
505
--- a/net/bluetooth/cmtp/sock.c
506
+++ b/net/bluetooth/cmtp/sock.c
507
@@ -189,8 +189,12 @@ static struct proto cmtp_proto = {
508
.obj_size = sizeof(struct bt_sock)
511
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
512
static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol,
515
+static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol)
520
--- a/net/bluetooth/hidp/sock.c
521
+++ b/net/bluetooth/hidp/sock.c
522
@@ -229,8 +229,12 @@ static struct proto hidp_proto = {
523
.obj_size = sizeof(struct bt_sock)
526
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
527
static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
530
+static int hidp_sock_create(struct net *net, struct socket *sock, int protocol)
535
--- a/net/bluetooth/l2cap_sock.c
536
+++ b/net/bluetooth/l2cap_sock.c
537
@@ -560,7 +560,14 @@ static int l2cap_sock_setsockopt_old(str
542
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
543
static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
545
+static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
550
struct sock *sk = sock->sk;
551
struct l2cap_chan *chan = l2cap_pi(sk)->chan;
552
@@ -1188,8 +1195,12 @@ static struct sock *l2cap_sock_alloc(str
556
+#if defined(CONFIG_COMPAT_BT_SOCK_CREATE_NEEDS_KERN)
557
static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
560
+static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol)
565
@@ -1201,7 +1212,11 @@ static int l2cap_sock_create(struct net
566
sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)
567
return -ESOCKTNOSUPPORT;
569
+#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
570
if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
572
+ if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW))
576
sock->ops = &l2cap_sock_ops;