Commit d945df256a7b2446227fafae2f89db85597412ef

Authored by Andrei Emeltchenko
Committed by Gustavo Padovan
1 parent 7028a8860f

bluetooth: Remove unneeded batostr function

batostr is not needed anymore since for printing Bluetooth
addresses we use %pMR specifier.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

Showing 2 changed files with 0 additions and 15 deletions Inline Diff

include/net/bluetooth/bluetooth.h
1 /* 1 /*
2 BlueZ - Bluetooth protocol stack for Linux 2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated 3 Copyright (C) 2000-2001 Qualcomm Incorporated
4 4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as 8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation; 9 published by the Free Software Foundation;
10 10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED. 22 SOFTWARE IS DISCLAIMED.
23 */ 23 */
24 24
25 #ifndef __BLUETOOTH_H 25 #ifndef __BLUETOOTH_H
26 #define __BLUETOOTH_H 26 #define __BLUETOOTH_H
27 27
28 #include <linux/poll.h> 28 #include <linux/poll.h>
29 #include <net/sock.h> 29 #include <net/sock.h>
30 #include <linux/seq_file.h> 30 #include <linux/seq_file.h>
31 31
32 #ifndef AF_BLUETOOTH 32 #ifndef AF_BLUETOOTH
33 #define AF_BLUETOOTH 31 33 #define AF_BLUETOOTH 31
34 #define PF_BLUETOOTH AF_BLUETOOTH 34 #define PF_BLUETOOTH AF_BLUETOOTH
35 #endif 35 #endif
36 36
37 /* Bluetooth versions */ 37 /* Bluetooth versions */
38 #define BLUETOOTH_VER_1_1 1 38 #define BLUETOOTH_VER_1_1 1
39 #define BLUETOOTH_VER_1_2 2 39 #define BLUETOOTH_VER_1_2 2
40 #define BLUETOOTH_VER_2_0 3 40 #define BLUETOOTH_VER_2_0 3
41 41
42 /* Reserv for core and drivers use */ 42 /* Reserv for core and drivers use */
43 #define BT_SKB_RESERVE 8 43 #define BT_SKB_RESERVE 8
44 44
45 #define BTPROTO_L2CAP 0 45 #define BTPROTO_L2CAP 0
46 #define BTPROTO_HCI 1 46 #define BTPROTO_HCI 1
47 #define BTPROTO_SCO 2 47 #define BTPROTO_SCO 2
48 #define BTPROTO_RFCOMM 3 48 #define BTPROTO_RFCOMM 3
49 #define BTPROTO_BNEP 4 49 #define BTPROTO_BNEP 4
50 #define BTPROTO_CMTP 5 50 #define BTPROTO_CMTP 5
51 #define BTPROTO_HIDP 6 51 #define BTPROTO_HIDP 6
52 #define BTPROTO_AVDTP 7 52 #define BTPROTO_AVDTP 7
53 53
54 #define SOL_HCI 0 54 #define SOL_HCI 0
55 #define SOL_L2CAP 6 55 #define SOL_L2CAP 6
56 #define SOL_SCO 17 56 #define SOL_SCO 17
57 #define SOL_RFCOMM 18 57 #define SOL_RFCOMM 18
58 58
59 #define BT_SECURITY 4 59 #define BT_SECURITY 4
60 struct bt_security { 60 struct bt_security {
61 __u8 level; 61 __u8 level;
62 __u8 key_size; 62 __u8 key_size;
63 }; 63 };
64 #define BT_SECURITY_SDP 0 64 #define BT_SECURITY_SDP 0
65 #define BT_SECURITY_LOW 1 65 #define BT_SECURITY_LOW 1
66 #define BT_SECURITY_MEDIUM 2 66 #define BT_SECURITY_MEDIUM 2
67 #define BT_SECURITY_HIGH 3 67 #define BT_SECURITY_HIGH 3
68 68
69 #define BT_DEFER_SETUP 7 69 #define BT_DEFER_SETUP 7
70 70
71 #define BT_FLUSHABLE 8 71 #define BT_FLUSHABLE 8
72 72
73 #define BT_FLUSHABLE_OFF 0 73 #define BT_FLUSHABLE_OFF 0
74 #define BT_FLUSHABLE_ON 1 74 #define BT_FLUSHABLE_ON 1
75 75
76 #define BT_POWER 9 76 #define BT_POWER 9
77 struct bt_power { 77 struct bt_power {
78 __u8 force_active; 78 __u8 force_active;
79 }; 79 };
80 #define BT_POWER_FORCE_ACTIVE_OFF 0 80 #define BT_POWER_FORCE_ACTIVE_OFF 0
81 #define BT_POWER_FORCE_ACTIVE_ON 1 81 #define BT_POWER_FORCE_ACTIVE_ON 1
82 82
83 #define BT_CHANNEL_POLICY 10 83 #define BT_CHANNEL_POLICY 10
84 84
85 /* BR/EDR only (default policy) 85 /* BR/EDR only (default policy)
86 * AMP controllers cannot be used. 86 * AMP controllers cannot be used.
87 * Channel move requests from the remote device are denied. 87 * Channel move requests from the remote device are denied.
88 * If the L2CAP channel is currently using AMP, move the channel to BR/EDR. 88 * If the L2CAP channel is currently using AMP, move the channel to BR/EDR.
89 */ 89 */
90 #define BT_CHANNEL_POLICY_BREDR_ONLY 0 90 #define BT_CHANNEL_POLICY_BREDR_ONLY 0
91 91
92 /* BR/EDR Preferred 92 /* BR/EDR Preferred
93 * Allow use of AMP controllers. 93 * Allow use of AMP controllers.
94 * If the L2CAP channel is currently on AMP, move it to BR/EDR. 94 * If the L2CAP channel is currently on AMP, move it to BR/EDR.
95 * Channel move requests from the remote device are allowed. 95 * Channel move requests from the remote device are allowed.
96 */ 96 */
97 #define BT_CHANNEL_POLICY_BREDR_PREFERRED 1 97 #define BT_CHANNEL_POLICY_BREDR_PREFERRED 1
98 98
99 /* AMP Preferred 99 /* AMP Preferred
100 * Allow use of AMP controllers 100 * Allow use of AMP controllers
101 * If the L2CAP channel is currently on BR/EDR and AMP controller 101 * If the L2CAP channel is currently on BR/EDR and AMP controller
102 * resources are available, initiate a channel move to AMP. 102 * resources are available, initiate a channel move to AMP.
103 * Channel move requests from the remote device are allowed. 103 * Channel move requests from the remote device are allowed.
104 * If the L2CAP socket has not been connected yet, try to create 104 * If the L2CAP socket has not been connected yet, try to create
105 * and configure the channel directly on an AMP controller rather 105 * and configure the channel directly on an AMP controller rather
106 * than BR/EDR. 106 * than BR/EDR.
107 */ 107 */
108 #define BT_CHANNEL_POLICY_AMP_PREFERRED 2 108 #define BT_CHANNEL_POLICY_AMP_PREFERRED 2
109 109
110 __printf(1, 2) 110 __printf(1, 2)
111 int bt_info(const char *fmt, ...); 111 int bt_info(const char *fmt, ...);
112 __printf(1, 2) 112 __printf(1, 2)
113 int bt_err(const char *fmt, ...); 113 int bt_err(const char *fmt, ...);
114 114
115 #define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__) 115 #define BT_INFO(fmt, ...) bt_info(fmt "\n", ##__VA_ARGS__)
116 #define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__) 116 #define BT_ERR(fmt, ...) bt_err(fmt "\n", ##__VA_ARGS__)
117 #define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__) 117 #define BT_DBG(fmt, ...) pr_debug(fmt "\n", ##__VA_ARGS__)
118 118
119 /* Connection and socket states */ 119 /* Connection and socket states */
120 enum { 120 enum {
121 BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */ 121 BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
122 BT_OPEN, 122 BT_OPEN,
123 BT_BOUND, 123 BT_BOUND,
124 BT_LISTEN, 124 BT_LISTEN,
125 BT_CONNECT, 125 BT_CONNECT,
126 BT_CONNECT2, 126 BT_CONNECT2,
127 BT_CONFIG, 127 BT_CONFIG,
128 BT_DISCONN, 128 BT_DISCONN,
129 BT_CLOSED 129 BT_CLOSED
130 }; 130 };
131 131
132 /* If unused will be removed by compiler */ 132 /* If unused will be removed by compiler */
133 static inline const char *state_to_string(int state) 133 static inline const char *state_to_string(int state)
134 { 134 {
135 switch (state) { 135 switch (state) {
136 case BT_CONNECTED: 136 case BT_CONNECTED:
137 return "BT_CONNECTED"; 137 return "BT_CONNECTED";
138 case BT_OPEN: 138 case BT_OPEN:
139 return "BT_OPEN"; 139 return "BT_OPEN";
140 case BT_BOUND: 140 case BT_BOUND:
141 return "BT_BOUND"; 141 return "BT_BOUND";
142 case BT_LISTEN: 142 case BT_LISTEN:
143 return "BT_LISTEN"; 143 return "BT_LISTEN";
144 case BT_CONNECT: 144 case BT_CONNECT:
145 return "BT_CONNECT"; 145 return "BT_CONNECT";
146 case BT_CONNECT2: 146 case BT_CONNECT2:
147 return "BT_CONNECT2"; 147 return "BT_CONNECT2";
148 case BT_CONFIG: 148 case BT_CONFIG:
149 return "BT_CONFIG"; 149 return "BT_CONFIG";
150 case BT_DISCONN: 150 case BT_DISCONN:
151 return "BT_DISCONN"; 151 return "BT_DISCONN";
152 case BT_CLOSED: 152 case BT_CLOSED:
153 return "BT_CLOSED"; 153 return "BT_CLOSED";
154 } 154 }
155 155
156 return "invalid state"; 156 return "invalid state";
157 } 157 }
158 158
159 /* BD Address */ 159 /* BD Address */
160 typedef struct { 160 typedef struct {
161 __u8 b[6]; 161 __u8 b[6];
162 } __packed bdaddr_t; 162 } __packed bdaddr_t;
163 163
164 /* BD Address type */ 164 /* BD Address type */
165 #define BDADDR_BREDR 0x00 165 #define BDADDR_BREDR 0x00
166 #define BDADDR_LE_PUBLIC 0x01 166 #define BDADDR_LE_PUBLIC 0x01
167 #define BDADDR_LE_RANDOM 0x02 167 #define BDADDR_LE_RANDOM 0x02
168 168
169 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} }) 169 #define BDADDR_ANY (&(bdaddr_t) {{0, 0, 0, 0, 0, 0} })
170 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} }) 170 #define BDADDR_LOCAL (&(bdaddr_t) {{0, 0, 0, 0xff, 0xff, 0xff} })
171 171
172 /* Copy, swap, convert BD Address */ 172 /* Copy, swap, convert BD Address */
173 static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2) 173 static inline int bacmp(bdaddr_t *ba1, bdaddr_t *ba2)
174 { 174 {
175 return memcmp(ba1, ba2, sizeof(bdaddr_t)); 175 return memcmp(ba1, ba2, sizeof(bdaddr_t));
176 } 176 }
177 static inline void bacpy(bdaddr_t *dst, bdaddr_t *src) 177 static inline void bacpy(bdaddr_t *dst, bdaddr_t *src)
178 { 178 {
179 memcpy(dst, src, sizeof(bdaddr_t)); 179 memcpy(dst, src, sizeof(bdaddr_t));
180 } 180 }
181 181
182 void baswap(bdaddr_t *dst, bdaddr_t *src); 182 void baswap(bdaddr_t *dst, bdaddr_t *src);
183 char *batostr(bdaddr_t *ba);
184 183
185 /* Common socket structures and functions */ 184 /* Common socket structures and functions */
186 185
187 #define bt_sk(__sk) ((struct bt_sock *) __sk) 186 #define bt_sk(__sk) ((struct bt_sock *) __sk)
188 187
189 struct bt_sock { 188 struct bt_sock {
190 struct sock sk; 189 struct sock sk;
191 bdaddr_t src; 190 bdaddr_t src;
192 bdaddr_t dst; 191 bdaddr_t dst;
193 struct list_head accept_q; 192 struct list_head accept_q;
194 struct sock *parent; 193 struct sock *parent;
195 unsigned long flags; 194 unsigned long flags;
196 }; 195 };
197 196
198 enum { 197 enum {
199 BT_SK_DEFER_SETUP, 198 BT_SK_DEFER_SETUP,
200 BT_SK_SUSPEND, 199 BT_SK_SUSPEND,
201 }; 200 };
202 201
203 struct bt_sock_list { 202 struct bt_sock_list {
204 struct hlist_head head; 203 struct hlist_head head;
205 rwlock_t lock; 204 rwlock_t lock;
206 #ifdef CONFIG_PROC_FS 205 #ifdef CONFIG_PROC_FS
207 struct file_operations fops; 206 struct file_operations fops;
208 int (* custom_seq_show)(struct seq_file *, void *); 207 int (* custom_seq_show)(struct seq_file *, void *);
209 #endif 208 #endif
210 }; 209 };
211 210
212 int bt_sock_register(int proto, const struct net_proto_family *ops); 211 int bt_sock_register(int proto, const struct net_proto_family *ops);
213 int bt_sock_unregister(int proto); 212 int bt_sock_unregister(int proto);
214 void bt_sock_link(struct bt_sock_list *l, struct sock *s); 213 void bt_sock_link(struct bt_sock_list *l, struct sock *s);
215 void bt_sock_unlink(struct bt_sock_list *l, struct sock *s); 214 void bt_sock_unlink(struct bt_sock_list *l, struct sock *s);
216 int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, 215 int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
217 struct msghdr *msg, size_t len, int flags); 216 struct msghdr *msg, size_t len, int flags);
218 int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock, 217 int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
219 struct msghdr *msg, size_t len, int flags); 218 struct msghdr *msg, size_t len, int flags);
220 uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait); 219 uint bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
221 int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg); 220 int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
222 int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo); 221 int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
223 222
224 void bt_accept_enqueue(struct sock *parent, struct sock *sk); 223 void bt_accept_enqueue(struct sock *parent, struct sock *sk);
225 void bt_accept_unlink(struct sock *sk); 224 void bt_accept_unlink(struct sock *sk);
226 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock); 225 struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock);
227 226
228 /* Skb helpers */ 227 /* Skb helpers */
229 struct l2cap_ctrl { 228 struct l2cap_ctrl {
230 unsigned int sframe:1, 229 unsigned int sframe:1,
231 poll:1, 230 poll:1,
232 final:1, 231 final:1,
233 fcs:1, 232 fcs:1,
234 sar:2, 233 sar:2,
235 super:2; 234 super:2;
236 __u16 reqseq; 235 __u16 reqseq;
237 __u16 txseq; 236 __u16 txseq;
238 __u8 retries; 237 __u8 retries;
239 }; 238 };
240 239
241 struct bt_skb_cb { 240 struct bt_skb_cb {
242 __u8 pkt_type; 241 __u8 pkt_type;
243 __u8 incoming; 242 __u8 incoming;
244 __u16 expect; 243 __u16 expect;
245 __u8 force_active; 244 __u8 force_active;
246 struct l2cap_ctrl control; 245 struct l2cap_ctrl control;
247 }; 246 };
248 #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) 247 #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb))
249 248
250 static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how) 249 static inline struct sk_buff *bt_skb_alloc(unsigned int len, gfp_t how)
251 { 250 {
252 struct sk_buff *skb; 251 struct sk_buff *skb;
253 252
254 skb = alloc_skb(len + BT_SKB_RESERVE, how); 253 skb = alloc_skb(len + BT_SKB_RESERVE, how);
255 if (skb) { 254 if (skb) {
256 skb_reserve(skb, BT_SKB_RESERVE); 255 skb_reserve(skb, BT_SKB_RESERVE);
257 bt_cb(skb)->incoming = 0; 256 bt_cb(skb)->incoming = 0;
258 } 257 }
259 return skb; 258 return skb;
260 } 259 }
261 260
262 static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk, 261 static inline struct sk_buff *bt_skb_send_alloc(struct sock *sk,
263 unsigned long len, int nb, int *err) 262 unsigned long len, int nb, int *err)
264 { 263 {
265 struct sk_buff *skb; 264 struct sk_buff *skb;
266 265
267 skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err); 266 skb = sock_alloc_send_skb(sk, len + BT_SKB_RESERVE, nb, err);
268 if (skb) { 267 if (skb) {
269 skb_reserve(skb, BT_SKB_RESERVE); 268 skb_reserve(skb, BT_SKB_RESERVE);
270 bt_cb(skb)->incoming = 0; 269 bt_cb(skb)->incoming = 0;
271 } 270 }
272 271
273 if (!skb && *err) 272 if (!skb && *err)
274 return NULL; 273 return NULL;
275 274
276 *err = sock_error(sk); 275 *err = sock_error(sk);
277 if (*err) 276 if (*err)
278 goto out; 277 goto out;
279 278
280 if (sk->sk_shutdown) { 279 if (sk->sk_shutdown) {
281 *err = -ECONNRESET; 280 *err = -ECONNRESET;
282 goto out; 281 goto out;
283 } 282 }
284 283
285 return skb; 284 return skb;
286 285
287 out: 286 out:
288 kfree_skb(skb); 287 kfree_skb(skb);
289 return NULL; 288 return NULL;
290 } 289 }
291 290
292 int bt_to_errno(__u16 code); 291 int bt_to_errno(__u16 code);
293 292
294 extern int hci_sock_init(void); 293 extern int hci_sock_init(void);
295 extern void hci_sock_cleanup(void); 294 extern void hci_sock_cleanup(void);
296 295
297 extern int bt_sysfs_init(void); 296 extern int bt_sysfs_init(void);
298 extern void bt_sysfs_cleanup(void); 297 extern void bt_sysfs_cleanup(void);
299 298
300 extern int bt_procfs_init(struct module* module, struct net *net, const char *name, 299 extern int bt_procfs_init(struct module* module, struct net *net, const char *name,
301 struct bt_sock_list* sk_list, 300 struct bt_sock_list* sk_list,
302 int (* seq_show)(struct seq_file *, void *)); 301 int (* seq_show)(struct seq_file *, void *));
303 extern void bt_procfs_cleanup(struct net *net, const char *name); 302 extern void bt_procfs_cleanup(struct net *net, const char *name);
304 303
305 extern struct dentry *bt_debugfs; 304 extern struct dentry *bt_debugfs;
306 305
307 int l2cap_init(void); 306 int l2cap_init(void);
308 void l2cap_exit(void); 307 void l2cap_exit(void);
309 308
310 int sco_init(void); 309 int sco_init(void);
311 void sco_exit(void); 310 void sco_exit(void);
312 311
313 void bt_sock_reclassify_lock(struct sock *sk, int proto); 312 void bt_sock_reclassify_lock(struct sock *sk, int proto);
314 313
315 #endif /* __BLUETOOTH_H */ 314 #endif /* __BLUETOOTH_H */
316 315
1 /* 1 /*
2 BlueZ - Bluetooth protocol stack for Linux 2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated 3 Copyright (C) 2000-2001 Qualcomm Incorporated
4 4
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> 5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License version 2 as 8 it under the terms of the GNU General Public License version 2 as
9 published by the Free Software Foundation; 9 published by the Free Software Foundation;
10 10
11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 11 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. 13 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY 14 IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY
15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES 15 CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 16 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 19
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, 20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS 21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED. 22 SOFTWARE IS DISCLAIMED.
23 */ 23 */
24 24
25 /* Bluetooth kernel library. */ 25 /* Bluetooth kernel library. */
26 26
27 #define pr_fmt(fmt) "Bluetooth: " fmt 27 #define pr_fmt(fmt) "Bluetooth: " fmt
28 28
29 #include <linux/export.h> 29 #include <linux/export.h>
30 30
31 #include <net/bluetooth/bluetooth.h> 31 #include <net/bluetooth/bluetooth.h>
32 32
33 void baswap(bdaddr_t *dst, bdaddr_t *src) 33 void baswap(bdaddr_t *dst, bdaddr_t *src)
34 { 34 {
35 unsigned char *d = (unsigned char *) dst; 35 unsigned char *d = (unsigned char *) dst;
36 unsigned char *s = (unsigned char *) src; 36 unsigned char *s = (unsigned char *) src;
37 unsigned int i; 37 unsigned int i;
38 38
39 for (i = 0; i < 6; i++) 39 for (i = 0; i < 6; i++)
40 d[i] = s[5 - i]; 40 d[i] = s[5 - i];
41 } 41 }
42 EXPORT_SYMBOL(baswap); 42 EXPORT_SYMBOL(baswap);
43 43
44 char *batostr(bdaddr_t *ba)
45 {
46 static char str[2][18];
47 static int i = 1;
48
49 i ^= 1;
50 sprintf(str[i], "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
51 ba->b[5], ba->b[4], ba->b[3],
52 ba->b[2], ba->b[1], ba->b[0]);
53
54 return str[i];
55 }
56 EXPORT_SYMBOL(batostr);
57
58 /* Bluetooth error codes to Unix errno mapping */ 44 /* Bluetooth error codes to Unix errno mapping */
59 int bt_to_errno(__u16 code) 45 int bt_to_errno(__u16 code)
60 { 46 {
61 switch (code) { 47 switch (code) {
62 case 0: 48 case 0:
63 return 0; 49 return 0;
64 50
65 case 0x01: 51 case 0x01:
66 return EBADRQC; 52 return EBADRQC;
67 53
68 case 0x02: 54 case 0x02:
69 return ENOTCONN; 55 return ENOTCONN;
70 56
71 case 0x03: 57 case 0x03:
72 return EIO; 58 return EIO;
73 59
74 case 0x04: 60 case 0x04:
75 return EHOSTDOWN; 61 return EHOSTDOWN;
76 62
77 case 0x05: 63 case 0x05:
78 return EACCES; 64 return EACCES;
79 65
80 case 0x06: 66 case 0x06:
81 return EBADE; 67 return EBADE;
82 68
83 case 0x07: 69 case 0x07:
84 return ENOMEM; 70 return ENOMEM;
85 71
86 case 0x08: 72 case 0x08:
87 return ETIMEDOUT; 73 return ETIMEDOUT;
88 74
89 case 0x09: 75 case 0x09:
90 return EMLINK; 76 return EMLINK;
91 77
92 case 0x0a: 78 case 0x0a:
93 return EMLINK; 79 return EMLINK;
94 80
95 case 0x0b: 81 case 0x0b:
96 return EALREADY; 82 return EALREADY;
97 83
98 case 0x0c: 84 case 0x0c:
99 return EBUSY; 85 return EBUSY;
100 86
101 case 0x0d: 87 case 0x0d:
102 case 0x0e: 88 case 0x0e:
103 case 0x0f: 89 case 0x0f:
104 return ECONNREFUSED; 90 return ECONNREFUSED;
105 91
106 case 0x10: 92 case 0x10:
107 return ETIMEDOUT; 93 return ETIMEDOUT;
108 94
109 case 0x11: 95 case 0x11:
110 case 0x27: 96 case 0x27:
111 case 0x29: 97 case 0x29:
112 case 0x20: 98 case 0x20:
113 return EOPNOTSUPP; 99 return EOPNOTSUPP;
114 100
115 case 0x12: 101 case 0x12:
116 return EINVAL; 102 return EINVAL;
117 103
118 case 0x13: 104 case 0x13:
119 case 0x14: 105 case 0x14:
120 case 0x15: 106 case 0x15:
121 return ECONNRESET; 107 return ECONNRESET;
122 108
123 case 0x16: 109 case 0x16:
124 return ECONNABORTED; 110 return ECONNABORTED;
125 111
126 case 0x17: 112 case 0x17:
127 return ELOOP; 113 return ELOOP;
128 114
129 case 0x18: 115 case 0x18:
130 return EACCES; 116 return EACCES;
131 117
132 case 0x1a: 118 case 0x1a:
133 return EPROTONOSUPPORT; 119 return EPROTONOSUPPORT;
134 120
135 case 0x1b: 121 case 0x1b:
136 return ECONNREFUSED; 122 return ECONNREFUSED;
137 123
138 case 0x19: 124 case 0x19:
139 case 0x1e: 125 case 0x1e:
140 case 0x23: 126 case 0x23:
141 case 0x24: 127 case 0x24:
142 case 0x25: 128 case 0x25:
143 return EPROTO; 129 return EPROTO;
144 130
145 default: 131 default:
146 return ENOSYS; 132 return ENOSYS;
147 } 133 }
148 } 134 }
149 EXPORT_SYMBOL(bt_to_errno); 135 EXPORT_SYMBOL(bt_to_errno);
150 136
151 int bt_info(const char *format, ...) 137 int bt_info(const char *format, ...)
152 { 138 {
153 struct va_format vaf; 139 struct va_format vaf;
154 va_list args; 140 va_list args;
155 int r; 141 int r;
156 142
157 va_start(args, format); 143 va_start(args, format);
158 144
159 vaf.fmt = format; 145 vaf.fmt = format;
160 vaf.va = &args; 146 vaf.va = &args;
161 147
162 r = pr_info("%pV", &vaf); 148 r = pr_info("%pV", &vaf);
163 149
164 va_end(args); 150 va_end(args);
165 151
166 return r; 152 return r;
167 } 153 }
168 EXPORT_SYMBOL(bt_info); 154 EXPORT_SYMBOL(bt_info);
169 155
170 int bt_err(const char *format, ...) 156 int bt_err(const char *format, ...)
171 { 157 {
172 struct va_format vaf; 158 struct va_format vaf;
173 va_list args; 159 va_list args;
174 int r; 160 int r;
175 161
176 va_start(args, format); 162 va_start(args, format);
177 163
178 vaf.fmt = format; 164 vaf.fmt = format;
179 vaf.va = &args; 165 vaf.va = &args;
180 166
181 r = pr_err("%pV", &vaf); 167 r = pr_err("%pV", &vaf);
182 168
183 va_end(args); 169 va_end(args);
184 170
185 return r; 171 return r;
186 } 172 }
187 EXPORT_SYMBOL(bt_err); 173 EXPORT_SYMBOL(bt_err);
188 174