aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/bluetooth/hci_vhci.c90
-rw-r--r--include/net/bluetooth/bluetooth.h6
-rw-r--r--include/net/bluetooth/hci_core.h2
-rw-r--r--include/net/bluetooth/l2cap.h71
-rw-r--r--net/bluetooth/hci_core.c41
-rw-r--r--net/bluetooth/l2cap.c117
-rw-r--r--net/bluetooth/rfcomm/core.c12
7 files changed, 184 insertions, 155 deletions
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 0bbefba6469c..1df9dda2e377 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -40,7 +40,7 @@
40#include <net/bluetooth/bluetooth.h> 40#include <net/bluetooth/bluetooth.h>
41#include <net/bluetooth/hci_core.h> 41#include <net/bluetooth/hci_core.h>
42 42
43#define VERSION "1.2" 43#define VERSION "1.3"
44 44
45static int minor = MISC_DYNAMIC_MINOR; 45static int minor = MISC_DYNAMIC_MINOR;
46 46
@@ -51,14 +51,8 @@ struct vhci_data {
51 51
52 wait_queue_head_t read_wait; 52 wait_queue_head_t read_wait;
53 struct sk_buff_head readq; 53 struct sk_buff_head readq;
54
55 struct fasync_struct *fasync;
56}; 54};
57 55
58#define VHCI_FASYNC 0x0010
59
60static struct miscdevice vhci_miscdev;
61
62static int vhci_open_dev(struct hci_dev *hdev) 56static int vhci_open_dev(struct hci_dev *hdev)
63{ 57{
64 set_bit(HCI_RUNNING, &hdev->flags); 58 set_bit(HCI_RUNNING, &hdev->flags);
@@ -105,9 +99,6 @@ static int vhci_send_frame(struct sk_buff *skb)
105 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); 99 memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
106 skb_queue_tail(&data->readq, skb); 100 skb_queue_tail(&data->readq, skb);
107 101
108 if (data->flags & VHCI_FASYNC)
109 kill_fasync(&data->fasync, SIGIO, POLL_IN);
110
111 wake_up_interruptible(&data->read_wait); 102 wake_up_interruptible(&data->read_wait);
112 103
113 return 0; 104 return 0;
@@ -179,41 +170,31 @@ static inline ssize_t vhci_put_user(struct vhci_data *data,
179static ssize_t vhci_read(struct file *file, 170static ssize_t vhci_read(struct file *file,
180 char __user *buf, size_t count, loff_t *pos) 171 char __user *buf, size_t count, loff_t *pos)
181{ 172{
182 DECLARE_WAITQUEUE(wait, current);
183 struct vhci_data *data = file->private_data; 173 struct vhci_data *data = file->private_data;
184 struct sk_buff *skb; 174 struct sk_buff *skb;
185 ssize_t ret = 0; 175 ssize_t ret = 0;
186 176
187 add_wait_queue(&data->read_wait, &wait);
188 while (count) { 177 while (count) {
189 set_current_state(TASK_INTERRUPTIBLE);
190
191 skb = skb_dequeue(&data->readq); 178 skb = skb_dequeue(&data->readq);
192 if (!skb) { 179 if (skb) {
193 if (file->f_flags & O_NONBLOCK) { 180 ret = vhci_put_user(data, skb, buf, count);
194 ret = -EAGAIN; 181 if (ret < 0)
195 break; 182 skb_queue_head(&data->readq, skb);
196 } 183 else
197 184 kfree_skb(skb);
198 if (signal_pending(current)) { 185 break;
199 ret = -ERESTARTSYS;
200 break;
201 }
202
203 schedule();
204 continue;
205 } 186 }
206 187
207 if (access_ok(VERIFY_WRITE, buf, count)) 188 if (file->f_flags & O_NONBLOCK) {
208 ret = vhci_put_user(data, skb, buf, count); 189 ret = -EAGAIN;
209 else 190 break;
210 ret = -EFAULT; 191 }
211 192
212 kfree_skb(skb); 193 ret = wait_event_interruptible(data->read_wait,
213 break; 194 !skb_queue_empty(&data->readq));
195 if (ret < 0)
196 break;
214 } 197 }
215 set_current_state(TASK_RUNNING);
216 remove_wait_queue(&data->read_wait, &wait);
217 198
218 return ret; 199 return ret;
219} 200}
@@ -223,9 +204,6 @@ static ssize_t vhci_write(struct file *file,
223{ 204{
224 struct vhci_data *data = file->private_data; 205 struct vhci_data *data = file->private_data;
225 206
226 if (!access_ok(VERIFY_READ, buf, count))
227 return -EFAULT;
228
229 return vhci_get_user(data, buf, count); 207 return vhci_get_user(data, buf, count);
230} 208}
231 209
@@ -259,11 +237,9 @@ static int vhci_open(struct inode *inode, struct file *file)
259 skb_queue_head_init(&data->readq); 237 skb_queue_head_init(&data->readq);
260 init_waitqueue_head(&data->read_wait); 238 init_waitqueue_head(&data->read_wait);
261 239
262 lock_kernel();
263 hdev = hci_alloc_dev(); 240 hdev = hci_alloc_dev();
264 if (!hdev) { 241 if (!hdev) {
265 kfree(data); 242 kfree(data);
266 unlock_kernel();
267 return -ENOMEM; 243 return -ENOMEM;
268 } 244 }
269 245
@@ -284,12 +260,10 @@ static int vhci_open(struct inode *inode, struct file *file)
284 BT_ERR("Can't register HCI device"); 260 BT_ERR("Can't register HCI device");
285 kfree(data); 261 kfree(data);
286 hci_free_dev(hdev); 262 hci_free_dev(hdev);
287 unlock_kernel();
288 return -EBUSY; 263 return -EBUSY;
289 } 264 }
290 265
291 file->private_data = data; 266 file->private_data = data;
292 unlock_kernel();
293 267
294 return nonseekable_open(inode, file); 268 return nonseekable_open(inode, file);
295} 269}
@@ -310,48 +284,25 @@ static int vhci_release(struct inode *inode, struct file *file)
310 return 0; 284 return 0;
311} 285}
312 286
313static int vhci_fasync(int fd, struct file *file, int on)
314{
315 struct vhci_data *data = file->private_data;
316 int err = 0;
317
318 lock_kernel();
319 err = fasync_helper(fd, file, on, &data->fasync);
320 if (err < 0)
321 goto out;
322
323 if (on)
324 data->flags |= VHCI_FASYNC;
325 else
326 data->flags &= ~VHCI_FASYNC;
327
328out:
329 unlock_kernel();
330 return err;
331}
332
333static const struct file_operations vhci_fops = { 287static const struct file_operations vhci_fops = {
334 .owner = THIS_MODULE,
335 .read = vhci_read, 288 .read = vhci_read,
336 .write = vhci_write, 289 .write = vhci_write,
337 .poll = vhci_poll, 290 .poll = vhci_poll,
338 .ioctl = vhci_ioctl, 291 .ioctl = vhci_ioctl,
339 .open = vhci_open, 292 .open = vhci_open,
340 .release = vhci_release, 293 .release = vhci_release,
341 .fasync = vhci_fasync,
342}; 294};
343 295
344static struct miscdevice vhci_miscdev= { 296static struct miscdevice vhci_miscdev= {
345 .name = "vhci", 297 .name = "vhci",
346 .fops = &vhci_fops, 298 .fops = &vhci_fops,
299 .minor = MISC_DYNAMIC_MINOR,
347}; 300};
348 301
349static int __init vhci_init(void) 302static int __init vhci_init(void)
350{ 303{
351 BT_INFO("Virtual HCI driver ver %s", VERSION); 304 BT_INFO("Virtual HCI driver ver %s", VERSION);
352 305
353 vhci_miscdev.minor = minor;
354
355 if (misc_register(&vhci_miscdev) < 0) { 306 if (misc_register(&vhci_miscdev) < 0) {
356 BT_ERR("Can't register misc device with minor %d", minor); 307 BT_ERR("Can't register misc device with minor %d", minor);
357 return -EIO; 308 return -EIO;
@@ -369,9 +320,6 @@ static void __exit vhci_exit(void)
369module_init(vhci_init); 320module_init(vhci_init);
370module_exit(vhci_exit); 321module_exit(vhci_exit);
371 322
372module_param(minor, int, 0444);
373MODULE_PARM_DESC(minor, "Miscellaneous minor device number");
374
375MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>"); 323MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
376MODULE_DESCRIPTION("Bluetooth virtual HCI driver ver " VERSION); 324MODULE_DESCRIPTION("Bluetooth virtual HCI driver ver " VERSION);
377MODULE_VERSION(VERSION); 325MODULE_VERSION(VERSION);
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 144d1d5dd82f..968166a45f86 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -81,12 +81,6 @@ enum {
81 BT_CLOSED 81 BT_CLOSED
82}; 82};
83 83
84/* Endianness conversions */
85#define htobs(a) __cpu_to_le16(a)
86#define htobl(a) __cpu_to_le32(a)
87#define btohs(a) __le16_to_cpu(a)
88#define btohl(a) __le32_to_cpu(a)
89
90/* BD Address */ 84/* BD Address */
91typedef struct { 85typedef struct {
92 __u8 b[6]; 86 __u8 b[6];
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 73aead222b32..c4ca4228b083 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -137,6 +137,8 @@ struct hci_dev {
137 struct device *parent; 137 struct device *parent;
138 struct device dev; 138 struct device dev;
139 139
140 struct rfkill *rfkill;
141
140 struct module *owner; 142 struct module *owner;
141 143
142 int (*open)(struct hci_dev *hdev); 144 int (*open)(struct hci_dev *hdev);
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index f566aa1f0a4c..e919fca1072a 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -26,8 +26,13 @@
26#define __L2CAP_H 26#define __L2CAP_H
27 27
28/* L2CAP defaults */ 28/* L2CAP defaults */
29#define L2CAP_DEFAULT_MTU 672 29#define L2CAP_DEFAULT_MTU 672
30#define L2CAP_DEFAULT_FLUSH_TO 0xFFFF 30#define L2CAP_DEFAULT_FLUSH_TO 0xffff
31#define L2CAP_DEFAULT_RX_WINDOW 1
32#define L2CAP_DEFAULT_MAX_RECEIVE 1
33#define L2CAP_DEFAULT_RETRANS_TO 300 /* 300 milliseconds */
34#define L2CAP_DEFAULT_MONITOR_TO 1000 /* 1 second */
35#define L2CAP_DEFAULT_MAX_RX_APDU 0xfff7
31 36
32#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */ 37#define L2CAP_CONN_TIMEOUT (40000) /* 40 seconds */
33#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */ 38#define L2CAP_INFO_TIMEOUT (4000) /* 4 seconds */
@@ -64,17 +69,29 @@ struct l2cap_conninfo {
64#define L2CAP_LM_SECURE 0x0020 69#define L2CAP_LM_SECURE 0x0020
65 70
66/* L2CAP command codes */ 71/* L2CAP command codes */
67#define L2CAP_COMMAND_REJ 0x01 72#define L2CAP_COMMAND_REJ 0x01
68#define L2CAP_CONN_REQ 0x02 73#define L2CAP_CONN_REQ 0x02
69#define L2CAP_CONN_RSP 0x03 74#define L2CAP_CONN_RSP 0x03
70#define L2CAP_CONF_REQ 0x04 75#define L2CAP_CONF_REQ 0x04
71#define L2CAP_CONF_RSP 0x05 76#define L2CAP_CONF_RSP 0x05
72#define L2CAP_DISCONN_REQ 0x06 77#define L2CAP_DISCONN_REQ 0x06
73#define L2CAP_DISCONN_RSP 0x07 78#define L2CAP_DISCONN_RSP 0x07
74#define L2CAP_ECHO_REQ 0x08 79#define L2CAP_ECHO_REQ 0x08
75#define L2CAP_ECHO_RSP 0x09 80#define L2CAP_ECHO_RSP 0x09
76#define L2CAP_INFO_REQ 0x0a 81#define L2CAP_INFO_REQ 0x0a
77#define L2CAP_INFO_RSP 0x0b 82#define L2CAP_INFO_RSP 0x0b
83
84/* L2CAP feature mask */
85#define L2CAP_FEAT_FLOWCTL 0x00000001
86#define L2CAP_FEAT_RETRANS 0x00000002
87#define L2CAP_FEAT_ERTM 0x00000008
88#define L2CAP_FEAT_STREAMING 0x00000010
89#define L2CAP_FEAT_FCS 0x00000020
90#define L2CAP_FEAT_FIXED_CHAN 0x00000080
91
92/* L2CAP checksum option */
93#define L2CAP_FCS_NONE 0x00
94#define L2CAP_FCS_CRC16 0x01
78 95
79/* L2CAP structures */ 96/* L2CAP structures */
80struct l2cap_hdr { 97struct l2cap_hdr {
@@ -106,17 +123,23 @@ struct l2cap_conn_rsp {
106 __le16 status; 123 __le16 status;
107} __attribute__ ((packed)); 124} __attribute__ ((packed));
108 125
126/* channel indentifier */
127#define L2CAP_CID_SIGNALING 0x0001
128#define L2CAP_CID_CONN_LESS 0x0002
129#define L2CAP_CID_DYN_START 0x0040
130#define L2CAP_CID_DYN_END 0xffff
131
109/* connect result */ 132/* connect result */
110#define L2CAP_CR_SUCCESS 0x0000 133#define L2CAP_CR_SUCCESS 0x0000
111#define L2CAP_CR_PEND 0x0001 134#define L2CAP_CR_PEND 0x0001
112#define L2CAP_CR_BAD_PSM 0x0002 135#define L2CAP_CR_BAD_PSM 0x0002
113#define L2CAP_CR_SEC_BLOCK 0x0003 136#define L2CAP_CR_SEC_BLOCK 0x0003
114#define L2CAP_CR_NO_MEM 0x0004 137#define L2CAP_CR_NO_MEM 0x0004
115 138
116/* connect status */ 139/* connect status */
117#define L2CAP_CS_NO_INFO 0x0000 140#define L2CAP_CS_NO_INFO 0x0000
118#define L2CAP_CS_AUTHEN_PEND 0x0001 141#define L2CAP_CS_AUTHEN_PEND 0x0001
119#define L2CAP_CS_AUTHOR_PEND 0x0002 142#define L2CAP_CS_AUTHOR_PEND 0x0002
120 143
121struct l2cap_conf_req { 144struct l2cap_conf_req {
122 __le16 dcid; 145 __le16 dcid;
@@ -143,10 +166,14 @@ struct l2cap_conf_opt {
143} __attribute__ ((packed)); 166} __attribute__ ((packed));
144#define L2CAP_CONF_OPT_SIZE 2 167#define L2CAP_CONF_OPT_SIZE 2
145 168
169#define L2CAP_CONF_HINT 0x80
170#define L2CAP_CONF_MASK 0x7f
171
146#define L2CAP_CONF_MTU 0x01 172#define L2CAP_CONF_MTU 0x01
147#define L2CAP_CONF_FLUSH_TO 0x02 173#define L2CAP_CONF_FLUSH_TO 0x02
148#define L2CAP_CONF_QOS 0x03 174#define L2CAP_CONF_QOS 0x03
149#define L2CAP_CONF_RFC 0x04 175#define L2CAP_CONF_RFC 0x04
176#define L2CAP_CONF_FCS 0x05
150 177
151#define L2CAP_CONF_MAX_SIZE 22 178#define L2CAP_CONF_MAX_SIZE 22
152 179
@@ -162,6 +189,8 @@ struct l2cap_conf_rfc {
162#define L2CAP_MODE_BASIC 0x00 189#define L2CAP_MODE_BASIC 0x00
163#define L2CAP_MODE_RETRANS 0x01 190#define L2CAP_MODE_RETRANS 0x01
164#define L2CAP_MODE_FLOWCTL 0x02 191#define L2CAP_MODE_FLOWCTL 0x02
192#define L2CAP_MODE_ERTM 0x03
193#define L2CAP_MODE_STREAM 0x04
165 194
166struct l2cap_disconn_req { 195struct l2cap_disconn_req {
167 __le16 dcid; 196 __le16 dcid;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cd061510b6bd..406ad07cdea1 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -39,6 +39,7 @@
39#include <linux/skbuff.h> 39#include <linux/skbuff.h>
40#include <linux/interrupt.h> 40#include <linux/interrupt.h>
41#include <linux/notifier.h> 41#include <linux/notifier.h>
42#include <linux/rfkill.h>
42#include <net/sock.h> 43#include <net/sock.h>
43 44
44#include <asm/system.h> 45#include <asm/system.h>
@@ -476,6 +477,11 @@ int hci_dev_open(__u16 dev)
476 477
477 hci_req_lock(hdev); 478 hci_req_lock(hdev);
478 479
480 if (hdev->rfkill && rfkill_blocked(hdev->rfkill)) {
481 ret = -ERFKILL;
482 goto done;
483 }
484
479 if (test_bit(HCI_UP, &hdev->flags)) { 485 if (test_bit(HCI_UP, &hdev->flags)) {
480 ret = -EALREADY; 486 ret = -EALREADY;
481 goto done; 487 goto done;
@@ -813,6 +819,24 @@ int hci_get_dev_info(void __user *arg)
813 819
814/* ---- Interface to HCI drivers ---- */ 820/* ---- Interface to HCI drivers ---- */
815 821
822static int hci_rfkill_set_block(void *data, bool blocked)
823{
824 struct hci_dev *hdev = data;
825
826 BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked);
827
828 if (!blocked)
829 return 0;
830
831 hci_dev_do_close(hdev);
832
833 return 0;
834}
835
836static const struct rfkill_ops hci_rfkill_ops = {
837 .set_block = hci_rfkill_set_block,
838};
839
816/* Alloc HCI device */ 840/* Alloc HCI device */
817struct hci_dev *hci_alloc_dev(void) 841struct hci_dev *hci_alloc_dev(void)
818{ 842{
@@ -844,7 +868,8 @@ int hci_register_dev(struct hci_dev *hdev)
844 struct list_head *head = &hci_dev_list, *p; 868 struct list_head *head = &hci_dev_list, *p;
845 int i, id = 0; 869 int i, id = 0;
846 870
847 BT_DBG("%p name %s type %d owner %p", hdev, hdev->name, hdev->type, hdev->owner); 871 BT_DBG("%p name %s type %d owner %p", hdev, hdev->name,
872 hdev->type, hdev->owner);
848 873
849 if (!hdev->open || !hdev->close || !hdev->destruct) 874 if (!hdev->open || !hdev->close || !hdev->destruct)
850 return -EINVAL; 875 return -EINVAL;
@@ -900,6 +925,15 @@ int hci_register_dev(struct hci_dev *hdev)
900 925
901 hci_register_sysfs(hdev); 926 hci_register_sysfs(hdev);
902 927
928 hdev->rfkill = rfkill_alloc(hdev->name, &hdev->dev,
929 RFKILL_TYPE_BLUETOOTH, &hci_rfkill_ops, hdev);
930 if (hdev->rfkill) {
931 if (rfkill_register(hdev->rfkill) < 0) {
932 rfkill_destroy(hdev->rfkill);
933 hdev->rfkill = NULL;
934 }
935 }
936
903 hci_notify(hdev, HCI_DEV_REG); 937 hci_notify(hdev, HCI_DEV_REG);
904 938
905 return id; 939 return id;
@@ -924,6 +958,11 @@ int hci_unregister_dev(struct hci_dev *hdev)
924 958
925 hci_notify(hdev, HCI_DEV_UNREG); 959 hci_notify(hdev, HCI_DEV_UNREG);
926 960
961 if (hdev->rfkill) {
962 rfkill_unregister(hdev->rfkill);
963 rfkill_destroy(hdev->rfkill);
964 }
965
927 hci_unregister_sysfs(hdev); 966 hci_unregister_sysfs(hdev);
928 967
929 __hci_dev_put(hdev); 968 __hci_dev_put(hdev);
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index ca4d3b40d5ce..bd0a4c1bced0 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -40,10 +40,10 @@
40#include <linux/skbuff.h> 40#include <linux/skbuff.h>
41#include <linux/list.h> 41#include <linux/list.h>
42#include <linux/device.h> 42#include <linux/device.h>
43#include <linux/uaccess.h>
43#include <net/sock.h> 44#include <net/sock.h>
44 45
45#include <asm/system.h> 46#include <asm/system.h>
46#include <asm/uaccess.h>
47#include <asm/unaligned.h> 47#include <asm/unaligned.h>
48 48
49#include <net/bluetooth/bluetooth.h> 49#include <net/bluetooth/bluetooth.h>
@@ -52,7 +52,7 @@
52 52
53#define VERSION "2.13" 53#define VERSION "2.13"
54 54
55static u32 l2cap_feat_mask = 0x0080; 55static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN;
56static u8 l2cap_fixed_chan[8] = { 0x02, }; 56static u8 l2cap_fixed_chan[8] = { 0x02, };
57 57
58static const struct proto_ops l2cap_sock_ops; 58static const struct proto_ops l2cap_sock_ops;
@@ -134,7 +134,8 @@ static inline struct sock *l2cap_get_chan_by_scid(struct l2cap_chan_list *l, u16
134 struct sock *s; 134 struct sock *s;
135 read_lock(&l->lock); 135 read_lock(&l->lock);
136 s = __l2cap_get_chan_by_scid(l, cid); 136 s = __l2cap_get_chan_by_scid(l, cid);
137 if (s) bh_lock_sock(s); 137 if (s)
138 bh_lock_sock(s);
138 read_unlock(&l->lock); 139 read_unlock(&l->lock);
139 return s; 140 return s;
140} 141}
@@ -154,17 +155,18 @@ static inline struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8
154 struct sock *s; 155 struct sock *s;
155 read_lock(&l->lock); 156 read_lock(&l->lock);
156 s = __l2cap_get_chan_by_ident(l, ident); 157 s = __l2cap_get_chan_by_ident(l, ident);
157 if (s) bh_lock_sock(s); 158 if (s)
159 bh_lock_sock(s);
158 read_unlock(&l->lock); 160 read_unlock(&l->lock);
159 return s; 161 return s;
160} 162}
161 163
162static u16 l2cap_alloc_cid(struct l2cap_chan_list *l) 164static u16 l2cap_alloc_cid(struct l2cap_chan_list *l)
163{ 165{
164 u16 cid = 0x0040; 166 u16 cid = L2CAP_CID_DYN_START;
165 167
166 for (; cid < 0xffff; cid++) { 168 for (; cid < L2CAP_CID_DYN_END; cid++) {
167 if(!__l2cap_get_chan_by_scid(l, cid)) 169 if (!__l2cap_get_chan_by_scid(l, cid))
168 return cid; 170 return cid;
169 } 171 }
170 172
@@ -204,7 +206,8 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so
204{ 206{
205 struct l2cap_chan_list *l = &conn->chan_list; 207 struct l2cap_chan_list *l = &conn->chan_list;
206 208
207 BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn, l2cap_pi(sk)->psm, l2cap_pi(sk)->dcid); 209 BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn,
210 l2cap_pi(sk)->psm, l2cap_pi(sk)->dcid);
208 211
209 conn->disc_reason = 0x13; 212 conn->disc_reason = 0x13;
210 213
@@ -215,13 +218,13 @@ static void __l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, struct so
215 l2cap_pi(sk)->scid = l2cap_alloc_cid(l); 218 l2cap_pi(sk)->scid = l2cap_alloc_cid(l);
216 } else if (sk->sk_type == SOCK_DGRAM) { 219 } else if (sk->sk_type == SOCK_DGRAM) {
217 /* Connectionless socket */ 220 /* Connectionless socket */
218 l2cap_pi(sk)->scid = 0x0002; 221 l2cap_pi(sk)->scid = L2CAP_CID_CONN_LESS;
219 l2cap_pi(sk)->dcid = 0x0002; 222 l2cap_pi(sk)->dcid = L2CAP_CID_CONN_LESS;
220 l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU; 223 l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU;
221 } else { 224 } else {
222 /* Raw socket can send/recv signalling messages only */ 225 /* Raw socket can send/recv signalling messages only */
223 l2cap_pi(sk)->scid = 0x0001; 226 l2cap_pi(sk)->scid = L2CAP_CID_SIGNALING;
224 l2cap_pi(sk)->dcid = 0x0001; 227 l2cap_pi(sk)->dcid = L2CAP_CID_SIGNALING;
225 l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU; 228 l2cap_pi(sk)->omtu = L2CAP_DEFAULT_MTU;
226 } 229 }
227 230
@@ -272,7 +275,7 @@ static inline int l2cap_check_security(struct sock *sk)
272 if (l2cap_pi(sk)->sec_level == BT_SECURITY_HIGH) 275 if (l2cap_pi(sk)->sec_level == BT_SECURITY_HIGH)
273 auth_type = HCI_AT_NO_BONDING_MITM; 276 auth_type = HCI_AT_NO_BONDING_MITM;
274 else 277 else
275 auth_type = HCI_AT_NO_BONDING; 278 auth_type = HCI_AT_NO_BONDING;
276 279
277 if (l2cap_pi(sk)->sec_level == BT_SECURITY_LOW) 280 if (l2cap_pi(sk)->sec_level == BT_SECURITY_LOW)
278 l2cap_pi(sk)->sec_level = BT_SECURITY_SDP; 281 l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
@@ -588,7 +591,8 @@ static inline struct sock *l2cap_get_sock_by_psm(int state, __le16 psm, bdaddr_t
588 struct sock *s; 591 struct sock *s;
589 read_lock(&l2cap_sk_list.lock); 592 read_lock(&l2cap_sk_list.lock);
590 s = __l2cap_get_sock_by_psm(state, psm, src); 593 s = __l2cap_get_sock_by_psm(state, psm, src);
591 if (s) bh_lock_sock(s); 594 if (s)
595 bh_lock_sock(s);
592 read_unlock(&l2cap_sk_list.lock); 596 read_unlock(&l2cap_sk_list.lock);
593 return s; 597 return s;
594} 598}
@@ -808,7 +812,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
808 goto done; 812 goto done;
809 } 813 }
810 814
811 if (la.l2_psm && btohs(la.l2_psm) < 0x1001 && 815 if (la.l2_psm && __le16_to_cpu(la.l2_psm) < 0x1001 &&
812 !capable(CAP_NET_BIND_SERVICE)) { 816 !capable(CAP_NET_BIND_SERVICE)) {
813 err = -EACCES; 817 err = -EACCES;
814 goto done; 818 goto done;
@@ -825,7 +829,8 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
825 l2cap_pi(sk)->sport = la.l2_psm; 829 l2cap_pi(sk)->sport = la.l2_psm;
826 sk->sk_state = BT_BOUND; 830 sk->sk_state = BT_BOUND;
827 831
828 if (btohs(la.l2_psm) == 0x0001 || btohs(la.l2_psm) == 0x0003) 832 if (__le16_to_cpu(la.l2_psm) == 0x0001 ||
833 __le16_to_cpu(la.l2_psm) == 0x0003)
829 l2cap_pi(sk)->sec_level = BT_SECURITY_SDP; 834 l2cap_pi(sk)->sec_level = BT_SECURITY_SDP;
830 } 835 }
831 836
@@ -844,12 +849,13 @@ static int l2cap_do_connect(struct sock *sk)
844 struct hci_conn *hcon; 849 struct hci_conn *hcon;
845 struct hci_dev *hdev; 850 struct hci_dev *hdev;
846 __u8 auth_type; 851 __u8 auth_type;
847 int err = 0; 852 int err;
848 853
849 BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst), 854 BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst),
850 l2cap_pi(sk)->psm); 855 l2cap_pi(sk)->psm);
851 856
852 if (!(hdev = hci_get_route(dst, src))) 857 hdev = hci_get_route(dst, src);
858 if (!hdev)
853 return -EHOSTUNREACH; 859 return -EHOSTUNREACH;
854 860
855 hci_dev_lock_bh(hdev); 861 hci_dev_lock_bh(hdev);
@@ -950,7 +956,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
950 goto done; 956 goto done;
951 } 957 }
952 958
953 switch(sk->sk_state) { 959 switch (sk->sk_state) {
954 case BT_CONNECT: 960 case BT_CONNECT:
955 case BT_CONNECT2: 961 case BT_CONNECT2:
956 case BT_CONFIG: 962 case BT_CONFIG:
@@ -975,7 +981,8 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
975 bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr); 981 bacpy(&bt_sk(sk)->dst, &la.l2_bdaddr);
976 l2cap_pi(sk)->psm = la.l2_psm; 982 l2cap_pi(sk)->psm = la.l2_psm;
977 983
978 if ((err = l2cap_do_connect(sk))) 984 err = l2cap_do_connect(sk);
985 if (err)
979 goto done; 986 goto done;
980 987
981wait: 988wait:
@@ -1009,9 +1016,9 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
1009 write_lock_bh(&l2cap_sk_list.lock); 1016 write_lock_bh(&l2cap_sk_list.lock);
1010 1017
1011 for (psm = 0x1001; psm < 0x1100; psm += 2) 1018 for (psm = 0x1001; psm < 0x1100; psm += 2)
1012 if (!__l2cap_get_sock_by_addr(htobs(psm), src)) { 1019 if (!__l2cap_get_sock_by_addr(cpu_to_le16(psm), src)) {
1013 l2cap_pi(sk)->psm = htobs(psm); 1020 l2cap_pi(sk)->psm = cpu_to_le16(psm);
1014 l2cap_pi(sk)->sport = htobs(psm); 1021 l2cap_pi(sk)->sport = cpu_to_le16(psm);
1015 err = 0; 1022 err = 0;
1016 break; 1023 break;
1017 } 1024 }
@@ -1100,11 +1107,11 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
1100 if (peer) { 1107 if (peer) {
1101 la->l2_psm = l2cap_pi(sk)->psm; 1108 la->l2_psm = l2cap_pi(sk)->psm;
1102 bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst); 1109 bacpy(&la->l2_bdaddr, &bt_sk(sk)->dst);
1103 la->l2_cid = htobs(l2cap_pi(sk)->dcid); 1110 la->l2_cid = cpu_to_le16(l2cap_pi(sk)->dcid);
1104 } else { 1111 } else {
1105 la->l2_psm = l2cap_pi(sk)->sport; 1112 la->l2_psm = l2cap_pi(sk)->sport;
1106 bacpy(&la->l2_bdaddr, &bt_sk(sk)->src); 1113 bacpy(&la->l2_bdaddr, &bt_sk(sk)->src);
1107 la->l2_cid = htobs(l2cap_pi(sk)->scid); 1114 la->l2_cid = cpu_to_le16(l2cap_pi(sk)->scid);
1108 } 1115 }
1109 1116
1110 return 0; 1117 return 0;
@@ -1114,7 +1121,7 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len)
1114{ 1121{
1115 struct l2cap_conn *conn = l2cap_pi(sk)->conn; 1122 struct l2cap_conn *conn = l2cap_pi(sk)->conn;
1116 struct sk_buff *skb, **frag; 1123 struct sk_buff *skb, **frag;
1117 int err, hlen, count, sent=0; 1124 int err, hlen, count, sent = 0;
1118 struct l2cap_hdr *lh; 1125 struct l2cap_hdr *lh;
1119 1126
1120 BT_DBG("sk %p len %d", sk, len); 1127 BT_DBG("sk %p len %d", sk, len);
@@ -1167,8 +1174,8 @@ static inline int l2cap_do_send(struct sock *sk, struct msghdr *msg, int len)
1167 1174
1168 frag = &(*frag)->next; 1175 frag = &(*frag)->next;
1169 } 1176 }
1170 1177 err = hci_send_acl(conn->hcon, skb, 0);
1171 if ((err = hci_send_acl(conn->hcon, skb, 0)) < 0) 1178 if (err < 0)
1172 goto fail; 1179 goto fail;
1173 1180
1174 return sent; 1181 return sent;
@@ -1556,7 +1563,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
1556{ 1563{
1557 struct l2cap_chan_list *l = &conn->chan_list; 1564 struct l2cap_chan_list *l = &conn->chan_list;
1558 struct sk_buff *nskb; 1565 struct sk_buff *nskb;
1559 struct sock * sk; 1566 struct sock *sk;
1560 1567
1561 BT_DBG("conn %p", conn); 1568 BT_DBG("conn %p", conn);
1562 1569
@@ -1568,8 +1575,8 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
1568 /* Don't send frame to the socket it came from */ 1575 /* Don't send frame to the socket it came from */
1569 if (skb->sk == sk) 1576 if (skb->sk == sk)
1570 continue; 1577 continue;
1571 1578 nskb = skb_clone(skb, GFP_ATOMIC);
1572 if (!(nskb = skb_clone(skb, GFP_ATOMIC))) 1579 if (!nskb)
1573 continue; 1580 continue;
1574 1581
1575 if (sock_queue_rcv_skb(sk, nskb)) 1582 if (sock_queue_rcv_skb(sk, nskb))
@@ -1587,7 +1594,8 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
1587 struct l2cap_hdr *lh; 1594 struct l2cap_hdr *lh;
1588 int len, count; 1595 int len, count;
1589 1596
1590 BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d", conn, code, ident, dlen); 1597 BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d",
1598 conn, code, ident, dlen);
1591 1599
1592 len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen; 1600 len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen;
1593 count = min_t(unsigned int, conn->mtu, len); 1601 count = min_t(unsigned int, conn->mtu, len);
@@ -1598,7 +1606,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
1598 1606
1599 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE); 1607 lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
1600 lh->len = cpu_to_le16(L2CAP_CMD_HDR_SIZE + dlen); 1608 lh->len = cpu_to_le16(L2CAP_CMD_HDR_SIZE + dlen);
1601 lh->cid = cpu_to_le16(0x0001); 1609 lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
1602 1610
1603 cmd = (struct l2cap_cmd_hdr *) skb_put(skb, L2CAP_CMD_HDR_SIZE); 1611 cmd = (struct l2cap_cmd_hdr *) skb_put(skb, L2CAP_CMD_HDR_SIZE);
1604 cmd->code = code; 1612 cmd->code = code;
@@ -1739,8 +1747,8 @@ static int l2cap_parse_conf_req(struct sock *sk, void *data)
1739 while (len >= L2CAP_CONF_OPT_SIZE) { 1747 while (len >= L2CAP_CONF_OPT_SIZE) {
1740 len -= l2cap_get_conf_opt(&req, &type, &olen, &val); 1748 len -= l2cap_get_conf_opt(&req, &type, &olen, &val);
1741 1749
1742 hint = type & 0x80; 1750 hint = type & L2CAP_CONF_HINT;
1743 type &= 0x7f; 1751 type &= L2CAP_CONF_MASK;
1744 1752
1745 switch (type) { 1753 switch (type) {
1746 case L2CAP_CONF_MTU: 1754 case L2CAP_CONF_MTU:
@@ -1966,10 +1974,12 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
1966 BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status); 1974 BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status);
1967 1975
1968 if (scid) { 1976 if (scid) {
1969 if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid))) 1977 sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
1978 if (!sk)
1970 return 0; 1979 return 0;
1971 } else { 1980 } else {
1972 if (!(sk = l2cap_get_chan_by_ident(&conn->chan_list, cmd->ident))) 1981 sk = l2cap_get_chan_by_ident(&conn->chan_list, cmd->ident);
1982 if (!sk)
1973 return 0; 1983 return 0;
1974 } 1984 }
1975 1985
@@ -2012,7 +2022,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2012 2022
2013 BT_DBG("dcid 0x%4.4x flags 0x%2.2x", dcid, flags); 2023 BT_DBG("dcid 0x%4.4x flags 0x%2.2x", dcid, flags);
2014 2024
2015 if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid))) 2025 sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid);
2026 if (!sk)
2016 return -ENOENT; 2027 return -ENOENT;
2017 2028
2018 if (sk->sk_state == BT_DISCONN) 2029 if (sk->sk_state == BT_DISCONN)
@@ -2079,9 +2090,11 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
2079 flags = __le16_to_cpu(rsp->flags); 2090 flags = __le16_to_cpu(rsp->flags);
2080 result = __le16_to_cpu(rsp->result); 2091 result = __le16_to_cpu(rsp->result);
2081 2092
2082 BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x", scid, flags, result); 2093 BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x",
2094 scid, flags, result);
2083 2095
2084 if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid))) 2096 sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
2097 if (!sk)
2085 return 0; 2098 return 0;
2086 2099
2087 switch (result) { 2100 switch (result) {
@@ -2142,7 +2155,8 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
2142 2155
2143 BT_DBG("scid 0x%4.4x dcid 0x%4.4x", scid, dcid); 2156 BT_DBG("scid 0x%4.4x dcid 0x%4.4x", scid, dcid);
2144 2157
2145 if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid))) 2158 sk = l2cap_get_chan_by_scid(&conn->chan_list, dcid);
2159 if (!sk)
2146 return 0; 2160 return 0;
2147 2161
2148 rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid); 2162 rsp.dcid = cpu_to_le16(l2cap_pi(sk)->scid);
@@ -2169,7 +2183,8 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
2169 2183
2170 BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid); 2184 BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid);
2171 2185
2172 if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid))) 2186 sk = l2cap_get_chan_by_scid(&conn->chan_list, scid);
2187 if (!sk)
2173 return 0; 2188 return 0;
2174 2189
2175 l2cap_chan_del(sk, 0); 2190 l2cap_chan_del(sk, 0);
@@ -2230,7 +2245,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
2230 if (type == L2CAP_IT_FEAT_MASK) { 2245 if (type == L2CAP_IT_FEAT_MASK) {
2231 conn->feat_mask = get_unaligned_le32(rsp->data); 2246 conn->feat_mask = get_unaligned_le32(rsp->data);
2232 2247
2233 if (conn->feat_mask & 0x0080) { 2248 if (conn->feat_mask & L2CAP_FEAT_FIXED_CHAN) {
2234 struct l2cap_info_req req; 2249 struct l2cap_info_req req;
2235 req.type = cpu_to_le16(L2CAP_IT_FIXED_CHAN); 2250 req.type = cpu_to_le16(L2CAP_IT_FIXED_CHAN);
2236 2251
@@ -2403,7 +2418,8 @@ drop:
2403 kfree_skb(skb); 2418 kfree_skb(skb);
2404 2419
2405done: 2420done:
2406 if (sk) bh_unlock_sock(sk); 2421 if (sk)
2422 bh_unlock_sock(sk);
2407 return 0; 2423 return 0;
2408} 2424}
2409 2425
@@ -2420,11 +2436,11 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
2420 BT_DBG("len %d, cid 0x%4.4x", len, cid); 2436 BT_DBG("len %d, cid 0x%4.4x", len, cid);
2421 2437
2422 switch (cid) { 2438 switch (cid) {
2423 case 0x0001: 2439 case L2CAP_CID_SIGNALING:
2424 l2cap_sig_channel(conn, skb); 2440 l2cap_sig_channel(conn, skb);
2425 break; 2441 break;
2426 2442
2427 case 0x0002: 2443 case L2CAP_CID_CONN_LESS:
2428 psm = get_unaligned((__le16 *) skb->data); 2444 psm = get_unaligned((__le16 *) skb->data);
2429 skb_pull(skb, 2); 2445 skb_pull(skb, 2);
2430 l2cap_conless_channel(conn, psm, skb); 2446 l2cap_conless_channel(conn, psm, skb);
@@ -2650,7 +2666,8 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
2650 } 2666 }
2651 2667
2652 /* Allocate skb for the complete frame (with header) */ 2668 /* Allocate skb for the complete frame (with header) */
2653 if (!(conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC))) 2669 conn->rx_skb = bt_skb_alloc(len, GFP_ATOMIC);
2670 if (!conn->rx_skb)
2654 goto drop; 2671 goto drop;
2655 2672
2656 skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len), 2673 skb_copy_from_linear_data(skb, skb_put(conn->rx_skb, skb->len),
@@ -2704,13 +2721,13 @@ static ssize_t l2cap_sysfs_show(struct class *dev, char *buf)
2704 2721
2705 str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n", 2722 str += sprintf(str, "%s %s %d %d 0x%4.4x 0x%4.4x %d %d %d\n",
2706 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst), 2723 batostr(&bt_sk(sk)->src), batostr(&bt_sk(sk)->dst),
2707 sk->sk_state, btohs(pi->psm), pi->scid, pi->dcid, 2724 sk->sk_state, __le16_to_cpu(pi->psm), pi->scid,
2708 pi->imtu, pi->omtu, pi->sec_level); 2725 pi->dcid, pi->imtu, pi->omtu, pi->sec_level);
2709 } 2726 }
2710 2727
2711 read_unlock_bh(&l2cap_sk_list.lock); 2728 read_unlock_bh(&l2cap_sk_list.lock);
2712 2729
2713 return (str - buf); 2730 return str - buf;
2714} 2731}
2715 2732
2716static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL); 2733static CLASS_ATTR(l2cap, S_IRUGO, l2cap_sysfs_show, NULL);
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 374536e050aa..e50566ebf9f9 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -679,7 +679,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src, bdaddr_t *dst
679 679
680 bacpy(&addr.l2_bdaddr, dst); 680 bacpy(&addr.l2_bdaddr, dst);
681 addr.l2_family = AF_BLUETOOTH; 681 addr.l2_family = AF_BLUETOOTH;
682 addr.l2_psm = htobs(RFCOMM_PSM); 682 addr.l2_psm = cpu_to_le16(RFCOMM_PSM);
683 addr.l2_cid = 0; 683 addr.l2_cid = 0;
684 *err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK); 684 *err = kernel_connect(sock, (struct sockaddr *) &addr, sizeof(addr), O_NONBLOCK);
685 if (*err == 0 || *err == -EINPROGRESS) 685 if (*err == 0 || *err == -EINPROGRESS)
@@ -852,9 +852,9 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d
852 } 852 }
853 853
854 if (cr && channel_mtu >= 0) 854 if (cr && channel_mtu >= 0)
855 pn->mtu = htobs(channel_mtu); 855 pn->mtu = cpu_to_le16(channel_mtu);
856 else 856 else
857 pn->mtu = htobs(d->mtu); 857 pn->mtu = cpu_to_le16(d->mtu);
858 858
859 *ptr = __fcs(buf); ptr++; 859 *ptr = __fcs(buf); ptr++;
860 860
@@ -1056,7 +1056,7 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr)
1056 1056
1057 if (len > 127) { 1057 if (len > 127) {
1058 hdr = (void *) skb_push(skb, 4); 1058 hdr = (void *) skb_push(skb, 4);
1059 put_unaligned(htobs(__len16(len)), (__le16 *) &hdr->len); 1059 put_unaligned(cpu_to_le16(__len16(len)), (__le16 *) &hdr->len);
1060 } else { 1060 } else {
1061 hdr = (void *) skb_push(skb, 3); 1061 hdr = (void *) skb_push(skb, 3);
1062 hdr->len = __len8(len); 1062 hdr->len = __len8(len);
@@ -1289,7 +1289,7 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
1289 1289
1290 d->priority = pn->priority; 1290 d->priority = pn->priority;
1291 1291
1292 d->mtu = btohs(pn->mtu); 1292 d->mtu = __le16_to_cpu(pn->mtu);
1293 1293
1294 if (cr && d->mtu > s->mtu) 1294 if (cr && d->mtu > s->mtu)
1295 d->mtu = s->mtu; 1295 d->mtu = s->mtu;
@@ -1922,7 +1922,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
1922 /* Bind socket */ 1922 /* Bind socket */
1923 bacpy(&addr.l2_bdaddr, ba); 1923 bacpy(&addr.l2_bdaddr, ba);
1924 addr.l2_family = AF_BLUETOOTH; 1924 addr.l2_family = AF_BLUETOOTH;
1925 addr.l2_psm = htobs(RFCOMM_PSM); 1925 addr.l2_psm = cpu_to_le16(RFCOMM_PSM);
1926 addr.l2_cid = 0; 1926 addr.l2_cid = 0;
1927 err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr)); 1927 err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
1928 if (err < 0) { 1928 if (err < 0) {