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 @@ -277,8 +277,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 @@ -478,7 +483,11 @@ static int hci_uart_tty_ioctl(struct tty
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 @@ -126,8 +126,12 @@ int bt_sock_unregister(int proto)
36 EXPORT_SYMBOL(bt_sock_unregister);
38 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
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 @@ -145,7 +149,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 (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
52 err = bt_proto[proto]->create(net, sock, proto, kern);
54 + err = bt_proto[proto]->create(net, sock, proto);
56 bt_sock_reclassify_lock(sock, proto);
57 module_put(bt_proto[proto]->owner);
59 @@ -258,7 +266,11 @@ int bt_sock_recvmsg(struct kiocb *iocb,
60 skb_reset_transport_header(skb);
61 err = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
63 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
64 sock_recv_ts_and_drops(msg, sk, skb);
66 + sock_recv_timestamp(msg, sk, skb);
69 skb_free_datagram(sk, skb);
71 @@ -338,7 +350,11 @@ int bt_sock_ioctl(struct socket *sock, u
72 if (sk->sk_state == BT_LISTEN)
75 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
76 amount = sk->sk_sndbuf - sk_wmem_alloc_get(sk);
78 + amount = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
82 err = put_user(amount, (int __user *) arg);
83 --- a/net/bluetooth/cmtp/capi.c
84 +++ b/net/bluetooth/cmtp/capi.c
85 @@ -383,7 +383,11 @@ static void cmtp_reset_ctr(struct capi_c
87 BT_DBG("ctrl %p", ctrl);
89 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,30))
92 + capi_ctr_reseted(ctrl);
95 atomic_inc(&session->terminate);
96 cmtp_schedule(session);
97 --- a/net/bluetooth/hci_core.c
98 +++ b/net/bluetooth/hci_core.c
100 #include <linux/skbuff.h>
101 #include <linux/interrupt.h>
102 #include <linux/notifier.h>
103 +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31))
104 #include <linux/rfkill.h>
106 +#include <linux/rfkill_backport.h>
109 #include <net/sock.h>
111 #include <asm/system.h>
112 --- a/net/bluetooth/hci_sock.c
113 +++ b/net/bluetooth/hci_sock.c
114 @@ -471,7 +471,11 @@ drop:
118 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
119 static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int len)
121 +static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int len)
124 struct hci_ufilter uf = { .opcode = 0 };
125 struct sock *sk = sock->sk;
126 @@ -626,8 +630,12 @@ static struct proto hci_sk_proto = {
127 .obj_size = sizeof(struct hci_pinfo)
130 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
131 static int hci_sock_create(struct net *net, struct socket *sock, int protocol,
134 +static int hci_sock_create(struct net *net, struct socket *sock, int protocol)
139 --- a/net/bluetooth/hci_sysfs.c
140 +++ b/net/bluetooth/hci_sysfs.c
141 @@ -68,7 +68,11 @@ static struct attribute_group bt_link_gr
142 .attrs = bt_link_attrs,
145 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
146 static const struct attribute_group *bt_link_groups[] = {
148 +static struct attribute_group *bt_link_groups[] = {
153 @@ -126,7 +130,11 @@ static void del_conn(struct work_struct
154 dev = device_find_child(&conn->dev, NULL, __match_tty);
157 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
158 device_move(dev, NULL, DPM_ORDER_DEV_LAST);
160 + device_move(dev, NULL);
165 @@ -392,7 +400,11 @@ static struct attribute_group bt_host_gr
166 .attrs = bt_host_attrs,
169 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
170 static const struct attribute_group *bt_host_groups[] = {
172 +static struct attribute_group *bt_host_groups[] = {
177 --- a/net/bluetooth/hidp/core.c
178 +++ b/net/bluetooth/hidp/core.c
179 @@ -313,6 +313,7 @@ static int hidp_send_report(struct hidp_
180 return hidp_queue_report(session, buf, rsize);
183 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
184 static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, size_t count,
185 unsigned char report_type)
187 @@ -332,6 +333,7 @@ static int hidp_output_raw_report(struct
193 static void hidp_idle_timeout(unsigned long arg)
195 @@ -596,10 +598,16 @@ static int hidp_session(void *arg)
196 session->input = NULL;
199 - if (session->hid) {
200 - hid_destroy_device(session->hid);
201 - session->hid = NULL;
203 + if (session->hid) {
204 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
205 + hid_destroy_device(session->hid);
206 + session->hid = NULL;
208 + if (session->hid->claimed & HID_CLAIMED_INPUT)
209 + hidinput_disconnect(session->hid);
210 + hid_free_device(session->hid);
214 /* Wakeup user-space polling for socket errors */
215 session->intr_sock->sk->sk_err = EUNATCH;
216 @@ -711,6 +719,70 @@ static void hidp_close(struct hid_device
220 +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
221 +static const struct {
225 +} hidp_blacklist[] = {
226 + /* Apple wireless Mighty Mouse */
227 + { 0x05ac, 0x030c, HID_QUIRK_MIGHTYMOUSE | HID_QUIRK_INVERT_HWHEEL },
229 + { } /* Terminating entry */
231 +static void hidp_setup_quirks(struct hid_device *hid)
235 + for (n = 0; hidp_blacklist[n].idVendor; n++)
236 + if (hidp_blacklist[n].idVendor == le16_to_cpu(hid->vendor) &&
237 + hidp_blacklist[n].idProduct == le16_to_cpu(hid->product))
238 + hid->quirks = hidp_blacklist[n].quirks;
241 +static void hidp_setup_hid(struct hidp_session *session,
242 + struct hidp_connadd_req *req)
244 + struct hid_device *hid = session->hid;
245 + struct hid_report *report;
248 + session->hid = hid;
250 + hid->driver_data = session;
252 + baswap(&src, &bt_sk(session->ctrl_sock->sk)->src);
253 + baswap(&dst, &bt_sk(session->ctrl_sock->sk)->dst);
255 + hid->bus = BUS_BLUETOOTH;
256 + hid->vendor = req->vendor;
257 + hid->product = req->product;
258 + hid->version = req->version;
259 + hid->country = req->country;
261 + strncpy(hid->name, req->name, 128);
262 + strncpy(hid->phys, batostr(&src), 64);
263 + strncpy(hid->uniq, batostr(&dst), 64);
265 + hid->dev = hidp_get_device(session);
266 + hid->hid_open = hidp_open;
267 + hid->hid_close = hidp_close;
269 + hid->hidinput_input_event = hidp_hidinput_event;
271 + hidp_setup_quirks(hid);
273 + list_for_each_entry(report, &hid->report_enum[HID_INPUT_REPORT].report_list, list)
274 + hidp_send_report(session, report);
276 + list_for_each_entry(report, &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
277 + hidp_send_report(session, report);
279 + if (hidinput_connect(hid) == 0)
280 + hid->claimed |= HID_CLAIMED_INPUT;
284 static int hidp_parse(struct hid_device *hid)
286 struct hidp_session *session = hid->driver_data;
287 @@ -815,6 +887,7 @@ fault:
293 int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
295 @@ -833,6 +906,39 @@ int hidp_add_connection(struct hidp_conn
297 BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size);
299 +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
300 + if (req->rd_size > 0) {
301 + unsigned char *buf = kmalloc(req->rd_size, GFP_KERNEL);
308 + if (copy_from_user(buf, req->rd_data, req->rd_size)) {
314 + session->hid = hid_parse_report(buf, req->rd_size);
318 + if (!session->hid) {
324 + if (!session->hid) {
325 + session->input = input_allocate_device();
326 + if (!session->input) {
332 down_write(&hidp_session_sem);
334 s = __hidp_get_session(&bt_sk(ctrl_sock->sk)->dst);
335 @@ -860,6 +966,7 @@ int hidp_add_connection(struct hidp_conn
336 session->flags = req->flags & (1 << HIDP_BLUETOOTH_VENDOR_ID);
337 session->idle_to = req->idle_to;
339 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
340 if (req->rd_size > 0) {
341 err = hidp_setup_hid(session, req);
342 if (err && err != -ENODEV)
343 @@ -871,6 +978,16 @@ int hidp_add_connection(struct hidp_conn
348 + if (session->input) {
349 + err = hidp_setup_input(session, req);
355 + hidp_setup_hid(session, req);
358 __hidp_link_session(session);
360 @@ -902,6 +1019,7 @@ unlink:
361 session->input = NULL;
364 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
366 hid_destroy_device(session->hid);
368 @@ -913,10 +1031,15 @@ unlink:
370 skb_queue_purge(&session->ctrl_transmit);
371 skb_queue_purge(&session->intr_transmit);
375 up_write(&hidp_session_sem);
377 +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27))
379 + hid_free_device(session->hid);
381 input_free_device(session->input);
384 @@ -1006,6 +1129,7 @@ int hidp_get_conninfo(struct hidp_connin
388 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
389 static const struct hid_device_id hidp_table[] = {
390 { HID_BLUETOOTH_DEVICE(HID_ANY_ID, HID_ANY_ID) },
392 @@ -1015,6 +1139,7 @@ static struct hid_driver hidp_driver = {
393 .name = "generic-bluetooth",
394 .id_table = hidp_table,
398 static int __init hidp_init(void)
400 @@ -1024,11 +1149,14 @@ static int __init hidp_init(void)
402 BT_INFO("HIDP (Human Interface Emulation) ver %s", VERSION);
404 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
405 ret = hid_register_driver(&hidp_driver);
410 ret = hidp_init_sockets();
411 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
415 @@ -1036,13 +1164,16 @@ static int __init hidp_init(void)
417 hid_unregister_driver(&hidp_driver);
423 static void __exit hidp_exit(void)
425 hidp_cleanup_sockets();
426 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,27))
427 hid_unregister_driver(&hidp_driver);
431 module_init(hidp_init);
432 --- a/net/bluetooth/rfcomm/sock.c
433 +++ b/net/bluetooth/rfcomm/sock.c
434 @@ -323,8 +323,13 @@ static struct sock *rfcomm_sock_alloc(st
438 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
439 static int rfcomm_sock_create(struct net *net, struct socket *sock,
440 int protocol, int kern)
442 +static int rfcomm_sock_create(struct net *net, struct socket *sock,
448 @@ -704,7 +709,11 @@ static int rfcomm_sock_recvmsg(struct ki
452 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
453 sock_recv_ts_and_drops(msg, sk, skb);
455 + sock_recv_timestamp(msg, sk, skb);
458 if (!(flags & MSG_PEEK)) {
459 atomic_sub(chunk, &sk->sk_rmem_alloc);
460 @@ -767,7 +776,11 @@ static int rfcomm_sock_setsockopt_old(st
464 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
465 static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
467 +static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
470 struct sock *sk = sock->sk;
471 struct bt_security sec;
472 --- a/net/bluetooth/rfcomm/tty.c
473 +++ b/net/bluetooth/rfcomm/tty.c
474 @@ -731,8 +731,12 @@ static int rfcomm_tty_open(struct tty_st
475 remove_wait_queue(&dev->wait, &wait);
478 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
479 device_move(dev->tty_dev, rfcomm_get_device(dev),
480 DPM_ORDER_DEV_AFTER_PARENT);
482 + device_move(dev->tty_dev, rfcomm_get_device(dev));
485 rfcomm_tty_copy_pending(dev);
487 @@ -752,7 +756,11 @@ static void rfcomm_tty_close(struct tty_
489 if (atomic_dec_and_test(&dev->opened)) {
490 if (dev->tty_dev->parent)
491 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,29))
492 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
494 + device_move(dev->tty_dev, NULL);
497 /* Close DLC and dettach TTY */
498 rfcomm_dlc_close(dev->dlc, 0);
499 --- a/net/bluetooth/sco.c
500 +++ b/net/bluetooth/sco.c
501 @@ -430,8 +430,12 @@ static struct sock *sco_sock_alloc(struc
505 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
506 static int sco_sock_create(struct net *net, struct socket *sock, int protocol,
509 +static int sco_sock_create(struct net *net, struct socket *sock, int protocol)
514 @@ -645,7 +649,11 @@ static int sco_sock_sendmsg(struct kiocb
518 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
519 static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
521 +static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
524 struct sock *sk = sock->sk;
526 --- a/net/bluetooth/bnep/sock.c
527 +++ b/net/bluetooth/bnep/sock.c
528 @@ -195,8 +195,12 @@ static struct proto bnep_proto = {
529 .obj_size = sizeof(struct bt_sock)
532 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
533 static int bnep_sock_create(struct net *net, struct socket *sock, int protocol,
536 +static int bnep_sock_create(struct net *net, struct socket *sock, int protocol)
541 --- a/net/bluetooth/cmtp/sock.c
542 +++ b/net/bluetooth/cmtp/sock.c
543 @@ -190,8 +190,12 @@ static struct proto cmtp_proto = {
544 .obj_size = sizeof(struct bt_sock)
547 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
548 static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol,
551 +static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol)
556 --- a/net/bluetooth/hidp/sock.c
557 +++ b/net/bluetooth/hidp/sock.c
558 @@ -241,8 +241,12 @@ static struct proto hidp_proto = {
559 .obj_size = sizeof(struct bt_sock)
562 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
563 static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
566 +static int hidp_sock_create(struct net *net, struct socket *sock, int protocol)
571 --- a/net/bluetooth/l2cap.c
572 +++ b/net/bluetooth/l2cap.c
573 @@ -822,8 +822,12 @@ static struct sock *l2cap_sock_alloc(str
577 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
578 static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
581 +static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol)
586 @@ -835,7 +839,11 @@ static int l2cap_sock_create(struct net
587 sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)
588 return -ESOCKTNOSUPPORT;
590 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,32))
591 if (sock->type == SOCK_RAW && !kern && !capable(CAP_NET_RAW))
593 + if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW))
597 sock->ops = &l2cap_sock_ops;
598 @@ -1764,7 +1772,11 @@ static int l2cap_sock_setsockopt_old(str
602 +#if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,31))
603 static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, unsigned int optlen)
605 +static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, char __user *optval, int optlen)
608 struct sock *sk = sock->sk;
609 struct bt_security sec;