NFC subsystem
Subsystems (10)
v4 cover NFC subsystem
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
Signature · 1 line
1.7.5.4
PATCH v4 1/6 NFC: add nfc subsystem core
From: Lauro Ramos Venancio <[email protected]>
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.
--- 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
drivers/Kconfig +0 -2
@@ -92,8 +92,6 @@ source "drivers/memstick/Kconfig" source "drivers/leds/Kconfig" -source "drivers/nfc/Kconfig" - source "drivers/accessibility/Kconfig" source "drivers/infiniband/Kconfig"
drivers/Makefile +1 -0
@@ -120,3 +120,4 @@ obj-y += ieee802154/ obj-y += clk/ obj-$(CONFIG_HWSPINLOCK) += hwspinlock/ +obj-$(CONFIG_NFC) += nfc/
drivers/nfc/Kconfig +3 -13
@@ -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
drivers/nfc/Makefile +2 -0
@@ -3,3 +3,5 @@ # obj-$(CONFIG_PN544_NFC) += pn544.o + +ccflags-$(CONFIG_NFC_DEBUG) := -DDEBUG
include/net/nfc.h new file +131 -0
131 lines not on this page · raw message
net/Kconfig +1 -0
@@ -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
net/Makefile +1 -0
@@ -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/
net/nfc/Kconfig new file +16 -0
@@ -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"
net/nfc/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# +# Makefile for the Linux NFC subsystem. +# + +obj-$(CONFIG_NFC) += nfc.o + +nfc-objs := core.o
net/nfc/core.c new file +344 -0
344 lines not on this page · raw message
net/nfc/nfc.h new file +75 -0
75 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Re: [PATCH v4 1/6] NFC: add nfc subsystem core
Quoted 4 lines · Aloisio Almeida Jr
From: Lauro Ramos Venancio <[email protected]>
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.
[]
net/nfc/nfc.h
Quoted 1 line
net/nfc/nfc.h +0
-0
[]
net/nfc/nfc.h line 31
Quoted 3 lines
net/nfc/nfc.h +3
-0+#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.
Re: [PATCH v4 1/6] NFC: add nfc subsystem core
Hi Joe,
Quoted 15 lines · Joe Perches
Quoted 4 lines · Aloisio Almeida Jr
From: Lauro Ramos Venancio <[email protected]>
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.[]
net/nfc/nfc.h
Quoted 1 line
net/nfc/nfc.h +0
-0[]
net/nfc/nfc.h line 31
Quoted 3 lines
net/nfc/nfc.h +3
-0+#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.
Quoted 8 lines
#define
nfc_info(etc...)
#definenfc_err(etc...)
#definenfc_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.
Quoted 2 lines
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
Re: [PATCH v4 1/6] NFC: add nfc subsystem core
Quoted 1 line · Aloisio Almeida
Hi Joe,
Oi Aloisio.
Quoted 23 lines · Joe Perches
Quoted 15 lines · Aloisio Almeida Jr
Quoted 4 lines
From: Lauro Ramos Venancio <[email protected]>
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.[]
net/nfc/nfc.h
Quoted 1 line
net/nfc/nfc.h +0
-0[]
net/nfc/nfc.h line 31
Quoted 3 lines
net/nfc/nfc.h +3
-0+#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.Quoted 7 lines
#define
nfc_info(etc...)
#definenfc_err(etc...)
#definenfc_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.
Quoted 8 lines
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.
Quoted 1 line
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
Marcel Holtmann
maintainerRe: [PATCH v4 1/6] NFC: add nfc subsystem core
In reply to Joe PerchesHi Joe,
Quoted 13 lines
Quoted 3 lines
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.
[]
net/nfc/nfc.h
Quoted 1 line
net/nfc/nfc.h +0
-0[]
net/nfc/nfc.h line 31
Quoted 3 lines
net/nfc/nfc.h +3
-0+#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.
Quoted 7 lines
#define
nfc_info(etc...)
#definenfc_err(etc...)
#definenfc_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.
Quoted 1 line
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
Re: [PATCH v4 1/6] NFC: add nfc subsystem core
Quoted 1 line · Marcel Holtmann
Hi Joe,
Hello Marcel.
Quoted 18 lines
Quoted 6 lines
Quoted 3 lines
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.
[]
net/nfc/nfc.h
Quoted 1 line
net/nfc/nfc.h +0
-0[]
Quoted 11 lines
net/nfc/nfc.h line 31
Quoted 3 lines
net/nfc/nfc.h +3
-0+#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.
#definenfc_info(etc...)
#definenfc_err(etc...)
#definenfc_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.
Quoted 2 lines
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.
Quoted 3 lines
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.
Quoted 4 lines
At this stage of the project it is a bit too early to tell I guess.
Quoted 1 line
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
Marcel Holtmann
maintainerRe: [PATCH v4 1/6] NFC: add nfc subsystem core
Hi Joe,
Quoted 14 lines
Quoted 3 lines
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.
Quoted 4 lines
At this stage of the project it is a bit too early to tell I guess.
Quoted 1 line
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.
Quoted 6 lines
I don't disagree that while debugging function names and tracing function entries/exits are useful.
Today,
dynamic_debugcan 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
Re: [PATCH v4 1/6] NFC: add nfc subsystem core
Hi Joe and Marcel,
Quoted 19 lines · Marcel Holtmann
Hi Joe,
Quoted 17 lines
Quoted 3 lines
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.
Quoted 4 lines
At this stage of the project it is a bit too early to tell I guess.
Quoted 1 line
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.
Quoted 6 lines
Quoted 3 lines
Today,
dynamic_debugcan 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
Re: [PATCH v4 1/6] NFC: add nfc subsystem core
Quoted 5 lines · Aloisio Almeida
Quoted 3 lines
Quoted 3 lines
Today,
dynamic_debugcan 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 ondev_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?
Quoted 8 lines
So, for
net/nfc/*I propose to use directly pr_*() functions. For device drivers the following macros would be provided:
#definenfc_dev_info(dev, fmt, arg...)dev_info((dev), "NFC: " fmt, ## arg)#definenfc_dev_err(dev, fmt, arg...)dev_err((dev), "%s: " fmt, __func__, ## arg)
#definenfc_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
Re: [PATCH v4 1/6] NFC: add nfc subsystem core
Hi Joe,
Quoted 19 lines · Joe Perches
Quoted 5 lines · Aloisio Almeida
Quoted 3 lines
Quoted 3 lines
Today,
dynamic_debugcan 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 ondev_dbg()calls dynamically.I believe that's false. It's definitely stored.
#define
dynamic_dev_dbg(dev, fmt, ...)do { \
static struct_ddebugdescriptor \
__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)
Quoted 1 line
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.
Quoted 1 line
I think you should add NFC to
nfc_dev_errtoo.
That's make sense to me also.
Aloisio
RFC: Add __dynamic_dev_dbg
Quoted 4 lines · Aloisio Almeida
It's stored but not retrieved. If you check
lib/dynamic_debug.cyou see that only__dynamic_pr_debug()(called bydynamic_pr_debug()) adds such information on prints. Thedev_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(-)
drivers/base/core.c +3 -2
@@ -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, ...)
include/linux/device.h +5 -0
@@ -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 )));
include/linux/dynamic_debug.h +8 -2
@@ -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
lib/dynamic_debug.c +38 -0
@@ -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) {
RFC: Add __dynamic_dev_dbg
In reply to Aloisio AlmeidaQuoted 4 lines · Aloisio Almeida
It's stored but not retrieved. If you check
lib/dynamic_debug.cyou see that only__dynamic_pr_debug()(called bydynamic_pr_debug()) adds such information on prints. Thedev_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(-)
drivers/base/core.c +3 -2
@@ -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, ...)
include/linux/device.h +5 -0
@@ -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 )));
include/linux/dynamic_debug.h +8 -2
@@ -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
lib/dynamic_debug.c +38 -0
@@ -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) {
Re: RFC: Add __dynamic_dev_dbg
Quoted 6 lines · Joe Perches
(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
Quoted 153 lines
---
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(-)drivers/base/core.c +3
-2@@ -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, ...)include/linux/device.h +5
-0@@ -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 )));include/linux/dynamic_debug.h +8
-2@@ -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 ) #elselib/dynamic_debug.c +38
-1@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
cover dynamic_debug
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(-)
Signature · 1 line
1.7.6.rc1
Re: [PATCH 0/4] dynamic_debug
Quoted 7 lines · Joe Perches
Some improvements and cleanups to
dynamic_debugbtw Jason:
You're not listed in
MAINTAINERSfor dynamic_debug.[ch]. Maybe you should add yourself.
Yes, I need to do that.
Thanks,
-Jason
Quoted 15 lines
Joe Perches (4):
dynamic_debug: Add__dynamic_dev_dbg
dynamic_debug: Consolidate prefix output to single routine
dynamic_debug: Remove uses ofKERN_CONTindynamic_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(-)Signature · 1 line
1.7.6.rc1
PATCH 1/4 dynamic_debug: Add __dynamic_dev_dbg
In reply to Jason BaronUnlike 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.
--- 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(-)
drivers/base/core.c +3 -2
@@ -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, ...)
include/linux/device.h +5 -0
@@ -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 )));
include/linux/dynamic_debug.h +8 -2
@@ -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
lib/dynamic_debug.c +38 -0
@@ -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) {
Signature · 1 line
1.7.6.rc1
PATCH 2/4 dynamic_debug: Consolidate prefix output to single routine
In reply to Jason BaronAdding dynamic_dev_dbg duplicated prefix output.
Consolidate that output to a single routine.
--- lib/dynamic_debug.c | 38 ++++++++++++++++++-------------------- 1 files changed, 18 insertions(+), 20 deletions(-)
lib/dynamic_debug.c +18 -20
@@ -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);
Signature · 1 line
1.7.6.rc1
PATCH 3/4 dynamic_debug: Remove uses of KERN_CONT in dynamic_emit_prefix
In reply to Jason BaronMultiple printks with KERN_CONT can be interleaved by other printks. Reduce the likelihood of that interleaving by consolidating multiple calls to printk.
--- lib/dynamic_debug.c | 34 +++++++++++++++++++++++----------- 1 files changed, 23 insertions(+), 11 deletions(-)
lib/dynamic_debug.c +23 -11
@@ -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, ...)
Signature · 1 line
1.7.6.rc1
PATCH 4/4 dynamic_debug: Convert printks to pr_<level>
In reply to Jason BaronAdd 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.
--- lib/dynamic_debug.c | 59 ++++++++++++++++++++++---------------------------- 1 files changed, 26 insertions(+), 33 deletions(-)
lib/dynamic_debug.c +26 -33
@@ -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);
Signature · 1 line
1.7.6.rc1
cover bluetooth: Use current logging styles
In reply to Marcel HoltmannQuoted 9 lines · Marcel Holtmann
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 tobt_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(-)
Signature · 1 line
1.7.6.rc1
PATCH 1/2 bluetooth: Rename function bt_err to bt_to_errno
Make it easier to use more normal logging styles later.
--- 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(-)
include/net/bluetooth/bluetooth.h +1 -1
@@ -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 );
net/bluetooth/hci_core.c +1 -1
@@ -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 :
net/bluetooth/l2cap_core.c +2 -2
@@ -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 ; }
net/bluetooth/lib.c +2 -2
@@ -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);
net/bluetooth/sco.c +2 -2
@@ -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 ; }
Signature · 1 line
1.7.6.rc1
Gustavo F. Padovan
AppliedRe: [PATCH 1/2] bluetooth: Rename function bt_err to bt_to_errno
Quoted 10 lines · Joe Perches
Make it easier to use more normal logging styles later.
Signed-off-by Joe Perches <[email protected]>--- 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
PATCH 2/2 bluetooth: Add bt_printk, convert logging macros to lower case
In reply to Joe PerchesUse 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
--- 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(-)
drivers/bluetooth/ath3k.c +24 -24
@@ -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); }
drivers/bluetooth/bcm203x.c +19 -19
@@ -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_idstruct 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_idrelease_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; }
drivers/bluetooth/bfusb.c +47 -47
350 lines not on this page · raw message
drivers/bluetooth/bluecard_cs.c +9 -9
@@ -218,7 +218,7 @@ static int bluecard_write(unsigned int iobase, unsigned int offset, __u8 *buf, istatic 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);
drivers/bluetooth/bpa10x.c +19 -19
@@ -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); }
drivers/bluetooth/bt3c_cs.c +17 -17
@@ -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:
drivers/bluetooth/btmrvl_debugfs.c +1 -1
@@ -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 ; }
drivers/bluetooth/btmrvl_main.c +37 -37
258 lines not on this page · raw message
drivers/bluetooth/btmrvl_sdio.c +56 -56
437 lines not on this page · raw message
drivers/bluetooth/btsdio.c +13 -13
@@ -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); }
drivers/bluetooth/btuart_cs.c +12 -12
@@ -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:
drivers/bluetooth/btusb.c +32 -32
256 lines not on this page · raw message
drivers/bluetooth/btwilink.c +17 -17
@@ -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); }
drivers/bluetooth/dtl1_cs.c +10 -10
@@ -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);
drivers/bluetooth/hci_ath.c +7 -7
@@ -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; }
drivers/bluetooth/hci_bcsp.c +29 -29
219 lines not on this page · raw message
drivers/bluetooth/hci_h4.c +9 -9
@@ -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) { registerint 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; }
drivers/bluetooth/hci_ldisc.c +18 -18
@@ -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);
drivers/bluetooth/hci_ll.c +38 -38
132 lines not on this page · raw message
net/bluetooth/cmtp/capi.c +23 -23
46 lines not on this page · raw message
net/bluetooth/hci_conn.c +26 -26
52 lines not on this page · raw message
net/bluetooth/hci_core.c +70 -70
140 lines not on this page · raw message
net/bluetooth/hci_event.c +117 -117
234 lines not on this page · raw message
net/bluetooth/hidp/core.c +25 -25
50 lines not on this page · raw message
net/bluetooth/l2cap_core.c +84 -84
168 lines not on this page · raw message
net/bluetooth/mgmt.c +40 -40
80 lines not on this page · raw message
net/bluetooth/rfcomm/core.c +76 -76
152 lines not on this page · raw message
net/bluetooth/rfcomm/sock.c +28 -28
56 lines not on this page · raw message
net/bluetooth/rfcomm/tty.c +50 -50
100 lines not on this page · raw message
net/bluetooth/sco.c +40 -40
80 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
1.7.6.rc1
Part of the diff is not shown here. View the raw message.
Re: [PATCH 2/2] bluetooth: Add bt_printk, convert logging macros to lower case
Hi Joe,
Quoted 18 lines · Joe Perches
Use the more common logging styles.
bt_printuses 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
Quoted 4 lines
$ 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
Re: [PATCH 2/2] bluetooth: Add bt_printk, convert logging macros to lower case
Quoted 1 line · Gustavo F. Padovan
Hi Joe,
Hello Gustavo.
Quoted 19 lines
Quoted 19 lines
Use the more common logging styles.
bt_printuses 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
Quoted 1 line
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>
Quoted 2 lines
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.
Quoted 4 lines
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
PATCH 1/1 bluetooth: Add bt_printk
In reply to Gustavo F. PadovanAdd 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
--- include/net/bluetooth/bluetooth.h | 9 ++++++--- net/bluetooth/lib.c | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-)
include/net/bluetooth/bluetooth.h +6 -3
@@ -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 {
net/bluetooth/lib.c +19 -0
@@ -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);
Signature · 1 line
1.7.6.rc1
Re: [PATCH] bluetooth: Add bt_printk
Hi Joe,
Quoted 26 lines · Joe Perches
Add a local logging function to emit bluetooth specific messages. Using vsprintf extension %pV saves code/text space.
Convert the current
BT_INFOandBT_ERRmacros to usebt_printk. Remove__func__fromBT_ERRmacro (and the uses). Prefix "Bluetooth: " toBT_ERR
Remove__func__fromBT_DBGas function can be prefixed when usingdynamic_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
Quoted 8 lines
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.oldSigned-off-by Joe Perches <[email protected]>
I applied this patch with a minimal change in the print format. I changed 'bluetooth' to 'Bluetooth'. Thanks a lot for the patch. ;)
Gustavo
Re: [PATCH] bluetooth: Add bt_printk
Quoted 37 lines · Gustavo F. Padovan
Hi Joe,
Quoted 33 lines · Joe Perches
Add a local logging function to emit bluetooth specific messages. Using vsprintf extension %pV saves code/text space.
Convert the current
BT_INFOandBT_ERRmacros to usebt_printk. Remove__func__fromBT_ERRmacro (and the uses). Prefix "Bluetooth: " toBT_ERR
Remove__func__fromBT_DBGas function can be prefixed when usingdynamic_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.oldwith 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
Quoted 4 lines
Quoted 1 line
Signed-off-by Joe Perches <[email protected]>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
PATCH v4 2/6 NFC: add nfc generic netlink interface
In reply to Aloisio Almeida JrFrom: Lauro Ramos Venancio <[email protected]>
The NFC generic netlink interface exports the NFC control operations to the user space.
--- 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
include/linux/nfc.h new file +112 -0
@@ -0,0 +1,112 @@ +/* +* Copyright (C) 2011 Instituto Nokia de Tecnologia +* +* Authors: +* Lauro Ramos Venancio <[email protected]> +* Aloisio Almeida Jr <[email protected]> +* +* 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 */
include/net/nfc.h +21 -0
@@ -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 */
net/nfc/Makefile +1 -1
@@ -4,4 +4,4 @@ obj-$(CONFIG_NFC) += nfc.o -nfc-objs := core.o +nfc-objs := core.o netlink.o
net/nfc/core.c +89 -2
138 lines not on this page · raw message
net/nfc/netlink.c new file +537 -0
537 lines not on this page · raw message
net/nfc/nfc.h +11 -0
@@ -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)
Signature · 1 line
1.7.5.4
PATCH v4 3/6 NFC: add NFC socket family
In reply to Aloisio Almeida Jr--- 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
include/linux/nfc.h +3 -0
@@ -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 */
include/linux/socket.h +3 -1
@@ -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. */
net/core/sock.c +3 -3
@@ -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" };/*
net/nfc/Makefile +1 -1
@@ -4,4 +4,4 @@ obj-$(CONFIG_NFC) += nfc.o -nfc-objs := core.o netlink.o +nfc-objs := core.o netlink.o af_nfc.o
net/nfc/af_nfc.c new file +98 -0
98 lines not on this page · raw message
net/nfc/core.c +7 -0
@@ -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); }
net/nfc/nfc.h +14 -0
@@ -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;
Signature · 1 line
1.7.5.4
PATCH v4 4/6 NFC: add the NFC socket raw protocol
In reply to Aloisio Almeida JrFrom: Lauro Ramos Venancio <[email protected]>
This socket protocol is used to perform data exchange with NFC targets.
--- 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
include/linux/nfc.h +12 -1
@@ -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 */
net/nfc/Makefile +1 -1
@@ -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
net/nfc/core.c +7 -0
@@ -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); }
net/nfc/nfc.h +14 -0
@@ -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);
net/nfc/rawsock.c new file +351 -0
351 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH v4 5/6 NFC: pn533: add NXP pn533 nfc device driver
In reply to Aloisio Almeida Jr--- 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
drivers/nfc/Kconfig +10 -0
@@ -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
drivers/nfc/Makefile +1 -0
@@ -3,5 +3,6 @@ # obj-$(CONFIG_PN544_NFC) += pn544.o +obj-$(CONFIG_NFC_PN533) += pn533.o ccflags-$(CONFIG_NFC_DEBUG) := -DDEBUG
drivers/nfc/pn533.c new file +1630 -0
1,630 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH v4 6/6 NFC: add Documentation/networking/nfc.txt
In reply to Aloisio Almeida Jr--- Documentation/networking/nfc.txt | 128 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 128 insertions(+), 0 deletions(-) create mode 100644 Documentation/networking/nfc.txt
Documentation/networking/nfc.txt new file +128 -0
@@ -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.
Signature · 1 line
1.7.5.4