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 #define pr_fmt(fmt) "Bluetooth: " fmt
29 #include <linux/export.h>
31 #include <net/bluetooth/bluetooth.h>
34 * baswap() - Swaps the order of a bd address
35 * @dst: Pointer to a bdaddr_t struct that will store the swapped
37 * @src: Pointer to the bdaddr_t struct to be swapped.
39 * This function reverses the byte order of a Bluetooth device
42 void baswap(bdaddr_t
*dst
, const bdaddr_t
*src
)
44 const unsigned char *s
= (const unsigned char *)src
;
45 unsigned char *d
= (unsigned char *)dst
;
48 for (i
= 0; i
< 6; i
++)
51 EXPORT_SYMBOL(baswap
);
54 * bt_to_errno() - Bluetooth error codes to standard errno
55 * @code: Bluetooth error code to be converted
57 * This function takes a Bluetooth error code as input and convets
58 * it to an equivalent Unix/standard errno value.
62 * If the bt error code is known, an equivalent Unix errno value
64 * If the given bt error code is not known, ENOSYS is returned.
66 int bt_to_errno(__u16 code
)
141 return EPROTONOSUPPORT
;
157 EXPORT_SYMBOL(bt_to_errno
);
160 * bt_status() - Standard errno value to Bluetooth error code
161 * @err: Unix/standard errno value to be converted
163 * This function converts a standard/Unix errno value to an
164 * equivalent Bluetooth error code.
166 * Return: Bluetooth error code.
168 * If the given errno is not found, 0x1f is returned by default
169 * which indicates an unspecified error.
170 * For err >= 0, no conversion is performed, and the same value
171 * is immediately returned.
173 __u8
bt_status(int err
)
230 case -EPROTONOSUPPORT
:
240 EXPORT_SYMBOL(bt_status
);
243 * bt_info() - Log Bluetooth information message
244 * @format: Message's format string
246 void bt_info(const char *format
, ...)
248 struct va_format vaf
;
251 va_start(args
, format
);
256 pr_info("%pV", &vaf
);
260 EXPORT_SYMBOL(bt_info
);
263 * bt_warn() - Log Bluetooth warning message
264 * @format: Message's format string
266 void bt_warn(const char *format
, ...)
268 struct va_format vaf
;
271 va_start(args
, format
);
276 pr_warn("%pV", &vaf
);
280 EXPORT_SYMBOL(bt_warn
);
283 * bt_err() - Log Bluetooth error message
284 * @format: Message's format string
286 void bt_err(const char *format
, ...)
288 struct va_format vaf
;
291 va_start(args
, format
);
300 EXPORT_SYMBOL(bt_err
);
302 #ifdef CONFIG_BT_FEATURE_DEBUG
303 static bool debug_enable
;
305 void bt_dbg_set(bool enable
)
307 debug_enable
= enable
;
310 bool bt_dbg_get(void)
316 * bt_dbg() - Log Bluetooth debugging message
317 * @format: Message's format string
319 void bt_dbg(const char *format
, ...)
321 struct va_format vaf
;
324 if (likely(!debug_enable
))
327 va_start(args
, format
);
332 printk(KERN_DEBUG
pr_fmt("%pV"), &vaf
);
336 EXPORT_SYMBOL(bt_dbg
);
340 * bt_warn_ratelimited() - Log rate-limited Bluetooth warning message
341 * @format: Message's format string
343 * This functions works like bt_warn, but it uses rate limiting
344 * to prevent the message from being logged too often.
346 void bt_warn_ratelimited(const char *format
, ...)
348 struct va_format vaf
;
351 va_start(args
, format
);
356 pr_warn_ratelimited("%pV", &vaf
);
360 EXPORT_SYMBOL(bt_warn_ratelimited
);
363 * bt_err_ratelimited() - Log rate-limited Bluetooth error message
364 * @format: Message's format string
366 * This functions works like bt_err, but it uses rate limiting
367 * to prevent the message from being logged too often.
369 void bt_err_ratelimited(const char *format
, ...)
371 struct va_format vaf
;
374 va_start(args
, format
);
379 pr_err_ratelimited("%pV", &vaf
);
383 EXPORT_SYMBOL(bt_err_ratelimited
);