All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/6] NFC subsystem
@ 2011-06-28 18:20 Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 1/6] NFC: add nfc subsystem core Aloisio Almeida Jr
                   ` (5 more replies)
  0 siblings, 6 replies; 38+ messages in thread
From: Aloisio Almeida Jr @ 2011-06-28 18:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, sameo, johannes, lauro.venancio, marcio.macedo,
	Waldemar.Rymarkiewicz, padovan, rdunlap, Aloisio Almeida Jr

This version includes the following changes:

 1. NFC_ERR(), NFC_INFO() and NFC_DBG() were created for message output in the
    subsystem. Device drivers still have to use dev_*() functions;
 2. Now using dynamic debug, NFC_DEBUG config was removed;
 3. core.c: nfc_targets_found(): kzmalloc()/memcpy() changed to kmemdup();
 4. An eventual error on sending NFC_EVENT_DEVICE_ADDED and
    NFC_EVENT_DEVICE_REMOVED messages will be ignored;
 5. Added the attribute 'packed' to initiator_data structs in pn533 driver. It
    fixes the felica polling loop;
 6. Fixes in the Documentation/networking/nfc.txt.

As Johannes Berg's patch (netlink: advertise incomplete dumps) is already on
wireless-next tree, I removed the tag 'RFC' from this patch series.

Aloisio Almeida Jr (3):
  NFC: add NFC socket family
  NFC: pn533: add NXP pn533 nfc device driver
  NFC: add Documentation/networking/nfc.txt

Lauro Ramos Venancio (3):
  NFC: add nfc subsystem core
  NFC: add nfc generic netlink interface
  NFC: add the NFC socket raw protocol

 Documentation/networking/nfc.txt |  128 +++
 drivers/Kconfig                  |    2 -
 drivers/Makefile                 |    1 +
 drivers/nfc/Kconfig              |   24 +-
 drivers/nfc/Makefile             |    3 +
 drivers/nfc/pn533.c              | 1630 ++++++++++++++++++++++++++++++++++++++
 include/linux/nfc.h              |  126 +++
 include/linux/socket.h           |    4 +-
 include/net/nfc.h                |  152 ++++
 net/Kconfig                      |    1 +
 net/Makefile                     |    1 +
 net/core/sock.c                  |    6 +-
 net/nfc/Kconfig                  |   16 +
 net/nfc/Makefile                 |    7 +
 net/nfc/af_nfc.c                 |   98 +++
 net/nfc/core.c                   |  445 +++++++++++
 net/nfc/netlink.c                |  537 +++++++++++++
 net/nfc/nfc.h                    |  114 +++
 net/nfc/rawsock.c                |  351 ++++++++
 19 files changed, 3628 insertions(+), 18 deletions(-)
 create mode 100644 Documentation/networking/nfc.txt
 create mode 100644 drivers/nfc/pn533.c
 create mode 100644 include/linux/nfc.h
 create mode 100644 include/net/nfc.h
 create mode 100644 net/nfc/Kconfig
 create mode 100644 net/nfc/Makefile
 create mode 100644 net/nfc/af_nfc.c
 create mode 100644 net/nfc/core.c
 create mode 100644 net/nfc/netlink.c
 create mode 100644 net/nfc/nfc.h
 create mode 100644 net/nfc/rawsock.c

-- 
1.7.5.4


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-28 18:20 [PATCH v4 0/6] NFC subsystem Aloisio Almeida Jr
@ 2011-06-28 18:20 ` Aloisio Almeida Jr
  2011-06-28 20:18   ` Joe Perches
  2011-06-28 18:20 ` [PATCH v4 2/6] NFC: add nfc generic netlink interface Aloisio Almeida Jr
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 38+ messages in thread
From: Aloisio Almeida Jr @ 2011-06-28 18:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, sameo, johannes, lauro.venancio, marcio.macedo,
	Waldemar.Rymarkiewicz, padovan, rdunlap, Aloisio Almeida Jr

From: Lauro Ramos Venancio <lauro.venancio@openbossa.org>

The NFC subsystem core is responsible for providing the device driver
interface. It is also responsible for providing an interface to the control
operations and data exchange.

Signed-off-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Signed-off-by: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/Kconfig      |    2 -
 drivers/Makefile     |    1 +
 drivers/nfc/Kconfig  |   16 +--
 drivers/nfc/Makefile |    2 +
 include/net/nfc.h    |  131 +++++++++++++++++++
 net/Kconfig          |    1 +
 net/Makefile         |    1 +
 net/nfc/Kconfig      |   16 +++
 net/nfc/Makefile     |    7 +
 net/nfc/core.c       |  344 ++++++++++++++++++++++++++++++++++++++++++++++++++
 net/nfc/nfc.h        |   75 +++++++++++
 11 files changed, 581 insertions(+), 15 deletions(-)
 create mode 100644 include/net/nfc.h
 create mode 100644 net/nfc/Kconfig
 create mode 100644 net/nfc/Makefile
 create mode 100644 net/nfc/core.c
 create mode 100644 net/nfc/nfc.h

diff --git a/drivers/Kconfig b/drivers/Kconfig
index 61631ed..a56b0b8 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -92,8 +92,6 @@ source "drivers/memstick/Kconfig"
 
 source "drivers/leds/Kconfig"
 
-source "drivers/nfc/Kconfig"
-
 source "drivers/accessibility/Kconfig"
 
 source "drivers/infiniband/Kconfig"
diff --git a/drivers/Makefile b/drivers/Makefile
index a29527f..843cd31 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -120,3 +120,4 @@ obj-y				+= ieee802154/
 obj-y				+= clk/
 
 obj-$(CONFIG_HWSPINLOCK)	+= hwspinlock/
+obj-$(CONFIG_NFC)		+= nfc/
diff --git a/drivers/nfc/Kconfig b/drivers/nfc/Kconfig
index ea15800..7809289 100644
--- a/drivers/nfc/Kconfig
+++ b/drivers/nfc/Kconfig
@@ -2,17 +2,8 @@
 # Near Field Communication (NFC) devices
 #
 
-menuconfig NFC_DEVICES
-	bool "Near Field Communication (NFC) devices"
-	default n
-	---help---
-	  You'll have to say Y if your computer contains an NFC device that
-	  you want to use under Linux.
-
-	  You can say N here if you don't have any Near Field Communication
-	  devices connected to your computer.
-
-if NFC_DEVICES
+menu "Near Field Communication (NFC) devices"
+	depends on NFC
 
 config PN544_NFC
 	tristate "PN544 NFC driver"
@@ -26,5 +17,4 @@ config PN544_NFC
 	  To compile this driver as a module, choose m here. The module will
 	  be called pn544.
 
-
-endif # NFC_DEVICES
+endmenu
diff --git a/drivers/nfc/Makefile b/drivers/nfc/Makefile
index a4efb16..25296f0 100644
--- a/drivers/nfc/Makefile
+++ b/drivers/nfc/Makefile
@@ -3,3 +3,5 @@
 #
 
 obj-$(CONFIG_PN544_NFC)		+= pn544.o
+
+ccflags-$(CONFIG_NFC_DEBUG) := -DDEBUG
diff --git a/include/net/nfc.h b/include/net/nfc.h
new file mode 100644
index 0000000..11d63dc
--- /dev/null
+++ b/include/net/nfc.h
@@ -0,0 +1,131 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __NET_NFC_H
+#define __NET_NFC_H
+
+#include <linux/device.h>
+#include <linux/skbuff.h>
+
+struct nfc_dev;
+
+/**
+ * data_exchange_cb_t - Definition of nfc_data_exchange callback
+ *
+ * @context: nfc_data_exchange cb_context parameter
+ * @skb: response data
+ * @err: If an error has occurred during data exchange, it is the
+ *	error number. Zero means no error.
+ *
+ * When a rx or tx package is lost or corrupted or the target gets out
+ * of the operating field, err is -EIO.
+ */
+typedef void (*data_exchange_cb_t)(void *context, struct sk_buff *skb,
+								int err);
+
+struct nfc_ops {
+	int (*start_poll)(struct nfc_dev *dev, u32 protocols);
+	void (*stop_poll)(struct nfc_dev *dev);
+	int (*activate_target)(struct nfc_dev *dev, u32 target_idx,
+							u32 protocol);
+	void (*deactivate_target)(struct nfc_dev *dev, u32 target_idx);
+	int (*data_exchange)(struct nfc_dev *dev, u32 target_idx,
+				struct sk_buff *skb, data_exchange_cb_t cb,
+							void *cb_context);
+};
+
+struct nfc_dev {
+	unsigned idx;
+	struct device dev;
+	bool polling;
+	u32 supported_protocols;
+
+	struct nfc_ops *ops;
+};
+#define to_nfc_dev(_dev) container_of(_dev, struct nfc_dev, dev)
+
+extern struct class nfc_class;
+
+struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
+					u32 supported_protocols);
+
+/**
+ * nfc_free_device - free nfc device
+ *
+ * @dev: The nfc device to free
+ */
+static inline void nfc_free_device(struct nfc_dev *dev)
+{
+	put_device(&dev->dev);
+}
+
+int nfc_register_device(struct nfc_dev *dev);
+
+void nfc_unregister_device(struct nfc_dev *dev);
+
+/**
+ * nfc_set_parent_dev - set the parent device
+ *
+ * @nfc_dev: The nfc device whose parent is being set
+ * @dev: The parent device
+ */
+static inline void nfc_set_parent_dev(struct nfc_dev *nfc_dev,
+					struct device *dev)
+{
+	nfc_dev->dev.parent = dev;
+}
+
+/**
+ * nfc_set_drvdata - set driver specifc data
+ *
+ * @dev: The nfc device
+ * @data: Pointer to driver specifc data
+ */
+static inline void nfc_set_drvdata(struct nfc_dev *dev, void *data)
+{
+	dev_set_drvdata(&dev->dev, data);
+}
+
+/**
+ * nfc_get_drvdata - get driver specifc data
+ *
+ * @dev: The nfc device
+ */
+static inline void *nfc_get_drvdata(struct nfc_dev *dev)
+{
+	return dev_get_drvdata(&dev->dev);
+}
+
+/**
+ * nfc_device_name - get the nfc device name
+ *
+ * @dev: The nfc device whose name to return
+ */
+static inline const char *nfc_device_name(struct nfc_dev *dev)
+{
+	return dev_name(&dev->dev);
+}
+
+struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp);
+
+#endif /* __NET_NFC_H */
diff --git a/net/Kconfig b/net/Kconfig
index 878151c..a073148 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -322,6 +322,7 @@ source "net/rfkill/Kconfig"
 source "net/9p/Kconfig"
 source "net/caif/Kconfig"
 source "net/ceph/Kconfig"
+source "net/nfc/Kconfig"
 
 
 endif   # if NET
diff --git a/net/Makefile b/net/Makefile
index a51d946..acdde49 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -68,3 +68,4 @@ obj-$(CONFIG_WIMAX)		+= wimax/
 obj-$(CONFIG_DNS_RESOLVER)	+= dns_resolver/
 obj-$(CONFIG_CEPH_LIB)		+= ceph/
 obj-$(CONFIG_BATMAN_ADV)	+= batman-adv/
+obj-$(CONFIG_NFC)		+= nfc/
diff --git a/net/nfc/Kconfig b/net/nfc/Kconfig
new file mode 100644
index 0000000..33e095b
--- /dev/null
+++ b/net/nfc/Kconfig
@@ -0,0 +1,16 @@
+#
+# NFC sybsystem configuration
+#
+
+menuconfig NFC
+	depends on NET && EXPERIMENTAL
+	tristate "NFC subsystem support (EXPERIMENTAL)"
+	default n
+	help
+	  Say Y here if you want to build support for NFC (Near field
+	  communication) devices.
+
+	  To compile this support as a module, choose M here: the module will
+	  be called nfc.
+
+source "drivers/nfc/Kconfig"
diff --git a/net/nfc/Makefile b/net/nfc/Makefile
new file mode 100644
index 0000000..28bee59
--- /dev/null
+++ b/net/nfc/Makefile
@@ -0,0 +1,7 @@
+#
+# Makefile for the Linux NFC subsystem.
+#
+
+obj-$(CONFIG_NFC) += nfc.o
+
+nfc-objs := core.o
diff --git a/net/nfc/core.c b/net/nfc/core.c
new file mode 100644
index 0000000..992bbc5
--- /dev/null
+++ b/net/nfc/core.c
@@ -0,0 +1,344 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+
+#include "nfc.h"
+
+#define VERSION "0.1"
+
+int nfc_devlist_generation;
+DEFINE_MUTEX(nfc_devlist_mutex);
+
+/**
+ * nfc_start_poll - start polling for nfc targets
+ *
+ * @dev: The nfc device that must start polling
+ * @protocols: bitset of nfc protocols that must be used for polling
+ *
+ * The device remains polling for targets until a target is found or
+ * the nfc_stop_poll function is called.
+ */
+int nfc_start_poll(struct nfc_dev *dev, u32 protocols)
+{
+	int rc;
+
+	NFC_DBG("dev_name:%s protocols=0x%x", dev_name(&dev->dev), protocols);
+
+	if (!protocols)
+		return -EINVAL;
+
+	device_lock(&dev->dev);
+
+	if (!device_is_registered(&dev->dev)) {
+		rc = -ENODEV;
+		goto error;
+	}
+
+	if (dev->polling) {
+		rc = -EBUSY;
+		goto error;
+	}
+
+	rc = dev->ops->start_poll(dev, protocols);
+	if (!rc)
+		dev->polling = true;
+
+error:
+	device_unlock(&dev->dev);
+	return rc;
+}
+
+/**
+ * nfc_stop_poll - stop polling for nfc targets
+ *
+ * @dev: The nfc device that must stop polling
+ */
+int nfc_stop_poll(struct nfc_dev *dev)
+{
+	int rc = 0;
+
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	device_lock(&dev->dev);
+
+	if (!device_is_registered(&dev->dev)) {
+		rc = -ENODEV;
+		goto error;
+	}
+
+	if (!dev->polling) {
+		rc = -EINVAL;
+		goto error;
+	}
+
+	dev->ops->stop_poll(dev);
+	dev->polling = false;
+
+error:
+	device_unlock(&dev->dev);
+	return rc;
+}
+
+/**
+ * nfc_activate_target - prepare the target for data exchange
+ *
+ * @dev: The nfc device that found the target
+ * @target_idx: index of the target that must be activated
+ * @protocol: nfc protocol that will be used for data exchange
+ */
+int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol)
+{
+	int rc;
+
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	device_lock(&dev->dev);
+
+	if (!device_is_registered(&dev->dev)) {
+		rc = -ENODEV;
+		goto error;
+	}
+
+	rc = dev->ops->activate_target(dev, target_idx, protocol);
+
+error:
+	device_unlock(&dev->dev);
+	return rc;
+}
+
+/**
+ * nfc_deactivate_target - deactivate a nfc target
+ *
+ * @dev: The nfc device that found the target
+ * @target_idx: index of the target that must be deactivated
+ */
+int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx)
+{
+	int rc = 0;
+
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	device_lock(&dev->dev);
+
+	if (!device_is_registered(&dev->dev)) {
+		rc = -ENODEV;
+		goto error;
+	}
+
+	dev->ops->deactivate_target(dev, target_idx);
+
+error:
+	device_unlock(&dev->dev);
+	return rc;
+}
+
+/**
+ * nfc_data_exchange - transceive data
+ *
+ * @dev: The nfc device that found the target
+ * @target_idx: index of the target
+ * @skb: data to be sent
+ * @cb: callback called when the response is received
+ * @cb_context: parameter for the callback function
+ *
+ * The user must wait for the callback before calling this function again.
+ */
+int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx,
+					struct sk_buff *skb,
+					data_exchange_cb_t cb,
+					void *cb_context)
+{
+	int rc;
+
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	device_lock(&dev->dev);
+
+	if (!device_is_registered(&dev->dev)) {
+		rc = -ENODEV;
+		kfree_skb(skb);
+		goto error;
+	}
+
+	rc = dev->ops->data_exchange(dev, target_idx, skb, cb, cb_context);
+
+error:
+	device_unlock(&dev->dev);
+	return rc;
+}
+
+/**
+ * nfc_alloc_skb - allocate a skb for data exchange responses
+ *
+ * @size: size to allocate
+ * @gfp: gfp flags
+ */
+struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp)
+{
+	struct sk_buff *skb;
+	unsigned int total_size;
+
+	total_size = size + 1;
+	skb = alloc_skb(total_size, gfp);
+
+	if (skb)
+		skb_reserve(skb, 1);
+
+	return skb;
+}
+EXPORT_SYMBOL(nfc_alloc_skb);
+
+static void nfc_release(struct device *d)
+{
+	struct nfc_dev *dev = to_nfc_dev(d);
+
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	kfree(dev);
+}
+
+struct class nfc_class = {
+	.name = "nfc",
+	.dev_release = nfc_release,
+};
+EXPORT_SYMBOL(nfc_class);
+
+static int match_idx(struct device *d, void *data)
+{
+	struct nfc_dev *dev = to_nfc_dev(d);
+	unsigned *idx = data;
+
+	return dev->idx == *idx;
+}
+
+struct nfc_dev *nfc_get_device(unsigned idx)
+{
+	struct device *d;
+
+	d = class_find_device(&nfc_class, NULL, &idx, match_idx);
+	if (!d)
+		return NULL;
+
+	return to_nfc_dev(d);
+}
+
+/**
+ * nfc_allocate_device - allocate a new nfc device
+ *
+ * @ops: device operations
+ * @supported_protocols: NFC protocols supported by the device
+ */
+struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
+					u32 supported_protocols)
+{
+	static atomic_t dev_no = ATOMIC_INIT(0);
+	struct nfc_dev *dev;
+
+	if (!ops->start_poll || !ops->stop_poll || !ops->activate_target ||
+		!ops->deactivate_target || !ops->data_exchange)
+		return NULL;
+
+	if (!supported_protocols)
+		return NULL;
+
+	dev = kzalloc(sizeof(struct nfc_dev), GFP_KERNEL);
+	if (!dev)
+		return NULL;
+
+	dev->dev.class = &nfc_class;
+	dev->idx = atomic_inc_return(&dev_no) - 1;
+	dev_set_name(&dev->dev, "nfc%d", dev->idx);
+	device_initialize(&dev->dev);
+
+	dev->ops = ops;
+	dev->supported_protocols = supported_protocols;
+
+	return dev;
+}
+EXPORT_SYMBOL(nfc_allocate_device);
+
+/**
+ * nfc_register_device - register a nfc device in the nfc subsystem
+ *
+ * @dev: The nfc device to register
+ */
+int nfc_register_device(struct nfc_dev *dev)
+{
+	int rc;
+
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	mutex_lock(&nfc_devlist_mutex);
+	nfc_devlist_generation++;
+	rc = device_add(&dev->dev);
+	mutex_unlock(&nfc_devlist_mutex);
+
+	return rc;
+}
+EXPORT_SYMBOL(nfc_register_device);
+
+/**
+ * nfc_unregister_device - unregister a nfc device in the nfc subsystem
+ *
+ * @dev: The nfc device to unregister
+ */
+void nfc_unregister_device(struct nfc_dev *dev)
+{
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	mutex_lock(&nfc_devlist_mutex);
+	nfc_devlist_generation++;
+
+	/* lock to avoid unregistering a device while an operation
+	   is in progress */
+	device_lock(&dev->dev);
+	device_del(&dev->dev);
+	device_unlock(&dev->dev);
+
+	mutex_unlock(&nfc_devlist_mutex);
+}
+EXPORT_SYMBOL(nfc_unregister_device);
+
+static int __init nfc_init(void)
+{
+	NFC_INFO("NFC Core ver %s", VERSION);
+
+	return class_register(&nfc_class);
+}
+
+static void __exit nfc_exit(void)
+{
+	class_unregister(&nfc_class);
+}
+
+subsys_initcall(nfc_init);
+module_exit(nfc_exit);
+
+MODULE_AUTHOR("Lauro Ramos Venancio <lauro.venancio@openbossa.org>");
+MODULE_DESCRIPTION("NFC Core ver " VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
new file mode 100644
index 0000000..b0ff15c
--- /dev/null
+++ b/net/nfc/nfc.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LOCAL_NFC_H
+#define __LOCAL_NFC_H
+
+#include <net/nfc.h>
+
+#define NFC_INFO(fmt, arg...) printk(KERN_INFO "NFC: " fmt "\n", ## arg)
+#define NFC_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n", __func__, ## arg)
+#define NFC_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)
+
+extern int nfc_devlist_generation;
+extern struct mutex nfc_devlist_mutex;
+
+struct nfc_dev *nfc_get_device(unsigned idx);
+
+static inline void nfc_put_device(struct nfc_dev *dev)
+{
+	put_device(&dev->dev);
+}
+
+static inline void nfc_device_iter_init(struct class_dev_iter *iter)
+{
+	class_dev_iter_init(iter, &nfc_class, NULL, NULL);
+}
+
+static inline struct nfc_dev *nfc_device_iter_next(struct class_dev_iter *iter)
+{
+	struct device *d = class_dev_iter_next(iter);
+	if (!d)
+		return NULL;
+
+	return to_nfc_dev(d);
+}
+
+static inline void nfc_device_iter_exit(struct class_dev_iter *iter)
+{
+	class_dev_iter_exit(iter);
+}
+
+int nfc_start_poll(struct nfc_dev *dev, u32 protocols);
+
+int nfc_stop_poll(struct nfc_dev *dev);
+
+int nfc_activate_target(struct nfc_dev *dev, u32 target_idx, u32 protocol);
+
+int nfc_deactivate_target(struct nfc_dev *dev, u32 target_idx);
+
+int nfc_data_exchange(struct nfc_dev *dev, u32 target_idx,
+					struct sk_buff *skb,
+					data_exchange_cb_t cb,
+					void *cb_context);
+
+#endif /* __LOCAL_NFC_H */
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 2/6] NFC: add nfc generic netlink interface
  2011-06-28 18:20 [PATCH v4 0/6] NFC subsystem Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 1/6] NFC: add nfc subsystem core Aloisio Almeida Jr
@ 2011-06-28 18:20 ` Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 3/6] NFC: add NFC socket family Aloisio Almeida Jr
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 38+ messages in thread
From: Aloisio Almeida Jr @ 2011-06-28 18:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, sameo, johannes, lauro.venancio, marcio.macedo,
	Waldemar.Rymarkiewicz, padovan, rdunlap, Aloisio Almeida Jr

From: Lauro Ramos Venancio <lauro.venancio@openbossa.org>

The NFC generic netlink interface exports the NFC control operations
to the user space.

Signed-off-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Signed-off-by: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
---
 include/linux/nfc.h |  112 +++++++++++
 include/net/nfc.h   |   21 ++
 net/nfc/Makefile    |    2 +-
 net/nfc/core.c      |   91 +++++++++-
 net/nfc/netlink.c   |  537 +++++++++++++++++++++++++++++++++++++++++++++++++++
 net/nfc/nfc.h       |   11 +
 6 files changed, 771 insertions(+), 3 deletions(-)
 create mode 100644 include/linux/nfc.h
 create mode 100644 net/nfc/netlink.c

diff --git a/include/linux/nfc.h b/include/linux/nfc.h
new file mode 100644
index 0000000..1170476
--- /dev/null
+++ b/include/linux/nfc.h
@@ -0,0 +1,112 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __LINUX_NFC_H
+#define __LINUX_NFC_H
+
+#define NFC_GENL_NAME "nfc"
+#define NFC_GENL_VERSION 1
+
+#define NFC_GENL_MCAST_EVENT_NAME "events"
+
+/**
+ * enum nfc_commands - supported nfc commands
+ *
+ * @NFC_CMD_UNSPEC: unspecified command
+ *
+ * @NFC_CMD_GET_DEVICE: request information about a device (requires
+ *	%NFC_ATTR_DEVICE_INDEX) or dump request to get a list of all nfc devices
+ * @NFC_CMD_START_POLL: start polling for targets using the given protocols
+ *	(requires %NFC_ATTR_DEVICE_INDEX and %NFC_ATTR_PROTOCOLS)
+ * @NFC_CMD_STOP_POLL: stop polling for targets (requires
+ *	%NFC_ATTR_DEVICE_INDEX)
+ * @NFC_CMD_GET_TARGET: dump all targets found by the previous poll (requires
+ *	%NFC_ATTR_DEVICE_INDEX)
+ * @NFC_EVENT_TARGETS_FOUND: event emitted when a new target is found
+ *	(it sends %NFC_ATTR_DEVICE_INDEX)
+ * @NFC_EVENT_DEVICE_ADDED: event emitted when a new device is registred
+ *	(it sends %NFC_ATTR_DEVICE_NAME, %NFC_ATTR_DEVICE_INDEX and
+ *	%NFC_ATTR_PROTOCOLS)
+ * @NFC_EVENT_DEVICE_REMOVED: event emitted when a device is removed
+ *	(it sends %NFC_ATTR_DEVICE_INDEX)
+ */
+enum nfc_commands {
+	NFC_CMD_UNSPEC,
+	NFC_CMD_GET_DEVICE,
+	NFC_CMD_START_POLL,
+	NFC_CMD_STOP_POLL,
+	NFC_CMD_GET_TARGET,
+	NFC_EVENT_TARGETS_FOUND,
+	NFC_EVENT_DEVICE_ADDED,
+	NFC_EVENT_DEVICE_REMOVED,
+/* private: internal use only */
+	__NFC_CMD_AFTER_LAST
+};
+#define NFC_CMD_MAX (__NFC_CMD_AFTER_LAST - 1)
+
+/**
+ * enum nfc_attrs - supported nfc attributes
+ *
+ * @NFC_ATTR_UNSPEC: unspecified attribute
+ *
+ * @NFC_ATTR_DEVICE_INDEX: index of nfc device
+ * @NFC_ATTR_DEVICE_NAME: device name, max 8 chars
+ * @NFC_ATTR_PROTOCOLS: nfc protocols - bitwise or-ed combination from
+ *	NFC_PROTO_*_MASK constants
+ * @NFC_ATTR_TARGET_INDEX: index of the nfc target
+ * @NFC_ATTR_TARGET_SENS_RES: NFC-A targets extra information such as NFCID
+ * @NFC_ATTR_TARGET_SEL_RES: NFC-A targets extra information (useful if the
+ *	target is not NFC-Forum compliant)
+ */
+enum nfc_attrs {
+	NFC_ATTR_UNSPEC,
+	NFC_ATTR_DEVICE_INDEX,
+	NFC_ATTR_DEVICE_NAME,
+	NFC_ATTR_PROTOCOLS,
+	NFC_ATTR_TARGET_INDEX,
+	NFC_ATTR_TARGET_SENS_RES,
+	NFC_ATTR_TARGET_SEL_RES,
+/* private: internal use only */
+	__NFC_ATTR_AFTER_LAST
+};
+#define NFC_ATTR_MAX (__NFC_ATTR_AFTER_LAST - 1)
+
+#define NFC_DEVICE_NAME_MAXSIZE 8
+
+/* NFC protocols */
+#define NFC_PROTO_JEWEL		1
+#define NFC_PROTO_MIFARE	2
+#define NFC_PROTO_FELICA	3
+#define NFC_PROTO_ISO14443	4
+#define NFC_PROTO_NFC_DEP	5
+
+#define NFC_PROTO_MAX		6
+
+/* NFC protocols masks used in bitsets */
+#define NFC_PROTO_JEWEL_MASK	(1 << NFC_PROTO_JEWEL)
+#define NFC_PROTO_MIFARE_MASK	(1 << NFC_PROTO_MIFARE)
+#define NFC_PROTO_FELICA_MASK	(1 << NFC_PROTO_FELICA)
+#define NFC_PROTO_ISO14443_MASK	(1 << NFC_PROTO_ISO14443)
+#define NFC_PROTO_NFC_DEP_MASK	(1 << NFC_PROTO_NFC_DEP)
+
+#endif /*__LINUX_NFC_H */
diff --git a/include/net/nfc.h b/include/net/nfc.h
index 11d63dc..01a30b3 100644
--- a/include/net/nfc.h
+++ b/include/net/nfc.h
@@ -54,10 +54,28 @@ struct nfc_ops {
 							void *cb_context);
 };
 
+struct nfc_target {
+	u32 idx;
+	u32 supported_protocols;
+	u16 sens_res;
+	u8 sel_res;
+};
+
+struct nfc_genl_data {
+	u32 poll_req_pid;
+	struct mutex genl_data_mutex;
+};
+
 struct nfc_dev {
 	unsigned idx;
+	unsigned target_idx;
+	struct nfc_target *targets;
+	int n_targets;
+	int targets_generation;
+	spinlock_t targets_lock;
 	struct device dev;
 	bool polling;
+	struct nfc_genl_data genl_data;
 	u32 supported_protocols;
 
 	struct nfc_ops *ops;
@@ -128,4 +146,7 @@ static inline const char *nfc_device_name(struct nfc_dev *dev)
 
 struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp);
 
+int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
+							int ntargets);
+
 #endif /* __NET_NFC_H */
diff --git a/net/nfc/Makefile b/net/nfc/Makefile
index 28bee59..fa6fc16 100644
--- a/net/nfc/Makefile
+++ b/net/nfc/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_NFC) += nfc.o
 
-nfc-objs := core.o
+nfc-objs := core.o netlink.o
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 992bbc5..a073834 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -212,12 +212,60 @@ struct sk_buff *nfc_alloc_skb(unsigned int size, gfp_t gfp)
 }
 EXPORT_SYMBOL(nfc_alloc_skb);
 
+/**
+ * nfc_targets_found - inform that targets were found
+ *
+ * @dev: The nfc device that found the targets
+ * @targets: array of nfc targets found
+ * @ntargets: targets array size
+ *
+ * The device driver must call this function when one or many nfc targets
+ * are found. After calling this function, the device driver must stop
+ * polling for targets.
+ */
+int nfc_targets_found(struct nfc_dev *dev, struct nfc_target *targets,
+							int n_targets)
+{
+	int i;
+
+	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
+
+	dev->polling = false;
+
+	for (i = 0; i < n_targets; i++)
+		targets[i].idx = dev->target_idx++;
+
+	spin_lock_bh(&dev->targets_lock);
+
+	dev->targets_generation++;
+
+	kfree(dev->targets);
+	dev->targets = kmemdup(targets, n_targets * sizeof(struct nfc_target),
+								GFP_ATOMIC);
+
+	if (!dev->targets) {
+		dev->n_targets = 0;
+		spin_unlock_bh(&dev->targets_lock);
+		return -ENOMEM;
+	}
+
+	dev->n_targets = n_targets;
+	spin_unlock_bh(&dev->targets_lock);
+
+	nfc_genl_targets_found(dev);
+
+	return 0;
+}
+EXPORT_SYMBOL(nfc_targets_found);
+
 static void nfc_release(struct device *d)
 {
 	struct nfc_dev *dev = to_nfc_dev(d);
 
 	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
 
+	nfc_genl_data_exit(&dev->genl_data);
+	kfree(dev->targets);
 	kfree(dev);
 }
 
@@ -277,6 +325,12 @@ struct nfc_dev *nfc_allocate_device(struct nfc_ops *ops,
 	dev->ops = ops;
 	dev->supported_protocols = supported_protocols;
 
+	spin_lock_init(&dev->targets_lock);
+	nfc_genl_data_init(&dev->genl_data);
+
+	/* first generation must not be 0 */
+	dev->targets_generation = 1;
+
 	return dev;
 }
 EXPORT_SYMBOL(nfc_allocate_device);
@@ -297,7 +351,15 @@ int nfc_register_device(struct nfc_dev *dev)
 	rc = device_add(&dev->dev);
 	mutex_unlock(&nfc_devlist_mutex);
 
-	return rc;
+	if (rc < 0)
+		return rc;
+
+	rc = nfc_genl_device_added(dev);
+	if (rc)
+		NFC_DBG("The userspace won't be notified that the device %s was"
+						" added", dev_name(&dev->dev));
+
+	return 0;
 }
 EXPORT_SYMBOL(nfc_register_device);
 
@@ -308,6 +370,8 @@ EXPORT_SYMBOL(nfc_register_device);
  */
 void nfc_unregister_device(struct nfc_dev *dev)
 {
+	int rc;
+
 	NFC_DBG("dev_name:%s", dev_name(&dev->dev));
 
 	mutex_lock(&nfc_devlist_mutex);
@@ -320,18 +384,41 @@ void nfc_unregister_device(struct nfc_dev *dev)
 	device_unlock(&dev->dev);
 
 	mutex_unlock(&nfc_devlist_mutex);
+
+	rc = nfc_genl_device_removed(dev);
+	if (rc)
+		NFC_DBG("The userspace won't be notified that the device %s was"
+					" removed", dev_name(&dev->dev));
 }
 EXPORT_SYMBOL(nfc_unregister_device);
 
 static int __init nfc_init(void)
 {
+	int rc;
+
 	NFC_INFO("NFC Core ver %s", VERSION);
 
-	return class_register(&nfc_class);
+	rc = class_register(&nfc_class);
+	if (rc)
+		return rc;
+
+	rc = nfc_genl_init();
+	if (rc)
+		goto err_genl;
+
+	/* the first generation must not be 0 */
+	nfc_devlist_generation = 1;
+
+	return 0;
+
+err_genl:
+	class_unregister(&nfc_class);
+	return rc;
 }
 
 static void __exit nfc_exit(void)
 {
+	nfc_genl_exit();
 	class_unregister(&nfc_class);
 }
 
diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c
new file mode 100644
index 0000000..b22b4e9
--- /dev/null
+++ b/net/nfc/netlink.c
@@ -0,0 +1,537 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <net/genetlink.h>
+#include <linux/nfc.h>
+#include <linux/slab.h>
+
+#include "nfc.h"
+
+static struct genl_multicast_group nfc_genl_event_mcgrp = {
+	.name = NFC_GENL_MCAST_EVENT_NAME,
+};
+
+struct genl_family nfc_genl_family = {
+	.id = GENL_ID_GENERATE,
+	.hdrsize = 0,
+	.name = NFC_GENL_NAME,
+	.version = NFC_GENL_VERSION,
+	.maxattr = NFC_ATTR_MAX,
+};
+
+static const struct nla_policy nfc_genl_policy[NFC_ATTR_MAX + 1] = {
+	[NFC_ATTR_DEVICE_INDEX] = { .type = NLA_U32 },
+	[NFC_ATTR_DEVICE_NAME] = { .type = NLA_STRING,
+				.len = NFC_DEVICE_NAME_MAXSIZE },
+	[NFC_ATTR_PROTOCOLS] = { .type = NLA_U32 },
+};
+
+static int nfc_genl_send_target(struct sk_buff *msg, struct nfc_target *target,
+					struct netlink_callback *cb, int flags)
+{
+	void *hdr;
+
+	NFC_DBG("");
+
+	hdr = genlmsg_put(msg, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq,
+				&nfc_genl_family, flags, NFC_CMD_GET_TARGET);
+	if (!hdr)
+		return -EMSGSIZE;
+
+	genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
+
+	NLA_PUT_U32(msg, NFC_ATTR_TARGET_INDEX, target->idx);
+	NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS,
+				target->supported_protocols);
+	NLA_PUT_U16(msg, NFC_ATTR_TARGET_SENS_RES, target->sens_res);
+	NLA_PUT_U8(msg, NFC_ATTR_TARGET_SEL_RES, target->sel_res);
+
+	return genlmsg_end(msg, hdr);
+
+nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+	return -EMSGSIZE;
+}
+
+static struct nfc_dev *__get_device_from_cb(struct netlink_callback *cb)
+{
+	struct nfc_dev *dev;
+	int rc;
+	u32 idx;
+
+	rc = nlmsg_parse(cb->nlh, GENL_HDRLEN + nfc_genl_family.hdrsize,
+						nfc_genl_family.attrbuf,
+						nfc_genl_family.maxattr,
+						nfc_genl_policy);
+	if (rc < 0)
+		return ERR_PTR(rc);
+
+	if (!nfc_genl_family.attrbuf[NFC_ATTR_DEVICE_INDEX])
+		return ERR_PTR(-EINVAL);
+
+	idx = nla_get_u32(nfc_genl_family.attrbuf[NFC_ATTR_DEVICE_INDEX]);
+
+	dev = nfc_get_device(idx);
+	if (!dev)
+		return ERR_PTR(-ENODEV);
+
+	return dev;
+}
+
+static int nfc_genl_dump_targets(struct sk_buff *skb,
+				struct netlink_callback *cb)
+{
+	int i = cb->args[0];
+	struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
+	int rc;
+
+	NFC_DBG("");
+
+	if (!dev) {
+		dev = __get_device_from_cb(cb);
+		if (IS_ERR(dev))
+			return PTR_ERR(dev);
+
+		cb->args[1] = (long) dev;
+	}
+
+	spin_lock_bh(&dev->targets_lock);
+
+	cb->seq = dev->targets_generation;
+
+	while (i < dev->n_targets) {
+		rc = nfc_genl_send_target(skb, &dev->targets[i], cb,
+								NLM_F_MULTI);
+		if (rc < 0)
+			break;
+
+		i++;
+	}
+
+	spin_unlock_bh(&dev->targets_lock);
+
+	cb->args[0] = i;
+
+	return skb->len;
+}
+
+static int nfc_genl_dump_targets_done(struct netlink_callback *cb)
+{
+	struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
+
+	NFC_DBG("");
+
+	if (dev)
+		nfc_put_device(dev);
+
+	return 0;
+}
+
+int nfc_genl_targets_found(struct nfc_dev *dev)
+{
+	struct sk_buff *msg;
+	void *hdr;
+
+	NFC_DBG("");
+
+	dev->genl_data.poll_req_pid = 0;
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_ATOMIC);
+	if (!msg)
+		return -ENOMEM;
+
+	hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
+				NFC_EVENT_TARGETS_FOUND);
+	if (!hdr)
+		goto free_msg;
+
+	NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
+
+	genlmsg_end(msg, hdr);
+
+	return genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_ATOMIC);
+
+nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+free_msg:
+	nlmsg_free(msg);
+	return -EMSGSIZE;
+}
+
+int nfc_genl_device_added(struct nfc_dev *dev)
+{
+	struct sk_buff *msg;
+	void *hdr;
+
+	NFC_DBG("");
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!msg)
+		return -ENOMEM;
+
+	hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
+				NFC_EVENT_DEVICE_ADDED);
+	if (!hdr)
+		goto free_msg;
+
+	NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
+	NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
+	NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols);
+
+	genlmsg_end(msg, hdr);
+
+	genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL);
+
+	return 0;
+
+nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+free_msg:
+	nlmsg_free(msg);
+	return -EMSGSIZE;
+}
+
+int nfc_genl_device_removed(struct nfc_dev *dev)
+{
+	struct sk_buff *msg;
+	void *hdr;
+
+	NFC_DBG("");
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!msg)
+		return -ENOMEM;
+
+	hdr = genlmsg_put(msg, 0, 0, &nfc_genl_family, 0,
+				NFC_EVENT_DEVICE_REMOVED);
+	if (!hdr)
+		goto free_msg;
+
+	NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
+
+	genlmsg_end(msg, hdr);
+
+	genlmsg_multicast(msg, 0, nfc_genl_event_mcgrp.id, GFP_KERNEL);
+
+	return 0;
+
+nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+free_msg:
+	nlmsg_free(msg);
+	return -EMSGSIZE;
+}
+
+static int nfc_genl_send_device(struct sk_buff *msg, struct nfc_dev *dev,
+						u32 pid, u32 seq,
+						struct netlink_callback *cb,
+						int flags)
+{
+	void *hdr;
+
+	NFC_DBG("");
+
+	hdr = genlmsg_put(msg, pid, seq, &nfc_genl_family, flags,
+							NFC_CMD_GET_DEVICE);
+	if (!hdr)
+		return -EMSGSIZE;
+
+	if (cb)
+		genl_dump_check_consistent(cb, hdr, &nfc_genl_family);
+
+	NLA_PUT_STRING(msg, NFC_ATTR_DEVICE_NAME, nfc_device_name(dev));
+	NLA_PUT_U32(msg, NFC_ATTR_DEVICE_INDEX, dev->idx);
+	NLA_PUT_U32(msg, NFC_ATTR_PROTOCOLS, dev->supported_protocols);
+
+	return genlmsg_end(msg, hdr);
+
+nla_put_failure:
+	genlmsg_cancel(msg, hdr);
+	return -EMSGSIZE;
+}
+
+static int nfc_genl_dump_devices(struct sk_buff *skb,
+				struct netlink_callback *cb)
+{
+	struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
+	struct nfc_dev *dev = (struct nfc_dev *) cb->args[1];
+	bool first_call = false;
+
+	NFC_DBG("");
+
+	if (!iter) {
+		first_call = true;
+		iter = kmalloc(sizeof(struct class_dev_iter), GFP_KERNEL);
+		if (!iter)
+			return -ENOMEM;
+		cb->args[0] = (long) iter;
+	}
+
+	mutex_lock(&nfc_devlist_mutex);
+
+	cb->seq = nfc_devlist_generation;
+
+	if (first_call) {
+		nfc_device_iter_init(iter);
+		dev = nfc_device_iter_next(iter);
+	}
+
+	while (dev) {
+		int rc;
+
+		rc = nfc_genl_send_device(skb, dev, NETLINK_CB(cb->skb).pid,
+							cb->nlh->nlmsg_seq,
+							cb, NLM_F_MULTI);
+		if (rc < 0)
+			break;
+
+		dev = nfc_device_iter_next(iter);
+	}
+
+	mutex_unlock(&nfc_devlist_mutex);
+
+	cb->args[1] = (long) dev;
+
+	return skb->len;
+}
+
+static int nfc_genl_dump_devices_done(struct netlink_callback *cb)
+{
+	struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
+
+	NFC_DBG("");
+
+	nfc_device_iter_exit(iter);
+	kfree(iter);
+
+	return 0;
+}
+
+static int nfc_genl_get_device(struct sk_buff *skb, struct genl_info *info)
+{
+	struct sk_buff *msg;
+	struct nfc_dev *dev;
+	u32 idx;
+	int rc = -ENOBUFS;
+
+	NFC_DBG("");
+
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+		return -EINVAL;
+
+	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
+
+	dev = nfc_get_device(idx);
+	if (!dev)
+		return -ENODEV;
+
+	msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL);
+	if (!msg) {
+		rc = -ENOMEM;
+		goto out_putdev;
+	}
+
+	rc = nfc_genl_send_device(msg, dev, info->snd_pid, info->snd_seq,
+								NULL, 0);
+	if (rc < 0)
+		goto out_free;
+
+	nfc_put_device(dev);
+
+	return genlmsg_reply(msg, info);
+
+out_free:
+	nlmsg_free(msg);
+out_putdev:
+	nfc_put_device(dev);
+	return rc;
+}
+
+static int nfc_genl_start_poll(struct sk_buff *skb, struct genl_info *info)
+{
+	struct nfc_dev *dev;
+	int rc;
+	u32 idx;
+	u32 protocols;
+
+	NFC_DBG("");
+
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX] ||
+		!info->attrs[NFC_ATTR_PROTOCOLS])
+		return -EINVAL;
+
+	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
+	protocols = nla_get_u32(info->attrs[NFC_ATTR_PROTOCOLS]);
+
+	dev = nfc_get_device(idx);
+	if (!dev)
+		return -ENODEV;
+
+	mutex_lock(&dev->genl_data.genl_data_mutex);
+
+	rc = nfc_start_poll(dev, protocols);
+	if (!rc)
+		dev->genl_data.poll_req_pid = info->snd_pid;
+
+	mutex_unlock(&dev->genl_data.genl_data_mutex);
+
+	nfc_put_device(dev);
+	return rc;
+}
+
+static int nfc_genl_stop_poll(struct sk_buff *skb, struct genl_info *info)
+{
+	struct nfc_dev *dev;
+	int rc;
+	u32 idx;
+
+	NFC_DBG("");
+
+	if (!info->attrs[NFC_ATTR_DEVICE_INDEX])
+		return -EINVAL;
+
+	idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]);
+
+	dev = nfc_get_device(idx);
+	if (!dev)
+		return -ENODEV;
+
+	mutex_lock(&dev->genl_data.genl_data_mutex);
+
+	if (dev->genl_data.poll_req_pid != info->snd_pid) {
+		rc = -EBUSY;
+		goto out;
+	}
+
+	rc = nfc_stop_poll(dev);
+	dev->genl_data.poll_req_pid = 0;
+
+out:
+	mutex_unlock(&dev->genl_data.genl_data_mutex);
+	nfc_put_device(dev);
+	return rc;
+}
+
+static struct genl_ops nfc_genl_ops[] = {
+	{
+		.cmd = NFC_CMD_GET_DEVICE,
+		.doit = nfc_genl_get_device,
+		.dumpit = nfc_genl_dump_devices,
+		.done = nfc_genl_dump_devices_done,
+		.policy = nfc_genl_policy,
+	},
+	{
+		.cmd = NFC_CMD_START_POLL,
+		.doit = nfc_genl_start_poll,
+		.policy = nfc_genl_policy,
+	},
+	{
+		.cmd = NFC_CMD_STOP_POLL,
+		.doit = nfc_genl_stop_poll,
+		.policy = nfc_genl_policy,
+	},
+	{
+		.cmd = NFC_CMD_GET_TARGET,
+		.dumpit = nfc_genl_dump_targets,
+		.done = nfc_genl_dump_targets_done,
+		.policy = nfc_genl_policy,
+	},
+};
+
+static int nfc_genl_rcv_nl_event(struct notifier_block *this,
+						unsigned long event, void *ptr)
+{
+	struct netlink_notify *n = ptr;
+	struct class_dev_iter iter;
+	struct nfc_dev *dev;
+
+	if (event != NETLINK_URELEASE || n->protocol != NETLINK_GENERIC)
+		goto out;
+
+	NFC_DBG("NETLINK_URELEASE event from id %d", n->pid);
+
+	nfc_device_iter_init(&iter);
+	dev = nfc_device_iter_next(&iter);
+
+	while (dev) {
+		mutex_lock(&dev->genl_data.genl_data_mutex);
+		if (dev->genl_data.poll_req_pid == n->pid) {
+			nfc_stop_poll(dev);
+			dev->genl_data.poll_req_pid = 0;
+		}
+		mutex_unlock(&dev->genl_data.genl_data_mutex);
+		dev = nfc_device_iter_next(&iter);
+	}
+
+	nfc_device_iter_exit(&iter);
+
+out:
+	return NOTIFY_DONE;
+}
+
+void nfc_genl_data_init(struct nfc_genl_data *genl_data)
+{
+	genl_data->poll_req_pid = 0;
+	mutex_init(&genl_data->genl_data_mutex);
+}
+
+void nfc_genl_data_exit(struct nfc_genl_data *genl_data)
+{
+	mutex_destroy(&genl_data->genl_data_mutex);
+}
+
+static struct notifier_block nl_notifier = {
+	.notifier_call  = nfc_genl_rcv_nl_event,
+};
+
+/**
+ * nfc_genl_init() - Initialize netlink interface
+ *
+ * This initialization function registers the nfc netlink family.
+ */
+int __init nfc_genl_init(void)
+{
+	int rc;
+
+	rc = genl_register_family_with_ops(&nfc_genl_family, nfc_genl_ops,
+					ARRAY_SIZE(nfc_genl_ops));
+	if (rc)
+		return rc;
+
+	rc = genl_register_mc_group(&nfc_genl_family, &nfc_genl_event_mcgrp);
+
+	netlink_register_notifier(&nl_notifier);
+
+	return rc;
+}
+
+/**
+ * nfc_genl_exit() - Deinitialize netlink interface
+ *
+ * This exit function unregisters the nfc netlink family.
+ */
+void nfc_genl_exit(void)
+{
+	netlink_unregister_notifier(&nl_notifier);
+	genl_unregister_family(&nfc_genl_family);
+}
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index b0ff15c..b2eb3de 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -33,6 +33,17 @@
 extern int nfc_devlist_generation;
 extern struct mutex nfc_devlist_mutex;
 
+int __init nfc_genl_init(void);
+void nfc_genl_exit(void);
+
+void nfc_genl_data_init(struct nfc_genl_data *genl_data);
+void nfc_genl_data_exit(struct nfc_genl_data *genl_data);
+
+int nfc_genl_targets_found(struct nfc_dev *dev);
+
+int nfc_genl_device_added(struct nfc_dev *dev);
+int nfc_genl_device_removed(struct nfc_dev *dev);
+
 struct nfc_dev *nfc_get_device(unsigned idx);
 
 static inline void nfc_put_device(struct nfc_dev *dev)
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 3/6] NFC: add NFC socket family
  2011-06-28 18:20 [PATCH v4 0/6] NFC subsystem Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 1/6] NFC: add nfc subsystem core Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 2/6] NFC: add nfc generic netlink interface Aloisio Almeida Jr
@ 2011-06-28 18:20 ` Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 4/6] NFC: add the NFC socket raw protocol Aloisio Almeida Jr
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 38+ messages in thread
From: Aloisio Almeida Jr @ 2011-06-28 18:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, sameo, johannes, lauro.venancio, marcio.macedo,
	Waldemar.Rymarkiewicz, padovan, rdunlap, Aloisio Almeida Jr

Signed-off-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Signed-off-by: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
---
 include/linux/nfc.h    |    3 +
 include/linux/socket.h |    4 +-
 net/core/sock.c        |    6 +-
 net/nfc/Makefile       |    2 +-
 net/nfc/af_nfc.c       |   98 ++++++++++++++++++++++++++++++++++++++++++++++++
 net/nfc/core.c         |    7 +++
 net/nfc/nfc.h          |   14 +++++++
 7 files changed, 129 insertions(+), 5 deletions(-)
 create mode 100644 net/nfc/af_nfc.c

diff --git a/include/linux/nfc.h b/include/linux/nfc.h
index 1170476..15f8cb3 100644
--- a/include/linux/nfc.h
+++ b/include/linux/nfc.h
@@ -109,4 +109,7 @@ enum nfc_attrs {
 #define NFC_PROTO_ISO14443_MASK	(1 << NFC_PROTO_ISO14443)
 #define NFC_PROTO_NFC_DEP_MASK	(1 << NFC_PROTO_NFC_DEP)
 
+/* NFC socket protocols */
+#define NFC_SOCKPROTO_MAX	0
+
 #endif /*__LINUX_NFC_H */
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 4ef98e4..e17f822 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -192,7 +192,8 @@ struct ucred {
 #define AF_IEEE802154	36	/* IEEE802154 sockets		*/
 #define AF_CAIF		37	/* CAIF sockets			*/
 #define AF_ALG		38	/* Algorithm sockets		*/
-#define AF_MAX		39	/* For now.. */
+#define AF_NFC		39	/* NFC sockets			*/
+#define AF_MAX		40	/* For now.. */
 
 /* Protocol families, same as address families. */
 #define PF_UNSPEC	AF_UNSPEC
@@ -234,6 +235,7 @@ struct ucred {
 #define PF_IEEE802154	AF_IEEE802154
 #define PF_CAIF		AF_CAIF
 #define PF_ALG		AF_ALG
+#define PF_NFC		AF_NFC
 #define PF_MAX		AF_MAX
 
 /* Maximum queue length specifiable by listen.  */
diff --git a/net/core/sock.c b/net/core/sock.c
index 6e81978..84d6de8 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -158,7 +158,7 @@ static const char *const af_family_key_strings[AF_MAX+1] = {
   "sk_lock-AF_TIPC"  , "sk_lock-AF_BLUETOOTH", "sk_lock-IUCV"        ,
   "sk_lock-AF_RXRPC" , "sk_lock-AF_ISDN"     , "sk_lock-AF_PHONET"   ,
   "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" , "sk_lock-AF_ALG"      ,
-  "sk_lock-AF_MAX"
+  "sk_lock-AF_NFC"   , "sk_lock-AF_MAX"
 };
 static const char *const af_family_slock_key_strings[AF_MAX+1] = {
   "slock-AF_UNSPEC", "slock-AF_UNIX"     , "slock-AF_INET"     ,
@@ -174,7 +174,7 @@ static const char *const af_family_slock_key_strings[AF_MAX+1] = {
   "slock-AF_TIPC"  , "slock-AF_BLUETOOTH", "slock-AF_IUCV"     ,
   "slock-AF_RXRPC" , "slock-AF_ISDN"     , "slock-AF_PHONET"   ,
   "slock-AF_IEEE802154", "slock-AF_CAIF" , "slock-AF_ALG"      ,
-  "slock-AF_MAX"
+  "slock-AF_NFC"   , "slock-AF_MAX"
 };
 static const char *const af_family_clock_key_strings[AF_MAX+1] = {
   "clock-AF_UNSPEC", "clock-AF_UNIX"     , "clock-AF_INET"     ,
@@ -190,7 +190,7 @@ static const char *const af_family_clock_key_strings[AF_MAX+1] = {
   "clock-AF_TIPC"  , "clock-AF_BLUETOOTH", "clock-AF_IUCV"     ,
   "clock-AF_RXRPC" , "clock-AF_ISDN"     , "clock-AF_PHONET"   ,
   "clock-AF_IEEE802154", "clock-AF_CAIF" , "clock-AF_ALG"      ,
-  "clock-AF_MAX"
+  "clock-AF_NFC"   , "clock-AF_MAX"
 };
 
 /*
diff --git a/net/nfc/Makefile b/net/nfc/Makefile
index fa6fc16..e081fdb 100644
--- a/net/nfc/Makefile
+++ b/net/nfc/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_NFC) += nfc.o
 
-nfc-objs := core.o netlink.o
+nfc-objs := core.o netlink.o af_nfc.o
diff --git a/net/nfc/af_nfc.c b/net/nfc/af_nfc.c
new file mode 100644
index 0000000..e982cef
--- /dev/null
+++ b/net/nfc/af_nfc.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/nfc.h>
+
+#include "nfc.h"
+
+static DEFINE_RWLOCK(proto_tab_lock);
+static const struct nfc_protocol *proto_tab[NFC_SOCKPROTO_MAX];
+
+static int nfc_sock_create(struct net *net, struct socket *sock, int proto,
+								int kern)
+{
+	int rc = -EPROTONOSUPPORT;
+
+	if (net != &init_net)
+		return -EAFNOSUPPORT;
+
+	if (proto < 0 || proto >= NFC_SOCKPROTO_MAX)
+		return -EINVAL;
+
+	read_lock(&proto_tab_lock);
+	if (proto_tab[proto] &&	try_module_get(proto_tab[proto]->owner)) {
+		rc = proto_tab[proto]->create(net, sock, proto_tab[proto]);
+		module_put(proto_tab[proto]->owner);
+	}
+	read_unlock(&proto_tab_lock);
+
+	return rc;
+}
+
+static struct net_proto_family nfc_sock_family_ops = {
+	.owner  = THIS_MODULE,
+	.family = PF_NFC,
+	.create = nfc_sock_create,
+};
+
+int nfc_proto_register(const struct nfc_protocol *nfc_proto)
+{
+	int rc;
+
+	if (nfc_proto->id < 0 || nfc_proto->id >= NFC_SOCKPROTO_MAX)
+		return -EINVAL;
+
+	rc = proto_register(nfc_proto->proto, 0);
+	if (rc)
+		return rc;
+
+	write_lock(&proto_tab_lock);
+	if (proto_tab[nfc_proto->id])
+		rc = -EBUSY;
+	else
+		proto_tab[nfc_proto->id] = nfc_proto;
+	write_unlock(&proto_tab_lock);
+
+	return rc;
+}
+EXPORT_SYMBOL(nfc_proto_register);
+
+void nfc_proto_unregister(const struct nfc_protocol *nfc_proto)
+{
+	write_lock(&proto_tab_lock);
+	proto_tab[nfc_proto->id] = NULL;
+	write_unlock(&proto_tab_lock);
+
+	proto_unregister(nfc_proto->proto);
+}
+EXPORT_SYMBOL(nfc_proto_unregister);
+
+int __init af_nfc_init(void)
+{
+	return sock_register(&nfc_sock_family_ops);
+}
+
+void af_nfc_exit(void)
+{
+	sock_unregister(PF_NFC);
+}
diff --git a/net/nfc/core.c b/net/nfc/core.c
index a073834..23e7ed7 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -409,8 +409,14 @@ static int __init nfc_init(void)
 	/* the first generation must not be 0 */
 	nfc_devlist_generation = 1;
 
+	rc = af_nfc_init();
+	if (rc)
+		goto err_af_nfc;
+
 	return 0;
 
+err_af_nfc:
+	nfc_genl_exit();
 err_genl:
 	class_unregister(&nfc_class);
 	return rc;
@@ -418,6 +424,7 @@ err_genl:
 
 static void __exit nfc_exit(void)
 {
+	af_nfc_exit();
 	nfc_genl_exit();
 	class_unregister(&nfc_class);
 }
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index b2eb3de..70a1c3a 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -25,11 +25,25 @@
 #define __LOCAL_NFC_H
 
 #include <net/nfc.h>
+#include <net/sock.h>
 
 #define NFC_INFO(fmt, arg...) printk(KERN_INFO "NFC: " fmt "\n", ## arg)
 #define NFC_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n", __func__, ## arg)
 #define NFC_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)
 
+struct nfc_protocol {
+	int id;
+	struct proto *proto;
+	struct module *owner;
+	int (*create)(struct net *net, struct socket *sock,
+			const struct nfc_protocol *nfc_proto);
+};
+
+int __init af_nfc_init(void);
+void af_nfc_exit(void);
+int nfc_proto_register(const struct nfc_protocol *nfc_proto);
+void nfc_proto_unregister(const struct nfc_protocol *nfc_proto);
+
 extern int nfc_devlist_generation;
 extern struct mutex nfc_devlist_mutex;
 
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 4/6] NFC: add the NFC socket raw protocol
  2011-06-28 18:20 [PATCH v4 0/6] NFC subsystem Aloisio Almeida Jr
                   ` (2 preceding siblings ...)
  2011-06-28 18:20 ` [PATCH v4 3/6] NFC: add NFC socket family Aloisio Almeida Jr
@ 2011-06-28 18:20 ` Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 5/6] NFC: pn533: add NXP pn533 nfc device driver Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 6/6] NFC: add Documentation/networking/nfc.txt Aloisio Almeida Jr
  5 siblings, 0 replies; 38+ messages in thread
From: Aloisio Almeida Jr @ 2011-06-28 18:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, sameo, johannes, lauro.venancio, marcio.macedo,
	Waldemar.Rymarkiewicz, padovan, rdunlap, Aloisio Almeida Jr

From: Lauro Ramos Venancio <lauro.venancio@openbossa.org>

This socket protocol is used to perform data exchange with NFC
targets.

Signed-off-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Signed-off-by: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
---
 include/linux/nfc.h |   13 ++-
 net/nfc/Makefile    |    2 +-
 net/nfc/core.c      |    7 +
 net/nfc/nfc.h       |   14 ++
 net/nfc/rawsock.c   |  351 +++++++++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 385 insertions(+), 2 deletions(-)
 create mode 100644 net/nfc/rawsock.c

diff --git a/include/linux/nfc.h b/include/linux/nfc.h
index 15f8cb3..330a4c5 100644
--- a/include/linux/nfc.h
+++ b/include/linux/nfc.h
@@ -24,6 +24,9 @@
 #ifndef __LINUX_NFC_H
 #define __LINUX_NFC_H
 
+#include <linux/types.h>
+#include <linux/socket.h>
+
 #define NFC_GENL_NAME "nfc"
 #define NFC_GENL_VERSION 1
 
@@ -109,7 +112,15 @@ enum nfc_attrs {
 #define NFC_PROTO_ISO14443_MASK	(1 << NFC_PROTO_ISO14443)
 #define NFC_PROTO_NFC_DEP_MASK	(1 << NFC_PROTO_NFC_DEP)
 
+struct sockaddr_nfc {
+	sa_family_t sa_family;
+	__u32 dev_idx;
+	__u32 target_idx;
+	__u32 nfc_protocol;
+};
+
 /* NFC socket protocols */
-#define NFC_SOCKPROTO_MAX	0
+#define NFC_SOCKPROTO_RAW	0
+#define NFC_SOCKPROTO_MAX	1
 
 #endif /*__LINUX_NFC_H */
diff --git a/net/nfc/Makefile b/net/nfc/Makefile
index e081fdb..16250c3 100644
--- a/net/nfc/Makefile
+++ b/net/nfc/Makefile
@@ -4,4 +4,4 @@
 
 obj-$(CONFIG_NFC) += nfc.o
 
-nfc-objs := core.o netlink.o af_nfc.o
+nfc-objs := core.o netlink.o af_nfc.o rawsock.o
diff --git a/net/nfc/core.c b/net/nfc/core.c
index 23e7ed7..259dd43 100644
--- a/net/nfc/core.c
+++ b/net/nfc/core.c
@@ -409,6 +409,10 @@ static int __init nfc_init(void)
 	/* the first generation must not be 0 */
 	nfc_devlist_generation = 1;
 
+	rc = rawsock_init();
+	if (rc)
+		goto err_rawsock;
+
 	rc = af_nfc_init();
 	if (rc)
 		goto err_af_nfc;
@@ -416,6 +420,8 @@ static int __init nfc_init(void)
 	return 0;
 
 err_af_nfc:
+	rawsock_exit();
+err_rawsock:
 	nfc_genl_exit();
 err_genl:
 	class_unregister(&nfc_class);
@@ -425,6 +431,7 @@ err_genl:
 static void __exit nfc_exit(void)
 {
 	af_nfc_exit();
+	rawsock_exit();
 	nfc_genl_exit();
 	class_unregister(&nfc_class);
 }
diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
index 70a1c3a..66c520e 100644
--- a/net/nfc/nfc.h
+++ b/net/nfc/nfc.h
@@ -39,6 +39,20 @@ struct nfc_protocol {
 			const struct nfc_protocol *nfc_proto);
 };
 
+struct nfc_rawsock {
+	struct sock sk;
+	struct nfc_dev *dev;
+	u32 target_idx;
+	struct work_struct tx_work;
+	bool tx_work_scheduled;
+};
+#define nfc_rawsock(sk) ((struct nfc_rawsock *) sk)
+#define to_rawsock_sk(_tx_work) \
+	((struct sock *) container_of(_tx_work, struct nfc_rawsock, tx_work))
+
+int __init rawsock_init(void);
+void rawsock_exit(void);
+
 int __init af_nfc_init(void);
 void af_nfc_exit(void);
 int nfc_proto_register(const struct nfc_protocol *nfc_proto);
diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c
new file mode 100644
index 0000000..e588e04
--- /dev/null
+++ b/net/nfc/rawsock.c
@@ -0,0 +1,351 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <net/tcp_states.h>
+#include <linux/nfc.h>
+
+#include "nfc.h"
+
+static void rawsock_write_queue_purge(struct sock *sk)
+{
+	NFC_DBG("");
+
+	spin_lock_bh(&sk->sk_write_queue.lock);
+	__skb_queue_purge(&sk->sk_write_queue);
+	nfc_rawsock(sk)->tx_work_scheduled = false;
+	spin_unlock_bh(&sk->sk_write_queue.lock);
+}
+
+static void rawsock_report_error(struct sock *sk, int err)
+{
+	NFC_DBG("");
+
+	sk->sk_shutdown = SHUTDOWN_MASK;
+	sk->sk_err = -err;
+	sk->sk_error_report(sk);
+
+	rawsock_write_queue_purge(sk);
+}
+
+static int rawsock_release(struct socket *sock)
+{
+	struct sock *sk = sock->sk;
+
+	NFC_DBG("");
+
+	sock_orphan(sk);
+	sock_put(sk);
+
+	return 0;
+}
+
+static int rawsock_connect(struct socket *sock, struct sockaddr *_addr,
+							int len, int flags)
+{
+	struct sock *sk = sock->sk;
+	struct sockaddr_nfc *addr = (struct sockaddr_nfc *)_addr;
+	struct nfc_dev *dev;
+	int rc = 0;
+
+	NFC_DBG("");
+
+	if (!addr || len < sizeof(struct sockaddr_nfc) ||
+		addr->sa_family != AF_NFC)
+		return -EINVAL;
+
+	lock_sock(sk);
+
+	if (sock->state == SS_CONNECTED) {
+		rc = -EISCONN;
+		goto error;
+	}
+
+	dev = nfc_get_device(addr->dev_idx);
+	if (!dev) {
+		rc = -ENODEV;
+		goto error;
+	}
+
+	if (addr->target_idx > dev->target_idx - 1 ||
+		addr->target_idx < dev->target_idx - dev->n_targets) {
+		rc = -EINVAL;
+		goto error;
+	}
+
+	if (addr->target_idx > dev->target_idx - 1 ||
+		addr->target_idx < dev->target_idx - dev->n_targets) {
+		rc = -EINVAL;
+		goto error;
+	}
+
+	rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol);
+	if (rc)
+		goto put_dev;
+
+	nfc_rawsock(sk)->dev = dev;
+	nfc_rawsock(sk)->target_idx = addr->target_idx;
+	sock->state = SS_CONNECTED;
+	sk->sk_state = TCP_ESTABLISHED;
+	sk->sk_state_change(sk);
+
+	release_sock(sk);
+	return 0;
+
+put_dev:
+	nfc_put_device(dev);
+error:
+	release_sock(sk);
+	return rc;
+}
+
+static int rawsock_add_header(struct sk_buff *skb)
+{
+
+	if (skb_cow_head(skb, 1))
+		return -ENOMEM;
+
+	*skb_push(skb, 1) = 0;
+
+	return 0;
+}
+
+static void rawsock_data_exchange_complete(void *context, struct sk_buff *skb,
+								int err)
+{
+	struct sock *sk = (struct sock *) context;
+
+	BUG_ON(in_irq());
+
+	if (err)
+		goto error;
+
+	err = rawsock_add_header(skb);
+	if (err)
+		goto error;
+
+	err = sock_queue_rcv_skb(sk, skb);
+	if (err)
+		goto error;
+
+	spin_lock_bh(&sk->sk_write_queue.lock);
+	if (!skb_queue_empty(&sk->sk_write_queue))
+		schedule_work(&nfc_rawsock(sk)->tx_work);
+	else
+		nfc_rawsock(sk)->tx_work_scheduled = false;
+	spin_unlock_bh(&sk->sk_write_queue.lock);
+
+	sock_put(sk);
+	return;
+
+error:
+	rawsock_report_error(sk, err);
+	sock_put(sk);
+}
+
+static void rawsock_tx_work(struct work_struct *work)
+{
+	struct sock *sk = to_rawsock_sk(work);
+	struct nfc_dev *dev = nfc_rawsock(sk)->dev;
+	u32 target_idx = nfc_rawsock(sk)->target_idx;
+	struct sk_buff *skb;
+	int rc;
+
+	if (sk->sk_shutdown & SEND_SHUTDOWN) {
+		rawsock_write_queue_purge(sk);
+		return;
+	}
+
+	skb = skb_dequeue(&sk->sk_write_queue);
+
+	sock_hold(sk);
+	rc = nfc_data_exchange(dev, target_idx, skb,
+				rawsock_data_exchange_complete, sk);
+	if (rc) {
+		rawsock_report_error(sk, rc);
+		sock_put(sk);
+	}
+}
+
+static int rawsock_sendmsg(struct kiocb *iocb, struct socket *sock,
+					struct msghdr *msg, size_t len)
+{
+	struct sock *sk = sock->sk;
+	struct sk_buff *skb;
+	int rc;
+
+	NFC_DBG("");
+
+	if (msg->msg_namelen)
+		return -EOPNOTSUPP;
+
+	if (sock->state != SS_CONNECTED)
+		return -ENOTCONN;
+
+	skb = sock_alloc_send_skb(sk, len, msg->msg_flags & MSG_DONTWAIT,
+									&rc);
+	if (!skb)
+		return rc;
+
+	rc = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len);
+	if (rc < 0) {
+		kfree_skb(skb);
+		return rc;
+	}
+
+	spin_lock_bh(&sk->sk_write_queue.lock);
+	__skb_queue_tail(&sk->sk_write_queue, skb);
+	if (!nfc_rawsock(sk)->tx_work_scheduled) {
+		schedule_work(&nfc_rawsock(sk)->tx_work);
+		nfc_rawsock(sk)->tx_work_scheduled = true;
+	}
+	spin_unlock_bh(&sk->sk_write_queue.lock);
+
+	return len;
+}
+
+static int rawsock_recvmsg(struct kiocb *iocb, struct socket *sock,
+				struct msghdr *msg, size_t len, int flags)
+{
+	int noblock = flags & MSG_DONTWAIT;
+	struct sock *sk = sock->sk;
+	struct sk_buff *skb;
+	int copied;
+	int rc;
+
+	NFC_DBG("");
+
+	skb = skb_recv_datagram(sk, flags, noblock, &rc);
+	if (!skb)
+		return rc;
+
+	msg->msg_namelen = 0;
+
+	copied = skb->len;
+	if (len < copied) {
+		msg->msg_flags |= MSG_TRUNC;
+		copied = len;
+	}
+
+	rc = skb_copy_datagram_iovec(skb, 0, msg->msg_iov, copied);
+
+	skb_free_datagram(sk, skb);
+
+	return rc ? : copied;
+}
+
+
+static const struct proto_ops rawsock_ops = {
+	.family         = PF_NFC,
+	.owner          = THIS_MODULE,
+	.release        = rawsock_release,
+	.bind           = sock_no_bind,
+	.connect        = rawsock_connect,
+	.socketpair     = sock_no_socketpair,
+	.accept         = sock_no_accept,
+	.getname        = sock_no_getname,
+	.poll           = datagram_poll,
+	.ioctl          = sock_no_ioctl,
+	.listen         = sock_no_listen,
+	.shutdown       = sock_no_shutdown,
+	.setsockopt     = sock_no_setsockopt,
+	.getsockopt     = sock_no_getsockopt,
+	.sendmsg        = rawsock_sendmsg,
+	.recvmsg        = rawsock_recvmsg,
+	.mmap           = sock_no_mmap,
+};
+
+static void rawsock_destruct(struct sock *sk)
+{
+	NFC_DBG("");
+
+	if (sk->sk_state == TCP_ESTABLISHED) {
+		nfc_deactivate_target(nfc_rawsock(sk)->dev,
+					nfc_rawsock(sk)->target_idx);
+		nfc_put_device(nfc_rawsock(sk)->dev);
+	}
+
+	skb_queue_purge(&sk->sk_receive_queue);
+
+	if (!sock_flag(sk, SOCK_DEAD)) {
+		NFC_ERR("Freeing alive NFC raw socket %p", sk);
+		return;
+	}
+}
+
+static int rawsock_create(struct net *net, struct socket *sock,
+				const struct nfc_protocol *nfc_proto)
+{
+	struct sock *sk;
+
+	NFC_DBG("");
+
+	if (sock->type != SOCK_SEQPACKET)
+		return -ESOCKTNOSUPPORT;
+
+	sock->ops = &rawsock_ops;
+
+	sk = sk_alloc(net, PF_NFC, GFP_KERNEL, nfc_proto->proto);
+	if (!sk)
+		return -ENOMEM;
+
+	sock_init_data(sock, sk);
+	sk->sk_protocol = nfc_proto->id;
+	sk->sk_destruct = rawsock_destruct;
+	sock->state = SS_UNCONNECTED;
+
+	INIT_WORK(&nfc_rawsock(sk)->tx_work, rawsock_tx_work);
+	nfc_rawsock(sk)->tx_work_scheduled = false;
+
+	return 0;
+}
+
+static struct proto rawsock_proto = {
+	.name     = "NFC_RAW",
+	.owner    = THIS_MODULE,
+	.obj_size = sizeof(struct nfc_rawsock),
+};
+
+static const struct nfc_protocol rawsock_nfc_proto = {
+	.id	  = NFC_SOCKPROTO_RAW,
+	.proto    = &rawsock_proto,
+	.owner    = THIS_MODULE,
+	.create   = rawsock_create
+};
+
+int __init rawsock_init(void)
+{
+	int rc;
+
+	NFC_DBG("");
+
+	rc = nfc_proto_register(&rawsock_nfc_proto);
+
+	return rc;
+}
+
+void rawsock_exit(void)
+{
+	NFC_DBG("");
+
+	nfc_proto_unregister(&rawsock_nfc_proto);
+}
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 5/6] NFC: pn533: add NXP pn533 nfc device driver
  2011-06-28 18:20 [PATCH v4 0/6] NFC subsystem Aloisio Almeida Jr
                   ` (3 preceding siblings ...)
  2011-06-28 18:20 ` [PATCH v4 4/6] NFC: add the NFC socket raw protocol Aloisio Almeida Jr
@ 2011-06-28 18:20 ` Aloisio Almeida Jr
  2011-06-28 18:20 ` [PATCH v4 6/6] NFC: add Documentation/networking/nfc.txt Aloisio Almeida Jr
  5 siblings, 0 replies; 38+ messages in thread
From: Aloisio Almeida Jr @ 2011-06-28 18:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, sameo, johannes, lauro.venancio, marcio.macedo,
	Waldemar.Rymarkiewicz, padovan, rdunlap, Aloisio Almeida Jr

Signed-off-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
Signed-off-by: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
---
 drivers/nfc/Kconfig  |   10 +
 drivers/nfc/Makefile |    1 +
 drivers/nfc/pn533.c  | 1630 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 1641 insertions(+), 0 deletions(-)
 create mode 100644 drivers/nfc/pn533.c

diff --git a/drivers/nfc/Kconfig b/drivers/nfc/Kconfig
index 7809289..2acff43 100644
--- a/drivers/nfc/Kconfig
+++ b/drivers/nfc/Kconfig
@@ -17,4 +17,14 @@ config PN544_NFC
 	  To compile this driver as a module, choose m here. The module will
 	  be called pn544.
 
+config NFC_PN533
+	tristate "NXP PN533 USB driver"
+	depends on USB
+	help
+	  NXP PN533 USB driver.
+	  This driver provides support for NFC NXP PN533 devices.
+
+	  Say Y here to compile support for PN533 devices into the
+	  kernel or say M to compile it as module (pn533).
+
 endmenu
diff --git a/drivers/nfc/Makefile b/drivers/nfc/Makefile
index 25296f0..8ef446d 100644
--- a/drivers/nfc/Makefile
+++ b/drivers/nfc/Makefile
@@ -3,5 +3,6 @@
 #
 
 obj-$(CONFIG_PN544_NFC)		+= pn544.o
+obj-$(CONFIG_NFC_PN533)		+= pn533.o
 
 ccflags-$(CONFIG_NFC_DEBUG) := -DDEBUG
diff --git a/drivers/nfc/pn533.c b/drivers/nfc/pn533.c
new file mode 100644
index 0000000..e860542
--- /dev/null
+++ b/drivers/nfc/pn533.c
@@ -0,0 +1,1630 @@
+/*
+ * Copyright (C) 2011 Instituto Nokia de Tecnologia
+ *
+ * Authors:
+ *    Lauro Ramos Venancio <lauro.venancio@openbossa.org>
+ *    Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/usb.h>
+#include <linux/nfc.h>
+#include <linux/netdevice.h>
+#include <net/nfc.h>
+
+#define VERSION "0.1"
+
+#define PN533_VENDOR_ID 0x4CC
+#define PN533_PRODUCT_ID 0x2533
+
+#define SCM_VENDOR_ID 0x4E6
+#define SCL3711_PRODUCT_ID 0x5591
+
+static const struct usb_device_id pn533_table[] = {
+	{ USB_DEVICE(PN533_VENDOR_ID, PN533_PRODUCT_ID) },
+	{ USB_DEVICE(SCM_VENDOR_ID, SCL3711_PRODUCT_ID) },
+	{ }
+};
+MODULE_DEVICE_TABLE(usb, pn533_table);
+
+/* frame definitions */
+#define PN533_FRAME_TAIL_SIZE 2
+#define PN533_FRAME_SIZE(f) (sizeof(struct pn533_frame) + f->datalen + \
+				PN533_FRAME_TAIL_SIZE)
+#define PN533_FRAME_ACK_SIZE (sizeof(struct pn533_frame) + 1)
+#define PN533_FRAME_CHECKSUM(f) (f->data[f->datalen])
+#define PN533_FRAME_POSTAMBLE(f) (f->data[f->datalen + 1])
+
+/* start of frame */
+#define PN533_SOF 0x00FF
+
+/* frame identifier: in/out/error */
+#define PN533_FRAME_IDENTIFIER(f) (f->data[0])
+#define PN533_DIR_OUT 0xD4
+#define PN533_DIR_IN 0xD5
+
+/* PN533 Commands */
+#define PN533_FRAME_CMD(f) (f->data[1])
+#define PN533_FRAME_CMD_PARAMS_PTR(f) (&f->data[2])
+#define PN533_FRAME_CMD_PARAMS_LEN(f) (f->datalen - 2)
+
+#define PN533_CMD_GET_FIRMWARE_VERSION 0x02
+#define PN533_CMD_RF_CONFIGURATION 0x32
+#define PN533_CMD_IN_DATA_EXCHANGE 0x40
+#define PN533_CMD_IN_LIST_PASSIVE_TARGET 0x4A
+#define PN533_CMD_IN_ATR 0x50
+#define PN533_CMD_IN_RELEASE 0x52
+
+#define PN533_CMD_RESPONSE(cmd) (cmd + 1)
+
+/* PN533 Return codes */
+#define PN533_CMD_RET_MASK 0x3F
+#define PN533_CMD_MI_MASK 0x40
+#define PN533_CMD_RET_SUCCESS 0x00
+
+struct pn533;
+
+typedef int (*pn533_cmd_complete_t) (struct pn533 *dev, void *arg,
+					u8 *params, int params_len);
+
+/* structs for pn533 commands */
+
+/* PN533_CMD_GET_FIRMWARE_VERSION */
+struct pn533_fw_version {
+	u8 ic;
+	u8 ver;
+	u8 rev;
+	u8 support;
+};
+
+/* PN533_CMD_RF_CONFIGURATION */
+#define PN533_CFGITEM_MAX_RETRIES 0x05
+
+#define PN533_CONFIG_MAX_RETRIES_NO_RETRY 0x00
+#define PN533_CONFIG_MAX_RETRIES_ENDLESS 0xFF
+
+struct pn533_config_max_retries {
+	u8 mx_rty_atr;
+	u8 mx_rty_psl;
+	u8 mx_rty_passive_act;
+} __packed;
+
+/* PN533_CMD_IN_LIST_PASSIVE_TARGET */
+
+/* felica commands opcode */
+#define PN533_FELICA_OPC_SENSF_REQ 0
+#define PN533_FELICA_OPC_SENSF_RES 1
+/* felica SENSF_REQ parameters */
+#define PN533_FELICA_SENSF_SC_ALL 0xFFFF
+#define PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE 0
+#define PN533_FELICA_SENSF_RC_SYSTEM_CODE 1
+#define PN533_FELICA_SENSF_RC_ADVANCED_PROTOCOL 2
+
+/* type B initiator_data values */
+#define PN533_TYPE_B_AFI_ALL_FAMILIES 0
+#define PN533_TYPE_B_POLL_METHOD_TIMESLOT 0
+#define PN533_TYPE_B_POLL_METHOD_PROBABILISTIC 1
+
+union pn533_cmd_poll_initdata {
+	struct {
+		u8 afi;
+		u8 polling_method;
+	} __packed type_b;
+	struct {
+		u8 opcode;
+		__be16 sc;
+		u8 rc;
+		u8 tsn;
+	} __packed felica;
+};
+
+/* Poll modulations */
+enum {
+	PN533_POLL_MOD_106KBPS_A,
+	PN533_POLL_MOD_212KBPS_FELICA,
+	PN533_POLL_MOD_424KBPS_FELICA,
+	PN533_POLL_MOD_106KBPS_JEWEL,
+	PN533_POLL_MOD_847KBPS_B,
+
+	__PN533_POLL_MOD_AFTER_LAST,
+};
+#define PN533_POLL_MOD_MAX (__PN533_POLL_MOD_AFTER_LAST - 1)
+
+struct pn533_poll_modulations {
+	struct {
+		u8 maxtg;
+		u8 brty;
+		union pn533_cmd_poll_initdata initiator_data;
+	} __packed data;
+	u8 len;
+};
+
+const struct pn533_poll_modulations poll_mod[] = {
+	[PN533_POLL_MOD_106KBPS_A] = {
+		.data = {
+			.maxtg = 1,
+			.brty = 0,
+		},
+		.len = 2,
+	},
+	[PN533_POLL_MOD_212KBPS_FELICA] = {
+		.data = {
+			.maxtg = 1,
+			.brty = 1,
+			.initiator_data.felica = {
+				.opcode = PN533_FELICA_OPC_SENSF_REQ,
+				.sc = PN533_FELICA_SENSF_SC_ALL,
+				.rc = PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE,
+				.tsn = 0,
+			},
+		},
+		.len = 7,
+	},
+	[PN533_POLL_MOD_424KBPS_FELICA] = {
+		.data = {
+			.maxtg = 1,
+			.brty = 2,
+			.initiator_data.felica = {
+				.opcode = PN533_FELICA_OPC_SENSF_REQ,
+				.sc = PN533_FELICA_SENSF_SC_ALL,
+				.rc = PN533_FELICA_SENSF_RC_NO_SYSTEM_CODE,
+				.tsn = 0,
+			},
+		 },
+		.len = 7,
+	},
+	[PN533_POLL_MOD_106KBPS_JEWEL] = {
+		.data = {
+			.maxtg = 1,
+			.brty = 4,
+		},
+		.len = 2,
+	},
+	[PN533_POLL_MOD_847KBPS_B] = {
+		.data = {
+			.maxtg = 1,
+			.brty = 8,
+			.initiator_data.type_b = {
+				.afi = PN533_TYPE_B_AFI_ALL_FAMILIES,
+				.polling_method =
+					PN533_TYPE_B_POLL_METHOD_TIMESLOT,
+			},
+		},
+		.len = 3,
+	},
+};
+
+/* PN533_CMD_IN_ATR */
+
+struct pn533_cmd_activate_param {
+	u8 tg;
+	u8 next;
+} __packed;
+
+struct pn533_cmd_activate_response {
+	u8 status;
+	u8 nfcid3t[10];
+	u8 didt;
+	u8 bst;
+	u8 brt;
+	u8 to;
+	u8 ppt;
+	/* optional */
+	u8 gt[];
+} __packed;
+
+
+struct pn533 {
+	struct usb_device *udev;
+	struct usb_interface *interface;
+	struct nfc_dev *nfc_dev;
+
+	struct urb *out_urb;
+	int out_maxlen;
+	struct pn533_frame *out_frame;
+
+	struct urb *in_urb;
+	int in_maxlen;
+	struct pn533_frame *in_frame;
+
+	struct tasklet_struct tasklet;
+	struct pn533_frame *tklt_in_frame;
+	int tklt_in_error;
+
+	pn533_cmd_complete_t cmd_complete;
+	void *cmd_complete_arg;
+	struct semaphore cmd_lock;
+	u8 cmd;
+
+	struct pn533_poll_modulations *poll_mod_active[PN533_POLL_MOD_MAX + 1];
+	u8 poll_mod_count;
+	u8 poll_mod_curr;
+	u32 poll_protocols;
+
+	u8 tgt_available_prots;
+	u8 tgt_active_prot;
+};
+
+struct pn533_frame {
+	u8 preamble;
+	__be16 start_frame;
+	u8 datalen;
+	u8 datalen_checksum;
+	u8 data[];
+} __packed;
+
+/* The rule: value + checksum = 0 */
+static inline u8 pn533_checksum(u8 value)
+{
+	return ~value + 1;
+}
+
+/* The rule: sum(data elements) + checksum = 0 */
+static u8 pn533_data_checksum(u8 *data, int datalen)
+{
+	u8 sum = 0;
+	int i;
+
+	for (i = 0; i < datalen; i++)
+		sum += data[i];
+
+	return pn533_checksum(sum);
+}
+
+/**
+ * pn533_tx_frame_ack - create a ack frame
+ * @frame:	The frame to be set as ack
+ *
+ * Ack is different type of standard frame. As a standard frame, it has
+ * preamble and start_frame. However the checksum of this frame must fail,
+ * i.e. datalen + datalen_checksum must NOT be zero. When the checksum test
+ * fails and datalen = 0 and datalen_checksum = 0xFF, the frame is a ack.
+ * After datalen_checksum field, the postamble is placed.
+ */
+static void pn533_tx_frame_ack(struct pn533_frame *frame)
+{
+	frame->preamble = 0;
+	frame->start_frame = cpu_to_be16(PN533_SOF);
+	frame->datalen = 0;
+	frame->datalen_checksum = 0xFF;
+	/* data[0] is used as postamble */
+	frame->data[0] = 0;
+}
+
+static void pn533_tx_frame_init(struct pn533_frame *frame, u8 cmd)
+{
+	frame->preamble = 0;
+	frame->start_frame = cpu_to_be16(PN533_SOF);
+	PN533_FRAME_IDENTIFIER(frame) = PN533_DIR_OUT;
+	PN533_FRAME_CMD(frame) = cmd;
+	frame->datalen = 2;
+}
+
+static void pn533_tx_frame_finish(struct pn533_frame *frame)
+{
+	frame->datalen_checksum = pn533_checksum(frame->datalen);
+
+	PN533_FRAME_CHECKSUM(frame) =
+		pn533_data_checksum(frame->data, frame->datalen);
+
+	PN533_FRAME_POSTAMBLE(frame) = 0;
+}
+
+static bool pn533_rx_frame_is_valid(struct pn533_frame *frame)
+{
+	u8 checksum;
+
+	if (frame->start_frame != cpu_to_be16(PN533_SOF))
+		return false;
+
+	checksum = pn533_checksum(frame->datalen);
+	if (checksum != frame->datalen_checksum)
+		return false;
+
+	checksum = pn533_data_checksum(frame->data, frame->datalen);
+	if (checksum != PN533_FRAME_CHECKSUM(frame))
+		return false;
+
+	return true;
+}
+
+static bool pn533_rx_frame_is_ack(struct pn533_frame *frame)
+{
+	if (frame->start_frame != cpu_to_be16(PN533_SOF))
+		return false;
+
+	if (frame->datalen != 0 || frame->datalen_checksum != 0xFF)
+		return false;
+
+	return true;
+}
+
+static bool pn533_rx_frame_is_cmd_response(struct pn533_frame *frame, u8 cmd)
+{
+	return (PN533_FRAME_CMD(frame) == PN533_CMD_RESPONSE(cmd));
+}
+
+static void pn533_tasklet_cmd_complete(unsigned long arg)
+{
+	struct pn533 *dev = (struct pn533 *) arg;
+	struct pn533_frame *in_frame = dev->tklt_in_frame;
+	int rc;
+
+	if (dev->tklt_in_error)
+		rc = dev->cmd_complete(dev, dev->cmd_complete_arg, NULL,
+							dev->tklt_in_error);
+	else
+		rc = dev->cmd_complete(dev, dev->cmd_complete_arg,
+					PN533_FRAME_CMD_PARAMS_PTR(in_frame),
+					PN533_FRAME_CMD_PARAMS_LEN(in_frame));
+
+	if (rc != -EINPROGRESS)
+		up(&dev->cmd_lock);
+}
+
+static void pn533_recv_response(struct urb *urb)
+{
+	struct pn533 *dev = urb->context;
+	struct pn533_frame *in_frame;
+
+	dev->tklt_in_frame = NULL;
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		dev_dbg(&dev->interface->dev, "%s - urb shutting down with "
+					"status: %d", __func__, urb->status);
+		dev->tklt_in_error = urb->status;
+		goto sched_tasklet;
+	default:
+		dev_err(&dev->interface->dev, "%s - nonzero urb status "
+				"received: %d", __func__, urb->status);
+		dev->tklt_in_error = urb->status;
+		goto sched_tasklet;
+	}
+
+	in_frame = dev->in_urb->transfer_buffer;
+
+	if (!pn533_rx_frame_is_valid(in_frame)) {
+		dev_err(&dev->interface->dev, "Received an invalid frame");
+		dev->tklt_in_error = -EIO;
+		goto sched_tasklet;
+	}
+
+	if (!pn533_rx_frame_is_cmd_response(in_frame, dev->cmd)) {
+		dev_err(&dev->interface->dev, "The received frame is not "
+					"response to the last command");
+		dev->tklt_in_error = -EIO;
+		goto sched_tasklet;
+	}
+
+	dev_dbg(&dev->interface->dev, "Received a valid frame");
+	dev->tklt_in_error = 0;
+	dev->tklt_in_frame = in_frame;
+
+sched_tasklet:
+	tasklet_schedule(&dev->tasklet);
+}
+
+static int pn533_submit_urb_for_response(struct pn533 *dev, gfp_t flags)
+{
+	dev->in_urb->complete = pn533_recv_response;
+
+	return usb_submit_urb(dev->in_urb, flags);
+}
+
+static void pn533_recv_ack(struct urb *urb)
+{
+	struct pn533 *dev = urb->context;
+	struct pn533_frame *in_frame;
+	int rc;
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		dev_dbg(&dev->interface->dev, "%s - urb shutting down with "
+					"status: %d", __func__, urb->status);
+		dev->tklt_in_error = urb->status;
+		goto sched_tasklet;
+	default:
+		dev_err(&dev->interface->dev, "%s - nonzero urb status "
+				"received: %d", __func__, urb->status);
+		dev->tklt_in_error = urb->status;
+		goto sched_tasklet;
+	}
+
+	in_frame = dev->in_urb->transfer_buffer;
+
+	if (!pn533_rx_frame_is_ack(in_frame)) {
+		dev_err(&dev->interface->dev, "%s - received an invalid ack",
+								__func__);
+		dev->tklt_in_error = -EIO;
+		goto sched_tasklet;
+	}
+
+	dev_dbg(&dev->interface->dev, "Received a valid ack");
+
+	rc = pn533_submit_urb_for_response(dev, GFP_ATOMIC);
+	if (rc) {
+		dev_err(&dev->interface->dev, "%s - usb_submit_urb failed "
+					"with result %d", __func__, rc);
+		dev->tklt_in_error = rc;
+		goto sched_tasklet;
+	}
+
+	return;
+
+sched_tasklet:
+	dev->tklt_in_frame = NULL;
+	tasklet_schedule(&dev->tasklet);
+}
+
+static int pn533_submit_urb_for_ack(struct pn533 *dev, gfp_t flags)
+{
+	dev->in_urb->complete = pn533_recv_ack;
+
+	return usb_submit_urb(dev->in_urb, flags);
+}
+
+static int pn533_send_ack(struct pn533 *dev, gfp_t flags)
+{
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "Sending ack");
+
+	pn533_tx_frame_ack(dev->out_frame);
+
+	dev->out_urb->transfer_buffer = dev->out_frame;
+	dev->out_urb->transfer_buffer_length = PN533_FRAME_ACK_SIZE;
+	rc = usb_submit_urb(dev->out_urb, flags);
+
+	return rc;
+}
+
+static int __pn533_send_cmd_frame_async(struct pn533 *dev,
+					struct pn533_frame *out_frame,
+					struct pn533_frame *in_frame,
+					int in_frame_len,
+					pn533_cmd_complete_t cmd_complete,
+					void *arg, gfp_t flags)
+{
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "Sending command 0x%x",
+				PN533_FRAME_CMD(out_frame));
+
+	dev->cmd = PN533_FRAME_CMD(out_frame);
+	dev->cmd_complete = cmd_complete;
+	dev->cmd_complete_arg = arg;
+
+	dev->out_urb->transfer_buffer = out_frame;
+	dev->out_urb->transfer_buffer_length =
+				PN533_FRAME_SIZE(out_frame);
+
+	dev->in_urb->transfer_buffer = in_frame;
+	dev->in_urb->transfer_buffer_length = in_frame_len;
+
+	rc = usb_submit_urb(dev->out_urb, flags);
+	if (rc)
+		return rc;
+
+	rc = pn533_submit_urb_for_ack(dev, flags);
+	if (rc)
+		goto error;
+
+	return 0;
+
+error:
+	usb_unlink_urb(dev->out_urb);
+	return rc;
+}
+
+static int pn533_send_cmd_frame_async(struct pn533 *dev,
+					struct pn533_frame *out_frame,
+					struct pn533_frame *in_frame,
+					int in_frame_len,
+					pn533_cmd_complete_t cmd_complete,
+					void *arg, gfp_t flags)
+{
+	int rc;
+
+	if (down_trylock(&dev->cmd_lock))
+		return -EBUSY;
+
+	rc = __pn533_send_cmd_frame_async(dev, out_frame, in_frame,
+					in_frame_len, cmd_complete, arg, flags);
+	if (rc)
+		goto error;
+
+	return 0;
+error:
+	up(&dev->cmd_lock);
+	return rc;
+}
+
+struct pn533_sync_cmd_response {
+	int rc;
+	struct completion done;
+};
+
+static int pn533_sync_cmd_complete(struct pn533 *dev, void *_arg,
+					u8 *params, int params_len)
+{
+	struct pn533_sync_cmd_response *arg = _arg;
+
+	arg->rc = 0;
+
+	if (params_len < 0) /* error */
+		arg->rc = params_len;
+
+	complete(&arg->done);
+
+	return 0;
+}
+
+static int pn533_send_cmd_frame_sync(struct pn533 *dev,
+						struct pn533_frame *out_frame,
+						struct pn533_frame *in_frame,
+						int in_frame_len)
+{
+	int rc;
+	struct pn533_sync_cmd_response arg;
+
+	init_completion(&arg.done);
+
+	rc = pn533_send_cmd_frame_async(dev, out_frame, in_frame, in_frame_len,
+				pn533_sync_cmd_complete, &arg, GFP_KERNEL);
+	if (rc)
+		return rc;
+
+	wait_for_completion(&arg.done);
+
+	return arg.rc;
+}
+
+static void pn533_send_complete(struct urb *urb)
+{
+	struct pn533 *dev = urb->context;
+
+	switch (urb->status) {
+	case 0:
+		/* success */
+		break;
+	case -ECONNRESET:
+	case -ENOENT:
+	case -ESHUTDOWN:
+		dev_dbg(&dev->interface->dev, "%s - urb shutting down with "
+			"status: %d", __func__, urb->status);
+		break;
+	default:
+		dev_dbg(&dev->interface->dev, "%s - nonzero urb status "
+				"received: %d", __func__, urb->status);
+	}
+}
+
+struct pn533_target_type_a {
+	__be16 sens_res;
+	u8 sel_res;
+	u8 nfcid_len;
+	u8 nfcid_data[];
+} __packed;
+
+
+#define PN533_TYPE_A_SENS_RES_NFCID1(x) ((u8)((be16_to_cpu(x) & 0x00C0) >> 6))
+#define PN533_TYPE_A_SENS_RES_SSD(x) ((u8)((be16_to_cpu(x) & 0x001F) >> 0))
+#define PN533_TYPE_A_SENS_RES_PLATCONF(x) ((u8)((be16_to_cpu(x) & 0x0F00) >> 8))
+
+#define PN533_TYPE_A_SENS_RES_SSD_JEWEL 0x00
+#define PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL 0x0C
+
+#define PN533_TYPE_A_SEL_PROT(x) (((x) & 0x60) >> 5)
+#define PN533_TYPE_A_SEL_CASCADE(x) (((x) & 0x04) >> 2)
+
+#define PN533_TYPE_A_SEL_PROT_MIFARE 0
+#define PN533_TYPE_A_SEL_PROT_ISO14443 1
+#define PN533_TYPE_A_SEL_PROT_DEP 2
+#define PN533_TYPE_A_SEL_PROT_ISO14443_DEP 3
+
+static bool pn533_target_type_a_is_valid(struct pn533_target_type_a *type_a,
+							int target_data_len)
+{
+	u8 ssd;
+	u8 platconf;
+
+	if (target_data_len < sizeof(struct pn533_target_type_a))
+		return false;
+
+	/* The lenght check of nfcid[] and ats[] are not being performed because
+	   the values are not being used */
+
+	/* Requirement 4.6.3.3 from NFC Forum Digital Spec */
+	ssd = PN533_TYPE_A_SENS_RES_SSD(type_a->sens_res);
+	platconf = PN533_TYPE_A_SENS_RES_PLATCONF(type_a->sens_res);
+
+	if ((ssd == PN533_TYPE_A_SENS_RES_SSD_JEWEL &&
+			platconf != PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL) ||
+			(ssd != PN533_TYPE_A_SENS_RES_SSD_JEWEL &&
+			platconf == PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL))
+		return false;
+
+	/* Requirements 4.8.2.1, 4.8.2.3, 4.8.2.5 and 4.8.2.7 from NFC Forum */
+	if (PN533_TYPE_A_SEL_CASCADE(type_a->sel_res) != 0)
+		return false;
+
+	return true;
+}
+
+static int pn533_target_found_type_a(struct nfc_target *nfc_tgt, u8 *tgt_data,
+							int tgt_data_len)
+{
+	struct pn533_target_type_a *tgt_type_a;
+
+	tgt_type_a = (struct pn533_target_type_a *) tgt_data;
+
+	if (!pn533_target_type_a_is_valid(tgt_type_a, tgt_data_len))
+		return -EPROTO;
+
+	switch (PN533_TYPE_A_SEL_PROT(tgt_type_a->sel_res)) {
+	case PN533_TYPE_A_SEL_PROT_MIFARE:
+		nfc_tgt->supported_protocols = NFC_PROTO_MIFARE_MASK;
+		break;
+	case PN533_TYPE_A_SEL_PROT_ISO14443:
+		nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK;
+		break;
+	case PN533_TYPE_A_SEL_PROT_DEP:
+		nfc_tgt->supported_protocols = NFC_PROTO_NFC_DEP_MASK;
+		break;
+	case PN533_TYPE_A_SEL_PROT_ISO14443_DEP:
+		nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK |
+							NFC_PROTO_NFC_DEP_MASK;
+		break;
+	}
+
+	nfc_tgt->sens_res = be16_to_cpu(tgt_type_a->sens_res);
+	nfc_tgt->sel_res = tgt_type_a->sel_res;
+
+	return 0;
+}
+
+struct pn533_target_felica {
+	u8 pol_res;
+	u8 opcode;
+	u8 nfcid2[8];
+	u8 pad[8];
+	/* optional */
+	u8 syst_code[];
+} __packed;
+
+#define PN533_FELICA_SENSF_NFCID2_DEP_B1 0x01
+#define PN533_FELICA_SENSF_NFCID2_DEP_B2 0xFE
+
+static bool pn533_target_felica_is_valid(struct pn533_target_felica *felica,
+							int target_data_len)
+{
+	if (target_data_len < sizeof(struct pn533_target_felica))
+		return false;
+
+	if (felica->opcode != PN533_FELICA_OPC_SENSF_RES)
+		return false;
+
+	return true;
+}
+
+static int pn533_target_found_felica(struct nfc_target *nfc_tgt, u8 *tgt_data,
+							int tgt_data_len)
+{
+	struct pn533_target_felica *tgt_felica;
+
+	tgt_felica = (struct pn533_target_felica *) tgt_data;
+
+	if (!pn533_target_felica_is_valid(tgt_felica, tgt_data_len))
+		return -EPROTO;
+
+	if (tgt_felica->nfcid2[0] == PN533_FELICA_SENSF_NFCID2_DEP_B1 &&
+					tgt_felica->nfcid2[1] ==
+					PN533_FELICA_SENSF_NFCID2_DEP_B2)
+		nfc_tgt->supported_protocols = NFC_PROTO_NFC_DEP_MASK;
+	else
+		nfc_tgt->supported_protocols = NFC_PROTO_FELICA_MASK;
+
+	return 0;
+}
+
+struct pn533_target_jewel {
+	__be16 sens_res;
+	u8 jewelid[4];
+} __packed;
+
+static bool pn533_target_jewel_is_valid(struct pn533_target_jewel *jewel,
+							int target_data_len)
+{
+	u8 ssd;
+	u8 platconf;
+
+	if (target_data_len < sizeof(struct pn533_target_jewel))
+		return false;
+
+	/* Requirement 4.6.3.3 from NFC Forum Digital Spec */
+	ssd = PN533_TYPE_A_SENS_RES_SSD(jewel->sens_res);
+	platconf = PN533_TYPE_A_SENS_RES_PLATCONF(jewel->sens_res);
+
+	if ((ssd == PN533_TYPE_A_SENS_RES_SSD_JEWEL &&
+			platconf != PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL) ||
+			(ssd != PN533_TYPE_A_SENS_RES_SSD_JEWEL &&
+			platconf == PN533_TYPE_A_SENS_RES_PLATCONF_JEWEL))
+		return false;
+
+	return true;
+}
+
+static int pn533_target_found_jewel(struct nfc_target *nfc_tgt, u8 *tgt_data,
+							int tgt_data_len)
+{
+	struct pn533_target_jewel *tgt_jewel;
+
+	tgt_jewel = (struct pn533_target_jewel *) tgt_data;
+
+	if (!pn533_target_jewel_is_valid(tgt_jewel, tgt_data_len))
+		return -EPROTO;
+
+	nfc_tgt->supported_protocols = NFC_PROTO_JEWEL_MASK;
+	nfc_tgt->sens_res = be16_to_cpu(tgt_jewel->sens_res);
+
+	return 0;
+}
+
+struct pn533_type_b_prot_info {
+	u8 bitrate;
+	u8 fsci_type;
+	u8 fwi_adc_fo;
+} __packed;
+
+#define PN533_TYPE_B_PROT_FCSI(x) (((x) & 0xF0) >> 4)
+#define PN533_TYPE_B_PROT_TYPE(x) (((x) & 0x0F) >> 0)
+#define PN533_TYPE_B_PROT_TYPE_RFU_MASK 0x8
+
+struct pn533_type_b_sens_res {
+	u8 opcode;
+	u8 nfcid[4];
+	u8 appdata[4];
+	struct pn533_type_b_prot_info prot_info;
+} __packed;
+
+#define PN533_TYPE_B_OPC_SENSB_RES 0x50
+
+struct pn533_target_type_b {
+	struct pn533_type_b_sens_res sensb_res;
+	u8 attrib_res_len;
+	u8 attrib_res[];
+} __packed;
+
+static bool pn533_target_type_b_is_valid(struct pn533_target_type_b *type_b,
+							int target_data_len)
+{
+	if (target_data_len < sizeof(struct pn533_target_type_b))
+		return false;
+
+	if (type_b->sensb_res.opcode != PN533_TYPE_B_OPC_SENSB_RES)
+		return false;
+
+	if (PN533_TYPE_B_PROT_TYPE(type_b->sensb_res.prot_info.fsci_type) &
+						PN533_TYPE_B_PROT_TYPE_RFU_MASK)
+		return false;
+
+	return true;
+}
+
+static int pn533_target_found_type_b(struct nfc_target *nfc_tgt, u8 *tgt_data,
+							int tgt_data_len)
+{
+	struct pn533_target_type_b *tgt_type_b;
+
+	tgt_type_b = (struct pn533_target_type_b *) tgt_data;
+
+	if (!pn533_target_type_b_is_valid(tgt_type_b, tgt_data_len))
+		return -EPROTO;
+
+	nfc_tgt->supported_protocols = NFC_PROTO_ISO14443_MASK;
+
+	return 0;
+}
+
+struct pn533_poll_response {
+	u8 nbtg;
+	u8 tg;
+	u8 target_data[];
+} __packed;
+
+static int pn533_target_found(struct pn533 *dev,
+			struct pn533_poll_response *resp, int resp_len)
+{
+	int target_data_len;
+	struct nfc_target nfc_tgt;
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "%s - Target found - modulation=%d",
+						__func__, dev->poll_mod_curr);
+
+	if (resp->tg != 1)
+		return -EPROTO;
+
+	target_data_len = resp_len - sizeof(struct pn533_poll_response);
+
+	switch (dev->poll_mod_curr) {
+	case PN533_POLL_MOD_106KBPS_A:
+		rc = pn533_target_found_type_a(&nfc_tgt, resp->target_data,
+							target_data_len);
+		break;
+	case PN533_POLL_MOD_212KBPS_FELICA:
+	case PN533_POLL_MOD_424KBPS_FELICA:
+		rc = pn533_target_found_felica(&nfc_tgt, resp->target_data,
+							target_data_len);
+		break;
+	case PN533_POLL_MOD_106KBPS_JEWEL:
+		rc = pn533_target_found_jewel(&nfc_tgt, resp->target_data,
+							target_data_len);
+		break;
+	case PN533_POLL_MOD_847KBPS_B:
+		rc = pn533_target_found_type_b(&nfc_tgt, resp->target_data,
+							target_data_len);
+		break;
+	default:
+		dev_err(&dev->interface->dev, "%s - Unknown current poll"
+						" modulation", __func__);
+		return -EPROTO;
+	}
+
+	if (rc)
+		return rc;
+
+	if (!(nfc_tgt.supported_protocols & dev->poll_protocols)) {
+		dev_dbg(&dev->interface->dev, "%s - The target found does not"
+					" have the desired protocol", __func__);
+		return -EAGAIN;
+	}
+
+	dev_dbg(&dev->interface->dev, "%s - Target found - protocols=0x%x",
+				 __func__, nfc_tgt.supported_protocols);
+
+	dev->tgt_available_prots = nfc_tgt.supported_protocols;
+
+	nfc_targets_found(dev->nfc_dev, &nfc_tgt, 1);
+
+	return 0;
+}
+
+static void pn533_poll_reset_mod_list(struct pn533 *dev)
+{
+	dev->poll_mod_count = 0;
+}
+
+static void pn533_poll_add_mod(struct pn533 *dev, u8 mod_index)
+{
+	dev->poll_mod_active[dev->poll_mod_count] =
+		(struct pn533_poll_modulations *) &poll_mod[mod_index];
+	dev->poll_mod_count++;
+}
+
+static void pn533_poll_create_mod_list(struct pn533 *dev, u32 protocols)
+{
+	pn533_poll_reset_mod_list(dev);
+
+	if (protocols & NFC_PROTO_MIFARE_MASK
+					|| protocols & NFC_PROTO_ISO14443_MASK
+					|| protocols & NFC_PROTO_NFC_DEP_MASK)
+		pn533_poll_add_mod(dev, PN533_POLL_MOD_106KBPS_A);
+
+	if (protocols & NFC_PROTO_FELICA_MASK
+					|| protocols & NFC_PROTO_NFC_DEP_MASK) {
+		pn533_poll_add_mod(dev, PN533_POLL_MOD_212KBPS_FELICA);
+		pn533_poll_add_mod(dev, PN533_POLL_MOD_424KBPS_FELICA);
+	}
+
+	if (protocols & NFC_PROTO_JEWEL_MASK)
+		pn533_poll_add_mod(dev, PN533_POLL_MOD_106KBPS_JEWEL);
+
+	if (protocols & NFC_PROTO_ISO14443_MASK)
+		pn533_poll_add_mod(dev, PN533_POLL_MOD_847KBPS_B);
+}
+
+static void pn533_start_poll_frame(struct pn533_frame *frame,
+					struct pn533_poll_modulations *mod)
+{
+
+	pn533_tx_frame_init(frame, PN533_CMD_IN_LIST_PASSIVE_TARGET);
+
+	memcpy(PN533_FRAME_CMD_PARAMS_PTR(frame), &mod->data, mod->len);
+	frame->datalen += mod->len;
+
+	pn533_tx_frame_finish(frame);
+}
+
+static int pn533_start_poll_complete(struct pn533 *dev, void *arg,
+						u8 *params, int params_len)
+{
+	struct pn533_poll_response *resp;
+	struct pn533_poll_modulations *next_mod;
+	int rc;
+
+	if (params_len == -ENOENT) {
+		dev_dbg(&dev->interface->dev, "%s - poll has been stopped",
+								__func__);
+		goto stop_poll;
+	}
+
+	if (params_len < 0) {
+		dev_err(&dev->interface->dev, "%s - error %d when running poll",
+							__func__, params_len);
+		goto stop_poll;
+	}
+
+	resp = (struct pn533_poll_response *) params;
+	if (resp->nbtg) {
+		rc = pn533_target_found(dev, resp, params_len);
+
+		/* We must stop the poll after a valid target found */
+		if (rc == 0)
+			goto stop_poll;
+
+		if (rc != -EAGAIN)
+			dev_err(&dev->interface->dev, "%s - The target found is"
+						" not valid, continue to poll",
+						__func__);
+	}
+
+	dev->poll_mod_curr = (dev->poll_mod_curr + 1) % dev->poll_mod_count;
+
+	next_mod = dev->poll_mod_active[dev->poll_mod_curr];
+
+	dev_dbg(&dev->interface->dev, "%s - poll next modulation (0x%x)",
+						__func__, dev->poll_mod_curr);
+
+	pn533_start_poll_frame(dev->out_frame, next_mod);
+
+	/* Don't need to down the semaphore again */
+	rc = __pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame,
+				dev->in_maxlen, pn533_start_poll_complete,
+				NULL, GFP_ATOMIC);
+
+	if (rc == -EPERM) {
+		dev_dbg(&dev->interface->dev, "%s - cannot poll next modulation"
+				" because poll has been stopped", __func__);
+		goto stop_poll;
+	}
+
+	if (rc) {
+		dev_err(&dev->interface->dev, "%s - error %d when trying to"
+				" poll next modulation", __func__, rc);
+		goto stop_poll;
+	}
+
+	/* Inform caller function to do not up the semaphore */
+	return -EINPROGRESS;
+
+stop_poll:
+	pn533_poll_reset_mod_list(dev);
+	dev->poll_protocols = 0;
+	return 0;
+}
+
+static int pn533_start_poll(struct nfc_dev *nfc_dev, u32 protocols)
+{
+	struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+	struct pn533_poll_modulations *start_mod;
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "%s - protocols=0x%x", __func__,
+								protocols);
+
+	if (dev->poll_mod_count) {
+		dev_err(&dev->interface->dev, "%s - "
+				"poll already active", __func__);
+		return -EBUSY;
+	}
+
+	if (dev->tgt_active_prot) {
+		dev_err(&dev->interface->dev, "%s - cannot poll with a target"
+						" already activated", __func__);
+		return -EBUSY;
+	}
+
+	pn533_poll_create_mod_list(dev, protocols);
+
+	if (!dev->poll_mod_count) {
+		dev_err(&dev->interface->dev, "%s - "
+				"no valid protocols specified", __func__);
+		rc = -EINVAL;
+		goto error;
+	}
+
+	dev_dbg(&dev->interface->dev, "%s - poll %d modulations types",
+					__func__, dev->poll_mod_count);
+
+	dev->poll_mod_curr = 0;
+	start_mod = dev->poll_mod_active[dev->poll_mod_curr];
+
+	pn533_start_poll_frame(dev->out_frame, start_mod);
+
+	rc = pn533_send_cmd_frame_async(dev, dev->out_frame, dev->in_frame,
+				dev->in_maxlen,	pn533_start_poll_complete,
+				NULL, GFP_KERNEL);
+
+	if (rc) {
+		dev_err(&dev->interface->dev, "%s - error %d when trying to"
+						" start poll", __func__, rc);
+		goto error;
+	}
+
+	dev->poll_protocols = protocols;
+
+	return 0;
+
+error:
+	pn533_poll_reset_mod_list(dev);
+	return rc;
+}
+
+static void pn533_stop_poll(struct nfc_dev *nfc_dev)
+{
+	struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+
+	dev_dbg(&dev->interface->dev, "%s", __func__);
+
+	if (!dev->poll_mod_count) {
+		dev_dbg(&dev->interface->dev, "%s - polling was not running",
+								__func__);
+		return;
+	}
+
+	/* An ack will cancel the last issued command (poll) */
+	pn533_send_ack(dev, GFP_KERNEL);
+
+	/* prevent pn533_start_poll_complete to issue a new poll meanwhile */
+	usb_kill_urb(dev->in_urb);
+}
+
+static int pn533_activate_target_nfcdep(struct pn533 *dev)
+{
+	struct pn533_cmd_activate_param param;
+	struct pn533_cmd_activate_response *resp;
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "%s", __func__);
+
+	pn533_tx_frame_init(dev->out_frame, PN533_CMD_IN_ATR);
+
+	param.tg = 1;
+	param.next = 0;
+	memcpy(PN533_FRAME_CMD_PARAMS_PTR(dev->out_frame), &param,
+				sizeof(struct pn533_cmd_activate_param));
+	dev->out_frame->datalen += sizeof(struct pn533_cmd_activate_param);
+
+	pn533_tx_frame_finish(dev->out_frame);
+
+	rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame,
+								dev->in_maxlen);
+	if (rc)
+		return rc;
+
+	resp = (struct pn533_cmd_activate_response *)
+				PN533_FRAME_CMD_PARAMS_PTR(dev->in_frame);
+	rc = resp->status & PN533_CMD_RET_MASK;
+	if (rc != PN533_CMD_RET_SUCCESS)
+		return -EIO;
+
+	return 0;
+}
+
+static int pn533_activate_target(struct nfc_dev *nfc_dev, u32 target_idx,
+								u32 protocol)
+{
+	struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "%s", __func__);
+
+	if (dev->poll_mod_count) {
+		dev_err(&dev->interface->dev, "%s - Cannot activate while"
+							" polling", __func__);
+		return -EBUSY;
+	}
+
+	if (dev->tgt_active_prot) {
+		dev_err(&dev->interface->dev, "%s - There is a target already"
+							" activated", __func__);
+		return -EBUSY;
+	}
+
+	if (!dev->tgt_available_prots) {
+		dev_err(&dev->interface->dev, "%s - There is no target"
+					" available to be activated", __func__);
+		return -EINVAL;
+	}
+
+	if (!(dev->tgt_available_prots & (1 << protocol))) {
+		dev_err(&dev->interface->dev, "%s - The found target does not"
+					" support the requested protocol %u",
+					__func__, protocol);
+		return -EINVAL;
+	}
+
+	dev_dbg(&dev->interface->dev, "%s - Activating target with protocol"
+						" %u", __func__, protocol);
+
+	if (protocol == NFC_PROTO_NFC_DEP) {
+		rc = pn533_activate_target_nfcdep(dev);
+		if (rc) {
+			dev_err(&dev->interface->dev, "%s - Error %d when "
+					" activating target with NFC_DEP"
+					" protocol", __func__, rc);
+			return rc;
+		}
+	}
+
+	dev->tgt_active_prot = protocol;
+	dev->tgt_available_prots = 0;
+
+	return 0;
+}
+
+static void pn533_deactivate_target(struct nfc_dev *nfc_dev, u32 target_idx)
+{
+	struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+	u8 tg;
+	u8 status;
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "%s", __func__);
+
+	if (!dev->tgt_active_prot) {
+		dev_err(&dev->interface->dev, "%s - There is no activated"
+							" target", __func__);
+		return;
+	}
+
+	dev_dbg(&dev->interface->dev, "%s - Deactivating target with protocol"
+				" %u", __func__, dev->tgt_active_prot);
+
+	dev->tgt_active_prot = 0;
+
+	pn533_tx_frame_init(dev->out_frame, PN533_CMD_IN_RELEASE);
+
+	tg = 1;
+	memcpy(PN533_FRAME_CMD_PARAMS_PTR(dev->out_frame), &tg, sizeof(u8));
+	dev->out_frame->datalen += sizeof(u8);
+
+	pn533_tx_frame_finish(dev->out_frame);
+
+	rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame,
+								dev->in_maxlen);
+	if (rc) {
+		dev_err(&dev->interface->dev, "%s - Error when sending release"
+					" command to the controller", __func__);
+		return;
+	}
+
+	status = PN533_FRAME_CMD_PARAMS_PTR(dev->in_frame)[0];
+	rc = status & PN533_CMD_RET_MASK;
+	if (rc != PN533_CMD_RET_SUCCESS)
+		dev_err(&dev->interface->dev, "%s - Error 0x%x when releasing"
+						" the target", __func__, rc);
+
+	return;
+}
+
+#define PN533_CMD_DATAEXCH_HEAD_LEN (sizeof(struct pn533_frame) + 3)
+#define PN533_CMD_DATAEXCH_DATA_MAXLEN 262
+
+static int pn533_data_exchange_tx_frame(struct pn533 *dev, struct sk_buff *skb)
+{
+	int payload_len = skb->len;
+	struct pn533_frame *out_frame;
+	struct sk_buff *discarded;
+	u8 tg;
+
+	dev_dbg(&dev->interface->dev, "%s - Sending %d bytes", __func__,
+								payload_len);
+
+	if (payload_len > PN533_CMD_DATAEXCH_DATA_MAXLEN) {
+		/* TODO: Implement support to multi-part data exchange */
+		dev_err(&dev->interface->dev, "%s - Data length greater than"
+					" the max allowed: %d", __func__,
+					PN533_CMD_DATAEXCH_DATA_MAXLEN);
+		return -ENOSYS;
+	}
+
+	/* Reserving header space */
+	if (skb_cow_head(skb, PN533_CMD_DATAEXCH_HEAD_LEN)) {
+		dev_err(&dev->interface->dev, "%s - Error to add header data",
+								__func__);
+		return -ENOMEM;
+	}
+
+	/* Reserving tail space, see pn533_tx_frame_finish */
+	if (skb_cow_data(skb, PN533_FRAME_TAIL_SIZE, &discarded) < 0) {
+		dev_err(&dev->interface->dev, "%s - Error to add tail data",
+							__func__);
+		return -ENOMEM;
+	}
+
+	skb_push(skb, PN533_CMD_DATAEXCH_HEAD_LEN);
+	out_frame = (struct pn533_frame *) skb->data;
+
+	pn533_tx_frame_init(out_frame, PN533_CMD_IN_DATA_EXCHANGE);
+
+	tg = 1;
+	memcpy(PN533_FRAME_CMD_PARAMS_PTR(out_frame), &tg, sizeof(u8));
+	out_frame->datalen += sizeof(u8);
+
+	/* The data is already in the out_frame, just update the datalen */
+	out_frame->datalen += payload_len;
+
+	pn533_tx_frame_finish(out_frame);
+	skb_put(skb, PN533_FRAME_TAIL_SIZE);
+
+	return 0;
+}
+
+struct pn533_data_exchange_arg {
+	struct sk_buff *skb_resp;
+	struct sk_buff *skb_out;
+	data_exchange_cb_t cb;
+	void *cb_context;
+};
+
+static int pn533_data_exchange_complete(struct pn533 *dev, void *_arg,
+						u8 *params, int params_len)
+{
+	struct pn533_data_exchange_arg *arg = _arg;
+	struct sk_buff *skb_resp = arg->skb_resp;
+	struct pn533_frame *in_frame = (struct pn533_frame *) skb_resp->data;
+	int err = 0;
+	u8 status;
+	u8 cmd_ret;
+
+	dev_dbg(&dev->interface->dev, "%s", __func__);
+
+	dev_kfree_skb_irq(arg->skb_out);
+
+	if (params_len < 0) { /* error */
+		err = params_len;
+		goto error;
+	}
+
+	skb_put(skb_resp, PN533_FRAME_SIZE(in_frame));
+
+	status = params[0];
+
+	cmd_ret = status & PN533_CMD_RET_MASK;
+	if (cmd_ret != PN533_CMD_RET_SUCCESS) {
+		dev_err(&dev->interface->dev, "%s - PN533 reported error %d"
+				" when exchanging data", __func__, cmd_ret);
+		err = -EIO;
+		goto error;
+	}
+
+	if (status & PN533_CMD_MI_MASK) {
+		/* TODO: Implement support to multi-part data exchange */
+		dev_err(&dev->interface->dev, "%s - Multi-part message not"
+					" supported yet", __func__);
+		/* Prevent the other messages from controller */
+		pn533_send_ack(dev, GFP_ATOMIC);
+		err = -ENOSYS;
+		goto error;
+	}
+
+	skb_pull(skb_resp, PN533_CMD_DATAEXCH_HEAD_LEN);
+	skb_trim(skb_resp, skb_resp->len - PN533_FRAME_TAIL_SIZE);
+
+	arg->cb(arg->cb_context, skb_resp, 0);
+	kfree(arg);
+	return 0;
+
+error:
+	dev_kfree_skb_irq(skb_resp);
+	arg->cb(arg->cb_context, NULL, err);
+	kfree(arg);
+	return 0;
+}
+
+int pn533_data_exchange(struct nfc_dev *nfc_dev, u32 target_idx,
+						struct sk_buff *skb,
+						data_exchange_cb_t cb,
+						void *cb_context)
+{
+	struct pn533 *dev = nfc_get_drvdata(nfc_dev);
+	struct pn533_frame *out_frame, *in_frame;
+	struct pn533_data_exchange_arg *arg;
+	struct sk_buff *skb_resp;
+	int skb_resp_len;
+	int rc;
+
+	dev_dbg(&dev->interface->dev, "%s", __func__);
+
+	if (!dev->tgt_active_prot) {
+		dev_err(&dev->interface->dev, "%s - Cannot exchange data with"
+					" no activated target", __func__);
+		rc = -EINVAL;
+		goto error;
+	}
+
+	rc = pn533_data_exchange_tx_frame(dev, skb);
+	if (rc)
+		goto error;
+
+	skb_resp_len = PN533_CMD_DATAEXCH_HEAD_LEN +
+			PN533_CMD_DATAEXCH_DATA_MAXLEN +
+			PN533_FRAME_TAIL_SIZE;
+
+	skb_resp = nfc_alloc_skb(skb_resp_len, GFP_KERNEL);
+	if (!skb_resp) {
+		rc = -ENOMEM;
+		goto error;
+	}
+
+	in_frame = (struct pn533_frame *) skb_resp->data;
+	out_frame = (struct pn533_frame *) skb->data;
+
+	arg = kmalloc(sizeof(struct pn533_data_exchange_arg), GFP_KERNEL);
+	if (!arg) {
+		rc = -ENOMEM;
+		goto free_skb_resp;
+	}
+
+	arg->skb_resp = skb_resp;
+	arg->skb_out = skb;
+	arg->cb = cb;
+	arg->cb_context = cb_context;
+
+	rc = pn533_send_cmd_frame_async(dev, out_frame, in_frame, skb_resp_len,
+					pn533_data_exchange_complete, arg,
+					GFP_KERNEL);
+	if (rc) {
+		dev_err(&dev->interface->dev, "%s - error %d when trying to"
+					" perform data_exchange", __func__, rc);
+		goto free_arg;
+	}
+
+	return 0;
+
+free_arg:
+	kfree(arg);
+free_skb_resp:
+	kfree_skb(skb_resp);
+error:
+	kfree_skb(skb);
+	return rc;
+}
+
+static int pn533_set_configuration(struct pn533 *dev, u8 cfgitem, u8 *cfgdata,
+								u8 cfgdata_len)
+{
+	int rc;
+	u8 *params;
+
+	pn533_tx_frame_init(dev->out_frame, PN533_CMD_RF_CONFIGURATION);
+
+	params = PN533_FRAME_CMD_PARAMS_PTR(dev->out_frame);
+	params[0] = cfgitem;
+	memcpy(&params[1], cfgdata, cfgdata_len);
+	dev->out_frame->datalen += (1 + cfgdata_len);
+
+	pn533_tx_frame_finish(dev->out_frame);
+
+	rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame,
+								dev->in_maxlen);
+
+	return rc;
+}
+
+struct nfc_ops pn533_nfc_ops = {
+	.start_poll = pn533_start_poll,
+	.stop_poll = pn533_stop_poll,
+	.activate_target = pn533_activate_target,
+	.deactivate_target = pn533_deactivate_target,
+	.data_exchange = pn533_data_exchange,
+};
+
+static int pn533_probe(struct usb_interface *interface,
+			const struct usb_device_id *id)
+{
+	struct pn533_fw_version *fw_ver;
+	struct pn533 *dev;
+	struct usb_host_interface *iface_desc;
+	struct usb_endpoint_descriptor *endpoint;
+	struct pn533_config_max_retries max_retries;
+	int in_endpoint = 0;
+	int out_endpoint = 0;
+	int rc = -ENOMEM;
+	int i;
+	u32 protocols;
+
+	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+	if (!dev)
+		return -ENOMEM;
+
+	dev->udev = usb_get_dev(interface_to_usbdev(interface));
+	dev->interface = interface;
+	sema_init(&dev->cmd_lock, 1);
+
+	iface_desc = interface->cur_altsetting;
+	for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) {
+		endpoint = &iface_desc->endpoint[i].desc;
+
+		if (!in_endpoint && usb_endpoint_is_bulk_in(endpoint)) {
+			dev->in_maxlen = le16_to_cpu(endpoint->wMaxPacketSize);
+			in_endpoint = endpoint->bEndpointAddress;
+		}
+
+		if (!out_endpoint && usb_endpoint_is_bulk_out(endpoint)) {
+			dev->out_maxlen =
+				le16_to_cpu(endpoint->wMaxPacketSize);
+			out_endpoint = endpoint->bEndpointAddress;
+		}
+	}
+
+	if (!in_endpoint || !out_endpoint) {
+		dev_err(&interface->dev, "Could not find bulk-in or "
+						"bulk-out endpoint");
+		rc = -ENODEV;
+		goto error;
+	}
+
+	dev->in_frame = kmalloc(dev->in_maxlen, GFP_KERNEL);
+	dev->in_urb = usb_alloc_urb(0, GFP_KERNEL);
+	dev->out_frame = kmalloc(dev->out_maxlen, GFP_KERNEL);
+	dev->out_urb = usb_alloc_urb(0, GFP_KERNEL);
+
+	if (!dev->in_frame || !dev->out_frame ||
+		!dev->in_urb || !dev->out_urb)
+		goto error;
+
+	usb_fill_bulk_urb(dev->in_urb, dev->udev,
+			usb_rcvbulkpipe(dev->udev, in_endpoint),
+			NULL, 0, NULL, dev);
+	usb_fill_bulk_urb(dev->out_urb, dev->udev,
+			usb_sndbulkpipe(dev->udev, out_endpoint),
+			NULL, 0,
+			pn533_send_complete, dev);
+
+	tasklet_init(&dev->tasklet, pn533_tasklet_cmd_complete, (ulong)dev);
+
+	usb_set_intfdata(interface, dev);
+
+	pn533_tx_frame_init(dev->out_frame, PN533_CMD_GET_FIRMWARE_VERSION);
+	pn533_tx_frame_finish(dev->out_frame);
+
+	rc = pn533_send_cmd_frame_sync(dev, dev->out_frame, dev->in_frame,
+								dev->in_maxlen);
+	if (rc)
+		goto kill_tasklet;
+
+	fw_ver = (struct pn533_fw_version *)
+				PN533_FRAME_CMD_PARAMS_PTR(dev->in_frame);
+	dev_info(&interface->dev, "NXP PN533 firmware ver %d.%d now attached",
+						fw_ver->ver, fw_ver->rev);
+
+	protocols = NFC_PROTO_JEWEL_MASK
+			| NFC_PROTO_MIFARE_MASK | NFC_PROTO_FELICA_MASK
+			| NFC_PROTO_ISO14443_MASK
+			| NFC_PROTO_NFC_DEP_MASK;
+
+	dev->nfc_dev = nfc_allocate_device(&pn533_nfc_ops, protocols);
+	if (!dev->nfc_dev)
+		goto kill_tasklet;
+
+	nfc_set_parent_dev(dev->nfc_dev, &interface->dev);
+	nfc_set_drvdata(dev->nfc_dev, dev);
+
+	rc = nfc_register_device(dev->nfc_dev);
+	if (rc)
+		goto free_nfc_dev;
+
+	max_retries.mx_rty_atr = PN533_CONFIG_MAX_RETRIES_ENDLESS;
+	max_retries.mx_rty_psl = 2;
+	max_retries.mx_rty_passive_act = PN533_CONFIG_MAX_RETRIES_NO_RETRY;
+
+	rc = pn533_set_configuration(dev, PN533_CFGITEM_MAX_RETRIES,
+				(u8 *) &max_retries, sizeof(max_retries));
+
+	if (rc) {
+		dev_err(&interface->dev, "Error on setting MAX_RETRIES "
+								"config");
+		goto free_nfc_dev;
+	}
+
+	return 0;
+
+free_nfc_dev:
+	nfc_free_device(dev->nfc_dev);
+kill_tasklet:
+	tasklet_kill(&dev->tasklet);
+error:
+	kfree(dev->in_frame);
+	usb_free_urb(dev->in_urb);
+	kfree(dev->out_frame);
+	usb_free_urb(dev->out_urb);
+	kfree(dev);
+	return rc;
+}
+
+static void pn533_disconnect(struct usb_interface *interface)
+{
+	struct pn533 *dev;
+
+	dev = usb_get_intfdata(interface);
+	usb_set_intfdata(interface, NULL);
+
+	nfc_unregister_device(dev->nfc_dev);
+	nfc_free_device(dev->nfc_dev);
+
+	usb_kill_urb(dev->in_urb);
+	usb_kill_urb(dev->out_urb);
+
+	tasklet_kill(&dev->tasklet);
+
+	kfree(dev->in_frame);
+	usb_free_urb(dev->in_urb);
+	kfree(dev->out_frame);
+	usb_free_urb(dev->out_urb);
+	kfree(dev);
+
+	dev_info(&interface->dev, "NXP PN533 NFC device disconnected");
+}
+
+static struct usb_driver pn533_driver = {
+	.name =		"pn533",
+	.probe =	pn533_probe,
+	.disconnect =	pn533_disconnect,
+	.id_table =	pn533_table,
+};
+
+static int __init pn533_init(void)
+{
+	int rc;
+
+	rc = usb_register(&pn533_driver);
+	if (rc)
+		err("usb_register failed. Error number %d", rc);
+
+	return rc;
+}
+
+static void __exit pn533_exit(void)
+{
+	usb_deregister(&pn533_driver);
+}
+
+module_init(pn533_init);
+module_exit(pn533_exit);
+
+MODULE_AUTHOR("Lauro Ramos Venancio <lauro.venancio@openbossa.org>");
+MODULE_DESCRIPTION("PN533 usb driver ver " VERSION);
+MODULE_VERSION(VERSION);
+MODULE_LICENSE("GPL");
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH v4 6/6] NFC: add Documentation/networking/nfc.txt
  2011-06-28 18:20 [PATCH v4 0/6] NFC subsystem Aloisio Almeida Jr
                   ` (4 preceding siblings ...)
  2011-06-28 18:20 ` [PATCH v4 5/6] NFC: pn533: add NXP pn533 nfc device driver Aloisio Almeida Jr
@ 2011-06-28 18:20 ` Aloisio Almeida Jr
  5 siblings, 0 replies; 38+ messages in thread
From: Aloisio Almeida Jr @ 2011-06-28 18:20 UTC (permalink / raw)
  To: linville
  Cc: linux-wireless, sameo, johannes, lauro.venancio, marcio.macedo,
	Waldemar.Rymarkiewicz, padovan, rdunlap, Aloisio Almeida Jr

Signed-off-by: Aloisio Almeida Jr <aloisio.almeida@openbossa.org>
Signed-off-by: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
---
 Documentation/networking/nfc.txt |  128 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 128 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/networking/nfc.txt

diff --git a/Documentation/networking/nfc.txt b/Documentation/networking/nfc.txt
new file mode 100644
index 0000000..b24c29b
--- /dev/null
+++ b/Documentation/networking/nfc.txt
@@ -0,0 +1,128 @@
+Linux NFC subsystem
+===================
+
+The Near Field Communication (NFC) subsystem is required to standardize the
+NFC device drivers development and to create an unified userspace interface.
+
+This document covers the architecture overview, the device driver interface
+description and the userspace interface description.
+
+Architecture overview
+---------------------
+
+The NFC subsystem is responsible for:
+      - NFC adapters management;
+      - Polling for targets;
+      - Low-level data exchange;
+
+The subsystem is divided in some parts. The 'core' is responsible for
+providing the device driver interface. On the other side, it is also
+responsible for providing an interface to control operations and low-level
+data exchange.
+
+The control operations are available to userspace via generic netlink.
+
+The low-level data exchange interface is provided by the new socket family
+PF_NFC. The NFC_SOCKPROTO_RAW performs raw communication with NFC targets.
+
+
+             +--------------------------------------+
+             |              USER SPACE              |
+             +--------------------------------------+
+                 ^                       ^
+                 | low-level             | control
+                 | data exchange         | operations
+                 |                       |
+                 |                       v
+                 |                  +-----------+
+                 | AF_NFC           |  netlink  |
+                 | socket           +-----------+
+                 | raw                   ^
+                 |                       |
+                 v                       v
+             +---------+            +-----------+
+             | rawsock | <--------> |   core    |
+             +---------+            +-----------+
+                                         ^
+                                         |
+                                         v
+                                    +-----------+
+                                    |  driver   |
+                                    +-----------+
+
+Device Driver Interface
+-----------------------
+
+When registering on the NFC subsystem, the device driver must inform the core
+of the set of supported NFC protocols and the set of ops callbacks. The ops
+callbacks that must be implemented are the following:
+
+* start_poll - setup the device to poll for targets
+* stop_poll - stop on progress polling operation
+* activate_target - select and initialize one of the targets found
+* deactivate_target - deselect and deinitialize the selected target
+* data_exchange - send data and receive the response (transceive operation)
+
+Userspace interface
+--------------------
+
+The userspace interface is divided in control operations and low-level data
+exchange operation.
+
+CONTROL OPERATIONS:
+
+Generic netlink is used to implement the interface to the control operations.
+The operations are composed by commands and events, all listed below:
+
+* NFC_CMD_GET_DEVICE - get specific device info or dump the device list
+* NFC_CMD_START_POLL - setup a specific device to polling for targets
+* NFC_CMD_STOP_POLL - stop the polling operation in a specific device
+* NFC_CMD_GET_TARGET - dump the list of targets found by a specific device
+
+* NFC_EVENT_DEVICE_ADDED - reports an NFC device addition
+* NFC_EVENT_DEVICE_REMOVED - reports an NFC device removal
+* NFC_EVENT_TARGETS_FOUND - reports START_POLL results when 1 or more targets
+are found
+
+The user must call START_POLL to poll for NFC targets, passing the desired NFC
+protocols through NFC_ATTR_PROTOCOLS attribute. The device remains in polling
+state until it finds any target. However, the user can stop the polling
+operation by calling STOP_POLL command. In this case, it will be checked if
+the requester of STOP_POLL is the same of START_POLL.
+
+If the polling operation finds one or more targets, the event TARGETS_FOUND is
+sent (including the device id). The user must call GET_TARGET to get the list of
+all targets found by such device. Each reply message has target attributes with
+relevant information such as the supported NFC protocols.
+
+All polling operations requested through one netlink socket are stopped when
+it's closed.
+
+LOW-LEVEL DATA EXCHANGE:
+
+The userspace must use PF_NFC sockets to perform any data communication with
+targets. All NFC sockets use AF_NFC:
+
+struct sockaddr_nfc {
+       sa_family_t sa_family;
+       __u32 dev_idx;
+       __u32 target_idx;
+       __u32 nfc_protocol;
+};
+
+To establish a connection with one target, the user must create an
+NFC_SOCKPROTO_RAW socket and call the 'connect' syscall with the sockaddr_nfc
+struct correctly filled. All information comes from NFC_EVENT_TARGETS_FOUND
+netlink event. As a target can support more than one NFC protocol, the user
+must inform which protocol it wants to use.
+
+Internally, 'connect' will result in an activate_target call to the driver.
+When the socket is closed, the target is deactivated.
+
+The data format exchanged through the sockets is NFC protocol dependent. For
+instance, when communicating with MIFARE tags, the data exchanged are MIFARE
+commands and their responses.
+
+The first received package is the response to the first sent package and so
+on. In order to allow valid "empty" responses, every data received has a NULL
+header of 1 byte.
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-28 18:20 ` [PATCH v4 1/6] NFC: add nfc subsystem core Aloisio Almeida Jr
@ 2011-06-28 20:18   ` Joe Perches
  2011-06-28 23:31     ` Aloisio Almeida
  2011-06-29  1:31     ` Marcel Holtmann
  0 siblings, 2 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-28 20:18 UTC (permalink / raw)
  To: Aloisio Almeida Jr
  Cc: linville, linux-wireless, sameo, johannes, lauro.venancio,
	marcio.macedo, Waldemar.Rymarkiewicz, padovan, rdunlap

On Tue, 2011-06-28 at 15:20 -0300, Aloisio Almeida Jr wrote:
> From: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
> The NFC subsystem core is responsible for providing the device driver
> interface. It is also responsible for providing an interface to the control
> operations and data exchange.
[]
> diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
[]
> +#define NFC_INFO(fmt, arg...) printk(KERN_INFO "NFC: " fmt "\n", ## arg)
> +#define NFC_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n", __func__, ## arg)
> +#define NFC_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)

I think these #defines and their uses would be
better lower case.

#define nfc_info(etc...)
#define nfc_err(etc...)
#define nfc_dbg(etc...)

And because these don't really take any nfc specific
struct as an argument, may be better removed altogether
and replaced with the pr_<level> equivalents.

I think emitting __func__ rarely adds useful information.


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-28 20:18   ` Joe Perches
@ 2011-06-28 23:31     ` Aloisio Almeida
  2011-06-28 23:52       ` Joe Perches
  2011-06-29  1:31     ` Marcel Holtmann
  1 sibling, 1 reply; 38+ messages in thread
From: Aloisio Almeida @ 2011-06-28 23:31 UTC (permalink / raw)
  To: Joe Perches
  Cc: linville, linux-wireless, sameo, johannes, lauro.venancio,
	marcio.macedo, Waldemar.Rymarkiewicz, padovan, rdunlap

Hi Joe,

On Tue, Jun 28, 2011 at 5:18 PM, Joe Perches <joe@perches.com> wrote:
> On Tue, 2011-06-28 at 15:20 -0300, Aloisio Almeida Jr wrote:
>> From: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
>> The NFC subsystem core is responsible for providing the device driver
>> interface. It is also responsible for providing an interface to the control
>> operations and data exchange.
> []
>> diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
> []
>> +#define NFC_INFO(fmt, arg...) printk(KERN_INFO "NFC: " fmt "\n", ## arg)
>> +#define NFC_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n", __func__, ## arg)
>> +#define NFC_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)
>
> I think these #defines and their uses would be
> better lower case.
>
> #define nfc_info(etc...)
> #define nfc_err(etc...)
> #define nfc_dbg(etc...)
>
> And because these don't really take any nfc specific
> struct as an argument, may be better removed altogether
> and replaced with the pr_<level> equivalents.
>
I was using pr_*() on previous versions. One of the proposed changes
for v4 was to create these macros to avoid calling pr_*() functions
with same parameters every time. The implementation chosen is based on
BT_* macros from bluetooth subsystem.

> I think emitting __func__ rarely adds useful information.
>
I can say that during the implementation phase I considered __func__
useful, mainly for tracing the execution. That's the reason I left it
in the code.

Aloisio

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-28 23:31     ` Aloisio Almeida
@ 2011-06-28 23:52       ` Joe Perches
  0 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-28 23:52 UTC (permalink / raw)
  To: Aloisio Almeida
  Cc: linville, linux-wireless, sameo, johannes, lauro.venancio,
	marcio.macedo, Waldemar.Rymarkiewicz, padovan, rdunlap

On Tue, 2011-06-28 at 20:31 -0300, Aloisio Almeida wrote:
> Hi Joe,

Oi Aloisio.

> On Tue, Jun 28, 2011 at 5:18 PM, Joe Perches <joe@perches.com> wrote:
> > On Tue, 2011-06-28 at 15:20 -0300, Aloisio Almeida Jr wrote:
> >> From: Lauro Ramos Venancio <lauro.venancio@openbossa.org>
> >> The NFC subsystem core is responsible for providing the device driver
> >> interface. It is also responsible for providing an interface to the control
> >> operations and data exchange.
> > []
> >> diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
> > []
> >> +#define NFC_INFO(fmt, arg...) printk(KERN_INFO "NFC: " fmt "\n", ## arg)
> >> +#define NFC_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n", __func__, ## arg)
> >> +#define NFC_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)
> >
> > I think these #defines and their uses would be
> > better lower case.
> >
> > #define nfc_info(etc...)
> > #define nfc_err(etc...)
> > #define nfc_dbg(etc...)
> >
> > And because these don't really take any nfc specific
> > struct as an argument, may be better removed altogether
> > and replaced with the pr_<level> equivalents.
> I was using pr_*() on previous versions. One of the proposed changes
> for v4 was to create these macros to avoid calling pr_*() functions
> with same parameters every time. The implementation chosen is based on
> BT_* macros from bluetooth subsystem.
> > I think emitting __func__ rarely adds useful information.
> I can say that during the implementation phase I considered __func__
> useful, mainly for tracing the execution. That's the reason I left it
> in the code.

Up to you, but regardless, I think the bluetooth macros
aren't good ones to follow.  Most all of the other
<foo>_<level> output logging forms are lowercase.

cheers, Joe


^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-28 20:18   ` Joe Perches
  2011-06-28 23:31     ` Aloisio Almeida
@ 2011-06-29  1:31     ` Marcel Holtmann
  2011-06-29  1:49       ` Joe Perches
  1 sibling, 1 reply; 38+ messages in thread
From: Marcel Holtmann @ 2011-06-29  1:31 UTC (permalink / raw)
  To: Joe Perches
  Cc: Aloisio Almeida Jr, linville, linux-wireless, sameo, johannes,
	lauro.venancio, marcio.macedo, Waldemar.Rymarkiewicz, padovan,
	rdunlap

Hi Joe,

> > The NFC subsystem core is responsible for providing the device driver
> > interface. It is also responsible for providing an interface to the control
> > operations and data exchange.
> []
> > diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
> []
> > +#define NFC_INFO(fmt, arg...) printk(KERN_INFO "NFC: " fmt "\n", ## arg)
> > +#define NFC_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n", __func__, ## arg)
> > +#define NFC_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)
> 
> I think these #defines and their uses would be
> better lower case.
> 
> #define nfc_info(etc...)
> #define nfc_err(etc...)
> #define nfc_dbg(etc...)
> 
> And because these don't really take any nfc specific
> struct as an argument, may be better removed altogether
> and replaced with the pr_<level> equivalents.

it is similar to what we do in the Bluetooth subsystem, but in the end
upper-case vs lower-case is a bit more personal taste.

The pr_<level> ones are nice and I wished we had them all back in the
days, but the NFC ones actually could take the controller as argument
and then us the dev_* versions of these commands.

At this stage of the project it is a bit too early to tell I guess.

> I think emitting __func__ rarely adds useful information.

Depends on how you are using your debug statements. I find it really
helpful since then you can keep the text detail to a minimum.

Regards

Marcel



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-29  1:31     ` Marcel Holtmann
@ 2011-06-29  1:49       ` Joe Perches
  2011-06-29 18:00         ` Marcel Holtmann
  0 siblings, 1 reply; 38+ messages in thread
From: Joe Perches @ 2011-06-29  1:49 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Aloisio Almeida Jr, linville, linux-wireless, sameo, johannes,
	lauro.venancio, marcio.macedo, Waldemar.Rymarkiewicz, padovan,
	rdunlap

On Tue, 2011-06-28 at 18:31 -0700, Marcel Holtmann wrote:
> Hi Joe,

Hello Marcel.

> > > The NFC subsystem core is responsible for providing the device driver
> > > interface. It is also responsible for providing an interface to the control
> > > operations and data exchange.
> > []
> > > diff --git a/net/nfc/nfc.h b/net/nfc/nfc.h
> > []
> > > +#define NFC_INFO(fmt, arg...) printk(KERN_INFO "NFC: " fmt "\n", ## arg)
> > > +#define NFC_ERR(fmt, arg...) printk(KERN_ERR "%s: " fmt "\n", __func__, ## arg)
> > > +#define NFC_DBG(fmt, arg...) pr_debug("%s: " fmt "\n", __func__, ## arg)
> > I think these #defines and their uses would be
> > better lower case.
> > #define nfc_info(etc...)
> > #define nfc_err(etc...)
> > #define nfc_dbg(etc...)
> > And because these don't really take any nfc specific
> > struct as an argument, may be better removed altogether
> > and replaced with the pr_<level> equivalents.
> 
> it is similar to what we do in the Bluetooth subsystem, but in the end
> upper-case vs lower-case is a bit more personal taste.

And a bit of of coding style agreement too.

> The pr_<level> ones are nice and I wished we had them all back in the
> days, but the NFC ones actually could take the controller as argument
> and then us the dev_* versions of these commands.

I do think that if there's a controller struct that's always
or mostly used with nfc_<level>, then it should be added and
passed to the functions arguments, maybe with NULL used where
necessary.

> At this stage of the project it is a bit too early to tell I guess.
> > I think emitting __func__ rarely adds useful information.
> Depends on how you are using your debug statements. I find it really
> helpful since then you can keep the text detail to a minimum.

I don't disagree that while debugging function names
and tracing function entries/exits are useful.

Today, dynamic_debug can add __func__ to the output as
desired so I think that it's not really necessary
to add to any <foo>_dbg callsite.

I don't think they're ever useful on <foo>_err.
If they are, then the message probably isn't
descriptive enough and adding %s/__func__ as
necessary is OK.

cheers, Joe



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-29  1:49       ` Joe Perches
@ 2011-06-29 18:00         ` Marcel Holtmann
  2011-06-29 23:23           ` Aloisio Almeida
  2011-06-30  1:18             ` Joe Perches
  0 siblings, 2 replies; 38+ messages in thread
From: Marcel Holtmann @ 2011-06-29 18:00 UTC (permalink / raw)
  To: Joe Perches
  Cc: Aloisio Almeida Jr, linville, linux-wireless, sameo, johannes,
	lauro.venancio, marcio.macedo, Waldemar.Rymarkiewicz, padovan,
	rdunlap

Hi Joe,

> > The pr_<level> ones are nice and I wished we had them all back in the
> > days, but the NFC ones actually could take the controller as argument
> > and then us the dev_* versions of these commands.
> 
> I do think that if there's a controller struct that's always
> or mostly used with nfc_<level>, then it should be added and
> passed to the functions arguments, maybe with NULL used where
> necessary.
> 
> > At this stage of the project it is a bit too early to tell I guess.
> > > I think emitting __func__ rarely adds useful information.
> > Depends on how you are using your debug statements. I find it really
> > helpful since then you can keep the text detail to a minimum.
> 
> I don't disagree that while debugging function names
> and tracing function entries/exits are useful.
> 
> Today, dynamic_debug can add __func__ to the output as
> desired so I think that it's not really necessary
> to add to any <foo>_dbg callsite.

I did not know that. Then we might should go ahead and also cleanup the
Bluetooth subsystem.

We do use an implied "Bluetooth: " prefix when calling BT_INFO, but that
can be easily changed to bt_info() as well since I do not care about
that part. 

The Bluetooth subsystem has a Linux 2.4 legacy history and a lot of
things can be done a lot nicer these days.

Regards

Marcel



^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-29 18:00         ` Marcel Holtmann
@ 2011-06-29 23:23           ` Aloisio Almeida
  2011-06-29 23:46             ` Joe Perches
  2011-06-30  1:18             ` Joe Perches
  1 sibling, 1 reply; 38+ messages in thread
From: Aloisio Almeida @ 2011-06-29 23:23 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Joe Perches, linville, linux-wireless, sameo, johannes,
	lauro.venancio, marcio.macedo, Waldemar.Rymarkiewicz, padovan,
	rdunlap

Hi Joe and Marcel,

On Wed, Jun 29, 2011 at 3:00 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Joe,
>
>> > The pr_<level> ones are nice and I wished we had them all back in the
>> > days, but the NFC ones actually could take the controller as argument
>> > and then us the dev_* versions of these commands.
>>
>> I do think that if there's a controller struct that's always
>> or mostly used with nfc_<level>, then it should be added and
>> passed to the functions arguments, maybe with NULL used where
>> necessary.
>>
>> > At this stage of the project it is a bit too early to tell I guess.
>> > > I think emitting __func__ rarely adds useful information.
>> > Depends on how you are using your debug statements. I find it really
>> > helpful since then you can keep the text detail to a minimum.
>>
>> I don't disagree that while debugging function names
>> and tracing function entries/exits are useful.
>>
>> Today, dynamic_debug can add __func__ to the output as
>> desired so I think that it's not really necessary
>> to add to any <foo>_dbg callsite.
>
> I did not know that. Then we might should go ahead and also cleanup the
> Bluetooth subsystem.

That's true only for pr_debug() function. You cannot add __func__ info
on dev_dbg() calls dynamically.

So, for net/nfc/* I propose to use directly pr_*() functions.

For device drivers the following macros would be provided:

#define nfc_dev_info(dev, fmt, arg...) dev_info((dev), "NFC: " fmt, ## arg)
#define nfc_dev_err(dev, fmt, arg...) dev_err((dev), "%s: " fmt,
__func__, ## arg)
#define nfc_dev_dbg(dev, fmt, arg...) dev_dbg((dev), "%s: " fmt,
__func__, ## arg)

What do you think?

Aloisio

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-29 23:23           ` Aloisio Almeida
@ 2011-06-29 23:46             ` Joe Perches
  2011-06-30  3:26               ` Aloisio Almeida
  0 siblings, 1 reply; 38+ messages in thread
From: Joe Perches @ 2011-06-29 23:46 UTC (permalink / raw)
  To: Aloisio Almeida, Jason Baron
  Cc: Marcel Holtmann, linville, linux-wireless, sameo, johannes,
	lauro.venancio, marcio.macedo, Waldemar.Rymarkiewicz, padovan,
	rdunlap

On Wed, 2011-06-29 at 20:23 -0300, Aloisio Almeida wrote:
> >> Today, dynamic_debug can add __func__ to the output as
> >> desired so I think that it's not really necessary
> >> to add to any <foo>_dbg callsite.
> That's true only for pr_debug() function. You cannot add __func__ info
> on dev_dbg() calls dynamically.

I believe that's false.  It's definitely stored.

#define dynamic_dev_dbg(dev, fmt, ...) do {				\
	static struct _ddebug descriptor				\
	__used								\
	__attribute__((section("__verbose"), aligned(8))) =		\
	{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__,		\
		_DPRINTK_FLAGS_DEFAULT };				\
	if (unlikely(descriptor.enabled))				\
		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
	} while (0)

Jason?  True or false?

> So, for net/nfc/* I propose to use directly pr_*() functions.
> For device drivers the following macros would be provided:
> #define nfc_dev_info(dev, fmt, arg...) dev_info((dev), "NFC: " fmt, ## arg)
> #define nfc_dev_err(dev, fmt, arg...) dev_err((dev), "%s: " fmt,
> __func__, ## arg)
> #define nfc_dev_dbg(dev, fmt, arg...) dev_dbg((dev), "%s: " fmt,
> __func__, ## arg)
> What do you think?

I still think __func__ isn't useful ;)
I think you should add NFC to nfc_dev_err too.

cheers, Joe


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 0/2] bluetooth: Use current logging styles
  2011-06-29 18:00         ` Marcel Holtmann
@ 2011-06-30  1:18             ` Joe Perches
  2011-06-30  1:18             ` Joe Perches
  1 sibling, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30  1:18 UTC (permalink / raw)
  To: Marcel Holtmann, linux-bluetooth; +Cc: linux-kernel, netdev

On Wed, 2011-06-29 at 11:00 -0700, Marcel Holtmann wrote:
> I did not know that. Then we might should go ahead and also cleanup the
> Bluetooth subsystem.
> 
> We do use an implied "Bluetooth: " prefix when calling BT_INFO, but that
> can be easily changed to bt_info() as well since I do not care about
> that part. 
> 
> The Bluetooth subsystem has a Linux 2.4 legacy history and a lot of
> things can be done a lot nicer these days.

Here you go Marcel.

It reduces code/text a couple/few percent too.
 
Joe Perches (2):
  bluetooth: Rename function bt_err to bt_to_errno
  bluetooth: Add bt_printk, convert logging macros to lower case

 drivers/bluetooth/ath3k.c          |   48 ++++----
 drivers/bluetooth/bcm203x.c        |   38 +++---
 drivers/bluetooth/bfusb.c          |   94 +++++++-------
 drivers/bluetooth/bluecard_cs.c    |   18 ++--
 drivers/bluetooth/bpa10x.c         |   38 +++---
 drivers/bluetooth/bt3c_cs.c        |   34 +++---
 drivers/bluetooth/btmrvl_debugfs.c |    2 +-
 drivers/bluetooth/btmrvl_main.c    |   74 ++++++------
 drivers/bluetooth/btmrvl_sdio.c    |  112 +++++++++---------
 drivers/bluetooth/btsdio.c         |   26 ++--
 drivers/bluetooth/btuart_cs.c      |   24 ++--
 drivers/bluetooth/btusb.c          |   64 +++++-----
 drivers/bluetooth/btwilink.c       |   34 +++---
 drivers/bluetooth/dtl1_cs.c        |   20 ++--
 drivers/bluetooth/hci_ath.c        |   14 +-
 drivers/bluetooth/hci_bcsp.c       |   58 +++++-----
 drivers/bluetooth/hci_h4.c         |   18 ++--
 drivers/bluetooth/hci_ldisc.c      |   36 +++---
 drivers/bluetooth/hci_ll.c         |   76 ++++++------
 drivers/bluetooth/hci_vhci.c       |    8 +-
 include/net/bluetooth/bluetooth.h  |   11 +-
 net/bluetooth/af_bluetooth.c       |   20 ++--
 net/bluetooth/bnep/core.c          |   26 ++--
 net/bluetooth/bnep/netdev.c        |   14 +-
 net/bluetooth/bnep/sock.c          |   10 +-
 net/bluetooth/cmtp/capi.c          |   46 ++++----
 net/bluetooth/cmtp/core.c          |   30 +++---
 net/bluetooth/cmtp/sock.c          |   10 +-
 net/bluetooth/hci_conn.c           |   52 ++++----
 net/bluetooth/hci_core.c           |  142 +++++++++++-----------
 net/bluetooth/hci_event.c          |  234 ++++++++++++++++++------------------
 net/bluetooth/hci_sock.c           |   26 ++--
 net/bluetooth/hci_sysfs.c          |   12 +-
 net/bluetooth/hidp/core.c          |   50 ++++----
 net/bluetooth/hidp/sock.c          |   10 +-
 net/bluetooth/l2cap_core.c         |  172 +++++++++++++-------------
 net/bluetooth/l2cap_sock.c         |   40 +++---
 net/bluetooth/lib.c                |   23 ++++-
 net/bluetooth/mgmt.c               |   80 ++++++------
 net/bluetooth/rfcomm/core.c        |  152 ++++++++++++------------
 net/bluetooth/rfcomm/sock.c        |   56 +++++-----
 net/bluetooth/rfcomm/tty.c         |  100 ++++++++--------
 net/bluetooth/sco.c                |   84 +++++++-------
 net/bluetooth/smp.c                |   30 +++---
 44 files changed, 1144 insertions(+), 1122 deletions(-)

-- 
1.7.6.rc1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 0/2] bluetooth: Use current logging styles
@ 2011-06-30  1:18             ` Joe Perches
  0 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30  1:18 UTC (permalink / raw)
  To: Marcel Holtmann, linux-bluetooth-u79uwXL29TY76Z2rM5mHXA
  Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA

On Wed, 2011-06-29 at 11:00 -0700, Marcel Holtmann wrote:
> I did not know that. Then we might should go ahead and also cleanup the
> Bluetooth subsystem.
> 
> We do use an implied "Bluetooth: " prefix when calling BT_INFO, but that
> can be easily changed to bt_info() as well since I do not care about
> that part. 
> 
> The Bluetooth subsystem has a Linux 2.4 legacy history and a lot of
> things can be done a lot nicer these days.

Here you go Marcel.

It reduces code/text a couple/few percent too.
 
Joe Perches (2):
  bluetooth: Rename function bt_err to bt_to_errno
  bluetooth: Add bt_printk, convert logging macros to lower case

 drivers/bluetooth/ath3k.c          |   48 ++++----
 drivers/bluetooth/bcm203x.c        |   38 +++---
 drivers/bluetooth/bfusb.c          |   94 +++++++-------
 drivers/bluetooth/bluecard_cs.c    |   18 ++--
 drivers/bluetooth/bpa10x.c         |   38 +++---
 drivers/bluetooth/bt3c_cs.c        |   34 +++---
 drivers/bluetooth/btmrvl_debugfs.c |    2 +-
 drivers/bluetooth/btmrvl_main.c    |   74 ++++++------
 drivers/bluetooth/btmrvl_sdio.c    |  112 +++++++++---------
 drivers/bluetooth/btsdio.c         |   26 ++--
 drivers/bluetooth/btuart_cs.c      |   24 ++--
 drivers/bluetooth/btusb.c          |   64 +++++-----
 drivers/bluetooth/btwilink.c       |   34 +++---
 drivers/bluetooth/dtl1_cs.c        |   20 ++--
 drivers/bluetooth/hci_ath.c        |   14 +-
 drivers/bluetooth/hci_bcsp.c       |   58 +++++-----
 drivers/bluetooth/hci_h4.c         |   18 ++--
 drivers/bluetooth/hci_ldisc.c      |   36 +++---
 drivers/bluetooth/hci_ll.c         |   76 ++++++------
 drivers/bluetooth/hci_vhci.c       |    8 +-
 include/net/bluetooth/bluetooth.h  |   11 +-
 net/bluetooth/af_bluetooth.c       |   20 ++--
 net/bluetooth/bnep/core.c          |   26 ++--
 net/bluetooth/bnep/netdev.c        |   14 +-
 net/bluetooth/bnep/sock.c          |   10 +-
 net/bluetooth/cmtp/capi.c          |   46 ++++----
 net/bluetooth/cmtp/core.c          |   30 +++---
 net/bluetooth/cmtp/sock.c          |   10 +-
 net/bluetooth/hci_conn.c           |   52 ++++----
 net/bluetooth/hci_core.c           |  142 +++++++++++-----------
 net/bluetooth/hci_event.c          |  234 ++++++++++++++++++------------------
 net/bluetooth/hci_sock.c           |   26 ++--
 net/bluetooth/hci_sysfs.c          |   12 +-
 net/bluetooth/hidp/core.c          |   50 ++++----
 net/bluetooth/hidp/sock.c          |   10 +-
 net/bluetooth/l2cap_core.c         |  172 +++++++++++++-------------
 net/bluetooth/l2cap_sock.c         |   40 +++---
 net/bluetooth/lib.c                |   23 ++++-
 net/bluetooth/mgmt.c               |   80 ++++++------
 net/bluetooth/rfcomm/core.c        |  152 ++++++++++++------------
 net/bluetooth/rfcomm/sock.c        |   56 +++++-----
 net/bluetooth/rfcomm/tty.c         |  100 ++++++++--------
 net/bluetooth/sco.c                |   84 +++++++-------
 net/bluetooth/smp.c                |   30 +++---
 44 files changed, 1144 insertions(+), 1122 deletions(-)

-- 
1.7.6.rc1

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 1/2] bluetooth: Rename function bt_err to bt_to_errno
  2011-06-30  1:18             ` Joe Perches
  (?)
@ 2011-06-30  1:18             ` Joe Perches
  2011-07-01 19:04               ` Gustavo F. Padovan
  -1 siblings, 1 reply; 38+ messages in thread
From: Joe Perches @ 2011-06-30  1:18 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo F. Padovan
  Cc: David S. Miller, linux-bluetooth, netdev, linux-kernel

Make it easier to use more normal logging styles later.

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/net/bluetooth/bluetooth.h |    2 +-
 net/bluetooth/hci_core.c          |    2 +-
 net/bluetooth/l2cap_core.c        |    4 ++--
 net/bluetooth/lib.c               |    4 ++--
 net/bluetooth/sco.c               |    4 ++--
 5 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 7bccaf9..7d77545f 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -204,7 +204,7 @@ out:
 	return NULL;
 }
 
-int bt_err(__u16 code);
+int bt_to_errno(__u16 code);
 
 extern int hci_sock_init(void);
 extern void hci_sock_cleanup(void);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index b18db56..ec34c5a 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -148,7 +148,7 @@ static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev,
 
 	switch (hdev->req_status) {
 	case HCI_REQ_DONE:
-		err = -bt_err(hdev->req_result);
+		err = -bt_to_errno(hdev->req_result);
 		break;
 
 	case HCI_REQ_CANCELED:
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 9ec9c8c..2a27428 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -4107,7 +4107,7 @@ static int l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 		if (conn)
 			l2cap_conn_ready(conn);
 	} else
-		l2cap_conn_del(hcon, bt_err(status));
+		l2cap_conn_del(hcon, bt_to_errno(status));
 
 	return 0;
 }
@@ -4131,7 +4131,7 @@ static int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason)
 	if (!(hcon->type == ACL_LINK || hcon->type == LE_LINK))
 		return -EINVAL;
 
-	l2cap_conn_del(hcon, bt_err(reason));
+	l2cap_conn_del(hcon, bt_to_errno(reason));
 
 	return 0;
 }
diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c
index b826d1b..4e7cf8b 100644
--- a/net/bluetooth/lib.c
+++ b/net/bluetooth/lib.c
@@ -59,7 +59,7 @@ char *batostr(bdaddr_t *ba)
 EXPORT_SYMBOL(batostr);
 
 /* Bluetooth error codes to Unix errno mapping */
-int bt_err(__u16 code)
+int bt_to_errno(__u16 code)
 {
 	switch (code) {
 	case 0:
@@ -149,4 +149,4 @@ int bt_err(__u16 code)
 		return ENOSYS;
 	}
 }
-EXPORT_SYMBOL(bt_err);
+EXPORT_SYMBOL(bt_to_errno);
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index cb4fb78..4c3621b 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -932,7 +932,7 @@ static int sco_connect_cfm(struct hci_conn *hcon, __u8 status)
 		if (conn)
 			sco_conn_ready(conn);
 	} else
-		sco_conn_del(hcon, bt_err(status));
+		sco_conn_del(hcon, bt_to_errno(status));
 
 	return 0;
 }
@@ -944,7 +944,7 @@ static int sco_disconn_cfm(struct hci_conn *hcon, __u8 reason)
 	if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
 		return -EINVAL;
 
-	sco_conn_del(hcon, bt_err(reason));
+	sco_conn_del(hcon, bt_to_errno(reason));
 
 	return 0;
 }
-- 
1.7.6.rc1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 2/2] bluetooth: Add bt_printk, convert logging macros to lower case
  2011-06-30  1:18             ` Joe Perches
  (?)
  (?)
@ 2011-06-30  1:18             ` Joe Perches
  2011-06-30  3:31                 ` Gustavo F. Padovan
  -1 siblings, 1 reply; 38+ messages in thread
From: Joe Perches @ 2011-06-30  1:18 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo F. Padovan
  Cc: David S. Miller, linux-bluetooth, linux-kernel, netdev

Use the more common logging styles.

bt_print uses vsprintf extension %pV.
This saves 2 to 3 % of code/text space.

$ find net/bluetooth -name "built-in.o.*" | xargs size
   text	   data	    bss	    dec	    hex	filename
  14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new
  15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
  18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new
  18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
  59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new
  61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old
  19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new
  19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
 346600	  19163	  86080	 451843	  6e503	net/bluetooth/built-in.o.new
 353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old

$ find drivers/bluetooth/ -name "built-in.o.*" | xargs size
   text	   data	    bss	    dec	    hex	filename
 129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new
 134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/bluetooth/ath3k.c          |   48 ++++----
 drivers/bluetooth/bcm203x.c        |   38 +++---
 drivers/bluetooth/bfusb.c          |   94 +++++++-------
 drivers/bluetooth/bluecard_cs.c    |   18 ++--
 drivers/bluetooth/bpa10x.c         |   38 +++---
 drivers/bluetooth/bt3c_cs.c        |   34 +++---
 drivers/bluetooth/btmrvl_debugfs.c |    2 +-
 drivers/bluetooth/btmrvl_main.c    |   74 ++++++------
 drivers/bluetooth/btmrvl_sdio.c    |  112 +++++++++---------
 drivers/bluetooth/btsdio.c         |   26 ++--
 drivers/bluetooth/btuart_cs.c      |   24 ++--
 drivers/bluetooth/btusb.c          |   64 +++++-----
 drivers/bluetooth/btwilink.c       |   34 +++---
 drivers/bluetooth/dtl1_cs.c        |   20 ++--
 drivers/bluetooth/hci_ath.c        |   14 +-
 drivers/bluetooth/hci_bcsp.c       |   58 +++++-----
 drivers/bluetooth/hci_h4.c         |   18 ++--
 drivers/bluetooth/hci_ldisc.c      |   36 +++---
 drivers/bluetooth/hci_ll.c         |   76 ++++++------
 drivers/bluetooth/hci_vhci.c       |    8 +-
 include/net/bluetooth/bluetooth.h  |    9 +-
 net/bluetooth/af_bluetooth.c       |   20 ++--
 net/bluetooth/bnep/core.c          |   26 ++--
 net/bluetooth/bnep/netdev.c        |   14 +-
 net/bluetooth/bnep/sock.c          |   10 +-
 net/bluetooth/cmtp/capi.c          |   46 ++++----
 net/bluetooth/cmtp/core.c          |   30 +++---
 net/bluetooth/cmtp/sock.c          |   10 +-
 net/bluetooth/hci_conn.c           |   52 ++++----
 net/bluetooth/hci_core.c           |  140 +++++++++++-----------
 net/bluetooth/hci_event.c          |  234 ++++++++++++++++++------------------
 net/bluetooth/hci_sock.c           |   26 ++--
 net/bluetooth/hci_sysfs.c          |   12 +-
 net/bluetooth/hidp/core.c          |   50 ++++----
 net/bluetooth/hidp/sock.c          |   10 +-
 net/bluetooth/l2cap_core.c         |  168 +++++++++++++-------------
 net/bluetooth/l2cap_sock.c         |   40 +++---
 net/bluetooth/lib.c                |   19 +++
 net/bluetooth/mgmt.c               |   80 ++++++------
 net/bluetooth/rfcomm/core.c        |  152 ++++++++++++------------
 net/bluetooth/rfcomm/sock.c        |   56 +++++-----
 net/bluetooth/rfcomm/tty.c         |  100 ++++++++--------
 net/bluetooth/sco.c                |   80 ++++++------
 net/bluetooth/smp.c                |   30 +++---
 44 files changed, 1136 insertions(+), 1114 deletions(-)

diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c
index 6bacef3..f0d8228 100644
--- a/drivers/bluetooth/ath3k.c
+++ b/drivers/bluetooth/ath3k.c
@@ -100,13 +100,13 @@ static int ath3k_load_firmware(struct usb_device *udev,
 	int err, pipe, len, size, sent = 0;
 	int count = firmware->size;
 
-	BT_DBG("udev %p", udev);
+	bt_dbg("udev %p", udev);
 
 	pipe = usb_sndctrlpipe(udev, 0);
 
 	send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
 	if (!send_buf) {
-		BT_ERR("Can't allocate memory chunk for firmware");
+		bt_err("Can't allocate memory chunk for firmware");
 		return -ENOMEM;
 	}
 
@@ -115,7 +115,7 @@ static int ath3k_load_firmware(struct usb_device *udev,
 				USB_REQ_DFU_DNLOAD,
 				USB_TYPE_VENDOR, 0, 0,
 				send_buf, 20, USB_CTRL_SET_TIMEOUT)) < 0) {
-		BT_ERR("Can't change to loading configuration err");
+		bt_err("Can't change to loading configuration err");
 		goto error;
 	}
 	sent += 20;
@@ -130,7 +130,7 @@ static int ath3k_load_firmware(struct usb_device *udev,
 					&len, 3000);
 
 		if (err || (len != size)) {
-			BT_ERR("Error in firmware loading err = %d,"
+			bt_err("Error in firmware loading err = %d,"
 				"len = %d, size = %d", err, len, size);
 			goto error;
 		}
@@ -177,7 +177,7 @@ static int ath3k_load_fwfile(struct usb_device *udev,
 
 	send_buf = kmalloc(BULK_SIZE, GFP_ATOMIC);
 	if (!send_buf) {
-		BT_ERR("Can't allocate memory chunk for firmware");
+		bt_err("Can't allocate memory chunk for firmware");
 		return -ENOMEM;
 	}
 
@@ -189,7 +189,7 @@ static int ath3k_load_fwfile(struct usb_device *udev,
 			USB_TYPE_VENDOR, 0, 0, send_buf,
 			size, USB_CTRL_SET_TIMEOUT);
 	if (ret < 0) {
-		BT_ERR("Can't change to loading configuration err");
+		bt_err("Can't change to loading configuration err");
 		kfree(send_buf);
 		return ret;
 	}
@@ -206,7 +206,7 @@ static int ath3k_load_fwfile(struct usb_device *udev,
 		err = usb_bulk_msg(udev, pipe, send_buf, size,
 					&len, 3000);
 		if (err || (len != size)) {
-			BT_ERR("Error in firmware loading err = %d,"
+			bt_err("Error in firmware loading err = %d,"
 				"len = %d, size = %d", err, len, size);
 			kfree(send_buf);
 			return err;
@@ -236,12 +236,12 @@ static int ath3k_set_normal_mode(struct usb_device *udev)
 
 	ret = ath3k_get_state(udev, &fw_state);
 	if (ret < 0) {
-		BT_ERR("Can't get state to change to normal mode err");
+		bt_err("Can't get state to change to normal mode err");
 		return ret;
 	}
 
 	if ((fw_state & ATH3K_MODE_MASK) == ATH3K_NORMAL_MODE) {
-		BT_DBG("firmware was already in normal mode");
+		bt_dbg("firmware was already in normal mode");
 		return 0;
 	}
 
@@ -261,18 +261,18 @@ static int ath3k_load_patch(struct usb_device *udev)
 
 	ret = ath3k_get_state(udev, &fw_state);
 	if (ret < 0) {
-		BT_ERR("Can't get state to change to load ram patch err");
+		bt_err("Can't get state to change to load ram patch err");
 		return ret;
 	}
 
 	if (fw_state & ATH3K_PATCH_UPDATE) {
-		BT_DBG("Patch was already downloaded");
+		bt_dbg("Patch was already downloaded");
 		return 0;
 	}
 
 	ret = ath3k_get_version(udev, &fw_version);
 	if (ret < 0) {
-		BT_ERR("Can't get version to change to load ram patch err");
+		bt_err("Can't get version to change to load ram patch err");
 		return ret;
 	}
 
@@ -281,7 +281,7 @@ static int ath3k_load_patch(struct usb_device *udev)
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {
-		BT_ERR("Patch file not found %s", filename);
+		bt_err("Patch file not found %s", filename);
 		return ret;
 	}
 
@@ -291,7 +291,7 @@ static int ath3k_load_patch(struct usb_device *udev)
 
 	if ((pt_version.rom_version != fw_version.rom_version) ||
 		(pt_version.build_version <= fw_version.build_version)) {
-		BT_ERR("Patch file version did not match with firmware");
+		bt_err("Patch file version did not match with firmware");
 		release_firmware(firmware);
 		return -EINVAL;
 	}
@@ -312,13 +312,13 @@ static int ath3k_load_syscfg(struct usb_device *udev)
 
 	ret = ath3k_get_state(udev, &fw_state);
 	if (ret < 0) {
-		BT_ERR("Can't get state to change to load configration err");
+		bt_err("Can't get state to change to load configration err");
 		return -EBUSY;
 	}
 
 	ret = ath3k_get_version(udev, &fw_version);
 	if (ret < 0) {
-		BT_ERR("Can't get version to change to load ram patch err");
+		bt_err("Can't get version to change to load ram patch err");
 		return ret;
 	}
 
@@ -343,7 +343,7 @@ static int ath3k_load_syscfg(struct usb_device *udev)
 
 	ret = request_firmware(&firmware, filename, &udev->dev);
 	if (ret < 0) {
-		BT_ERR("Configuration file not found %s", filename);
+		bt_err("Configuration file not found %s", filename);
 		return ret;
 	}
 
@@ -360,7 +360,7 @@ static int ath3k_probe(struct usb_interface *intf,
 	struct usb_device *udev = interface_to_usbdev(intf);
 	int ret;
 
-	BT_DBG("intf %p id %p", intf, id);
+	bt_dbg("intf %p id %p", intf, id);
 
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
@@ -377,17 +377,17 @@ static int ath3k_probe(struct usb_interface *intf,
 	if (id->driver_info & BTUSB_ATH3012) {
 		ret = ath3k_load_patch(udev);
 		if (ret < 0) {
-			BT_ERR("Loading patch file failed");
+			bt_err("Loading patch file failed");
 			return ret;
 		}
 		ret = ath3k_load_syscfg(udev);
 		if (ret < 0) {
-			BT_ERR("Loading sysconfig file failed");
+			bt_err("Loading sysconfig file failed");
 			return ret;
 		}
 		ret = ath3k_set_normal_mode(udev);
 		if (ret < 0) {
-			BT_ERR("Set normal mode failed");
+			bt_err("Set normal mode failed");
 			return ret;
 		}
 		ath3k_switch_pid(udev);
@@ -395,7 +395,7 @@ static int ath3k_probe(struct usb_interface *intf,
 	}
 
 	if (request_firmware(&firmware, "ath3k-1.fw", &udev->dev) < 0) {
-		BT_ERR("Error loading firmware");
+		bt_err("Error loading firmware");
 		return -EIO;
 	}
 
@@ -407,7 +407,7 @@ static int ath3k_probe(struct usb_interface *intf,
 
 static void ath3k_disconnect(struct usb_interface *intf)
 {
-	BT_DBG("ath3k_disconnect intf %p", intf);
+	bt_dbg("ath3k_disconnect intf %p", intf);
 }
 
 static struct usb_driver ath3k_driver = {
@@ -419,7 +419,7 @@ static struct usb_driver ath3k_driver = {
 
 static int __init ath3k_init(void)
 {
-	BT_INFO("Atheros AR30xx firmware driver ver %s", VERSION);
+	bt_info("Atheros AR30xx firmware driver ver %s", VERSION);
 	return usb_register(&ath3k_driver);
 }
 
diff --git a/drivers/bluetooth/bcm203x.c b/drivers/bluetooth/bcm203x.c
index 8b1b643..109dd8c 100644
--- a/drivers/bluetooth/bcm203x.c
+++ b/drivers/bluetooth/bcm203x.c
@@ -80,10 +80,10 @@ static void bcm203x_complete(struct urb *urb)
 	struct usb_device *udev = urb->dev;
 	int len;
 
-	BT_DBG("udev %p urb %p", udev, urb);
+	bt_dbg("udev %p urb %p", udev, urb);
 
 	if (urb->status) {
-		BT_ERR("URB failed with status %d", urb->status);
+		bt_err("URB failed with status %d", urb->status);
 		data->state = BCM203X_ERROR;
 		return;
 	}
@@ -107,12 +107,12 @@ static void bcm203x_complete(struct urb *urb)
 		data->state = BCM203X_CHECK_MEMORY;
 
 		if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
-			BT_ERR("Can't submit URB");
+			bt_err("Can't submit URB");
 		break;
 
 	case BCM203X_CHECK_MEMORY:
 		if (data->buffer[0] != '#') {
-			BT_ERR("Memory select failed");
+			bt_err("Memory select failed");
 			data->state = BCM203X_ERROR;
 			break;
 		}
@@ -135,12 +135,12 @@ static void bcm203x_complete(struct urb *urb)
 		}
 
 		if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
-			BT_ERR("Can't submit URB");
+			bt_err("Can't submit URB");
 		break;
 
 	case BCM203X_CHECK_FIRMWARE:
 		if (data->buffer[0] != '.') {
-			BT_ERR("Firmware loading failed");
+			bt_err("Firmware loading failed");
 			data->state = BCM203X_ERROR;
 			break;
 		}
@@ -156,7 +156,7 @@ static void bcm203x_work(struct work_struct *work)
 		container_of(work, struct bcm203x_data, work);
 
 	if (usb_submit_urb(data->urb, GFP_ATOMIC) < 0)
-		BT_ERR("Can't submit URB");
+		bt_err("Can't submit URB");
 }
 
 static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id *id)
@@ -166,14 +166,14 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 	struct bcm203x_data *data;
 	int size;
 
-	BT_DBG("intf %p id %p", intf, id);
+	bt_dbg("intf %p id %p", intf, id);
 
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
 
 	data = kzalloc(sizeof(*data), GFP_KERNEL);
 	if (!data) {
-		BT_ERR("Can't allocate memory for data structure");
+		bt_err("Can't allocate memory for data structure");
 		return -ENOMEM;
 	}
 
@@ -182,25 +182,25 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 
 	data->urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!data->urb) {
-		BT_ERR("Can't allocate URB");
+		bt_err("Can't allocate URB");
 		kfree(data);
 		return -ENOMEM;
 	}
 
 	if (request_firmware(&firmware, "BCM2033-MD.hex", &udev->dev) < 0) {
-		BT_ERR("Mini driver request failed");
+		bt_err("Mini driver request failed");
 		usb_free_urb(data->urb);
 		kfree(data);
 		return -EIO;
 	}
 
-	BT_DBG("minidrv data %p size %zu", firmware->data, firmware->size);
+	bt_dbg("minidrv data %p size %zu", firmware->data, firmware->size);
 
 	size = max_t(uint, firmware->size, 4096);
 
 	data->buffer = kmalloc(size, GFP_KERNEL);
 	if (!data->buffer) {
-		BT_ERR("Can't allocate memory for mini driver");
+		bt_err("Can't allocate memory for mini driver");
 		release_firmware(firmware);
 		usb_free_urb(data->urb);
 		kfree(data);
@@ -215,18 +215,18 @@ static int bcm203x_probe(struct usb_interface *intf, const struct usb_device_id
 	release_firmware(firmware);
 
 	if (request_firmware(&firmware, "BCM2033-FW.bin", &udev->dev) < 0) {
-		BT_ERR("Firmware request failed");
+		bt_err("Firmware request failed");
 		usb_free_urb(data->urb);
 		kfree(data->buffer);
 		kfree(data);
 		return -EIO;
 	}
 
-	BT_DBG("firmware data %p size %zu", firmware->data, firmware->size);
+	bt_dbg("firmware data %p size %zu", firmware->data, firmware->size);
 
 	data->fw_data = kmemdup(firmware->data, firmware->size, GFP_KERNEL);
 	if (!data->fw_data) {
-		BT_ERR("Can't allocate memory for firmware image");
+		bt_err("Can't allocate memory for firmware image");
 		release_firmware(firmware);
 		usb_free_urb(data->urb);
 		kfree(data->buffer);
@@ -252,7 +252,7 @@ static void bcm203x_disconnect(struct usb_interface *intf)
 {
 	struct bcm203x_data *data = usb_get_intfdata(intf);
 
-	BT_DBG("intf %p", intf);
+	bt_dbg("intf %p", intf);
 
 	usb_kill_urb(data->urb);
 
@@ -275,11 +275,11 @@ static int __init bcm203x_init(void)
 {
 	int err;
 
-	BT_INFO("Broadcom Blutonium firmware driver ver %s", VERSION);
+	bt_info("Broadcom Blutonium firmware driver ver %s", VERSION);
 
 	err = usb_register(&bcm203x_driver);
 	if (err < 0)
-		BT_ERR("Failed to register USB driver");
+		bt_err("Failed to register USB driver");
 
 	return err;
 }
diff --git a/drivers/bluetooth/bfusb.c b/drivers/bluetooth/bfusb.c
index 005919a..b574c90 100644
--- a/drivers/bluetooth/bfusb.c
+++ b/drivers/bluetooth/bfusb.c
@@ -95,7 +95,7 @@ static struct urb *bfusb_get_completed(struct bfusb_data *data)
 	struct sk_buff *skb;
 	struct urb *urb = NULL;
 
-	BT_DBG("bfusb %p", data);
+	bt_dbg("bfusb %p", data);
 
 	skb = skb_dequeue(&data->completed_q);
 	if (skb) {
@@ -111,7 +111,7 @@ static void bfusb_unlink_urbs(struct bfusb_data *data)
 	struct sk_buff *skb;
 	struct urb *urb;
 
-	BT_DBG("bfusb %p", data);
+	bt_dbg("bfusb %p", data);
 
 	while ((skb = skb_dequeue(&data->pending_q))) {
 		urb = ((struct bfusb_data_scb *) skb->cb)->urb;
@@ -129,7 +129,7 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
 	struct urb *urb = bfusb_get_completed(data);
 	int err, pipe;
 
-	BT_DBG("bfusb %p skb %p len %d", data, skb, skb->len);
+	bt_dbg("bfusb %p skb %p len %d", data, skb, skb->len);
 
 	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
 		return -ENOMEM;
@@ -145,7 +145,7 @@ static int bfusb_send_bulk(struct bfusb_data *data, struct sk_buff *skb)
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err) {
-		BT_ERR("%s bulk tx submit failed urb %p err %d", 
+		bt_err("%s bulk tx submit failed urb %p err %d", 
 					data->hdev->name, urb, err);
 		skb_unlink(skb, &data->pending_q);
 		usb_free_urb(urb);
@@ -159,7 +159,7 @@ static void bfusb_tx_wakeup(struct bfusb_data *data)
 {
 	struct sk_buff *skb;
 
-	BT_DBG("bfusb %p", data);
+	bt_dbg("bfusb %p", data);
 
 	if (test_and_set_bit(BFUSB_TX_PROCESS, &data->state)) {
 		set_bit(BFUSB_TX_WAKEUP, &data->state);
@@ -187,7 +187,7 @@ static void bfusb_tx_complete(struct urb *urb)
 	struct sk_buff *skb = (struct sk_buff *) urb->context;
 	struct bfusb_data *data = (struct bfusb_data *) skb->dev;
 
-	BT_DBG("bfusb %p urb %p skb %p len %d", data, urb, skb, skb->len);
+	bt_dbg("bfusb %p urb %p skb %p len %d", data, urb, skb, skb->len);
 
 	atomic_dec(&data->pending_tx);
 
@@ -216,7 +216,7 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
 	struct sk_buff *skb;
 	int err, pipe, size = HCI_MAX_FRAME_SIZE + 32;
 
-	BT_DBG("bfusb %p urb %p", data, urb);
+	bt_dbg("bfusb %p urb %p", data, urb);
 
 	if (!urb && !(urb = usb_alloc_urb(0, GFP_ATOMIC)))
 		return -ENOMEM;
@@ -241,7 +241,7 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err) {
-		BT_ERR("%s bulk rx submit failed urb %p err %d",
+		bt_err("%s bulk rx submit failed urb %p err %d",
 					data->hdev->name, urb, err);
 		skb_unlink(skb, &data->pending_q);
 		kfree_skb(skb);
@@ -253,10 +253,10 @@ static int bfusb_rx_submit(struct bfusb_data *data, struct urb *urb)
 
 static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned char *buf, int len)
 {
-	BT_DBG("bfusb %p hdr 0x%02x data %p len %d", data, hdr, buf, len);
+	bt_dbg("bfusb %p hdr 0x%02x data %p len %d", data, hdr, buf, len);
 
 	if (hdr & 0x10) {
-		BT_ERR("%s error in block", data->hdev->name);
+		bt_err("%s error in block", data->hdev->name);
 		kfree_skb(data->reassembly);
 		data->reassembly = NULL;
 		return -EIO;
@@ -268,13 +268,13 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 		int pkt_len = 0;
 
 		if (data->reassembly) {
-			BT_ERR("%s unexpected start block", data->hdev->name);
+			bt_err("%s unexpected start block", data->hdev->name);
 			kfree_skb(data->reassembly);
 			data->reassembly = NULL;
 		}
 
 		if (len < 1) {
-			BT_ERR("%s no packet type found", data->hdev->name);
+			bt_err("%s no packet type found", data->hdev->name);
 			return -EPROTO;
 		}
 
@@ -286,7 +286,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 				struct hci_event_hdr *hdr = (struct hci_event_hdr *) buf;
 				pkt_len = HCI_EVENT_HDR_SIZE + hdr->plen;
 			} else {
-				BT_ERR("%s event block is too short", data->hdev->name);
+				bt_err("%s event block is too short", data->hdev->name);
 				return -EILSEQ;
 			}
 			break;
@@ -296,7 +296,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 				struct hci_acl_hdr *hdr = (struct hci_acl_hdr *) buf;
 				pkt_len = HCI_ACL_HDR_SIZE + __le16_to_cpu(hdr->dlen);
 			} else {
-				BT_ERR("%s data block is too short", data->hdev->name);
+				bt_err("%s data block is too short", data->hdev->name);
 				return -EILSEQ;
 			}
 			break;
@@ -306,7 +306,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 				struct hci_sco_hdr *hdr = (struct hci_sco_hdr *) buf;
 				pkt_len = HCI_SCO_HDR_SIZE + hdr->dlen;
 			} else {
-				BT_ERR("%s audio block is too short", data->hdev->name);
+				bt_err("%s audio block is too short", data->hdev->name);
 				return -EILSEQ;
 			}
 			break;
@@ -314,7 +314,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 
 		skb = bt_skb_alloc(pkt_len, GFP_ATOMIC);
 		if (!skb) {
-			BT_ERR("%s no memory for the packet", data->hdev->name);
+			bt_err("%s no memory for the packet", data->hdev->name);
 			return -ENOMEM;
 		}
 
@@ -324,7 +324,7 @@ static inline int bfusb_recv_block(struct bfusb_data *data, int hdr, unsigned ch
 		data->reassembly = skb;
 	} else {
 		if (!data->reassembly) {
-			BT_ERR("%s unexpected continuation block", data->hdev->name);
+			bt_err("%s unexpected continuation block", data->hdev->name);
 			return -EIO;
 		}
 	}
@@ -348,7 +348,7 @@ static void bfusb_rx_complete(struct urb *urb)
 	int count = urb->actual_length;
 	int err, hdr, len;
 
-	BT_DBG("bfusb %p urb %p skb %p len %d", data, urb, skb, skb->len);
+	bt_dbg("bfusb %p urb %p skb %p len %d", data, urb, skb, skb->len);
 
 	read_lock(&data->lock);
 
@@ -376,7 +376,7 @@ static void bfusb_rx_complete(struct urb *urb)
 		}
 
 		if (count < len) {
-			BT_ERR("%s block extends over URB buffer ranges",
+			bt_err("%s block extends over URB buffer ranges",
 					data->hdev->name);
 		}
 
@@ -401,7 +401,7 @@ resubmit:
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err) {
-		BT_ERR("%s bulk resubmit failed urb %p err %d",
+		bt_err("%s bulk resubmit failed urb %p err %d",
 					data->hdev->name, urb, err);
 	}
 
@@ -415,7 +415,7 @@ static int bfusb_open(struct hci_dev *hdev)
 	unsigned long flags;
 	int i, err;
 
-	BT_DBG("hdev %p bfusb %p", hdev, data);
+	bt_dbg("hdev %p bfusb %p", hdev, data);
 
 	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -439,7 +439,7 @@ static int bfusb_flush(struct hci_dev *hdev)
 {
 	struct bfusb_data *data = hdev->driver_data;
 
-	BT_DBG("hdev %p bfusb %p", hdev, data);
+	bt_dbg("hdev %p bfusb %p", hdev, data);
 
 	skb_queue_purge(&data->transmit_q);
 
@@ -451,7 +451,7 @@ static int bfusb_close(struct hci_dev *hdev)
 	struct bfusb_data *data = hdev->driver_data;
 	unsigned long flags;
 
-	BT_DBG("hdev %p bfusb %p", hdev, data);
+	bt_dbg("hdev %p bfusb %p", hdev, data);
 
 	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -473,10 +473,10 @@ static int bfusb_send_frame(struct sk_buff *skb)
 	unsigned char buf[3];
 	int sent = 0, size, count;
 
-	BT_DBG("hdev %p skb %p type %d len %d", hdev, skb, bt_cb(skb)->pkt_type, skb->len);
+	bt_dbg("hdev %p skb %p type %d len %d", hdev, skb, bt_cb(skb)->pkt_type, skb->len);
 
 	if (!hdev) {
-		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+		bt_err("Frame for unknown HCI device (hdev=NULL)");
 		return -ENODEV;
 	}
 
@@ -505,7 +505,7 @@ static int bfusb_send_frame(struct sk_buff *skb)
 	/* Max HCI frame size seems to be 1511 + 1 */
 	nskb = bt_skb_alloc(count + 32, GFP_ATOMIC);
 	if (!nskb) {
-		BT_ERR("Can't allocate memory for new packet");
+		bt_err("Can't allocate memory for new packet");
 		return -ENOMEM;
 	}
 
@@ -548,7 +548,7 @@ static void bfusb_destruct(struct hci_dev *hdev)
 {
 	struct bfusb_data *data = hdev->driver_data;
 
-	BT_DBG("hdev %p bfusb %p", hdev, data);
+	bt_dbg("hdev %p bfusb %p", hdev, data);
 
 	kfree(data);
 }
@@ -564,15 +564,15 @@ static int bfusb_load_firmware(struct bfusb_data *data,
 	unsigned char *buf;
 	int err, pipe, len, size, sent = 0;
 
-	BT_DBG("bfusb %p udev %p", data, data->udev);
+	bt_dbg("bfusb %p udev %p", data, data->udev);
 
-	BT_INFO("BlueFRITZ! USB loading firmware");
+	bt_info("BlueFRITZ! USB loading firmware");
 
 	pipe = usb_sndctrlpipe(data->udev, 0);
 
 	if (usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION,
 				0, 1, 0, NULL, 0, USB_CTRL_SET_TIMEOUT) < 0) {
-		BT_ERR("Can't change to loading configuration");
+		bt_err("Can't change to loading configuration");
 		return -EBUSY;
 	}
 
@@ -580,7 +580,7 @@ static int bfusb_load_firmware(struct bfusb_data *data,
 
 	buf = kmalloc(BFUSB_MAX_BLOCK_SIZE + 3, GFP_ATOMIC);
 	if (!buf) {
-		BT_ERR("Can't allocate memory chunk for firmware");
+		bt_err("Can't allocate memory chunk for firmware");
 		return -ENOMEM;
 	}
 
@@ -595,7 +595,7 @@ static int bfusb_load_firmware(struct bfusb_data *data,
 					&len, BFUSB_BLOCK_TIMEOUT);
 
 		if (err || (len != size)) {
-			BT_ERR("Error in firmware loading");
+			bt_err("Error in firmware loading");
 			goto error;
 		}
 
@@ -606,7 +606,7 @@ static int bfusb_load_firmware(struct bfusb_data *data,
 	err = usb_bulk_msg(data->udev, pipe, NULL, 0,
 					&len, BFUSB_BLOCK_TIMEOUT);
 	if (err < 0) {
-		BT_ERR("Error in null packet request");
+		bt_err("Error in null packet request");
 		goto error;
 	}
 
@@ -615,13 +615,13 @@ static int bfusb_load_firmware(struct bfusb_data *data,
 	err = usb_control_msg(data->udev, pipe, USB_REQ_SET_CONFIGURATION,
 				0, 2, 0, NULL, 0, USB_CTRL_SET_TIMEOUT);
 	if (err < 0) {
-		BT_ERR("Can't change to running configuration");
+		bt_err("Can't change to running configuration");
 		goto error;
 	}
 
 	data->udev->toggle[0] = data->udev->toggle[1] = 0;
 
-	BT_INFO("BlueFRITZ! USB device ready");
+	bt_info("BlueFRITZ! USB device ready");
 
 	kfree(buf);
 	return 0;
@@ -646,7 +646,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	struct hci_dev *hdev;
 	struct bfusb_data *data;
 
-	BT_DBG("intf %p id %p", intf, id);
+	bt_dbg("intf %p id %p", intf, id);
 
 	/* Check number of endpoints */
 	if (intf->cur_altsetting->desc.bNumEndpoints < 2)
@@ -656,14 +656,14 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	bulk_in_ep  = &intf->cur_altsetting->endpoint[1];
 
 	if (!bulk_out_ep || !bulk_in_ep) {
-		BT_ERR("Bulk endpoints not found");
+		bt_err("Bulk endpoints not found");
 		goto done;
 	}
 
 	/* Initialize control structure and load firmware */
 	data = kzalloc(sizeof(struct bfusb_data), GFP_KERNEL);
 	if (!data) {
-		BT_ERR("Can't allocate memory for control structure");
+		bt_err("Can't allocate memory for control structure");
 		goto done;
 	}
 
@@ -681,14 +681,14 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	skb_queue_head_init(&data->completed_q);
 
 	if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) {
-		BT_ERR("Firmware request failed");
+		bt_err("Firmware request failed");
 		goto error;
 	}
 
-	BT_DBG("firmware data %p size %zu", firmware->data, firmware->size);
+	bt_dbg("firmware data %p size %zu", firmware->data, firmware->size);
 
 	if (bfusb_load_firmware(data, firmware->data, firmware->size) < 0) {
-		BT_ERR("Firmware loading failed");
+		bt_err("Firmware loading failed");
 		goto release;
 	}
 
@@ -697,7 +697,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	/* Initialize and register HCI device */
 	hdev = hci_alloc_dev();
 	if (!hdev) {
-		BT_ERR("Can't allocate HCI device");
+		bt_err("Can't allocate HCI device");
 		goto error;
 	}
 
@@ -717,7 +717,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
 	hdev->owner = THIS_MODULE;
 
 	if (hci_register_dev(hdev) < 0) {
-		BT_ERR("Can't register HCI device");
+		bt_err("Can't register HCI device");
 		hci_free_dev(hdev);
 		goto error;
 	}
@@ -741,7 +741,7 @@ static void bfusb_disconnect(struct usb_interface *intf)
 	struct bfusb_data *data = usb_get_intfdata(intf);
 	struct hci_dev *hdev = data->hdev;
 
-	BT_DBG("intf %p", intf);
+	bt_dbg("intf %p", intf);
 
 	if (!hdev)
 		return;
@@ -751,7 +751,7 @@ static void bfusb_disconnect(struct usb_interface *intf)
 	bfusb_close(hdev);
 
 	if (hci_unregister_dev(hdev) < 0)
-		BT_ERR("Can't unregister HCI device %s", hdev->name);
+		bt_err("Can't unregister HCI device %s", hdev->name);
 
 	hci_free_dev(hdev);
 }
@@ -767,11 +767,11 @@ static int __init bfusb_init(void)
 {
 	int err;
 
-	BT_INFO("BlueFRITZ! USB driver ver %s", VERSION);
+	bt_info("BlueFRITZ! USB driver ver %s", VERSION);
 
 	err = usb_register(&bfusb_driver);
 	if (err < 0)
-		BT_ERR("Failed to register BlueFRITZ! USB driver");
+		bt_err("Failed to register BlueFRITZ! USB driver");
 
 	return err;
 }
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index aed1904..aaf9b03 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -218,7 +218,7 @@ static int bluecard_write(unsigned int iobase, unsigned int offset, __u8 *buf, i
 static void bluecard_write_wakeup(bluecard_info_t *info)
 {
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -374,7 +374,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
 	int i, len;
 
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -392,7 +392,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
 			info->rx_state = RECV_WAIT_PACKET_TYPE;
 			info->rx_count = 0;
 			if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
-				BT_ERR("Can't allocate mem for new packet");
+				bt_err("Can't allocate mem for new packet");
 				return;
 			}
 		}
@@ -434,7 +434,7 @@ static void bluecard_receive(bluecard_info_t *info, unsigned int offset)
 
 			default:
 				/* unknown packet */
-				BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
+				bt_err("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
 				info->hdev->stat.err_rx++;
 
 				kfree_skb(info->rx_skb);
@@ -568,7 +568,7 @@ static int bluecard_hci_set_baud_rate(struct hci_dev *hdev, int baud)
 	unsigned char cmd[] = { HCI_COMMAND_PKT, 0x09, 0xfc, 0x01, 0x03 };
 
 	if (!(skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
-		BT_ERR("Can't allocate mem for new packet");
+		bt_err("Can't allocate mem for new packet");
 		return -1;
 	}
 
@@ -663,7 +663,7 @@ static int bluecard_hci_send_frame(struct sk_buff *skb)
 	struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
 
 	if (!hdev) {
-		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+		bt_err("Frame for unknown HCI device (hdev=NULL)");
 		return -ENODEV;
 	}
 
@@ -727,7 +727,7 @@ static int bluecard_open(bluecard_info_t *info)
 	/* Initialize HCI device */
 	hdev = hci_alloc_dev();
 	if (!hdev) {
-		BT_ERR("Can't allocate HCI device");
+		bt_err("Can't allocate HCI device");
 		return -ENOMEM;
 	}
 
@@ -815,7 +815,7 @@ static int bluecard_open(bluecard_info_t *info)
 
 	/* Register HCI device */
 	if (hci_register_dev(hdev) < 0) {
-		BT_ERR("Can't register HCI device");
+		bt_err("Can't register HCI device");
 		info->hdev = NULL;
 		hci_free_dev(hdev);
 		return -ENODEV;
@@ -845,7 +845,7 @@ static int bluecard_close(bluecard_info_t *info)
 	outb(0x80, iobase + 0x30);
 
 	if (hci_unregister_dev(hdev) < 0)
-		BT_ERR("Can't unregister HCI device %s", hdev->name);
+		bt_err("Can't unregister HCI device %s", hdev->name);
 
 	hci_free_dev(hdev);
 
diff --git a/drivers/bluetooth/bpa10x.c b/drivers/bluetooth/bpa10x.c
index 751b338..59e8ab3 100644
--- a/drivers/bluetooth/bpa10x.c
+++ b/drivers/bluetooth/bpa10x.c
@@ -68,7 +68,7 @@ static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count)
 {
 	struct bpa10x_data *data = hdev->driver_data;
 
-	BT_DBG("%s queue %d buffer %p count %d", hdev->name,
+	bt_dbg("%s queue %d buffer %p count %d", hdev->name,
 							queue, buf, count);
 
 	if (queue < 0 || queue > 1)
@@ -125,7 +125,7 @@ static int bpa10x_recv(struct hci_dev *hdev, int queue, void *buf, int count)
 
 			skb = bt_skb_alloc(len, GFP_ATOMIC);
 			if (!skb) {
-				BT_ERR("%s no memory for packet", hdev->name);
+				bt_err("%s no memory for packet", hdev->name);
 				return -ENOMEM;
 			}
 
@@ -169,7 +169,7 @@ static void bpa10x_tx_complete(struct urb *urb)
 	struct sk_buff *skb = urb->context;
 	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
 
-	BT_DBG("%s urb %p status %d count %d", hdev->name,
+	bt_dbg("%s urb %p status %d count %d", hdev->name,
 					urb, urb->status, urb->actual_length);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
@@ -192,7 +192,7 @@ static void bpa10x_rx_complete(struct urb *urb)
 	struct bpa10x_data *data = hdev->driver_data;
 	int err;
 
-	BT_DBG("%s urb %p status %d count %d", hdev->name,
+	bt_dbg("%s urb %p status %d count %d", hdev->name,
 					urb, urb->status, urb->actual_length);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
@@ -202,7 +202,7 @@ static void bpa10x_rx_complete(struct urb *urb)
 		if (bpa10x_recv(hdev, usb_pipebulk(urb->pipe),
 						urb->transfer_buffer,
 						urb->actual_length) < 0) {
-			BT_ERR("%s corrupted event packet", hdev->name);
+			bt_err("%s corrupted event packet", hdev->name);
 			hdev->stat.err_rx++;
 		}
 	}
@@ -211,7 +211,7 @@ static void bpa10x_rx_complete(struct urb *urb)
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err < 0) {
-		BT_ERR("%s urb %p failed to resubmit (%d)",
+		bt_err("%s urb %p failed to resubmit (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -225,7 +225,7 @@ static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev)
 	unsigned int pipe;
 	int err, size = 16;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!urb)
@@ -248,7 +248,7 @@ static inline int bpa10x_submit_intr_urb(struct hci_dev *hdev)
 
 	err = usb_submit_urb(urb, GFP_KERNEL);
 	if (err < 0) {
-		BT_ERR("%s urb %p submission failed (%d)",
+		bt_err("%s urb %p submission failed (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -266,7 +266,7 @@ static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev)
 	unsigned int pipe;
 	int err, size = 64;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	urb = usb_alloc_urb(0, GFP_KERNEL);
 	if (!urb)
@@ -289,7 +289,7 @@ static inline int bpa10x_submit_bulk_urb(struct hci_dev *hdev)
 
 	err = usb_submit_urb(urb, GFP_KERNEL);
 	if (err < 0) {
-		BT_ERR("%s urb %p submission failed (%d)",
+		bt_err("%s urb %p submission failed (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -304,7 +304,7 @@ static int bpa10x_open(struct hci_dev *hdev)
 	struct bpa10x_data *data = hdev->driver_data;
 	int err;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -331,7 +331,7 @@ static int bpa10x_close(struct hci_dev *hdev)
 {
 	struct bpa10x_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -345,7 +345,7 @@ static int bpa10x_flush(struct hci_dev *hdev)
 {
 	struct bpa10x_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	usb_kill_anchored_urbs(&data->tx_anchor);
 
@@ -361,7 +361,7 @@ static int bpa10x_send_frame(struct sk_buff *skb)
 	unsigned int pipe;
 	int err;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
 		return -EBUSY;
@@ -422,7 +422,7 @@ static int bpa10x_send_frame(struct sk_buff *skb)
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err < 0) {
-		BT_ERR("%s urb %p submission failed", hdev->name, urb);
+		bt_err("%s urb %p submission failed", hdev->name, urb);
 		kfree(urb->setup_packet);
 		usb_unanchor_urb(urb);
 	}
@@ -436,7 +436,7 @@ static void bpa10x_destruct(struct hci_dev *hdev)
 {
 	struct bpa10x_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	kfree_skb(data->rx_skb[0]);
 	kfree_skb(data->rx_skb[1]);
@@ -449,7 +449,7 @@ static int bpa10x_probe(struct usb_interface *intf, const struct usb_device_id *
 	struct hci_dev *hdev;
 	int err;
 
-	BT_DBG("intf %p id %p", intf, id);
+	bt_dbg("intf %p id %p", intf, id);
 
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
 		return -ENODEV;
@@ -502,7 +502,7 @@ static void bpa10x_disconnect(struct usb_interface *intf)
 {
 	struct bpa10x_data *data = usb_get_intfdata(intf);
 
-	BT_DBG("intf %p", intf);
+	bt_dbg("intf %p", intf);
 
 	if (!data)
 		return;
@@ -523,7 +523,7 @@ static struct usb_driver bpa10x_driver = {
 
 static int __init bpa10x_init(void)
 {
-	BT_INFO("Digianswer Bluetooth USB driver ver %s", VERSION);
+	bt_info("Digianswer Bluetooth USB driver ver %s", VERSION);
 
 	return usb_register(&bpa10x_driver);
 }
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 4fc0194..cc83eeb 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -179,7 +179,7 @@ static int bt3c_write(unsigned int iobase, int fifo_size, __u8 *buf, int len)
 static void bt3c_write_wakeup(bt3c_info_t *info)
 {
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -204,7 +204,7 @@ static void bt3c_write_wakeup(bt3c_info_t *info)
 		len = bt3c_write(iobase, 256, skb->data, skb->len);
 
 		if (len != skb->len) {
-			BT_ERR("Very strange");
+			bt_err("Very strange");
 		}
 
 		kfree_skb(skb);
@@ -221,7 +221,7 @@ static void bt3c_receive(bt3c_info_t *info)
 	int size = 0, avail;
 
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -240,7 +240,7 @@ static void bt3c_receive(bt3c_info_t *info)
 			info->rx_state = RECV_WAIT_PACKET_TYPE;
 			info->rx_count = 0;
 			if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
-				BT_ERR("Can't allocate mem for new packet");
+				bt_err("Can't allocate mem for new packet");
 				return;
 			}
 		}
@@ -272,7 +272,7 @@ static void bt3c_receive(bt3c_info_t *info)
 
 			default:
 				/* Unknown packet */
-				BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
+				bt_err("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
 				info->hdev->stat.err_rx++;
 				clear_bit(HCI_RUNNING, &(info->hdev->flags));
 
@@ -355,17 +355,17 @@ static irqreturn_t bt3c_interrupt(int irq, void *dev_inst)
 		int stat = bt3c_read(iobase, 0x7001);
 
 		if ((stat & 0xff) == 0x7f) {
-			BT_ERR("Very strange (stat=0x%04x)", stat);
+			bt_err("Very strange (stat=0x%04x)", stat);
 		} else if ((stat & 0xff) != 0xff) {
 			if (stat & 0x0020) {
 				int status = bt3c_read(iobase, 0x7002) & 0x10;
-				BT_INFO("%s: Antenna %s", info->hdev->name,
+				bt_info("%s: Antenna %s", info->hdev->name,
 							status ? "out" : "in");
 			}
 			if (stat & 0x0001)
 				bt3c_receive(info);
 			if (stat & 0x0002) {
-				//BT_ERR("Ack (stat=0x%04x)", stat);
+				//bt_err("Ack (stat=0x%04x)", stat);
 				clear_bit(XMIT_SENDING, &(info->tx_state));
 				bt3c_write_wakeup(info);
 			}
@@ -424,7 +424,7 @@ static int bt3c_hci_send_frame(struct sk_buff *skb)
 	unsigned long flags;
 
 	if (!hdev) {
-		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+		bt_err("Frame for unknown HCI device (hdev=NULL)");
 		return -ENODEV;
 	}
 
@@ -494,7 +494,7 @@ static int bt3c_load_firmware(bt3c_info_t *info, const unsigned char *firmware,
 	/* Load */
 	while (count) {
 		if (ptr[0] != 'S') {
-			BT_ERR("Bad address in firmware");
+			bt_err("Bad address in firmware");
 			err = -EFAULT;
 			goto error;
 		}
@@ -518,7 +518,7 @@ static int bt3c_load_firmware(bt3c_info_t *info, const unsigned char *firmware,
 		}
 
 		if (((tmp + fcs) & 0xff) != 0xff) {
-			BT_ERR("Checksum error in firmware");
+			bt_err("Checksum error in firmware");
 			err = -EILSEQ;
 			goto error;
 		}
@@ -573,7 +573,7 @@ static int bt3c_open(bt3c_info_t *info)
 	/* Initialize HCI device */
 	hdev = hci_alloc_dev();
 	if (!hdev) {
-		BT_ERR("Can't allocate HCI device");
+		bt_err("Can't allocate HCI device");
 		return -ENOMEM;
 	}
 
@@ -595,7 +595,7 @@ static int bt3c_open(bt3c_info_t *info)
 	/* Load firmware */
 	err = request_firmware(&firmware, "BT3CPCC.bin", &info->p_dev->dev);
 	if (err < 0) {
-		BT_ERR("Firmware request failed");
+		bt_err("Firmware request failed");
 		goto error;
 	}
 
@@ -604,7 +604,7 @@ static int bt3c_open(bt3c_info_t *info)
 	release_firmware(firmware);
 
 	if (err < 0) {
-		BT_ERR("Firmware loading failed");
+		bt_err("Firmware loading failed");
 		goto error;
 	}
 
@@ -614,7 +614,7 @@ static int bt3c_open(bt3c_info_t *info)
 	/* Register HCI device */
 	err = hci_register_dev(hdev);
 	if (err < 0) {
-		BT_ERR("Can't register HCI device");
+		bt_err("Can't register HCI device");
 		goto error;
 	}
 
@@ -637,7 +637,7 @@ static int bt3c_close(bt3c_info_t *info)
 	bt3c_hci_close(hdev);
 
 	if (hci_unregister_dev(hdev) < 0)
-		BT_ERR("Can't unregister HCI device %s", hdev->name);
+		bt_err("Can't unregister HCI device %s", hdev->name);
 
 	hci_free_dev(hdev);
 
@@ -728,7 +728,7 @@ static int bt3c_config(struct pcmcia_device *link)
 	if (!pcmcia_loop_config(link, bt3c_check_config_notpicky, NULL))
 		goto found_port;
 
-	BT_ERR("No usable port range found");
+	bt_err("No usable port range found");
 	goto failed;
 
 found_port:
diff --git a/drivers/bluetooth/btmrvl_debugfs.c b/drivers/bluetooth/btmrvl_debugfs.c
index 8ecf4c6..5a96a21 100644
--- a/drivers/bluetooth/btmrvl_debugfs.c
+++ b/drivers/bluetooth/btmrvl_debugfs.c
@@ -394,7 +394,7 @@ void btmrvl_debugfs_init(struct hci_dev *hdev)
 	priv->debugfs_data = dbg;
 
 	if (!dbg) {
-		BT_ERR("Can not allocate memory for btmrvl_debugfs_data.");
+		bt_err("Can not allocate memory for btmrvl_debugfs_data.");
 		return;
 	}
 
diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index 548d1d9..f5352a1 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -70,7 +70,7 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
 
 	event = (struct btmrvl_event *) skb->data;
 	if (event->ec != 0xff) {
-		BT_DBG("Not Marvell Event=%x", event->ec);
+		bt_dbg("Not Marvell Event=%x", event->ec);
 		ret = -EINVAL;
 		goto exit;
 	}
@@ -82,19 +82,19 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
 				adapter->psmode = 1;
 			else
 				adapter->psmode = 0;
-			BT_DBG("PS Mode:%s",
+			bt_dbg("PS Mode:%s",
 				(adapter->psmode) ? "Enable" : "Disable");
 		} else {
-			BT_DBG("PS Mode command failed");
+			bt_dbg("PS Mode command failed");
 		}
 		break;
 
 	case BT_CMD_HOST_SLEEP_CONFIG:
 		if (!event->data[3])
-			BT_DBG("gpio=%x, gap=%x", event->data[1],
+			bt_dbg("gpio=%x, gap=%x", event->data[1],
 							event->data[2]);
 		else
-			BT_DBG("HSCFG command failed");
+			bt_dbg("HSCFG command failed");
 		break;
 
 	case BT_CMD_HOST_SLEEP_ENABLE:
@@ -103,16 +103,16 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
 			if (adapter->psmode)
 				adapter->ps_state = PS_SLEEP;
 			wake_up_interruptible(&adapter->cmd_wait_q);
-			BT_DBG("HS ACTIVATED!");
+			bt_dbg("HS ACTIVATED!");
 		} else {
-			BT_DBG("HS Enable failed");
+			bt_dbg("HS Enable failed");
 		}
 		break;
 
 	case BT_CMD_MODULE_CFG_REQ:
 		if (priv->btmrvl_dev.sendcmdflag &&
 				event->data[1] == MODULE_BRINGUP_REQ) {
-			BT_DBG("EVENT:%s",
+			bt_dbg("EVENT:%s",
 				((event->data[2] == MODULE_BROUGHT_UP) ||
 				(event->data[2] == MODULE_ALREADY_UP)) ?
 				"Bring-up succeed" : "Bring-up failed");
@@ -122,13 +122,13 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
 			else
 				priv->btmrvl_dev.dev_type = HCI_BREDR;
 
-			BT_DBG("dev_type: %d", priv->btmrvl_dev.dev_type);
+			bt_dbg("dev_type: %d", priv->btmrvl_dev.dev_type);
 		} else if (priv->btmrvl_dev.sendcmdflag &&
 				event->data[1] == MODULE_SHUTDOWN_REQ) {
-			BT_DBG("EVENT:%s", (event->data[2]) ?
+			bt_dbg("EVENT:%s", (event->data[2]) ?
 				"Shutdown failed" : "Shutdown succeed");
 		} else {
-			BT_DBG("BT_CMD_MODULE_CFG_REQ resp for APP");
+			bt_dbg("BT_CMD_MODULE_CFG_REQ resp for APP");
 			ret = -EINVAL;
 		}
 		break;
@@ -136,12 +136,12 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
 	case BT_EVENT_POWER_STATE:
 		if (event->data[1] == BT_PS_SLEEP)
 			adapter->ps_state = PS_SLEEP;
-		BT_DBG("EVENT:%s",
+		bt_dbg("EVENT:%s",
 			(adapter->ps_state) ? "PS_SLEEP" : "PS_AWAKE");
 		break;
 
 	default:
-		BT_DBG("Unknown Event=%d", event->data[0]);
+		bt_dbg("Unknown Event=%d", event->data[0]);
 		ret = -EINVAL;
 		break;
 	}
@@ -162,7 +162,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
 
 	skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
 	if (skb == NULL) {
-		BT_ERR("No free skb");
+		bt_err("No free skb");
 		return -ENOMEM;
 	}
 
@@ -180,7 +180,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
 
 	priv->adapter->cmd_complete = false;
 
-	BT_DBG("Queue module cfg Command");
+	bt_dbg("Queue module cfg Command");
 
 	wake_up_interruptible(&priv->main_thread.wait_q);
 
@@ -188,11 +188,11 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
 				priv->adapter->cmd_complete,
 				msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) {
 		ret = -ETIMEDOUT;
-		BT_ERR("module_cfg_cmd(%x): timeout: %d",
+		bt_err("module_cfg_cmd(%x): timeout: %d",
 					subcmd, priv->btmrvl_dev.sendcmdflag);
 	}
 
-	BT_DBG("module cfg Command done");
+	bt_dbg("module cfg Command done");
 
 	return ret;
 }
@@ -205,7 +205,7 @@ int btmrvl_enable_ps(struct btmrvl_private *priv)
 
 	skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
 	if (skb == NULL) {
-		BT_ERR("No free skb");
+		bt_err("No free skb");
 		return -ENOMEM;
 	}
 
@@ -224,7 +224,7 @@ int btmrvl_enable_ps(struct btmrvl_private *priv)
 	skb->dev = (void *) priv->btmrvl_dev.hcidev;
 	skb_queue_head(&priv->adapter->tx_queue, skb);
 
-	BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
+	bt_dbg("Queue PSMODE Command:%d", cmd->data[0]);
 
 	return 0;
 }
@@ -238,7 +238,7 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv)
 
 	skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
 	if (skb == NULL) {
-		BT_ERR("No free skb");
+		bt_err("No free skb");
 		return -ENOMEM;
 	}
 
@@ -251,7 +251,7 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv)
 	skb->dev = (void *) priv->btmrvl_dev.hcidev;
 	skb_queue_head(&priv->adapter->tx_queue, skb);
 
-	BT_DBG("Queue hs enable Command");
+	bt_dbg("Queue hs enable Command");
 
 	wake_up_interruptible(&priv->main_thread.wait_q);
 
@@ -259,7 +259,7 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv)
 			priv->adapter->hs_state,
 			msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) {
 		ret = -ETIMEDOUT;
-		BT_ERR("timeout: %d, %d,%d", priv->adapter->hs_state,
+		bt_err("timeout: %d, %d,%d", priv->adapter->hs_state,
 						priv->adapter->ps_state,
 						priv->adapter->wakeup_tries);
 	}
@@ -278,7 +278,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
 
 		skb = bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
 		if (skb == NULL) {
-			BT_ERR("No free skb");
+			bt_err("No free skb");
 			return -ENOMEM;
 		}
 
@@ -293,7 +293,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
 		skb->dev = (void *) priv->btmrvl_dev.hcidev;
 		skb_queue_head(&priv->adapter->tx_queue, skb);
 
-		BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x",
+		bt_dbg("Queue HSCFG Command, gpio=0x%x, gap=0x%x",
 						cmd->data[0], cmd->data[1]);
 	}
 
@@ -324,7 +324,7 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
 		return -EINVAL;
 
 	if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) {
-		BT_ERR("Tx Error: Bad skb length %d : %d",
+		bt_err("Tx Error: Bad skb length %d : %d",
 						skb->len, BTM_UPLD_SIZE);
 		return -EINVAL;
 	}
@@ -334,7 +334,7 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
 
 		skb = skb_realloc_headroom(skb, BTM_HEADER_LEN);
 		if (!skb) {
-			BT_ERR("Tx Error: realloc_headroom failed %d",
+			bt_err("Tx Error: realloc_headroom failed %d",
 				BTM_HEADER_LEN);
 			skb = tmp;
 			return -EINVAL;
@@ -394,16 +394,16 @@ static int btmrvl_send_frame(struct sk_buff *skb)
 	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
 	struct btmrvl_private *priv = NULL;
 
-	BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
+	bt_dbg("type=%d, len=%d", skb->pkt_type, skb->len);
 
 	if (!hdev || !hdev->driver_data) {
-		BT_ERR("Frame for unknown HCI device");
+		bt_err("Frame for unknown HCI device");
 		return -ENODEV;
 	}
 
 	priv = (struct btmrvl_private *) hdev->driver_data;
 	if (!test_bit(HCI_RUNNING, &hdev->flags)) {
-		BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
+		bt_err("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
 		print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
 							skb->data, skb->len);
 		return -EBUSY;
@@ -484,7 +484,7 @@ static int btmrvl_service_main_thread(void *data)
 				((!adapter->int_count) &&
 				(!priv->btmrvl_dev.tx_dnld_rdy ||
 				skb_queue_empty(&adapter->tx_queue)))) {
-			BT_DBG("main_thread is sleeping...");
+			bt_dbg("main_thread is sleeping...");
 			schedule();
 		}
 
@@ -492,10 +492,10 @@ static int btmrvl_service_main_thread(void *data)
 
 		remove_wait_queue(&thread->wait_q, &wait);
 
-		BT_DBG("main_thread woke up");
+		bt_dbg("main_thread woke up");
 
 		if (kthread_should_stop()) {
-			BT_DBG("main_thread: break from main thread");
+			bt_dbg("main_thread: break from main thread");
 			break;
 		}
 
@@ -541,7 +541,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv)
 
 	hdev = hci_alloc_dev();
 	if (!hdev) {
-		BT_ERR("Can not allocate HCI device");
+		bt_err("Can not allocate HCI device");
 		goto err_hdev;
 	}
 
@@ -563,7 +563,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv)
 
 	ret = hci_register_dev(hdev);
 	if (ret < 0) {
-		BT_ERR("Can not register HCI device");
+		bt_err("Can not register HCI device");
 		goto err_hci_register_dev;
 	}
 
@@ -593,19 +593,19 @@ struct btmrvl_private *btmrvl_add_card(void *card)
 
 	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
 	if (!priv) {
-		BT_ERR("Can not allocate priv");
+		bt_err("Can not allocate priv");
 		goto err_priv;
 	}
 
 	priv->adapter = kzalloc(sizeof(*priv->adapter), GFP_KERNEL);
 	if (!priv->adapter) {
-		BT_ERR("Allocate buffer for btmrvl_adapter failed!");
+		bt_err("Allocate buffer for btmrvl_adapter failed!");
 		goto err_adapter;
 	}
 
 	btmrvl_init_adapter(priv);
 
-	BT_DBG("Starting kthread...");
+	bt_dbg("Starting kthread...");
 	priv->main_thread.priv = priv;
 	spin_lock_init(&priv->driver_lock);
 
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 7f521d4..bc51814 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -159,7 +159,7 @@ static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card *card,
 
 	sdio_writeb(card->func, mask, card->reg->host_int_mask, &ret);
 	if (ret) {
-		BT_ERR("Unable to enable the host interrupt!");
+		bt_err("Unable to enable the host interrupt!");
 		ret = -EIO;
 	}
 
@@ -180,7 +180,7 @@ static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card *card,
 
 	sdio_writeb(card->func, host_int_mask, card->reg->host_int_mask, &ret);
 	if (ret < 0) {
-		BT_ERR("Unable to disable the host interrupt!");
+		bt_err("Unable to disable the host interrupt!");
 		return -EIO;
 	}
 
@@ -206,7 +206,7 @@ static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card *card, u8 bits)
 	ret = -ETIMEDOUT;
 
 failed:
-	BT_ERR("FAILED! ret=%d", ret);
+	bt_err("FAILED! ret=%d", ret);
 
 	return ret;
 }
@@ -247,7 +247,7 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
 	ret = request_firmware(&fw_helper, card->helper,
 						&card->func->dev);
 	if ((ret < 0) || !fw_helper) {
-		BT_ERR("request_firmware(helper) failed, error code = %d",
+		bt_err("request_firmware(helper) failed, error code = %d",
 									ret);
 		ret = -ENOENT;
 		goto done;
@@ -256,14 +256,14 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
 	helper = fw_helper->data;
 	helperlen = fw_helper->size;
 
-	BT_DBG("Downloading helper image (%d bytes), block size %d bytes",
+	bt_dbg("Downloading helper image (%d bytes), block size %d bytes",
 						helperlen, SDIO_BLOCK_SIZE);
 
 	tmphlprbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN);
 
 	tmphlprbuf = kzalloc(tmphlprbufsz, GFP_KERNEL);
 	if (!tmphlprbuf) {
-		BT_ERR("Unable to allocate buffer for helper."
+		bt_err("Unable to allocate buffer for helper."
 			" Terminating download");
 		ret = -ENOMEM;
 		goto done;
@@ -280,7 +280,7 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
 		ret = btmrvl_sdio_poll_card_status(card,
 					    CARD_IO_READY | DN_LD_CARD_RDY);
 		if (ret < 0) {
-			BT_ERR("Helper download poll status timeout @ %d",
+			bt_err("Helper download poll status timeout @ %d",
 				hlprblknow);
 			goto done;
 		}
@@ -305,7 +305,7 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
 		ret = sdio_writesb(card->func, card->ioport, helperbuf,
 				FIRMWARE_TRANSFER_NBLOCK * SDIO_BLOCK_SIZE);
 		if (ret < 0) {
-			BT_ERR("IO error during helper download @ %d",
+			bt_err("IO error during helper download @ %d",
 				hlprblknow);
 			goto done;
 		}
@@ -313,14 +313,14 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
 		hlprblknow += tx_len;
 	} while (true);
 
-	BT_DBG("Transferring helper image EOF block");
+	bt_dbg("Transferring helper image EOF block");
 
 	memset(helperbuf, 0x0, SDIO_BLOCK_SIZE);
 
 	ret = sdio_writesb(card->func, card->ioport, helperbuf,
 							SDIO_BLOCK_SIZE);
 	if (ret < 0) {
-		BT_ERR("IO error in writing helper image EOF block");
+		bt_err("IO error in writing helper image EOF block");
 		goto done;
 	}
 
@@ -349,7 +349,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 	ret = request_firmware(&fw_firmware, card->firmware,
 							&card->func->dev);
 	if ((ret < 0) || !fw_firmware) {
-		BT_ERR("request_firmware(firmware) failed, error code = %d",
+		bt_err("request_firmware(firmware) failed, error code = %d",
 									ret);
 		ret = -ENOENT;
 		goto done;
@@ -358,12 +358,12 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 	firmware = fw_firmware->data;
 	firmwarelen = fw_firmware->size;
 
-	BT_DBG("Downloading FW image (%d bytes)", firmwarelen);
+	bt_dbg("Downloading FW image (%d bytes)", firmwarelen);
 
 	tmpfwbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN);
 	tmpfwbuf = kzalloc(tmpfwbufsz, GFP_KERNEL);
 	if (!tmpfwbuf) {
-		BT_ERR("Unable to allocate buffer for firmware."
+		bt_err("Unable to allocate buffer for firmware."
 		       " Terminating download");
 		ret = -ENOMEM;
 		goto done;
@@ -378,7 +378,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 		ret = btmrvl_sdio_poll_card_status(card,
 					CARD_IO_READY | DN_LD_CARD_RDY);
 		if (ret < 0) {
-			BT_ERR("FW download with helper poll status"
+			bt_err("FW download with helper poll status"
 						" timeout @ %d", offset);
 			goto done;
 		}
@@ -391,7 +391,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 			base0 = sdio_readb(card->func,
 					card->reg->sq_read_base_addr_a0, &ret);
 			if (ret) {
-				BT_ERR("BASE0 register read failed:"
+				bt_err("BASE0 register read failed:"
 					" base0 = 0x%04X(%d)."
 					" Terminating download",
 					base0, base0);
@@ -401,7 +401,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 			base1 = sdio_readb(card->func,
 					card->reg->sq_read_base_addr_a1, &ret);
 			if (ret) {
-				BT_ERR("BASE1 register read failed:"
+				bt_err("BASE1 register read failed:"
 					" base1 = 0x%04X(%d)."
 					" Terminating download",
 					base1, base1);
@@ -419,7 +419,7 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 		if (!len)
 			break;
 		else if (len > BTM_UPLD_SIZE) {
-			BT_ERR("FW download failure @%d, invalid length %d",
+			bt_err("FW download failure @%d, invalid length %d",
 								offset, len);
 			ret = -EINVAL;
 			goto done;
@@ -430,12 +430,12 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 		if (len & BIT(0)) {
 			count++;
 			if (count > MAX_WRITE_IOMEM_RETRY) {
-				BT_ERR("FW download failure @%d, "
+				bt_err("FW download failure @%d, "
 					"over max retry count", offset);
 				ret = -EIO;
 				goto done;
 			}
-			BT_ERR("FW CRC error indicated by the helper: "
+			bt_err("FW CRC error indicated by the helper: "
 				"len = 0x%04X, txlen = %d", len, txlen);
 			len &= ~BIT(0);
 			/* Set txlen to 0 so as to resend from same offset */
@@ -456,18 +456,18 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
 						tx_blocks * blksz_dl);
 
 		if (ret < 0) {
-			BT_ERR("FW download, writesb(%d) failed @%d",
+			bt_err("FW download, writesb(%d) failed @%d",
 							count, offset);
 			sdio_writeb(card->func, HOST_CMD53_FIN,
 						card->reg->cfg, &ret);
 			if (ret)
-				BT_ERR("writeb failed (CFG)");
+				bt_err("writeb failed (CFG)");
 		}
 
 		offset += txlen;
 	} while (true);
 
-	BT_DBG("FW download over, size %d bytes", offset);
+	bt_dbg("FW download over, size %d bytes", offset);
 
 	ret = 0;
 
@@ -491,7 +491,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
 	struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
 
 	if (!card || !card->func) {
-		BT_ERR("card or function is NULL!");
+		bt_err("card or function is NULL!");
 		ret = -EINVAL;
 		goto exit;
 	}
@@ -499,7 +499,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
 	/* Read the length of data to be transferred */
 	ret = btmrvl_sdio_read_rx_len(card, &buf_len);
 	if (ret < 0) {
-		BT_ERR("read rx_len failed");
+		bt_err("read rx_len failed");
 		ret = -EIO;
 		goto exit;
 	}
@@ -509,7 +509,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
 
 	if (buf_len <= SDIO_HEADER_LEN
 			|| (buf_block_len * blksz) > ALLOC_BUF_SIZE) {
-		BT_ERR("invalid packet length: %d", buf_len);
+		bt_err("invalid packet length: %d", buf_len);
 		ret = -EINVAL;
 		goto exit;
 	}
@@ -518,7 +518,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
 	skb = bt_skb_alloc(buf_block_len * blksz + BTSDIO_DMA_ALIGN,
 								GFP_ATOMIC);
 	if (skb == NULL) {
-		BT_ERR("No free skb");
+		bt_err("No free skb");
 		goto exit;
 	}
 
@@ -534,7 +534,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
 	ret = sdio_readsb(card->func, payload, card->ioport,
 			  buf_block_len * blksz);
 	if (ret < 0) {
-		BT_ERR("readsb failed: %d", ret);
+		bt_err("readsb failed: %d", ret);
 		ret = -EIO;
 		goto exit;
 	}
@@ -576,7 +576,7 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
 		break;
 
 	default:
-		BT_ERR("Unknown packet type:%d", type);
+		bt_err("Unknown packet type:%d", type);
 		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, payload,
 						blksz * buf_block_len);
 
@@ -609,7 +609,7 @@ static int btmrvl_sdio_process_int_status(struct btmrvl_private *priv)
 	sdio_claim_host(card->func);
 	if (ireg & DN_LD_HOST_INT_STATUS) {
 		if (priv->btmrvl_dev.tx_dnld_rdy)
-			BT_DBG("tx_done already received: "
+			bt_dbg("tx_done already received: "
 				" int_status=0x%x", ireg);
 		else
 			priv->btmrvl_dev.tx_dnld_rdy = true;
@@ -633,7 +633,7 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
 
 	card = sdio_get_drvdata(func);
 	if (!card || !card->priv) {
-		BT_ERR("sbi_interrupt(%p) card or priv is "
+		bt_err("sbi_interrupt(%p) card or priv is "
 				"NULL, card=%p\n", func, card);
 		return;
 	}
@@ -642,7 +642,7 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
 
 	ireg = sdio_readb(card->func, card->reg->host_intstatus, &ret);
 	if (ret) {
-		BT_ERR("sdio_readb: read int status register failed");
+		bt_err("sdio_readb: read int status register failed");
 		return;
 	}
 
@@ -652,13 +652,13 @@ static void btmrvl_sdio_interrupt(struct sdio_func *func)
 		 * Clear the interrupt status register and re-enable the
 		 * interrupt.
 		 */
-		BT_DBG("ireg = 0x%x", ireg);
+		bt_dbg("ireg = 0x%x", ireg);
 
 		sdio_writeb(card->func, ~(ireg) & (DN_LD_HOST_INT_STATUS |
 					UP_LD_HOST_INT_STATUS),
 				card->reg->host_intstatus, &ret);
 		if (ret) {
-			BT_ERR("sdio_writeb: clear int status register failed");
+			bt_err("sdio_writeb: clear int status register failed");
 			return;
 		}
 	}
@@ -677,7 +677,7 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
 	int ret = 0;
 
 	if (!card || !card->func) {
-		BT_ERR("Error: card or function is NULL!");
+		bt_err("Error: card or function is NULL!");
 		ret = -EINVAL;
 		goto failed;
 	}
@@ -688,21 +688,21 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
 
 	ret = sdio_enable_func(func);
 	if (ret) {
-		BT_ERR("sdio_enable_func() failed: ret=%d", ret);
+		bt_err("sdio_enable_func() failed: ret=%d", ret);
 		ret = -EIO;
 		goto release_host;
 	}
 
 	ret = sdio_claim_irq(func, btmrvl_sdio_interrupt);
 	if (ret) {
-		BT_ERR("sdio_claim_irq failed: ret=%d", ret);
+		bt_err("sdio_claim_irq failed: ret=%d", ret);
 		ret = -EIO;
 		goto disable_func;
 	}
 
 	ret = sdio_set_block_size(card->func, SDIO_BLOCK_SIZE);
 	if (ret) {
-		BT_ERR("cannot set SDIO block size");
+		bt_err("cannot set SDIO block size");
 		ret = -EIO;
 		goto release_irq;
 	}
@@ -731,7 +731,7 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
 
 	card->ioport |= (reg << 16);
 
-	BT_DBG("SDIO FUNC%d IO port: 0x%x", func->num, card->ioport);
+	bt_dbg("SDIO FUNC%d IO port: 0x%x", func->num, card->ioport);
 
 	sdio_set_drvdata(func, card);
 
@@ -812,7 +812,7 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv,
 	int tmpbufsz;
 
 	if (!card || !card->func) {
-		BT_ERR("card or function is NULL!");
+		bt_err("card or function is NULL!");
 		return -EINVAL;
 	}
 
@@ -837,7 +837,7 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv,
 				   buf_block_len * blksz);
 		if (ret < 0) {
 			i++;
-			BT_ERR("i=%d writesb failed: %d", i, ret);
+			bt_err("i=%d writesb failed: %d", i, ret);
 			print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
 						payload, nb);
 			ret = -EIO;
@@ -862,25 +862,25 @@ static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
 	int pollnum = MAX_POLL_TRIES;
 
 	if (!card || !card->func) {
-		BT_ERR("card or function is NULL!");
+		bt_err("card or function is NULL!");
 		return -EINVAL;
 	}
 	sdio_claim_host(card->func);
 
 	if (!btmrvl_sdio_verify_fw_download(card, 1)) {
-		BT_DBG("Firmware already downloaded!");
+		bt_dbg("Firmware already downloaded!");
 		goto done;
 	}
 
 	/* Check if other function driver is downloading the firmware */
 	fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret);
 	if (ret) {
-		BT_ERR("Failed to read FW downloading status!");
+		bt_err("Failed to read FW downloading status!");
 		ret = -EIO;
 		goto done;
 	}
 	if (fws0) {
-		BT_DBG("BT not the winner (%#x). Skip FW downloading", fws0);
+		bt_dbg("BT not the winner (%#x). Skip FW downloading", fws0);
 
 		/* Give other function more time to download the firmware */
 		pollnum *= 10;
@@ -888,21 +888,21 @@ static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
 		if (card->helper) {
 			ret = btmrvl_sdio_download_helper(card);
 			if (ret) {
-				BT_ERR("Failed to download helper!");
+				bt_err("Failed to download helper!");
 				ret = -EIO;
 				goto done;
 			}
 		}
 
 		if (btmrvl_sdio_download_fw_w_helper(card)) {
-			BT_ERR("Failed to download firmware!");
+			bt_err("Failed to download firmware!");
 			ret = -EIO;
 			goto done;
 		}
 	}
 
 	if (btmrvl_sdio_verify_fw_download(card, pollnum)) {
-		BT_ERR("FW failed to be active in time!");
+		bt_err("FW failed to be active in time!");
 		ret = -ETIMEDOUT;
 		goto done;
 	}
@@ -919,7 +919,7 @@ static int btmrvl_sdio_wakeup_fw(struct btmrvl_private *priv)
 	int ret = 0;
 
 	if (!card || !card->func) {
-		BT_ERR("card or function is NULL!");
+		bt_err("card or function is NULL!");
 		return -EINVAL;
 	}
 
@@ -929,7 +929,7 @@ static int btmrvl_sdio_wakeup_fw(struct btmrvl_private *priv)
 
 	sdio_release_host(card->func);
 
-	BT_DBG("wake up firmware");
+	bt_dbg("wake up firmware");
 
 	return ret;
 }
@@ -941,7 +941,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
 	struct btmrvl_private *priv = NULL;
 	struct btmrvl_sdio_card *card = NULL;
 
-	BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d",
+	bt_info("vendor=0x%x, device=0x%x, class=%d, fn=%d",
 			id->vendor, id->device, id->class, func->num);
 
 	card = kzalloc(sizeof(*card), GFP_KERNEL);
@@ -961,7 +961,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
 	}
 
 	if (btmrvl_sdio_register_dev(card) < 0) {
-		BT_ERR("Failed to register BT device!");
+		bt_err("Failed to register BT device!");
 		ret = -ENODEV;
 		goto free_card;
 	}
@@ -970,7 +970,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
 	btmrvl_sdio_disable_host_int(card);
 
 	if (btmrvl_sdio_download_fw(card)) {
-		BT_ERR("Downloading firmware failed!");
+		bt_err("Downloading firmware failed!");
 		ret = -ENODEV;
 		goto unreg_dev;
 	}
@@ -981,7 +981,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
 
 	priv = btmrvl_add_card(card);
 	if (!priv) {
-		BT_ERR("Initializing card failed!");
+		bt_err("Initializing card failed!");
 		ret = -ENODEV;
 		goto disable_host_int;
 	}
@@ -994,7 +994,7 @@ static int btmrvl_sdio_probe(struct sdio_func *func,
 	priv->hw_process_int_status = btmrvl_sdio_process_int_status;
 
 	if (btmrvl_register_hdev(priv)) {
-		BT_ERR("Register hdev failed!");
+		bt_err("Register hdev failed!");
 		ret = -ENODEV;
 		goto disable_host_int;
 	}
@@ -1029,7 +1029,7 @@ static void btmrvl_sdio_remove(struct sdio_func *func)
 							MODULE_SHUTDOWN_REQ);
 				btmrvl_sdio_disable_host_int(card);
 			}
-			BT_DBG("unregester dev");
+			bt_dbg("unregester dev");
 			btmrvl_sdio_unregister_dev(card);
 			btmrvl_remove_card(card->priv);
 			kfree(card);
@@ -1047,7 +1047,7 @@ static struct sdio_driver bt_mrvl_sdio = {
 static int __init btmrvl_sdio_init_module(void)
 {
 	if (sdio_register_driver(&bt_mrvl_sdio) != 0) {
-		BT_ERR("SDIO Driver Registration Failed");
+		bt_err("SDIO Driver Registration Failed");
 		return -ENODEV;
 	}
 
diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c
index 792e32d..47555fe 100644
--- a/drivers/bluetooth/btsdio.c
+++ b/drivers/bluetooth/btsdio.c
@@ -78,7 +78,7 @@ static int btsdio_tx_packet(struct btsdio_data *data, struct sk_buff *skb)
 {
 	int err;
 
-	BT_DBG("%s", data->hdev->name);
+	bt_dbg("%s", data->hdev->name);
 
 	/* Prepend Type-A header */
 	skb_push(skb, 4);
@@ -107,7 +107,7 @@ static void btsdio_work(struct work_struct *work)
 	struct sk_buff *skb;
 	int err;
 
-	BT_DBG("%s", data->hdev->name);
+	bt_dbg("%s", data->hdev->name);
 
 	sdio_claim_host(data->func);
 
@@ -129,7 +129,7 @@ static int btsdio_rx_packet(struct btsdio_data *data)
 	struct sk_buff *skb;
 	int err, len;
 
-	BT_DBG("%s", data->hdev->name);
+	bt_dbg("%s", data->hdev->name);
 
 	err = sdio_readsb(data->func, hdr, REG_RDAT, 4);
 	if (err < 0)
@@ -174,7 +174,7 @@ static void btsdio_interrupt(struct sdio_func *func)
 	struct btsdio_data *data = sdio_get_drvdata(func);
 	int intrd;
 
-	BT_DBG("%s", data->hdev->name);
+	bt_dbg("%s", data->hdev->name);
 
 	intrd = sdio_readb(func, REG_INTRD, NULL);
 	if (intrd & 0x01) {
@@ -192,7 +192,7 @@ static int btsdio_open(struct hci_dev *hdev)
 	struct btsdio_data *data = hdev->driver_data;
 	int err;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -227,7 +227,7 @@ static int btsdio_close(struct hci_dev *hdev)
 {
 	struct btsdio_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -248,7 +248,7 @@ static int btsdio_flush(struct hci_dev *hdev)
 {
 	struct btsdio_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	skb_queue_purge(&data->txq);
 
@@ -260,7 +260,7 @@ static int btsdio_send_frame(struct sk_buff *skb)
 	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
 	struct btsdio_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
 		return -EBUSY;
@@ -293,7 +293,7 @@ static void btsdio_destruct(struct hci_dev *hdev)
 {
 	struct btsdio_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	kfree(data);
 }
@@ -306,10 +306,10 @@ static int btsdio_probe(struct sdio_func *func,
 	struct sdio_func_tuple *tuple = func->tuples;
 	int err;
 
-	BT_DBG("func %p id %p class 0x%04x", func, id, func->class);
+	bt_dbg("func %p id %p class 0x%04x", func, id, func->class);
 
 	while (tuple) {
-		BT_DBG("code 0x%x size %d", tuple->code, tuple->size);
+		bt_dbg("code 0x%x size %d", tuple->code, tuple->size);
 		tuple = tuple->next;
 	}
 
@@ -366,7 +366,7 @@ static void btsdio_remove(struct sdio_func *func)
 	struct btsdio_data *data = sdio_get_drvdata(func);
 	struct hci_dev *hdev;
 
-	BT_DBG("func %p", func);
+	bt_dbg("func %p", func);
 
 	if (!data)
 		return;
@@ -389,7 +389,7 @@ static struct sdio_driver btsdio_driver = {
 
 static int __init btsdio_init(void)
 {
-	BT_INFO("Generic Bluetooth SDIO driver ver %s", VERSION);
+	bt_info("Generic Bluetooth SDIO driver ver %s", VERSION);
 
 	return sdio_register_driver(&btsdio_driver);
 }
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 526b618..460ec83 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -131,7 +131,7 @@ static int btuart_write(unsigned int iobase, int fifo_size, __u8 *buf, int len)
 static void btuart_write_wakeup(btuart_info_t *info)
 {
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -178,7 +178,7 @@ static void btuart_receive(btuart_info_t *info)
 	int boguscount = 0;
 
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -192,7 +192,7 @@ static void btuart_receive(btuart_info_t *info)
 			info->rx_state = RECV_WAIT_PACKET_TYPE;
 			info->rx_count = 0;
 			if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
-				BT_ERR("Can't allocate mem for new packet");
+				bt_err("Can't allocate mem for new packet");
 				return;
 			}
 		}
@@ -221,7 +221,7 @@ static void btuart_receive(btuart_info_t *info)
 
 			default:
 				/* Unknown packet */
-				BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
+				bt_err("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
 				info->hdev->stat.err_rx++;
 				clear_bit(HCI_RUNNING, &(info->hdev->flags));
 
@@ -309,7 +309,7 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst)
 
 		switch (iir) {
 		case UART_IIR_RLSI:
-			BT_ERR("RLSI");
+			bt_err("RLSI");
 			break;
 		case UART_IIR_RDI:
 			/* Receive interrupt */
@@ -322,7 +322,7 @@ static irqreturn_t btuart_interrupt(int irq, void *dev_inst)
 			}
 			break;
 		default:
-			BT_ERR("Unhandled IIR=%#x", iir);
+			bt_err("Unhandled IIR=%#x", iir);
 			break;
 		}
 
@@ -349,7 +349,7 @@ static void btuart_change_speed(btuart_info_t *info, unsigned int speed)
 	int divisor;
 
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -431,7 +431,7 @@ static int btuart_hci_send_frame(struct sk_buff *skb)
 	struct hci_dev *hdev = (struct hci_dev *)(skb->dev);
 
 	if (!hdev) {
-		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+		bt_err("Frame for unknown HCI device (hdev=NULL)");
 		return -ENODEV;
 	}
 
@@ -491,7 +491,7 @@ static int btuart_open(btuart_info_t *info)
 	/* Initialize HCI device */
 	hdev = hci_alloc_dev();
 	if (!hdev) {
-		BT_ERR("Can't allocate HCI device");
+		bt_err("Can't allocate HCI device");
 		return -ENOMEM;
 	}
 
@@ -534,7 +534,7 @@ static int btuart_open(btuart_info_t *info)
 
 	/* Register HCI device */
 	if (hci_register_dev(hdev) < 0) {
-		BT_ERR("Can't register HCI device");
+		bt_err("Can't register HCI device");
 		info->hdev = NULL;
 		hci_free_dev(hdev);
 		return -ENODEV;
@@ -566,7 +566,7 @@ static int btuart_close(btuart_info_t *info)
 	spin_unlock_irqrestore(&(info->lock), flags);
 
 	if (hci_unregister_dev(hdev) < 0)
-		BT_ERR("Can't unregister HCI device %s", hdev->name);
+		bt_err("Can't unregister HCI device %s", hdev->name);
 
 	hci_free_dev(hdev);
 
@@ -657,7 +657,7 @@ static int btuart_config(struct pcmcia_device *link)
 	if (!pcmcia_loop_config(link, btuart_check_config_notpicky, NULL))
 		goto found_port;
 
-	BT_ERR("No usable port range found");
+	bt_err("No usable port range found");
 	goto failed;
 
 found_port:
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index c2de895..8e2fdf5 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -230,7 +230,7 @@ static void btusb_intr_complete(struct urb *urb)
 	struct btusb_data *data = hdev->driver_data;
 	int err;
 
-	BT_DBG("%s urb %p status %d count %d", hdev->name,
+	bt_dbg("%s urb %p status %d count %d", hdev->name,
 					urb, urb->status, urb->actual_length);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
@@ -242,7 +242,7 @@ static void btusb_intr_complete(struct urb *urb)
 		if (hci_recv_fragment(hdev, HCI_EVENT_PKT,
 						urb->transfer_buffer,
 						urb->actual_length) < 0) {
-			BT_ERR("%s corrupted event packet", hdev->name);
+			bt_err("%s corrupted event packet", hdev->name);
 			hdev->stat.err_rx++;
 		}
 	}
@@ -256,7 +256,7 @@ static void btusb_intr_complete(struct urb *urb)
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err < 0) {
 		if (err != -EPERM)
-			BT_ERR("%s urb %p failed to resubmit (%d)",
+			bt_err("%s urb %p failed to resubmit (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -270,7 +270,7 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
 	unsigned int pipe;
 	int err, size;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!data->intr_ep)
 		return -ENODEV;
@@ -299,7 +299,7 @@ static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
 
 	err = usb_submit_urb(urb, mem_flags);
 	if (err < 0) {
-		BT_ERR("%s urb %p submission failed (%d)",
+		bt_err("%s urb %p submission failed (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -315,7 +315,7 @@ static void btusb_bulk_complete(struct urb *urb)
 	struct btusb_data *data = hdev->driver_data;
 	int err;
 
-	BT_DBG("%s urb %p status %d count %d", hdev->name,
+	bt_dbg("%s urb %p status %d count %d", hdev->name,
 					urb, urb->status, urb->actual_length);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
@@ -327,7 +327,7 @@ static void btusb_bulk_complete(struct urb *urb)
 		if (hci_recv_fragment(hdev, HCI_ACLDATA_PKT,
 						urb->transfer_buffer,
 						urb->actual_length) < 0) {
-			BT_ERR("%s corrupted ACL packet", hdev->name);
+			bt_err("%s corrupted ACL packet", hdev->name);
 			hdev->stat.err_rx++;
 		}
 	}
@@ -341,7 +341,7 @@ static void btusb_bulk_complete(struct urb *urb)
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err < 0) {
 		if (err != -EPERM)
-			BT_ERR("%s urb %p failed to resubmit (%d)",
+			bt_err("%s urb %p failed to resubmit (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -355,7 +355,7 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
 	unsigned int pipe;
 	int err, size = HCI_MAX_FRAME_SIZE;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!data->bulk_rx_ep)
 		return -ENODEV;
@@ -382,7 +382,7 @@ static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
 
 	err = usb_submit_urb(urb, mem_flags);
 	if (err < 0) {
-		BT_ERR("%s urb %p submission failed (%d)",
+		bt_err("%s urb %p submission failed (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -398,7 +398,7 @@ static void btusb_isoc_complete(struct urb *urb)
 	struct btusb_data *data = hdev->driver_data;
 	int i, err;
 
-	BT_DBG("%s urb %p status %d count %d", hdev->name,
+	bt_dbg("%s urb %p status %d count %d", hdev->name,
 					urb, urb->status, urb->actual_length);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
@@ -417,7 +417,7 @@ static void btusb_isoc_complete(struct urb *urb)
 			if (hci_recv_fragment(hdev, HCI_SCODATA_PKT,
 						urb->transfer_buffer + offset,
 								length) < 0) {
-				BT_ERR("%s corrupted SCO packet", hdev->name);
+				bt_err("%s corrupted SCO packet", hdev->name);
 				hdev->stat.err_rx++;
 			}
 		}
@@ -431,7 +431,7 @@ static void btusb_isoc_complete(struct urb *urb)
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err < 0) {
 		if (err != -EPERM)
-			BT_ERR("%s urb %p failed to resubmit (%d)",
+			bt_err("%s urb %p failed to resubmit (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -441,7 +441,7 @@ static inline void __fill_isoc_descriptor(struct urb *urb, int len, int mtu)
 {
 	int i, offset = 0;
 
-	BT_DBG("len %d mtu %d", len, mtu);
+	bt_dbg("len %d mtu %d", len, mtu);
 
 	for (i = 0; i < BTUSB_MAX_ISOC_FRAMES && len >= mtu;
 					i++, offset += mtu, len -= mtu) {
@@ -466,7 +466,7 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
 	unsigned int pipe;
 	int err, size;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!data->isoc_rx_ep)
 		return -ENODEV;
@@ -503,7 +503,7 @@ static int btusb_submit_isoc_urb(struct hci_dev *hdev, gfp_t mem_flags)
 
 	err = usb_submit_urb(urb, mem_flags);
 	if (err < 0) {
-		BT_ERR("%s urb %p submission failed (%d)",
+		bt_err("%s urb %p submission failed (%d)",
 						hdev->name, urb, -err);
 		usb_unanchor_urb(urb);
 	}
@@ -519,7 +519,7 @@ static void btusb_tx_complete(struct urb *urb)
 	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
 	struct btusb_data *data = hdev->driver_data;
 
-	BT_DBG("%s urb %p status %d count %d", hdev->name,
+	bt_dbg("%s urb %p status %d count %d", hdev->name,
 					urb, urb->status, urb->actual_length);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
@@ -545,7 +545,7 @@ static void btusb_isoc_tx_complete(struct urb *urb)
 	struct sk_buff *skb = urb->context;
 	struct hci_dev *hdev = (struct hci_dev *) skb->dev;
 
-	BT_DBG("%s urb %p status %d count %d", hdev->name,
+	bt_dbg("%s urb %p status %d count %d", hdev->name,
 					urb, urb->status, urb->actual_length);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
@@ -567,7 +567,7 @@ static int btusb_open(struct hci_dev *hdev)
 	struct btusb_data *data = hdev->driver_data;
 	int err;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	err = usb_autopm_get_interface(data->intf);
 	if (err < 0)
@@ -617,7 +617,7 @@ static int btusb_close(struct hci_dev *hdev)
 	struct btusb_data *data = hdev->driver_data;
 	int err;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -646,7 +646,7 @@ static int btusb_flush(struct hci_dev *hdev)
 {
 	struct btusb_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	usb_kill_anchored_urbs(&data->tx_anchor);
 
@@ -662,7 +662,7 @@ static int btusb_send_frame(struct sk_buff *skb)
 	unsigned int pipe;
 	int err;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_bit(HCI_RUNNING, &hdev->flags))
 		return -EBUSY;
@@ -751,7 +751,7 @@ skip_waking:
 
 	err = usb_submit_urb(urb, GFP_ATOMIC);
 	if (err < 0) {
-		BT_ERR("%s urb %p submission failed", hdev->name, urb);
+		bt_err("%s urb %p submission failed", hdev->name, urb);
 		kfree(urb->setup_packet);
 		usb_unanchor_urb(urb);
 	} else {
@@ -768,7 +768,7 @@ static void btusb_destruct(struct hci_dev *hdev)
 {
 	struct btusb_data *data = hdev->driver_data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	kfree(data);
 }
@@ -777,7 +777,7 @@ static void btusb_notify(struct hci_dev *hdev, unsigned int evt)
 {
 	struct btusb_data *data = hdev->driver_data;
 
-	BT_DBG("%s evt %d", hdev->name, evt);
+	bt_dbg("%s evt %d", hdev->name, evt);
 
 	if (hdev->conn_hash.sco_num != data->sco_num) {
 		data->sco_num = hdev->conn_hash.sco_num;
@@ -797,7 +797,7 @@ static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
 
 	err = usb_set_interface(data->udev, 1, altsetting);
 	if (err < 0) {
-		BT_ERR("%s setting interface failed (%d)", hdev->name, -err);
+		bt_err("%s setting interface failed (%d)", hdev->name, -err);
 		return err;
 	}
 
@@ -821,7 +821,7 @@ static inline int __set_isoc_interface(struct hci_dev *hdev, int altsetting)
 	}
 
 	if (!data->isoc_tx_ep || !data->isoc_rx_ep) {
-		BT_ERR("%s invalid SCO descriptors", hdev->name);
+		bt_err("%s invalid SCO descriptors", hdev->name);
 		return -ENODEV;
 	}
 
@@ -889,7 +889,7 @@ static int btusb_probe(struct usb_interface *intf,
 	struct hci_dev *hdev;
 	int i, err;
 
-	BT_DBG("intf %p id %p", intf, id);
+	bt_dbg("intf %p id %p", intf, id);
 
 	/* interface numbers are hardcoded in the spec */
 	if (intf->cur_altsetting->desc.bInterfaceNumber != 0)
@@ -1056,7 +1056,7 @@ static void btusb_disconnect(struct usb_interface *intf)
 	struct btusb_data *data = usb_get_intfdata(intf);
 	struct hci_dev *hdev;
 
-	BT_DBG("intf %p", intf);
+	bt_dbg("intf %p", intf);
 
 	if (!data)
 		return;
@@ -1087,7 +1087,7 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
 {
 	struct btusb_data *data = usb_get_intfdata(intf);
 
-	BT_DBG("intf %p", intf);
+	bt_dbg("intf %p", intf);
 
 	if (data->suspend_count++)
 		return 0;
@@ -1131,7 +1131,7 @@ static int btusb_resume(struct usb_interface *intf)
 	struct hci_dev *hdev = data->hdev;
 	int err = 0;
 
-	BT_DBG("intf %p", intf);
+	bt_dbg("intf %p", intf);
 
 	if (--data->suspend_count)
 		return 0;
@@ -1197,7 +1197,7 @@ static struct usb_driver btusb_driver = {
 
 static int __init btusb_init(void)
 {
-	BT_INFO("Generic Bluetooth USB driver ver %s", VERSION);
+	bt_info("Generic Bluetooth USB driver ver %s", VERSION);
 
 	return usb_register(&btusb_driver);
 }
diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
index 65d27af..874daa9 100644
--- a/drivers/bluetooth/btwilink.c
+++ b/drivers/bluetooth/btwilink.c
@@ -112,7 +112,7 @@ static long st_receive(void *priv_data, struct sk_buff *skb)
 	/* Forward skb to HCI core layer */
 	err = hci_recv_frame(skb);
 	if (err < 0) {
-		BT_ERR("Unable to push skb to HCI core(%d)", err);
+		bt_err("Unable to push skb to HCI core(%d)", err);
 		return err;
 	}
 
@@ -154,7 +154,7 @@ static int ti_st_open(struct hci_dev *hdev)
 	struct ti_st *hst;
 	int err, i;
 
-	BT_DBG("%s %p", hdev->name, hdev);
+	bt_dbg("%s %p", hdev->name, hdev);
 
 	if (test_and_set_bit(HCI_RUNNING, &hdev->flags))
 		return -EBUSY;
@@ -183,21 +183,21 @@ static int ti_st_open(struct hci_dev *hdev)
 
 		if (err != -EINPROGRESS) {
 			clear_bit(HCI_RUNNING, &hdev->flags);
-			BT_ERR("st_register failed %d", err);
+			bt_err("st_register failed %d", err);
 			return err;
 		}
 
 		/* ST is busy with either protocol
 		 * registration or firmware download.
 		 */
-		BT_DBG("waiting for registration "
+		bt_dbg("waiting for registration "
 				"completion signal from ST");
 		timeleft = wait_for_completion_timeout
 			(&hst->wait_reg_completion,
 			 msecs_to_jiffies(BT_REGISTER_TIMEOUT));
 		if (!timeleft) {
 			clear_bit(HCI_RUNNING, &hdev->flags);
-			BT_ERR("Timeout(%d sec),didn't get reg "
+			bt_err("Timeout(%d sec),didn't get reg "
 					"completion signal from ST",
 					BT_REGISTER_TIMEOUT / 1000);
 			return -ETIMEDOUT;
@@ -207,7 +207,7 @@ static int ti_st_open(struct hci_dev *hdev)
 		 * called with ERROR status? */
 		if (hst->reg_status != 0) {
 			clear_bit(HCI_RUNNING, &hdev->flags);
-			BT_ERR("ST registration completed with invalid "
+			bt_err("ST registration completed with invalid "
 					"status %d", hst->reg_status);
 			return -EAGAIN;
 		}
@@ -215,13 +215,13 @@ static int ti_st_open(struct hci_dev *hdev)
 done:
 		hst->st_write = ti_st_proto[i].write;
 		if (!hst->st_write) {
-			BT_ERR("undefined ST write function");
+			bt_err("undefined ST write function");
 			clear_bit(HCI_RUNNING, &hdev->flags);
 			for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
 				/* Undo registration with ST */
 				err = st_unregister(&ti_st_proto[i]);
 				if (err)
-					BT_ERR("st_unregister() failed with "
+					bt_err("st_unregister() failed with "
 							"error %d", err);
 				hst->st_write = NULL;
 			}
@@ -243,7 +243,7 @@ static int ti_st_close(struct hci_dev *hdev)
 	for (i = 0; i < MAX_BT_CHNL_IDS; i++) {
 		err = st_unregister(&ti_st_proto[i]);
 		if (err)
-			BT_ERR("st_unregister(%d) failed with error %d",
+			bt_err("st_unregister(%d) failed with error %d",
 					ti_st_proto[i].chnl_id, err);
 	}
 
@@ -268,7 +268,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
 	/* Prepend skb with frame type */
 	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
 
-	BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type,
+	bt_dbg("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type,
 			skb->len);
 
 	/* Insert skb to shared transport layer's transmit queue.
@@ -278,7 +278,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
 	len = hst->st_write(skb);
 	if (len < 0) {
 		kfree_skb(skb);
-		BT_ERR("ST write failed (%ld)", len);
+		bt_err("ST write failed (%ld)", len);
 		/* Try Again, would only fail if UART has gone bad */
 		return -EAGAIN;
 	}
@@ -292,7 +292,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
 
 static void ti_st_destruct(struct hci_dev *hdev)
 {
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 	/* do nothing here, since platform remove
 	 * would free the hdev->driver_data
 	 */
@@ -315,7 +315,7 @@ static int bt_ti_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	BT_DBG("hdev %p", hdev);
+	bt_dbg("hdev %p", hdev);
 
 	hst->hdev = hdev;
 	hdev->bus = HCI_UART;
@@ -329,13 +329,13 @@ static int bt_ti_probe(struct platform_device *pdev)
 
 	err = hci_register_dev(hdev);
 	if (err < 0) {
-		BT_ERR("Can't register HCI device error %d", err);
+		bt_err("Can't register HCI device error %d", err);
 		kfree(hst);
 		hci_free_dev(hdev);
 		return err;
 	}
 
-	BT_DBG("HCI device registered (hdev %p)", hdev);
+	bt_dbg("HCI device registered (hdev %p)", hdev);
 
 	dev_set_drvdata(&pdev->dev, hst);
 	return err;
@@ -349,7 +349,7 @@ static int bt_ti_remove(struct platform_device *pdev)
 	if (!hst)
 		return -EFAULT;
 
-	BT_DBG("%s", hst->hdev->name);
+	bt_dbg("%s", hst->hdev->name);
 
 	hdev = hst->hdev;
 	ti_st_close(hdev);
@@ -374,7 +374,7 @@ static struct platform_driver btwilink_driver = {
 /* ------- Module Init/Exit interfaces ------ */
 static int __init btwilink_init(void)
 {
-	BT_INFO("Bluetooth Driver for TI WiLink - Version %s", VERSION);
+	bt_info("Bluetooth Driver for TI WiLink - Version %s", VERSION);
 
 	return platform_driver_register(&btwilink_driver);
 }
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 5e4c2de..887660f 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -133,7 +133,7 @@ static int dtl1_write(unsigned int iobase, int fifo_size, __u8 *buf, int len)
 static void dtl1_write_wakeup(dtl1_info_t *info)
 {
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -209,7 +209,7 @@ static void dtl1_receive(dtl1_info_t *info)
 	int boguscount = 0;
 
 	if (!info) {
-		BT_ERR("Unknown device");
+		bt_err("Unknown device");
 		return;
 	}
 
@@ -221,7 +221,7 @@ static void dtl1_receive(dtl1_info_t *info)
 		/* Allocate packet */
 		if (info->rx_skb == NULL)
 			if (!(info->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC))) {
-				BT_ERR("Can't allocate mem for new packet");
+				bt_err("Can't allocate mem for new packet");
 				info->rx_state = RECV_WAIT_NSH;
 				info->rx_count = NSHL;
 				return;
@@ -266,7 +266,7 @@ static void dtl1_receive(dtl1_info_t *info)
 					break;
 				default:
 					/* unknown packet */
-					BT_ERR("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
+					bt_err("Unknown HCI packet with type 0x%02x received", bt_cb(info->rx_skb)->pkt_type);
 					kfree_skb(info->rx_skb);
 					break;
 				}
@@ -313,7 +313,7 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst)
 
 		switch (iir) {
 		case UART_IIR_RLSI:
-			BT_ERR("RLSI");
+			bt_err("RLSI");
 			break;
 		case UART_IIR_RDI:
 			/* Receive interrupt */
@@ -326,7 +326,7 @@ static irqreturn_t dtl1_interrupt(int irq, void *dev_inst)
 			}
 			break;
 		default:
-			BT_ERR("Unhandled IIR=%#x", iir);
+			bt_err("Unhandled IIR=%#x", iir);
 			break;
 		}
 
@@ -395,7 +395,7 @@ static int dtl1_hci_send_frame(struct sk_buff *skb)
 	nsh_t nsh;
 
 	if (!hdev) {
-		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+		bt_err("Frame for unknown HCI device (hdev=NULL)");
 		return -ENODEV;
 	}
 
@@ -476,7 +476,7 @@ static int dtl1_open(dtl1_info_t *info)
 	/* Initialize HCI device */
 	hdev = hci_alloc_dev();
 	if (!hdev) {
-		BT_ERR("Can't allocate HCI device");
+		bt_err("Can't allocate HCI device");
 		return -ENOMEM;
 	}
 
@@ -520,7 +520,7 @@ static int dtl1_open(dtl1_info_t *info)
 
 	/* Register HCI device */
 	if (hci_register_dev(hdev) < 0) {
-		BT_ERR("Can't register HCI device");
+		bt_err("Can't register HCI device");
 		info->hdev = NULL;
 		hci_free_dev(hdev);
 		return -ENODEV;
@@ -552,7 +552,7 @@ static int dtl1_close(dtl1_info_t *info)
 	spin_unlock_irqrestore(&(info->lock), flags);
 
 	if (hci_unregister_dev(hdev) < 0)
-		BT_ERR("Can't unregister HCI device %s", hdev->name);
+		bt_err("Can't unregister HCI device %s", hdev->name);
 
 	hci_free_dev(hdev);
 
diff --git a/drivers/bluetooth/hci_ath.c b/drivers/bluetooth/hci_ath.c
index 4093935..c65b1e6 100644
--- a/drivers/bluetooth/hci_ath.c
+++ b/drivers/bluetooth/hci_ath.c
@@ -110,7 +110,7 @@ static int ath_open(struct hci_uart *hu)
 {
 	struct ath_struct *ath;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	ath = kzalloc(sizeof(*ath), GFP_ATOMIC);
 	if (!ath)
@@ -131,7 +131,7 @@ static int ath_flush(struct hci_uart *hu)
 {
 	struct ath_struct *ath = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	skb_queue_purge(&ath->txq);
 
@@ -143,7 +143,7 @@ static int ath_close(struct hci_uart *hu)
 {
 	struct ath_struct *ath = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	skb_queue_purge(&ath->txq);
 
@@ -178,7 +178,7 @@ static int ath_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 			ath->cur_sleep = skb->data[HCI_COMMAND_HDR_SIZE];
 	}
 
-	BT_DBG("hu %p skb %p", hu, skb);
+	bt_dbg("hu %p skb %p", hu, skb);
 
 	/* Prepend skb with frame type */
 	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
@@ -205,7 +205,7 @@ static int ath_recv(struct hci_uart *hu, void *data, int count)
 
 	ret = hci_recv_stream_fragment(hu->hdev, data, count);
 	if (ret < 0) {
-		BT_ERR("Frame Reassembly Failed");
+		bt_err("Frame Reassembly Failed");
 		return ret;
 	}
 
@@ -227,9 +227,9 @@ int __init ath_init(void)
 	int err = hci_uart_register_proto(&athp);
 
 	if (!err)
-		BT_INFO("HCIATH3K protocol initialized");
+		bt_info("HCIATH3K protocol initialized");
 	else
-		BT_ERR("HCIATH3K protocol registration failed");
+		bt_err("HCIATH3K protocol registration failed");
 
 	return err;
 }
diff --git a/drivers/bluetooth/hci_bcsp.c b/drivers/bluetooth/hci_bcsp.c
index 9c5b2dc..2bd1db8 100644
--- a/drivers/bluetooth/hci_bcsp.c
+++ b/drivers/bluetooth/hci_bcsp.c
@@ -152,7 +152,7 @@ static int bcsp_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 	struct bcsp_struct *bcsp = hu->priv;
 
 	if (skb->len > 0xFFF) {
-		BT_ERR("Packet too long");
+		bt_err("Packet too long");
 		kfree_skb(skb);
 		return 0;
 	}
@@ -168,7 +168,7 @@ static int bcsp_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 		break;
 
 	default:
-		BT_ERR("Unknown packet type");
+		bt_err("Unknown packet type");
 		kfree_skb(skb);
 		break;
 	}
@@ -206,7 +206,7 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
 		rel = 0;	/* unreliable channel */
 		break;
 	default:
-		BT_ERR("Unknown packet type");
+		bt_err("Unknown packet type");
 		return NULL;
 	}
 
@@ -239,11 +239,11 @@ static struct sk_buff *bcsp_prepare_pkt(struct bcsp_struct *bcsp, u8 *data,
 
 	hdr[0] = bcsp->rxseq_txack << 3;
 	bcsp->txack_req = 0;
-	BT_DBG("We request packet no %u to card", bcsp->rxseq_txack);
+	bt_dbg("We request packet no %u to card", bcsp->rxseq_txack);
 
 	if (rel) {
 		hdr[0] |= 0x80 + bcsp->msgq_txseq;
-		BT_DBG("Sending packet with seqno %u", bcsp->msgq_txseq);
+		bt_dbg("Sending packet with seqno %u", bcsp->msgq_txseq);
 		bcsp->msgq_txseq = (bcsp->msgq_txseq + 1) & 0x07;
 	}
 
@@ -298,7 +298,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
 			return nskb;
 		} else {
 			skb_queue_head(&bcsp->unrel, skb);
-			BT_ERR("Could not dequeue pkt because alloc_skb failed");
+			bt_err("Could not dequeue pkt because alloc_skb failed");
 		}
 	}
 
@@ -317,7 +317,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
 			return nskb;
 		} else {
 			skb_queue_head(&bcsp->rel, skb);
-			BT_ERR("Could not dequeue pkt because alloc_skb failed");
+			bt_err("Could not dequeue pkt because alloc_skb failed");
 		}
 	}
 
@@ -340,7 +340,7 @@ static struct sk_buff *bcsp_dequeue(struct hci_uart *hu)
 
 static int bcsp_flush(struct hci_uart *hu)
 {
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 	return 0;
 }
 
@@ -365,9 +365,9 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp)
 	}
 
 	if (bcsp->rxack != seqno)
-		BT_ERR("Peer acked invalid packet");
+		bt_err("Peer acked invalid packet");
 
-	BT_DBG("Removing %u pkts out of %u, up to seqno %u",
+	bt_dbg("Removing %u pkts out of %u, up to seqno %u",
 	       pkts_to_be_removed, skb_queue_len(&bcsp->unack),
 	       (seqno - 1) & 0x07);
 
@@ -387,7 +387,7 @@ static void bcsp_pkt_cull(struct bcsp_struct *bcsp)
 	spin_unlock_irqrestore(&bcsp->unack.lock, flags);
 
 	if (i != pkts_to_be_removed)
-		BT_ERR("Removed only %u out of %u pkts", i, pkts_to_be_removed);
+		bt_err("Removed only %u out of %u pkts", i, pkts_to_be_removed);
 }
 
 /* Handle BCSP link-establishment packets. When we
@@ -405,7 +405,7 @@ static void bcsp_handle_le_pkt(struct hci_uart *hu)
 			!memcmp(&bcsp->rx_skb->data[4], conf_pkt, 4)) {
 		struct sk_buff *nskb = alloc_skb(4, GFP_ATOMIC);
 
-		BT_DBG("Found a LE conf pkt");
+		bt_dbg("Found a LE conf pkt");
 		if (!nskb)
 			return;
 		memcpy(skb_put(nskb, 4), conf_rsp_pkt, 4);
@@ -417,7 +417,7 @@ static void bcsp_handle_le_pkt(struct hci_uart *hu)
 	/* Spot "sync" pkts. If we find one...disaster! */
 	else if (bcsp->rx_skb->data[1] >> 4 == 4 && bcsp->rx_skb->data[2] == 0 &&
 			!memcmp(&bcsp->rx_skb->data[4], sync_pkt, 4)) {
-		BT_ERR("Found a LE sync pkt, card has reset");
+		bt_err("Found a LE sync pkt, card has reset");
 	}
 }
 
@@ -461,7 +461,7 @@ static inline void bcsp_unslip_one_byte(struct bcsp_struct *bcsp, unsigned char
 			break;
 
 		default:
-			BT_ERR ("Invalid byte %02x after esc byte", byte);
+			bt_err ("Invalid byte %02x after esc byte", byte);
 			kfree_skb(bcsp->rx_skb);
 			bcsp->rx_skb = NULL;
 			bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
@@ -476,7 +476,7 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu)
 	int pass_up;
 
 	if (bcsp->rx_skb->data[0] & 0x80) {	/* reliable pkt */
-		BT_DBG("Received seqno %u from card", bcsp->rxseq_txack);
+		bt_dbg("Received seqno %u from card", bcsp->rxseq_txack);
 		bcsp->rxseq_txack++;
 		bcsp->rxseq_txack %= 0x8;
 		bcsp->txack_req    = 1;
@@ -486,7 +486,7 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu)
 	}
 
 	bcsp->rxack = (bcsp->rx_skb->data[0] >> 3) & 0x07;
-	BT_DBG("Request for pkt %u from card", bcsp->rxack);
+	bt_dbg("Request for pkt %u from card", bcsp->rxack);
 
 	bcsp_pkt_cull(bcsp);
 	if ((bcsp->rx_skb->data[1] & 0x0f) == 6 &&
@@ -524,7 +524,7 @@ static void bcsp_complete_rx_pkt(struct hci_uart *hu)
 
 				hci_recv_frame(bcsp->rx_skb);
 			} else {
-				BT_ERR ("Packet for unknown channel (%u %s)",
+				bt_err ("Packet for unknown channel (%u %s)",
 					bcsp->rx_skb->data[1] & 0x0f,
 					bcsp->rx_skb->data[0] & 0x80 ? 
 					"reliable" : "unreliable");
@@ -554,14 +554,14 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
 	struct bcsp_struct *bcsp = hu->priv;
 	register unsigned char *ptr;
 
-	BT_DBG("hu %p count %d rx_state %d rx_count %ld", 
+	bt_dbg("hu %p count %d rx_state %d rx_count %ld", 
 		hu, count, bcsp->rx_state, bcsp->rx_count);
 
 	ptr = data;
 	while (count) {
 		if (bcsp->rx_count) {
 			if (*ptr == 0xc0) {
-				BT_ERR("Short BCSP packet");
+				bt_err("Short BCSP packet");
 				kfree_skb(bcsp->rx_skb);
 				bcsp->rx_state = BCSP_W4_PKT_START;
 				bcsp->rx_count = 0;
@@ -576,7 +576,7 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
 		case BCSP_W4_BCSP_HDR:
 			if ((0xff & (u8) ~ (bcsp->rx_skb->data[0] + bcsp->rx_skb->data[1] +
 					bcsp->rx_skb->data[2])) != bcsp->rx_skb->data[3]) {
-				BT_ERR("Error in BCSP hdr checksum");
+				bt_err("Error in BCSP hdr checksum");
 				kfree_skb(bcsp->rx_skb);
 				bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
 				bcsp->rx_count = 0;
@@ -584,7 +584,7 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
 			}
 			if (bcsp->rx_skb->data[0] & 0x80	/* reliable pkt */
 			    		&& (bcsp->rx_skb->data[0] & 0x07) != bcsp->rxseq_txack) {
-				BT_ERR ("Out-of-order packet arrived, got %u expected %u",
+				bt_err ("Out-of-order packet arrived, got %u expected %u",
 					bcsp->rx_skb->data[0] & 0x07, bcsp->rxseq_txack);
 
 				kfree_skb(bcsp->rx_skb);
@@ -607,7 +607,7 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
 
 		case BCSP_W4_CRC:
 			if (bitrev16(bcsp->message_crc) != bscp_get_crc(bcsp)) {
-				BT_ERR ("Checksum failed: computed %04x received %04x",
+				bt_err ("Checksum failed: computed %04x received %04x",
 					bitrev16(bcsp->message_crc),
 					bscp_get_crc(bcsp));
 
@@ -626,7 +626,7 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
 				bcsp->rx_state = BCSP_W4_PKT_START;
 				break;
 			default:
-				/*BT_ERR("Ignoring byte %02x", *ptr);*/
+				/*bt_err("Ignoring byte %02x", *ptr);*/
 				break;
 			}
 			ptr++; count--;
@@ -650,7 +650,7 @@ static int bcsp_recv(struct hci_uart *hu, void *data, int count)
 
 				bcsp->rx_skb = bt_skb_alloc(0x1005, GFP_ATOMIC);
 				if (!bcsp->rx_skb) {
-					BT_ERR("Can't allocate mem for new packet");
+					bt_err("Can't allocate mem for new packet");
 					bcsp->rx_state = BCSP_W4_PKT_DELIMITER;
 					bcsp->rx_count = 0;
 					return 0;
@@ -672,7 +672,7 @@ static void bcsp_timed_event(unsigned long arg)
 	struct sk_buff *skb;
 	unsigned long flags;
 
-	BT_DBG("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen);
+	bt_dbg("hu %p retransmitting %u pkts", hu, bcsp->unack.qlen);
 
 	spin_lock_irqsave_nested(&bcsp->unack.lock, flags, SINGLE_DEPTH_NESTING);
 
@@ -690,7 +690,7 @@ static int bcsp_open(struct hci_uart *hu)
 {
 	struct bcsp_struct *bcsp;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	bcsp = kzalloc(sizeof(*bcsp), GFP_ATOMIC);
 	if (!bcsp)
@@ -718,7 +718,7 @@ static int bcsp_close(struct hci_uart *hu)
 	struct bcsp_struct *bcsp = hu->priv;
 	hu->priv = NULL;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	skb_queue_purge(&bcsp->unack);
 	skb_queue_purge(&bcsp->rel);
@@ -744,9 +744,9 @@ int __init bcsp_init(void)
 	int err = hci_uart_register_proto(&bcsp);
 
 	if (!err)
-		BT_INFO("HCI BCSP protocol initialized");
+		bt_info("HCI BCSP protocol initialized");
 	else
-		BT_ERR("HCI BCSP protocol registration failed");
+		bt_err("HCI BCSP protocol registration failed");
 
 	return err;
 }
diff --git a/drivers/bluetooth/hci_h4.c b/drivers/bluetooth/hci_h4.c
index 2fcd8b3..a962c9f 100644
--- a/drivers/bluetooth/hci_h4.c
+++ b/drivers/bluetooth/hci_h4.c
@@ -67,7 +67,7 @@ static int h4_open(struct hci_uart *hu)
 {
 	struct h4_struct *h4;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	h4 = kzalloc(sizeof(*h4), GFP_ATOMIC);
 	if (!h4)
@@ -84,7 +84,7 @@ static int h4_flush(struct hci_uart *hu)
 {
 	struct h4_struct *h4 = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	skb_queue_purge(&h4->txq);
 
@@ -98,7 +98,7 @@ static int h4_close(struct hci_uart *hu)
 
 	hu->priv = NULL;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	skb_queue_purge(&h4->txq);
 
@@ -115,7 +115,7 @@ static int h4_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 {
 	struct h4_struct *h4 = hu->priv;
 
-	BT_DBG("hu %p skb %p", hu, skb);
+	bt_dbg("hu %p skb %p", hu, skb);
 
 	/* Prepend skb with frame type */
 	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
@@ -128,12 +128,12 @@ static inline int h4_check_data_len(struct h4_struct *h4, int len)
 {
 	register int room = skb_tailroom(h4->rx_skb);
 
-	BT_DBG("len %d room %d", len, room);
+	bt_dbg("len %d room %d", len, room);
 
 	if (!len) {
 		hci_recv_frame(h4->rx_skb);
 	} else if (len > room) {
-		BT_ERR("Data length is too large");
+		bt_err("Data length is too large");
 		kfree_skb(h4->rx_skb);
 	} else {
 		h4->rx_state = H4_W4_DATA;
@@ -155,7 +155,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
 
 	ret = hci_recv_stream_fragment(hu->hdev, data, count);
 	if (ret < 0) {
-		BT_ERR("Frame Reassembly Failed");
+		bt_err("Frame Reassembly Failed");
 		return ret;
 	}
 
@@ -183,9 +183,9 @@ int __init h4_init(void)
 	int err = hci_uart_register_proto(&h4p);
 
 	if (!err)
-		BT_INFO("HCI H4 protocol initialized");
+		bt_info("HCI H4 protocol initialized");
 	else
-		BT_ERR("HCI H4 protocol registration failed");
+		bt_err("HCI H4 protocol registration failed");
 
 	return err;
 }
diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c
index 48ad2a7..a009920 100644
--- a/drivers/bluetooth/hci_ldisc.c
+++ b/drivers/bluetooth/hci_ldisc.c
@@ -129,7 +129,7 @@ int hci_uart_tx_wakeup(struct hci_uart *hu)
 		return 0;
 	}
 
-	BT_DBG("");
+	bt_dbg("");
 
 restart:
 	clear_bit(HCI_UART_TX_WAKEUP, &hu->tx_state);
@@ -162,7 +162,7 @@ restart:
 /* Initialize device */
 static int hci_uart_open(struct hci_dev *hdev)
 {
-	BT_DBG("%s %p", hdev->name, hdev);
+	bt_dbg("%s %p", hdev->name, hdev);
 
 	/* Nothing to do for UART driver */
 
@@ -177,7 +177,7 @@ static int hci_uart_flush(struct hci_dev *hdev)
 	struct hci_uart *hu  = (struct hci_uart *) hdev->driver_data;
 	struct tty_struct *tty = hu->tty;
 
-	BT_DBG("hdev %p tty %p", hdev, tty);
+	bt_dbg("hdev %p tty %p", hdev, tty);
 
 	if (hu->tx_skb) {
 		kfree_skb(hu->tx_skb); hu->tx_skb = NULL;
@@ -196,7 +196,7 @@ static int hci_uart_flush(struct hci_dev *hdev)
 /* Close device */
 static int hci_uart_close(struct hci_dev *hdev)
 {
-	BT_DBG("hdev %p", hdev);
+	bt_dbg("hdev %p", hdev);
 
 	if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))
 		return 0;
@@ -213,7 +213,7 @@ static int hci_uart_send_frame(struct sk_buff *skb)
 	struct hci_uart *hu;
 
 	if (!hdev) {
-		BT_ERR("Frame for unknown device (hdev=NULL)");
+		bt_err("Frame for unknown device (hdev=NULL)");
 		return -ENODEV;
 	}
 
@@ -222,7 +222,7 @@ static int hci_uart_send_frame(struct sk_buff *skb)
 
 	hu = (struct hci_uart *) hdev->driver_data;
 
-	BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
+	bt_dbg("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
 
 	hu->proto->enqueue(hu, skb);
 
@@ -236,7 +236,7 @@ static void hci_uart_destruct(struct hci_dev *hdev)
 	if (!hdev)
 		return;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 	kfree(hdev->driver_data);
 }
 
@@ -254,7 +254,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 {
 	struct hci_uart *hu = (void *) tty->disc_data;
 
-	BT_DBG("tty %p", tty);
+	bt_dbg("tty %p", tty);
 
 	/* FIXME: This btw is bogus, nothing requires the old ldisc to clear
 	   the pointer */
@@ -267,7 +267,7 @@ static int hci_uart_tty_open(struct tty_struct *tty)
 		return -EOPNOTSUPP;
 
 	if (!(hu = kzalloc(sizeof(struct hci_uart), GFP_KERNEL))) {
-		BT_ERR("Can't allocate control structure");
+		bt_err("Can't allocate control structure");
 		return -ENFILE;
 	}
 
@@ -298,7 +298,7 @@ static void hci_uart_tty_close(struct tty_struct *tty)
 {
 	struct hci_uart *hu = (void *)tty->disc_data;
 
-	BT_DBG("tty %p", tty);
+	bt_dbg("tty %p", tty);
 
 	/* Detach from the tty */
 	tty->disc_data = NULL;
@@ -331,7 +331,7 @@ static void hci_uart_tty_wakeup(struct tty_struct *tty)
 {
 	struct hci_uart *hu = (void *)tty->disc_data;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	if (!hu)
 		return;
@@ -379,12 +379,12 @@ static int hci_uart_register_dev(struct hci_uart *hu)
 {
 	struct hci_dev *hdev;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	/* Initialize and register HCI device */
 	hdev = hci_alloc_dev();
 	if (!hdev) {
-		BT_ERR("Can't allocate HCI device");
+		bt_err("Can't allocate HCI device");
 		return -ENOMEM;
 	}
 
@@ -409,7 +409,7 @@ static int hci_uart_register_dev(struct hci_uart *hu)
 		set_bit(HCI_QUIRK_RAW_DEVICE, &hdev->quirks);
 
 	if (hci_register_dev(hdev) < 0) {
-		BT_ERR("Can't register HCI device");
+		bt_err("Can't register HCI device");
 		hci_free_dev(hdev);
 		return -ENODEV;
 	}
@@ -460,7 +460,7 @@ static int hci_uart_tty_ioctl(struct tty_struct *tty, struct file * file,
 	struct hci_uart *hu = (void *)tty->disc_data;
 	int err = 0;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	/* Verify the status of the device */
 	if (!hu)
@@ -531,7 +531,7 @@ static int __init hci_uart_init(void)
 	static struct tty_ldisc_ops hci_uart_ldisc;
 	int err;
 
-	BT_INFO("HCI UART driver ver %s", VERSION);
+	bt_info("HCI UART driver ver %s", VERSION);
 
 	/* Register the tty discipline */
 
@@ -549,7 +549,7 @@ static int __init hci_uart_init(void)
 	hci_uart_ldisc.owner		= THIS_MODULE;
 
 	if ((err = tty_register_ldisc(N_HCI, &hci_uart_ldisc))) {
-		BT_ERR("HCI line discipline registration failed. (%d)", err);
+		bt_err("HCI line discipline registration failed. (%d)", err);
 		return err;
 	}
 
@@ -588,7 +588,7 @@ static void __exit hci_uart_exit(void)
 
 	/* Release tty registration of line discipline */
 	if ((err = tty_unregister_ldisc(N_HCI)))
-		BT_ERR("Can't unregister HCI line discipline (%d)", err);
+		bt_err("Can't unregister HCI line discipline (%d)", err);
 }
 
 module_init(hci_uart_init);
diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index 7e4b435..008fd4e 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -97,12 +97,12 @@ static int send_hcill_cmd(u8 cmd, struct hci_uart *hu)
 	struct ll_struct *ll = hu->priv;
 	struct hcill_cmd *hcill_packet;
 
-	BT_DBG("hu %p cmd 0x%x", hu, cmd);
+	bt_dbg("hu %p cmd 0x%x", hu, cmd);
 
 	/* allocate packet */
 	skb = bt_skb_alloc(1, GFP_ATOMIC);
 	if (!skb) {
-		BT_ERR("cannot allocate memory for HCILL packet");
+		bt_err("cannot allocate memory for HCILL packet");
 		err = -ENOMEM;
 		goto out;
 	}
@@ -123,7 +123,7 @@ static int ll_open(struct hci_uart *hu)
 {
 	struct ll_struct *ll;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	ll = kzalloc(sizeof(*ll), GFP_ATOMIC);
 	if (!ll)
@@ -145,7 +145,7 @@ static int ll_flush(struct hci_uart *hu)
 {
 	struct ll_struct *ll = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	skb_queue_purge(&ll->tx_wait_q);
 	skb_queue_purge(&ll->txq);
@@ -158,7 +158,7 @@ static int ll_close(struct hci_uart *hu)
 {
 	struct ll_struct *ll = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	skb_queue_purge(&ll->tx_wait_q);
 	skb_queue_purge(&ll->txq);
@@ -197,7 +197,7 @@ static void ll_device_want_to_wakeup(struct hci_uart *hu)
 	unsigned long flags;
 	struct ll_struct *ll = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	/* lock hcill state */
 	spin_lock_irqsave(&ll->hcill_lock, flags);
@@ -214,18 +214,18 @@ static void ll_device_want_to_wakeup(struct hci_uart *hu)
 		 * require an explicit ack here, do accept it, thus it is
 		 * perfectly safe to always send one.
 		 */
-		BT_DBG("dual wake-up-indication");
+		bt_dbg("dual wake-up-indication");
 		/* deliberate fall-through - do not add break */
 	case HCILL_ASLEEP:
 		/* acknowledge device wake up */
 		if (send_hcill_cmd(HCILL_WAKE_UP_ACK, hu) < 0) {
-			BT_ERR("cannot acknowledge device wake up");
+			bt_err("cannot acknowledge device wake up");
 			goto out;
 		}
 		break;
 	default:
 		/* any other state is illegal */
-		BT_ERR("received HCILL_WAKE_UP_IND in state %ld", ll->hcill_state);
+		bt_err("received HCILL_WAKE_UP_IND in state %ld", ll->hcill_state);
 		break;
 	}
 
@@ -247,18 +247,18 @@ static void ll_device_want_to_sleep(struct hci_uart *hu)
 	unsigned long flags;
 	struct ll_struct *ll = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	/* lock hcill state */
 	spin_lock_irqsave(&ll->hcill_lock, flags);
 
 	/* sanity check */
 	if (ll->hcill_state != HCILL_AWAKE)
-		BT_ERR("ERR: HCILL_GO_TO_SLEEP_IND in state %ld", ll->hcill_state);
+		bt_err("ERR: HCILL_GO_TO_SLEEP_IND in state %ld", ll->hcill_state);
 
 	/* acknowledge device sleep */
 	if (send_hcill_cmd(HCILL_GO_TO_SLEEP_ACK, hu) < 0) {
-		BT_ERR("cannot acknowledge device sleep");
+		bt_err("cannot acknowledge device sleep");
 		goto out;
 	}
 
@@ -280,14 +280,14 @@ static void ll_device_woke_up(struct hci_uart *hu)
 	unsigned long flags;
 	struct ll_struct *ll = hu->priv;
 
-	BT_DBG("hu %p", hu);
+	bt_dbg("hu %p", hu);
 
 	/* lock hcill state */
 	spin_lock_irqsave(&ll->hcill_lock, flags);
 
 	/* sanity check */
 	if (ll->hcill_state != HCILL_ASLEEP_TO_AWAKE)
-		BT_ERR("received HCILL_WAKE_UP_ACK in state %ld", ll->hcill_state);
+		bt_err("received HCILL_WAKE_UP_ACK in state %ld", ll->hcill_state);
 
 	/* send pending packets and change state to HCILL_AWAKE */
 	__ll_do_awake(ll);
@@ -305,7 +305,7 @@ static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 	unsigned long flags = 0;
 	struct ll_struct *ll = hu->priv;
 
-	BT_DBG("hu %p skb %p", hu, skb);
+	bt_dbg("hu %p skb %p", hu, skb);
 
 	/* Prepend skb with frame type */
 	memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
@@ -316,27 +316,27 @@ static int ll_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 	/* act according to current state */
 	switch (ll->hcill_state) {
 	case HCILL_AWAKE:
-		BT_DBG("device awake, sending normally");
+		bt_dbg("device awake, sending normally");
 		skb_queue_tail(&ll->txq, skb);
 		break;
 	case HCILL_ASLEEP:
-		BT_DBG("device asleep, waking up and queueing packet");
+		bt_dbg("device asleep, waking up and queueing packet");
 		/* save packet for later */
 		skb_queue_tail(&ll->tx_wait_q, skb);
 		/* awake device */
 		if (send_hcill_cmd(HCILL_WAKE_UP_IND, hu) < 0) {
-			BT_ERR("cannot wake up device");
+			bt_err("cannot wake up device");
 			break;
 		}
 		ll->hcill_state = HCILL_ASLEEP_TO_AWAKE;
 		break;
 	case HCILL_ASLEEP_TO_AWAKE:
-		BT_DBG("device waking up, queueing packet");
+		bt_dbg("device waking up, queueing packet");
 		/* transient state; just keep packet for later */
 		skb_queue_tail(&ll->tx_wait_q, skb);
 		break;
 	default:
-		BT_ERR("illegal hcill state: %ld (losing packet)", ll->hcill_state);
+		bt_err("illegal hcill state: %ld (losing packet)", ll->hcill_state);
 		kfree_skb(skb);
 		break;
 	}
@@ -350,12 +350,12 @@ static inline int ll_check_data_len(struct ll_struct *ll, int len)
 {
 	register int room = skb_tailroom(ll->rx_skb);
 
-	BT_DBG("len %d room %d", len, room);
+	bt_dbg("len %d room %d", len, room);
 
 	if (!len) {
 		hci_recv_frame(ll->rx_skb);
 	} else if (len > room) {
-		BT_ERR("Data length is too large");
+		bt_err("Data length is too large");
 		kfree_skb(ll->rx_skb);
 	} else {
 		ll->rx_state = HCILL_W4_DATA;
@@ -380,7 +380,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 	struct hci_sco_hdr   *sh;
 	register int len, type, dlen;
 
-	BT_DBG("hu %p count %d rx_state %ld rx_count %ld", hu, count, ll->rx_state, ll->rx_count);
+	bt_dbg("hu %p count %d rx_state %ld rx_count %ld", hu, count, ll->rx_state, ll->rx_count);
 
 	ptr = data;
 	while (count) {
@@ -394,7 +394,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 
 			switch (ll->rx_state) {
 			case HCILL_W4_DATA:
-				BT_DBG("Complete data");
+				bt_dbg("Complete data");
 				hci_recv_frame(ll->rx_skb);
 
 				ll->rx_state = HCILL_W4_PACKET_TYPE;
@@ -404,7 +404,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 			case HCILL_W4_EVENT_HDR:
 				eh = hci_event_hdr(ll->rx_skb);
 
-				BT_DBG("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen);
+				bt_dbg("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen);
 
 				ll_check_data_len(ll, eh->plen);
 				continue;
@@ -413,7 +413,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 				ah = hci_acl_hdr(ll->rx_skb);
 				dlen = __le16_to_cpu(ah->dlen);
 
-				BT_DBG("ACL header: dlen %d", dlen);
+				bt_dbg("ACL header: dlen %d", dlen);
 
 				ll_check_data_len(ll, dlen);
 				continue;
@@ -421,7 +421,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 			case HCILL_W4_SCO_HDR:
 				sh = hci_sco_hdr(ll->rx_skb);
 
-				BT_DBG("SCO header: dlen %d", sh->dlen);
+				bt_dbg("SCO header: dlen %d", sh->dlen);
 
 				ll_check_data_len(ll, sh->dlen);
 				continue;
@@ -431,21 +431,21 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 		/* HCILL_W4_PACKET_TYPE */
 		switch (*ptr) {
 		case HCI_EVENT_PKT:
-			BT_DBG("Event packet");
+			bt_dbg("Event packet");
 			ll->rx_state = HCILL_W4_EVENT_HDR;
 			ll->rx_count = HCI_EVENT_HDR_SIZE;
 			type = HCI_EVENT_PKT;
 			break;
 
 		case HCI_ACLDATA_PKT:
-			BT_DBG("ACL packet");
+			bt_dbg("ACL packet");
 			ll->rx_state = HCILL_W4_ACL_HDR;
 			ll->rx_count = HCI_ACL_HDR_SIZE;
 			type = HCI_ACLDATA_PKT;
 			break;
 
 		case HCI_SCODATA_PKT:
-			BT_DBG("SCO packet");
+			bt_dbg("SCO packet");
 			ll->rx_state = HCILL_W4_SCO_HDR;
 			ll->rx_count = HCI_SCO_HDR_SIZE;
 			type = HCI_SCODATA_PKT;
@@ -453,31 +453,31 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 
 		/* HCILL signals */
 		case HCILL_GO_TO_SLEEP_IND:
-			BT_DBG("HCILL_GO_TO_SLEEP_IND packet");
+			bt_dbg("HCILL_GO_TO_SLEEP_IND packet");
 			ll_device_want_to_sleep(hu);
 			ptr++; count--;
 			continue;
 
 		case HCILL_GO_TO_SLEEP_ACK:
 			/* shouldn't happen */
-			BT_ERR("received HCILL_GO_TO_SLEEP_ACK (in state %ld)", ll->hcill_state);
+			bt_err("received HCILL_GO_TO_SLEEP_ACK (in state %ld)", ll->hcill_state);
 			ptr++; count--;
 			continue;
 
 		case HCILL_WAKE_UP_IND:
-			BT_DBG("HCILL_WAKE_UP_IND packet");
+			bt_dbg("HCILL_WAKE_UP_IND packet");
 			ll_device_want_to_wakeup(hu);
 			ptr++; count--;
 			continue;
 
 		case HCILL_WAKE_UP_ACK:
-			BT_DBG("HCILL_WAKE_UP_ACK packet");
+			bt_dbg("HCILL_WAKE_UP_ACK packet");
 			ll_device_woke_up(hu);
 			ptr++; count--;
 			continue;
 
 		default:
-			BT_ERR("Unknown HCI packet type %2.2x", (__u8)*ptr);
+			bt_err("Unknown HCI packet type %2.2x", (__u8)*ptr);
 			hu->hdev->stat.err_rx++;
 			ptr++; count--;
 			continue;
@@ -488,7 +488,7 @@ static int ll_recv(struct hci_uart *hu, void *data, int count)
 		/* Allocate packet */
 		ll->rx_skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
 		if (!ll->rx_skb) {
-			BT_ERR("Can't allocate mem for new packet");
+			bt_err("Can't allocate mem for new packet");
 			ll->rx_state = HCILL_W4_PACKET_TYPE;
 			ll->rx_count = 0;
 			return -ENOMEM;
@@ -522,9 +522,9 @@ int __init ll_init(void)
 	int err = hci_uart_register_proto(&llp);
 
 	if (!err)
-		BT_INFO("HCILL protocol initialized");
+		bt_info("HCILL protocol initialized");
 	else
-		BT_ERR("HCILL protocol registration failed");
+		bt_err("HCILL protocol registration failed");
 
 	return err;
 }
diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 67c180c..cb43f9e 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -84,7 +84,7 @@ static int vhci_send_frame(struct sk_buff *skb)
 	struct vhci_data *data;
 
 	if (!hdev) {
-		BT_ERR("Frame for unknown HCI device (hdev=NULL)");
+		bt_err("Frame for unknown HCI device (hdev=NULL)");
 		return -ENODEV;
 	}
 
@@ -248,7 +248,7 @@ static int vhci_open(struct inode *inode, struct file *file)
 	hdev->owner = THIS_MODULE;
 
 	if (hci_register_dev(hdev) < 0) {
-		BT_ERR("Can't register HCI device");
+		bt_err("Can't register HCI device");
 		kfree(data);
 		hci_free_dev(hdev);
 		return -EBUSY;
@@ -265,7 +265,7 @@ static int vhci_release(struct inode *inode, struct file *file)
 	struct hci_dev *hdev = data->hdev;
 
 	if (hci_unregister_dev(hdev) < 0) {
-		BT_ERR("Can't unregister HCI device %s", hdev->name);
+		bt_err("Can't unregister HCI device %s", hdev->name);
 	}
 
 	hci_free_dev(hdev);
@@ -293,7 +293,7 @@ static struct miscdevice vhci_miscdev= {
 
 static int __init vhci_init(void)
 {
-	BT_INFO("Virtual HCI driver ver %s", VERSION);
+	bt_info("Virtual HCI driver ver %s", VERSION);
 
 	return misc_register(&vhci_miscdev);
 }
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 7d77545f..b83d977 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -76,9 +76,12 @@ struct bt_power {
 #define BT_POWER_FORCE_ACTIVE_OFF 0
 #define BT_POWER_FORCE_ACTIVE_ON  1
 
-#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
-#define BT_ERR(fmt, arg...)  printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
-#define BT_DBG(fmt, arg...)  pr_debug("%s: " fmt "\n" , __func__ , ## arg)
+__attribute__((format (printf, 2, 3)))
+int bt_printk(const char *level, const char *fmt, ...);
+
+#define bt_info(fmt, arg...)	bt_printk(KERN_INFO, pr_fmt(fmt), ##arg)
+#define bt_err(fmt, arg...)	bt_printk(KERN_ERR, pr_fmt(fmt), ##arg)
+#define bt_dbg(fmt, arg...)	pr_debug(fmt "\n", ##arg)
 
 /* Connection and socket states */
 enum {
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 8add9b4..4748ad8 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -172,7 +172,7 @@ EXPORT_SYMBOL(bt_sock_unlink);
 
 void bt_accept_enqueue(struct sock *parent, struct sock *sk)
 {
-	BT_DBG("parent %p, sk %p", parent, sk);
+	bt_dbg("parent %p, sk %p", parent, sk);
 
 	sock_hold(sk);
 	list_add_tail(&bt_sk(sk)->accept_q, &bt_sk(parent)->accept_q);
@@ -183,7 +183,7 @@ EXPORT_SYMBOL(bt_accept_enqueue);
 
 void bt_accept_unlink(struct sock *sk)
 {
-	BT_DBG("sk %p state %d", sk, sk->sk_state);
+	bt_dbg("sk %p state %d", sk, sk->sk_state);
 
 	list_del_init(&bt_sk(sk)->accept_q);
 	bt_sk(sk)->parent->sk_ack_backlog--;
@@ -197,7 +197,7 @@ struct sock *bt_accept_dequeue(struct sock *parent, struct socket *newsock)
 	struct list_head *p, *n;
 	struct sock *sk;
 
-	BT_DBG("parent %p", parent);
+	bt_dbg("parent %p", parent);
 
 	local_bh_disable();
 	list_for_each_safe(p, n, &bt_sk(parent)->accept_q) {
@@ -240,7 +240,7 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
 	size_t copied;
 	int err;
 
-	BT_DBG("sock %p sk %p len %zu", sock, sk, len);
+	bt_dbg("sock %p sk %p len %zu", sock, sk, len);
 
 	if (flags & (MSG_OOB))
 		return -EOPNOTSUPP;
@@ -313,7 +313,7 @@ int bt_sock_stream_recvmsg(struct kiocb *iocb, struct socket *sock,
 
 	msg->msg_namelen = 0;
 
-	BT_DBG("sk %p size %zu", sk, size);
+	bt_dbg("sk %p size %zu", sk, size);
 
 	lock_sock(sk);
 
@@ -402,7 +402,7 @@ unsigned int bt_sock_poll(struct file *file, struct socket *sock, poll_table *wa
 	struct sock *sk = sock->sk;
 	unsigned int mask = 0;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	poll_wait(file, sk_sleep(sk), wait);
 
@@ -445,7 +445,7 @@ int bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
 	long amount;
 	int err;
 
-	BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg);
+	bt_dbg("sk %p cmd %x arg %lx", sk, cmd, arg);
 
 	switch (cmd) {
 	case TIOCOUTQ:
@@ -491,7 +491,7 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
 	DECLARE_WAITQUEUE(wait, current);
 	int err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	add_wait_queue(sk_sleep(sk), &wait);
 	while (sk->sk_state != state) {
@@ -531,7 +531,7 @@ static int __init bt_init(void)
 {
 	int err;
 
-	BT_INFO("Core ver %s", VERSION);
+	bt_info("Core ver %s", VERSION);
 
 	err = bt_sysfs_init();
 	if (err < 0)
@@ -543,7 +543,7 @@ static int __init bt_init(void)
 		return err;
 	}
 
-	BT_INFO("HCI device and connection manager initialized");
+	bt_info("HCI device and connection manager initialized");
 
 	err = hci_sock_init();
 	if (err < 0)
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index ca39fcf..29399d2 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -67,7 +67,7 @@ static struct bnep_session *__bnep_get_session(u8 *dst)
 	struct bnep_session *s;
 	struct list_head *p;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	list_for_each(p, &bnep_session_list) {
 		s = list_entry(p, struct bnep_session, list);
@@ -138,7 +138,7 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len
 	if (len < n)
 		return -EILSEQ;
 
-	BT_DBG("filter len %d", n);
+	bt_dbg("filter len %d", n);
 
 #ifdef CONFIG_BT_BNEP_PROTO_FILTER
 	n /= 4;
@@ -150,7 +150,7 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len
 			f[i].start = get_unaligned_be16(data++);
 			f[i].end   = get_unaligned_be16(data++);
 
-			BT_DBG("proto filter start %d end %d",
+			bt_dbg("proto filter start %d end %d",
 				f[i].start, f[i].end);
 		}
 
@@ -184,7 +184,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
 	if (len < n)
 		return -EILSEQ;
 
-	BT_DBG("filter len %d", n);
+	bt_dbg("filter len %d", n);
 
 #ifdef CONFIG_BT_BNEP_MC_FILTER
 	n /= (ETH_ALEN * 2);
@@ -206,7 +206,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
 			a2 = data;
 			data += ETH_ALEN;
 
-			BT_DBG("mc filter %s -> %s",
+			bt_dbg("mc filter %s -> %s",
 				batostr((void *) a1), batostr((void *) a2));
 
 			/* Iterate from a1 to a2 */
@@ -222,7 +222,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
 		}
 	}
 
-	BT_DBG("mc filter hash 0x%llx", s->mc_filter);
+	bt_dbg("mc filter hash 0x%llx", s->mc_filter);
 
 	bnep_send_rsp(s, BNEP_FILTER_MULTI_ADDR_RSP, BNEP_SUCCESS);
 #else
@@ -284,7 +284,7 @@ static int bnep_rx_extension(struct bnep_session *s, struct sk_buff *skb)
 			break;
 		}
 
-		BT_DBG("type 0x%x len %d", h->type, h->len);
+		bt_dbg("type 0x%x len %d", h->type, h->len);
 
 		switch (h->type & BNEP_TYPE_MASK) {
 		case BNEP_EXT_CONTROL:
@@ -419,7 +419,7 @@ static inline int bnep_tx_frame(struct bnep_session *s, struct sk_buff *skb)
 	int len = 0, il = 0;
 	u8 type = 0;
 
-	BT_DBG("skb %p dev %p type %d", skb, skb->dev, skb->pkt_type);
+	bt_dbg("skb %p dev %p type %d", skb, skb->dev, skb->pkt_type);
 
 	if (!skb->dev) {
 		/* Control frame sent by us */
@@ -478,7 +478,7 @@ static int bnep_session(void *arg)
 	struct sk_buff *skb;
 	wait_queue_t wait;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	set_user_nice(current, -15);
 
@@ -557,7 +557,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
 	u8 dst[ETH_ALEN], src[ETH_ALEN];
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	baswap((void *) dst, &bt_sk(sock->sk)->dst);
 	baswap((void *) src, &bt_sk(sock->sk)->src);
@@ -635,7 +635,7 @@ int bnep_del_connection(struct bnep_conndel_req *req)
 	struct bnep_session *s;
 	int  err = 0;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	down_read(&bnep_session_sem);
 
@@ -719,9 +719,9 @@ static int __init bnep_init(void)
 	strcat(flt, "multicast");
 #endif
 
-	BT_INFO("BNEP (Ethernet Emulation) ver %s", VERSION);
+	bt_info("BNEP (Ethernet Emulation) ver %s", VERSION);
 	if (flt[0])
-		BT_INFO("BNEP filters: %s", flt);
+		bt_info("BNEP filters: %s", flt);
 
 	bnep_sock_init();
 	return 0;
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
index 8c100c9..b43ab23 100644
--- a/net/bluetooth/bnep/netdev.c
+++ b/net/bluetooth/bnep/netdev.c
@@ -65,12 +65,12 @@ static void bnep_net_set_mc_list(struct net_device *dev)
 	struct sk_buff *skb;
 	int size;
 
-	BT_DBG("%s mc_count %d", dev->name, netdev_mc_count(dev));
+	bt_dbg("%s mc_count %d", dev->name, netdev_mc_count(dev));
 
 	size = sizeof(*r) + (BNEP_MAX_MULTICAST_FILTERS + 1) * ETH_ALEN * 2;
 	skb  = alloc_skb(size, GFP_ATOMIC);
 	if (!skb) {
-		BT_ERR("%s Multicast list allocation failed", dev->name);
+		bt_err("%s Multicast list allocation failed", dev->name);
 		return;
 	}
 
@@ -117,13 +117,13 @@ static void bnep_net_set_mc_list(struct net_device *dev)
 
 static int bnep_net_set_mac_addr(struct net_device *dev, void *arg)
 {
-	BT_DBG("%s", dev->name);
+	bt_dbg("%s", dev->name);
 	return 0;
 }
 
 static void bnep_net_timeout(struct net_device *dev)
 {
-	BT_DBG("net_timeout");
+	bt_dbg("net_timeout");
 	netif_wake_queue(dev);
 }
 
@@ -165,7 +165,7 @@ static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session
 			return 0;
 	}
 
-	BT_DBG("BNEP: filtered skb %p, proto 0x%.4x", skb, proto);
+	bt_dbg("BNEP: filtered skb %p, proto 0x%.4x", skb, proto);
 	return 1;
 }
 #endif
@@ -176,7 +176,7 @@ static netdev_tx_t bnep_net_xmit(struct sk_buff *skb,
 	struct bnep_session *s = netdev_priv(dev);
 	struct sock *sk = s->sock->sk;
 
-	BT_DBG("skb %p, dev %p", skb, dev);
+	bt_dbg("skb %p, dev %p", skb, dev);
 
 #ifdef CONFIG_BT_BNEP_MC_FILTER
 	if (bnep_net_mc_filter(skb, s)) {
@@ -202,7 +202,7 @@ static netdev_tx_t bnep_net_xmit(struct sk_buff *skb,
 	wake_up_interruptible(sk_sleep(sk));
 
 	if (skb_queue_len(&sk->sk_write_queue) >= BNEP_TX_QUEUE_LEN) {
-		BT_DBG("tx queue is full");
+		bt_dbg("tx queue is full");
 
 		/* Stop queuing.
 		 * Session thread will do netif_wake_queue() */
diff --git a/net/bluetooth/bnep/sock.c b/net/bluetooth/bnep/sock.c
index 17800b1..e5bbaa6 100644
--- a/net/bluetooth/bnep/sock.c
+++ b/net/bluetooth/bnep/sock.c
@@ -50,7 +50,7 @@ static int bnep_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	BT_DBG("sock %p sk %p", sock, sk);
+	bt_dbg("sock %p sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -70,7 +70,7 @@ static int bnep_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
 	void __user *argp = (void __user *)arg;
 	int err;
 
-	BT_DBG("cmd %x arg %lx", cmd, arg);
+	bt_dbg("cmd %x arg %lx", cmd, arg);
 
 	switch (cmd) {
 	case BNEPCONNADD:
@@ -201,7 +201,7 @@ static int bnep_sock_create(struct net *net, struct socket *sock, int protocol,
 {
 	struct sock *sk;
 
-	BT_DBG("sock %p", sock);
+	bt_dbg("sock %p", sock);
 
 	if (sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
@@ -245,7 +245,7 @@ int __init bnep_sock_init(void)
 	return 0;
 
 error:
-	BT_ERR("Can't register BNEP socket");
+	bt_err("Can't register BNEP socket");
 	proto_unregister(&bnep_proto);
 	return err;
 }
@@ -253,7 +253,7 @@ error:
 void __exit bnep_sock_cleanup(void)
 {
 	if (bt_sock_unregister(BTPROTO_BNEP) < 0)
-		BT_ERR("Can't unregister BNEP socket");
+		bt_err("Can't unregister BNEP socket");
 
 	proto_unregister(&bnep_proto);
 }
diff --git a/net/bluetooth/cmtp/capi.c b/net/bluetooth/cmtp/capi.c
index 040f67b..2deed02 100644
--- a/net/bluetooth/cmtp/capi.c
+++ b/net/bluetooth/cmtp/capi.c
@@ -74,7 +74,7 @@ static struct cmtp_application *cmtp_application_add(struct cmtp_session *sessio
 {
 	struct cmtp_application *app = kzalloc(sizeof(*app), GFP_KERNEL);
 
-	BT_DBG("session %p application %p appl %d", session, app, appl);
+	bt_dbg("session %p application %p appl %d", session, app, appl);
 
 	if (!app)
 		return NULL;
@@ -89,7 +89,7 @@ static struct cmtp_application *cmtp_application_add(struct cmtp_session *sessio
 
 static void cmtp_application_del(struct cmtp_session *session, struct cmtp_application *app)
 {
-	BT_DBG("session %p application %p", session, app);
+	bt_dbg("session %p application %p", session, app);
 
 	if (app) {
 		list_del(&app->list);
@@ -137,7 +137,7 @@ static void cmtp_send_capimsg(struct cmtp_session *session, struct sk_buff *skb)
 {
 	struct cmtp_scb *scb = (void *) skb->cb;
 
-	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+	bt_dbg("session %p skb %p len %d", session, skb, skb->len);
 
 	scb->id = -1;
 	scb->data = (CAPIMSG_COMMAND(skb->data) == CAPI_DATA_B3);
@@ -154,11 +154,11 @@ static void cmtp_send_interopmsg(struct cmtp_session *session,
 	struct sk_buff *skb;
 	unsigned char *s;
 
-	BT_DBG("session %p subcmd 0x%02x appl %d msgnum %d", session, subcmd, appl, msgnum);
+	bt_dbg("session %p subcmd 0x%02x appl %d msgnum %d", session, subcmd, appl, msgnum);
 
 	skb = alloc_skb(CAPI_MSG_BASELEN + 6 + len, GFP_ATOMIC);
 	if (!skb) {
-		BT_ERR("Can't allocate memory for interoperability packet");
+		bt_err("Can't allocate memory for interoperability packet");
 		return;
 	}
 
@@ -190,7 +190,7 @@ static void cmtp_recv_interopmsg(struct cmtp_session *session, struct sk_buff *s
 	__u16 appl, msgnum, func, info;
 	__u32 controller;
 
-	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+	bt_dbg("session %p skb %p len %d", session, skb, skb->len);
 
 	switch (CAPIMSG_SUBCOMMAND(skb->data)) {
 	case CAPI_CONF:
@@ -329,7 +329,7 @@ void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb)
 	__u16 appl;
 	__u32 contr;
 
-	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+	bt_dbg("session %p skb %p len %d", session, skb, skb->len);
 
 	if (skb->len < CAPI_MSG_BASELEN)
 		return;
@@ -352,7 +352,7 @@ void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb)
 		appl = application->appl;
 		CAPIMSG_SETAPPID(skb->data, appl);
 	} else {
-		BT_ERR("Can't find application with id %d", appl);
+		bt_err("Can't find application with id %d", appl);
 		kfree_skb(skb);
 		return;
 	}
@@ -363,7 +363,7 @@ void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb)
 	}
 
 	if (!ctrl) {
-		BT_ERR("Can't find controller %d for message", session->num);
+		bt_err("Can't find controller %d for message", session->num);
 		kfree_skb(skb);
 		return;
 	}
@@ -373,7 +373,7 @@ void cmtp_recv_capimsg(struct cmtp_session *session, struct sk_buff *skb)
 
 static int cmtp_load_firmware(struct capi_ctr *ctrl, capiloaddata *data)
 {
-	BT_DBG("ctrl %p data %p", ctrl, data);
+	bt_dbg("ctrl %p data %p", ctrl, data);
 
 	return 0;
 }
@@ -382,7 +382,7 @@ static void cmtp_reset_ctr(struct capi_ctr *ctrl)
 {
 	struct cmtp_session *session = ctrl->driverdata;
 
-	BT_DBG("ctrl %p", ctrl);
+	bt_dbg("ctrl %p", ctrl);
 
 	capi_ctr_down(ctrl);
 
@@ -398,12 +398,12 @@ static void cmtp_register_appl(struct capi_ctr *ctrl, __u16 appl, capi_register_
 	unsigned char buf[8];
 	int err = 0, nconn, want = rp->level3cnt;
 
-	BT_DBG("ctrl %p appl %d level3cnt %d datablkcnt %d datablklen %d",
+	bt_dbg("ctrl %p appl %d level3cnt %d datablkcnt %d datablklen %d",
 		ctrl, appl, rp->level3cnt, rp->datablkcnt, rp->datablklen);
 
 	application = cmtp_application_add(session, appl);
 	if (!application) {
-		BT_ERR("Can't allocate memory for new application");
+		bt_err("Can't allocate memory for new application");
 		return;
 	}
 
@@ -463,11 +463,11 @@ static void cmtp_release_appl(struct capi_ctr *ctrl, __u16 appl)
 	struct cmtp_session *session = ctrl->driverdata;
 	struct cmtp_application *application;
 
-	BT_DBG("ctrl %p appl %d", ctrl, appl);
+	bt_dbg("ctrl %p appl %d", ctrl, appl);
 
 	application = cmtp_application_get(session, CMTP_APPLID, appl);
 	if (!application) {
-		BT_ERR("Can't find application");
+		bt_err("Can't find application");
 		return;
 	}
 
@@ -489,14 +489,14 @@ static u16 cmtp_send_message(struct capi_ctr *ctrl, struct sk_buff *skb)
 	__u16 appl;
 	__u32 contr;
 
-	BT_DBG("ctrl %p skb %p", ctrl, skb);
+	bt_dbg("ctrl %p skb %p", ctrl, skb);
 
 	appl = CAPIMSG_APPID(skb->data);
 	contr = CAPIMSG_CONTROL(skb->data);
 
 	application = cmtp_application_get(session, CMTP_APPLID, appl);
 	if ((!application) || (application->state != BT_CONNECTED)) {
-		BT_ERR("Can't find application with id %d", appl);
+		bt_err("Can't find application with id %d", appl);
 		return CAPI_ILLAPPNR;
 	}
 
@@ -554,7 +554,7 @@ int cmtp_attach_device(struct cmtp_session *session)
 	unsigned char buf[4];
 	long ret;
 
-	BT_DBG("session %p", session);
+	bt_dbg("session %p", session);
 
 	capimsg_setu32(buf, 0, 0);
 
@@ -564,7 +564,7 @@ int cmtp_attach_device(struct cmtp_session *session)
 	ret = wait_event_interruptible_timeout(session->wait,
 			session->ncontroller, CMTP_INTEROP_TIMEOUT);
 
-	BT_INFO("Found %d CAPI controller(s) on device %s", session->ncontroller, session->name);
+	bt_info("Found %d CAPI controller(s) on device %s", session->ncontroller, session->name);
 
 	if (!ret)
 		return -ETIMEDOUT;
@@ -573,7 +573,7 @@ int cmtp_attach_device(struct cmtp_session *session)
 		return -ENODEV;
 
 	if (session->ncontroller > 1)
-		BT_INFO("Setting up only CAPI controller 1");
+		bt_info("Setting up only CAPI controller 1");
 
 	session->ctrl.owner      = THIS_MODULE;
 	session->ctrl.driverdata = session;
@@ -590,13 +590,13 @@ int cmtp_attach_device(struct cmtp_session *session)
 	session->ctrl.proc_fops = &cmtp_proc_fops;
 
 	if (attach_capi_ctr(&session->ctrl) < 0) {
-		BT_ERR("Can't attach new controller");
+		bt_err("Can't attach new controller");
 		return -EBUSY;
 	}
 
 	session->num = session->ctrl.cnr;
 
-	BT_DBG("session %p num %d", session, session->num);
+	bt_dbg("session %p num %d", session, session->num);
 
 	capimsg_setu32(buf, 0, 1);
 
@@ -617,7 +617,7 @@ int cmtp_attach_device(struct cmtp_session *session)
 
 void cmtp_detach_device(struct cmtp_session *session)
 {
-	BT_DBG("session %p", session);
+	bt_dbg("session %p", session);
 
 	detach_capi_ctr(&session->ctrl);
 }
diff --git a/net/bluetooth/cmtp/core.c b/net/bluetooth/cmtp/core.c
index c5b11af..12062af 100644
--- a/net/bluetooth/cmtp/core.c
+++ b/net/bluetooth/cmtp/core.c
@@ -55,7 +55,7 @@ static struct cmtp_session *__cmtp_get_session(bdaddr_t *bdaddr)
 	struct cmtp_session *session;
 	struct list_head *p;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	list_for_each(p, &cmtp_session_list) {
 		session = list_entry(p, struct cmtp_session, list);
@@ -112,13 +112,13 @@ static inline void cmtp_add_msgpart(struct cmtp_session *session, int id, const
 	struct sk_buff *skb = session->reassembly[id], *nskb;
 	int size;
 
-	BT_DBG("session %p buf %p count %d", session, buf, count);
+	bt_dbg("session %p buf %p count %d", session, buf, count);
 
 	size = (skb) ? skb->len + count : count;
 
 	nskb = alloc_skb(size, GFP_ATOMIC);
 	if (!nskb) {
-		BT_ERR("Can't allocate memory for CAPI message");
+		bt_err("Can't allocate memory for CAPI message");
 		return;
 	}
 
@@ -137,7 +137,7 @@ static inline int cmtp_recv_frame(struct cmtp_session *session, struct sk_buff *
 	__u8 hdr, hdrlen, id;
 	__u16 len;
 
-	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+	bt_dbg("session %p skb %p len %d", session, skb, skb->len);
 
 	while (skb->len > 0) {
 		hdr = skb->data[0];
@@ -159,10 +159,10 @@ static inline int cmtp_recv_frame(struct cmtp_session *session, struct sk_buff *
 
 		id = (hdr & 0x3c) >> 2;
 
-		BT_DBG("hdr 0x%02x hdrlen %d len %d id %d", hdr, hdrlen, len, id);
+		bt_dbg("hdr 0x%02x hdrlen %d len %d id %d", hdr, hdrlen, len, id);
 
 		if (hdrlen + len > skb->len) {
-			BT_ERR("Wrong size or header information in CMTP frame");
+			bt_err("Wrong size or header information in CMTP frame");
 			break;
 		}
 
@@ -200,7 +200,7 @@ static int cmtp_send_frame(struct cmtp_session *session, unsigned char *data, in
 	struct kvec iv = { data, len };
 	struct msghdr msg;
 
-	BT_DBG("session %p data %p len %d", session, data, len);
+	bt_dbg("session %p data %p len %d", session, data, len);
 
 	if (!len)
 		return 0;
@@ -216,11 +216,11 @@ static void cmtp_process_transmit(struct cmtp_session *session)
 	unsigned char *hdr;
 	unsigned int size, tail;
 
-	BT_DBG("session %p", session);
+	bt_dbg("session %p", session);
 
 	nskb = alloc_skb(session->mtu, GFP_ATOMIC);
 	if (!nskb) {
-		BT_ERR("Can't allocate memory for new frame");
+		bt_err("Can't allocate memory for new frame");
 		return;
 	}
 
@@ -286,7 +286,7 @@ static int cmtp_session(void *arg)
 	struct sk_buff *skb;
 	wait_queue_t wait;
 
-	BT_DBG("session %p", session);
+	bt_dbg("session %p", session);
 
 	set_user_nice(current, -15);
 
@@ -330,7 +330,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
 	struct cmtp_session *session, *s;
 	int i, err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL);
 	if (!session)
@@ -349,7 +349,7 @@ int cmtp_add_connection(struct cmtp_connadd_req *req, struct socket *sock)
 	session->mtu = min_t(uint, l2cap_pi(sock->sk)->chan->omtu,
 					l2cap_pi(sock->sk)->chan->imtu);
 
-	BT_DBG("mtu %d", session->mtu);
+	bt_dbg("mtu %d", session->mtu);
 
 	sprintf(session->name, "%s", batostr(&bt_sk(sock->sk)->dst));
 
@@ -404,7 +404,7 @@ int cmtp_del_connection(struct cmtp_conndel_req *req)
 	struct cmtp_session *session;
 	int err = 0;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	down_read(&cmtp_session_sem);
 
@@ -427,7 +427,7 @@ int cmtp_get_connlist(struct cmtp_connlist_req *req)
 	struct list_head *p;
 	int err = 0, n = 0;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	down_read(&cmtp_session_sem);
 
@@ -475,7 +475,7 @@ int cmtp_get_conninfo(struct cmtp_conninfo *ci)
 
 static int __init cmtp_init(void)
 {
-	BT_INFO("CMTP (CAPI Emulation) ver %s", VERSION);
+	bt_info("CMTP (CAPI Emulation) ver %s", VERSION);
 
 	cmtp_init_sockets();
 
diff --git a/net/bluetooth/cmtp/sock.c b/net/bluetooth/cmtp/sock.c
index 3f2dd5c..e5b9356 100644
--- a/net/bluetooth/cmtp/sock.c
+++ b/net/bluetooth/cmtp/sock.c
@@ -47,7 +47,7 @@ static int cmtp_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	BT_DBG("sock %p sk %p", sock, sk);
+	bt_dbg("sock %p sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -68,7 +68,7 @@ static int cmtp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
 	void __user *argp = (void __user *)arg;
 	int err;
 
-	BT_DBG("cmd %x arg %lx", cmd, arg);
+	bt_dbg("cmd %x arg %lx", cmd, arg);
 
 	switch (cmd) {
 	case CMTPCONNADD:
@@ -195,7 +195,7 @@ static int cmtp_sock_create(struct net *net, struct socket *sock, int protocol,
 {
 	struct sock *sk;
 
-	BT_DBG("sock %p", sock);
+	bt_dbg("sock %p", sock);
 
 	if (sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
@@ -239,7 +239,7 @@ int cmtp_init_sockets(void)
 	return 0;
 
 error:
-	BT_ERR("Can't register CMTP socket");
+	bt_err("Can't register CMTP socket");
 	proto_unregister(&cmtp_proto);
 	return err;
 }
@@ -247,7 +247,7 @@ error:
 void cmtp_cleanup_sockets(void)
 {
 	if (bt_sock_unregister(BTPROTO_CMTP) < 0)
-		BT_ERR("Can't unregister CMTP socket");
+		bt_err("Can't unregister CMTP socket");
 
 	proto_unregister(&cmtp_proto);
 }
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index fa48c0b..942d647 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -80,7 +80,7 @@ void hci_acl_connect(struct hci_conn *conn)
 	struct inquiry_entry *ie;
 	struct hci_cp_create_conn cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	conn->state = BT_CONNECT;
 	conn->out = 1;
@@ -121,7 +121,7 @@ static void hci_acl_connect_cancel(struct hci_conn *conn)
 {
 	struct hci_cp_create_conn_cancel cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	if (conn->hdev->hci_ver < 2)
 		return;
@@ -134,7 +134,7 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
 {
 	struct hci_cp_disconnect cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	conn->state = BT_DISCONN;
 
@@ -148,7 +148,7 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle)
 	struct hci_dev *hdev = conn->hdev;
 	struct hci_cp_add_sco cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	conn->state = BT_CONNECT;
 	conn->out = 1;
@@ -166,7 +166,7 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
 	struct hci_dev *hdev = conn->hdev;
 	struct hci_cp_setup_sync_conn cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	conn->state = BT_CONNECT;
 	conn->out = 1;
@@ -211,7 +211,7 @@ void hci_le_start_enc(struct hci_conn *conn, __le16 ediv, __u8 rand[8],
 	struct hci_dev *hdev = conn->hdev;
 	struct hci_cp_le_start_enc cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	memset(&cp, 0, sizeof(cp));
 
@@ -229,7 +229,7 @@ void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16])
 	struct hci_dev *hdev = conn->hdev;
 	struct hci_cp_le_ltk_reply cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	memset(&cp, 0, sizeof(cp));
 
@@ -245,7 +245,7 @@ void hci_le_ltk_neg_reply(struct hci_conn *conn)
 	struct hci_dev *hdev = conn->hdev;
 	struct hci_cp_le_ltk_neg_reply cp;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	memset(&cp, 0, sizeof(cp));
 
@@ -259,7 +259,7 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
 {
 	struct hci_conn *sco = conn->link;
 
-	BT_DBG("%p", conn);
+	bt_dbg("%p", conn);
 
 	if (!sco)
 		return;
@@ -281,7 +281,7 @@ static void hci_conn_timeout(unsigned long arg)
 	struct hci_dev *hdev = conn->hdev;
 	__u8 reason;
 
-	BT_DBG("conn %p state %d", conn, conn->state);
+	bt_dbg("conn %p state %d", conn, conn->state);
 
 	if (atomic_read(&conn->refcnt))
 		return;
@@ -315,7 +315,7 @@ static void hci_conn_idle(unsigned long arg)
 {
 	struct hci_conn *conn = (void *) arg;
 
-	BT_DBG("conn %p mode %d", conn, conn->mode);
+	bt_dbg("conn %p mode %d", conn, conn->mode);
 
 	hci_conn_enter_sniff_mode(conn);
 }
@@ -337,7 +337,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst)
 {
 	struct hci_conn *conn;
 
-	BT_DBG("%s dst %s", hdev->name, batostr(dst));
+	bt_dbg("%s dst %s", hdev->name, batostr(dst));
 
 	conn = kzalloc(sizeof(struct hci_conn), GFP_ATOMIC);
 	if (!conn)
@@ -402,7 +402,7 @@ int hci_conn_del(struct hci_conn *conn)
 {
 	struct hci_dev *hdev = conn->hdev;
 
-	BT_DBG("%s conn %p handle %d", hdev->name, conn, conn->handle);
+	bt_dbg("%s conn %p handle %d", hdev->name, conn, conn->handle);
 
 	del_timer(&conn->idle_timer);
 
@@ -453,7 +453,7 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
 	struct hci_dev *hdev = NULL;
 	struct list_head *p;
 
-	BT_DBG("%s -> %s", batostr(src), batostr(dst));
+	bt_dbg("%s -> %s", batostr(src), batostr(dst));
 
 	read_lock_bh(&hci_dev_list_lock);
 
@@ -495,7 +495,7 @@ struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8
 	struct hci_conn *sco;
 	struct hci_conn *le;
 
-	BT_DBG("%s dst %s", hdev->name, batostr(dst));
+	bt_dbg("%s dst %s", hdev->name, batostr(dst));
 
 	if (type == LE_LINK) {
 		struct adv_entry *entry;
@@ -575,7 +575,7 @@ EXPORT_SYMBOL(hci_connect);
 /* Check link security requirement */
 int hci_conn_check_link_mode(struct hci_conn *conn)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (conn->ssp_mode > 0 && conn->hdev->ssp_mode > 0 &&
 					!(conn->link_mode & HCI_LM_ENCRYPT))
@@ -588,7 +588,7 @@ EXPORT_SYMBOL(hci_conn_check_link_mode);
 /* Authenticate remote device */
 static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (conn->pending_sec_level > sec_level)
 		sec_level = conn->pending_sec_level;
@@ -618,7 +618,7 @@ static int hci_conn_auth(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
 /* Encrypt the the link */
 static void hci_conn_encrypt(struct hci_conn *conn)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (!test_and_set_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
 		struct hci_cp_set_conn_encrypt cp;
@@ -632,7 +632,7 @@ static void hci_conn_encrypt(struct hci_conn *conn)
 /* Enable security */
 int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	/* For sdp we don't need the link key. */
 	if (sec_level == BT_SECURITY_SDP)
@@ -688,7 +688,7 @@ EXPORT_SYMBOL(hci_conn_security);
 /* Check secure link requirement */
 int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (sec_level != BT_SECURITY_HIGH)
 		return 1; /* Accept if non-secure is required */
@@ -703,7 +703,7 @@ EXPORT_SYMBOL(hci_conn_check_secure);
 /* Change link key */
 int hci_conn_change_link_key(struct hci_conn *conn)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
 		struct hci_cp_change_conn_link_key cp;
@@ -719,7 +719,7 @@ EXPORT_SYMBOL(hci_conn_change_link_key);
 /* Switch role */
 int hci_conn_switch_role(struct hci_conn *conn, __u8 role)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (!role && conn->link_mode & HCI_LM_MASTER)
 		return 1;
@@ -740,7 +740,7 @@ void hci_conn_enter_active_mode(struct hci_conn *conn, __u8 force_active)
 {
 	struct hci_dev *hdev = conn->hdev;
 
-	BT_DBG("conn %p mode %d", conn, conn->mode);
+	bt_dbg("conn %p mode %d", conn, conn->mode);
 
 	if (test_bit(HCI_RAW, &hdev->flags))
 		return;
@@ -768,7 +768,7 @@ void hci_conn_enter_sniff_mode(struct hci_conn *conn)
 {
 	struct hci_dev *hdev = conn->hdev;
 
-	BT_DBG("conn %p mode %d", conn, conn->mode);
+	bt_dbg("conn %p mode %d", conn, conn->mode);
 
 	if (test_bit(HCI_RAW, &hdev->flags))
 		return;
@@ -805,7 +805,7 @@ void hci_conn_hash_flush(struct hci_dev *hdev)
 	struct hci_conn_hash *h = &hdev->conn_hash;
 	struct list_head *p;
 
-	BT_DBG("hdev %s", hdev->name);
+	bt_dbg("hdev %s", hdev->name);
 
 	p = h->list.next;
 	while (p != &h->list) {
@@ -826,7 +826,7 @@ void hci_conn_check_pending(struct hci_dev *hdev)
 {
 	struct hci_conn *conn;
 
-	BT_DBG("hdev %s", hdev->name);
+	bt_dbg("hdev %s", hdev->name);
 
 	hci_dev_lock(hdev);
 
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index ec34c5a..41254be 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -98,7 +98,7 @@ static void hci_notify(struct hci_dev *hdev, int event)
 
 void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result)
 {
-	BT_DBG("%s command 0x%04x result 0x%2.2x", hdev->name, cmd, result);
+	bt_dbg("%s command 0x%04x result 0x%2.2x", hdev->name, cmd, result);
 
 	/* If this is the init phase check if the completed command matches
 	 * the last init command, and if not just return.
@@ -115,7 +115,7 @@ void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result)
 
 static void hci_req_cancel(struct hci_dev *hdev, int err)
 {
-	BT_DBG("%s err 0x%2.2x", hdev->name, err);
+	bt_dbg("%s err 0x%2.2x", hdev->name, err);
 
 	if (hdev->req_status == HCI_REQ_PEND) {
 		hdev->req_result = err;
@@ -131,7 +131,7 @@ static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev,
 	DECLARE_WAITQUEUE(wait, current);
 	int err = 0;
 
-	BT_DBG("%s start", hdev->name);
+	bt_dbg("%s start", hdev->name);
 
 	hdev->req_status = HCI_REQ_PEND;
 
@@ -162,7 +162,7 @@ static int __hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *hdev,
 
 	hdev->req_status = hdev->req_result = 0;
 
-	BT_DBG("%s end: err %d", hdev->name, err);
+	bt_dbg("%s end: err %d", hdev->name, err);
 
 	return err;
 }
@@ -185,7 +185,7 @@ static inline int hci_request(struct hci_dev *hdev, void (*req)(struct hci_dev *
 
 static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
 {
-	BT_DBG("%s %ld", hdev->name, opt);
+	bt_dbg("%s %ld", hdev->name, opt);
 
 	/* Reset device */
 	set_bit(HCI_RESET, &hdev->flags);
@@ -199,7 +199,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
 	__le16 param;
 	__u8 flt_type;
 
-	BT_DBG("%s %ld", hdev->name, opt);
+	bt_dbg("%s %ld", hdev->name, opt);
 
 	/* Driver initialization */
 
@@ -271,7 +271,7 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
 
 static void hci_le_init_req(struct hci_dev *hdev, unsigned long opt)
 {
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	/* Read LE buffer size */
 	hci_send_cmd(hdev, HCI_OP_LE_READ_BUFFER_SIZE, 0, NULL);
@@ -281,7 +281,7 @@ static void hci_scan_req(struct hci_dev *hdev, unsigned long opt)
 {
 	__u8 scan = opt;
 
-	BT_DBG("%s %x", hdev->name, scan);
+	bt_dbg("%s %x", hdev->name, scan);
 
 	/* Inquiry and Page scans */
 	hci_send_cmd(hdev, HCI_OP_WRITE_SCAN_ENABLE, 1, &scan);
@@ -291,7 +291,7 @@ static void hci_auth_req(struct hci_dev *hdev, unsigned long opt)
 {
 	__u8 auth = opt;
 
-	BT_DBG("%s %x", hdev->name, auth);
+	bt_dbg("%s %x", hdev->name, auth);
 
 	/* Authentication */
 	hci_send_cmd(hdev, HCI_OP_WRITE_AUTH_ENABLE, 1, &auth);
@@ -301,7 +301,7 @@ static void hci_encrypt_req(struct hci_dev *hdev, unsigned long opt)
 {
 	__u8 encrypt = opt;
 
-	BT_DBG("%s %x", hdev->name, encrypt);
+	bt_dbg("%s %x", hdev->name, encrypt);
 
 	/* Encryption */
 	hci_send_cmd(hdev, HCI_OP_WRITE_ENCRYPT_MODE, 1, &encrypt);
@@ -311,7 +311,7 @@ static void hci_linkpol_req(struct hci_dev *hdev, unsigned long opt)
 {
 	__le16 policy = cpu_to_le16(opt);
 
-	BT_DBG("%s %x", hdev->name, policy);
+	bt_dbg("%s %x", hdev->name, policy);
 
 	/* Default link policy */
 	hci_send_cmd(hdev, HCI_OP_WRITE_DEF_LINK_POLICY, 2, &policy);
@@ -324,7 +324,7 @@ struct hci_dev *hci_dev_get(int index)
 	struct hci_dev *hdev = NULL;
 	struct list_head *p;
 
-	BT_DBG("%d", index);
+	bt_dbg("%d", index);
 
 	if (index < 0)
 		return NULL;
@@ -347,7 +347,7 @@ static void inquiry_cache_flush(struct hci_dev *hdev)
 	struct inquiry_cache *cache = &hdev->inq_cache;
 	struct inquiry_entry *next  = cache->list, *e;
 
-	BT_DBG("cache %p", cache);
+	bt_dbg("cache %p", cache);
 
 	cache->list = NULL;
 	while ((e = next)) {
@@ -361,7 +361,7 @@ struct inquiry_entry *hci_inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *b
 	struct inquiry_cache *cache = &hdev->inq_cache;
 	struct inquiry_entry *e;
 
-	BT_DBG("cache %p, %s", cache, batostr(bdaddr));
+	bt_dbg("cache %p, %s", cache, batostr(bdaddr));
 
 	for (e = cache->list; e; e = e->next)
 		if (!bacmp(&e->data.bdaddr, bdaddr))
@@ -374,7 +374,7 @@ void hci_inquiry_cache_update(struct hci_dev *hdev, struct inquiry_data *data)
 	struct inquiry_cache *cache = &hdev->inq_cache;
 	struct inquiry_entry *ie;
 
-	BT_DBG("cache %p, %s", cache, batostr(&data->bdaddr));
+	bt_dbg("cache %p, %s", cache, batostr(&data->bdaddr));
 
 	ie = hci_inquiry_cache_lookup(hdev, &data->bdaddr);
 	if (!ie) {
@@ -410,7 +410,7 @@ static int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
 		info++;
 	}
 
-	BT_DBG("cache %p, copied %d", cache, copied);
+	bt_dbg("cache %p, copied %d", cache, copied);
 	return copied;
 }
 
@@ -419,7 +419,7 @@ static void hci_inq_req(struct hci_dev *hdev, unsigned long opt)
 	struct hci_inquiry_req *ir = (struct hci_inquiry_req *) opt;
 	struct hci_cp_inquiry cp;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (test_bit(HCI_INQUIRY, &hdev->flags))
 		return;
@@ -480,7 +480,7 @@ int hci_inquiry(void __user *arg)
 	ir.num_rsp = inquiry_cache_dump(hdev, max_rsp, buf);
 	hci_dev_unlock_bh(hdev);
 
-	BT_DBG("num_rsp %d", ir.num_rsp);
+	bt_dbg("num_rsp %d", ir.num_rsp);
 
 	if (!copy_to_user(ptr, &ir, sizeof(ir))) {
 		ptr += sizeof(ir);
@@ -508,7 +508,7 @@ int hci_dev_open(__u16 dev)
 	if (!hdev)
 		return -ENODEV;
 
-	BT_DBG("%s %p", hdev->name, hdev);
+	bt_dbg("%s %p", hdev->name, hdev);
 
 	hci_req_lock(hdev);
 
@@ -584,7 +584,7 @@ done:
 
 static int hci_dev_do_close(struct hci_dev *hdev)
 {
-	BT_DBG("%s %p", hdev->name, hdev);
+	bt_dbg("%s %p", hdev->name, hdev);
 
 	hci_req_cancel(hdev, ENODEV);
 	hci_req_lock(hdev);
@@ -891,7 +891,7 @@ static int hci_rfkill_set_block(void *data, bool blocked)
 {
 	struct hci_dev *hdev = data;
 
-	BT_DBG("%p name %s blocked %d", hdev, hdev->name, blocked);
+	bt_dbg("%p name %s blocked %d", hdev, hdev->name, blocked);
 
 	if (!blocked)
 		return 0;
@@ -934,7 +934,7 @@ static void hci_power_on(struct work_struct *work)
 {
 	struct hci_dev *hdev = container_of(work, struct hci_dev, power_on);
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (hci_dev_open(hdev->id) < 0)
 		return;
@@ -951,7 +951,7 @@ static void hci_power_off(struct work_struct *work)
 {
 	struct hci_dev *hdev = container_of(work, struct hci_dev, power_off);
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_close(hdev->id);
 }
@@ -960,7 +960,7 @@ static void hci_auto_off(unsigned long data)
 {
 	struct hci_dev *hdev = (struct hci_dev *) data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	clear_bit(HCI_AUTO_OFF, &hdev->flags);
 
@@ -969,7 +969,7 @@ static void hci_auto_off(unsigned long data)
 
 void hci_del_off_timer(struct hci_dev *hdev)
 {
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	clear_bit(HCI_AUTO_OFF, &hdev->flags);
 	del_timer(&hdev->off_timer);
@@ -1077,7 +1077,7 @@ int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
 		list_add(&key->list, &hdev->link_keys);
 	}
 
-	BT_DBG("%s key for %s type %u", hdev->name, batostr(bdaddr), type);
+	bt_dbg("%s key for %s type %u", hdev->name, batostr(bdaddr), type);
 
 	/* Some buggy controller combinations generate a changed
 	 * combination key for legacy pairing even when there's no
@@ -1122,7 +1122,7 @@ int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr)
 	if (!key)
 		return -ENOENT;
 
-	BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+	bt_dbg("%s removing %s", hdev->name, batostr(bdaddr));
 
 	list_del(&key->list);
 	kfree(key);
@@ -1135,7 +1135,7 @@ static void hci_cmd_timer(unsigned long arg)
 {
 	struct hci_dev *hdev = (void *) arg;
 
-	BT_ERR("%s command tx timeout", hdev->name);
+	bt_err("%s command tx timeout", hdev->name);
 	atomic_set(&hdev->cmd_cnt, 1);
 	clear_bit(HCI_RESET, &hdev->flags);
 	tasklet_schedule(&hdev->cmd_task);
@@ -1161,7 +1161,7 @@ int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr)
 	if (!data)
 		return -ENOENT;
 
-	BT_DBG("%s removing %s", hdev->name, batostr(bdaddr));
+	bt_dbg("%s removing %s", hdev->name, batostr(bdaddr));
 
 	list_del(&data->list);
 	kfree(data);
@@ -1200,7 +1200,7 @@ int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
 	memcpy(data->hash, hash, sizeof(data->hash));
 	memcpy(data->randomizer, randomizer, sizeof(data->randomizer));
 
-	BT_DBG("%s for %s", hdev->name, batostr(bdaddr));
+	bt_dbg("%s for %s", hdev->name, batostr(bdaddr));
 
 	return 0;
 }
@@ -1316,7 +1316,7 @@ int hci_adv_entries_clear(struct hci_dev *hdev)
 		kfree(entry);
 	}
 
-	BT_DBG("%s adv cache cleared", hdev->name);
+	bt_dbg("%s adv cache cleared", hdev->name);
 
 	return 0;
 }
@@ -1362,7 +1362,7 @@ int hci_add_adv_entry(struct hci_dev *hdev,
 
 	list_add(&entry->list, &hdev->adv_entries);
 
-	BT_DBG("%s adv entry added: address %s type %u", hdev->name,
+	bt_dbg("%s adv entry added: address %s type %u", hdev->name,
 				batostr(&entry->bdaddr), entry->bdaddr_type);
 
 	return 0;
@@ -1382,7 +1382,7 @@ int hci_register_dev(struct hci_dev *hdev)
 	struct list_head *head = &hci_dev_list, *p;
 	int i, id = 0;
 
-	BT_DBG("%p name %s bus %d owner %p", hdev, hdev->name,
+	bt_dbg("%p name %s bus %d owner %p", hdev, hdev->name,
 						hdev->bus, hdev->owner);
 
 	if (!hdev->open || !hdev->close || !hdev->destruct)
@@ -1462,7 +1462,7 @@ int hci_register_dev(struct hci_dev *hdev)
 
 	hdev->tfm = alloc_cypher();
 	if (IS_ERR(hdev->tfm))
-		BT_INFO("Failed to load transform for ecb(aes): %ld",
+		bt_info("Failed to load transform for ecb(aes): %ld",
 							PTR_ERR(hdev->tfm));
 
 	hci_register_sysfs(hdev);
@@ -1498,7 +1498,7 @@ int hci_unregister_dev(struct hci_dev *hdev)
 {
 	int i;
 
-	BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
+	bt_dbg("%p name %s bus %d", hdev, hdev->name, hdev->bus);
 
 	write_lock_bh(&hci_dev_list_lock);
 	list_del(&hdev->list);
@@ -1756,7 +1756,7 @@ int hci_register_proto(struct hci_proto *hp)
 {
 	int err = 0;
 
-	BT_DBG("%p name %s id %d", hp, hp->name, hp->id);
+	bt_dbg("%p name %s id %d", hp, hp->name, hp->id);
 
 	if (hp->id >= HCI_MAX_PROTO)
 		return -EINVAL;
@@ -1778,7 +1778,7 @@ int hci_unregister_proto(struct hci_proto *hp)
 {
 	int err = 0;
 
-	BT_DBG("%p name %s id %d", hp, hp->name, hp->id);
+	bt_dbg("%p name %s id %d", hp, hp->name, hp->id);
 
 	if (hp->id >= HCI_MAX_PROTO)
 		return -EINVAL;
@@ -1798,7 +1798,7 @@ EXPORT_SYMBOL(hci_unregister_proto);
 
 int hci_register_cb(struct hci_cb *cb)
 {
-	BT_DBG("%p name %s", cb, cb->name);
+	bt_dbg("%p name %s", cb, cb->name);
 
 	write_lock_bh(&hci_cb_list_lock);
 	list_add(&cb->list, &hci_cb_list);
@@ -1810,7 +1810,7 @@ EXPORT_SYMBOL(hci_register_cb);
 
 int hci_unregister_cb(struct hci_cb *cb)
 {
-	BT_DBG("%p name %s", cb, cb->name);
+	bt_dbg("%p name %s", cb, cb->name);
 
 	write_lock_bh(&hci_cb_list_lock);
 	list_del(&cb->list);
@@ -1829,7 +1829,7 @@ static int hci_send_frame(struct sk_buff *skb)
 		return -ENODEV;
 	}
 
-	BT_DBG("%s type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
+	bt_dbg("%s type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
 
 	if (atomic_read(&hdev->promisc)) {
 		/* Time stamp */
@@ -1851,11 +1851,11 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)
 	struct hci_command_hdr *hdr;
 	struct sk_buff *skb;
 
-	BT_DBG("%s opcode 0x%x plen %d", hdev->name, opcode, plen);
+	bt_dbg("%s opcode 0x%x plen %d", hdev->name, opcode, plen);
 
 	skb = bt_skb_alloc(len, GFP_ATOMIC);
 	if (!skb) {
-		BT_ERR("%s no memory for command", hdev->name);
+		bt_err("%s no memory for command", hdev->name);
 		return -ENOMEM;
 	}
 
@@ -1866,7 +1866,7 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 opcode, __u32 plen, void *param)
 	if (plen)
 		memcpy(skb_put(skb, plen), param, plen);
 
-	BT_DBG("skb len %d", skb->len);
+	bt_dbg("skb len %d", skb->len);
 
 	bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
 	skb->dev = (void *) hdev;
@@ -1893,7 +1893,7 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 opcode)
 	if (hdr->opcode != cpu_to_le16(opcode))
 		return NULL;
 
-	BT_DBG("%s opcode 0x%x", hdev->name, opcode);
+	bt_dbg("%s opcode 0x%x", hdev->name, opcode);
 
 	return hdev->sent_cmd->data + HCI_COMMAND_HDR_SIZE;
 }
@@ -1916,7 +1916,7 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
 	struct hci_dev *hdev = conn->hdev;
 	struct sk_buff *list;
 
-	BT_DBG("%s conn %p flags 0x%x", hdev->name, conn, flags);
+	bt_dbg("%s conn %p flags 0x%x", hdev->name, conn, flags);
 
 	skb->dev = (void *) hdev;
 	bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
@@ -1925,12 +1925,12 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
 	list = skb_shinfo(skb)->frag_list;
 	if (!list) {
 		/* Non fragmented */
-		BT_DBG("%s nonfrag skb %p len %d", hdev->name, skb, skb->len);
+		bt_dbg("%s nonfrag skb %p len %d", hdev->name, skb, skb->len);
 
 		skb_queue_tail(&conn->data_q, skb);
 	} else {
 		/* Fragmented */
-		BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len);
+		bt_dbg("%s frag %p len %d", hdev->name, skb, skb->len);
 
 		skb_shinfo(skb)->frag_list = NULL;
 
@@ -1948,7 +1948,7 @@ void hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
 			bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
 			hci_add_acl_hdr(skb, conn->handle, flags);
 
-			BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len);
+			bt_dbg("%s frag %p len %d", hdev->name, skb, skb->len);
 
 			__skb_queue_tail(&conn->data_q, skb);
 		} while (list);
@@ -1966,7 +1966,7 @@ void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
 	struct hci_dev *hdev = conn->hdev;
 	struct hci_sco_hdr hdr;
 
-	BT_DBG("%s len %d", hdev->name, skb->len);
+	bt_dbg("%s len %d", hdev->name, skb->len);
 
 	hdr.handle = cpu_to_le16(conn->handle);
 	hdr.dlen   = skb->len;
@@ -2029,7 +2029,7 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
 			break;
 		default:
 			cnt = 0;
-			BT_ERR("Unknown link type");
+			bt_err("Unknown link type");
 		}
 
 		q = cnt / num;
@@ -2037,7 +2037,7 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
 	} else
 		*quote = 0;
 
-	BT_DBG("conn %p quote %d", conn, *quote);
+	bt_dbg("conn %p quote %d", conn, *quote);
 	return conn;
 }
 
@@ -2047,13 +2047,13 @@ static inline void hci_link_tx_to(struct hci_dev *hdev, __u8 type)
 	struct list_head *p;
 	struct hci_conn  *c;
 
-	BT_ERR("%s link tx timeout", hdev->name);
+	bt_err("%s link tx timeout", hdev->name);
 
 	/* Kill stalled connections */
 	list_for_each(p, &h->list) {
 		c = list_entry(p, struct hci_conn, list);
 		if (c->type == type && c->sent) {
-			BT_ERR("%s killing stalled connection %s",
+			bt_err("%s killing stalled connection %s",
 				hdev->name, batostr(&c->dst));
 			hci_acl_disconn(c, 0x13);
 		}
@@ -2066,7 +2066,7 @@ static inline void hci_sched_acl(struct hci_dev *hdev)
 	struct sk_buff *skb;
 	int quote;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_bit(HCI_RAW, &hdev->flags)) {
 		/* ACL tx timeout must be longer than maximum
@@ -2077,7 +2077,7 @@ static inline void hci_sched_acl(struct hci_dev *hdev)
 
 	while (hdev->acl_cnt && (conn = hci_low_sent(hdev, ACL_LINK, &quote))) {
 		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
-			BT_DBG("skb %p len %d", skb, skb->len);
+			bt_dbg("skb %p len %d", skb, skb->len);
 
 			hci_conn_enter_active_mode(conn, bt_cb(skb)->force_active);
 
@@ -2097,11 +2097,11 @@ static inline void hci_sched_sco(struct hci_dev *hdev)
 	struct sk_buff *skb;
 	int quote;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	while (hdev->sco_cnt && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) {
 		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
-			BT_DBG("skb %p len %d", skb, skb->len);
+			bt_dbg("skb %p len %d", skb, skb->len);
 			hci_send_frame(skb);
 
 			conn->sent++;
@@ -2117,11 +2117,11 @@ static inline void hci_sched_esco(struct hci_dev *hdev)
 	struct sk_buff *skb;
 	int quote;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	while (hdev->sco_cnt && (conn = hci_low_sent(hdev, ESCO_LINK, &quote))) {
 		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
-			BT_DBG("skb %p len %d", skb, skb->len);
+			bt_dbg("skb %p len %d", skb, skb->len);
 			hci_send_frame(skb);
 
 			conn->sent++;
@@ -2137,7 +2137,7 @@ static inline void hci_sched_le(struct hci_dev *hdev)
 	struct sk_buff *skb;
 	int quote, cnt;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_bit(HCI_RAW, &hdev->flags)) {
 		/* LE tx timeout must be longer than maximum
@@ -2150,7 +2150,7 @@ static inline void hci_sched_le(struct hci_dev *hdev)
 	cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
 	while (cnt && (conn = hci_low_sent(hdev, LE_LINK, &quote))) {
 		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
-			BT_DBG("skb %p len %d", skb, skb->len);
+			bt_dbg("skb %p len %d", skb, skb->len);
 
 			hci_send_frame(skb);
 			hdev->le_last_tx = jiffies;
@@ -2172,7 +2172,7 @@ static void hci_tx_task(unsigned long arg)
 
 	read_lock(&hci_task_lock);
 
-	BT_DBG("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt,
+	bt_dbg("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt,
 		hdev->sco_cnt, hdev->le_cnt);
 
 	/* Schedule queues and send stuff to HCI driver */
@@ -2207,7 +2207,7 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 	flags  = hci_flags(handle);
 	handle = hci_handle(handle);
 
-	BT_DBG("%s len %d handle 0x%x flags 0x%x", hdev->name, skb->len, handle, flags);
+	bt_dbg("%s len %d handle 0x%x flags 0x%x", hdev->name, skb->len, handle, flags);
 
 	hdev->stat.acl_rx++;
 
@@ -2227,7 +2227,7 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 			return;
 		}
 	} else {
-		BT_ERR("%s ACL packet for unknown connection handle %d",
+		bt_err("%s ACL packet for unknown connection handle %d",
 			hdev->name, handle);
 	}
 
@@ -2245,7 +2245,7 @@ static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 
 	handle = __le16_to_cpu(hdr->handle);
 
-	BT_DBG("%s len %d handle 0x%x", hdev->name, skb->len, handle);
+	bt_dbg("%s len %d handle 0x%x", hdev->name, skb->len, handle);
 
 	hdev->stat.sco_rx++;
 
@@ -2263,7 +2263,7 @@ static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
 			return;
 		}
 	} else {
-		BT_ERR("%s SCO packet for unknown connection handle %d",
+		bt_err("%s SCO packet for unknown connection handle %d",
 			hdev->name, handle);
 	}
 
@@ -2275,7 +2275,7 @@ static void hci_rx_task(unsigned long arg)
 	struct hci_dev *hdev = (struct hci_dev *) arg;
 	struct sk_buff *skb;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	read_lock(&hci_task_lock);
 
@@ -2307,12 +2307,12 @@ static void hci_rx_task(unsigned long arg)
 			break;
 
 		case HCI_ACLDATA_PKT:
-			BT_DBG("%s ACL data packet", hdev->name);
+			bt_dbg("%s ACL data packet", hdev->name);
 			hci_acldata_packet(hdev, skb);
 			break;
 
 		case HCI_SCODATA_PKT:
-			BT_DBG("%s SCO data packet", hdev->name);
+			bt_dbg("%s SCO data packet", hdev->name);
 			hci_scodata_packet(hdev, skb);
 			break;
 
@@ -2330,7 +2330,7 @@ static void hci_cmd_task(unsigned long arg)
 	struct hci_dev *hdev = (struct hci_dev *) arg;
 	struct sk_buff *skb;
 
-	BT_DBG("%s cmd %d", hdev->name, atomic_read(&hdev->cmd_cnt));
+	bt_dbg("%s cmd %d", hdev->name, atomic_read(&hdev->cmd_cnt));
 
 	/* Send queued commands */
 	if (atomic_read(&hdev->cmd_cnt)) {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index ac2c5e8..1df9dd3 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -51,7 +51,7 @@ static void hci_cc_inquiry_cancel(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (status)
 		return;
@@ -69,7 +69,7 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (status)
 		return;
@@ -83,7 +83,7 @@ static void hci_cc_exit_periodic_inq(struct hci_dev *hdev, struct sk_buff *skb)
 
 static void hci_cc_remote_name_req_cancel(struct hci_dev *hdev, struct sk_buff *skb)
 {
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 }
 
 static void hci_cc_role_discovery(struct hci_dev *hdev, struct sk_buff *skb)
@@ -91,7 +91,7 @@ static void hci_cc_role_discovery(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_rp_role_discovery *rp = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -114,7 +114,7 @@ static void hci_cc_read_link_policy(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_rp_read_link_policy *rp = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -134,7 +134,7 @@ static void hci_cc_write_link_policy(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_conn *conn;
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -156,7 +156,7 @@ static void hci_cc_read_def_link_policy(struct hci_dev *hdev, struct sk_buff *sk
 {
 	struct hci_rp_read_def_link_policy *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -169,7 +169,7 @@ static void hci_cc_write_def_link_policy(struct hci_dev *hdev, struct sk_buff *s
 	__u8 status = *((__u8 *) skb->data);
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_DEF_LINK_POLICY);
 	if (!sent)
@@ -185,7 +185,7 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	clear_bit(HCI_RESET, &hdev->flags);
 
@@ -197,7 +197,7 @@ static void hci_cc_write_local_name(struct hci_dev *hdev, struct sk_buff *skb)
 	__u8 status = *((__u8 *) skb->data);
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_LOCAL_NAME);
 	if (!sent)
@@ -216,7 +216,7 @@ static void hci_cc_read_local_name(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_read_local_name *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -229,7 +229,7 @@ static void hci_cc_write_auth_enable(struct hci_dev *hdev, struct sk_buff *skb)
 	__u8 status = *((__u8 *) skb->data);
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_AUTH_ENABLE);
 	if (!sent)
@@ -252,7 +252,7 @@ static void hci_cc_write_encrypt_mode(struct hci_dev *hdev, struct sk_buff *skb)
 	__u8 status = *((__u8 *) skb->data);
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_ENCRYPT_MODE);
 	if (!sent)
@@ -275,7 +275,7 @@ static void hci_cc_write_scan_enable(struct hci_dev *hdev, struct sk_buff *skb)
 	__u8 status = *((__u8 *) skb->data);
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	sent = hci_sent_cmd_data(hdev, HCI_OP_WRITE_SCAN_ENABLE);
 	if (!sent)
@@ -310,14 +310,14 @@ static void hci_cc_read_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_read_class_of_dev *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
 
 	memcpy(hdev->dev_class, rp->dev_class, 3);
 
-	BT_DBG("%s class 0x%.2x%.2x%.2x", hdev->name,
+	bt_dbg("%s class 0x%.2x%.2x%.2x", hdev->name,
 		hdev->dev_class[2], hdev->dev_class[1], hdev->dev_class[0]);
 }
 
@@ -326,7 +326,7 @@ static void hci_cc_write_class_of_dev(struct hci_dev *hdev, struct sk_buff *skb)
 	__u8 status = *((__u8 *) skb->data);
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (status)
 		return;
@@ -343,7 +343,7 @@ static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_rp_read_voice_setting *rp = (void *) skb->data;
 	__u16 setting;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -355,7 +355,7 @@ static void hci_cc_read_voice_setting(struct hci_dev *hdev, struct sk_buff *skb)
 
 	hdev->voice_setting = setting;
 
-	BT_DBG("%s voice setting 0x%04x", hdev->name, setting);
+	bt_dbg("%s voice setting 0x%04x", hdev->name, setting);
 
 	if (hdev->notify) {
 		tasklet_disable(&hdev->tx_task);
@@ -370,7 +370,7 @@ static void hci_cc_write_voice_setting(struct hci_dev *hdev, struct sk_buff *skb
 	__u16 setting;
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (status)
 		return;
@@ -386,7 +386,7 @@ static void hci_cc_write_voice_setting(struct hci_dev *hdev, struct sk_buff *skb
 
 	hdev->voice_setting = setting;
 
-	BT_DBG("%s voice setting 0x%04x", hdev->name, setting);
+	bt_dbg("%s voice setting 0x%04x", hdev->name, setting);
 
 	if (hdev->notify) {
 		tasklet_disable(&hdev->tx_task);
@@ -399,7 +399,7 @@ static void hci_cc_host_buffer_size(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	hci_req_complete(hdev, HCI_OP_HOST_BUFFER_SIZE, status);
 }
@@ -408,7 +408,7 @@ static void hci_cc_read_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_read_ssp_mode *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -421,7 +421,7 @@ static void hci_cc_write_ssp_mode(struct hci_dev *hdev, struct sk_buff *skb)
 	__u8 status = *((__u8 *) skb->data);
 	void *sent;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (status)
 		return;
@@ -548,7 +548,7 @@ static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_read_local_version *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -559,7 +559,7 @@ static void hci_cc_read_local_version(struct hci_dev *hdev, struct sk_buff *skb)
 	hdev->manufacturer = __le16_to_cpu(rp->manufacturer);
 	hdev->lmp_subver = __le16_to_cpu(rp->lmp_subver);
 
-	BT_DBG("%s manufacturer %d hci ver %d:%d", hdev->name,
+	bt_dbg("%s manufacturer %d hci ver %d:%d", hdev->name,
 					hdev->manufacturer,
 					hdev->hci_ver, hdev->hci_rev);
 
@@ -589,7 +589,7 @@ static void hci_cc_read_local_commands(struct hci_dev *hdev, struct sk_buff *skb
 {
 	struct hci_rp_read_local_commands *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		goto done;
@@ -607,7 +607,7 @@ static void hci_cc_read_local_features(struct hci_dev *hdev, struct sk_buff *skb
 {
 	struct hci_rp_read_local_features *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -651,7 +651,7 @@ static void hci_cc_read_local_features(struct hci_dev *hdev, struct sk_buff *skb
 	if (hdev->features[5] & LMP_EDR_3S_ESCO)
 		hdev->esco_type |= (ESCO_2EV5 | ESCO_3EV5);
 
-	BT_DBG("%s features 0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", hdev->name,
+	bt_dbg("%s features 0x%.2x%.2x%.2x%.2x%.2x%.2x%.2x%.2x", hdev->name,
 					hdev->features[0], hdev->features[1],
 					hdev->features[2], hdev->features[3],
 					hdev->features[4], hdev->features[5],
@@ -662,7 +662,7 @@ static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_read_buffer_size *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -680,7 +680,7 @@ static void hci_cc_read_buffer_size(struct hci_dev *hdev, struct sk_buff *skb)
 	hdev->acl_cnt = hdev->acl_pkts;
 	hdev->sco_cnt = hdev->sco_pkts;
 
-	BT_DBG("%s acl mtu %d:%d sco mtu %d:%d", hdev->name,
+	bt_dbg("%s acl mtu %d:%d sco mtu %d:%d", hdev->name,
 					hdev->acl_mtu, hdev->acl_pkts,
 					hdev->sco_mtu, hdev->sco_pkts);
 }
@@ -689,7 +689,7 @@ static void hci_cc_read_bd_addr(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_read_bd_addr *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (!rp->status)
 		bacpy(&hdev->bdaddr, &rp->bdaddr);
@@ -701,7 +701,7 @@ static void hci_cc_write_ca_timeout(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	hci_req_complete(hdev, HCI_OP_WRITE_CA_TIMEOUT, status);
 }
@@ -711,7 +711,7 @@ static void hci_cc_delete_stored_link_key(struct hci_dev *hdev,
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	hci_req_complete(hdev, HCI_OP_DELETE_STORED_LINK_KEY, status);
 }
@@ -720,7 +720,7 @@ static void hci_cc_set_event_mask(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	hci_req_complete(hdev, HCI_OP_SET_EVENT_MASK, status);
 }
@@ -730,7 +730,7 @@ static void hci_cc_write_inquiry_mode(struct hci_dev *hdev,
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	hci_req_complete(hdev, HCI_OP_WRITE_INQUIRY_MODE, status);
 }
@@ -740,7 +740,7 @@ static void hci_cc_read_inq_rsp_tx_power(struct hci_dev *hdev,
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	hci_req_complete(hdev, HCI_OP_READ_INQ_RSP_TX_POWER, status);
 }
@@ -749,7 +749,7 @@ static void hci_cc_set_event_flt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	hci_req_complete(hdev, HCI_OP_SET_EVENT_FLT, status);
 }
@@ -760,7 +760,7 @@ static void hci_cc_pin_code_reply(struct hci_dev *hdev, struct sk_buff *skb)
 	struct hci_cp_pin_code_reply *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (test_bit(HCI_MGMT, &hdev->flags))
 		mgmt_pin_code_reply_complete(hdev->id, &rp->bdaddr, rp->status);
@@ -781,7 +781,7 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_pin_code_neg_reply *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (test_bit(HCI_MGMT, &hdev->flags))
 		mgmt_pin_code_neg_reply_complete(hdev->id, &rp->bdaddr,
@@ -792,7 +792,7 @@ static void hci_cc_le_read_buffer_size(struct hci_dev *hdev,
 {
 	struct hci_rp_le_read_buffer_size *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -802,7 +802,7 @@ static void hci_cc_le_read_buffer_size(struct hci_dev *hdev,
 
 	hdev->le_cnt = hdev->le_pkts;
 
-	BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts);
+	bt_dbg("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts);
 
 	hci_req_complete(hdev, HCI_OP_LE_READ_BUFFER_SIZE, rp->status);
 }
@@ -811,7 +811,7 @@ static void hci_cc_user_confirm_reply(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (test_bit(HCI_MGMT, &hdev->flags))
 		mgmt_user_confirm_reply_complete(hdev->id, &rp->bdaddr,
@@ -823,7 +823,7 @@ static void hci_cc_user_confirm_neg_reply(struct hci_dev *hdev,
 {
 	struct hci_rp_user_confirm_reply *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (test_bit(HCI_MGMT, &hdev->flags))
 		mgmt_user_confirm_neg_reply_complete(hdev->id, &rp->bdaddr,
@@ -835,7 +835,7 @@ static void hci_cc_read_local_oob_data_reply(struct hci_dev *hdev,
 {
 	struct hci_rp_read_local_oob_data *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	mgmt_read_local_oob_data_reply_complete(hdev->id, rp->hash,
 						rp->randomizer, rp->status);
@@ -847,7 +847,7 @@ static void hci_cc_le_set_scan_enable(struct hci_dev *hdev,
 	struct hci_cp_le_set_scan_enable *cp;
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (status)
 		return;
@@ -872,7 +872,7 @@ static void hci_cc_le_ltk_reply(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_le_ltk_reply *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -884,7 +884,7 @@ static void hci_cc_le_ltk_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_rp_le_ltk_neg_reply *rp = (void *) skb->data;
 
-	BT_DBG("%s status 0x%x", hdev->name, rp->status);
+	bt_dbg("%s status 0x%x", hdev->name, rp->status);
 
 	if (rp->status)
 		return;
@@ -894,7 +894,7 @@ static void hci_cc_le_ltk_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
 
 static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
 {
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (status) {
 		hci_req_complete(hdev, HCI_OP_INQUIRY, status);
@@ -913,7 +913,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_create_conn *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	cp = hci_sent_cmd_data(hdev, HCI_OP_CREATE_CONN);
 	if (!cp)
@@ -923,7 +923,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
 
 	conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
 
-	BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->bdaddr), conn);
+	bt_dbg("%s bdaddr %s conn %p", hdev->name, batostr(&cp->bdaddr), conn);
 
 	if (status) {
 		if (conn && conn->state == BT_CONNECT) {
@@ -941,7 +941,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
 				conn->out = 1;
 				conn->link_mode |= HCI_LM_MASTER;
 			} else
-				BT_ERR("No memory for new connection");
+				bt_err("No memory for new connection");
 		}
 	}
 
@@ -954,7 +954,7 @@ static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status)
 	struct hci_conn *acl, *sco;
 	__u16 handle;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -965,7 +965,7 @@ static void hci_cs_add_sco(struct hci_dev *hdev, __u8 status)
 
 	handle = __le16_to_cpu(cp->handle);
 
-	BT_DBG("%s handle %d", hdev->name, handle);
+	bt_dbg("%s handle %d", hdev->name, handle);
 
 	hci_dev_lock(hdev);
 
@@ -988,7 +988,7 @@ static void hci_cs_auth_requested(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_auth_requested *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -1015,7 +1015,7 @@ static void hci_cs_set_conn_encrypt(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_set_conn_encrypt *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -1060,7 +1060,7 @@ static void hci_cs_remote_name_req(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_remote_name_req *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	/* If successful wait for the name req complete event before
 	 * checking for the need to do authentication */
@@ -1095,7 +1095,7 @@ static void hci_cs_read_remote_features(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_read_remote_features *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -1122,7 +1122,7 @@ static void hci_cs_read_remote_ext_features(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_read_remote_ext_features *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -1150,7 +1150,7 @@ static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status)
 	struct hci_conn *acl, *sco;
 	__u16 handle;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -1161,7 +1161,7 @@ static void hci_cs_setup_sync_conn(struct hci_dev *hdev, __u8 status)
 
 	handle = __le16_to_cpu(cp->handle);
 
-	BT_DBG("%s handle %d", hdev->name, handle);
+	bt_dbg("%s handle %d", hdev->name, handle);
 
 	hci_dev_lock(hdev);
 
@@ -1184,7 +1184,7 @@ static void hci_cs_sniff_mode(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_sniff_mode *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -1211,7 +1211,7 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_exit_sniff_mode *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	if (!status)
 		return;
@@ -1238,7 +1238,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
 	struct hci_cp_le_create_conn *cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 
 	cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN);
 	if (!cp)
@@ -1248,7 +1248,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
 
 	conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->peer_addr);
 
-	BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->peer_addr),
+	bt_dbg("%s bdaddr %s conn %p", hdev->name, batostr(&cp->peer_addr),
 		conn);
 
 	if (status) {
@@ -1264,7 +1264,7 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
 				conn->dst_type = cp->peer_addr_type;
 				conn->out = 1;
 			} else {
-				BT_ERR("No memory for new connection");
+				bt_err("No memory for new connection");
 			}
 		}
 	}
@@ -1274,14 +1274,14 @@ static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
 
 static void hci_cs_le_start_enc(struct hci_dev *hdev, u8 status)
 {
-	BT_DBG("%s status 0x%x", hdev->name, status);
+	bt_dbg("%s status 0x%x", hdev->name, status);
 }
 
 static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	__u8 status = *((__u8 *) skb->data);
 
-	BT_DBG("%s status %d", hdev->name, status);
+	bt_dbg("%s status %d", hdev->name, status);
 
 	if (test_bit(HCI_MGMT, &hdev->flags) &&
 				test_and_clear_bit(HCI_INQUIRY, &hdev->flags))
@@ -1298,7 +1298,7 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
 	struct inquiry_info *info = (void *) (skb->data + 1);
 	int num_rsp = *((__u8 *) skb->data);
 
-	BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
+	bt_dbg("%s num_rsp %d", hdev->name, num_rsp);
 
 	if (!num_rsp)
 		return;
@@ -1333,7 +1333,7 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
 	struct hci_ev_conn_complete *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -1411,7 +1411,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
 	struct hci_ev_conn_request *ev = (void *) skb->data;
 	int mask = hdev->link_mode;
 
-	BT_DBG("%s bdaddr %s type 0x%x", hdev->name,
+	bt_dbg("%s bdaddr %s type 0x%x", hdev->name,
 					batostr(&ev->bdaddr), ev->link_type);
 
 	mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
@@ -1432,7 +1432,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
 		if (!conn) {
 			conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr);
 			if (!conn) {
-				BT_ERR("No memory for new connection");
+				bt_err("No memory for new connection");
 				hci_dev_unlock(hdev);
 				return;
 			}
@@ -1485,7 +1485,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_ev_disconn_complete *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	if (ev->status) {
 		mgmt_disconnect_failed(hdev->id);
@@ -1515,7 +1515,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
 	struct hci_ev_auth_complete *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -1526,7 +1526,7 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
 	if (!ev->status) {
 		if (!(conn->ssp_mode > 0 && hdev->ssp_mode > 0) &&
 				test_bit(HCI_CONN_REAUTH_PEND,	&conn->pend)) {
-			BT_INFO("re-auth of legacy device is not possible.");
+			bt_info("re-auth of legacy device is not possible.");
 		} else {
 			conn->link_mode |= HCI_LM_AUTH;
 			conn->sec_level = conn->pending_sec_level;
@@ -1580,7 +1580,7 @@ static inline void hci_remote_name_evt(struct hci_dev *hdev, struct sk_buff *skb
 	struct hci_ev_remote_name *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_conn_check_pending(hdev);
 
@@ -1611,7 +1611,7 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *
 	struct hci_ev_encrypt_change *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -1647,7 +1647,7 @@ static inline void hci_change_link_key_complete_evt(struct hci_dev *hdev, struct
 	struct hci_ev_change_link_key_complete *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -1669,7 +1669,7 @@ static inline void hci_remote_features_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_ev_remote_features *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -1712,12 +1712,12 @@ unlock:
 
 static inline void hci_remote_version_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 }
 
 static inline void hci_qos_setup_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 }
 
 static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
@@ -1895,7 +1895,7 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
 		break;
 
 	default:
-		BT_DBG("%s opcode 0x%x", hdev->name, opcode);
+		bt_dbg("%s opcode 0x%x", hdev->name, opcode);
 		break;
 	}
 
@@ -1977,7 +1977,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
 		break;
 
 	default:
-		BT_DBG("%s opcode 0x%x", hdev->name, opcode);
+		bt_dbg("%s opcode 0x%x", hdev->name, opcode);
 		break;
 	}
 
@@ -1996,7 +1996,7 @@ static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb
 	struct hci_ev_role_change *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -2025,10 +2025,10 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
 
 	skb_pull(skb, sizeof(*ev));
 
-	BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
+	bt_dbg("%s num_hndl %d", hdev->name, ev->num_hndl);
 
 	if (skb->len < ev->num_hndl * 4) {
-		BT_DBG("%s bad parameters", hdev->name);
+		bt_dbg("%s bad parameters", hdev->name);
 		return;
 	}
 
@@ -2077,7 +2077,7 @@ static inline void hci_mode_change_evt(struct hci_dev *hdev, struct sk_buff *skb
 	struct hci_ev_mode_change *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -2105,7 +2105,7 @@ static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_ev_pin_code_req *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2140,7 +2140,7 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_conn *conn;
 	struct link_key *key;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (!test_bit(HCI_LINK_KEYS, &hdev->flags))
 		return;
@@ -2149,17 +2149,17 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff
 
 	key = hci_find_link_key(hdev, &ev->bdaddr);
 	if (!key) {
-		BT_DBG("%s link key not found for %s", hdev->name,
+		bt_dbg("%s link key not found for %s", hdev->name,
 							batostr(&ev->bdaddr));
 		goto not_found;
 	}
 
-	BT_DBG("%s found key type %u for %s", hdev->name, key->type,
+	bt_dbg("%s found key type %u for %s", hdev->name, key->type,
 							batostr(&ev->bdaddr));
 
 	if (!test_bit(HCI_DEBUG_KEYS, &hdev->flags) &&
 				key->type == HCI_LK_DEBUG_COMBINATION) {
-		BT_DBG("%s ignoring debug key", hdev->name);
+		bt_dbg("%s ignoring debug key", hdev->name);
 		goto not_found;
 	}
 
@@ -2168,13 +2168,13 @@ static inline void hci_link_key_request_evt(struct hci_dev *hdev, struct sk_buff
 		if (key->type == HCI_LK_UNAUTH_COMBINATION &&
 				conn->auth_type != 0xff &&
 				(conn->auth_type & 0x01)) {
-			BT_DBG("%s ignoring unauthenticated key", hdev->name);
+			bt_dbg("%s ignoring unauthenticated key", hdev->name);
 			goto not_found;
 		}
 
 		if (key->type == HCI_LK_COMBINATION && key->pin_len < 16 &&
 				conn->pending_sec_level == BT_SECURITY_HIGH) {
-			BT_DBG("%s ignoring key unauthenticated for high \
+			bt_dbg("%s ignoring key unauthenticated for high \
 							security", hdev->name);
 			goto not_found;
 		}
@@ -2203,7 +2203,7 @@ static inline void hci_link_key_notify_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_conn *conn;
 	u8 pin_len = 0;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2231,7 +2231,7 @@ static inline void hci_clock_offset_evt(struct hci_dev *hdev, struct sk_buff *sk
 	struct hci_ev_clock_offset *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -2254,7 +2254,7 @@ static inline void hci_pkt_type_change_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_ev_pkt_type_change *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -2270,7 +2270,7 @@ static inline void hci_pscan_rep_mode_evt(struct hci_dev *hdev, struct sk_buff *
 	struct hci_ev_pscan_rep_mode *ev = (void *) skb->data;
 	struct inquiry_entry *ie;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2288,7 +2288,7 @@ static inline void hci_inquiry_result_with_rssi_evt(struct hci_dev *hdev, struct
 	struct inquiry_data data;
 	int num_rsp = *((__u8 *) skb->data);
 
-	BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
+	bt_dbg("%s num_rsp %d", hdev->name, num_rsp);
 
 	if (!num_rsp)
 		return;
@@ -2346,7 +2346,7 @@ static inline void hci_remote_ext_features_evt(struct hci_dev *hdev, struct sk_b
 	struct hci_ev_remote_ext_features *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2390,7 +2390,7 @@ static inline void hci_sync_conn_complete_evt(struct hci_dev *hdev, struct sk_bu
 	struct hci_ev_sync_conn_complete *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -2442,14 +2442,14 @@ unlock:
 
 static inline void hci_sync_conn_changed_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 }
 
 static inline void hci_sniff_subrate_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_ev_sniff_subrate *ev = (void *) skb->data;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 }
 
 static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
@@ -2458,7 +2458,7 @@ static inline void hci_extended_inquiry_result_evt(struct hci_dev *hdev, struct
 	struct extended_inquiry_info *info = (void *) (skb->data + 1);
 	int num_rsp = *((__u8 *) skb->data);
 
-	BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
+	bt_dbg("%s num_rsp %d", hdev->name, num_rsp);
 
 	if (!num_rsp)
 		return;
@@ -2512,7 +2512,7 @@ static inline void hci_io_capa_request_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_ev_io_capa_request *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2561,7 +2561,7 @@ static inline void hci_io_capa_reply_evt(struct hci_dev *hdev, struct sk_buff *s
 	struct hci_ev_io_capa_reply *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2584,7 +2584,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
 	int loc_mitm, rem_mitm, confirm_hint = 0;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2604,7 +2604,7 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
 	 * initiators (connect_cfm_cb set) since then we always have the MITM
 	 * bit set. */
 	if (!conn->connect_cfm_cb && loc_mitm && conn->remote_cap == 0x03) {
-		BT_DBG("Rejecting request: remote device can't provide MITM");
+		bt_dbg("Rejecting request: remote device can't provide MITM");
 		hci_send_cmd(hdev, HCI_OP_USER_CONFIRM_NEG_REPLY,
 					sizeof(ev->bdaddr), &ev->bdaddr);
 		goto unlock;
@@ -2618,12 +2618,12 @@ static inline void hci_user_confirm_request_evt(struct hci_dev *hdev,
 		 * proceed from user space (mgmt_user_confirm with
 		 * confirm_hint set to 1). */
 		if (!test_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
-			BT_DBG("Confirming auto-accept as acceptor");
+			bt_dbg("Confirming auto-accept as acceptor");
 			confirm_hint = 1;
 			goto confirm;
 		}
 
-		BT_DBG("Auto-accept of user confirmation with %ums delay",
+		bt_dbg("Auto-accept of user confirmation with %ums delay",
 						hdev->auto_accept_delay);
 
 		if (hdev->auto_accept_delay > 0) {
@@ -2650,7 +2650,7 @@ static inline void hci_simple_pair_complete_evt(struct hci_dev *hdev, struct sk_
 	struct hci_ev_simple_pair_complete *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2677,7 +2677,7 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_
 	struct hci_ev_remote_host_features *ev = (void *) skb->data;
 	struct inquiry_entry *ie;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2694,7 +2694,7 @@ static inline void hci_remote_oob_data_request_evt(struct hci_dev *hdev,
 	struct hci_ev_remote_oob_data_request *ev = (void *) skb->data;
 	struct oob_data *data;
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	hci_dev_lock(hdev);
 
@@ -2728,7 +2728,7 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff
 	struct hci_ev_le_conn_complete *ev = (void *) skb->data;
 	struct hci_conn *conn;
 
-	BT_DBG("%s status %d", hdev->name, ev->status);
+	bt_dbg("%s status %d", hdev->name, ev->status);
 
 	hci_dev_lock(hdev);
 
@@ -2736,7 +2736,7 @@ static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff
 	if (!conn) {
 		conn = hci_conn_add(hdev, LE_LINK, &ev->bdaddr);
 		if (!conn) {
-			BT_ERR("No memory for new connection");
+			bt_err("No memory for new connection");
 			hci_dev_unlock(hdev);
 			return;
 		}
@@ -2795,7 +2795,7 @@ static inline void hci_le_ltk_request_evt(struct hci_dev *hdev,
 	struct hci_cp_le_ltk_reply cp;
 	struct hci_conn *conn;
 
-	BT_DBG("%s handle %d", hdev->name, cpu_to_le16(ev->handle));
+	bt_dbg("%s handle %d", hdev->name, cpu_to_le16(ev->handle));
 
 	hci_dev_lock(hdev);
 
@@ -2987,7 +2987,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
 		break;
 
 	default:
-		BT_DBG("%s event 0x%x", hdev->name, event);
+		bt_dbg("%s event 0x%x", hdev->name, event);
 		break;
 	}
 
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index ff02cf5..496f6b3 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -91,7 +91,7 @@ void hci_send_to_sock(struct hci_dev *hdev, struct sk_buff *skb,
 	struct sock *sk;
 	struct hlist_node *node;
 
-	BT_DBG("hdev %p len %d", hdev, skb->len);
+	bt_dbg("hdev %p len %d", hdev, skb->len);
 
 	read_lock(&hci_sk_list.lock);
 	sk_for_each(sk, node, &hci_sk_list.head) {
@@ -157,7 +157,7 @@ static int hci_sock_release(struct socket *sock)
 	struct sock *sk = sock->sk;
 	struct hci_dev *hdev;
 
-	BT_DBG("sock %p sk %p", sock, sk);
+	bt_dbg("sock %p sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -252,7 +252,7 @@ static int hci_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long a
 	void __user *argp = (void __user *) arg;
 	int err;
 
-	BT_DBG("cmd %x arg %lx", cmd, arg);
+	bt_dbg("cmd %x arg %lx", cmd, arg);
 
 	switch (cmd) {
 	case HCIGETDEVLIST:
@@ -314,7 +314,7 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
 	struct hci_dev *hdev = NULL;
 	int len, err = 0;
 
-	BT_DBG("sock %p sk %p", sock, sk);
+	bt_dbg("sock %p sk %p", sock, sk);
 
 	if (!addr)
 		return -EINVAL;
@@ -364,7 +364,7 @@ static int hci_sock_getname(struct socket *sock, struct sockaddr *addr, int *add
 	struct sock *sk = sock->sk;
 	struct hci_dev *hdev = hci_pi(sk)->hdev;
 
-	BT_DBG("sock %p sk %p", sock, sk);
+	bt_dbg("sock %p sk %p", sock, sk);
 
 	if (!hdev)
 		return -EBADFD;
@@ -421,7 +421,7 @@ static int hci_sock_recvmsg(struct kiocb *iocb, struct socket *sock,
 	struct sk_buff *skb;
 	int copied, err;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	if (flags & (MSG_OOB))
 		return -EOPNOTSUPP;
@@ -459,7 +459,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
 	struct sk_buff *skb;
 	int err;
 
-	BT_DBG("sock %p sk %p", sock, sk);
+	bt_dbg("sock %p sk %p", sock, sk);
 
 	if (msg->msg_flags & MSG_OOB)
 		return -EOPNOTSUPP;
@@ -553,7 +553,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname, char
 	struct sock *sk = sock->sk;
 	int err = 0, opt = 0;
 
-	BT_DBG("sk %p, opt %d", sk, optname);
+	bt_dbg("sk %p, opt %d", sk, optname);
 
 	lock_sock(sk);
 
@@ -707,7 +707,7 @@ static int hci_sock_create(struct net *net, struct socket *sock, int protocol,
 {
 	struct sock *sk;
 
-	BT_DBG("sock %p", sock);
+	bt_dbg("sock %p", sock);
 
 	if (sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
@@ -736,7 +736,7 @@ static int hci_sock_dev_event(struct notifier_block *this, unsigned long event,
 	struct hci_dev *hdev = (struct hci_dev *) ptr;
 	struct hci_ev_si_device ev;
 
-	BT_DBG("hdev %s event %ld", hdev->name, event);
+	bt_dbg("hdev %s event %ld", hdev->name, event);
 
 	/* Send event to sockets */
 	ev.event  = event;
@@ -793,12 +793,12 @@ int __init hci_sock_init(void)
 
 	hci_register_notifier(&hci_sock_nblock);
 
-	BT_INFO("HCI socket layer initialized");
+	bt_info("HCI socket layer initialized");
 
 	return 0;
 
 error:
-	BT_ERR("HCI socket registration failed");
+	bt_err("HCI socket registration failed");
 	proto_unregister(&hci_sk_proto);
 	return err;
 }
@@ -806,7 +806,7 @@ error:
 void hci_sock_cleanup(void)
 {
 	if (bt_sock_unregister(BTPROTO_HCI) < 0)
-		BT_ERR("HCI socket unregistration failed");
+		bt_err("HCI socket unregistration failed");
 
 	hci_unregister_notifier(&hci_sock_nblock);
 
diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index a6c3aa8..ae91be0 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -96,7 +96,7 @@ static void add_conn(struct work_struct *work)
 	dev_set_drvdata(&conn->dev, conn);
 
 	if (device_add(&conn->dev) < 0) {
-		BT_ERR("Failed to register connection device");
+		bt_err("Failed to register connection device");
 		return;
 	}
 
@@ -141,7 +141,7 @@ void hci_conn_init_sysfs(struct hci_conn *conn)
 {
 	struct hci_dev *hdev = conn->hdev;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	conn->dev.type = &bt_link;
 	conn->dev.class = bt_class;
@@ -155,14 +155,14 @@ void hci_conn_init_sysfs(struct hci_conn *conn)
 
 void hci_conn_add_sysfs(struct hci_conn *conn)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	queue_work(conn->hdev->workqueue, &conn->work_add);
 }
 
 void hci_conn_del_sysfs(struct hci_conn *conn)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	queue_work(conn->hdev->workqueue, &conn->work_del);
 }
@@ -545,7 +545,7 @@ int hci_register_sysfs(struct hci_dev *hdev)
 	struct device *dev = &hdev->dev;
 	int err;
 
-	BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
+	bt_dbg("%p name %s bus %d", hdev, hdev->name, hdev->bus);
 
 	dev->type = &bt_host;
 	dev->class = bt_class;
@@ -581,7 +581,7 @@ int hci_register_sysfs(struct hci_dev *hdev)
 
 void hci_unregister_sysfs(struct hci_dev *hdev)
 {
-	BT_DBG("%p name %s bus %d", hdev, hdev->name, hdev->bus);
+	bt_dbg("%p name %s bus %d", hdev, hdev->name, hdev->bus);
 
 	debugfs_remove_recursive(hdev->debugfs);
 
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index c405a95..01ae736 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -83,7 +83,7 @@ static struct hidp_session *__hidp_get_session(bdaddr_t *bdaddr)
 	struct hidp_session *session;
 	struct list_head *p;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	list_for_each(p, &hidp_session_list) {
 		session = list_entry(p, struct hidp_session, list);
@@ -145,7 +145,7 @@ static int hidp_queue_event(struct hidp_session *session, struct input_dev *dev,
 	unsigned char newleds;
 	struct sk_buff *skb;
 
-	BT_DBG("session %p type %d code %d value %d", session, type, code, value);
+	bt_dbg("session %p type %d code %d value %d", session, type, code, value);
 
 	if (type != EV_LED)
 		return -1;
@@ -163,7 +163,7 @@ static int hidp_queue_event(struct hidp_session *session, struct input_dev *dev,
 
 	skb = alloc_skb(3, GFP_ATOMIC);
 	if (!skb) {
-		BT_ERR("Can't allocate memory for new frame");
+		bt_err("Can't allocate memory for new frame");
 		return -ENOMEM;
 	}
 
@@ -216,14 +216,14 @@ static void hidp_input_report(struct hidp_session *session, struct sk_buff *skb)
 				if (hidp_keycode[keys[i]])
 					input_report_key(dev, hidp_keycode[keys[i]], 0);
 				else
-					BT_ERR("Unknown key (scancode %#x) released.", keys[i]);
+					bt_err("Unknown key (scancode %#x) released.", keys[i]);
 			}
 
 			if (udata[i] > 3 && memscan(keys + 2, udata[i], 6) == keys + 8) {
 				if (hidp_keycode[udata[i]])
 					input_report_key(dev, hidp_keycode[udata[i]], 1);
 				else
-					BT_ERR("Unknown key (scancode %#x) pressed.", udata[i]);
+					bt_err("Unknown key (scancode %#x) pressed.", udata[i]);
 			}
 		}
 
@@ -253,11 +253,11 @@ static int __hidp_send_ctrl_message(struct hidp_session *session,
 {
 	struct sk_buff *skb;
 
-	BT_DBG("session %p data %p size %d", session, data, size);
+	bt_dbg("session %p data %p size %d", session, data, size);
 
 	skb = alloc_skb(size + 1, GFP_ATOMIC);
 	if (!skb) {
-		BT_ERR("Can't allocate memory for new frame");
+		bt_err("Can't allocate memory for new frame");
 		return -ENOMEM;
 	}
 
@@ -287,11 +287,11 @@ static int hidp_queue_report(struct hidp_session *session,
 {
 	struct sk_buff *skb;
 
-	BT_DBG("session %p hid %p data %p size %d", session, session->hid, data, size);
+	bt_dbg("session %p hid %p data %p size %d", session, session->hid, data, size);
 
 	skb = alloc_skb(size + 1, GFP_ATOMIC);
 	if (!skb) {
-		BT_ERR("Can't allocate memory for new frame");
+		bt_err("Can't allocate memory for new frame");
 		return -ENOMEM;
 	}
 
@@ -482,7 +482,7 @@ static inline void hidp_del_timer(struct hidp_session *session)
 static void hidp_process_handshake(struct hidp_session *session,
 					unsigned char param)
 {
-	BT_DBG("session %p param 0x%02x", session, param);
+	bt_dbg("session %p param 0x%02x", session, param);
 	session->output_report_success = 0; /* default condition */
 
 	switch (param) {
@@ -528,7 +528,7 @@ static void hidp_process_handshake(struct hidp_session *session,
 static void hidp_process_hid_control(struct hidp_session *session,
 					unsigned char param)
 {
-	BT_DBG("session %p param 0x%02x", session, param);
+	bt_dbg("session %p param 0x%02x", session, param);
 
 	if (param == HIDP_CTRL_VIRTUAL_CABLE_UNPLUG) {
 		/* Flush the transmit queues */
@@ -544,7 +544,7 @@ static int hidp_process_data(struct hidp_session *session, struct sk_buff *skb,
 				unsigned char param)
 {
 	int done_with_skb = 1;
-	BT_DBG("session %p skb %p len %d param 0x%02x", session, skb, skb->len, param);
+	bt_dbg("session %p skb %p len %d param 0x%02x", session, skb, skb->len, param);
 
 	switch (param) {
 	case HIDP_DATA_RTYPE_INPUT:
@@ -588,7 +588,7 @@ static void hidp_recv_ctrl_frame(struct hidp_session *session,
 	unsigned char hdr, type, param;
 	int free_skb = 1;
 
-	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+	bt_dbg("session %p skb %p len %d", session, skb, skb->len);
 
 	hdr = skb->data[0];
 	skb_pull(skb, 1);
@@ -624,7 +624,7 @@ static void hidp_recv_intr_frame(struct hidp_session *session,
 {
 	unsigned char hdr;
 
-	BT_DBG("session %p skb %p len %d", session, skb, skb->len);
+	bt_dbg("session %p skb %p len %d", session, skb, skb->len);
 
 	hdr = skb->data[0];
 	skb_pull(skb, 1);
@@ -637,10 +637,10 @@ static void hidp_recv_intr_frame(struct hidp_session *session,
 
 		if (session->hid) {
 			hid_input_report(session->hid, HID_INPUT_REPORT, skb->data, skb->len, 1);
-			BT_DBG("report len %d", skb->len);
+			bt_dbg("report len %d", skb->len);
 		}
 	} else {
-		BT_DBG("Unsupported protocol header 0x%02x", hdr);
+		bt_dbg("Unsupported protocol header 0x%02x", hdr);
 	}
 
 	kfree_skb(skb);
@@ -651,7 +651,7 @@ static int hidp_send_frame(struct socket *sock, unsigned char *data, int len)
 	struct kvec iv = { data, len };
 	struct msghdr msg;
 
-	BT_DBG("sock %p data %p len %d", sock, data, len);
+	bt_dbg("sock %p data %p len %d", sock, data, len);
 
 	if (!len)
 		return 0;
@@ -665,7 +665,7 @@ static void hidp_process_transmit(struct hidp_session *session)
 {
 	struct sk_buff *skb;
 
-	BT_DBG("session %p", session);
+	bt_dbg("session %p", session);
 
 	while ((skb = skb_dequeue(&session->ctrl_transmit))) {
 		if (hidp_send_frame(session->ctrl_sock, skb->data, skb->len) < 0) {
@@ -696,7 +696,7 @@ static int hidp_session(void *arg)
 	struct sk_buff *skb;
 	wait_queue_t ctrl_wait, intr_wait;
 
-	BT_DBG("session %p", session);
+	bt_dbg("session %p", session);
 
 	set_user_nice(current, -15);
 
@@ -957,7 +957,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
 	int vendor, product;
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	if (bacmp(&bt_sk(ctrl_sock->sk)->src, &bt_sk(intr_sock->sk)->src) ||
 			bacmp(&bt_sk(ctrl_sock->sk)->dst, &bt_sk(intr_sock->sk)->dst))
@@ -967,7 +967,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
 	if (!session)
 		return -ENOMEM;
 
-	BT_DBG("rd_data %p rd_size %d", req->rd_data, req->rd_size);
+	bt_dbg("rd_data %p rd_size %d", req->rd_data, req->rd_size);
 
 	down_write(&hidp_session_sem);
 
@@ -984,7 +984,7 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
 	session->intr_mtu = min_t(uint, l2cap_pi(intr_sock->sk)->chan->omtu,
 					l2cap_pi(intr_sock->sk)->chan->imtu);
 
-	BT_DBG("ctrl mtu %d intr mtu %d", session->ctrl_mtu, session->intr_mtu);
+	bt_dbg("ctrl mtu %d intr mtu %d", session->ctrl_mtu, session->intr_mtu);
 
 	session->ctrl_sock = ctrl_sock;
 	session->intr_sock = intr_sock;
@@ -1097,7 +1097,7 @@ int hidp_del_connection(struct hidp_conndel_req *req)
 	struct hidp_session *session;
 	int err = 0;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	down_read(&hidp_session_sem);
 
@@ -1125,7 +1125,7 @@ int hidp_get_connlist(struct hidp_connlist_req *req)
 	struct list_head *p;
 	int err = 0, n = 0;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	down_read(&hidp_session_sem);
 
@@ -1184,7 +1184,7 @@ static int __init hidp_init(void)
 {
 	int ret;
 
-	BT_INFO("HIDP (Human Interface Emulation) ver %s", VERSION);
+	bt_info("HIDP (Human Interface Emulation) ver %s", VERSION);
 
 	ret = hid_register_driver(&hidp_driver);
 	if (ret)
diff --git a/net/bluetooth/hidp/sock.c b/net/bluetooth/hidp/sock.c
index 178ac7f..72fd7e5 100644
--- a/net/bluetooth/hidp/sock.c
+++ b/net/bluetooth/hidp/sock.c
@@ -43,7 +43,7 @@ static int hidp_sock_release(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	BT_DBG("sock %p sk %p", sock, sk);
+	bt_dbg("sock %p sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -65,7 +65,7 @@ static int hidp_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long
 	struct socket *isock;
 	int err;
 
-	BT_DBG("cmd %x arg %lx", cmd, arg);
+	bt_dbg("cmd %x arg %lx", cmd, arg);
 
 	switch (cmd) {
 	case HIDPCONNADD:
@@ -247,7 +247,7 @@ static int hidp_sock_create(struct net *net, struct socket *sock, int protocol,
 {
 	struct sock *sk;
 
-	BT_DBG("sock %p", sock);
+	bt_dbg("sock %p", sock);
 
 	if (sock->type != SOCK_RAW)
 		return -ESOCKTNOSUPPORT;
@@ -291,7 +291,7 @@ int __init hidp_init_sockets(void)
 	return 0;
 
 error:
-	BT_ERR("Can't register HIDP socket");
+	bt_err("Can't register HIDP socket");
 	proto_unregister(&hidp_proto);
 	return err;
 }
@@ -299,7 +299,7 @@ error:
 void __exit hidp_cleanup_sockets(void)
 {
 	if (bt_sock_unregister(BTPROTO_HIDP) < 0)
-		BT_ERR("Can't unregister HIDP socket");
+		bt_err("Can't unregister HIDP socket");
 
 	proto_unregister(&hidp_proto);
 }
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 2a27428..da9f254 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -223,7 +223,7 @@ static u16 l2cap_alloc_cid(struct l2cap_conn *conn)
 
 static void l2cap_set_timer(struct l2cap_chan *chan, struct timer_list *timer, long timeout)
 {
-       BT_DBG("chan %p state %d timeout %ld", chan->sk, chan->state, timeout);
+       bt_dbg("chan %p state %d timeout %ld", chan->sk, chan->state, timeout);
 
        if (!mod_timer(timer, jiffies + timeout))
 	       chan_hold(chan);
@@ -231,7 +231,7 @@ static void l2cap_set_timer(struct l2cap_chan *chan, struct timer_list *timer, l
 
 static void l2cap_clear_timer(struct l2cap_chan *chan, struct timer_list *timer)
 {
-       BT_DBG("chan %p state %d", chan, chan->state);
+       bt_dbg("chan %p state %d", chan, chan->state);
 
        if (timer_pending(timer) && del_timer(timer))
 	       chan_put(chan);
@@ -249,7 +249,7 @@ static void l2cap_chan_timeout(unsigned long arg)
 	struct sock *sk = chan->sk;
 	int reason;
 
-	BT_DBG("chan %p state %d", chan, chan->state);
+	bt_dbg("chan %p state %d", chan, chan->state);
 
 	bh_lock_sock(sk);
 
@@ -311,7 +311,7 @@ void l2cap_chan_destroy(struct l2cap_chan *chan)
 
 static void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
 {
-	BT_DBG("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn,
+	bt_dbg("conn %p, psm 0x%2.2x, dcid 0x%4.4x", conn,
 			chan->psm, chan->dcid);
 
 	conn->disc_reason = 0x13;
@@ -356,7 +356,7 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
 
 	__clear_chan_timer(chan);
 
-	BT_DBG("chan %p, conn %p, err %d", chan, conn, err);
+	bt_dbg("chan %p, conn %p, err %d", chan, conn, err);
 
 	if (conn) {
 		/* Delete from channel list */
@@ -408,7 +408,7 @@ static void l2cap_chan_cleanup_listen(struct sock *parent)
 {
 	struct sock *sk;
 
-	BT_DBG("parent %p", parent);
+	bt_dbg("parent %p", parent);
 
 	/* Close not yet accepted channels */
 	while ((sk = bt_accept_dequeue(parent, NULL))) {
@@ -426,7 +426,7 @@ void l2cap_chan_close(struct l2cap_chan *chan, int reason)
 	struct l2cap_conn *conn = chan->conn;
 	struct sock *sk = chan->sk;
 
-	BT_DBG("chan %p state %d socket %p", chan, chan->state, sk->sk_socket);
+	bt_dbg("chan %p state %d socket %p", chan, chan->state, sk->sk_socket);
 
 	switch (chan->state) {
 	case BT_LISTEN:
@@ -550,7 +550,7 @@ static void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len,
 	struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
 	u8 flags;
 
-	BT_DBG("code 0x%2.2x", code);
+	bt_dbg("code 0x%2.2x", code);
 
 	if (!skb)
 		return;
@@ -579,7 +579,7 @@ static inline void l2cap_send_sframe(struct l2cap_chan *chan, u16 control)
 	if (chan->fcs == L2CAP_FCS_CRC16)
 		hlen += 2;
 
-	BT_DBG("chan %p, control 0x%2.2x", chan, control);
+	bt_dbg("chan %p, control 0x%2.2x", chan, control);
 
 	count = min_t(unsigned int, conn->mtu, hlen);
 	control |= L2CAP_CTRL_FRAME_TYPE;
@@ -713,7 +713,7 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
 {
 	struct l2cap_chan *chan, *tmp;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	read_lock(&conn->chan_lock);
 
@@ -839,7 +839,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
 	struct sock *parent, *sk;
 	struct l2cap_chan *chan, *pchan;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	/* Check if we have socket listening on cid */
 	pchan = l2cap_global_chan_by_scid(BT_LISTEN, L2CAP_CID_LE_DATA,
@@ -853,7 +853,7 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
 
 	/* Check for backlog size */
 	if (sk_acceptq_is_full(parent)) {
-		BT_DBG("backlog full %d", parent->sk_ack_backlog);
+		bt_dbg("backlog full %d", parent->sk_ack_backlog);
 		goto clean;
 	}
 
@@ -890,7 +890,7 @@ static void l2cap_chan_ready(struct sock *sk)
 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
 	struct sock *parent = bt_sk(sk)->parent;
 
-	BT_DBG("sk %p, parent %p", sk, parent);
+	bt_dbg("sk %p, parent %p", sk, parent);
 
 	chan->conf_state = 0;
 	__clear_chan_timer(chan);
@@ -906,7 +906,7 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
 {
 	struct l2cap_chan *chan;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (!conn->hcon->out && conn->hcon->type == LE_LINK)
 		l2cap_le_conn_ready(conn);
@@ -941,7 +941,7 @@ static void l2cap_conn_unreliable(struct l2cap_conn *conn, int err)
 {
 	struct l2cap_chan *chan;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	read_lock(&conn->chan_lock);
 
@@ -974,7 +974,7 @@ static void l2cap_conn_del(struct hci_conn *hcon, int err)
 	if (!conn)
 		return;
 
-	BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);
+	bt_dbg("hcon %p conn %p, err %d", hcon, conn, err);
 
 	kfree_skb(conn->rx_skb);
 
@@ -1018,7 +1018,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon, u8 status)
 	hcon->l2cap_data = conn;
 	conn->hcon = hcon;
 
-	BT_DBG("hcon %p conn %p", hcon, conn);
+	bt_dbg("hcon %p conn %p", hcon, conn);
 
 	if (hcon->hdev->le_mtu && hcon->type == LE_LINK)
 		conn->mtu = hcon->hdev->le_mtu;
@@ -1100,7 +1100,7 @@ int l2cap_chan_connect(struct l2cap_chan *chan)
 	__u8 auth_type;
 	int err;
 
-	BT_DBG("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst),
+	bt_dbg("%s -> %s psm 0x%2.2x", batostr(src), batostr(dst),
 							chan->psm);
 
 	hdev = hci_get_route(dst, src);
@@ -1192,7 +1192,7 @@ static void l2cap_monitor_timeout(unsigned long arg)
 	struct l2cap_chan *chan = (void *) arg;
 	struct sock *sk = chan->sk;
 
-	BT_DBG("chan %p", chan);
+	bt_dbg("chan %p", chan);
 
 	bh_lock_sock(sk);
 	if (chan->retry_count >= chan->remote_max_tx) {
@@ -1213,7 +1213,7 @@ static void l2cap_retrans_timeout(unsigned long arg)
 	struct l2cap_chan *chan = (void *) arg;
 	struct sock *sk = chan->sk;
 
-	BT_DBG("chan %p", chan);
+	bt_dbg("chan %p", chan);
 
 	bh_lock_sock(sk);
 	chan->retry_count = 1;
@@ -1249,7 +1249,7 @@ void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb)
 	struct hci_conn *hcon = chan->conn->hcon;
 	u16 flags;
 
-	BT_DBG("chan %p, skb %p len %d", chan, skb, skb->len);
+	bt_dbg("chan %p, skb %p len %d", chan, skb, skb->len);
 
 	if (!chan->flushable && lmp_no_flush_capable(hcon->hdev))
 		flags = ACL_START_NO_FLUSH;
@@ -1472,7 +1472,7 @@ struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr
 	int err, count, hlen = L2CAP_HDR_SIZE + 2;
 	struct l2cap_hdr *lh;
 
-	BT_DBG("sk %p len %d", sk, (int)len);
+	bt_dbg("sk %p len %d", sk, (int)len);
 
 	count = min_t(unsigned int, (conn->mtu - hlen), len);
 	skb = bt_skb_send_alloc(sk, count + hlen,
@@ -1502,7 +1502,7 @@ struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *m
 	int err, count, hlen = L2CAP_HDR_SIZE;
 	struct l2cap_hdr *lh;
 
-	BT_DBG("sk %p len %d", sk, (int)len);
+	bt_dbg("sk %p len %d", sk, (int)len);
 
 	count = min_t(unsigned int, (conn->mtu - hlen), len);
 	skb = bt_skb_send_alloc(sk, count + hlen,
@@ -1531,7 +1531,7 @@ struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *
 	int err, count, hlen = L2CAP_HDR_SIZE + 2;
 	struct l2cap_hdr *lh;
 
-	BT_DBG("sk %p len %d", sk, (int)len);
+	bt_dbg("sk %p len %d", sk, (int)len);
 
 	if (!conn)
 		return ERR_PTR(-ENOTCONN);
@@ -1686,7 +1686,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len)
 		break;
 
 	default:
-		BT_DBG("bad state %1.1x", chan->mode);
+		bt_dbg("bad state %1.1x", chan->mode);
 		err = -EBADFD;
 	}
 
@@ -1699,7 +1699,7 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
 	struct sk_buff *nskb;
 	struct l2cap_chan *chan;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	read_lock(&conn->chan_lock);
 	list_for_each_entry(chan, &conn->chan_l, list) {
@@ -1729,7 +1729,7 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
 	struct l2cap_hdr *lh;
 	int len, count;
 
-	BT_DBG("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d",
+	bt_dbg("conn %p, code 0x%2.2x, ident 0x%2.2x, len %d",
 			conn, code, ident, dlen);
 
 	len = L2CAP_HDR_SIZE + L2CAP_CMD_HDR_SIZE + dlen;
@@ -1813,7 +1813,7 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned
 		break;
 	}
 
-	BT_DBG("type 0x%2.2x len %d val 0x%lx", *type, opt->len, *val);
+	bt_dbg("type 0x%2.2x len %d val 0x%lx", *type, opt->len, *val);
 	return len;
 }
 
@@ -1821,7 +1821,7 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val)
 {
 	struct l2cap_conf_opt *opt = *ptr;
 
-	BT_DBG("type 0x%2.2x len %d val 0x%lx", type, len, val);
+	bt_dbg("type 0x%2.2x len %d val 0x%lx", type, len, val);
 
 	opt->type = type;
 	opt->len  = len;
@@ -1901,7 +1901,7 @@ static int l2cap_build_conf_req(struct l2cap_chan *chan, void *data)
 	struct l2cap_conf_rfc rfc = { .mode = chan->mode };
 	void *ptr = req->data;
 
-	BT_DBG("chan %p", chan);
+	bt_dbg("chan %p", chan);
 
 	if (chan->num_conf_req || chan->num_conf_rsp)
 		goto done;
@@ -2004,7 +2004,7 @@ static int l2cap_parse_conf_req(struct l2cap_chan *chan, void *data)
 	u16 mtu = L2CAP_DEFAULT_MTU;
 	u16 result = L2CAP_CONF_SUCCESS;
 
-	BT_DBG("chan %p", chan);
+	bt_dbg("chan %p", chan);
 
 	while (len >= L2CAP_CONF_OPT_SIZE) {
 		len -= l2cap_get_conf_opt(&req, &type, &olen, &val);
@@ -2153,7 +2153,7 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len, voi
 	unsigned long val;
 	struct l2cap_conf_rfc rfc;
 
-	BT_DBG("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data);
+	bt_dbg("chan %p, rsp %p, len %d, req %p", chan, rsp, len, data);
 
 	while (len >= L2CAP_CONF_OPT_SIZE) {
 		len -= l2cap_get_conf_opt(&rsp, &type, &olen, &val);
@@ -2218,7 +2218,7 @@ static int l2cap_build_conf_rsp(struct l2cap_chan *chan, void *data, u16 result,
 	struct l2cap_conf_rsp *rsp = data;
 	void *ptr = rsp->data;
 
-	BT_DBG("chan %p", chan);
+	bt_dbg("chan %p", chan);
 
 	rsp->scid   = cpu_to_le16(chan->dcid);
 	rsp->result = cpu_to_le16(result);
@@ -2254,7 +2254,7 @@ static void l2cap_conf_rfc_get(struct l2cap_chan *chan, void *rsp, int len)
 	unsigned long val;
 	struct l2cap_conf_rfc rfc;
 
-	BT_DBG("chan %p, rsp %p, len %d", chan, rsp, len);
+	bt_dbg("chan %p, rsp %p, len %d", chan, rsp, len);
 
 	if ((chan->mode != L2CAP_MODE_ERTM) && (chan->mode != L2CAP_MODE_STREAMING))
 		return;
@@ -2313,7 +2313,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
 	u16 dcid = 0, scid = __le16_to_cpu(req->scid);
 	__le16 psm = req->psm;
 
-	BT_DBG("psm 0x%2.2x scid 0x%4.4x", psm, scid);
+	bt_dbg("psm 0x%2.2x scid 0x%4.4x", psm, scid);
 
 	/* Check if we have socket listening on psm */
 	pchan = l2cap_global_chan_by_psm(BT_LISTEN, psm, conn->src);
@@ -2338,7 +2338,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
 
 	/* Check for backlog size */
 	if (sk_acceptq_is_full(parent)) {
-		BT_DBG("backlog full %d", parent->sk_ack_backlog);
+		bt_dbg("backlog full %d", parent->sk_ack_backlog);
 		goto response;
 	}
 
@@ -2449,7 +2449,7 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
 	result = __le16_to_cpu(rsp->result);
 	status = __le16_to_cpu(rsp->status);
 
-	BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status);
+	bt_dbg("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status);
 
 	if (scid) {
 		chan = l2cap_get_chan_by_scid(conn, scid);
@@ -2522,7 +2522,7 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
 	dcid  = __le16_to_cpu(req->dcid);
 	flags = __le16_to_cpu(req->flags);
 
-	BT_DBG("dcid 0x%4.4x flags 0x%2.2x", dcid, flags);
+	bt_dbg("dcid 0x%4.4x flags 0x%2.2x", dcid, flags);
 
 	chan = l2cap_get_chan_by_scid(conn, dcid);
 	if (!chan)
@@ -2615,7 +2615,7 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
 	flags  = __le16_to_cpu(rsp->flags);
 	result = __le16_to_cpu(rsp->result);
 
-	BT_DBG("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x",
+	bt_dbg("scid 0x%4.4x flags 0x%2.2x result 0x%2.2x",
 			scid, flags, result);
 
 	chan = l2cap_get_chan_by_scid(conn, scid);
@@ -2696,7 +2696,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
 	scid = __le16_to_cpu(req->scid);
 	dcid = __le16_to_cpu(req->dcid);
 
-	BT_DBG("scid 0x%4.4x dcid 0x%4.4x", scid, dcid);
+	bt_dbg("scid 0x%4.4x dcid 0x%4.4x", scid, dcid);
 
 	chan = l2cap_get_chan_by_scid(conn, dcid);
 	if (!chan)
@@ -2736,7 +2736,7 @@ static inline int l2cap_disconnect_rsp(struct l2cap_conn *conn, struct l2cap_cmd
 	scid = __le16_to_cpu(rsp->scid);
 	dcid = __le16_to_cpu(rsp->dcid);
 
-	BT_DBG("dcid 0x%4.4x scid 0x%4.4x", dcid, scid);
+	bt_dbg("dcid 0x%4.4x scid 0x%4.4x", dcid, scid);
 
 	chan = l2cap_get_chan_by_scid(conn, scid);
 	if (!chan)
@@ -2767,7 +2767,7 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm
 
 	type = __le16_to_cpu(req->type);
 
-	BT_DBG("type 0x%4.4x", type);
+	bt_dbg("type 0x%4.4x", type);
 
 	if (type == L2CAP_IT_FEAT_MASK) {
 		u8 buf[8];
@@ -2808,7 +2808,7 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
 	type   = __le16_to_cpu(rsp->type);
 	result = __le16_to_cpu(rsp->result);
 
-	BT_DBG("type 0x%4.4x result 0x%2.2x", type, result);
+	bt_dbg("type 0x%4.4x result 0x%2.2x", type, result);
 
 	/* L2CAP Info req/rsp are unbound to channels, add extra checks */
 	if (cmd->ident != conn->info_ident ||
@@ -2896,7 +2896,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 	latency		= __le16_to_cpu(req->latency);
 	to_multiplier	= __le16_to_cpu(req->to_multiplier);
 
-	BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x",
+	bt_dbg("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x",
 						min, max, latency, to_multiplier);
 
 	memset(&rsp, 0, sizeof(rsp));
@@ -2966,7 +2966,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn *conn,
 		break;
 
 	default:
-		BT_ERR("Unknown BR/EDR signaling command 0x%2.2x", cmd->code);
+		bt_err("Unknown BR/EDR signaling command 0x%2.2x", cmd->code);
 		err = -EINVAL;
 		break;
 	}
@@ -2988,7 +2988,7 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
 		return 0;
 
 	default:
-		BT_ERR("Unknown LE signaling command 0x%2.2x", cmd->code);
+		bt_err("Unknown LE signaling command 0x%2.2x", cmd->code);
 		return -EINVAL;
 	}
 }
@@ -3011,10 +3011,10 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
 
 		cmd_len = le16_to_cpu(cmd.len);
 
-		BT_DBG("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, cmd.ident);
+		bt_dbg("code 0x%2.2x len %d id 0x%2.2x", cmd.code, cmd_len, cmd.ident);
 
 		if (cmd_len > len || !cmd.ident) {
-			BT_DBG("corrupted command");
+			bt_dbg("corrupted command");
 			break;
 		}
 
@@ -3026,7 +3026,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn,
 		if (err) {
 			struct l2cap_cmd_rej rej;
 
-			BT_ERR("Wrong link type (%d)", err);
+			bt_err("Wrong link type (%d)", err);
 
 			/* FIXME: Map err to a valid reason */
 			rej.reason = cpu_to_le16(0);
@@ -3261,7 +3261,7 @@ done:
 	clear_bit(CONN_LOCAL_BUSY, &chan->conn_state);
 	clear_bit(CONN_RNR_SENT, &chan->conn_state);
 
-	BT_DBG("chan %p, Exit local busy", chan);
+	bt_dbg("chan %p, Exit local busy", chan);
 
 	return 0;
 }
@@ -3332,7 +3332,7 @@ static int l2cap_push_rx_skb(struct l2cap_chan *chan, struct sk_buff *skb, u16 c
 	}
 
 	/* Busy Condition */
-	BT_DBG("chan %p, Enter local busy", chan);
+	bt_dbg("chan %p, Enter local busy", chan);
 
 	set_bit(CONN_LOCAL_BUSY, &chan->conn_state);
 	bt_cb(skb)->sar = control >> L2CAP_CTRL_SAR_SHIFT;
@@ -3508,7 +3508,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
 	int num_to_ack = (chan->tx_win/6) + 1;
 	int err = 0;
 
-	BT_DBG("chan %p len %d tx_seq %d rx_control 0x%4.4x", chan, skb->len,
+	bt_dbg("chan %p len %d tx_seq %d rx_control 0x%4.4x", chan, skb->len,
 							tx_seq, rx_control);
 
 	if (L2CAP_CTRL_FINAL & rx_control &&
@@ -3554,7 +3554,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
 				chan->buffer_seq = chan->buffer_seq_srej;
 				clear_bit(CONN_SREJ_SENT, &chan->conn_state);
 				l2cap_send_ack(chan);
-				BT_DBG("chan %p, Exit SREJ_SENT", chan);
+				bt_dbg("chan %p, Exit SREJ_SENT", chan);
 			}
 		} else {
 			struct srej_list *l;
@@ -3583,7 +3583,7 @@ static inline int l2cap_data_channel_iframe(struct l2cap_chan *chan, u16 rx_cont
 
 		set_bit(CONN_SREJ_SENT, &chan->conn_state);
 
-		BT_DBG("chan %p, Enter SREJ", chan);
+		bt_dbg("chan %p, Enter SREJ", chan);
 
 		INIT_LIST_HEAD(&chan->srej_l);
 		chan->buffer_seq_srej = chan->buffer_seq;
@@ -3634,7 +3634,7 @@ drop:
 
 static inline void l2cap_data_channel_rrframe(struct l2cap_chan *chan, u16 rx_control)
 {
-	BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, __get_reqseq(rx_control),
+	bt_dbg("chan %p, req_seq %d ctrl 0x%4.4x", chan, __get_reqseq(rx_control),
 						rx_control);
 
 	chan->expected_ack_seq = __get_reqseq(rx_control);
@@ -3676,7 +3676,7 @@ static inline void l2cap_data_channel_rejframe(struct l2cap_chan *chan, u16 rx_c
 {
 	u8 tx_seq = __get_reqseq(rx_control);
 
-	BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
+	bt_dbg("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
 
 	clear_bit(CONN_REMOTE_BUSY, &chan->conn_state);
 
@@ -3697,7 +3697,7 @@ static inline void l2cap_data_channel_srejframe(struct l2cap_chan *chan, u16 rx_
 {
 	u8 tx_seq = __get_reqseq(rx_control);
 
-	BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
+	bt_dbg("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
 
 	clear_bit(CONN_REMOTE_BUSY, &chan->conn_state);
 
@@ -3733,7 +3733,7 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c
 {
 	u8 tx_seq = __get_reqseq(rx_control);
 
-	BT_DBG("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
+	bt_dbg("chan %p, req_seq %d ctrl 0x%4.4x", chan, tx_seq, rx_control);
 
 	set_bit(CONN_REMOTE_BUSY, &chan->conn_state);
 	chan->expected_ack_seq = tx_seq;
@@ -3757,7 +3757,7 @@ static inline void l2cap_data_channel_rnrframe(struct l2cap_chan *chan, u16 rx_c
 
 static inline int l2cap_data_channel_sframe(struct l2cap_chan *chan, u16 rx_control, struct sk_buff *skb)
 {
-	BT_DBG("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len);
+	bt_dbg("chan %p rx_control 0x%4.4x len %d", chan, rx_control, skb->len);
 
 	if (L2CAP_CTRL_FINAL & rx_control &&
 			test_bit(CONN_WAIT_F, &chan->conn_state)) {
@@ -3844,7 +3844,7 @@ static int l2cap_ertm_data_rcv(struct sock *sk, struct sk_buff *skb)
 		l2cap_data_channel_iframe(chan, control, skb);
 	} else {
 		if (len != 0) {
-			BT_ERR("%d", len);
+			bt_err("%d", len);
 			l2cap_send_disconn_req(chan->conn, chan, ECONNRESET);
 			goto drop;
 		}
@@ -3869,13 +3869,13 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
 
 	chan = l2cap_get_chan_by_scid(conn, cid);
 	if (!chan) {
-		BT_DBG("unknown cid 0x%4.4x", cid);
+		bt_dbg("unknown cid 0x%4.4x", cid);
 		goto drop;
 	}
 
 	sk = chan->sk;
 
-	BT_DBG("chan %p, len %d", chan, skb->len);
+	bt_dbg("chan %p, len %d", chan, skb->len);
 
 	if (chan->state != BT_CONNECTED)
 		goto drop;
@@ -3933,7 +3933,7 @@ static inline int l2cap_data_channel(struct l2cap_conn *conn, u16 cid, struct sk
 		goto done;
 
 	default:
-		BT_DBG("chan %p: bad mode 0x%2.2x", chan, chan->mode);
+		bt_dbg("chan %p: bad mode 0x%2.2x", chan, chan->mode);
 		break;
 	}
 
@@ -3960,7 +3960,7 @@ static inline int l2cap_conless_channel(struct l2cap_conn *conn, __le16 psm, str
 
 	bh_lock_sock(sk);
 
-	BT_DBG("sk %p, len %d", sk, skb->len);
+	bt_dbg("sk %p, len %d", sk, skb->len);
 
 	if (chan->state != BT_BOUND && chan->state != BT_CONNECTED)
 		goto drop;
@@ -3993,7 +3993,7 @@ static inline int l2cap_att_channel(struct l2cap_conn *conn, __le16 cid, struct
 
 	bh_lock_sock(sk);
 
-	BT_DBG("sk %p, len %d", sk, skb->len);
+	bt_dbg("sk %p, len %d", sk, skb->len);
 
 	if (chan->state != BT_BOUND && chan->state != BT_CONNECTED)
 		goto drop;
@@ -4028,7 +4028,7 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
 		return;
 	}
 
-	BT_DBG("len %d, cid 0x%4.4x", len, cid);
+	bt_dbg("len %d, cid 0x%4.4x", len, cid);
 
 	switch (cid) {
 	case L2CAP_CID_LE_SIGNALING:
@@ -4067,7 +4067,7 @@ static int l2cap_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 type)
 	if (type != ACL_LINK)
 		return -EINVAL;
 
-	BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
+	bt_dbg("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
 
 	/* Find listening sockets and check their link_mode */
 	read_lock(&chan_list_lock);
@@ -4097,7 +4097,7 @@ static int l2cap_connect_cfm(struct hci_conn *hcon, u8 status)
 {
 	struct l2cap_conn *conn;
 
-	BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
+	bt_dbg("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
 
 	if (!(hcon->type == ACL_LINK || hcon->type == LE_LINK))
 		return -EINVAL;
@@ -4116,7 +4116,7 @@ static int l2cap_disconn_ind(struct hci_conn *hcon)
 {
 	struct l2cap_conn *conn = hcon->l2cap_data;
 
-	BT_DBG("hcon %p", hcon);
+	bt_dbg("hcon %p", hcon);
 
 	if ((hcon->type != ACL_LINK && hcon->type != LE_LINK) || !conn)
 		return 0x13;
@@ -4126,7 +4126,7 @@ static int l2cap_disconn_ind(struct hci_conn *hcon)
 
 static int l2cap_disconn_cfm(struct hci_conn *hcon, u8 reason)
 {
-	BT_DBG("hcon %p reason %d", hcon, reason);
+	bt_dbg("hcon %p reason %d", hcon, reason);
 
 	if (!(hcon->type == ACL_LINK || hcon->type == LE_LINK))
 		return -EINVAL;
@@ -4161,7 +4161,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 	if (!conn)
 		return 0;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	read_lock(&conn->chan_lock);
 
@@ -4170,7 +4170,7 @@ static int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt)
 
 		bh_lock_sock(sk);
 
-		BT_DBG("chan->scid %d", chan->scid);
+		bt_dbg("chan->scid %d", chan->scid);
 
 		if (chan->scid == L2CAP_CID_LE_DATA) {
 			if (!status && encrypt) {
@@ -4258,7 +4258,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 	if (!conn)
 		goto drop;
 
-	BT_DBG("conn %p len %d flags 0x%x", conn, skb->len, flags);
+	bt_dbg("conn %p len %d flags 0x%x", conn, skb->len, flags);
 
 	if (!(flags & ACL_CONT)) {
 		struct l2cap_hdr *hdr;
@@ -4267,7 +4267,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 		int len;
 
 		if (conn->rx_len) {
-			BT_ERR("Unexpected start frame (len %d)", skb->len);
+			bt_err("Unexpected start frame (len %d)", skb->len);
 			kfree_skb(conn->rx_skb);
 			conn->rx_skb = NULL;
 			conn->rx_len = 0;
@@ -4276,7 +4276,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 
 		/* Start fragment always begin with Basic L2CAP header */
 		if (skb->len < L2CAP_HDR_SIZE) {
-			BT_ERR("Frame is too short (len %d)", skb->len);
+			bt_err("Frame is too short (len %d)", skb->len);
 			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
@@ -4291,10 +4291,10 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 			return 0;
 		}
 
-		BT_DBG("Start: total len %d, frag len %d", len, skb->len);
+		bt_dbg("Start: total len %d, frag len %d", len, skb->len);
 
 		if (skb->len > len) {
-			BT_ERR("Frame is too long (len %d, expected len %d)",
+			bt_err("Frame is too long (len %d, expected len %d)",
 				skb->len, len);
 			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
@@ -4306,7 +4306,7 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 			struct sock *sk = chan->sk;
 
 			if (chan->imtu < len - L2CAP_HDR_SIZE) {
-				BT_ERR("Frame exceeding recv MTU (len %d, "
+				bt_err("Frame exceeding recv MTU (len %d, "
 							"MTU %d)", len,
 							chan->imtu);
 				bh_unlock_sock(sk);
@@ -4325,16 +4325,16 @@ static int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb, u16 fl
 								skb->len);
 		conn->rx_len = len - skb->len;
 	} else {
-		BT_DBG("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len);
+		bt_dbg("Cont: frag len %d (expecting %d)", skb->len, conn->rx_len);
 
 		if (!conn->rx_len) {
-			BT_ERR("Unexpected continuation frame (len %d)", skb->len);
+			bt_err("Unexpected continuation frame (len %d)", skb->len);
 			l2cap_conn_unreliable(conn, ECOMM);
 			goto drop;
 		}
 
 		if (skb->len > conn->rx_len) {
-			BT_ERR("Fragment is too long (len %d, expected %d)",
+			bt_err("Fragment is too long (len %d, expected %d)",
 					skb->len, conn->rx_len);
 			kfree_skb(conn->rx_skb);
 			conn->rx_skb = NULL;
@@ -4422,7 +4422,7 @@ int __init l2cap_init(void)
 
 	err = hci_register_proto(&l2cap_hci_proto);
 	if (err < 0) {
-		BT_ERR("L2CAP protocol registration failed");
+		bt_err("L2CAP protocol registration failed");
 		bt_sock_unregister(BTPROTO_L2CAP);
 		goto error;
 	}
@@ -4431,7 +4431,7 @@ int __init l2cap_init(void)
 		l2cap_debugfs = debugfs_create_file("l2cap", 0444,
 					bt_debugfs, NULL, &l2cap_debugfs_fops);
 		if (!l2cap_debugfs)
-			BT_ERR("Failed to create L2CAP debug file");
+			bt_err("Failed to create L2CAP debug file");
 	}
 
 	return 0;
@@ -4450,7 +4450,7 @@ void l2cap_exit(void)
 	destroy_workqueue(_busy_wq);
 
 	if (hci_unregister_proto(&l2cap_hci_proto) < 0)
-		BT_ERR("L2CAP protocol unregistration failed");
+		bt_err("L2CAP protocol unregistration failed");
 
 	l2cap_cleanup_sockets();
 }
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index 39082d4..bc31d62 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -42,7 +42,7 @@ static int l2cap_sock_bind(struct socket *sock, struct sockaddr *addr, int alen)
 	struct sockaddr_l2 la;
 	int len, err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (!addr || addr->sa_family != AF_BLUETOOTH)
 		return -EINVAL;
@@ -106,7 +106,7 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, int al
 	struct sockaddr_l2 la;
 	int len, err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (!addr || alen < sizeof(addr->sa_family) ||
 	    addr->sa_family != AF_BLUETOOTH)
@@ -192,7 +192,7 @@ static int l2cap_sock_listen(struct socket *sock, int backlog)
 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
 	int err = 0;
 
-	BT_DBG("sk %p backlog %d", sk, backlog);
+	bt_dbg("sk %p backlog %d", sk, backlog);
 
 	lock_sock(sk);
 
@@ -242,7 +242,7 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl
 
 	timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
 
-	BT_DBG("sk %p timeo %ld", sk, timeo);
+	bt_dbg("sk %p timeo %ld", sk, timeo);
 
 	/* Wait for an incoming connection. (wake-one). */
 	add_wait_queue_exclusive(sk_sleep(sk), &wait);
@@ -275,7 +275,7 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl
 
 	newsock->state = SS_CONNECTED;
 
-	BT_DBG("new socket %p", nsk);
+	bt_dbg("new socket %p", nsk);
 
 done:
 	release_sock(sk);
@@ -288,7 +288,7 @@ static int l2cap_sock_getname(struct socket *sock, struct sockaddr *addr, int *l
 	struct sock *sk = sock->sk;
 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	addr->sa_family = AF_BLUETOOTH;
 	*len = sizeof(struct sockaddr_l2);
@@ -315,7 +315,7 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname, char __us
 	int len, err = 0;
 	u32 opt;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (get_user(len, optlen))
 		return -EFAULT;
@@ -401,7 +401,7 @@ static int l2cap_sock_getsockopt(struct socket *sock, int level, int optname, ch
 	struct bt_power pwr;
 	int len, err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (level == SOL_L2CAP)
 		return l2cap_sock_getsockopt_old(sock, optname, optval, optlen);
@@ -479,7 +479,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
 	int len, err = 0;
 	u32 opt;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	lock_sock(sk);
 
@@ -567,7 +567,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
 	int len, err = 0;
 	u32 opt;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (level == SOL_L2CAP)
 		return l2cap_sock_setsockopt_old(sock, optname, optval, optlen);
@@ -686,7 +686,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock, struct ms
 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
 	int err;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	err = sock_error(sk);
 	if (err)
@@ -738,7 +738,7 @@ static void l2cap_sock_kill(struct sock *sk)
 	if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
 		return;
 
-	BT_DBG("sk %p state %d", sk, sk->sk_state);
+	bt_dbg("sk %p state %d", sk, sk->sk_state);
 
 	/* Kill poor orphan */
 
@@ -753,7 +753,7 @@ static int l2cap_sock_shutdown(struct socket *sock, int how)
 	struct l2cap_chan *chan = l2cap_pi(sk)->chan;
 	int err = 0;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -783,7 +783,7 @@ static int l2cap_sock_release(struct socket *sock)
 	struct sock *sk = sock->sk;
 	int err;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -840,7 +840,7 @@ static struct l2cap_ops l2cap_chan_ops = {
 
 static void l2cap_sock_destruct(struct sock *sk)
 {
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	skb_queue_purge(&sk->sk_receive_queue);
 	skb_queue_purge(&sk->sk_write_queue);
@@ -851,7 +851,7 @@ static void l2cap_sock_init(struct sock *sk, struct sock *parent)
 	struct l2cap_pinfo *pi = l2cap_pi(sk);
 	struct l2cap_chan *chan = pi->chan;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (parent) {
 		struct l2cap_chan *pchan = l2cap_pi(parent)->chan;
@@ -955,7 +955,7 @@ static int l2cap_sock_create(struct net *net, struct socket *sock, int protocol,
 {
 	struct sock *sk;
 
-	BT_DBG("sock %p", sock);
+	bt_dbg("sock %p", sock);
 
 	sock->state = SS_UNCONNECTED;
 
@@ -1014,12 +1014,12 @@ int __init l2cap_init_sockets(void)
 	if (err < 0)
 		goto error;
 
-	BT_INFO("L2CAP socket layer initialized");
+	bt_info("L2CAP socket layer initialized");
 
 	return 0;
 
 error:
-	BT_ERR("L2CAP socket registration failed");
+	bt_err("L2CAP socket registration failed");
 	proto_unregister(&l2cap_proto);
 	return err;
 }
@@ -1027,7 +1027,7 @@ error:
 void l2cap_cleanup_sockets(void)
 {
 	if (bt_sock_unregister(BTPROTO_L2CAP) < 0)
-		BT_ERR("L2CAP socket unregistration failed");
+		bt_err("L2CAP socket unregistration failed");
 
 	proto_unregister(&l2cap_proto);
 }
diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c
index 4e7cf8b..6545286 100644
--- a/net/bluetooth/lib.c
+++ b/net/bluetooth/lib.c
@@ -150,3 +150,22 @@ int bt_to_errno(__u16 code)
 	}
 }
 EXPORT_SYMBOL(bt_to_errno);
+
+int bt_printk(const char *level, const char *format, ...)
+{
+	struct va_format vaf;
+	va_list args;
+	int r;
+
+	va_start(args, format);
+
+	vaf.fmt = format;
+	vaf.va = &args;
+
+	r = printk("%sbluetooth: %pV\n", level, &vaf);
+
+	va_end(args);
+
+	return r;
+}
+EXPORT_SYMBOL(bt_printk);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index 64c0418..d8550f9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -49,7 +49,7 @@ static int cmd_status(struct sock *sk, u16 index, u16 cmd, u8 status)
 	struct mgmt_hdr *hdr;
 	struct mgmt_ev_cmd_status *ev;
 
-	BT_DBG("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status);
+	bt_dbg("sock %p, index %u, cmd %u, status %u", sk, index, cmd, status);
 
 	skb = alloc_skb(sizeof(*hdr) + sizeof(*ev), GFP_ATOMIC);
 	if (!skb)
@@ -78,7 +78,7 @@ static int cmd_complete(struct sock *sk, u16 index, u16 cmd, void *rp,
 	struct mgmt_hdr *hdr;
 	struct mgmt_ev_cmd_complete *ev;
 
-	BT_DBG("sock %p", sk);
+	bt_dbg("sock %p", sk);
 
 	skb = alloc_skb(sizeof(*hdr) + sizeof(*ev) + rp_len, GFP_ATOMIC);
 	if (!skb)
@@ -106,7 +106,7 @@ static int read_version(struct sock *sk)
 {
 	struct mgmt_rp_read_version rp;
 
-	BT_DBG("sock %p", sk);
+	bt_dbg("sock %p", sk);
 
 	rp.version = MGMT_VERSION;
 	put_unaligned_le16(MGMT_REVISION, &rp.revision);
@@ -123,7 +123,7 @@ static int read_index_list(struct sock *sk)
 	u16 count;
 	int i, err;
 
-	BT_DBG("sock %p", sk);
+	bt_dbg("sock %p", sk);
 
 	read_lock(&hci_dev_list_lock);
 
@@ -153,7 +153,7 @@ static int read_index_list(struct sock *sk)
 			continue;
 
 		put_unaligned_le16(d->id, &rp->index[i++]);
-		BT_DBG("Added hci%u", d->id);
+		bt_dbg("Added hci%u", d->id);
 	}
 
 	read_unlock(&hci_dev_list_lock);
@@ -171,7 +171,7 @@ static int read_controller_info(struct sock *sk, u16 index)
 	struct mgmt_rp_read_info rp;
 	struct hci_dev *hdev;
 
-	BT_DBG("sock %p hci%u", sk, index);
+	bt_dbg("sock %p hci%u", sk, index);
 
 	hdev = hci_dev_get(index);
 	if (!hdev)
@@ -307,7 +307,7 @@ static int set_powered(struct sock *sk, u16 index, unsigned char *data, u16 len)
 
 	cp = (void *) data;
 
-	BT_DBG("request for hci%u", index);
+	bt_dbg("request for hci%u", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_SET_POWERED, EINVAL);
@@ -359,7 +359,7 @@ static int set_discoverable(struct sock *sk, u16 index, unsigned char *data,
 
 	cp = (void *) data;
 
-	BT_DBG("request for hci%u", index);
+	bt_dbg("request for hci%u", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_SET_DISCOVERABLE, EINVAL);
@@ -420,7 +420,7 @@ static int set_connectable(struct sock *sk, u16 index, unsigned char *data,
 
 	cp = (void *) data;
 
-	BT_DBG("request for hci%u", index);
+	bt_dbg("request for hci%u", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_SET_CONNECTABLE, EINVAL);
@@ -513,7 +513,7 @@ static int set_pairable(struct sock *sk, u16 index, unsigned char *data,
 
 	cp = (void *) data;
 
-	BT_DBG("request for hci%u", index);
+	bt_dbg("request for hci%u", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_SET_PAIRABLE, EINVAL);
@@ -706,7 +706,7 @@ static int update_class(struct hci_dev *hdev)
 {
 	u8 cod[3];
 
-	BT_DBG("%s", hdev->name);
+	bt_dbg("%s", hdev->name);
 
 	if (test_bit(HCI_SERVICE_CACHE, &hdev->flags))
 		return 0;
@@ -730,7 +730,7 @@ static int add_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
 
 	cp = (void *) data;
 
-	BT_DBG("request for hci%u", index);
+	bt_dbg("request for hci%u", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_ADD_UUID, EINVAL);
@@ -779,7 +779,7 @@ static int remove_uuid(struct sock *sk, u16 index, unsigned char *data, u16 len)
 
 	cp = (void *) data;
 
-	BT_DBG("request for hci%u", index);
+	bt_dbg("request for hci%u", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_REMOVE_UUID, EINVAL);
@@ -838,7 +838,7 @@ static int set_dev_class(struct sock *sk, u16 index, unsigned char *data,
 
 	cp = (void *) data;
 
-	BT_DBG("request for hci%u", index);
+	bt_dbg("request for hci%u", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_SET_DEV_CLASS, EINVAL);
@@ -881,7 +881,7 @@ static int set_service_cache(struct sock *sk, u16 index,  unsigned char *data,
 
 	hci_dev_lock(hdev);
 
-	BT_DBG("hci%u enable %d", index, cp->enable);
+	bt_dbg("hci%u enable %d", index, cp->enable);
 
 	if (cp->enable) {
 		set_bit(HCI_SERVICE_CACHE, &hdev->flags);
@@ -919,7 +919,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len)
 
 	expected_len = sizeof(*cp) + key_count * sizeof(struct mgmt_key_info);
 	if (expected_len != len) {
-		BT_ERR("load_keys: expected %u bytes, got %u bytes",
+		bt_err("load_keys: expected %u bytes, got %u bytes",
 							len, expected_len);
 		return -EINVAL;
 	}
@@ -928,7 +928,7 @@ static int load_keys(struct sock *sk, u16 index, unsigned char *data, u16 len)
 	if (!hdev)
 		return cmd_status(sk, index, MGMT_OP_LOAD_KEYS, ENODEV);
 
-	BT_DBG("hci%u debug_keys %u key_count %u", index, cp->debug_keys,
+	bt_dbg("hci%u debug_keys %u key_count %u", index, cp->debug_keys,
 								key_count);
 
 	hci_dev_lock(hdev);
@@ -1009,7 +1009,7 @@ static int disconnect(struct sock *sk, u16 index, unsigned char *data, u16 len)
 	struct hci_conn *conn;
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	cp = (void *) data;
 
@@ -1070,7 +1070,7 @@ static int get_connections(struct sock *sk, u16 index)
 	u16 count;
 	int i, err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	hdev = hci_dev_get(index);
 	if (!hdev)
@@ -1138,7 +1138,7 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data,
 	struct pending_cmd *cmd;
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	cp = (void *) data;
 
@@ -1165,7 +1165,7 @@ static int pin_code_reply(struct sock *sk, u16 index, unsigned char *data,
 	if (conn->pending_sec_level == BT_SECURITY_HIGH && cp->pin_len != 16) {
 		bacpy(&ncp.bdaddr, &cp->bdaddr);
 
-		BT_ERR("PIN code is not 16 bytes long");
+		bt_err("PIN code is not 16 bytes long");
 
 		err = send_pin_code_neg_reply(sk, index, hdev, &ncp);
 		if (err >= 0)
@@ -1203,7 +1203,7 @@ static int pin_code_neg_reply(struct sock *sk, u16 index, unsigned char *data,
 	struct mgmt_cp_pin_code_neg_reply *cp;
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	cp = (void *) data;
 
@@ -1239,7 +1239,7 @@ static int set_io_capability(struct sock *sk, u16 index, unsigned char *data,
 	struct hci_dev *hdev;
 	struct mgmt_cp_set_io_capability *cp;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	cp = (void *) data;
 
@@ -1254,7 +1254,7 @@ static int set_io_capability(struct sock *sk, u16 index, unsigned char *data,
 
 	hdev->io_capability = cp->io_capability;
 
-	BT_DBG("%s IO capability set to 0x%02x", hdev->name,
+	bt_dbg("%s IO capability set to 0x%02x", hdev->name,
 							hdev->io_capability);
 
 	hci_dev_unlock(hdev);
@@ -1312,11 +1312,11 @@ static void pairing_complete_cb(struct hci_conn *conn, u8 status)
 {
 	struct pending_cmd *cmd;
 
-	BT_DBG("status %u", status);
+	bt_dbg("status %u", status);
 
 	cmd = find_pairing(conn);
 	if (!cmd) {
-		BT_DBG("Unable to find a pending command");
+		bt_dbg("Unable to find a pending command");
 		return;
 	}
 
@@ -1332,7 +1332,7 @@ static int pair_device(struct sock *sk, u16 index, unsigned char *data, u16 len)
 	struct hci_conn *conn;
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	cp = (void *) data;
 
@@ -1400,7 +1400,7 @@ static int user_confirm_reply(struct sock *sk, u16 index, unsigned char *data,
 	struct hci_dev *hdev;
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	if (success) {
 		mgmt_op = MGMT_OP_USER_CONFIRM_REPLY;
@@ -1450,7 +1450,7 @@ static int set_local_name(struct sock *sk, u16 index, unsigned char *data,
 	struct pending_cmd *cmd;
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	if (len != sizeof(*mgmt_cp))
 		return cmd_status(sk, index, MGMT_OP_SET_LOCAL_NAME, EINVAL);
@@ -1486,7 +1486,7 @@ static int read_local_oob_data(struct sock *sk, u16 index)
 	struct pending_cmd *cmd;
 	int err;
 
-	BT_DBG("hci%u", index);
+	bt_dbg("hci%u", index);
 
 	hdev = hci_dev_get(index);
 	if (!hdev)
@@ -1536,7 +1536,7 @@ static int add_remote_oob_data(struct sock *sk, u16 index, unsigned char *data,
 	struct mgmt_cp_add_remote_oob_data *cp = (void *) data;
 	int err;
 
-	BT_DBG("hci%u ", index);
+	bt_dbg("hci%u ", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_ADD_REMOTE_OOB_DATA,
@@ -1570,7 +1570,7 @@ static int remove_remote_oob_data(struct sock *sk, u16 index,
 	struct mgmt_cp_remove_remote_oob_data *cp = (void *) data;
 	int err;
 
-	BT_DBG("hci%u ", index);
+	bt_dbg("hci%u ", index);
 
 	if (len != sizeof(*cp))
 		return cmd_status(sk, index, MGMT_OP_REMOVE_REMOTE_OOB_DATA,
@@ -1605,7 +1605,7 @@ static int start_discovery(struct sock *sk, u16 index)
 	struct hci_dev *hdev;
 	int err;
 
-	BT_DBG("hci%u", index);
+	bt_dbg("hci%u", index);
 
 	hdev = hci_dev_get(index);
 	if (!hdev)
@@ -1641,7 +1641,7 @@ static int stop_discovery(struct sock *sk, u16 index)
 	struct pending_cmd *cmd;
 	int err;
 
-	BT_DBG("hci%u", index);
+	bt_dbg("hci%u", index);
 
 	hdev = hci_dev_get(index);
 	if (!hdev)
@@ -1673,7 +1673,7 @@ static int block_device(struct sock *sk, u16 index, unsigned char *data,
 	struct mgmt_cp_block_device *cp;
 	int err;
 
-	BT_DBG("hci%u", index);
+	bt_dbg("hci%u", index);
 
 	cp = (void *) data;
 
@@ -1705,7 +1705,7 @@ static int unblock_device(struct sock *sk, u16 index, unsigned char *data,
 	struct mgmt_cp_unblock_device *cp;
 	int err;
 
-	BT_DBG("hci%u", index);
+	bt_dbg("hci%u", index);
 
 	cp = (void *) data;
 
@@ -1737,7 +1737,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
 	u16 opcode, index, len;
 	int err;
 
-	BT_DBG("got %zu bytes", msglen);
+	bt_dbg("got %zu bytes", msglen);
 
 	if (msglen < sizeof(*hdr))
 		return -EINVAL;
@@ -1851,7 +1851,7 @@ int mgmt_control(struct sock *sk, struct msghdr *msg, size_t msglen)
 		err = unblock_device(sk, index, buf + sizeof(*hdr), len);
 		break;
 	default:
-		BT_DBG("Unknown op %u", opcode);
+		bt_dbg("Unknown op %u", opcode);
 		err = cmd_status(sk, index, opcode, 0x01);
 		break;
 	}
@@ -2098,7 +2098,7 @@ int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value,
 {
 	struct mgmt_ev_user_confirm_request ev;
 
-	BT_DBG("hci%u", index);
+	bt_dbg("hci%u", index);
 
 	bacpy(&ev.bdaddr, bdaddr);
 	ev.confirm_hint = confirm_hint;
@@ -2198,7 +2198,7 @@ int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
 	struct pending_cmd *cmd;
 	int err;
 
-	BT_DBG("hci%u status %u", index, status);
+	bt_dbg("hci%u status %u", index, status);
 
 	cmd = mgmt_pending_find(MGMT_OP_READ_LOCAL_OOB_DATA, index);
 	if (!cmd)
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 5759bb7..1849956 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -204,13 +204,13 @@ static inline int __check_fcs(u8 *data, int type, u8 fcs)
 /* ---- L2CAP callbacks ---- */
 static void rfcomm_l2state_change(struct sock *sk)
 {
-	BT_DBG("%p state %d", sk, sk->sk_state);
+	bt_dbg("%p state %d", sk, sk->sk_state);
 	rfcomm_schedule();
 }
 
 static void rfcomm_l2data_ready(struct sock *sk, int bytes)
 {
-	BT_DBG("%p bytes %d", sk, bytes);
+	bt_dbg("%p bytes %d", sk, bytes);
 	rfcomm_schedule();
 }
 
@@ -218,7 +218,7 @@ static int rfcomm_l2sock_create(struct socket **sock)
 {
 	int err;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	err = sock_create_kern(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP, sock);
 	if (!err) {
@@ -255,7 +255,7 @@ static void rfcomm_session_timeout(unsigned long arg)
 {
 	struct rfcomm_session *s = (void *) arg;
 
-	BT_DBG("session %p state %ld", s, s->state);
+	bt_dbg("session %p state %ld", s, s->state);
 
 	set_bit(RFCOMM_TIMED_OUT, &s->flags);
 	rfcomm_schedule();
@@ -263,7 +263,7 @@ static void rfcomm_session_timeout(unsigned long arg)
 
 static void rfcomm_session_set_timer(struct rfcomm_session *s, long timeout)
 {
-	BT_DBG("session %p state %ld timeout %ld", s, s->state, timeout);
+	bt_dbg("session %p state %ld timeout %ld", s, s->state, timeout);
 
 	if (!mod_timer(&s->timer, jiffies + timeout))
 		rfcomm_session_hold(s);
@@ -271,7 +271,7 @@ static void rfcomm_session_set_timer(struct rfcomm_session *s, long timeout)
 
 static void rfcomm_session_clear_timer(struct rfcomm_session *s)
 {
-	BT_DBG("session %p state %ld", s, s->state);
+	bt_dbg("session %p state %ld", s, s->state);
 
 	if (timer_pending(&s->timer) && del_timer(&s->timer))
 		rfcomm_session_put(s);
@@ -282,7 +282,7 @@ static void rfcomm_dlc_timeout(unsigned long arg)
 {
 	struct rfcomm_dlc *d = (void *) arg;
 
-	BT_DBG("dlc %p state %ld", d, d->state);
+	bt_dbg("dlc %p state %ld", d, d->state);
 
 	set_bit(RFCOMM_TIMED_OUT, &d->flags);
 	rfcomm_dlc_put(d);
@@ -291,7 +291,7 @@ static void rfcomm_dlc_timeout(unsigned long arg)
 
 static void rfcomm_dlc_set_timer(struct rfcomm_dlc *d, long timeout)
 {
-	BT_DBG("dlc %p state %ld timeout %ld", d, d->state, timeout);
+	bt_dbg("dlc %p state %ld timeout %ld", d, d->state, timeout);
 
 	if (!mod_timer(&d->timer, jiffies + timeout))
 		rfcomm_dlc_hold(d);
@@ -299,7 +299,7 @@ static void rfcomm_dlc_set_timer(struct rfcomm_dlc *d, long timeout)
 
 static void rfcomm_dlc_clear_timer(struct rfcomm_dlc *d)
 {
-	BT_DBG("dlc %p state %ld", d, d->state);
+	bt_dbg("dlc %p state %ld", d, d->state);
 
 	if (timer_pending(&d->timer) && del_timer(&d->timer))
 		rfcomm_dlc_put(d);
@@ -307,7 +307,7 @@ static void rfcomm_dlc_clear_timer(struct rfcomm_dlc *d)
 
 static void rfcomm_dlc_clear_state(struct rfcomm_dlc *d)
 {
-	BT_DBG("%p", d);
+	bt_dbg("%p", d);
 
 	d->state      = BT_OPEN;
 	d->flags      = 0;
@@ -335,14 +335,14 @@ struct rfcomm_dlc *rfcomm_dlc_alloc(gfp_t prio)
 
 	rfcomm_dlc_clear_state(d);
 
-	BT_DBG("%p", d);
+	bt_dbg("%p", d);
 
 	return d;
 }
 
 void rfcomm_dlc_free(struct rfcomm_dlc *d)
 {
-	BT_DBG("%p", d);
+	bt_dbg("%p", d);
 
 	skb_queue_purge(&d->tx_queue);
 	kfree(d);
@@ -350,7 +350,7 @@ void rfcomm_dlc_free(struct rfcomm_dlc *d)
 
 static void rfcomm_dlc_link(struct rfcomm_session *s, struct rfcomm_dlc *d)
 {
-	BT_DBG("dlc %p session %p", d, s);
+	bt_dbg("dlc %p session %p", d, s);
 
 	rfcomm_session_hold(s);
 
@@ -364,7 +364,7 @@ static void rfcomm_dlc_unlink(struct rfcomm_dlc *d)
 {
 	struct rfcomm_session *s = d->session;
 
-	BT_DBG("dlc %p refcnt %d session %p", d, atomic_read(&d->refcnt), s);
+	bt_dbg("dlc %p refcnt %d session %p", d, atomic_read(&d->refcnt), s);
 
 	list_del(&d->list);
 	d->session = NULL;
@@ -395,7 +395,7 @@ static int __rfcomm_dlc_open(struct rfcomm_dlc *d, bdaddr_t *src, bdaddr_t *dst,
 	int err = 0;
 	u8 dlci;
 
-	BT_DBG("dlc %p state %ld %s %s channel %d",
+	bt_dbg("dlc %p state %ld %s %s channel %d",
 			d, d->state, batostr(src), batostr(dst), channel);
 
 	if (channel < 1 || channel > 30)
@@ -461,7 +461,7 @@ static int __rfcomm_dlc_close(struct rfcomm_dlc *d, int err)
 	if (!s)
 		return 0;
 
-	BT_DBG("dlc %p state %ld dlci %d err %d session %p",
+	bt_dbg("dlc %p state %ld dlci %d err %d session %p",
 			d, d->state, d->dlci, err, s);
 
 	switch (d->state) {
@@ -528,7 +528,7 @@ int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb)
 	if (d->state != BT_CONNECTED)
 		return -ENOTCONN;
 
-	BT_DBG("dlc %p mtu %d len %d", d, d->mtu, len);
+	bt_dbg("dlc %p mtu %d len %d", d, d->mtu, len);
 
 	if (len > d->mtu)
 		return -EINVAL;
@@ -543,7 +543,7 @@ int rfcomm_dlc_send(struct rfcomm_dlc *d, struct sk_buff *skb)
 
 void __rfcomm_dlc_throttle(struct rfcomm_dlc *d)
 {
-	BT_DBG("dlc %p state %ld", d, d->state);
+	bt_dbg("dlc %p state %ld", d, d->state);
 
 	if (!d->cfc) {
 		d->v24_sig |= RFCOMM_V24_FC;
@@ -554,7 +554,7 @@ void __rfcomm_dlc_throttle(struct rfcomm_dlc *d)
 
 void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
 {
-	BT_DBG("dlc %p state %ld", d, d->state);
+	bt_dbg("dlc %p state %ld", d, d->state);
 
 	if (!d->cfc) {
 		d->v24_sig &= ~RFCOMM_V24_FC;
@@ -570,7 +570,7 @@ void __rfcomm_dlc_unthrottle(struct rfcomm_dlc *d)
  */
 int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig)
 {
-	BT_DBG("dlc %p state %ld v24_sig 0x%x",
+	bt_dbg("dlc %p state %ld v24_sig 0x%x",
 			d, d->state, v24_sig);
 
 	if (test_bit(RFCOMM_RX_THROTTLED, &d->flags))
@@ -588,7 +588,7 @@ int rfcomm_dlc_set_modem_status(struct rfcomm_dlc *d, u8 v24_sig)
 
 int rfcomm_dlc_get_modem_status(struct rfcomm_dlc *d, u8 *v24_sig)
 {
-	BT_DBG("dlc %p state %ld v24_sig 0x%x",
+	bt_dbg("dlc %p state %ld v24_sig 0x%x",
 			d, d->state, d->v24_sig);
 
 	*v24_sig = d->v24_sig;
@@ -603,7 +603,7 @@ static struct rfcomm_session *rfcomm_session_add(struct socket *sock, int state)
 	if (!s)
 		return NULL;
 
-	BT_DBG("session %p sock %p", s, sock);
+	bt_dbg("session %p sock %p", s, sock);
 
 	setup_timer(&s->timer, rfcomm_session_timeout, (unsigned long) s);
 
@@ -631,7 +631,7 @@ static void rfcomm_session_del(struct rfcomm_session *s)
 {
 	int state = s->state;
 
-	BT_DBG("session %p state %ld", s, s->state);
+	bt_dbg("session %p state %ld", s, s->state);
 
 	list_del(&s->list);
 
@@ -667,7 +667,7 @@ static void rfcomm_session_close(struct rfcomm_session *s, int err)
 	struct rfcomm_dlc *d;
 	struct list_head *p, *n;
 
-	BT_DBG("session %p state %ld err %d", s, s->state, err);
+	bt_dbg("session %p state %ld err %d", s, s->state, err);
 
 	rfcomm_session_hold(s);
 
@@ -694,7 +694,7 @@ static struct rfcomm_session *rfcomm_session_create(bdaddr_t *src,
 	struct socket *sock;
 	struct sock *sk;
 
-	BT_DBG("%s %s", batostr(src), batostr(dst));
+	bt_dbg("%s %s", batostr(src), batostr(dst));
 
 	*err = rfcomm_l2sock_create(&sock);
 	if (*err < 0)
@@ -757,7 +757,7 @@ static int rfcomm_send_frame(struct rfcomm_session *s, u8 *data, int len)
 	struct kvec iv = { data, len };
 	struct msghdr msg;
 
-	BT_DBG("session %p len %d", s, len);
+	bt_dbg("session %p len %d", s, len);
 
 	memset(&msg, 0, sizeof(msg));
 
@@ -768,7 +768,7 @@ static int rfcomm_send_sabm(struct rfcomm_session *s, u8 dlci)
 {
 	struct rfcomm_cmd cmd;
 
-	BT_DBG("%p dlci %d", s, dlci);
+	bt_dbg("%p dlci %d", s, dlci);
 
 	cmd.addr = __addr(s->initiator, dlci);
 	cmd.ctrl = __ctrl(RFCOMM_SABM, 1);
@@ -782,7 +782,7 @@ static int rfcomm_send_ua(struct rfcomm_session *s, u8 dlci)
 {
 	struct rfcomm_cmd cmd;
 
-	BT_DBG("%p dlci %d", s, dlci);
+	bt_dbg("%p dlci %d", s, dlci);
 
 	cmd.addr = __addr(!s->initiator, dlci);
 	cmd.ctrl = __ctrl(RFCOMM_UA, 1);
@@ -796,7 +796,7 @@ static int rfcomm_send_disc(struct rfcomm_session *s, u8 dlci)
 {
 	struct rfcomm_cmd cmd;
 
-	BT_DBG("%p dlci %d", s, dlci);
+	bt_dbg("%p dlci %d", s, dlci);
 
 	cmd.addr = __addr(s->initiator, dlci);
 	cmd.ctrl = __ctrl(RFCOMM_DISC, 1);
@@ -811,7 +811,7 @@ static int rfcomm_queue_disc(struct rfcomm_dlc *d)
 	struct rfcomm_cmd *cmd;
 	struct sk_buff *skb;
 
-	BT_DBG("dlc %p dlci %d", d, d->dlci);
+	bt_dbg("dlc %p dlci %d", d, d->dlci);
 
 	skb = alloc_skb(sizeof(*cmd), GFP_KERNEL);
 	if (!skb)
@@ -832,7 +832,7 @@ static int rfcomm_send_dm(struct rfcomm_session *s, u8 dlci)
 {
 	struct rfcomm_cmd cmd;
 
-	BT_DBG("%p dlci %d", s, dlci);
+	bt_dbg("%p dlci %d", s, dlci);
 
 	cmd.addr = __addr(!s->initiator, dlci);
 	cmd.ctrl = __ctrl(RFCOMM_DM, 1);
@@ -848,7 +848,7 @@ static int rfcomm_send_nsc(struct rfcomm_session *s, int cr, u8 type)
 	struct rfcomm_mcc *mcc;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p cr %d type %d", s, cr, type);
+	bt_dbg("%p cr %d type %d", s, cr, type);
 
 	hdr = (void *) ptr; ptr += sizeof(*hdr);
 	hdr->addr = __addr(s->initiator, 0);
@@ -874,7 +874,7 @@ static int rfcomm_send_pn(struct rfcomm_session *s, int cr, struct rfcomm_dlc *d
 	struct rfcomm_pn  *pn;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p cr %d dlci %d mtu %d", s, cr, d->dlci, d->mtu);
+	bt_dbg("%p cr %d dlci %d mtu %d", s, cr, d->dlci, d->mtu);
 
 	hdr = (void *) ptr; ptr += sizeof(*hdr);
 	hdr->addr = __addr(s->initiator, 0);
@@ -919,7 +919,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
 	struct rfcomm_rpn *rpn;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x"
+	bt_dbg("%p cr %d dlci %d bit_r 0x%x data_b 0x%x stop_b 0x%x parity 0x%x"
 			" flwc_s 0x%x xon_c 0x%x xoff_c 0x%x p_mask 0x%x",
 		s, cr, dlci, bit_rate, data_bits, stop_bits, parity,
 		flow_ctrl_settings, xon_char, xoff_char, param_mask);
@@ -954,7 +954,7 @@ static int rfcomm_send_rls(struct rfcomm_session *s, int cr, u8 dlci, u8 status)
 	struct rfcomm_rls *rls;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p cr %d status 0x%x", s, cr, status);
+	bt_dbg("%p cr %d status 0x%x", s, cr, status);
 
 	hdr = (void *) ptr; ptr += sizeof(*hdr);
 	hdr->addr = __addr(s->initiator, 0);
@@ -981,7 +981,7 @@ static int rfcomm_send_msc(struct rfcomm_session *s, int cr, u8 dlci, u8 v24_sig
 	struct rfcomm_msc *msc;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p cr %d v24 0x%x", s, cr, v24_sig);
+	bt_dbg("%p cr %d v24 0x%x", s, cr, v24_sig);
 
 	hdr = (void *) ptr; ptr += sizeof(*hdr);
 	hdr->addr = __addr(s->initiator, 0);
@@ -1007,7 +1007,7 @@ static int rfcomm_send_fcoff(struct rfcomm_session *s, int cr)
 	struct rfcomm_mcc *mcc;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p cr %d", s, cr);
+	bt_dbg("%p cr %d", s, cr);
 
 	hdr = (void *) ptr; ptr += sizeof(*hdr);
 	hdr->addr = __addr(s->initiator, 0);
@@ -1029,7 +1029,7 @@ static int rfcomm_send_fcon(struct rfcomm_session *s, int cr)
 	struct rfcomm_mcc *mcc;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p cr %d", s, cr);
+	bt_dbg("%p cr %d", s, cr);
 
 	hdr = (void *) ptr; ptr += sizeof(*hdr);
 	hdr->addr = __addr(s->initiator, 0);
@@ -1055,7 +1055,7 @@ static int rfcomm_send_test(struct rfcomm_session *s, int cr, u8 *pattern, int l
 	if (len > 125)
 		return -EINVAL;
 
-	BT_DBG("%p cr %d", s, cr);
+	bt_dbg("%p cr %d", s, cr);
 
 	hdr[0] = __addr(s->initiator, 0);
 	hdr[1] = __ctrl(RFCOMM_UIH, 0);
@@ -1082,7 +1082,7 @@ static int rfcomm_send_credits(struct rfcomm_session *s, u8 addr, u8 credits)
 	struct rfcomm_hdr *hdr;
 	u8 buf[16], *ptr = buf;
 
-	BT_DBG("%p addr %d credits %d", s, addr, credits);
+	bt_dbg("%p addr %d credits %d", s, addr, credits);
 
 	hdr = (void *) ptr; ptr += sizeof(*hdr);
 	hdr->addr = addr;
@@ -1119,7 +1119,7 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr)
 /* ---- RFCOMM frame reception ---- */
 static int rfcomm_recv_ua(struct rfcomm_session *s, u8 dlci)
 {
-	BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+	bt_dbg("session %p state %ld dlci %d", s, s->state, dlci);
 
 	if (dlci) {
 		/* Data channel */
@@ -1177,7 +1177,7 @@ static int rfcomm_recv_dm(struct rfcomm_session *s, u8 dlci)
 {
 	int err = 0;
 
-	BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+	bt_dbg("session %p state %ld dlci %d", s, s->state, dlci);
 
 	if (dlci) {
 		/* Data DLC */
@@ -1207,7 +1207,7 @@ static int rfcomm_recv_disc(struct rfcomm_session *s, u8 dlci)
 {
 	int err = 0;
 
-	BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+	bt_dbg("session %p state %ld dlci %d", s, s->state, dlci);
 
 	if (dlci) {
 		struct rfcomm_dlc *d = rfcomm_dlc_get(s, dlci);
@@ -1244,7 +1244,7 @@ void rfcomm_dlc_accept(struct rfcomm_dlc *d)
 	struct sock *sk = d->session->sock->sk;
 	struct l2cap_conn *conn = l2cap_pi(sk)->chan->conn;
 
-	BT_DBG("dlc %p", d);
+	bt_dbg("dlc %p", d);
 
 	rfcomm_send_ua(d->session, d->dlci);
 
@@ -1285,7 +1285,7 @@ static int rfcomm_recv_sabm(struct rfcomm_session *s, u8 dlci)
 	struct rfcomm_dlc *d;
 	u8 channel;
 
-	BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+	bt_dbg("session %p state %ld dlci %d", s, s->state, dlci);
 
 	if (!dlci) {
 		rfcomm_send_ua(s, 0);
@@ -1326,7 +1326,7 @@ static int rfcomm_apply_pn(struct rfcomm_dlc *d, int cr, struct rfcomm_pn *pn)
 {
 	struct rfcomm_session *s = d->session;
 
-	BT_DBG("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d",
+	bt_dbg("dlc %p state %ld dlci %d mtu %d fc 0x%x credits %d",
 			d, d->state, d->dlci, pn->mtu, pn->flow_ctrl, pn->credits);
 
 	if ((pn->flow_ctrl == 0xf0 && s->cfc != RFCOMM_CFC_DISABLED) ||
@@ -1357,7 +1357,7 @@ static int rfcomm_recv_pn(struct rfcomm_session *s, int cr, struct sk_buff *skb)
 	struct rfcomm_dlc *d;
 	u8 dlci = pn->dlci;
 
-	BT_DBG("session %p state %ld dlci %d", s, s->state, dlci);
+	bt_dbg("session %p state %ld dlci %d", s, s->state, dlci);
 
 	if (!dlci)
 		return 0;
@@ -1417,7 +1417,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	u8 xoff_char = 0;
 	u16 rpn_mask = RFCOMM_RPN_PM_ALL;
 
-	BT_DBG("dlci %d cr %d len 0x%x bitr 0x%x line 0x%x flow 0x%x xonc 0x%x xoffc 0x%x pm 0x%x",
+	bt_dbg("dlci %d cr %d len 0x%x bitr 0x%x line 0x%x flow 0x%x xonc 0x%x xoffc 0x%x pm 0x%x",
 		dlci, cr, len, rpn->bit_rate, rpn->line_settings, rpn->flow_ctrl,
 		rpn->xon_char, rpn->xoff_char, rpn->param_mask);
 
@@ -1442,7 +1442,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_BITRATE)) {
 		bit_rate = rpn->bit_rate;
 		if (bit_rate > RFCOMM_RPN_BR_230400) {
-			BT_DBG("RPN bit rate mismatch 0x%x", bit_rate);
+			bt_dbg("RPN bit rate mismatch 0x%x", bit_rate);
 			bit_rate = RFCOMM_RPN_BR_9600;
 			rpn_mask ^= RFCOMM_RPN_PM_BITRATE;
 		}
@@ -1451,7 +1451,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_DATA)) {
 		data_bits = __get_rpn_data_bits(rpn->line_settings);
 		if (data_bits != RFCOMM_RPN_DATA_8) {
-			BT_DBG("RPN data bits mismatch 0x%x", data_bits);
+			bt_dbg("RPN data bits mismatch 0x%x", data_bits);
 			data_bits = RFCOMM_RPN_DATA_8;
 			rpn_mask ^= RFCOMM_RPN_PM_DATA;
 		}
@@ -1460,7 +1460,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_STOP)) {
 		stop_bits = __get_rpn_stop_bits(rpn->line_settings);
 		if (stop_bits != RFCOMM_RPN_STOP_1) {
-			BT_DBG("RPN stop bits mismatch 0x%x", stop_bits);
+			bt_dbg("RPN stop bits mismatch 0x%x", stop_bits);
 			stop_bits = RFCOMM_RPN_STOP_1;
 			rpn_mask ^= RFCOMM_RPN_PM_STOP;
 		}
@@ -1469,7 +1469,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_PARITY)) {
 		parity = __get_rpn_parity(rpn->line_settings);
 		if (parity != RFCOMM_RPN_PARITY_NONE) {
-			BT_DBG("RPN parity mismatch 0x%x", parity);
+			bt_dbg("RPN parity mismatch 0x%x", parity);
 			parity = RFCOMM_RPN_PARITY_NONE;
 			rpn_mask ^= RFCOMM_RPN_PM_PARITY;
 		}
@@ -1478,7 +1478,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_FLOW)) {
 		flow_ctrl = rpn->flow_ctrl;
 		if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) {
-			BT_DBG("RPN flow ctrl mismatch 0x%x", flow_ctrl);
+			bt_dbg("RPN flow ctrl mismatch 0x%x", flow_ctrl);
 			flow_ctrl = RFCOMM_RPN_FLOW_NONE;
 			rpn_mask ^= RFCOMM_RPN_PM_FLOW;
 		}
@@ -1487,7 +1487,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_XON)) {
 		xon_char = rpn->xon_char;
 		if (xon_char != RFCOMM_RPN_XON_CHAR) {
-			BT_DBG("RPN XON char mismatch 0x%x", xon_char);
+			bt_dbg("RPN XON char mismatch 0x%x", xon_char);
 			xon_char = RFCOMM_RPN_XON_CHAR;
 			rpn_mask ^= RFCOMM_RPN_PM_XON;
 		}
@@ -1496,7 +1496,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
 	if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_XOFF)) {
 		xoff_char = rpn->xoff_char;
 		if (xoff_char != RFCOMM_RPN_XOFF_CHAR) {
-			BT_DBG("RPN XOFF char mismatch 0x%x", xoff_char);
+			bt_dbg("RPN XOFF char mismatch 0x%x", xoff_char);
 			xoff_char = RFCOMM_RPN_XOFF_CHAR;
 			rpn_mask ^= RFCOMM_RPN_PM_XOFF;
 		}
@@ -1514,7 +1514,7 @@ static int rfcomm_recv_rls(struct rfcomm_session *s, int cr, struct sk_buff *skb
 	struct rfcomm_rls *rls = (void *) skb->data;
 	u8 dlci = __get_dlci(rls->dlci);
 
-	BT_DBG("dlci %d cr %d status 0x%x", dlci, cr, rls->status);
+	bt_dbg("dlci %d cr %d status 0x%x", dlci, cr, rls->status);
 
 	if (!cr)
 		return 0;
@@ -1534,7 +1534,7 @@ static int rfcomm_recv_msc(struct rfcomm_session *s, int cr, struct sk_buff *skb
 	struct rfcomm_dlc *d;
 	u8 dlci = __get_dlci(msc->dlci);
 
-	BT_DBG("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig);
+	bt_dbg("dlci %d cr %d v24 0x%x", dlci, cr, msc->v24_sig);
 
 	d = rfcomm_dlc_get(s, dlci);
 	if (!d)
@@ -1573,7 +1573,7 @@ static int rfcomm_recv_mcc(struct rfcomm_session *s, struct sk_buff *skb)
 	type = __get_mcc_type(mcc->type);
 	len  = __get_mcc_len(mcc->len);
 
-	BT_DBG("%p type 0x%x cr %d", s, type, cr);
+	bt_dbg("%p type 0x%x cr %d", s, type, cr);
 
 	skb_pull(skb, 2);
 
@@ -1617,7 +1617,7 @@ static int rfcomm_recv_mcc(struct rfcomm_session *s, struct sk_buff *skb)
 		break;
 
 	default:
-		BT_ERR("Unknown control type 0x%02x", type);
+		bt_err("Unknown control type 0x%02x", type);
 		rfcomm_send_nsc(s, cr, type);
 		break;
 	}
@@ -1628,7 +1628,7 @@ static int rfcomm_recv_data(struct rfcomm_session *s, u8 dlci, int pf, struct sk
 {
 	struct rfcomm_dlc *d;
 
-	BT_DBG("session %p state %ld dlci %d pf %d", s, s->state, dlci, pf);
+	bt_dbg("session %p state %ld dlci %d pf %d", s, s->state, dlci, pf);
 
 	d = rfcomm_dlc_get(s, dlci);
 	if (!d) {
@@ -1670,7 +1670,7 @@ static int rfcomm_recv_frame(struct rfcomm_session *s, struct sk_buff *skb)
 	fcs = *(u8 *)skb_tail_pointer(skb);
 
 	if (__check_fcs(skb->data, type, fcs)) {
-		BT_ERR("bad checksum in packet");
+		bt_err("bad checksum in packet");
 		kfree_skb(skb);
 		return -EILSEQ;
 	}
@@ -1708,7 +1708,7 @@ static int rfcomm_recv_frame(struct rfcomm_session *s, struct sk_buff *skb)
 		break;
 
 	default:
-		BT_ERR("Unknown packet type 0x%02x", type);
+		bt_err("Unknown packet type 0x%02x", type);
 		break;
 	}
 	kfree_skb(skb);
@@ -1722,7 +1722,7 @@ static void rfcomm_process_connect(struct rfcomm_session *s)
 	struct rfcomm_dlc *d;
 	struct list_head *p, *n;
 
-	BT_DBG("session %p state %ld", s, s->state);
+	bt_dbg("session %p state %ld", s, s->state);
 
 	list_for_each_safe(p, n, &s->dlcs) {
 		d = list_entry(p, struct rfcomm_dlc, list);
@@ -1746,7 +1746,7 @@ static inline int rfcomm_process_tx(struct rfcomm_dlc *d)
 	struct sk_buff *skb;
 	int err;
 
-	BT_DBG("dlc %p state %ld cfc %d rx_credits %d tx_credits %d",
+	bt_dbg("dlc %p state %ld cfc %d rx_credits %d tx_credits %d",
 			d, d->state, d->cfc, d->rx_credits, d->tx_credits);
 
 	/* Send pending MSC */
@@ -1794,7 +1794,7 @@ static inline void rfcomm_process_dlcs(struct rfcomm_session *s)
 	struct rfcomm_dlc *d;
 	struct list_head *p, *n;
 
-	BT_DBG("session %p state %ld", s, s->state);
+	bt_dbg("session %p state %ld", s, s->state);
 
 	list_for_each_safe(p, n, &s->dlcs) {
 		d = list_entry(p, struct rfcomm_dlc, list);
@@ -1850,7 +1850,7 @@ static inline void rfcomm_process_rx(struct rfcomm_session *s)
 	struct sock *sk = sock->sk;
 	struct sk_buff *skb;
 
-	BT_DBG("session %p state %ld qlen %d", s, s->state, skb_queue_len(&sk->sk_receive_queue));
+	bt_dbg("session %p state %ld qlen %d", s, s->state, skb_queue_len(&sk->sk_receive_queue));
 
 	/* Get data directly from socket receive queue without copying it. */
 	while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
@@ -1876,7 +1876,7 @@ static inline void rfcomm_accept_connection(struct rfcomm_session *s)
 	if (list_empty(&bt_sk(sock->sk)->accept_q))
 		return;
 
-	BT_DBG("session %p", s);
+	bt_dbg("session %p", s);
 
 	err = kernel_accept(sock, &nsock, O_NONBLOCK);
 	if (err < 0)
@@ -1904,7 +1904,7 @@ static inline void rfcomm_check_connection(struct rfcomm_session *s)
 {
 	struct sock *sk = s->sock->sk;
 
-	BT_DBG("%p state %ld", s, s->state);
+	bt_dbg("%p state %ld", s, s->state);
 
 	switch (sk->sk_state) {
 	case BT_CONNECTED:
@@ -1977,7 +1977,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
 	/* Create socket */
 	err = rfcomm_l2sock_create(&sock);
 	if (err < 0) {
-		BT_ERR("Create socket failed %d", err);
+		bt_err("Create socket failed %d", err);
 		return err;
 	}
 
@@ -1988,7 +1988,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
 	addr.l2_cid    = 0;
 	err = kernel_bind(sock, (struct sockaddr *) &addr, sizeof(addr));
 	if (err < 0) {
-		BT_ERR("Bind failed %d", err);
+		bt_err("Bind failed %d", err);
 		goto failed;
 	}
 
@@ -2001,7 +2001,7 @@ static int rfcomm_add_listener(bdaddr_t *ba)
 	/* Start listening on the socket */
 	err = kernel_listen(sock, 10);
 	if (err) {
-		BT_ERR("Listen failed %d", err);
+		bt_err("Listen failed %d", err);
 		goto failed;
 	}
 
@@ -2022,7 +2022,7 @@ static void rfcomm_kill_listener(void)
 	struct rfcomm_session *s;
 	struct list_head *p, *n;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	list_for_each_safe(p, n, &session_list) {
 		s = list_entry(p, struct rfcomm_session, list);
@@ -2032,7 +2032,7 @@ static void rfcomm_kill_listener(void)
 
 static int rfcomm_run(void *unused)
 {
-	BT_DBG("");
+	bt_dbg("");
 
 	set_user_nice(current, -10);
 
@@ -2063,7 +2063,7 @@ static void rfcomm_security_cfm(struct hci_conn *conn, u8 status, u8 encrypt)
 	struct rfcomm_dlc *d;
 	struct list_head *p, *n;
 
-	BT_DBG("conn %p status 0x%02x encrypt 0x%02x", conn, status, encrypt);
+	bt_dbg("conn %p status 0x%02x encrypt 0x%02x", conn, status, encrypt);
 
 	s = rfcomm_session_get(&conn->hdev->bdaddr, &conn->dst);
 	if (!s)
@@ -2169,7 +2169,7 @@ static int __init rfcomm_init(void)
 		rfcomm_dlc_debugfs = debugfs_create_file("rfcomm_dlc", 0444,
 				bt_debugfs, NULL, &rfcomm_dlc_debugfs_fops);
 		if (!rfcomm_dlc_debugfs)
-			BT_ERR("Failed to create RFCOMM debug file");
+			bt_err("Failed to create RFCOMM debug file");
 	}
 
 	err = rfcomm_init_ttys();
@@ -2180,7 +2180,7 @@ static int __init rfcomm_init(void)
 	if (err < 0)
 		goto cleanup;
 
-	BT_INFO("RFCOMM ver %s", VERSION);
+	bt_info("RFCOMM ver %s", VERSION);
 
 	return 0;
 
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 8f01e6b..776d286 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -87,7 +87,7 @@ static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
 	if (!sk)
 		return;
 
-	BT_DBG("dlc %p state %ld err %d", d, d->state, err);
+	bt_dbg("dlc %p state %ld err %d", d, d->state, err);
 
 	local_irq_save(flags);
 	bh_lock_sock(sk);
@@ -171,7 +171,7 @@ static void rfcomm_sock_destruct(struct sock *sk)
 {
 	struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
 
-	BT_DBG("sk %p dlc %p", sk, d);
+	bt_dbg("sk %p dlc %p", sk, d);
 
 	skb_queue_purge(&sk->sk_receive_queue);
 	skb_queue_purge(&sk->sk_write_queue);
@@ -191,7 +191,7 @@ static void rfcomm_sock_cleanup_listen(struct sock *parent)
 {
 	struct sock *sk;
 
-	BT_DBG("parent %p", parent);
+	bt_dbg("parent %p", parent);
 
 	/* Close not yet accepted dlcs */
 	while ((sk = bt_accept_dequeue(parent, NULL))) {
@@ -211,7 +211,7 @@ static void rfcomm_sock_kill(struct sock *sk)
 	if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
 		return;
 
-	BT_DBG("sk %p state %d refcnt %d", sk, sk->sk_state, atomic_read(&sk->sk_refcnt));
+	bt_dbg("sk %p state %d refcnt %d", sk, sk->sk_state, atomic_read(&sk->sk_refcnt));
 
 	/* Kill poor orphan */
 	bt_sock_unlink(&rfcomm_sk_list, sk);
@@ -223,7 +223,7 @@ static void __rfcomm_sock_close(struct sock *sk)
 {
 	struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
 
-	BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
+	bt_dbg("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
 
 	switch (sk->sk_state) {
 	case BT_LISTEN:
@@ -256,7 +256,7 @@ static void rfcomm_sock_init(struct sock *sk, struct sock *parent)
 {
 	struct rfcomm_pinfo *pi = rfcomm_pi(sk);
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (parent) {
 		sk->sk_type = parent->sk_type;
@@ -318,7 +318,7 @@ static struct sock *rfcomm_sock_alloc(struct net *net, struct socket *sock, int
 
 	bt_sock_link(&rfcomm_sk_list, sk);
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 	return sk;
 }
 
@@ -327,7 +327,7 @@ static int rfcomm_sock_create(struct net *net, struct socket *sock,
 {
 	struct sock *sk;
 
-	BT_DBG("sock %p", sock);
+	bt_dbg("sock %p", sock);
 
 	sock->state = SS_UNCONNECTED;
 
@@ -350,7 +350,7 @@ static int rfcomm_sock_bind(struct socket *sock, struct sockaddr *addr, int addr
 	struct sock *sk = sock->sk;
 	int err = 0;
 
-	BT_DBG("sk %p %s", sk, batostr(&sa->rc_bdaddr));
+	bt_dbg("sk %p %s", sk, batostr(&sa->rc_bdaddr));
 
 	if (!addr || addr->sa_family != AF_BLUETOOTH)
 		return -EINVAL;
@@ -392,7 +392,7 @@ static int rfcomm_sock_connect(struct socket *sock, struct sockaddr *addr, int a
 	struct rfcomm_dlc *d = rfcomm_pi(sk)->dlc;
 	int err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (alen < sizeof(struct sockaddr_rc) ||
 	    addr->sa_family != AF_BLUETOOTH)
@@ -432,7 +432,7 @@ static int rfcomm_sock_listen(struct socket *sock, int backlog)
 	struct sock *sk = sock->sk;
 	int err = 0;
 
-	BT_DBG("sk %p backlog %d", sk, backlog);
+	bt_dbg("sk %p backlog %d", sk, backlog);
 
 	lock_sock(sk);
 
@@ -497,7 +497,7 @@ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int f
 
 	timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
 
-	BT_DBG("sk %p timeo %ld", sk, timeo);
+	bt_dbg("sk %p timeo %ld", sk, timeo);
 
 	/* Wait for an incoming connection. (wake-one). */
 	add_wait_queue_exclusive(sk_sleep(sk), &wait);
@@ -530,7 +530,7 @@ static int rfcomm_sock_accept(struct socket *sock, struct socket *newsock, int f
 
 	newsock->state = SS_CONNECTED;
 
-	BT_DBG("new socket %p", nsk);
+	bt_dbg("new socket %p", nsk);
 
 done:
 	release_sock(sk);
@@ -542,7 +542,7 @@ static int rfcomm_sock_getname(struct socket *sock, struct sockaddr *addr, int *
 	struct sockaddr_rc *sa = (struct sockaddr_rc *) addr;
 	struct sock *sk = sock->sk;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	sa->rc_family  = AF_BLUETOOTH;
 	sa->rc_channel = rfcomm_pi(sk)->channel;
@@ -572,7 +572,7 @@ static int rfcomm_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
 	if (sk->sk_shutdown & SEND_SHUTDOWN)
 		return -EPIPE;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	lock_sock(sk);
 
@@ -645,7 +645,7 @@ static int rfcomm_sock_setsockopt_old(struct socket *sock, int optname, char __u
 	int err = 0;
 	u32 opt;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	lock_sock(sk);
 
@@ -683,7 +683,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
 	size_t len;
 	u32 opt;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (level == SOL_RFCOMM)
 		return rfcomm_sock_setsockopt_old(sock, optname, optval, optlen);
@@ -747,7 +747,7 @@ static int rfcomm_sock_getsockopt_old(struct socket *sock, int optname, char __u
 	int len, err = 0;
 	u32 opt;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (get_user(len, optlen))
 		return -EFAULT;
@@ -811,7 +811,7 @@ static int rfcomm_sock_getsockopt(struct socket *sock, int level, int optname, c
 	struct bt_security sec;
 	int len, err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (level == SOL_RFCOMM)
 		return rfcomm_sock_getsockopt_old(sock, optname, optval, optlen);
@@ -864,7 +864,7 @@ static int rfcomm_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned lon
 	struct sock *sk __maybe_unused = sock->sk;
 	int err;
 
-	BT_DBG("sk %p cmd %x arg %lx", sk, cmd, arg);
+	bt_dbg("sk %p cmd %x arg %lx", sk, cmd, arg);
 
 	err = bt_sock_ioctl(sock, cmd, arg);
 
@@ -886,7 +886,7 @@ static int rfcomm_sock_shutdown(struct socket *sock, int how)
 	struct sock *sk = sock->sk;
 	int err = 0;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -908,7 +908,7 @@ static int rfcomm_sock_release(struct socket *sock)
 	struct sock *sk = sock->sk;
 	int err;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -930,7 +930,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
 	bdaddr_t src, dst;
 	int result = 0;
 
-	BT_DBG("session %p channel %d", s, channel);
+	bt_dbg("session %p channel %d", s, channel);
 
 	rfcomm_session_getaddr(s, &src, &dst);
 
@@ -943,7 +943,7 @@ int rfcomm_connect_ind(struct rfcomm_session *s, u8 channel, struct rfcomm_dlc *
 
 	/* Check for backlog size */
 	if (sk_acceptq_is_full(parent)) {
-		BT_DBG("backlog full %d", parent->sk_ack_backlog);
+		bt_dbg("backlog full %d", parent->sk_ack_backlog);
 		goto done;
 	}
 
@@ -1047,15 +1047,15 @@ int __init rfcomm_init_sockets(void)
 		rfcomm_sock_debugfs = debugfs_create_file("rfcomm", 0444,
 				bt_debugfs, NULL, &rfcomm_sock_debugfs_fops);
 		if (!rfcomm_sock_debugfs)
-			BT_ERR("Failed to create RFCOMM debug file");
+			bt_err("Failed to create RFCOMM debug file");
 	}
 
-	BT_INFO("RFCOMM socket layer initialized");
+	bt_info("RFCOMM socket layer initialized");
 
 	return 0;
 
 error:
-	BT_ERR("RFCOMM socket layer registration failed");
+	bt_err("RFCOMM socket layer registration failed");
 	proto_unregister(&rfcomm_proto);
 	return err;
 }
@@ -1065,7 +1065,7 @@ void __exit rfcomm_cleanup_sockets(void)
 	debugfs_remove(rfcomm_sock_debugfs);
 
 	if (bt_sock_unregister(BTPROTO_RFCOMM) < 0)
-		BT_ERR("RFCOMM socket layer unregistration failed");
+		bt_err("RFCOMM socket layer unregistration failed");
 
 	proto_unregister(&rfcomm_proto);
 }
diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
index c258796..313441d 100644
--- a/net/bluetooth/rfcomm/tty.c
+++ b/net/bluetooth/rfcomm/tty.c
@@ -88,7 +88,7 @@ static void rfcomm_dev_destruct(struct rfcomm_dev *dev)
 {
 	struct rfcomm_dlc *dlc = dev->dlc;
 
-	BT_DBG("dev %p dlc %p", dev, dlc);
+	bt_dbg("dev %p dlc %p", dev, dlc);
 
 	/* Refcount should only hit zero when called from rfcomm_dev_del()
 	   which will have taken us off the list. Everything else are
@@ -201,7 +201,7 @@ static int rfcomm_dev_add(struct rfcomm_dev_req *req, struct rfcomm_dlc *dlc)
 	struct list_head *head = &rfcomm_dev_list, *p;
 	int err = 0;
 
-	BT_DBG("id %d channel %d", req->dev_id, req->channel);
+	bt_dbg("id %d channel %d", req->dev_id, req->channel);
 
 	dev = kzalloc(sizeof(struct rfcomm_dev), GFP_KERNEL);
 	if (!dev)
@@ -310,10 +310,10 @@ out:
 	dev_set_drvdata(dev->tty_dev, dev);
 
 	if (device_create_file(dev->tty_dev, &dev_attr_address) < 0)
-		BT_ERR("Failed to create address attribute");
+		bt_err("Failed to create address attribute");
 
 	if (device_create_file(dev->tty_dev, &dev_attr_channel) < 0)
-		BT_ERR("Failed to create channel attribute");
+		bt_err("Failed to create channel attribute");
 
 	return dev->id;
 
@@ -324,7 +324,7 @@ free:
 
 static void rfcomm_dev_del(struct rfcomm_dev *dev)
 {
-	BT_DBG("dev %p", dev);
+	bt_dbg("dev %p", dev);
 
 	BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
 
@@ -388,7 +388,7 @@ static int rfcomm_create_dev(struct sock *sk, void __user *arg)
 	if (copy_from_user(&req, arg, sizeof(req)))
 		return -EFAULT;
 
-	BT_DBG("sk %p dev_id %d flags 0x%x", sk, req.dev_id, req.flags);
+	bt_dbg("sk %p dev_id %d flags 0x%x", sk, req.dev_id, req.flags);
 
 	if (req.flags != NOCAP_FLAGS && !capable(CAP_NET_ADMIN))
 		return -EPERM;
@@ -429,7 +429,7 @@ static int rfcomm_release_dev(void __user *arg)
 	if (copy_from_user(&req, arg, sizeof(req)))
 		return -EFAULT;
 
-	BT_DBG("dev_id %d flags 0x%x", req.dev_id, req.flags);
+	bt_dbg("dev_id %d flags 0x%x", req.dev_id, req.flags);
 
 	dev = rfcomm_dev_get(req.dev_id);
 	if (!dev)
@@ -461,7 +461,7 @@ static int rfcomm_get_dev_list(void __user *arg)
 	int n = 0, size, err;
 	u16 dev_num;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	if (get_user(dev_num, (u16 __user *) arg))
 		return -EFAULT;
@@ -510,7 +510,7 @@ static int rfcomm_get_dev_info(void __user *arg)
 	struct rfcomm_dev_info di;
 	int err = 0;
 
-	BT_DBG("");
+	bt_dbg("");
 
 	if (copy_from_user(&di, arg, sizeof(di)))
 		return -EFAULT;
@@ -534,7 +534,7 @@ static int rfcomm_get_dev_info(void __user *arg)
 
 int rfcomm_dev_ioctl(struct sock *sk, unsigned int cmd, void __user *arg)
 {
-	BT_DBG("cmd %d arg %p", cmd, arg);
+	bt_dbg("cmd %d arg %p", cmd, arg);
 
 	switch (cmd) {
 	case RFCOMMCREATEDEV:
@@ -570,7 +570,7 @@ static void rfcomm_dev_data_ready(struct rfcomm_dlc *dlc, struct sk_buff *skb)
 		return;
 	}
 
-	BT_DBG("dlc %p tty %p len %d", dlc, tty, skb->len);
+	bt_dbg("dlc %p tty %p len %d", dlc, tty, skb->len);
 
 	tty_insert_flip_string(tty, skb->data, skb->len);
 	tty_flip_buffer_push(tty);
@@ -584,7 +584,7 @@ static void rfcomm_dev_state_change(struct rfcomm_dlc *dlc, int err)
 	if (!dev)
 		return;
 
-	BT_DBG("dlc %p dev %p err %d", dlc, dev, err);
+	bt_dbg("dlc %p dev %p err %d", dlc, dev, err);
 
 	dev->err = err;
 	wake_up_interruptible(&dev->wait);
@@ -620,7 +620,7 @@ static void rfcomm_dev_modem_status(struct rfcomm_dlc *dlc, u8 v24_sig)
 	if (!dev)
 		return;
 
-	BT_DBG("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig);
+	bt_dbg("dlc %p dev %p v24_sig 0x%02x", dlc, dev, v24_sig);
 
 	if ((dev->modem_status & TIOCM_CD) && !(v24_sig & RFCOMM_V24_DV)) {
 		if (dev->tty && !C_CLOCAL(dev->tty))
@@ -642,7 +642,7 @@ static void rfcomm_tty_wakeup(unsigned long arg)
 	if (!tty)
 		return;
 
-	BT_DBG("dev %p tty %p", dev, tty);
+	bt_dbg("dev %p tty %p", dev, tty);
 	tty_wakeup(tty);
 }
 
@@ -655,7 +655,7 @@ static void rfcomm_tty_copy_pending(struct rfcomm_dev *dev)
 	if (!tty)
 		return;
 
-	BT_DBG("dev %p tty %p", dev, tty);
+	bt_dbg("dev %p tty %p", dev, tty);
 
 	rfcomm_dlc_lock(dev->dlc);
 
@@ -679,7 +679,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
 
 	id = tty->index;
 
-	BT_DBG("tty %p id %d", tty, id);
+	bt_dbg("tty %p id %d", tty, id);
 
 	/* We don't leak this refcount. For reasons which are not entirely
 	   clear, the TTY layer will call our ->close() method even if the
@@ -689,7 +689,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
 	if (!dev)
 		return -ENODEV;
 
-	BT_DBG("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst),
+	bt_dbg("dev %p dst %s channel %d opened %d", dev, batostr(&dev->dst),
 				dev->channel, atomic_read(&dev->opened));
 
 	if (atomic_inc_return(&dev->opened) > 1)
@@ -751,7 +751,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
 	if (!dev)
 		return;
 
-	BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
+	bt_dbg("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
 						atomic_read(&dev->opened));
 
 	if (atomic_dec_and_test(&dev->opened)) {
@@ -788,7 +788,7 @@ static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, in
 	struct sk_buff *skb;
 	int err = 0, sent = 0, size;
 
-	BT_DBG("tty %p count %d", tty, count);
+	bt_dbg("tty %p count %d", tty, count);
 
 	while (count) {
 		size = min_t(uint, count, dlc->mtu);
@@ -820,7 +820,7 @@ static int rfcomm_tty_write_room(struct tty_struct *tty)
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 	int room;
 
-	BT_DBG("tty %p", tty);
+	bt_dbg("tty %p", tty);
 
 	if (!dev || !dev->dlc)
 		return 0;
@@ -834,39 +834,39 @@ static int rfcomm_tty_write_room(struct tty_struct *tty)
 
 static int rfcomm_tty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
 {
-	BT_DBG("tty %p cmd 0x%02x", tty, cmd);
+	bt_dbg("tty %p cmd 0x%02x", tty, cmd);
 
 	switch (cmd) {
 	case TCGETS:
-		BT_DBG("TCGETS is not supported");
+		bt_dbg("TCGETS is not supported");
 		return -ENOIOCTLCMD;
 
 	case TCSETS:
-		BT_DBG("TCSETS is not supported");
+		bt_dbg("TCSETS is not supported");
 		return -ENOIOCTLCMD;
 
 	case TIOCMIWAIT:
-		BT_DBG("TIOCMIWAIT");
+		bt_dbg("TIOCMIWAIT");
 		break;
 
 	case TIOCGSERIAL:
-		BT_ERR("TIOCGSERIAL is not supported");
+		bt_err("TIOCGSERIAL is not supported");
 		return -ENOIOCTLCMD;
 
 	case TIOCSSERIAL:
-		BT_ERR("TIOCSSERIAL is not supported");
+		bt_err("TIOCSSERIAL is not supported");
 		return -ENOIOCTLCMD;
 
 	case TIOCSERGSTRUCT:
-		BT_ERR("TIOCSERGSTRUCT is not supported");
+		bt_err("TIOCSERGSTRUCT is not supported");
 		return -ENOIOCTLCMD;
 
 	case TIOCSERGETLSR:
-		BT_ERR("TIOCSERGETLSR is not supported");
+		bt_err("TIOCSERGETLSR is not supported");
 		return -ENOIOCTLCMD;
 
 	case TIOCSERCONFIG:
-		BT_ERR("TIOCSERCONFIG is not supported");
+		bt_err("TIOCSERCONFIG is not supported");
 		return -ENOIOCTLCMD;
 
 	default:
@@ -888,52 +888,52 @@ static void rfcomm_tty_set_termios(struct tty_struct *tty, struct ktermios *old)
 
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
-	BT_DBG("tty %p termios %p", tty, old);
+	bt_dbg("tty %p termios %p", tty, old);
 
 	if (!dev || !dev->dlc || !dev->dlc->session)
 		return;
 
 	/* Handle turning off CRTSCTS */
 	if ((old->c_cflag & CRTSCTS) && !(new->c_cflag & CRTSCTS))
-		BT_DBG("Turning off CRTSCTS unsupported");
+		bt_dbg("Turning off CRTSCTS unsupported");
 
 	/* Parity on/off and when on, odd/even */
 	if (((old->c_cflag & PARENB) != (new->c_cflag & PARENB)) ||
 			((old->c_cflag & PARODD) != (new->c_cflag & PARODD))) {
 		changes |= RFCOMM_RPN_PM_PARITY;
-		BT_DBG("Parity change detected.");
+		bt_dbg("Parity change detected.");
 	}
 
 	/* Mark and space parity are not supported! */
 	if (new->c_cflag & PARENB) {
 		if (new->c_cflag & PARODD) {
-			BT_DBG("Parity is ODD");
+			bt_dbg("Parity is ODD");
 			parity = RFCOMM_RPN_PARITY_ODD;
 		} else {
-			BT_DBG("Parity is EVEN");
+			bt_dbg("Parity is EVEN");
 			parity = RFCOMM_RPN_PARITY_EVEN;
 		}
 	} else {
-		BT_DBG("Parity is OFF");
+		bt_dbg("Parity is OFF");
 		parity = RFCOMM_RPN_PARITY_NONE;
 	}
 
 	/* Setting the x_on / x_off characters */
 	if (old->c_cc[VSTOP] != new->c_cc[VSTOP]) {
-		BT_DBG("XOFF custom");
+		bt_dbg("XOFF custom");
 		x_on = new->c_cc[VSTOP];
 		changes |= RFCOMM_RPN_PM_XON;
 	} else {
-		BT_DBG("XOFF default");
+		bt_dbg("XOFF default");
 		x_on = RFCOMM_RPN_XON_CHAR;
 	}
 
 	if (old->c_cc[VSTART] != new->c_cc[VSTART]) {
-		BT_DBG("XON custom");
+		bt_dbg("XON custom");
 		x_off = new->c_cc[VSTART];
 		changes |= RFCOMM_RPN_PM_XOFF;
 	} else {
-		BT_DBG("XON default");
+		bt_dbg("XON default");
 		x_off = RFCOMM_RPN_XOFF_CHAR;
 	}
 
@@ -1020,7 +1020,7 @@ static void rfcomm_tty_throttle(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
-	BT_DBG("tty %p dev %p", tty, dev);
+	bt_dbg("tty %p dev %p", tty, dev);
 
 	rfcomm_dlc_throttle(dev->dlc);
 }
@@ -1029,7 +1029,7 @@ static void rfcomm_tty_unthrottle(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
-	BT_DBG("tty %p dev %p", tty, dev);
+	bt_dbg("tty %p dev %p", tty, dev);
 
 	rfcomm_dlc_unthrottle(dev->dlc);
 }
@@ -1038,7 +1038,7 @@ static int rfcomm_tty_chars_in_buffer(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
-	BT_DBG("tty %p dev %p", tty, dev);
+	bt_dbg("tty %p dev %p", tty, dev);
 
 	if (!dev || !dev->dlc)
 		return 0;
@@ -1053,7 +1053,7 @@ static void rfcomm_tty_flush_buffer(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
-	BT_DBG("tty %p dev %p", tty, dev);
+	bt_dbg("tty %p dev %p", tty, dev);
 
 	if (!dev || !dev->dlc)
 		return;
@@ -1064,19 +1064,19 @@ static void rfcomm_tty_flush_buffer(struct tty_struct *tty)
 
 static void rfcomm_tty_send_xchar(struct tty_struct *tty, char ch)
 {
-	BT_DBG("tty %p ch %c", tty, ch);
+	bt_dbg("tty %p ch %c", tty, ch);
 }
 
 static void rfcomm_tty_wait_until_sent(struct tty_struct *tty, int timeout)
 {
-	BT_DBG("tty %p timeout %d", tty, timeout);
+	bt_dbg("tty %p timeout %d", tty, timeout);
 }
 
 static void rfcomm_tty_hangup(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
-	BT_DBG("tty %p dev %p", tty, dev);
+	bt_dbg("tty %p dev %p", tty, dev);
 
 	if (!dev)
 		return;
@@ -1095,7 +1095,7 @@ static int rfcomm_tty_tiocmget(struct tty_struct *tty)
 {
 	struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
 
-	BT_DBG("tty %p dev %p", tty, dev);
+	bt_dbg("tty %p dev %p", tty, dev);
 
 	return dev->modem_status;
 }
@@ -1106,7 +1106,7 @@ static int rfcomm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigne
 	struct rfcomm_dlc *dlc = dev->dlc;
 	u8 v24_sig;
 
-	BT_DBG("tty %p dev %p set 0x%02x clear 0x%02x", tty, dev, set, clear);
+	bt_dbg("tty %p dev %p set 0x%02x clear 0x%02x", tty, dev, set, clear);
 
 	rfcomm_dlc_get_modem_status(dlc, &v24_sig);
 
@@ -1173,12 +1173,12 @@ int __init rfcomm_init_ttys(void)
 	tty_set_operations(rfcomm_tty_driver, &rfcomm_ops);
 
 	if (tty_register_driver(rfcomm_tty_driver)) {
-		BT_ERR("Can't register RFCOMM TTY driver");
+		bt_err("Can't register RFCOMM TTY driver");
 		put_tty_driver(rfcomm_tty_driver);
 		return -1;
 	}
 
-	BT_INFO("RFCOMM TTY layer initialized");
+	bt_info("RFCOMM TTY layer initialized");
 
 	return 0;
 }
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 4c3621b..db0bc64 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -71,7 +71,7 @@ static void sco_sock_timeout(unsigned long arg)
 {
 	struct sock *sk = (struct sock *) arg;
 
-	BT_DBG("sock %p state %d", sk, sk->sk_state);
+	bt_dbg("sock %p state %d", sk, sk->sk_state);
 
 	bh_lock_sock(sk);
 	sk->sk_err = ETIMEDOUT;
@@ -84,13 +84,13 @@ static void sco_sock_timeout(unsigned long arg)
 
 static void sco_sock_set_timer(struct sock *sk, long timeout)
 {
-	BT_DBG("sock %p state %d timeout %ld", sk, sk->sk_state, timeout);
+	bt_dbg("sock %p state %d timeout %ld", sk, sk->sk_state, timeout);
 	sk_reset_timer(sk, &sk->sk_timer, jiffies + timeout);
 }
 
 static void sco_sock_clear_timer(struct sock *sk)
 {
-	BT_DBG("sock %p state %d", sk, sk->sk_state);
+	bt_dbg("sock %p state %d", sk, sk->sk_state);
 	sk_stop_timer(sk, &sk->sk_timer);
 }
 
@@ -120,7 +120,7 @@ static struct sco_conn *sco_conn_add(struct hci_conn *hcon, __u8 status)
 	else
 		conn->mtu = 60;
 
-	BT_DBG("hcon %p conn %p", hcon, conn);
+	bt_dbg("hcon %p conn %p", hcon, conn);
 
 	return conn;
 }
@@ -142,7 +142,7 @@ static int sco_conn_del(struct hci_conn *hcon, int err)
 	if (!conn)
 		return 0;
 
-	BT_DBG("hcon %p conn %p, err %d", hcon, conn, err);
+	bt_dbg("hcon %p conn %p, err %d", hcon, conn, err);
 
 	/* Kill socket */
 	sk = sco_chan_get(conn);
@@ -182,7 +182,7 @@ static int sco_connect(struct sock *sk)
 	struct hci_dev  *hdev;
 	int err, type;
 
-	BT_DBG("%s -> %s", batostr(src), batostr(dst));
+	bt_dbg("%s -> %s", batostr(src), batostr(dst));
 
 	hdev = hci_get_route(dst, src);
 	if (!hdev)
@@ -239,7 +239,7 @@ static inline int sco_send_frame(struct sock *sk, struct msghdr *msg, int len)
 	if (len > conn->mtu)
 		return -EINVAL;
 
-	BT_DBG("sk %p len %d", sk, len);
+	bt_dbg("sk %p len %d", sk, len);
 
 	count = min_t(unsigned int, conn->mtu, len);
 	skb = bt_skb_send_alloc(sk, count,
@@ -264,7 +264,7 @@ static inline void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)
 	if (!sk)
 		goto drop;
 
-	BT_DBG("sk %p len %d", sk, skb->len);
+	bt_dbg("sk %p len %d", sk, skb->len);
 
 	if (sk->sk_state != BT_CONNECTED)
 		goto drop;
@@ -320,7 +320,7 @@ static struct sock *sco_get_sock_listen(bdaddr_t *src)
 
 static void sco_sock_destruct(struct sock *sk)
 {
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	skb_queue_purge(&sk->sk_receive_queue);
 	skb_queue_purge(&sk->sk_write_queue);
@@ -330,7 +330,7 @@ static void sco_sock_cleanup_listen(struct sock *parent)
 {
 	struct sock *sk;
 
-	BT_DBG("parent %p", parent);
+	bt_dbg("parent %p", parent);
 
 	/* Close not yet accepted channels */
 	while ((sk = bt_accept_dequeue(parent, NULL))) {
@@ -350,7 +350,7 @@ static void sco_sock_kill(struct sock *sk)
 	if (!sock_flag(sk, SOCK_ZAPPED) || sk->sk_socket)
 		return;
 
-	BT_DBG("sk %p state %d", sk, sk->sk_state);
+	bt_dbg("sk %p state %d", sk, sk->sk_state);
 
 	/* Kill poor orphan */
 	bt_sock_unlink(&sco_sk_list, sk);
@@ -360,7 +360,7 @@ static void sco_sock_kill(struct sock *sk)
 
 static void __sco_sock_close(struct sock *sk)
 {
-	BT_DBG("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
+	bt_dbg("sk %p state %d socket %p", sk, sk->sk_state, sk->sk_socket);
 
 	switch (sk->sk_state) {
 	case BT_LISTEN:
@@ -401,7 +401,7 @@ static void sco_sock_close(struct sock *sk)
 
 static void sco_sock_init(struct sock *sk, struct sock *parent)
 {
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (parent)
 		sk->sk_type = parent->sk_type;
@@ -443,7 +443,7 @@ static int sco_sock_create(struct net *net, struct socket *sock, int protocol,
 {
 	struct sock *sk;
 
-	BT_DBG("sock %p", sock);
+	bt_dbg("sock %p", sock);
 
 	sock->state = SS_UNCONNECTED;
 
@@ -467,7 +467,7 @@ static int sco_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
 	bdaddr_t *src = &sa->sco_bdaddr;
 	int err = 0;
 
-	BT_DBG("sk %p %s", sk, batostr(&sa->sco_bdaddr));
+	bt_dbg("sk %p %s", sk, batostr(&sa->sco_bdaddr));
 
 	if (!addr || addr->sa_family != AF_BLUETOOTH)
 		return -EINVAL;
@@ -503,7 +503,7 @@ static int sco_sock_connect(struct socket *sock, struct sockaddr *addr, int alen
 	int err = 0;
 
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (alen < sizeof(struct sockaddr_sco) ||
 	    addr->sa_family != AF_BLUETOOTH)
@@ -537,7 +537,7 @@ static int sco_sock_listen(struct socket *sock, int backlog)
 	struct sock *sk = sock->sk;
 	int err = 0;
 
-	BT_DBG("sk %p backlog %d", sk, backlog);
+	bt_dbg("sk %p backlog %d", sk, backlog);
 
 	lock_sock(sk);
 
@@ -571,7 +571,7 @@ static int sco_sock_accept(struct socket *sock, struct socket *newsock, int flag
 
 	timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
 
-	BT_DBG("sk %p timeo %ld", sk, timeo);
+	bt_dbg("sk %p timeo %ld", sk, timeo);
 
 	/* Wait for an incoming connection. (wake-one). */
 	add_wait_queue_exclusive(sk_sleep(sk), &wait);
@@ -604,7 +604,7 @@ static int sco_sock_accept(struct socket *sock, struct socket *newsock, int flag
 
 	newsock->state = SS_CONNECTED;
 
-	BT_DBG("new socket %p", ch);
+	bt_dbg("new socket %p", ch);
 
 done:
 	release_sock(sk);
@@ -616,7 +616,7 @@ static int sco_sock_getname(struct socket *sock, struct sockaddr *addr, int *len
 	struct sockaddr_sco *sa = (struct sockaddr_sco *) addr;
 	struct sock *sk = sock->sk;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	addr->sa_family = AF_BLUETOOTH;
 	*len = sizeof(struct sockaddr_sco);
@@ -635,7 +635,7 @@ static int sco_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
 	struct sock *sk = sock->sk;
 	int err;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	err = sock_error(sk);
 	if (err)
@@ -660,7 +660,7 @@ static int sco_sock_setsockopt(struct socket *sock, int level, int optname, char
 	struct sock *sk = sock->sk;
 	int err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	lock_sock(sk);
 
@@ -681,7 +681,7 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user
 	struct sco_conninfo cinfo;
 	int len, err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (get_user(len, optlen))
 		return -EFAULT;
@@ -697,7 +697,7 @@ static int sco_sock_getsockopt_old(struct socket *sock, int optname, char __user
 
 		opts.mtu = sco_pi(sk)->conn->mtu;
 
-		BT_DBG("mtu %d", opts.mtu);
+		bt_dbg("mtu %d", opts.mtu);
 
 		len = min_t(unsigned int, len, sizeof(opts));
 		if (copy_to_user(optval, (char *)&opts, len))
@@ -735,7 +735,7 @@ static int sco_sock_getsockopt(struct socket *sock, int level, int optname, char
 	struct sock *sk = sock->sk;
 	int len, err = 0;
 
-	BT_DBG("sk %p", sk);
+	bt_dbg("sk %p", sk);
 
 	if (level == SOL_SCO)
 		return sco_sock_getsockopt_old(sock, optname, optval, optlen);
@@ -760,7 +760,7 @@ static int sco_sock_shutdown(struct socket *sock, int how)
 	struct sock *sk = sock->sk;
 	int err = 0;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -784,7 +784,7 @@ static int sco_sock_release(struct socket *sock)
 	struct sock *sk = sock->sk;
 	int err = 0;
 
-	BT_DBG("sock %p, sk %p", sock, sk);
+	bt_dbg("sock %p, sk %p", sock, sk);
 
 	if (!sk)
 		return 0;
@@ -804,7 +804,7 @@ static int sco_sock_release(struct socket *sock)
 
 static void __sco_chan_add(struct sco_conn *conn, struct sock *sk, struct sock *parent)
 {
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	sco_pi(sk)->conn = conn;
 	conn->sk = sk;
@@ -821,7 +821,7 @@ static void sco_chan_del(struct sock *sk, int err)
 
 	conn = sco_pi(sk)->conn;
 
-	BT_DBG("sk %p, conn %p, err %d", sk, conn, err);
+	bt_dbg("sk %p, conn %p, err %d", sk, conn, err);
 
 	if (conn) {
 		sco_conn_lock(conn);
@@ -845,7 +845,7 @@ static void sco_conn_ready(struct sco_conn *conn)
 	struct sock *parent;
 	struct sock *sk = conn->sk;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	sco_conn_lock(conn);
 
@@ -899,7 +899,7 @@ static int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type)
 	if (type != SCO_LINK && type != ESCO_LINK)
 		return -EINVAL;
 
-	BT_DBG("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
+	bt_dbg("hdev %s, bdaddr %s", hdev->name, batostr(bdaddr));
 
 	/* Find listening sockets */
 	read_lock(&sco_sk_list.lock);
@@ -920,7 +920,7 @@ static int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 type)
 
 static int sco_connect_cfm(struct hci_conn *hcon, __u8 status)
 {
-	BT_DBG("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
+	bt_dbg("hcon %p bdaddr %s status %d", hcon, batostr(&hcon->dst), status);
 
 	if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
 		return -EINVAL;
@@ -939,7 +939,7 @@ static int sco_connect_cfm(struct hci_conn *hcon, __u8 status)
 
 static int sco_disconn_cfm(struct hci_conn *hcon, __u8 reason)
 {
-	BT_DBG("hcon %p reason %d", hcon, reason);
+	bt_dbg("hcon %p reason %d", hcon, reason);
 
 	if (hcon->type != SCO_LINK && hcon->type != ESCO_LINK)
 		return -EINVAL;
@@ -956,7 +956,7 @@ static int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb)
 	if (!conn)
 		goto drop;
 
-	BT_DBG("conn %p len %d", conn, skb->len);
+	bt_dbg("conn %p len %d", conn, skb->len);
 
 	if (skb->len) {
 		sco_recv_frame(conn, skb);
@@ -1044,13 +1044,13 @@ int __init sco_init(void)
 
 	err = bt_sock_register(BTPROTO_SCO, &sco_sock_family_ops);
 	if (err < 0) {
-		BT_ERR("SCO socket registration failed");
+		bt_err("SCO socket registration failed");
 		goto error;
 	}
 
 	err = hci_register_proto(&sco_hci_proto);
 	if (err < 0) {
-		BT_ERR("SCO protocol registration failed");
+		bt_err("SCO protocol registration failed");
 		bt_sock_unregister(BTPROTO_SCO);
 		goto error;
 	}
@@ -1059,10 +1059,10 @@ int __init sco_init(void)
 		sco_debugfs = debugfs_create_file("sco", 0444,
 					bt_debugfs, NULL, &sco_debugfs_fops);
 		if (!sco_debugfs)
-			BT_ERR("Failed to create SCO debug file");
+			bt_err("Failed to create SCO debug file");
 	}
 
-	BT_INFO("SCO socket layer initialized");
+	bt_info("SCO socket layer initialized");
 
 	return 0;
 
@@ -1076,10 +1076,10 @@ void __exit sco_exit(void)
 	debugfs_remove(sco_debugfs);
 
 	if (bt_sock_unregister(BTPROTO_SCO) < 0)
-		BT_ERR("SCO socket unregistration failed");
+		bt_err("SCO socket unregistration failed");
 
 	if (hci_unregister_proto(&sco_hci_proto) < 0)
-		BT_ERR("SCO protocol unregistration failed");
+		bt_err("SCO protocol unregistration failed");
 
 	proto_unregister(&sco_proto);
 }
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c
index a36f870..6e14fab 100644
--- a/net/bluetooth/smp.c
+++ b/net/bluetooth/smp.c
@@ -52,7 +52,7 @@ static int smp_e(struct crypto_blkcipher *tfm, const u8 *k, u8 *r)
 	unsigned char iv[128];
 
 	if (tfm == NULL) {
-		BT_ERR("tfm %p", tfm);
+		bt_err("tfm %p", tfm);
 		return -EINVAL;
 	}
 
@@ -61,7 +61,7 @@ static int smp_e(struct crypto_blkcipher *tfm, const u8 *k, u8 *r)
 
 	err = crypto_blkcipher_setkey(tfm, k, 16);
 	if (err) {
-		BT_ERR("cipher setkey failed: %d", err);
+		bt_err("cipher setkey failed: %d", err);
 		return err;
 	}
 
@@ -75,7 +75,7 @@ static int smp_e(struct crypto_blkcipher *tfm, const u8 *k, u8 *r)
 
 	err = crypto_blkcipher_encrypt(&desc, &sg, &sg, 16);
 	if (err)
-		BT_ERR("Encrypt data error %d", err);
+		bt_err("Encrypt data error %d", err);
 
 	return err;
 }
@@ -107,7 +107,7 @@ static int smp_c1(struct crypto_blkcipher *tfm, u8 k[16], u8 r[16],
 	/* res = e(k, res) */
 	err = smp_e(tfm, k, res);
 	if (err) {
-		BT_ERR("Encrypt data error");
+		bt_err("Encrypt data error");
 		return err;
 	}
 
@@ -117,7 +117,7 @@ static int smp_c1(struct crypto_blkcipher *tfm, u8 k[16], u8 r[16],
 	/* res = e(k, res) */
 	err = smp_e(tfm, k, res);
 	if (err)
-		BT_ERR("Encrypt data error");
+		bt_err("Encrypt data error");
 
 	return err;
 }
@@ -133,7 +133,7 @@ static int smp_s1(struct crypto_blkcipher *tfm, u8 k[16],
 
 	err = smp_e(tfm, k, _r);
 	if (err)
-		BT_ERR("Encrypt data error");
+		bt_err("Encrypt data error");
 
 	return err;
 }
@@ -176,7 +176,7 @@ static void smp_send_cmd(struct l2cap_conn *conn, u8 code, u16 len, void *data)
 {
 	struct sk_buff *skb = smp_build_cmd(conn, code, len, data);
 
-	BT_DBG("code 0x%2.2x", code);
+	bt_dbg("code 0x%2.2x", code);
 
 	if (!skb)
 		return;
@@ -223,7 +223,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb)
 	struct smp_cmd_pairing rsp, *req = (void *) skb->data;
 	u8 key_size;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	conn->preq[0] = SMP_CMD_PAIRING_REQ;
 	memcpy(&conn->preq[1], req, sizeof(*req));
@@ -261,7 +261,7 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb)
 	int ret;
 	u8 res[16], key_size;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	skb_pull(skb, sizeof(*rsp));
 
@@ -300,7 +300,7 @@ static u8 smp_cmd_pairing_confirm(struct l2cap_conn *conn, struct sk_buff *skb)
 {
 	struct crypto_blkcipher *tfm = conn->hcon->hdev->tfm;
 
-	BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
+	bt_dbg("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
 
 	memcpy(conn->pcnf, skb->data, sizeof(conn->pcnf));
 	skb_pull(skb, sizeof(conn->pcnf));
@@ -360,12 +360,12 @@ static u8 smp_cmd_pairing_random(struct l2cap_conn *conn, struct sk_buff *skb)
 	if (ret)
 		return SMP_UNSPECIFIED;
 
-	BT_DBG("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
+	bt_dbg("conn %p %s", conn, conn->hcon->out ? "master" : "slave");
 
 	swap128(res, confirm);
 
 	if (memcmp(conn->pcnf, confirm, sizeof(conn->pcnf)) != 0) {
-		BT_ERR("Pairing failed (confirmation values mismatch)");
+		bt_err("Pairing failed (confirmation values mismatch)");
 		return SMP_CONFIRM_FAILED;
 	}
 
@@ -404,7 +404,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
 	struct smp_cmd_pairing cp;
 	struct hci_conn *hcon = conn->hcon;
 
-	BT_DBG("conn %p", conn);
+	bt_dbg("conn %p", conn);
 
 	if (test_bit(HCI_CONN_ENCRYPT_PEND, &hcon->pend))
 		return 0;
@@ -432,7 +432,7 @@ int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
 	struct hci_conn *hcon = conn->hcon;
 	__u8 authreq;
 
-	BT_DBG("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level);
+	bt_dbg("conn %p hcon %p level 0x%2.2x", conn, hcon, sec_level);
 
 	if (IS_ERR(hcon->hdev->tfm))
 		return 1;
@@ -517,7 +517,7 @@ int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
 	case SMP_CMD_IDENT_ADDR_INFO:
 	case SMP_CMD_SIGN_INFO:
 	default:
-		BT_DBG("Unknown command code 0x%2.2x", code);
+		bt_dbg("Unknown command code 0x%2.2x", code);
 
 		reason = SMP_CMD_NOTSUPP;
 		err = -EOPNOTSUPP;
-- 
1.7.6.rc1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCH v4 1/6] NFC: add nfc subsystem core
  2011-06-29 23:46             ` Joe Perches
@ 2011-06-30  3:26               ` Aloisio Almeida
  2011-06-30  4:28                 ` RFC: Add __dynamic_dev_dbg Joe Perches
  2011-06-30  4:49                 ` Joe Perches
  0 siblings, 2 replies; 38+ messages in thread
From: Aloisio Almeida @ 2011-06-30  3:26 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jason Baron, Marcel Holtmann, linville, linux-wireless, sameo,
	johannes, lauro.venancio, marcio.macedo, Waldemar.Rymarkiewicz,
	padovan, rdunlap

Hi Joe,

On Wed, Jun 29, 2011 at 8:46 PM, Joe Perches <joe@perches.com> wrote:
> On Wed, 2011-06-29 at 20:23 -0300, Aloisio Almeida wrote:
>> >> Today, dynamic_debug can add __func__ to the output as
>> >> desired so I think that it's not really necessary
>> >> to add to any <foo>_dbg callsite.
>> That's true only for pr_debug() function. You cannot add __func__ info
>> on dev_dbg() calls dynamically.
>
> I believe that's false.  It's definitely stored.
>
> #define dynamic_dev_dbg(dev, fmt, ...) do {                             \
>        static struct _ddebug descriptor                                \
>        __used                                                          \
>        __attribute__((section("__verbose"), aligned(8))) =             \
>        { KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__,            \
>                _DPRINTK_FLAGS_DEFAULT };                               \
>        if (unlikely(descriptor.enabled))                               \
>                dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);        \
>        } while (0)
>
> Jason?  True or false?

It's stored but not retrieved. If you check lib/dynamic_debug.c you
see that only __dynamic_pr_debug() (called by dynamic_pr_debug() )
adds such information on prints. The dev_printk() does not check
_DPRINTK_FLAGS_INCL_* flags.

> I think you should add NFC to nfc_dev_err too.

That's make sense to me also.

Aloisio

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 2/2] bluetooth: Add bt_printk, convert logging macros to lower case
@ 2011-06-30  3:31                 ` Gustavo F. Padovan
  0 siblings, 0 replies; 38+ messages in thread
From: Gustavo F. Padovan @ 2011-06-30  3:31 UTC (permalink / raw)
  To: Joe Perches
  Cc: Marcel Holtmann, David S. Miller, linux-bluetooth, linux-kernel, netdev

Hi Joe,

* Joe Perches <joe@perches.com> [2011-06-29 18:18:30 -0700]:

> Use the more common logging styles.
> 
> bt_print uses vsprintf extension %pV.
> This saves 2 to 3 % of code/text space.
> 
> $ find net/bluetooth -name "built-in.o.*" | xargs size
>    text	   data	    bss	    dec	    hex	filename
>   14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new
>   15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
>   18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new
>   18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
>   59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new
>   61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old
>   19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new
>   19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
>  346600	  19163	  86080	 451843	  6e503	net/bluetooth/built-in.o.new
>  353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
> 
> $ find drivers/bluetooth/ -name "built-in.o.*" | xargs size
>    text	   data	    bss	    dec	    hex	filename
>  129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new
>  134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old

This is really nice, but can we keep the lower case? I think applying this
patch now will break things to people developing on top of my tree.
Then someday in the future when development becomes calm or just after the
next merge window I run a s/BT_*/bt_*/ on everything.

Thanks a lot for looking into this, reduce code/text by 3% only changing
logging is awesome.

	Gustavo

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 2/2] bluetooth: Add bt_printk, convert logging macros to lower case
@ 2011-06-30  3:31                 ` Gustavo F. Padovan
  0 siblings, 0 replies; 38+ messages in thread
From: Gustavo F. Padovan @ 2011-06-30  3:31 UTC (permalink / raw)
  To: Joe Perches
  Cc: Marcel Holtmann, David S. Miller,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA

Hi Joe,

* Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org> [2011-06-29 18:18:30 -0700]:

> Use the more common logging styles.
> 
> bt_print uses vsprintf extension %pV.
> This saves 2 to 3 % of code/text space.
> 
> $ find net/bluetooth -name "built-in.o.*" | xargs size
>    text	   data	    bss	    dec	    hex	filename
>   14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new
>   15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
>   18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new
>   18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
>   59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new
>   61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old
>   19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new
>   19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
>  346600	  19163	  86080	 451843	  6e503	net/bluetooth/built-in.o.new
>  353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
> 
> $ find drivers/bluetooth/ -name "built-in.o.*" | xargs size
>    text	   data	    bss	    dec	    hex	filename
>  129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new
>  134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old

This is really nice, but can we keep the lower case? I think applying this
patch now will break things to people developing on top of my tree.
Then someday in the future when development becomes calm or just after the
next merge window I run a s/BT_*/bt_*/ on everything.

Thanks a lot for looking into this, reduce code/text by 3% only changing
logging is awesome.

	Gustavo

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 2/2] bluetooth: Add bt_printk, convert logging macros to lower case
  2011-06-30  3:31                 ` Gustavo F. Padovan
  (?)
@ 2011-06-30  3:47                 ` Joe Perches
  -1 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30  3:47 UTC (permalink / raw)
  To: Gustavo F. Padovan
  Cc: Marcel Holtmann, David S. Miller, linux-bluetooth, linux-kernel, netdev

On Thu, 2011-06-30 at 00:31 -0300, Gustavo F. Padovan wrote:
> Hi Joe,

Hello Gustavo.

> > Use the more common logging styles.
> > bt_print uses vsprintf extension %pV.
> > This saves 2 to 3 % of code/text space.
> > $ find net/bluetooth -name "built-in.o.*" | xargs size
> >    text	   data	    bss	    dec	    hex	filename
> >   14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new
> >   15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
> >   18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new
> >   18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
> >   59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new
> >   61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old
> >   19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new
> >   19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
> >  346600	  19163	  86080	 451843	  6e503	net/bluetooth/built-in.o.new
> >  353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
> > $ find drivers/bluetooth/ -name "built-in.o.*" | xargs size
> >    text	   data	    bss	    dec	    hex	filename
> >  129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new
> >  134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old
> This is really nice, but can we keep the lower case?

I don't understand what you mean.
Maybe "keep the upper case"?

Sure, go for it.

My point was to add bt_printk and convert the macros.
You could break that up into 5 patches I suppose.

Some sequence like:

	Add bt_printk, convert current BT_<LEVEL> to use them
	Rename bt_err to bt_to_errno
	Add lowercase bt_<level>
	Case conversions of BT_<LEVEL> to bt_<level>
	Remove BT_<LEVEL>

> I think applying this
> patch now will break things to people developing on top of my tree.

Do what you think best.
The code size saving is in conversion to bt_printk and using %pV.
The UPPER->lower is noisy and trivial.

> Then someday in the future when development becomes calm or just after the
> next merge window I run a s/BT_*/bt_*/ on everything.
> Thanks a lot for looking into this, reduce code/text by 3% only changing
> logging is awesome.

cheers, Joe


^ permalink raw reply	[flat|nested] 38+ messages in thread

* RFC: Add __dynamic_dev_dbg
  2011-06-30  3:26               ` Aloisio Almeida
@ 2011-06-30  4:28                 ` Joe Perches
  2011-06-30  4:49                 ` Joe Perches
  1 sibling, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30  4:28 UTC (permalink / raw)
  To: Aloisio Almeida
  Cc: Jason Baron, Marcel Holtmann, linville, linux-wireless, sameo,
	johannes, lauro.venancio, marcio.macedo, Waldemar.Rymarkiewicz,
	padovan, rdunlap

On Thu, 2011-06-30 at 00:26 -0300, Aloisio Almeida wrote:
> It's stored but not retrieved. If you check lib/dynamic_debug.c you
> see that only __dynamic_pr_debug() (called by dynamic_pr_debug() )
> adds such information on prints. The dev_printk() does not check
> _DPRINTK_FLAGS_INCL_* flags.

That seems enough easy to fix.

Jason?  How does this look?

---

 drivers/base/core.c           |    5 +++--
 include/linux/device.h        |    5 +++++
 include/linux/dynamic_debug.h |   10 ++++++++--
 lib/dynamic_debug.c           |   38 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index bc8729d..82c8654 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1764,8 +1764,8 @@ void device_shutdown(void)
 
 #ifdef CONFIG_PRINTK
 
-static int __dev_printk(const char *level, const struct device *dev,
-			struct va_format *vaf)
+int __dev_printk(const char *level, const struct device *dev,
+		 struct va_format *vaf)
 {
 	if (!dev)
 		return printk("%s(NULL device *): %pV", level, vaf);
@@ -1773,6 +1773,7 @@ static int __dev_printk(const char *level, const struct device *dev,
 	return printk("%s%s %s: %pV",
 		      level, dev_driver_string(dev), dev_name(dev), vaf);
 }
+EXPORT_SYMBOL(__dev_printk);
 
 int dev_printk(const char *level, const struct device *dev,
 	       const char *fmt, ...)
diff --git a/include/linux/device.h b/include/linux/device.h
index e4f62d8..53711f2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -785,6 +785,8 @@ extern const char *dev_driver_string(const struct device *dev);
 
 #ifdef CONFIG_PRINTK
 
+extern int __dev_printk(const char *level, const struct device *dev,
+			struct va_format *vaf);
 extern int dev_printk(const char *level, const struct device *dev,
 		      const char *fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
@@ -805,6 +807,9 @@ extern int _dev_info(const struct device *dev, const char *fmt, ...)
 
 #else
 
+static inline int __dev_printk(const char *level, const struct device *dev,
+			       struct va_format *vaf)
+	 { return 0; }
 static inline int dev_printk(const char *level, const struct device *dev,
 		      const char *fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index e747ecd..bdf1531 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -47,6 +47,13 @@ extern int ddebug_remove_module(const char *mod_name);
 extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
 
+struct device;
+
+extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
+			     const struct device *dev,
+			     const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+
 #define dynamic_pr_debug(fmt, ...) do {					\
 	static struct _ddebug descriptor				\
 	__used								\
@@ -57,7 +64,6 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \
 	} while (0)
 
-
 #define dynamic_dev_dbg(dev, fmt, ...) do {				\
 	static struct _ddebug descriptor				\
 	__used								\
@@ -65,7 +71,7 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 	{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__,		\
 		_DPRINTK_FLAGS_DEFAULT };				\
 	if (unlikely(descriptor.enabled))				\
-		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
+		__dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);	\
 	} while (0)
 
 #else
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 75ca78f..5c5f8f9 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -30,6 +30,7 @@
 #include <linux/jump_label.h>
 #include <linux/hardirq.h>
 #include <linux/sched.h>
+#include <linux/device.h>
 
 extern struct _ddebug __start___verbose[];
 extern struct _ddebug __stop___verbose[];
@@ -456,6 +457,43 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 }
 EXPORT_SYMBOL(__dynamic_pr_debug);
 
+int __dynamic_dev_dbg(struct _ddebug *descriptor,
+		      const struct device *dev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+	int res;
+
+	BUG_ON(!descriptor);
+	BUG_ON(!fmt);
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	res = printk(KERN_DEBUG);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
+		if (in_interrupt())
+			res += printk(KERN_CONT "<intr> ");
+		else
+			res += printk(KERN_CONT "[%d] ", task_pid_vnr(current));
+	}
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
+		res += printk(KERN_CONT "%s:", descriptor->modname);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
+		res += printk(KERN_CONT "%s:", descriptor->function);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
+		res += printk(KERN_CONT "%d ", descriptor->lineno);
+
+	res += __dev_printk("", dev, &vaf);
+
+	va_end(args);
+
+	return res;
+}
+EXPORT_SYMBOL(__dynamic_dev_dbg);
+
 static __initdata char ddebug_setup_string[1024];
 static __init int ddebug_setup_query(char *str)
 {



^ permalink raw reply related	[flat|nested] 38+ messages in thread

* RFC: Add __dynamic_dev_dbg
  2011-06-30  3:26               ` Aloisio Almeida
  2011-06-30  4:28                 ` RFC: Add __dynamic_dev_dbg Joe Perches
@ 2011-06-30  4:49                 ` Joe Perches
  2011-06-30 16:32                   ` Jason Baron
  1 sibling, 1 reply; 38+ messages in thread
From: Joe Perches @ 2011-06-30  4:49 UTC (permalink / raw)
  To: LKML; +Cc: Jason Baron, Aloisio Almeida

On Thu, 2011-06-30 at 00:26 -0300, Aloisio Almeida wrote:
> It's stored but not retrieved. If you check lib/dynamic_debug.c you
> see that only __dynamic_pr_debug() (called by dynamic_pr_debug() )
> adds such information on prints. The dev_printk() does not check
> _DPRINTK_FLAGS_INCL_* flags.

(resending to LKML)

That seems enough easy to fix.

Jason?  How does this look?

---

 drivers/base/core.c           |    5 +++--
 include/linux/device.h        |    5 +++++
 include/linux/dynamic_debug.h |   10 ++++++++--
 lib/dynamic_debug.c           |   38 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index bc8729d..82c8654 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1764,8 +1764,8 @@ void device_shutdown(void)
 
 #ifdef CONFIG_PRINTK
 
-static int __dev_printk(const char *level, const struct device *dev,
-			struct va_format *vaf)
+int __dev_printk(const char *level, const struct device *dev,
+		 struct va_format *vaf)
 {
 	if (!dev)
 		return printk("%s(NULL device *): %pV", level, vaf);
@@ -1773,6 +1773,7 @@ static int __dev_printk(const char *level, const struct device *dev,
 	return printk("%s%s %s: %pV",
 		      level, dev_driver_string(dev), dev_name(dev), vaf);
 }
+EXPORT_SYMBOL(__dev_printk);
 
 int dev_printk(const char *level, const struct device *dev,
 	       const char *fmt, ...)
diff --git a/include/linux/device.h b/include/linux/device.h
index e4f62d8..53711f2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -785,6 +785,8 @@ extern const char *dev_driver_string(const struct device *dev);
 
 #ifdef CONFIG_PRINTK
 
+extern int __dev_printk(const char *level, const struct device *dev,
+			struct va_format *vaf);
 extern int dev_printk(const char *level, const struct device *dev,
 		      const char *fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
@@ -805,6 +807,9 @@ extern int _dev_info(const struct device *dev, const char *fmt, ...)
 
 #else
 
+static inline int __dev_printk(const char *level, const struct device *dev,
+			       struct va_format *vaf)
+	 { return 0; }
 static inline int dev_printk(const char *level, const struct device *dev,
 		      const char *fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index e747ecd..bdf1531 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -47,6 +47,13 @@ extern int ddebug_remove_module(const char *mod_name);
 extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
 
+struct device;
+
+extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
+			     const struct device *dev,
+			     const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+
 #define dynamic_pr_debug(fmt, ...) do {					\
 	static struct _ddebug descriptor				\
 	__used								\
@@ -57,7 +64,6 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \
 	} while (0)
 
-
 #define dynamic_dev_dbg(dev, fmt, ...) do {				\
 	static struct _ddebug descriptor				\
 	__used								\
@@ -65,7 +71,7 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 	{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__,		\
 		_DPRINTK_FLAGS_DEFAULT };				\
 	if (unlikely(descriptor.enabled))				\
-		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
+		__dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);	\
 	} while (0)
 
 #else
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 75ca78f..5c5f8f9 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -30,6 +30,7 @@
 #include <linux/jump_label.h>
 #include <linux/hardirq.h>
 #include <linux/sched.h>
+#include <linux/device.h>
 
 extern struct _ddebug __start___verbose[];
 extern struct _ddebug __stop___verbose[];
@@ -456,6 +457,43 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 }
 EXPORT_SYMBOL(__dynamic_pr_debug);
 
+int __dynamic_dev_dbg(struct _ddebug *descriptor,
+		      const struct device *dev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+	int res;
+
+	BUG_ON(!descriptor);
+	BUG_ON(!fmt);
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	res = printk(KERN_DEBUG);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
+		if (in_interrupt())
+			res += printk(KERN_CONT "<intr> ");
+		else
+			res += printk(KERN_CONT "[%d] ", task_pid_vnr(current));
+	}
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
+		res += printk(KERN_CONT "%s:", descriptor->modname);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
+		res += printk(KERN_CONT "%s:", descriptor->function);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
+		res += printk(KERN_CONT "%d ", descriptor->lineno);
+
+	res += __dev_printk("", dev, &vaf);
+
+	va_end(args);
+
+	return res;
+}
+EXPORT_SYMBOL(__dynamic_dev_dbg);
+
 static __initdata char ddebug_setup_string[1024];
 static __init int ddebug_setup_query(char *str)
 {




^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH] bluetooth: Add bt_printk
  2011-06-30  3:31                 ` Gustavo F. Padovan
@ 2011-06-30  7:19                   ` Joe Perches
  -1 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30  7:19 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo F. Padovan
  Cc: David S. Miller, linux-bluetooth, netdev, linux-kernel

Add a local logging function to emit bluetooth specific
messages.  Using vsprintf extension %pV saves code/text
space.

Convert the current BT_INFO and BT_ERR macros to use bt_printk.
Remove __func__ from BT_ERR macro (and the uses).
Prefix "Bluetooth: " to BT_ERR
Remove __func__ from BT_DBG as function can be prefixed when
using dynamic_debug.

With allyesconfig:

   text	   data	    bss	    dec	    hex	filename
 129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new2
 134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old
  14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new2
  15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
 346595	  19163	  86080	 451838	  6e4fe	net/bluetooth/built-in.o.new2
 353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
  18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new2
  18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
  19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new2
  19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
  59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new2
  61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old

with x86 defconfig (and just bluetooth):

$ size net/bluetooth/built-in.o.defconfig.*
   text	   data	    bss	    dec	    hex	filename
  66358	    933	    100	  67391	  1073f	net/bluetooth/built-in.o.defconfig.new
  66643	    933	    100	  67676	  1085c	net/bluetooth/built-in.o.defconfig.old

Signed-off-by: Joe Perches <joe@perches.com>
---
 include/net/bluetooth/bluetooth.h |    9 ++++++---
 net/bluetooth/lib.c               |   19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 7bccaf9..042591c 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -76,9 +76,12 @@ struct bt_power {
 #define BT_POWER_FORCE_ACTIVE_OFF 0
 #define BT_POWER_FORCE_ACTIVE_ON  1
 
-#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
-#define BT_ERR(fmt, arg...)  printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
-#define BT_DBG(fmt, arg...)  pr_debug("%s: " fmt "\n" , __func__ , ## arg)
+__attribute__((format (printf, 2, 3)))
+int bt_printk(const char *level, const char *fmt, ...);
+
+#define BT_INFO(fmt, arg...)	bt_printk(KERN_INFO, pr_fmt(fmt), ##arg)
+#define BT_ERR(fmt, arg...)	bt_printk(KERN_ERR, pr_fmt(fmt), ##arg)
+#define BT_DBG(fmt, arg...)	pr_debug(fmt "\n", ##arg)
 
 /* Connection and socket states */
 enum {
diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c
index b826d1b..fdb3ec3 100644
--- a/net/bluetooth/lib.c
+++ b/net/bluetooth/lib.c
@@ -150,3 +150,22 @@ int bt_err(__u16 code)
 	}
 }
 EXPORT_SYMBOL(bt_err);
+
+int bt_printk(const char *level, const char *format, ...)
+{
+	struct va_format vaf;
+	va_list args;
+	int r;
+
+	va_start(args, format);
+
+	vaf.fmt = format;
+	vaf.va = &args;
+
+	r = printk("%sbluetooth: %pV\n", level, &vaf);
+
+	va_end(args);
+
+	return r;
+}
+EXPORT_SYMBOL(bt_printk);
-- 
1.7.6.rc1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH] bluetooth: Add bt_printk
@ 2011-06-30  7:19                   ` Joe Perches
  0 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30  7:19 UTC (permalink / raw)
  To: Marcel Holtmann, Gustavo F. Padovan
  Cc: David S. Miller, linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Add a local logging function to emit bluetooth specific
messages.  Using vsprintf extension %pV saves code/text
space.

Convert the current BT_INFO and BT_ERR macros to use bt_printk.
Remove __func__ from BT_ERR macro (and the uses).
Prefix "Bluetooth: " to BT_ERR
Remove __func__ from BT_DBG as function can be prefixed when
using dynamic_debug.

With allyesconfig:

   text	   data	    bss	    dec	    hex	filename
 129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new2
 134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old
  14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new2
  15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
 346595	  19163	  86080	 451838	  6e4fe	net/bluetooth/built-in.o.new2
 353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
  18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new2
  18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
  19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new2
  19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
  59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new2
  61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old

with x86 defconfig (and just bluetooth):

$ size net/bluetooth/built-in.o.defconfig.*
   text	   data	    bss	    dec	    hex	filename
  66358	    933	    100	  67391	  1073f	net/bluetooth/built-in.o.defconfig.new
  66643	    933	    100	  67676	  1085c	net/bluetooth/built-in.o.defconfig.old

Signed-off-by: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>
---
 include/net/bluetooth/bluetooth.h |    9 ++++++---
 net/bluetooth/lib.c               |   19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index 7bccaf9..042591c 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -76,9 +76,12 @@ struct bt_power {
 #define BT_POWER_FORCE_ACTIVE_OFF 0
 #define BT_POWER_FORCE_ACTIVE_ON  1
 
-#define BT_INFO(fmt, arg...) printk(KERN_INFO "Bluetooth: " fmt "\n" , ## arg)
-#define BT_ERR(fmt, arg...)  printk(KERN_ERR "%s: " fmt "\n" , __func__ , ## arg)
-#define BT_DBG(fmt, arg...)  pr_debug("%s: " fmt "\n" , __func__ , ## arg)
+__attribute__((format (printf, 2, 3)))
+int bt_printk(const char *level, const char *fmt, ...);
+
+#define BT_INFO(fmt, arg...)	bt_printk(KERN_INFO, pr_fmt(fmt), ##arg)
+#define BT_ERR(fmt, arg...)	bt_printk(KERN_ERR, pr_fmt(fmt), ##arg)
+#define BT_DBG(fmt, arg...)	pr_debug(fmt "\n", ##arg)
 
 /* Connection and socket states */
 enum {
diff --git a/net/bluetooth/lib.c b/net/bluetooth/lib.c
index b826d1b..fdb3ec3 100644
--- a/net/bluetooth/lib.c
+++ b/net/bluetooth/lib.c
@@ -150,3 +150,22 @@ int bt_err(__u16 code)
 	}
 }
 EXPORT_SYMBOL(bt_err);
+
+int bt_printk(const char *level, const char *format, ...)
+{
+	struct va_format vaf;
+	va_list args;
+	int r;
+
+	va_start(args, format);
+
+	vaf.fmt = format;
+	vaf.va = &args;
+
+	r = printk("%sbluetooth: %pV\n", level, &vaf);
+
+	va_end(args);
+
+	return r;
+}
+EXPORT_SYMBOL(bt_printk);
-- 
1.7.6.rc1

^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: RFC: Add __dynamic_dev_dbg
  2011-06-30  4:49                 ` Joe Perches
@ 2011-06-30 16:32                   ` Jason Baron
  2011-06-30 18:14                     ` [PATCH 0/4] dynamic_debug Joe Perches
  0 siblings, 1 reply; 38+ messages in thread
From: Jason Baron @ 2011-06-30 16:32 UTC (permalink / raw)
  To: Joe Perches; +Cc: LKML, Aloisio Almeida

On Wed, Jun 29, 2011 at 09:49:01PM -0700, Joe Perches wrote:
> (resending to LKML)
> 
> That seems enough easy to fix.
> 
> Jason?  How does this look?
> 

Thanks for noticing the inconsistency. Patch makes sense to me.

There seem to be a number of pending dynamic debug patches. So if you want to
send me this patch with a changelog and sob line, I can queue up with the rest.

thanks,

-Jason

> ---
> 
>  drivers/base/core.c           |    5 +++--
>  include/linux/device.h        |    5 +++++
>  include/linux/dynamic_debug.h |   10 ++++++++--
>  lib/dynamic_debug.c           |   38 ++++++++++++++++++++++++++++++++++++++
>  4 files changed, 54 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index bc8729d..82c8654 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c
> @@ -1764,8 +1764,8 @@ void device_shutdown(void)
>  
>  #ifdef CONFIG_PRINTK
>  
> -static int __dev_printk(const char *level, const struct device *dev,
> -			struct va_format *vaf)
> +int __dev_printk(const char *level, const struct device *dev,
> +		 struct va_format *vaf)
>  {
>  	if (!dev)
>  		return printk("%s(NULL device *): %pV", level, vaf);
> @@ -1773,6 +1773,7 @@ static int __dev_printk(const char *level, const struct device *dev,
>  	return printk("%s%s %s: %pV",
>  		      level, dev_driver_string(dev), dev_name(dev), vaf);
>  }
> +EXPORT_SYMBOL(__dev_printk);
>  
>  int dev_printk(const char *level, const struct device *dev,
>  	       const char *fmt, ...)
> diff --git a/include/linux/device.h b/include/linux/device.h
> index e4f62d8..53711f2 100644
> --- a/include/linux/device.h
> +++ b/include/linux/device.h
> @@ -785,6 +785,8 @@ extern const char *dev_driver_string(const struct device *dev);
>  
>  #ifdef CONFIG_PRINTK
>  
> +extern int __dev_printk(const char *level, const struct device *dev,
> +			struct va_format *vaf);
>  extern int dev_printk(const char *level, const struct device *dev,
>  		      const char *fmt, ...)
>  	__attribute__ ((format (printf, 3, 4)));
> @@ -805,6 +807,9 @@ extern int _dev_info(const struct device *dev, const char *fmt, ...)
>  
>  #else
>  
> +static inline int __dev_printk(const char *level, const struct device *dev,
> +			       struct va_format *vaf)
> +	 { return 0; }
>  static inline int dev_printk(const char *level, const struct device *dev,
>  		      const char *fmt, ...)
>  	__attribute__ ((format (printf, 3, 4)));
> diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
> index e747ecd..bdf1531 100644
> --- a/include/linux/dynamic_debug.h
> +++ b/include/linux/dynamic_debug.h
> @@ -47,6 +47,13 @@ extern int ddebug_remove_module(const char *mod_name);
>  extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
>  	__attribute__ ((format (printf, 2, 3)));
>  
> +struct device;
> +
> +extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
> +			     const struct device *dev,
> +			     const char *fmt, ...)
> +	__attribute__ ((format (printf, 3, 4)));
> +
>  #define dynamic_pr_debug(fmt, ...) do {					\
>  	static struct _ddebug descriptor				\
>  	__used								\
> @@ -57,7 +64,6 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
>  		__dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \
>  	} while (0)
>  
> -
>  #define dynamic_dev_dbg(dev, fmt, ...) do {				\
>  	static struct _ddebug descriptor				\
>  	__used								\
> @@ -65,7 +71,7 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
>  	{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__,		\
>  		_DPRINTK_FLAGS_DEFAULT };				\
>  	if (unlikely(descriptor.enabled))				\
> -		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
> +		__dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);	\
>  	} while (0)
>  
>  #else
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 75ca78f..5c5f8f9 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -30,6 +30,7 @@
>  #include <linux/jump_label.h>
>  #include <linux/hardirq.h>
>  #include <linux/sched.h>
> +#include <linux/device.h>
>  
>  extern struct _ddebug __start___verbose[];
>  extern struct _ddebug __stop___verbose[];
> @@ -456,6 +457,43 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
>  }
>  EXPORT_SYMBOL(__dynamic_pr_debug);
>  
> +int __dynamic_dev_dbg(struct _ddebug *descriptor,
> +		      const struct device *dev, const char *fmt, ...)
> +{
> +	struct va_format vaf;
> +	va_list args;
> +	int res;
> +
> +	BUG_ON(!descriptor);
> +	BUG_ON(!fmt);
> +
> +	va_start(args, fmt);
> +
> +	vaf.fmt = fmt;
> +	vaf.va = &args;
> +
> +	res = printk(KERN_DEBUG);
> +	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
> +		if (in_interrupt())
> +			res += printk(KERN_CONT "<intr> ");
> +		else
> +			res += printk(KERN_CONT "[%d] ", task_pid_vnr(current));
> +	}
> +	if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
> +		res += printk(KERN_CONT "%s:", descriptor->modname);
> +	if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
> +		res += printk(KERN_CONT "%s:", descriptor->function);
> +	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
> +		res += printk(KERN_CONT "%d ", descriptor->lineno);
> +
> +	res += __dev_printk("", dev, &vaf);
> +
> +	va_end(args);
> +
> +	return res;
> +}
> +EXPORT_SYMBOL(__dynamic_dev_dbg);
> +
>  static __initdata char ddebug_setup_string[1024];
>  static __init int ddebug_setup_query(char *str)
>  {
> 
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 0/4] dynamic_debug
  2011-06-30 16:32                   ` Jason Baron
@ 2011-06-30 18:14                     ` Joe Perches
  2011-06-30 18:14                       ` [PATCH 1/4] dynamic_debug: Add __dynamic_dev_dbg Joe Perches
                                         ` (4 more replies)
  0 siblings, 5 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30 18:14 UTC (permalink / raw)
  To: Jason Baron, netdev; +Cc: linux-kernel

Some improvements and cleanups to dynamic_debug

btw Jason:

You're not listed in MAINTAINERS for dynamic_debug.[ch].
Maybe you should add yourself. 

Joe Perches (4):
  dynamic_debug: Add __dynamic_dev_dbg
  dynamic_debug: Consolidate prefix output to single routine
  dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix
  dynamic_debug: Convert printks to pr_<level>

 drivers/base/core.c           |    5 +-
 include/linux/device.h        |    5 ++
 include/linux/dynamic_debug.h |   10 +++-
 lib/dynamic_debug.c           |  133 +++++++++++++++++++++++++++--------------
 4 files changed, 103 insertions(+), 50 deletions(-)

-- 
1.7.6.rc1


^ permalink raw reply	[flat|nested] 38+ messages in thread

* [PATCH 1/4] dynamic_debug: Add __dynamic_dev_dbg
  2011-06-30 18:14                     ` [PATCH 0/4] dynamic_debug Joe Perches
@ 2011-06-30 18:14                       ` Joe Perches
  2011-06-30 18:14                       ` [PATCH 2/4] dynamic_debug: Consolidate prefix output to single routine Joe Perches
                                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30 18:14 UTC (permalink / raw)
  To: Jason Baron, Greg Kroah-Hartman; +Cc: Aloisio Almeida, linux-kernel, netdev

Unlike dynamic_pr_debug, dynamic uses of dev_dbg can not
currently add task_pid/KBUILD_MODNAME/__func__/__LINE__
to selected debug output.

Add a new function similar to dynamic_pr_debug to
optionally emit these prefixes.

cc: Aloisio Almeida <aloisio.almeida@openbossa.org>

Noticed-by: Aloisio Almeida <aloisio.almeida@openbossa.org>
Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/base/core.c           |    5 +++--
 include/linux/device.h        |    5 +++++
 include/linux/dynamic_debug.h |   10 ++++++++--
 lib/dynamic_debug.c           |   38 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/drivers/base/core.c b/drivers/base/core.c
index bc8729d..82c8654 100644
--- a/drivers/base/core.c
+++ b/drivers/base/core.c
@@ -1764,8 +1764,8 @@ void device_shutdown(void)
 
 #ifdef CONFIG_PRINTK
 
-static int __dev_printk(const char *level, const struct device *dev,
-			struct va_format *vaf)
+int __dev_printk(const char *level, const struct device *dev,
+		 struct va_format *vaf)
 {
 	if (!dev)
 		return printk("%s(NULL device *): %pV", level, vaf);
@@ -1773,6 +1773,7 @@ static int __dev_printk(const char *level, const struct device *dev,
 	return printk("%s%s %s: %pV",
 		      level, dev_driver_string(dev), dev_name(dev), vaf);
 }
+EXPORT_SYMBOL(__dev_printk);
 
 int dev_printk(const char *level, const struct device *dev,
 	       const char *fmt, ...)
diff --git a/include/linux/device.h b/include/linux/device.h
index e4f62d8..53711f2 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -785,6 +785,8 @@ extern const char *dev_driver_string(const struct device *dev);
 
 #ifdef CONFIG_PRINTK
 
+extern int __dev_printk(const char *level, const struct device *dev,
+			struct va_format *vaf);
 extern int dev_printk(const char *level, const struct device *dev,
 		      const char *fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
@@ -805,6 +807,9 @@ extern int _dev_info(const struct device *dev, const char *fmt, ...)
 
 #else
 
+static inline int __dev_printk(const char *level, const struct device *dev,
+			       struct va_format *vaf)
+	 { return 0; }
 static inline int dev_printk(const char *level, const struct device *dev,
 		      const char *fmt, ...)
 	__attribute__ ((format (printf, 3, 4)));
diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h
index e747ecd..bdf1531 100644
--- a/include/linux/dynamic_debug.h
+++ b/include/linux/dynamic_debug.h
@@ -47,6 +47,13 @@ extern int ddebug_remove_module(const char *mod_name);
 extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 	__attribute__ ((format (printf, 2, 3)));
 
+struct device;
+
+extern int __dynamic_dev_dbg(struct _ddebug *descriptor,
+			     const struct device *dev,
+			     const char *fmt, ...)
+	__attribute__ ((format (printf, 3, 4)));
+
 #define dynamic_pr_debug(fmt, ...) do {					\
 	static struct _ddebug descriptor				\
 	__used								\
@@ -57,7 +64,6 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 		__dynamic_pr_debug(&descriptor, pr_fmt(fmt), ##__VA_ARGS__); \
 	} while (0)
 
-
 #define dynamic_dev_dbg(dev, fmt, ...) do {				\
 	static struct _ddebug descriptor				\
 	__used								\
@@ -65,7 +71,7 @@ extern int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 	{ KBUILD_MODNAME, __func__, __FILE__, fmt, __LINE__,		\
 		_DPRINTK_FLAGS_DEFAULT };				\
 	if (unlikely(descriptor.enabled))				\
-		dev_printk(KERN_DEBUG, dev, fmt, ##__VA_ARGS__);	\
+		__dynamic_dev_dbg(&descriptor, dev, fmt, ##__VA_ARGS__);	\
 	} while (0)
 
 #else
diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 75ca78f..5c5f8f9 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -30,6 +30,7 @@
 #include <linux/jump_label.h>
 #include <linux/hardirq.h>
 #include <linux/sched.h>
+#include <linux/device.h>
 
 extern struct _ddebug __start___verbose[];
 extern struct _ddebug __stop___verbose[];
@@ -456,6 +457,43 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 }
 EXPORT_SYMBOL(__dynamic_pr_debug);
 
+int __dynamic_dev_dbg(struct _ddebug *descriptor,
+		      const struct device *dev, const char *fmt, ...)
+{
+	struct va_format vaf;
+	va_list args;
+	int res;
+
+	BUG_ON(!descriptor);
+	BUG_ON(!fmt);
+
+	va_start(args, fmt);
+
+	vaf.fmt = fmt;
+	vaf.va = &args;
+
+	res = printk(KERN_DEBUG);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
+		if (in_interrupt())
+			res += printk(KERN_CONT "<intr> ");
+		else
+			res += printk(KERN_CONT "[%d] ", task_pid_vnr(current));
+	}
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
+		res += printk(KERN_CONT "%s:", descriptor->modname);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
+		res += printk(KERN_CONT "%s:", descriptor->function);
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
+		res += printk(KERN_CONT "%d ", descriptor->lineno);
+
+	res += __dev_printk("", dev, &vaf);
+
+	va_end(args);
+
+	return res;
+}
+EXPORT_SYMBOL(__dynamic_dev_dbg);
+
 static __initdata char ddebug_setup_string[1024];
 static __init int ddebug_setup_query(char *str)
 {
-- 
1.7.6.rc1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 2/4] dynamic_debug: Consolidate prefix output to single routine
  2011-06-30 18:14                     ` [PATCH 0/4] dynamic_debug Joe Perches
  2011-06-30 18:14                       ` [PATCH 1/4] dynamic_debug: Add __dynamic_dev_dbg Joe Perches
@ 2011-06-30 18:14                       ` Joe Perches
  2011-06-30 18:14                       ` [PATCH 3/4] dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix Joe Perches
                                         ` (2 subsequent siblings)
  4 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30 18:14 UTC (permalink / raw)
  To: Jason Baron, linux-kernel

Adding dynamic_dev_dbg duplicated prefix output.
Consolidate that output to a single routine.

Signed-off-by: Joe Perches <joe@perches.com>
---
 lib/dynamic_debug.c |   38 ++++++++++++++++++--------------------
 1 files changed, 18 insertions(+), 20 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 5c5f8f9..758e922 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -428,15 +428,10 @@ static int ddebug_exec_query(char *query_string)
 	return 0;
 }
 
-int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
+static int dynamic_emit_prefix(const struct _ddebug *descriptor)
 {
-	va_list args;
 	int res;
 
-	BUG_ON(!descriptor);
-	BUG_ON(!fmt);
-
-	va_start(args, fmt);
 	res = printk(KERN_DEBUG);
 	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
 		if (in_interrupt())
@@ -450,7 +445,23 @@ int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
 		res += printk(KERN_CONT "%s:", descriptor->function);
 	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
 		res += printk(KERN_CONT "%d ", descriptor->lineno);
+
+	return res;
+}
+
+int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
+{
+	va_list args;
+	int res;
+
+	BUG_ON(!descriptor);
+	BUG_ON(!fmt);
+
+	va_start(args, fmt);
+
+	res = dynamic_emit_prefix(descriptor);
 	res += vprintk(fmt, args);
+
 	va_end(args);
 
 	return res;
@@ -472,20 +483,7 @@ int __dynamic_dev_dbg(struct _ddebug *descriptor,
 	vaf.fmt = fmt;
 	vaf.va = &args;
 
-	res = printk(KERN_DEBUG);
-	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
-		if (in_interrupt())
-			res += printk(KERN_CONT "<intr> ");
-		else
-			res += printk(KERN_CONT "[%d] ", task_pid_vnr(current));
-	}
-	if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
-		res += printk(KERN_CONT "%s:", descriptor->modname);
-	if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
-		res += printk(KERN_CONT "%s:", descriptor->function);
-	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
-		res += printk(KERN_CONT "%d ", descriptor->lineno);
-
+	res = dynamic_emit_prefix(descriptor);
 	res += __dev_printk("", dev, &vaf);
 
 	va_end(args);
-- 
1.7.6.rc1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 3/4] dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix
  2011-06-30 18:14                     ` [PATCH 0/4] dynamic_debug Joe Perches
  2011-06-30 18:14                       ` [PATCH 1/4] dynamic_debug: Add __dynamic_dev_dbg Joe Perches
  2011-06-30 18:14                       ` [PATCH 2/4] dynamic_debug: Consolidate prefix output to single routine Joe Perches
@ 2011-06-30 18:14                       ` Joe Perches
  2011-06-30 18:14                       ` [PATCH 4/4] dynamic_debug: Convert printks to pr_<level> Joe Perches
  2011-06-30 19:51                       ` [PATCH 0/4] dynamic_debug Jason Baron
  4 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30 18:14 UTC (permalink / raw)
  To: Jason Baron, linux-kernel

Multiple printks with KERN_CONT can be interleaved by
other printks.  Reduce the likelihood of that interleaving
by consolidating multiple calls to printk.

Signed-off-by: Joe Perches <joe@perches.com>
---
 lib/dynamic_debug.c |   34 +++++++++++++++++++++++-----------
 1 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 758e922..6669078 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -430,23 +430,35 @@ static int ddebug_exec_query(char *query_string)
 
 static int dynamic_emit_prefix(const struct _ddebug *descriptor)
 {
-	int res;
+	char tid[sizeof(int) + sizeof(int)/2 + 4];
+	char lineno[sizeof(int) + sizeof(int)/2];
 
-	res = printk(KERN_DEBUG);
 	if (descriptor->flags & _DPRINTK_FLAGS_INCL_TID) {
 		if (in_interrupt())
-			res += printk(KERN_CONT "<intr> ");
+			snprintf(tid, sizeof(tid), "%s", "<intr> ");
 		else
-			res += printk(KERN_CONT "[%d] ", task_pid_vnr(current));
+			snprintf(tid, sizeof(tid), "[%d] ",
+				 task_pid_vnr(current));
+	} else {
+		tid[0] = 0;
 	}
-	if (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME)
-		res += printk(KERN_CONT "%s:", descriptor->modname);
-	if (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME)
-		res += printk(KERN_CONT "%s:", descriptor->function);
-	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
-		res += printk(KERN_CONT "%d ", descriptor->lineno);
 
-	return res;
+	if (descriptor->flags & _DPRINTK_FLAGS_INCL_LINENO)
+		snprintf(lineno, sizeof(lineno), "%d", descriptor->lineno);
+	else
+		lineno[0] = 0;
+
+	return printk(KERN_DEBUG "%s%s%s%s%s%s",
+		      tid,
+		      (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) ?
+		      descriptor->modname : "",
+		      (descriptor->flags & _DPRINTK_FLAGS_INCL_MODNAME) ?
+		      ":" : "",
+		      (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) ?
+		      descriptor->function : "",
+		      (descriptor->flags & _DPRINTK_FLAGS_INCL_FUNCNAME) ?
+		      ":" : "",
+		      lineno);
 }
 
 int __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...)
-- 
1.7.6.rc1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* [PATCH 4/4] dynamic_debug: Convert printks to pr_<level>
  2011-06-30 18:14                     ` [PATCH 0/4] dynamic_debug Joe Perches
                                         ` (2 preceding siblings ...)
  2011-06-30 18:14                       ` [PATCH 3/4] dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix Joe Perches
@ 2011-06-30 18:14                       ` Joe Perches
  2011-06-30 19:51                       ` [PATCH 0/4] dynamic_debug Jason Baron
  4 siblings, 0 replies; 38+ messages in thread
From: Joe Perches @ 2011-06-30 18:14 UTC (permalink / raw)
  To: Jason Baron, linux-kernel

Add pr_fmt(fmt) with __func__.
Converts "ddebug:" prefix to "dynamic_debug:".

Most likely the if (verbose) outputs could
also be converted from pr_info to pr_debug.

Signed-off-by: Joe Perches <joe@perches.com>
---
 lib/dynamic_debug.c |   59 ++++++++++++++++++++++----------------------------
 1 files changed, 26 insertions(+), 33 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 6669078..e627874 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -10,6 +10,8 @@
  * Copyright (C) 2011 Bart Van Assche.  All Rights Reserved.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ":%s: " fmt, __func__
+
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -160,8 +162,7 @@ static void ddebug_change(const struct ddebug_query *query,
 			else
 				dp->enabled = 0;
 			if (verbose)
-				printk(KERN_INFO
-					"ddebug: changed %s:%d [%s]%s %s\n",
+				pr_info("changed %s:%d [%s]%s %s\n",
 					dp->filename, dp->lineno,
 					dt->mod_name, dp->function,
 					ddebug_describe_flags(dp, flagbuf,
@@ -171,7 +172,7 @@ static void ddebug_change(const struct ddebug_query *query,
 	mutex_unlock(&ddebug_lock);
 
 	if (!nfound && verbose)
-		printk(KERN_INFO "ddebug: no matches for query\n");
+		pr_info("no matches for query\n");
 }
 
 /*
@@ -216,10 +217,10 @@ static int ddebug_tokenize(char *buf, char *words[], int maxwords)
 
 	if (verbose) {
 		int i;
-		printk(KERN_INFO "%s: split into words:", __func__);
+		pr_info("split into words:");
 		for (i = 0 ; i < nwords ; i++)
-			printk(" \"%s\"", words[i]);
-		printk("\n");
+			pr_cont(" \"%s\"", words[i]);
+		pr_cont("\n");
 	}
 
 	return nwords;
@@ -331,16 +332,15 @@ static int ddebug_parse_query(char *words[], int nwords,
 			}
 		} else {
 			if (verbose)
-				printk(KERN_ERR "%s: unknown keyword \"%s\"\n",
-					__func__, words[i]);
+				pr_err("unknown keyword \"%s\"\n", words[i]);
 			return -EINVAL;
 		}
 	}
 
 	if (verbose)
-		printk(KERN_INFO "%s: q->function=\"%s\" q->filename=\"%s\" "
-		       "q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n",
-			__func__, query->function, query->filename,
+		pr_info("q->function=\"%s\" q->filename=\"%s\" "
+			"q->module=\"%s\" q->format=\"%s\" q->lineno=%u-%u\n",
+			query->function, query->filename,
 			query->module, query->format, query->first_lineno,
 			query->last_lineno);
 
@@ -369,7 +369,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
 		return -EINVAL;
 	}
 	if (verbose)
-		printk(KERN_INFO "%s: op='%c'\n", __func__, op);
+		pr_info("op='%c'\n", op);
 
 	for ( ; *str ; ++str) {
 		for (i = ARRAY_SIZE(opt_array) - 1; i >= 0; i--) {
@@ -384,7 +384,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
 	if (flags == 0)
 		return -EINVAL;
 	if (verbose)
-		printk(KERN_INFO "%s: flags=0x%x\n", __func__, flags);
+		pr_info("flags=0x%x\n", flags);
 
 	/* calculate final *flagsp, *maskp according to mask and op */
 	switch (op) {
@@ -402,8 +402,7 @@ static int ddebug_parse_flags(const char *str, unsigned int *flagsp,
 		break;
 	}
 	if (verbose)
-		printk(KERN_INFO "%s: *flagsp=0x%x *maskp=0x%x\n",
-			__func__, *flagsp, *maskp);
+		pr_info("*flagsp=0x%x *maskp=0x%x\n", *flagsp, *maskp);
 	return 0;
 }
 
@@ -508,7 +507,7 @@ static __initdata char ddebug_setup_string[1024];
 static __init int ddebug_setup_query(char *str)
 {
 	if (strlen(str) >= 1024) {
-		pr_warning("ddebug boot param string too large\n");
+		pr_warn("ddebug boot param string too large\n");
 		return 0;
 	}
 	strcpy(ddebug_setup_string, str);
@@ -536,8 +535,7 @@ static ssize_t ddebug_proc_write(struct file *file, const char __user *ubuf,
 		return -EFAULT;
 	tmpbuf[len] = '\0';
 	if (verbose)
-		printk(KERN_INFO "%s: read %d bytes from userspace\n",
-			__func__, (int)len);
+		pr_info("read %d bytes from userspace\n", (int)len);
 
 	ret = ddebug_exec_query(tmpbuf);
 	if (ret)
@@ -600,8 +598,7 @@ static void *ddebug_proc_start(struct seq_file *m, loff_t *pos)
 	int n = *pos;
 
 	if (verbose)
-		printk(KERN_INFO "%s: called m=%p *pos=%lld\n",
-			__func__, m, (unsigned long long)*pos);
+		pr_info("called m=%p *pos=%lld\n", m, (unsigned long long)*pos);
 
 	mutex_lock(&ddebug_lock);
 
@@ -626,8 +623,8 @@ static void *ddebug_proc_next(struct seq_file *m, void *p, loff_t *pos)
 	struct _ddebug *dp;
 
 	if (verbose)
-		printk(KERN_INFO "%s: called m=%p p=%p *pos=%lld\n",
-			__func__, m, p, (unsigned long long)*pos);
+		pr_info("called m=%p p=%p *pos=%lld\n",
+			m, p, (unsigned long long)*pos);
 
 	if (p == SEQ_START_TOKEN)
 		dp = ddebug_iter_first(iter);
@@ -650,8 +647,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
 	char flagsbuf[8];
 
 	if (verbose)
-		printk(KERN_INFO "%s: called m=%p p=%p\n",
-			__func__, m, p);
+		pr_info("called m=%p p=%p\n", m, p);
 
 	if (p == SEQ_START_TOKEN) {
 		seq_puts(m,
@@ -676,8 +672,7 @@ static int ddebug_proc_show(struct seq_file *m, void *p)
 static void ddebug_proc_stop(struct seq_file *m, void *p)
 {
 	if (verbose)
-		printk(KERN_INFO "%s: called m=%p p=%p\n",
-			__func__, m, p);
+		pr_info("called m=%p p=%p\n", m, p);
 	mutex_unlock(&ddebug_lock);
 }
 
@@ -700,7 +695,7 @@ static int ddebug_proc_open(struct inode *inode, struct file *file)
 	int err;
 
 	if (verbose)
-		printk(KERN_INFO "%s: called\n", __func__);
+		pr_info("called\n");
 
 	iter = kzalloc(sizeof(*iter), GFP_KERNEL);
 	if (iter == NULL)
@@ -752,8 +747,7 @@ int ddebug_add_module(struct _ddebug *tab, unsigned int n,
 	mutex_unlock(&ddebug_lock);
 
 	if (verbose)
-		printk(KERN_INFO "%u debug prints in module %s\n",
-				 n, dt->mod_name);
+		pr_info("%u debug prints in module %s\n", n, dt->mod_name);
 	return 0;
 }
 EXPORT_SYMBOL_GPL(ddebug_add_module);
@@ -775,8 +769,7 @@ int ddebug_remove_module(const char *mod_name)
 	int ret = -ENOENT;
 
 	if (verbose)
-		printk(KERN_INFO "%s: removing module \"%s\"\n",
-				__func__, mod_name);
+		pr_info("removing module \"%s\"\n", mod_name);
 
 	mutex_lock(&ddebug_lock);
 	list_for_each_entry_safe(dt, nextdt, &ddebug_tables, link) {
@@ -852,8 +845,8 @@ static int __init dynamic_debug_init(void)
 	if (ddebug_setup_string[0] != '\0') {
 		ret = ddebug_exec_query(ddebug_setup_string);
 		if (ret)
-			pr_warning("Invalid ddebug boot param %s",
-				   ddebug_setup_string);
+			pr_warn("Invalid ddebug boot param %s",
+				ddebug_setup_string);
 		else
 			pr_info("ddebug initialized with string %s",
 				ddebug_setup_string);
-- 
1.7.6.rc1


^ permalink raw reply related	[flat|nested] 38+ messages in thread

* Re: [PATCH 0/4] dynamic_debug
  2011-06-30 18:14                     ` [PATCH 0/4] dynamic_debug Joe Perches
                                         ` (3 preceding siblings ...)
  2011-06-30 18:14                       ` [PATCH 4/4] dynamic_debug: Convert printks to pr_<level> Joe Perches
@ 2011-06-30 19:51                       ` Jason Baron
  4 siblings, 0 replies; 38+ messages in thread
From: Jason Baron @ 2011-06-30 19:51 UTC (permalink / raw)
  To: Joe Perches; +Cc: netdev, linux-kernel, greg

On Thu, Jun 30, 2011 at 11:14:33AM -0700, Joe Perches wrote:
> Some improvements and cleanups to dynamic_debug
> 
> btw Jason:
> 
> You're not listed in MAINTAINERS for dynamic_debug.[ch].
> Maybe you should add yourself. 
> 

Yes, I need to do that.

Thanks,

-Jason


> Joe Perches (4):
>   dynamic_debug: Add __dynamic_dev_dbg
>   dynamic_debug: Consolidate prefix output to single routine
>   dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix
>   dynamic_debug: Convert printks to pr_<level>
> 
>  drivers/base/core.c           |    5 +-
>  include/linux/device.h        |    5 ++
>  include/linux/dynamic_debug.h |   10 +++-
>  lib/dynamic_debug.c           |  133 +++++++++++++++++++++++++++--------------
>  4 files changed, 103 insertions(+), 50 deletions(-)
> 
> -- 
> 1.7.6.rc1
> 

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH] bluetooth: Add bt_printk
@ 2011-07-01 19:03                     ` Gustavo F. Padovan
  0 siblings, 0 replies; 38+ messages in thread
From: Gustavo F. Padovan @ 2011-07-01 19:03 UTC (permalink / raw)
  To: Joe Perches
  Cc: Marcel Holtmann, David S. Miller, linux-bluetooth, netdev, linux-kernel

Hi Joe,

* Joe Perches <joe@perches.com> [2011-06-30 00:19:51 -0700]:

> Add a local logging function to emit bluetooth specific
> messages.  Using vsprintf extension %pV saves code/text
> space.
> 
> Convert the current BT_INFO and BT_ERR macros to use bt_printk.
> Remove __func__ from BT_ERR macro (and the uses).
> Prefix "Bluetooth: " to BT_ERR
> Remove __func__ from BT_DBG as function can be prefixed when
> using dynamic_debug.
> 
> With allyesconfig:
> 
>    text	   data	    bss	    dec	    hex	filename
>  129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new2
>  134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old
>   14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new2
>   15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
>  346595	  19163	  86080	 451838	  6e4fe	net/bluetooth/built-in.o.new2
>  353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
>   18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new2
>   18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
>   19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new2
>   19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
>   59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new2
>   61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old
> 
> with x86 defconfig (and just bluetooth):
> 
> $ size net/bluetooth/built-in.o.defconfig.*
>    text	   data	    bss	    dec	    hex	filename
>   66358	    933	    100	  67391	  1073f	net/bluetooth/built-in.o.defconfig.new
>   66643	    933	    100	  67676	  1085c	net/bluetooth/built-in.o.defconfig.old
> 
> Signed-off-by: Joe Perches <joe@perches.com>

I applied this patch with a minimal change in the print format. I changed
'bluetooth' to 'Bluetooth'. Thanks a lot for the patch. ;)

	Gustavo

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH] bluetooth: Add bt_printk
@ 2011-07-01 19:03                     ` Gustavo F. Padovan
  0 siblings, 0 replies; 38+ messages in thread
From: Gustavo F. Padovan @ 2011-07-01 19:03 UTC (permalink / raw)
  To: Joe Perches
  Cc: Marcel Holtmann, David S. Miller,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

Hi Joe,

* Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org> [2011-06-30 00:19:51 -0700]:

> Add a local logging function to emit bluetooth specific
> messages.  Using vsprintf extension %pV saves code/text
> space.
> 
> Convert the current BT_INFO and BT_ERR macros to use bt_printk.
> Remove __func__ from BT_ERR macro (and the uses).
> Prefix "Bluetooth: " to BT_ERR
> Remove __func__ from BT_DBG as function can be prefixed when
> using dynamic_debug.
> 
> With allyesconfig:
> 
>    text	   data	    bss	    dec	    hex	filename
>  129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new2
>  134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old
>   14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new2
>   15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
>  346595	  19163	  86080	 451838	  6e4fe	net/bluetooth/built-in.o.new2
>  353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
>   18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new2
>   18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
>   19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new2
>   19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
>   59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new2
>   61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old
> 
> with x86 defconfig (and just bluetooth):
> 
> $ size net/bluetooth/built-in.o.defconfig.*
>    text	   data	    bss	    dec	    hex	filename
>   66358	    933	    100	  67391	  1073f	net/bluetooth/built-in.o.defconfig.new
>   66643	    933	    100	  67676	  1085c	net/bluetooth/built-in.o.defconfig.old
> 
> Signed-off-by: Joe Perches <joe-6d6DIl74uiNBDgjK7y7TUQ@public.gmane.org>

I applied this patch with a minimal change in the print format. I changed
'bluetooth' to 'Bluetooth'. Thanks a lot for the patch. ;)

	Gustavo

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH 1/2] bluetooth: Rename function bt_err to bt_to_errno
  2011-06-30  1:18             ` [PATCH 1/2] bluetooth: Rename function bt_err to bt_to_errno Joe Perches
@ 2011-07-01 19:04               ` Gustavo F. Padovan
  0 siblings, 0 replies; 38+ messages in thread
From: Gustavo F. Padovan @ 2011-07-01 19:04 UTC (permalink / raw)
  To: Joe Perches
  Cc: Marcel Holtmann, David S. Miller, linux-bluetooth, netdev, linux-kernel

* Joe Perches <joe@perches.com> [2011-06-29 18:18:29 -0700]:

> Make it easier to use more normal logging styles later.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  include/net/bluetooth/bluetooth.h |    2 +-
>  net/bluetooth/hci_core.c          |    2 +-
>  net/bluetooth/l2cap_core.c        |    4 ++--
>  net/bluetooth/lib.c               |    4 ++--
>  net/bluetooth/sco.c               |    4 ++--
>  5 files changed, 8 insertions(+), 8 deletions(-)

I applied this one as well. Thanks.

	Gustavo

^ permalink raw reply	[flat|nested] 38+ messages in thread

* Re: [PATCH] bluetooth: Add bt_printk
  2011-07-01 19:03                     ` Gustavo F. Padovan
  (?)
@ 2011-07-01 19:36                     ` Gustavo F. Padovan
  -1 siblings, 0 replies; 38+ messages in thread
From: Gustavo F. Padovan @ 2011-07-01 19:36 UTC (permalink / raw)
  To: Joe Perches
  Cc: Marcel Holtmann, David S. Miller, linux-bluetooth, netdev, linux-kernel

* Gustavo F. Padovan <padovan@profusion.mobi> [2011-07-01 16:03:27 -0300]:

> Hi Joe,
> 
> * Joe Perches <joe@perches.com> [2011-06-30 00:19:51 -0700]:
> 
> > Add a local logging function to emit bluetooth specific
> > messages.  Using vsprintf extension %pV saves code/text
> > space.
> > 
> > Convert the current BT_INFO and BT_ERR macros to use bt_printk.
> > Remove __func__ from BT_ERR macro (and the uses).
> > Prefix "Bluetooth: " to BT_ERR
> > Remove __func__ from BT_DBG as function can be prefixed when
> > using dynamic_debug.
> > 
> > With allyesconfig:
> > 
> >    text	   data	    bss	    dec	    hex	filename
> >  129956	   8632	  36096	 174684	  2aa5c	drivers/bluetooth/built-in.o.new2
> >  134402	   8632	  36064	 179098	  2bb9a	drivers/bluetooth/built-in.o.old
> >   14778	   1012	   3408	  19198	   4afe	net/bluetooth/bnep/built-in.o.new2
> >   15067	   1012	   3408	  19487	   4c1f	net/bluetooth/bnep/built-in.o.old
> >  346595	  19163	  86080	 451838	  6e4fe	net/bluetooth/built-in.o.new2
> >  353751	  19163	  86064	 458978	  700e2	net/bluetooth/built-in.o.old
> >   18483	   1172	   4264	  23919	   5d6f	net/bluetooth/cmtp/built-in.o.new2
> >   18927	   1172	   4264	  24363	   5f2b	net/bluetooth/cmtp/built-in.o.old
> >   19237	   1172	   5152	  25561	   63d9	net/bluetooth/hidp/built-in.o.new2
> >   19581	   1172	   5152	  25905	   6531	net/bluetooth/hidp/built-in.o.old
> >   59461	   3884	  14464	  77809	  12ff1	net/bluetooth/rfcomm/built-in.o.new2
> >   61206	   3884	  14464	  79554	  136c2	net/bluetooth/rfcomm/built-in.o.old
> > 
> > with x86 defconfig (and just bluetooth):
> > 
> > $ size net/bluetooth/built-in.o.defconfig.*
> >    text	   data	    bss	    dec	    hex	filename
> >   66358	    933	    100	  67391	  1073f	net/bluetooth/built-in.o.defconfig.new
> >   66643	    933	    100	  67676	  1085c	net/bluetooth/built-in.o.defconfig.old
> > 
> > Signed-off-by: Joe Perches <joe@perches.com>
> 
> I applied this patch with a minimal change in the print format. I changed
> 'bluetooth' to 'Bluetooth'. Thanks a lot for the patch. ;)

Ah, and in the case someone want to add the function name to debug messages
after this patch. It is easy. Just run

echo -n "module bluetooth +pf" > /sys/kernel/debug/dynamic_debug/control

And debug with funcion names will be enabled. ;)

	Gustavo

^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2011-07-01 19:36 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-28 18:20 [PATCH v4 0/6] NFC subsystem Aloisio Almeida Jr
2011-06-28 18:20 ` [PATCH v4 1/6] NFC: add nfc subsystem core Aloisio Almeida Jr
2011-06-28 20:18   ` Joe Perches
2011-06-28 23:31     ` Aloisio Almeida
2011-06-28 23:52       ` Joe Perches
2011-06-29  1:31     ` Marcel Holtmann
2011-06-29  1:49       ` Joe Perches
2011-06-29 18:00         ` Marcel Holtmann
2011-06-29 23:23           ` Aloisio Almeida
2011-06-29 23:46             ` Joe Perches
2011-06-30  3:26               ` Aloisio Almeida
2011-06-30  4:28                 ` RFC: Add __dynamic_dev_dbg Joe Perches
2011-06-30  4:49                 ` Joe Perches
2011-06-30 16:32                   ` Jason Baron
2011-06-30 18:14                     ` [PATCH 0/4] dynamic_debug Joe Perches
2011-06-30 18:14                       ` [PATCH 1/4] dynamic_debug: Add __dynamic_dev_dbg Joe Perches
2011-06-30 18:14                       ` [PATCH 2/4] dynamic_debug: Consolidate prefix output to single routine Joe Perches
2011-06-30 18:14                       ` [PATCH 3/4] dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix Joe Perches
2011-06-30 18:14                       ` [PATCH 4/4] dynamic_debug: Convert printks to pr_<level> Joe Perches
2011-06-30 19:51                       ` [PATCH 0/4] dynamic_debug Jason Baron
2011-06-30  1:18           ` [PATCH 0/2] bluetooth: Use current logging styles Joe Perches
2011-06-30  1:18             ` Joe Perches
2011-06-30  1:18             ` [PATCH 1/2] bluetooth: Rename function bt_err to bt_to_errno Joe Perches
2011-07-01 19:04               ` Gustavo F. Padovan
2011-06-30  1:18             ` [PATCH 2/2] bluetooth: Add bt_printk, convert logging macros to lower case Joe Perches
2011-06-30  3:31               ` Gustavo F. Padovan
2011-06-30  3:31                 ` Gustavo F. Padovan
2011-06-30  3:47                 ` Joe Perches
2011-06-30  7:19                 ` [PATCH] bluetooth: Add bt_printk Joe Perches
2011-06-30  7:19                   ` Joe Perches
2011-07-01 19:03                   ` Gustavo F. Padovan
2011-07-01 19:03                     ` Gustavo F. Padovan
2011-07-01 19:36                     ` Gustavo F. Padovan
2011-06-28 18:20 ` [PATCH v4 2/6] NFC: add nfc generic netlink interface Aloisio Almeida Jr
2011-06-28 18:20 ` [PATCH v4 3/6] NFC: add NFC socket family Aloisio Almeida Jr
2011-06-28 18:20 ` [PATCH v4 4/6] NFC: add the NFC socket raw protocol Aloisio Almeida Jr
2011-06-28 18:20 ` [PATCH v4 5/6] NFC: pn533: add NXP pn533 nfc device driver Aloisio Almeida Jr
2011-06-28 18:20 ` [PATCH v4 6/6] NFC: add Documentation/networking/nfc.txt Aloisio Almeida Jr

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.