ARM: 7409/1: Do not call flush_cache_user_range with mmap_sem held
[linux/fpc-iii.git] / net / bluetooth / lib.c
blobb826d1bf10df5ce53f9674a061a65e940af73913
1 /*
2 BlueZ - Bluetooth protocol stack for Linux
3 Copyright (C) 2000-2001 Qualcomm Incorporated
5 Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com>
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
9 published by the Free Software Foundation;
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,
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
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
17 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS,
21 COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS
22 SOFTWARE IS DISCLAIMED.
25 /* Bluetooth kernel library. */
27 #include <linux/module.h>
29 #include <linux/kernel.h>
30 #include <linux/stddef.h>
31 #include <linux/string.h>
32 #include <asm/errno.h>
34 #include <net/bluetooth/bluetooth.h>
36 void baswap(bdaddr_t *dst, bdaddr_t *src)
38 unsigned char *d = (unsigned char *) dst;
39 unsigned char *s = (unsigned char *) src;
40 unsigned int i;
42 for (i = 0; i < 6; i++)
43 d[i] = s[5 - i];
45 EXPORT_SYMBOL(baswap);
47 char *batostr(bdaddr_t *ba)
49 static char str[2][18];
50 static int i = 1;
52 i ^= 1;
53 sprintf(str[i], "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
54 ba->b[5], ba->b[4], ba->b[3],
55 ba->b[2], ba->b[1], ba->b[0]);
57 return str[i];
59 EXPORT_SYMBOL(batostr);
61 /* Bluetooth error codes to Unix errno mapping */
62 int bt_err(__u16 code)
64 switch (code) {
65 case 0:
66 return 0;
68 case 0x01:
69 return EBADRQC;
71 case 0x02:
72 return ENOTCONN;
74 case 0x03:
75 return EIO;
77 case 0x04:
78 return EHOSTDOWN;
80 case 0x05:
81 return EACCES;
83 case 0x06:
84 return EBADE;
86 case 0x07:
87 return ENOMEM;
89 case 0x08:
90 return ETIMEDOUT;
92 case 0x09:
93 return EMLINK;
95 case 0x0a:
96 return EMLINK;
98 case 0x0b:
99 return EALREADY;
101 case 0x0c:
102 return EBUSY;
104 case 0x0d:
105 case 0x0e:
106 case 0x0f:
107 return ECONNREFUSED;
109 case 0x10:
110 return ETIMEDOUT;
112 case 0x11:
113 case 0x27:
114 case 0x29:
115 case 0x20:
116 return EOPNOTSUPP;
118 case 0x12:
119 return EINVAL;
121 case 0x13:
122 case 0x14:
123 case 0x15:
124 return ECONNRESET;
126 case 0x16:
127 return ECONNABORTED;
129 case 0x17:
130 return ELOOP;
132 case 0x18:
133 return EACCES;
135 case 0x1a:
136 return EPROTONOSUPPORT;
138 case 0x1b:
139 return ECONNREFUSED;
141 case 0x19:
142 case 0x1e:
143 case 0x23:
144 case 0x24:
145 case 0x25:
146 return EPROTO;
148 default:
149 return ENOSYS;
152 EXPORT_SYMBOL(bt_err);