Linux bluetooth development
 help / color / mirror / Atom feed
* Re: HDP proposed API(0.5)
From: José Antonio Santos Cadenas @ 2010-05-17 21:40 UTC (permalink / raw)
  To: João Paulo Rechi Vita; +Cc: linux-bluetooth
In-Reply-To: <AANLkTikCmZydkLG863_MbrMhiNlWx5GecQaXitr1q0xX@mail.gmail.com>

El Monday 17 May 2010 23:17:58 João Paulo Rechi Vita escribió:
> On Mon, May 17, 2010 at 11:54, José Antonio Santos Cadenas
> 
> <jcaden@libresoft.es> wrote:
> > Hope the last one :)
> > 
> > ----------------------------
> > 
> > BlueZ D-Bus Health API description
> > **********************************
> > 
> >        Santiago Carot-Nemesio <sancane@gmail.com>
> >        José Antonio Santos-Cadenas <santoscadenas@gmail.com>
> >        Elvis Pfützenreuter <epx@signove.com>
> > 
> > Health Device Profile hierarchy
> > ===============================
> > 
> > Service         org.bluez
> > Interface       org.bluez.HealthAdapter
> > Object path     [variable prefix]/{hci0,hci1,...}
> > 
> > Methods         object CreateInstance(object path, dict config)
> > 
> >                        Returns the path for the new HealthInstance
> > object. The path parameter is the path of the remote object with the
> > callbacks to notify events (see
> >                        org.bluez.HealthAgent at the end of this document)
> >                        This petition starts an mcap instance and also
> > register in the SDP if is needed
> >                        Dict is defined as bellow:
> >                        { "data_spec" : The data_spec is the data exchange
> >                                        specification (see section 5.2.10
> > of the specification document) possible values:
> >                                                0x00 = reserved,
> >                                                0x01 [IEEE 11073-20601],
> >                                                0x02..0xff reserved,
> >                                        (optional)
> >                          "end_points" : [{ (optional)
> >                                "mdepid" : uint8, (optional)
> >                                "role" : ("source" or "sink"), (mandatory)
> >                                "specs" :[{ (mandatory)
> >                                        "data_type" : uint16, (mandatory)
> >                                        "description" : string, (optional)
> >                                }]
> >                          }]
> >                        }
> > 
> >                        if "data_spec" is not set, no SDP record will be
> >                        registered, so all the other data in the
> > dictionary will be ignored
> > 
> >                        Instance will be closed by the call or implicitly
> > when the programs leaves the bus.
> > 
> >                        Possible errors: org.bluez.Error.InvalidArguments
> > 
> >                void CloseInstance(object path)
> > 
> >                        Closes the HDP instance identified by the object
> > path. Also instance will be closed if the process that started leaves
> > the bus. If there is a SDP record associated to this instance it will be
> > removed.
> > 
> >                        Possible errors: org.bluez.Error.InvalidArguments
> >                                        org.bluez.Error.NotFound
> > 
> > -------------------------------------------------------------------------
> > -------
> > 
> > Service         org.bluez
> > Interface       org.bluez.HealthDevice
> > Object path     [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
> > 
> > Methods         array GetHealthInstances()
> > 
> >                        Gets the information of the remote instances
> > present in this device and published on its SDP record. The returned
> > data follows this format.
> > 
> >                        [{"id": "an instance identification as string",
> >                         "data_spec" : data spec,
> >                         "end_points":
> >                                ["mdepid": uint8,
> >                                 "role"  : "source" or "sink" ,
> >                                 "specs" : [{
> >                                        "dtype"       : uint16,
> >                                        "description" : string, (optional)
> >                                 }]
> >                                ]
> >                        }];
> > 
> > -------------------------------------------------------------------------
> > -------
> > 
> > Service         org.bluez
> > Interface       org.bluez.HealthInstance
> > Object path     [variable prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}
> > 
> >                object Connect(remote_instance_id)
> > 
> >                        Connects with the remote instance and returns its
> > object path. To get the session ids on a remote device, you must run the
> > GetHealthInstances in the HealthDevice object.
> > 
> >                        Possible errors: org.bluez.Error.InvalidArguments
> >                                        org.bluez.Error.HealthError
> > 
> >                void Disconnect(object device, boolean cache)
> > 
> >                        Disconnect from the remote device. If chahe is
> > false, state will also be deleted. Otherwise, the state will be kept for
> > allowing future reconnections until the adapter is removed.
> > 
> >                        Possible errors: org.bluez.Error.InvalidArguments
> >                                        org.bluez.Error.NotFound
> >                                        org.bluez.Error.HealthError
> > 
> > -------------------------------------------------------------------------
> > -------
> > 
> > Service         org.bluez
> > Interface       org.bluez.HealthLink
> > Object path     [variable
> > prefix]/{hci0,hci1,...}/{hdp0,hdp1,...}/rem_inst_id
> > 
> >                boolean Echo(array{byte})
> > 
> >                        Sends an echo petition to the remote intance.
> > Returns True if response matches with the buffer sent. If some error is
> > detected False value is returned and the associated MCL is closed.
> > 
> >                uint16 OpenDataChannel(byte mdepid, byte config)
> > 
> >                        Creates a new data channel with the indicated
> > config to the remote MCAP Data End Point (MDEP). The configuration
> > should indicate the channel quality of service. In the current version
> > of HDP, valid values are 0x01 for reliable channels and 0x02 for
> > streaming data channel.
> > 
> >                        Returns the data channel id.
> > 
> >                        Possible errors: org.bluez.Error.InvalidArguments
> >                                        org.bluez.Error.HealthError
> > 
> >                array GetDataChannelFileDescriptor(uint16 mdlid)
> 
> Wouldn't be better to pass the fd through the LinkConnected call on
> Agent? Doing it here allows any process to get the fds.

Originally we thought about doing like that. But Elvis suggested to centralize 
all the ways that you get the file descriptor in just one place and we thought 
that it was a great idea. In addition, think that you will need this call 
because the LinkConnected call is only called when the connection is initiated 
by the remote HDP instance but the connections initiated by your side will not 
be notified. About the "security" issue you mentioned, we are planing to 
control who can call this methods only the process that initiated the HDP 
instance will receive a response to this methods, any other process will 
receive an error.

> 
> >                        Gets a file descriptor where data can be read or
> >                        written for receive or sent by the data channel.
> >                        Returns an array of file descriptors one for write
> >                        and other for read.
> > 
> >                        Possible errors: org.bluez.Error.InvalidArguments
> >                                        org.bluez.Error.NotFound
> >                                        org.bluez.Error.HealthError
> > 
> >                void DeleteDataChannel(uint16 mdlid)
> > 
> >                        Deletes a data channel so it will not be available
> > for use.
> > 
> >                        Possible errors: org.bluez.Error.InvalidArguments
> >                                        org.bluez.Error.NotFound
> >                                        org.bluez.Error.HealthError
> > 
> >                void DeleteAllDataChannels()
> > 
> >                        Deletes all data channels so it will not be
> > available for use. Typically this function is called when the connection
> > with the remote device will be closed permanently
> > 
> >                        Possible errors: org.bluez.Error.HealthError
> > 
> >                dict GetDataChannelStatus()
> > 
> >                        Return a dictionary with all the data channels
> > that can be used to send data right now. The dictionary is formed like
> > follows:
> >                        {
> >                                "reliable": [mdlid_r1, mdlid_r2, ...],
> >                                "streaming" : [mdlid_s1, mdlid_s2, ...]
> >                        }
> > 
> >                        The fist reliable data channel will always be the
> > first data channel in reliable array.
> > 
> > HealthAgent hierarchy
> > ==================
> > 
> > (this object is implemented by the HDP client an receives notifications)
> > 
> > Service         unique name
> > Interface       org.bluez.HealthAgent
> > Object path     freely definable
> > 
> >                void LinkConnected(object path)
> > 
> >                        This method is called whenever a new connection
> >                        has been established over the control channel of
> > the current HDP instance. The object path paremeter contains the object
> > path of the created HealthLink.
> > 
> >                void LinkDisconnected(object path)
> > 
> >                        This method is called when a remote device is
> >                        disconnected definitively. Any future
> > reconnections will fail. Also all data channels associated to this
> > device will be closed.
> > 
> >                void CreatedDataChannel(object path, uint16 mdlid, byte
> > conf)
> > 
> >                        This method is called when a new data channel is
> > created The path contains the object path of the HealthLink where the
> > new connection is created, the mdlid is the data channel identificator
> > and conf is the que quality of service of the data channel (0x01
> > reliable, 0x02 streaming).
> > 
> >                void DeletedDataChannel(object path, uint16 mdlid)
> > 
> >                        This method is called when a data channel is
> > closed. After this call the data channel will not be valid and can be
> > reused for future created data channels. --
> > To unsubscribe from this list: send the line "unsubscribe
> > linux-bluetooth" in the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* Re: HDP proposed API(0.5)
From: Gustavo F. Padovan @ 2010-05-17 23:20 UTC (permalink / raw)
  To: Elvis Pfützenreuter
  Cc: João Paulo Rechi Vita, jcaden, linux-bluetooth
In-Reply-To: <DCEDCB0F-6BA3-4100-96F9-0A33AC440F82@signove.com>

Hi Elvis,

* Elvis Pfützenreuter <epx@signove.com> [2010-05-17 19:02:33 -0300]:

> 
> On 17/05/2010, at 18:38, Gustavo F. Padovan wrote:
> 
> > Hi,
> > 
> > * João Paulo Rechi Vita <jprvita@gmail.com> [2010-05-17 18:17:58 -0300]:
> > 
> > <snip>
> > 
> >> On Mon, May 17, 2010 at 11:54, José Antonio Santos Cadenas
> >> <jcaden@libresoft.es> wrote:
> >>> 
> >>>                array GetDataChannelFileDescriptor(uint16 mdlid)
> >>> 
> >> 
> >> Wouldn't be better to pass the fd through the LinkConnected call on
> >> Agent? Doing it here allows any process to get the fds.
> > 
> > I was thinking about the MCAP in kernel implementation, my conclusion is
> > that we can solve one of the biggest problem of HDP API if we do it in
> > kernel: the transparency of MCAP reconnection. HDP will open an MCAP
> > socket and pass it to the user(IEEE app). Then if we need a
> > reconnection, MCAP will transparently reconnect changing the L2CAP
> > channel to transmit the data without the need to change the socket
> > opened with the userspace.
> > 
> > Keep the MCAP socket open means that we are keeping the MCL state for
> > further reconnection.
> > 
> > Doing it inside the kernel removes a big amount of complexity of HDP and
> > IEEE profiles, since we won't need any pipe or change of fd. That could
> > be a killer feature to make it in the kernel.
> > 
> > Any comments? Is this reasonable?
> 
> 
> The fd passed to the application could actually be an UNIX socket, so these semantics could be implemented with MCAP in user space. I guess the pipes only appeared in discussion because of the possibility of zero-copy communication.

MCAP in kernel gives zero-copy communication and just one socket to the
HDP API. The better of both UNIX socket and pipes options.
 
> That semantics would be implemented in MCAP part. The HDP profile code itself is (or should be) free from these worries.
> 
> Moving MCAP to kernel hides the complexity from userspace HDP profile, but it continues to exist. Then I worry about more complex debugging, dependency on kernel version (or need to put efforts on backporting). MCAP sits above L2CAP, not besides it.

The complexity will exist anyway, I'm proposing a less complex option.
Is not that complex change the L2CAP channels used by the MCL inside the
kernel. Between all the proposed options to handle reconnection it
looks the less complex one.

We should not care about backporting now. We are working directly
with upstream and upstream is what really matters here. :)

You will depend on kernel version anyway since ERTM is inside the
kernel. About backport if you backport ERTM, then backport MCAP will be
easy.

Also MCAP will keep sitting on top of L2CAP, that won't change.

> 
> I acknowledge that it would work, but honestly I prefer to see things being moved to the outside of the kernel than to the inside :)

The real question here is where MCAP will fit better. And where it adds
less complexity to its users.

-- 
Gustavo F. Padovan
http://padovan.org

^ permalink raw reply

* Compat-wireless for 2.6.34 final - 802.11 and bluetooth backported
From: Luis R. Rodriguez @ 2010-05-18  1:27 UTC (permalink / raw)
  To: linux-wireless, linux-bluetooth
  Cc: linux-kernel, Pavel Roskin, Hauke Mehrtens

2.6.34 was released today and now we get a respective compat-wireless
stable [1] tarball based on it [2]. This gives us the 2.6.34 802.11
subsystem, bluetooth subsystem and new 802.11/bluetooth drivers
compilable and installable on older kernels. Please report any issues
ASAP. For details on changes you can refer to the
ChangeLog-2.6.34-wireless [3].

Worth mentioning for this release is I've updated the version tagging
for compat-wireless to allow distributions/users/developers to keep
better track of what exact revision is being used. This was based on
Pavel Roskin's suggestion to use read-only module parameters which are
kept even if you build this tarball into your kernel somehow. Here is
an example of the new files and example output based on this specific
new tarball release:

$ sudo grep '' /sys/module/compat/parameters/compat_*
/sys/module/compat/parameters/compat_base_tree:linux-2.6-allstable.git
/sys/module/compat/parameters/compat_base_tree_version:v2.6.34
/sys/module/compat/parameters/compat_version:compat-wireless-v2.6.34-6-g0ad438e

Upon loading the compat module you would also see this output:

Compat-wireless backport release: compat-wireless-v2.6.34-6-g0ad438e
Backport based on linux-2.6-allstable.git v2.6.34

Since git describe is being used to describe both the base tree and
the compat-wireless release you will be able to tell how many patches
on top of the base tree have been applied. This should account for any
deltas you have created and reflect that (hope is the delta is always
0 with respect to upstream). In the above example output there are 6
patches on top of the "compat-wireless-v2.6.34" tag I created for the
first release, I then found some bugs due to the new version scheme
changes and fixed some of them, so I have applied 6 patches on top of
the original release.

I should note there are a few modules which *do not* make use of the
compat module but do make use of a lot of the defines at build time,
an example of such a module is rndis_wlan so you'd have to load the
compat module manually to get the above info or run strings on the
module.

With bleeding edge releases you will now get:

$ sudo grep '' /sys/module/compat/parameters/compat_*
/sys/module/compat/parameters/compat_base_tree:linux-next.git
/sys/module/compat/parameters/compat_base_tree_version:next-20100517
/sys/module/compat/parameters/compat_version:compat-wireless-20100517-7-ged07f6b

The respective output upon load is:

Compat-wireless backport release: compat-wireless-20100517-7-ged07f6b
Backport based on linux-next.git next-20100517

If there are any questions please let me know.

On a final note thanks to all those who have contributed to this
2.6.34 release of both the generic kernel compatibility module and
compat-wireless, specially to Haukes and Pavel.

Below is the shortlog linux-2.6.33.y.. of compat-wireless:

Bala Shanmugam (1):
      compat-2.6: New targets to compile bluetooth alone

Hauke Mehrtens (17):
      compat-wireless: Add more functions into netdev oops backport
      compat-wireless: backport kfifo for libertas
      compat-wireless: Backport net_device_ops set_mac_address
      compat-wireless: activate usbnet for kernel > 2.6.28
      compat-wireless: Activate ssb and libertas
      compat-wireless: Add missing file
      This adds a refresh option to admin-update.sh using quilt.
      compat-wireless: Refresh patches
      compat-wireless: small fixes to admin-update.sh
      compat-wireless: Backport netdev_ops select_queue
      compat-wireless: remove device_type in usbnet.c
      compat-wireless: missing ksize export
      compat-wireless: fix constant name
      compat-wireless: fix bluetooth capi build
      compat-wireless: update .gitignore
      compat-wireless: update config options
      compat-wireless: Fix refresh script if no patches are available

Luis R. Rodriguez (55):
      Update patch hunk offsets for next-20091228
      Intel removed uts header, update patch for that
      Update patch hunks for next-20100106
      Remove pointless bt-install-scripts extra target
      Fix iwlagn patch offset breakage
      Update patch 01-netdev.patch offsets
      Update 17-netdev-queue.patch offsets
      Update hunk offsets for 15-symbol-export-conflicts.patch
      Update error message on old unsupported kernels
      Add support for driver-select to enable older kernels
      Stop carrying around bitops.h header
      Stop carrying around pm_qos_params.h
      Stop carrying around the include/linux/unaligned stuff
      Actually copy over the new headers from compat
      Move down bluetooth config.mk options
      Prevent CONFIG_COMPAT_BLUETOOTH_* options from going to compat_autoconf.h
      Disable bluetooth compat for kernels older than 2.6.27
      Enable CONFIG_BT_CMTP only if CONFIG_BT_CMTP is enabled
      Ran ./scripts/admin-update.sh refresh
      Fix driver-select for ath9k and ath5k
      Fix a few typos on config.mk and the new enable olde kernel patches
      Enable 2.6.23 for ath9k and ath5k
      Backport access to pcidev->is_pcie member for kernels < 2.6.24
      Add backport for netns for kernels <= 2.6.24 for 802.11
      Disable 2.6.24 for ath9k and ath5k
      ./scripts/admin-update.sh refresh
      Fix typo on 06-header-changes.patch
      Enable CONFIG_COMPAT_FIRMWARE_CLASS for kernels < 2.6.33
      Fix driver_select for ar9170
      Only build compat_firmware_class if CONFIG_FW_LOADER was enabled
      Copy over the new udev scripts/rules from compat.git
      ./scripts/admin-update.sh refresh
      Run admin-update-.sh refresh for 2010-02-01
      compat-wireless: fix patches/16-bluetooth.patch
      Run ./scripts/admin-update.sh refresh
      Fix patches/16-bluetooth.patch
      Enable CONFIG_BT_ATH3K
      ./scripts/admin-update.sh refresh for next-20100216
      Backport multiqueue support for kernels < 2.6.27
      Add linux-next cherry picked patches directory
      Skip empty patch directories if one is found.
      Some updates to make the patches apply to 2.6.34
      admin-update refresh
      compat-wireless: add test cherry pick patch
      Fix drivers usb Makefile for 2.6.34
      ./scripts/admin-update.sh refresh
      Change admin-update.sh to use system version files
      Split up the NOSTDINC_FLAGS into a few lines
      Use the defines to tag the compat module
      Document /sys/module/compat/parameters/compat_* on README
      Fix dependency on on WEXT
      Fix the CREL compat-wireless release name on top level Makefile
      Fix gen-compat-autoconf.sh for new version name changes
      Fix scripts/driver-select due to new version changes
      Add the compat to the unload of the modules

And the generic kernel compatibility module keeps moving along as
well, here's that shortlog:

Felix Fietkau (2):
      compat: fix firmware class compile on linux 2.6.32
      compat: add rcu_dereference_check

Grazvydas Ignotas (1):
      compat: fix uevent_suppress on 2.6.29 or older kernels

Hauke Mehrtens (19):
      compat: fix two return types
      compat: autoconf.h moved from linux/ to generated/ with kernel 2.6.33
      compat: build pccard and pcmcia condituinaly
      compat: fix build with CONFIG_USB=m
      compat: fix build on arm
      compat: backport genlmsg_unicast
      compat: backport some netdevice.h defs
      compat: backport some more of the netdev debug printk
      compat: fix some build problems with kernel 2.6.24
      compat: backport device_{lock,trylock,unlock}
      compat: update bitops.h
      compat: backport PCMCIA_DEVICE_PROD_ID3
      compat: Backport clamp
      compat: Add definitions needed for libertas sdio driver.
      compat: Add linux/version.h include before using it.
      compat: backport convert multicast list to list_head.
      compat: update compat_firmware_class.c to new version
      compat: backport sk_sleep
      compat: backport usb_alloc_coherent() and usb_free_coherent()

Luis R. Rodriguez (17):
      Add notes about why debugfs_remove_recursive() cannot be backported
      Update for next-20100113
      Backport the new firmware_class from > 2.6.33 down to 2.6.23
      Enable the compat_firmware_class to be built only on < 2.6.32
      Enable 2.6.33 compatibility
      Export CONFIG_COMPAT_FIRMWARE_CLASS
      Fix loading of compat_firmware_class due to class name conflict
      Only build compat_firmware_class if CONFIG_FW_LOADER was enabled
      Fix build with CONFIG_PCMCIA disabled
      Fix build with CONFIG_USB disabled
      Install udev rules and scripts needed for compat_firmware_class
      Add a print for v2.6.34-rc4
      compat: add compat_version read-only module parameter
      Modify compat main print
      Add the COMPAT_BASE_TREE and COMPAT_BASE_TREE_VERSION
      Add a COMPAT_PROJECT tag
      Fix the syntax for the defines passed for compat

Pavel Roskin (9):
      compat: backport for ARM dma_sync_single_range_*() helpers
      compat: backport debugfs_remove_recursive()
      compat: move debugfs_remove_recursive() to compat-2.6.27
      compat: define KEY_RFKILL, which appeared in Linux 2.6.33
      compat: add compat-2.6.35.h and IW_HANDLER
      compat: add qdisc_all_tx_empty for Linux 2.6.26 and older
      compat: add device_create() implementation for Linux 2.6.26 and older
      compat: add stub headers linux/tracepoint.h and trace/define_trace.h
      compat: add net/net_namespace.h stub for Linux 2.6.23 and older

[1] http://wireless.kernel.org/en/users/Download/stable
[2] http://www.orbit-lab.org/kernel/compat-wireless-2.6-stable/v2.6.34/compat-wireless-2.6.34.tar.bz2
[3] http://www.orbit-lab.org/kernel/compat-wireless-2.6-stable/v2.6.34/ChangeLog-2.6.34-wireless

  Luis

^ permalink raw reply

* [PATCH 1/4] Add manual log to hcitrace
From: Gustavo F. Padovan @ 2010-05-18  2:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: gustavo, marcel

Remove the BlueZ log scheme from hcitrace to avoid intersection with the
new BlueZ dynamic debug.
---
 Makefile.tools |    3 +--
 tracer/main.c  |   38 ++++++++++++++++++++++++++------------
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/Makefile.tools b/Makefile.tools
index d9a2425..b311223 100644
--- a/Makefile.tools
+++ b/Makefile.tools
@@ -63,8 +63,7 @@ EXTRA_DIST += tools/rfcomm.conf
 if TRACER
 sbin_PROGRAMS += tracer/hcitrace
 
-tracer_hcitrace_SOURCES = tracer/main.c \
-				src/logging.h src/logging.c
+tracer_hcitrace_SOURCES = tracer/main.c
 tracer_hcitrace_LDADD = lib/libbluetooth.la \
 				@GLIB_LIBS@ @DBUS_LIBS@ @CAPNG_LIBS@
 tracer_hcitrace_DEPENDENCIES = lib/libbluetooth.la
diff --git a/tracer/main.c b/tracer/main.c
index 5ec5ff2..0806ffe 100644
--- a/tracer/main.c
+++ b/tracer/main.c
@@ -32,11 +32,10 @@
 #include <string.h>
 #include <signal.h>
 #include <sys/stat.h>
+#include <syslog.h>
 
 #include <glib.h>
 
-#include "logging.h"
-
 #ifdef HAVE_CAPNG
 #include <cap-ng.h>
 #endif
@@ -48,11 +47,6 @@ static void sig_term(int sig)
 	g_main_loop_quit(event_loop);
 }
 
-static void sig_debug(int sig)
-{
-	toggle_debug();
-}
-
 static gboolean option_detach = TRUE;
 static gboolean option_debug = FALSE;
 
@@ -65,6 +59,25 @@ static GOptionEntry options[] = {
 	{ NULL },
 };
 
+static void debug(const char *format, ...)
+{
+	va_list ap;
+
+	if (!option_debug)
+		return;
+
+	va_start(ap, format);
+
+	vsyslog(LOG_DEBUG, format, ap);
+
+	va_end(ap);
+}
+
+static void sig_debug(int sig)
+{
+	option_debug = !option_debug;
+}
+
 int main(int argc, char *argv[])
 {
 	GOptionContext *context;
@@ -103,7 +116,9 @@ int main(int argc, char *argv[])
 
 	umask(0077);
 
-	start_logging("hcitrace", "HCI trace daemon %s", VERSION);
+	openlog("hcitrace", LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_DAEMON);
+
+	syslog(LOG_INFO, "HCI trace deamon %s", VERSION);
 
 	memset(&sa, 0, sizeof(sa));
 	sa.sa_flags = SA_NOCLDSTOP;
@@ -118,8 +133,7 @@ int main(int argc, char *argv[])
 	sigaction(SIGPIPE, &sa, NULL);
 
 	if (option_debug == TRUE) {
-		info("Enabling debug information");
-		enable_debug();
+		syslog(LOG_INFO, "Enabling debug information");
 	}
 
 	event_loop = g_main_loop_new(NULL, FALSE);
@@ -130,9 +144,9 @@ int main(int argc, char *argv[])
 
 	g_main_loop_unref(event_loop);
 
-	info("Exit");
+	syslog(LOG_INFO, "Exit");
 
-	stop_logging();
+	closelog();
 
 	return 0;
 }
-- 
1.7.1

^ permalink raw reply related

* [PATCH 2/4] Add dynamic debug feature
From: Gustavo F. Padovan @ 2010-05-18  2:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: gustavo, marcel
In-Reply-To: <1274149638-31580-1-git-send-email-gustavo@padovan.org>

It is still needed a sed work in the sources to changes debug() to DBG()

Thanks, to Vinicius Gomes that helped me sort out a linking issue with
this patch.
---
 src/logging.c |   69 ++++++++++++++++++++++++++++++++++++++------------------
 src/logging.h |   34 +++++++++++++++++++++++-----
 src/main.c    |   36 ++++++++++++++---------------
 3 files changed, 92 insertions(+), 47 deletions(-)

diff --git a/src/logging.c b/src/logging.c
index 704f848..39a5142 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -29,9 +29,9 @@
 #include <stdarg.h>
 #include <syslog.h>
 
-#include "logging.h"
+#include <glib.h>
 
-static volatile int debug_enabled = 0;
+#include "logging.h"
 
 static inline void vinfo(const char *format, va_list ap)
 {
@@ -64,9 +64,6 @@ void debug(const char *format, ...)
 {
 	va_list ap;
 
-	if (!debug_enabled)
-		return;
-
 	va_start(ap, format);
 
 	vsyslog(LOG_DEBUG, format, ap);
@@ -74,35 +71,63 @@ void debug(const char *format, ...)
 	va_end(ap);
 }
 
-void toggle_debug(void)
-{
-	debug_enabled = (debug_enabled + 1) % 2;
-}
+extern struct btd_debug_desc __start___debug[];
+extern struct btd_debug_desc __stop___debug[];
 
-void enable_debug(void)
-{
-	debug_enabled = 1;
-}
+static gchar **enabled = NULL;
 
-void disable_debug(void)
+static gboolean is_enabled(struct btd_debug_desc *desc)
 {
-	debug_enabled = 0;
+        int i;
+
+        if (enabled == NULL)
+                return 0;
+
+        for (i = 0; enabled[i] != NULL; i++) {
+                if (desc->name != NULL && g_pattern_match_simple(enabled[i],
+                                                        desc->name) == TRUE)
+                        return 1;
+                if (desc->file != NULL && g_pattern_match_simple(enabled[i],
+                                                        desc->file) == TRUE)
+                        return 1;
+        }
+
+        return 0;
 }
 
-void start_logging(const char *ident, const char *message, ...)
+void __btd_log_init(const char *debug, int detach)
 {
-	va_list ap;
+	int option = LOG_NDELAY | LOG_PID;
+	struct btd_debug_desc *desc;
+	const char *name = NULL, *file = NULL;
 
-	openlog(ident, LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_DAEMON);
+	if (debug != NULL)
+		enabled = g_strsplit_set(debug, ":, ", 0);
 
-	va_start(ap, message);
+	for (desc = __start___debug; desc < __stop___debug; desc++) {
+		if (file != NULL || name != NULL) {
+			if (g_strcmp0(desc->file, file) == 0) {
+				if (desc->name == NULL)
+					desc->name = name;
+			} else
+				file = NULL;
+		}
 
-	vinfo(message, ap);
+		if (is_enabled(desc))
+			desc->flags |= BTD_DEBUG_FLAG_PRINT;
+	}
 
-	va_end(ap);
+	if (!detach)
+		option |= LOG_PERROR;
+
+	openlog("bluetoothd", option, LOG_DAEMON);
+
+	syslog(LOG_INFO, "Bluetooth deamon %s", VERSION);
 }
 
-void stop_logging(void)
+void __btd_log_cleanup(void)
 {
 	closelog();
+
+	g_strfreev(enabled);
 }
diff --git a/src/logging.h b/src/logging.h
index 2e9d564..9af51e7 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -27,12 +27,34 @@
 void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
 void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
 void debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void toggle_debug(void);
-void enable_debug(void);
-void disable_debug(void);
-void start_logging(const char *ident, const char *message, ...);
-void stop_logging(void);
 
-#define DBG(fmt, arg...)  debug("%s: " fmt "\n" , __FUNCTION__ , ## arg)
+void __btd_log_init(const char *debug, int detach);
+void __btd_log_cleanup(void);
+
+struct btd_debug_desc {
+        const char *name;
+        const char *file;
+#define BTD_DEBUG_FLAG_DEFAULT (0)
+#define BTD_DEBUG_FLAG_PRINT   (1 << 0)
+        unsigned int flags;
+} __attribute__((aligned(8)));
+
+/**
+ * DBG:
+ * @fmt: format string
+ * @arg...: list of arguments
+ *
+ * Simple macro around debug() which also include the function
+ * name it is called in.
+ */
+#define DBG(fmt, arg...) do { \
+        static struct btd_debug_desc __btd_debug_desc \
+        __attribute__((used, section("__debug"), aligned(8))) = { \
+                .file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
+        }; \
+        if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
+                debug("%s:%s() " fmt, \
+                                        __FILE__, __FUNCTION__ , ## arg); \
+} while (0)
 
 #endif /* __LOGGING_H */
diff --git a/src/main.c b/src/main.c
index 014d8b6..ac14165 100644
--- a/src/main.c
+++ b/src/main.c
@@ -288,13 +288,8 @@ static void sig_term(int sig)
 	g_main_loop_quit(event_loop);
 }
 
-static void sig_debug(int sig)
-{
-	toggle_debug();
-}
-
+static gchar *option_debug = NULL;
 static gboolean option_detach = TRUE;
-static gboolean option_debug = FALSE;
 static gboolean option_udev = FALSE;
 
 static guint last_adapter_timeout = 0;
@@ -327,12 +322,23 @@ void btd_stop_exit_timer(void)
 	last_adapter_timeout = 0;
 }
 
+static gboolean parse_debug(const char *key, const char *value, gpointer user_data, GError **error)
+{
+	if (value)
+		option_debug = g_strdup(value);
+	else
+		option_debug = g_strdup("*");
+
+	return TRUE;
+}
+
 static GOptionEntry options[] = {
 	{ "nodaemon", 'n', G_OPTION_FLAG_REVERSE,
 				G_OPTION_ARG_NONE, &option_detach,
 				"Don't run as daemon in background" },
-	{ "debug", 'd', 0, G_OPTION_ARG_NONE, &option_debug,
-				"Enable debug information output" },
+	{ "debug", 'd', G_OPTION_FLAG_OPTIONAL_ARG,
+				G_OPTION_ARG_CALLBACK, parse_debug,
+				"Enable debug information output", "DEBUG" },
 	{ "udev", 'u', 0, G_OPTION_ARG_NONE, &option_udev,
 				"Run from udev mode of operation" },
 	{ NULL },
@@ -392,7 +398,7 @@ int main(int argc, char *argv[])
 
 	umask(0077);
 
-	start_logging("bluetoothd", "Bluetooth daemon %s", VERSION);
+	__btd_log_init(option_debug, option_detach);
 
 	memset(&sa, 0, sizeof(sa));
 	sa.sa_flags = SA_NOCLDSTOP;
@@ -400,17 +406,9 @@ int main(int argc, char *argv[])
 	sigaction(SIGTERM, &sa, NULL);
 	sigaction(SIGINT,  &sa, NULL);
 
-	sa.sa_handler = sig_debug;
-	sigaction(SIGUSR2, &sa, NULL);
-
 	sa.sa_handler = SIG_IGN;
 	sigaction(SIGPIPE, &sa, NULL);
 
-	if (option_debug == TRUE) {
-		info("Enabling debug information");
-		enable_debug();
-	}
-
 	config = load_config(CONFIGDIR "/main.conf");
 
 	parse_config(config);
@@ -446,7 +444,7 @@ int main(int argc, char *argv[])
 
 	rfkill_init();
 
-	debug("Entering main loop");
+	DBG("Entering main loop");
 
 	g_main_loop_run(event_loop);
 
@@ -469,7 +467,7 @@ int main(int argc, char *argv[])
 
 	info("Exit");
 
-	stop_logging();
+	__btd_log_cleanup();
 
 	return 0;
 }
-- 
1.7.1

^ permalink raw reply related

* [PATCH 3/4] Move debug() to DBG()
From: Gustavo F. Padovan @ 2010-05-18  2:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: gustavo, marcel
In-Reply-To: <1274149638-31580-2-git-send-email-gustavo@padovan.org>

Use the new dynamic debug feature
---
 audio/a2dp.c             |  112 +++++++++++++++++++++++-----------------------
 audio/avdtp.c            |   98 ++++++++++++++++++++--------------------
 audio/control.c          |   36 +++++++-------
 audio/device.c           |    4 +-
 audio/gateway.c          |   14 +++---
 audio/headset.c          |   62 +++++++++++++-------------
 audio/main.c             |    6 +-
 audio/manager.c          |   46 +++++++++---------
 audio/sink.c             |   22 +++++-----
 audio/source.c           |   22 +++++-----
 audio/telephony-dummy.c  |   36 +++++++-------
 audio/telephony-maemo5.c |   64 +++++++++++++-------------
 audio/telephony-maemo6.c |   66 +++++++++++++-------------
 audio/telephony-ofono.c  |   74 +++++++++++++++---------------
 audio/telephony.h        |    4 +-
 audio/unix.c             |   30 ++++++------
 input/device.c           |    6 +-
 input/manager.c          |    2 +-
 input/server.c           |    2 +-
 network/common.c         |    4 +-
 network/connection.c     |    4 +-
 network/manager.c        |   18 ++++----
 network/server.c         |    8 ++--
 plugins/echo.c           |    4 +-
 plugins/hal.c            |    4 +-
 plugins/hciops.c         |    4 +-
 plugins/netlink.c        |    2 +-
 plugins/pnat.c           |   14 +++---
 plugins/service.c        |   16 +++---
 serial/port.c            |    8 ++--
 serial/proxy.c           |   16 +++---
 src/adapter.c            |   38 ++++++++--------
 src/agent.c              |   12 +++---
 src/dbus-hci.c           |   32 +++++++-------
 src/device.c             |   36 +++++++-------
 src/main.c               |   36 +++++++-------
 src/plugin.c             |    8 ++--
 src/rfkill.c             |    4 +-
 src/sdpd-service.c       |    6 +-
 src/security.c           |    6 +-
 40 files changed, 493 insertions(+), 493 deletions(-)

diff --git a/audio/a2dp.c b/audio/a2dp.c
index 148898a..fd12fbe 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -112,14 +112,14 @@ static struct a2dp_setup *setup_ref(struct a2dp_setup *setup)
 {
 	setup->ref++;
 
-	debug("setup_ref(%p): ref=%d", setup, setup->ref);
+	DBG("setup_ref(%p): ref=%d", setup, setup->ref);
 
 	return setup;
 }
 
 static void setup_free(struct a2dp_setup *s)
 {
-	debug("setup_free(%p)", s);
+	DBG("setup_free(%p)", s);
 	setups = g_slist_remove(setups, s);
 	if (s->session)
 		avdtp_unref(s->session);
@@ -132,7 +132,7 @@ static void setup_unref(struct a2dp_setup *setup)
 {
 	setup->ref--;
 
-	debug("setup_unref(%p): ref=%d", setup, setup->ref);
+	DBG("setup_unref(%p): ref=%d", setup, setup->ref);
 
 	if (setup->ref <= 0)
 		setup_free(setup);
@@ -290,9 +290,9 @@ static gboolean sbc_setconf_ind(struct avdtp *session,
 	struct audio_device *dev;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Set_Configuration_Ind", sep);
+		DBG("Sink %p: Set_Configuration_Ind", sep);
 	else
-		debug("Source %p: Set_Configuration_Ind", sep);
+		DBG("Source %p: Set_Configuration_Ind", sep);
 
 	dev = a2dp_get_dev(session);
 	if (!dev) {
@@ -353,9 +353,9 @@ static gboolean sbc_getcap_ind(struct avdtp *session, struct avdtp_local_sep *se
 	struct sbc_codec_cap sbc_cap;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Get_Capability_Ind", sep);
+		DBG("Sink %p: Get_Capability_Ind", sep);
 	else
-		debug("Source %p: Get_Capability_Ind", sep);
+		DBG("Source %p: Get_Capability_Ind", sep);
 
 	*caps = NULL;
 
@@ -417,9 +417,9 @@ static gboolean mpeg_setconf_ind(struct avdtp *session,
 	struct audio_device *dev;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Set_Configuration_Ind", sep);
+		DBG("Sink %p: Set_Configuration_Ind", sep);
 	else
-		debug("Source %p: Set_Configuration_Ind", sep);
+		DBG("Source %p: Set_Configuration_Ind", sep);
 
 	dev = a2dp_get_dev(session);
 	if (!dev) {
@@ -458,9 +458,9 @@ static gboolean mpeg_getcap_ind(struct avdtp *session,
 	struct mpeg_codec_cap mpeg_cap;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Get_Capability_Ind", sep);
+		DBG("Sink %p: Get_Capability_Ind", sep);
 	else
-		debug("Source %p: Get_Capability_Ind", sep);
+		DBG("Source %p: Get_Capability_Ind", sep);
 
 	*caps = NULL;
 
@@ -515,9 +515,9 @@ static void setconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	int ret;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Set_Configuration_Cfm", sep);
+		DBG("Sink %p: Set_Configuration_Cfm", sep);
 	else
-		debug("Source %p: Set_Configuration_Cfm", sep);
+		DBG("Source %p: Set_Configuration_Cfm", sep);
 
 	setup = find_setup_by_session(session);
 
@@ -557,9 +557,9 @@ static gboolean getconf_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Get_Configuration_Ind", sep);
+		DBG("Sink %p: Get_Configuration_Ind", sep);
 	else
-		debug("Source %p: Get_Configuration_Ind", sep);
+		DBG("Source %p: Get_Configuration_Ind", sep);
 	return TRUE;
 }
 
@@ -570,9 +570,9 @@ static void getconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Set_Configuration_Cfm", sep);
+		DBG("Sink %p: Set_Configuration_Cfm", sep);
 	else
-		debug("Source %p: Set_Configuration_Cfm", sep);
+		DBG("Source %p: Set_Configuration_Cfm", sep);
 }
 
 static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
@@ -582,9 +582,9 @@ static gboolean open_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Open_Ind", sep);
+		DBG("Sink %p: Open_Ind", sep);
 	else
-		debug("Source %p: Open_Ind", sep);
+		DBG("Source %p: Open_Ind", sep);
 	return TRUE;
 }
 
@@ -596,9 +596,9 @@ static void open_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_setup *setup;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Open_Cfm", sep);
+		DBG("Sink %p: Open_Cfm", sep);
 	else
-		debug("Source %p: Open_Cfm", sep);
+		DBG("Source %p: Open_Cfm", sep);
 
 	setup = find_setup_by_session(session);
 	if (!setup)
@@ -636,9 +636,9 @@ static gboolean start_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_setup *setup;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Start_Ind", sep);
+		DBG("Sink %p: Start_Ind", sep);
 	else
-		debug("Source %p: Start_Ind", sep);
+		DBG("Source %p: Start_Ind", sep);
 
 	setup = find_setup_by_session(session);
 	if (setup)
@@ -662,9 +662,9 @@ static void start_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_setup *setup;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Start_Cfm", sep);
+		DBG("Sink %p: Start_Cfm", sep);
 	else
-		debug("Source %p: Start_Cfm", sep);
+		DBG("Source %p: Start_Cfm", sep);
 
 	setup = find_setup_by_session(session);
 	if (!setup)
@@ -685,9 +685,9 @@ static gboolean suspend_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Suspend_Ind", sep);
+		DBG("Sink %p: Suspend_Ind", sep);
 	else
-		debug("Source %p: Suspend_Ind", sep);
+		DBG("Source %p: Suspend_Ind", sep);
 
 	if (a2dp_sep->suspend_timer) {
 		g_source_remove(a2dp_sep->suspend_timer);
@@ -708,9 +708,9 @@ static void suspend_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	gboolean start;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Suspend_Cfm", sep);
+		DBG("Sink %p: Suspend_Cfm", sep);
 	else
-		debug("Source %p: Suspend_Cfm", sep);
+		DBG("Source %p: Suspend_Cfm", sep);
 
 	a2dp_sep->suspending = FALSE;
 
@@ -751,9 +751,9 @@ static gboolean close_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Close_Ind", sep);
+		DBG("Sink %p: Close_Ind", sep);
 	else
-		debug("Source %p: Close_Ind", sep);
+		DBG("Source %p: Close_Ind", sep);
 
 	return TRUE;
 }
@@ -816,9 +816,9 @@ static void close_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_setup *setup;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Close_Cfm", sep);
+		DBG("Sink %p: Close_Cfm", sep);
 	else
-		debug("Source %p: Close_Cfm", sep);
+		DBG("Source %p: Close_Cfm", sep);
 
 	setup = find_setup_by_session(session);
 	if (!setup)
@@ -842,9 +842,9 @@ static gboolean abort_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Abort_Ind", sep);
+		DBG("Sink %p: Abort_Ind", sep);
 	else
-		debug("Source %p: Abort_Ind", sep);
+		DBG("Source %p: Abort_Ind", sep);
 
 	a2dp_sep->stream = NULL;
 
@@ -859,9 +859,9 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_setup *setup;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: Abort_Cfm", sep);
+		DBG("Sink %p: Abort_Cfm", sep);
 	else
-		debug("Source %p: Abort_Cfm", sep);
+		DBG("Source %p: Abort_Cfm", sep);
 
 	setup = find_setup_by_session(session);
 	if (!setup)
@@ -876,9 +876,9 @@ static gboolean reconf_ind(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: ReConfigure_Ind", sep);
+		DBG("Sink %p: ReConfigure_Ind", sep);
 	else
-		debug("Source %p: ReConfigure_Ind", sep);
+		DBG("Source %p: ReConfigure_Ind", sep);
 	return TRUE;
 }
 
@@ -891,9 +891,9 @@ static gboolean delayreport_ind(struct avdtp *session,
 	struct audio_device *dev = a2dp_get_dev(session);
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: DelayReport_Ind", sep);
+		DBG("Sink %p: DelayReport_Ind", sep);
 	else
-		debug("Source %p: DelayReport_Ind", sep);
+		DBG("Source %p: DelayReport_Ind", sep);
 
 	unix_delay_report(dev, rseid, delay);
 
@@ -908,9 +908,9 @@ static void reconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_setup *setup;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: ReConfigure_Cfm", sep);
+		DBG("Sink %p: ReConfigure_Cfm", sep);
 	else
-		debug("Source %p: ReConfigure_Cfm", sep);
+		DBG("Source %p: ReConfigure_Cfm", sep);
 
 	setup = find_setup_by_session(session);
 	if (!setup)
@@ -931,9 +931,9 @@ static void delay_report_cfm(struct avdtp *session, struct avdtp_local_sep *sep,
 	struct a2dp_sep *a2dp_sep = user_data;
 
 	if (a2dp_sep->type == AVDTP_SEP_TYPE_SINK)
-		debug("Sink %p: DelayReport_Cfm", sep);
+		DBG("Sink %p: DelayReport_Cfm", sep);
 	else
-		debug("Source %p: DelayReport_Cfm", sep);
+		DBG("Source %p: DelayReport_Cfm", sep);
 }
 
 static struct avdtp_sep_cfm cfm = {
@@ -1129,7 +1129,7 @@ int a2dp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 	str = g_key_file_get_string(config, "General", "Enable", &err);
 
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else {
 		if (strstr(str, "Sink"))
@@ -1142,7 +1142,7 @@ int a2dp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 	str = g_key_file_get_string(config, "General", "Disable", &err);
 
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else {
 		if (strstr(str, "Sink"))
@@ -1154,7 +1154,7 @@ int a2dp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 
 	str = g_key_file_get_string(config, "A2DP", "SBCSources", &err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else {
 		sbc_srcs = atoi(str);
@@ -1163,7 +1163,7 @@ int a2dp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 
 	str = g_key_file_get_string(config, "A2DP", "MPEG12Sources", &err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else {
 		mpeg12_srcs = atoi(str);
@@ -1172,7 +1172,7 @@ int a2dp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 
 	str = g_key_file_get_string(config, "A2DP", "SBCSinks", &err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else {
 		sbc_sinks = atoi(str);
@@ -1181,7 +1181,7 @@ int a2dp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 
 	str = g_key_file_get_string(config, "A2DP", "MPEG12Sinks", &err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else {
 		mpeg12_sinks = atoi(str);
@@ -1354,7 +1354,7 @@ unsigned int a2dp_config(struct avdtp *session, struct a2dp_sep *sep,
 	if (sep->codec != codec_cap->media_codec_type)
 		return 0;
 
-	debug("a2dp_config: selected SEP %p", sep->sep);
+	DBG("a2dp_config: selected SEP %p", sep->sep);
 
 	cb_data = g_new0(struct a2dp_setup_cb, 1);
 	cb_data->config_cb = cb;
@@ -1419,7 +1419,7 @@ unsigned int a2dp_config(struct avdtp *session, struct a2dp_sep *sep,
 	case AVDTP_STATE_OPEN:
 	case AVDTP_STATE_STREAMING:
 		if (avdtp_stream_has_capabilities(setup->stream, caps)) {
-			debug("Configuration match: resuming");
+			DBG("Configuration match: resuming");
 			g_idle_add((GSourceFunc) finalize_config, setup);
 		} else if (!setup->reconfigure) {
 			setup->reconfigure = TRUE;
@@ -1558,7 +1558,7 @@ gboolean a2dp_cancel(struct audio_device *dev, unsigned int id)
 	struct a2dp_setup *setup;
 	GSList *l;
 
-	debug("a2dp_cancel()");
+	DBG("a2dp_cancel()");
 
 	setup = find_setup_by_dev(dev);
 	if (!setup)
@@ -1592,7 +1592,7 @@ gboolean a2dp_sep_lock(struct a2dp_sep *sep, struct avdtp *session)
 	if (sep->locked)
 		return FALSE;
 
-	debug("SEP %p locked", sep->sep);
+	DBG("SEP %p locked", sep->sep);
 	sep->locked = TRUE;
 
 	return TRUE;
@@ -1606,7 +1606,7 @@ gboolean a2dp_sep_unlock(struct a2dp_sep *sep, struct avdtp *session)
 
 	sep->locked = FALSE;
 
-	debug("SEP %p unlocked", sep->sep);
+	DBG("SEP %p unlocked", sep->sep);
 
 	if (!sep->stream || state == AVDTP_STATE_IDLE)
 		return TRUE;
diff --git a/audio/avdtp.c b/audio/avdtp.c
index beacb32..19a15a4 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -541,7 +541,7 @@ static gboolean avdtp_send(struct avdtp *session, uint8_t transaction,
 	cont_fragments = (len - (session->omtu - sizeof(start))) /
 					(session->omtu - sizeof(cont)) + 1;
 
-	debug("avdtp_send: %zu bytes split into %d fragments", len,
+	DBG("avdtp_send: %zu bytes split into %d fragments", len,
 							cont_fragments + 1);
 
 	/* Send the start packet */
@@ -559,7 +559,7 @@ static gboolean avdtp_send(struct avdtp *session, uint8_t transaction,
 	if (!try_send(sock, session->buf, session->omtu))
 		return FALSE;
 
-	debug("avdtp_send: first packet with %zu bytes sent",
+	DBG("avdtp_send: first packet with %zu bytes sent",
 						session->omtu - sizeof(start));
 
 	sent = session->omtu - sizeof(start);
@@ -572,12 +572,12 @@ static gboolean avdtp_send(struct avdtp *session, uint8_t transaction,
 		if (left + sizeof(cont) > session->omtu) {
 			cont.packet_type = AVDTP_PKT_TYPE_CONTINUE;
 			to_copy = session->omtu - sizeof(cont);
-			debug("avdtp_send: sending continue with %d bytes",
+			DBG("avdtp_send: sending continue with %d bytes",
 								to_copy);
 		} else {
 			cont.packet_type = AVDTP_PKT_TYPE_END;
 			to_copy = left;
-			debug("avdtp_send: sending end with %d bytes",
+			DBG("avdtp_send: sending end with %d bytes",
 								to_copy);
 		}
 
@@ -625,7 +625,7 @@ static gboolean stream_close_timeout(gpointer user_data)
 {
 	struct avdtp_stream *stream = user_data;
 
-	debug("Timed out waiting for peer to close the transport channel");
+	DBG("Timed out waiting for peer to close the transport channel");
 
 	stream->timer = 0;
 
@@ -638,7 +638,7 @@ static gboolean stream_open_timeout(gpointer user_data)
 {
 	struct avdtp_stream *stream = user_data;
 
-	debug("Timed out waiting for peer to open the transport channel");
+	DBG("Timed out waiting for peer to open the transport channel");
 
 	stream->timer = 0;
 
@@ -908,7 +908,7 @@ static void handle_unanswered_req(struct avdtp *session,
 
 	if (session->req->signal_id == AVDTP_ABORT) {
 		/* Avoid freeing the Abort request here */
-		debug("handle_unanswered_req: Abort req, returning");
+		DBG("handle_unanswered_req: Abort req, returning");
 		session->req->stream = NULL;
 		return;
 	}
@@ -977,11 +977,11 @@ static void avdtp_sep_set_state(struct avdtp *session,
 
 	if (sep->state == state) {
 		avdtp_error_init(&err, AVDTP_ERROR_ERRNO, EIO);
-		debug("stream state change failed: %s", avdtp_strerror(&err));
+		DBG("stream state change failed: %s", avdtp_strerror(&err));
 		err_ptr = &err;
 	} else {
 		err_ptr = NULL;
-		debug("stream state changed: %s -> %s",
+		DBG("stream state changed: %s -> %s",
 				avdtp_statestr(sep->state),
 				avdtp_statestr(state));
 	}
@@ -1069,7 +1069,7 @@ static void connection_lost(struct avdtp *session, int err)
 	struct audio_device *dev;
 
 	ba2str(&session->dst, address);
-	debug("Disconnected from %s", address);
+	DBG("Disconnected from %s", address);
 
 	dev = manager_get_device(&session->server->src, &session->dst, FALSE);
 
@@ -1119,7 +1119,7 @@ void avdtp_unref(struct avdtp *session)
 
 	session->ref--;
 
-	debug("avdtp_unref(%p): ref=%d", session, session->ref);
+	DBG("avdtp_unref(%p): ref=%d", session, session->ref);
 
 	if (session->ref == 1) {
 		if (session->state == AVDTP_SESSION_STATE_CONNECTING &&
@@ -1146,7 +1146,7 @@ void avdtp_unref(struct avdtp *session)
 
 	server = session->server;
 
-	debug("avdtp_unref(%p): freeing session and removing from list",
+	DBG("avdtp_unref(%p): freeing session and removing from list",
 			session);
 
 	if (session->dc_timer)
@@ -1168,7 +1168,7 @@ void avdtp_unref(struct avdtp *session)
 struct avdtp *avdtp_ref(struct avdtp *session)
 {
 	session->ref++;
-	debug("avdtp_ref(%p): ref=%d", session, session->ref);
+	DBG("avdtp_ref(%p): ref=%d", session, session->ref);
 	if (session->dc_timer)
 		remove_disconnect_timer(session);
 	return session;
@@ -1803,47 +1803,47 @@ static gboolean avdtp_parse_cmd(struct avdtp *session, uint8_t transaction,
 {
 	switch (signal_id) {
 	case AVDTP_DISCOVER:
-		debug("Received DISCOVER_CMD");
+		DBG("Received DISCOVER_CMD");
 		return avdtp_discover_cmd(session, transaction, buf, size);
 	case AVDTP_GET_CAPABILITIES:
-		debug("Received  GET_CAPABILITIES_CMD");
+		DBG("Received  GET_CAPABILITIES_CMD");
 		return avdtp_getcap_cmd(session, transaction, buf, size,
 									FALSE);
 	case AVDTP_GET_ALL_CAPABILITIES:
-		debug("Received  GET_ALL_CAPABILITIES_CMD");
+		DBG("Received  GET_ALL_CAPABILITIES_CMD");
 		return avdtp_getcap_cmd(session, transaction, buf, size, TRUE);
 	case AVDTP_SET_CONFIGURATION:
-		debug("Received SET_CONFIGURATION_CMD");
+		DBG("Received SET_CONFIGURATION_CMD");
 		return avdtp_setconf_cmd(session, transaction, buf, size);
 	case AVDTP_GET_CONFIGURATION:
-		debug("Received GET_CONFIGURATION_CMD");
+		DBG("Received GET_CONFIGURATION_CMD");
 		return avdtp_getconf_cmd(session, transaction, buf, size);
 	case AVDTP_RECONFIGURE:
-		debug("Received RECONFIGURE_CMD");
+		DBG("Received RECONFIGURE_CMD");
 		return avdtp_reconf_cmd(session, transaction, buf, size);
 	case AVDTP_OPEN:
-		debug("Received OPEN_CMD");
+		DBG("Received OPEN_CMD");
 		return avdtp_open_cmd(session, transaction, buf, size);
 	case AVDTP_START:
-		debug("Received START_CMD");
+		DBG("Received START_CMD");
 		return avdtp_start_cmd(session, transaction, buf, size);
 	case AVDTP_CLOSE:
-		debug("Received CLOSE_CMD");
+		DBG("Received CLOSE_CMD");
 		return avdtp_close_cmd(session, transaction, buf, size);
 	case AVDTP_SUSPEND:
-		debug("Received SUSPEND_CMD");
+		DBG("Received SUSPEND_CMD");
 		return avdtp_suspend_cmd(session, transaction, buf, size);
 	case AVDTP_ABORT:
-		debug("Received ABORT_CMD");
+		DBG("Received ABORT_CMD");
 		return avdtp_abort_cmd(session, transaction, buf, size);
 	case AVDTP_SECURITY_CONTROL:
-		debug("Received SECURITY_CONTROL_CMD");
+		DBG("Received SECURITY_CONTROL_CMD");
 		return avdtp_secctl_cmd(session, transaction, buf, size);
 	case AVDTP_DELAY_REPORT:
-		debug("Received DELAY_REPORT_CMD");
+		DBG("Received DELAY_REPORT_CMD");
 		return avdtp_delayreport_cmd(session, transaction, buf, size);
 	default:
-		debug("Received unknown request id %u", signal_id);
+		DBG("Received unknown request id %u", signal_id);
 		return avdtp_unknown_cmd(session, transaction, signal_id);
 	}
 }
@@ -1963,7 +1963,7 @@ static enum avdtp_parse_result avdtp_parse_data(struct avdtp *session,
 
 	if (session->in.no_of_packets > 1) {
 		session->in.no_of_packets--;
-		debug("Received AVDTP fragment. %d to go",
+		DBG("Received AVDTP fragment. %d to go",
 						session->in.no_of_packets);
 		return PARSE_FRAGMENT;
 	}
@@ -1980,7 +1980,7 @@ static gboolean session_cb(GIOChannel *chan, GIOCondition cond,
 	struct avdtp_common_header *header;
 	gsize size;
 
-	debug("session_cb");
+	DBG("session_cb");
 
 	if (cond & G_IO_NVAL)
 		return FALSE;
@@ -2218,12 +2218,12 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	}
 
 	ba2str(&session->dst, address);
-	debug("AVDTP: connected %s channel to %s",
+	DBG("AVDTP: connected %s channel to %s",
 			session->pending_open ? "transport" : "signaling",
 			address);
 
 	if (session->state == AVDTP_SESSION_STATE_CONNECTING) {
-		debug("AVDTP imtu=%u, omtu=%u", session->imtu, session->omtu);
+		DBG("AVDTP imtu=%u, omtu=%u", session->imtu, session->omtu);
 
 		session->buf = g_malloc0(session->imtu);
 		avdtp_set_state(session, AVDTP_SESSION_STATE_CONNECTED);
@@ -2318,7 +2318,7 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
 		goto drop;
 	}
 
-	debug("AVDTP: incoming connect from %s", address);
+	DBG("AVDTP: incoming connect from %s", address);
 
 	session = avdtp_get_internal(&src, &dst);
 	if (!session)
@@ -2331,7 +2331,7 @@ static void avdtp_confirm_cb(GIOChannel *chan, gpointer data)
 	 * Abort the device's channel in favor of our own.
 	 */
 	if (session->state == AVDTP_SESSION_STATE_CONNECTING) {
-		debug("avdtp_confirm_cb: connect already in progress"
+		DBG("avdtp_confirm_cb: connect already in progress"
 						" (XCASE connect:connect)");
 		goto drop;
 	}
@@ -2609,7 +2609,7 @@ static gboolean avdtp_discover_resp(struct avdtp *session,
 		struct seid_req req;
 		int ret;
 
-		debug("seid %d type %d media %d in use %d",
+		DBG("seid %d type %d media %d in use %d",
 				resp->seps[i].seid, resp->seps[i].type,
 				resp->seps[i].media_type, resp->seps[i].inuse);
 
@@ -2665,7 +2665,7 @@ static gboolean avdtp_get_capabilities_resp(struct avdtp *session,
 
 	sep = find_remote_sep(session->seps, seid);
 
-	debug("seid %d type %d media %d", sep->seid,
+	DBG("seid %d type %d media %d", sep->seid,
 					sep->type, sep->media_type);
 
 	if (sep->caps) {
@@ -2809,12 +2809,12 @@ static gboolean avdtp_parse_resp(struct avdtp *session,
 
 	switch (signal_id) {
 	case AVDTP_DISCOVER:
-		debug("DISCOVER request succeeded");
+		DBG("DISCOVER request succeeded");
 		return avdtp_discover_resp(session, buf, size);
 	case AVDTP_GET_ALL_CAPABILITIES:
 		get_all = "ALL_";
 	case AVDTP_GET_CAPABILITIES:
-		debug("GET_%sCAPABILITIES request succeeded", get_all);
+		DBG("GET_%sCAPABILITIES request succeeded", get_all);
 		if (!avdtp_get_capabilities_resp(session, buf, size))
 			return FALSE;
 		if (!(next && (next->signal_id == AVDTP_GET_CAPABILITIES ||
@@ -2826,35 +2826,35 @@ static gboolean avdtp_parse_resp(struct avdtp *session,
 	/* The remaining commands require an existing stream so bail out
 	 * here if the stream got unexpectedly disconnected */
 	if (!stream) {
-		debug("AVDTP: stream was closed while waiting for reply");
+		DBG("AVDTP: stream was closed while waiting for reply");
 		return TRUE;
 	}
 
 	switch (signal_id) {
 	case AVDTP_SET_CONFIGURATION:
-		debug("SET_CONFIGURATION request succeeded");
+		DBG("SET_CONFIGURATION request succeeded");
 		return avdtp_set_configuration_resp(session, stream,
 								buf, size);
 	case AVDTP_RECONFIGURE:
-		debug("RECONFIGURE request succeeded");
+		DBG("RECONFIGURE request succeeded");
 		return avdtp_reconfigure_resp(session, stream, buf, size);
 	case AVDTP_OPEN:
-		debug("OPEN request succeeded");
+		DBG("OPEN request succeeded");
 		return avdtp_open_resp(session, stream, buf, size);
 	case AVDTP_SUSPEND:
-		debug("SUSPEND request succeeded");
+		DBG("SUSPEND request succeeded");
 		return avdtp_suspend_resp(session, stream, buf, size);
 	case AVDTP_START:
-		debug("START request succeeded");
+		DBG("START request succeeded");
 		return avdtp_start_resp(session, stream, buf, size);
 	case AVDTP_CLOSE:
-		debug("CLOSE request succeeded");
+		DBG("CLOSE request succeeded");
 		return avdtp_close_resp(session, stream, buf, size);
 	case AVDTP_ABORT:
-		debug("ABORT request succeeded");
+		DBG("ABORT request succeeded");
 		return avdtp_abort_resp(session, stream, buf, size);
 	case AVDTP_DELAY_REPORT:
-		debug("DELAY_REPORT request succeeded");
+		DBG("DELAY_REPORT request succeeded");
 		return avdtp_delay_report_resp(session, stream, buf, size);
 	}
 
@@ -3347,7 +3347,7 @@ int avdtp_set_configuration(struct avdtp *session,
 	if (!(lsep && rsep))
 		return -EINVAL;
 
-	debug("avdtp_set_configuration(%p): int_seid=%u, acp_seid=%u",
+	DBG("avdtp_set_configuration(%p): int_seid=%u, acp_seid=%u",
 			session, lsep->info.seid, rsep->seid);
 
 	new_stream = g_new0(struct avdtp_stream, 1);
@@ -3606,7 +3606,7 @@ struct avdtp_local_sep *avdtp_register_sep(const bdaddr_t *src, uint8_t type,
 	sep->server = server;
 	sep->delay_reporting = TRUE;
 
-	debug("SEP %p registered: type:%d codec:%d seid:%d", sep,
+	DBG("SEP %p registered: type:%d codec:%d seid:%d", sep,
 			sep->info.type, sep->codec, sep->info.seid);
 	server->seps = g_slist_append(server->seps, sep);
 
@@ -3722,7 +3722,7 @@ int avdtp_init(const bdaddr_t *src, GKeyFile *config, uint16_t *version)
 	tmp = g_key_file_get_boolean(config, "General",
 			"Master", &err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else
 		master = tmp;
diff --git a/audio/control.c b/audio/control.c
index 1763d60..da2bb5f 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -374,17 +374,17 @@ static void handle_panel_passthrough(struct control *control,
 		if ((operands[0] & 0x7F) != key_map[i].avrcp)
 			continue;
 
-		debug("AVRCP: %s %s", key_map[i].name, status);
+		DBG("AVRCP: %s %s", key_map[i].name, status);
 
 		key_quirks = control->key_quirks[key_map[i].avrcp];
 
 		if (key_quirks & QUIRK_NO_RELEASE) {
 			if (!pressed) {
-				debug("AVRCP: Ignoring release");
+				DBG("AVRCP: Ignoring release");
 				break;
 			}
 
-			debug("AVRCP: treating key press as press + release");
+			DBG("AVRCP: treating key press as press + release");
 			send_key(control->uinput, key_map[i].uinput, 1);
 			send_key(control->uinput, key_map[i].uinput, 0);
 			break;
@@ -395,7 +395,7 @@ static void handle_panel_passthrough(struct control *control,
 	}
 
 	if (key_map[i].name == NULL)
-		debug("AVRCP: unknown button 0x%02X %s",
+		DBG("AVRCP: unknown button 0x%02X %s",
 						operands[0] & 0x7F, status);
 }
 
@@ -425,7 +425,7 @@ static void avctp_disconnected(struct audio_device *dev)
 		char address[18];
 
 		ba2str(&dev->dst, address);
-		debug("AVRCP: closing uinput for %s", address);
+		DBG("AVRCP: closing uinput for %s", address);
 
 		ioctl(control->uinput, UI_DEV_DESTROY);
 		close(control->uinput);
@@ -442,7 +442,7 @@ static void avctp_set_state(struct control *control, avctp_state_t new_state)
 
 	switch (new_state) {
 	case AVCTP_STATE_DISCONNECTED:
-		debug("AVCTP Disconnected");
+		DBG("AVCTP Disconnected");
 
 		avctp_disconnected(control->dev);
 
@@ -462,10 +462,10 @@ static void avctp_set_state(struct control *control, avctp_state_t new_state)
 
 		break;
 	case AVCTP_STATE_CONNECTING:
-		debug("AVCTP Connecting");
+		DBG("AVCTP Connecting");
 		break;
 	case AVCTP_STATE_CONNECTED:
-		debug("AVCTP Connected");
+		DBG("AVCTP Connected");
 		value = TRUE;
 		g_dbus_emit_signal(control->dev->conn, control->dev->path,
 				AUDIO_CONTROL_INTERFACE, "Connected",
@@ -505,7 +505,7 @@ static gboolean control_cb(GIOChannel *chan, GIOCondition cond,
 	if (ret <= 0)
 		goto failed;
 
-	debug("Got %d bytes of data for AVCTP session %p", ret, control);
+	DBG("Got %d bytes of data for AVCTP session %p", ret, control);
 
 	if ((unsigned int) ret < sizeof(struct avctp_header)) {
 		error("Too small AVCTP packet");
@@ -516,7 +516,7 @@ static gboolean control_cb(GIOChannel *chan, GIOCondition cond,
 
 	avctp = (struct avctp_header *) buf;
 
-	debug("AVCTP transaction %u, packet type %u, C/R %u, IPID %u, "
+	DBG("AVCTP transaction %u, packet type %u, C/R %u, IPID %u, "
 			"PID 0x%04X",
 			avctp->transaction, avctp->packet_type,
 			avctp->cr, avctp->ipid, ntohs(avctp->pid));
@@ -534,7 +534,7 @@ static gboolean control_cb(GIOChannel *chan, GIOCondition cond,
 	operands = buf + sizeof(struct avctp_header) + sizeof(struct avrcp_header);
 	operand_count = ret;
 
-	debug("AVRCP %s 0x%01X, subunit_type 0x%02X, subunit_id 0x%01X, "
+	DBG("AVRCP %s 0x%01X, subunit_type 0x%02X, subunit_id 0x%01X, "
 			"opcode 0x%02X, %d operands",
 			avctp->cr ? "response" : "command",
 			avrcp->code, avrcp->subunit_type, avrcp->subunit_id,
@@ -568,7 +568,7 @@ static gboolean control_cb(GIOChannel *chan, GIOCondition cond,
 			operands[0] = 0x07;
 		if (operand_count >= 2)
 			operands[1] = SUBUNIT_PANEL << 3;
-		debug("reply to %s", avrcp->opcode == OP_UNITINFO ?
+		DBG("reply to %s", avrcp->opcode == OP_UNITINFO ?
 				"OP_UNITINFO" : "OP_SUBUNITINFO");
 	} else {
 		avctp->cr = AVCTP_RESPONSE;
@@ -579,7 +579,7 @@ static gboolean control_cb(GIOChannel *chan, GIOCondition cond,
 	return TRUE;
 
 failed:
-	debug("AVCTP session %p got disconnected", control);
+	DBG("AVCTP session %p got disconnected", control);
 	avctp_set_state(control, AVCTP_STATE_DISCONNECTED);
 	return FALSE;
 }
@@ -660,7 +660,7 @@ static void init_uinput(struct control *control)
 	if (control->uinput < 0)
 		error("AVRCP: failed to init uinput for %s", address);
 	else
-		debug("AVRCP: uinput initialized for %s", address);
+		DBG("AVRCP: uinput initialized for %s", address);
 }
 
 static void avctp_connect_cb(GIOChannel *chan, GError *err, gpointer data)
@@ -687,7 +687,7 @@ static void avctp_connect_cb(GIOChannel *chan, GError *err, gpointer data)
 		return;
 	}
 
-	debug("AVCTP: connected to %s", address);
+	DBG("AVCTP: connected to %s", address);
 
 	if (!control->io)
 		control->io = g_io_channel_ref(chan);
@@ -851,7 +851,7 @@ int avrcp_register(DBusConnection *conn, const bdaddr_t *src, GKeyFile *config)
 		tmp = g_key_file_get_boolean(config, "General",
 							"Master", &err);
 		if (err) {
-			debug("audio.conf: %s", err->message);
+			DBG("audio.conf: %s", err->message);
 			g_error_free(err);
 		} else
 			master = tmp;
@@ -1112,7 +1112,7 @@ static void path_unregister(void *data)
 	struct audio_device *dev = data;
 	struct control *control = dev->control;
 
-	debug("Unregistered interface %s on path %s",
+	DBG("Unregistered interface %s on path %s",
 		AUDIO_CONTROL_INTERFACE, dev->path);
 
 	if (control->state != AVCTP_STATE_DISCONNECTED)
@@ -1146,7 +1146,7 @@ struct control *control_init(struct audio_device *dev, uint16_t uuid16)
 					dev, path_unregister))
 		return NULL;
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 		AUDIO_CONTROL_INTERFACE, dev->path);
 
 	control = g_new0(struct control, 1);
diff --git a/audio/device.c b/audio/device.c
index 76aaddd..fceb7a1 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -157,7 +157,7 @@ static void device_set_state(struct audio_device *dev, audio_state_t new_state)
 		priv->authorized = FALSE;
 
 	if (dev->priv->state == new_state) {
-		debug("state change attempted from %s to %s",
+		DBG("state change attempted from %s to %s",
 							state_str, state_str);
 		return;
 	}
@@ -605,7 +605,7 @@ struct audio_device *audio_device_register(DBusConnection *conn,
 		return NULL;
 	}
 
-	debug("Registered interface %s on path %s", AUDIO_INTERFACE,
+	DBG("Registered interface %s on path %s", AUDIO_INTERFACE,
 								dev->path);
 
 	if (sink_callback_id == 0)
diff --git a/audio/gateway.c b/audio/gateway.c
index 22e5da2..62b3f60 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -158,7 +158,7 @@ static gboolean sco_io_cb(GIOChannel *chan, GIOCondition cond,
 		return FALSE;
 
 	if (cond & (G_IO_ERR | G_IO_HUP)) {
-		debug("sco connection is released");
+		DBG("sco connection is released");
 		g_io_channel_shutdown(gw->sco, TRUE, NULL);
 		g_io_channel_unref(gw->sco);
 		gw->sco = NULL;
@@ -174,7 +174,7 @@ static void sco_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	struct audio_device *dev = (struct audio_device *) user_data;
 	struct gateway *gw = dev->gateway;
 
-	debug("at the begin of sco_connect_cb() in gateway.c");
+	DBG("at the begin of sco_connect_cb() in gateway.c");
 
 	gw->sco = g_io_channel_ref(chan);
 
@@ -198,18 +198,18 @@ static void newconnection_reply(DBusPendingCall *call, void *data)
 	DBusError derr;
 
 	if (!dev->gateway->rfcomm) {
-		debug("RFCOMM disconnected from server before agent reply");
+		DBG("RFCOMM disconnected from server before agent reply");
 		goto done;
 	}
 
 	dbus_error_init(&derr);
 	if (!dbus_set_error_from_message(&derr, reply)) {
-		debug("Agent reply: file descriptor passed successfuly");
+		DBG("Agent reply: file descriptor passed successfuly");
 		change_state(dev, GATEWAY_STATE_CONNECTED);
 		goto done;
 	}
 
-	debug("Agent reply: %s", derr.message);
+	DBG("Agent reply: %s", derr.message);
 
 	dbus_error_free(&derr);
 	gateway_close(dev);
@@ -432,7 +432,7 @@ static DBusMessage *ag_disconnect(DBusConnection *conn, DBusMessage *msg,
 
 	gateway_close(device);
 	ba2str(&device->dst, gw_addr);
-	debug("Disconnected from %s, %s", gw_addr, device->path);
+	DBG("Disconnected from %s, %s", gw_addr, device->path);
 
 	return reply;
 }
@@ -442,7 +442,7 @@ static void agent_exited(DBusConnection *conn, void *data)
 	struct gateway *gateway = data;
 	struct hf_agent *agent = gateway->agent;
 
-	debug("Agent %s exited", agent->name);
+	DBG("Agent %s exited", agent->name);
 
 	agent_free(agent);
 	gateway->agent = NULL;
diff --git a/audio/headset.c b/audio/headset.c
index 1d9f8f2..7bcaa96 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -212,7 +212,7 @@ static void print_ag_features(uint32_t features)
 	char *str;
 
 	if (features == 0) {
-		debug("HFP AG features: (none)");
+		DBG("HFP AG features: (none)");
 		return;
 	}
 
@@ -239,7 +239,7 @@ static void print_ag_features(uint32_t features)
 
 	str = g_string_free(gstr, FALSE);
 
-	debug("%s", str);
+	DBG("%s", str);
 
 	g_free(str);
 }
@@ -250,7 +250,7 @@ static void print_hf_features(uint32_t features)
 	char *str;
 
 	if (features == 0) {
-		debug("HFP HF features: (none)");
+		DBG("HFP HF features: (none)");
 		return;
 	}
 
@@ -273,7 +273,7 @@ static void print_hf_features(uint32_t features)
 
 	str = g_string_free(gstr, FALSE);
 
-	debug("%s", str);
+	DBG("%s", str);
 
 	g_free(str);
 }
@@ -591,11 +591,11 @@ static void sco_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 		return;
 	}
 
-	debug("SCO socket opened for headset %s", dev->path);
+	DBG("SCO socket opened for headset %s", dev->path);
 
 	sk = g_io_channel_unix_get_fd(chan);
 
-	debug("SCO fd=%d", sk);
+	DBG("SCO fd=%d", sk);
 
 	if (p) {
 		p->io = NULL;
@@ -670,7 +670,7 @@ static void hfp_slc_complete(struct audio_device *dev)
 	struct headset *hs = dev->headset;
 	struct pending_connect *p = hs->pending;
 
-	debug("HFP Service Level Connection established");
+	DBG("HFP Service Level Connection established");
 
 	headset_set_state(dev, HEADSET_STATE_CONNECTED);
 
@@ -754,7 +754,7 @@ static int event_reporting(struct audio_device *dev, const char *buf)
 	g_strfreev(tokens);
 	tokens = NULL;
 
-	debug("Event reporting (CMER): mode=%d, ind=%d",
+	DBG("Event reporting (CMER): mode=%d, ind=%d",
 			ag.er_mode, ag.er_ind);
 
 	switch (ag.er_ind) {
@@ -938,7 +938,7 @@ static int dial_number(struct audio_device *device, const char *buf)
 	buf_len = strlen(buf);
 
 	if (buf[buf_len - 1] != ';') {
-		debug("Rejecting non-voice call dial request");
+		DBG("Rejecting non-voice call dial request");
 		return -EINVAL;
 	}
 
@@ -1054,10 +1054,10 @@ static int extended_errors(struct audio_device *device, const char *buf)
 
 	if (buf[8] == '1') {
 		slc->cme_enabled = TRUE;
-		debug("CME errors enabled for headset %p", hs);
+		DBG("CME errors enabled for headset %p", hs);
 	} else {
 		slc->cme_enabled = FALSE;
-		debug("CME errors disabled for headset %p", hs);
+		DBG("CME errors disabled for headset %p", hs);
 	}
 
 	return headset_send(hs, "\r\nOK\r\n");
@@ -1073,10 +1073,10 @@ static int call_waiting_notify(struct audio_device *device, const char *buf)
 
 	if (buf[8] == '1') {
 		slc->cwa_enabled = TRUE;
-		debug("Call waiting notification enabled for headset %p", hs);
+		DBG("Call waiting notification enabled for headset %p", hs);
 	} else {
 		slc->cwa_enabled = FALSE;
-		debug("Call waiting notification disabled for headset %p", hs);
+		DBG("Call waiting notification disabled for headset %p", hs);
 	}
 
 	return headset_send(hs, "\r\nOK\r\n");
@@ -1203,7 +1203,7 @@ static int handle_event(struct audio_device *device, const char *buf)
 {
 	struct event *ev;
 
-	debug("Received %s", buf);
+	DBG("Received %s", buf);
 
 	for (ev = event_callbacks; ev->cmd; ev++) {
 		if (!strncmp(buf, ev->cmd, strlen(ev->cmd)))
@@ -1247,7 +1247,7 @@ static gboolean rfcomm_io_cb(GIOChannel *chan, GIOCondition cond,
 	slc = hs->slc;
 
 	if (cond & (G_IO_ERR | G_IO_HUP)) {
-		debug("ERR or HUP on RFCOMM socket");
+		DBG("ERR or HUP on RFCOMM socket");
 		goto failed;
 	}
 
@@ -1359,7 +1359,7 @@ void headset_connect_cb(GIOChannel *chan, GError *err, gpointer user_data)
 	g_io_add_watch(chan, G_IO_IN | G_IO_ERR | G_IO_HUP| G_IO_NVAL,
 			(GIOFunc) rfcomm_io_cb, dev);
 
-	debug("%s: Connected to %s", dev->path, hs_address);
+	DBG("%s: Connected to %s", dev->path, hs_address);
 
 	hs->slc = g_new0(struct headset_slc, 1);
 	hs->slc->nrec = TRUE;
@@ -1421,10 +1421,10 @@ static int headset_set_channel(struct headset *headset,
 
 	if (svc == HANDSFREE_SVCLASS_ID) {
 		headset->hfp_handle = record->handle;
-		debug("Discovered Handsfree service on channel %d", ch);
+		DBG("Discovered Handsfree service on channel %d", ch);
 	} else {
 		headset->hsp_handle = record->handle;
-		debug("Discovered Headset service on channel %d", ch);
+		DBG("Discovered Headset service on channel %d", ch);
 	}
 
 	return 0;
@@ -1570,7 +1570,7 @@ static int rfcomm_connect(struct audio_device *dev, headset_stream_cb_t cb,
 
 	ba2str(&dev->dst, address);
 
-	debug("%s: Connecting to %s channel %d", dev->path, address,
+	DBG("%s: Connecting to %s channel %d", dev->path, address,
 		hs->rfcomm_ch);
 
 	hs->tmp_rfcomm = bt_io_connect(BT_IO_RFCOMM, headset_connect_cb, dev,
@@ -1740,7 +1740,7 @@ static DBusMessage *hs_ring(DBusConnection *conn, DBusMessage *msg,
 		return NULL;
 
 	if (ag.ring_timer) {
-		debug("IndicateCall received when already indicating");
+		DBG("IndicateCall received when already indicating");
 		goto done;
 	}
 
@@ -1780,7 +1780,7 @@ static DBusMessage *hs_cancel_call(DBusConnection *conn,
 		g_source_remove(ag.ring_timer);
 		ag.ring_timer = 0;
 	} else
-		debug("Got CancelCall method call but no call is active");
+		DBG("Got CancelCall method call but no call is active");
 
 	return reply;
 }
@@ -2133,7 +2133,7 @@ void headset_update(struct audio_device *dev, uint16_t svc,
 		break;
 
 	default:
-		debug("Invalid record passed to headset_update");
+		DBG("Invalid record passed to headset_update");
 		return;
 	}
 }
@@ -2182,11 +2182,11 @@ static void path_unregister(void *data)
 	struct headset *hs = dev->headset;
 
 	if (hs->state > HEADSET_STATE_DISCONNECTED) {
-		debug("Headset unregistered while device was connected!");
+		DBG("Headset unregistered while device was connected!");
 		headset_shutdown(dev);
 	}
 
-	debug("Unregistered interface %s on path %s",
+	DBG("Unregistered interface %s on path %s",
 		AUDIO_HEADSET_INTERFACE, dev->path);
 
 	headset_free(dev);
@@ -2222,7 +2222,7 @@ struct headset *headset_init(struct audio_device *dev, uint16_t svc,
 		break;
 
 	default:
-		debug("Invalid record passed to headset_init");
+		DBG("Invalid record passed to headset_init");
 		g_free(hs);
 		return NULL;
 	}
@@ -2236,7 +2236,7 @@ register_iface:
 		return NULL;
 	}
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 		AUDIO_HEADSET_INTERFACE, dev->path);
 
 	return hs;
@@ -2254,7 +2254,7 @@ uint32_t headset_config_init(GKeyFile *config)
 	str = g_key_file_get_string(config, "General", "SCORouting",
 					&err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else {
 		if (strcmp(str, "PCM") == 0)
@@ -2582,7 +2582,7 @@ void headset_set_state(struct audio_device *dev, headset_state_t state)
 
 	hs->state = state;
 
-	debug("State changed %s: %s -> %s", dev->path, str_state[old_state],
+	DBG("State changed %s: %s -> %s", dev->path, str_state[old_state],
 		str_state[state]);
 
 	for (l = headset_callbacks; l != NULL; l = l->next) {
@@ -2713,7 +2713,7 @@ int telephony_event_ind(int index)
 		return -ENODEV;
 
 	if (!ag.er_ind) {
-		debug("telephony_report_event called but events are disabled");
+		DBG("telephony_report_event called but events are disabled");
 		return -EINVAL;
 	}
 
@@ -2756,7 +2756,7 @@ int telephony_incoming_call_ind(const char *number, int type)
 	slc = hs->slc;
 
 	if (ag.ring_timer) {
-		debug("telephony_incoming_call_ind: already calling");
+		DBG("telephony_incoming_call_ind: already calling");
 		return -EBUSY;
 	}
 
@@ -2815,7 +2815,7 @@ int telephony_ready_ind(uint32_t features,
 	ag.rh = rh;
 	ag.chld = g_strdup(chld);
 
-	debug("Telephony plugin initialized");
+	DBG("Telephony plugin initialized");
 
 	print_ag_features(ag.features);
 
diff --git a/audio/main.c b/audio/main.c
index 74e5914..34b45a8 100644
--- a/audio/main.c
+++ b/audio/main.c
@@ -102,7 +102,7 @@ static void sco_server_cb(GIOChannel *chan, GError *err, gpointer data)
 
 	if (device->headset) {
 		if (headset_get_state(device) < HEADSET_STATE_CONNECTED) {
-			debug("Refusing SCO from non-connected headset");
+			DBG("Refusing SCO from non-connected headset");
 			goto drop;
 		}
 
@@ -118,7 +118,7 @@ static void sco_server_cb(GIOChannel *chan, GError *err, gpointer data)
 		headset_set_state(device, HEADSET_STATE_PLAYING);
 	} else if (device->gateway) {
 		if (!gateway_is_connected(device)) {
-			debug("Refusing SCO from non-connected AG");
+			DBG("Refusing SCO from non-connected AG");
 			goto drop;
 		}
 
@@ -130,7 +130,7 @@ static void sco_server_cb(GIOChannel *chan, GError *err, gpointer data)
 	sk = g_io_channel_unix_get_fd(chan);
 	fcntl(sk, F_SETFL, 0);
 
-	debug("Accepted SCO connection from %s", addr);
+	DBG("Accepted SCO connection from %s", addr);
 
 	return;
 
diff --git a/audio/manager.c b/audio/manager.c
index 06c7d78..ec795e6 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -171,14 +171,14 @@ static void handle_uuid(const char *uuidstr, struct audio_device *device)
 	uuid16 = uuid.value.uuid16;
 
 	if (!server_is_enabled(&device->src, uuid16)) {
-		debug("audio handle_uuid: server not enabled for %s (0x%04x)",
+		DBG("audio handle_uuid: server not enabled for %s (0x%04x)",
 				uuidstr, uuid16);
 		return;
 	}
 
 	switch (uuid16) {
 	case HEADSET_SVCLASS_ID:
-		debug("Found Headset record");
+		DBG("Found Headset record");
 		if (device->headset)
 			headset_update(device, uuid16, uuidstr);
 		else
@@ -186,10 +186,10 @@ static void handle_uuid(const char *uuidstr, struct audio_device *device)
 							uuidstr);
 		break;
 	case HEADSET_AGW_SVCLASS_ID:
-		debug("Found Headset AG record");
+		DBG("Found Headset AG record");
 		break;
 	case HANDSFREE_SVCLASS_ID:
-		debug("Found Handsfree record");
+		DBG("Found Handsfree record");
 		if (device->headset)
 			headset_update(device, uuid16, uuidstr);
 		else
@@ -197,23 +197,23 @@ static void handle_uuid(const char *uuidstr, struct audio_device *device)
 							uuidstr);
 		break;
 	case HANDSFREE_AGW_SVCLASS_ID:
-		debug("Found Handsfree AG record");
+		DBG("Found Handsfree AG record");
 		if (enabled.gateway && (device->gateway == NULL))
 			device->gateway = gateway_init(device);
 		break;
 	case AUDIO_SINK_SVCLASS_ID:
-		debug("Found Audio Sink");
+		DBG("Found Audio Sink");
 		if (device->sink == NULL)
 			device->sink = sink_init(device);
 		break;
 	case AUDIO_SOURCE_SVCLASS_ID:
-		debug("Found Audio Source");
+		DBG("Found Audio Source");
 		if (device->source == NULL)
 			device->source = source_init(device);
 		break;
 	case AV_REMOTE_SVCLASS_ID:
 	case AV_REMOTE_TARGET_SVCLASS_ID:
-		debug("Found AV %s", uuid16 == AV_REMOTE_SVCLASS_ID ?
+		DBG("Found AV %s", uuid16 == AV_REMOTE_SVCLASS_ID ?
 							"Remote" : "Target");
 		if (device->control)
 			control_update(device, uuid16);
@@ -223,7 +223,7 @@ static void handle_uuid(const char *uuidstr, struct audio_device *device)
 			avrcp_connect(device);
 		break;
 	default:
-		debug("Unrecognized UUID: 0x%04X", uuid16);
+		DBG("Unrecognized UUID: 0x%04X", uuid16);
 		break;
 	}
 }
@@ -437,7 +437,7 @@ static gboolean hs_preauth_cb(GIOChannel *chan, GIOCondition cond,
 {
 	struct audio_device *device = user_data;
 
-	debug("Headset disconnected during authorization");
+	DBG("Headset disconnected during authorization");
 
 	audio_device_cancel_authorization(device, headset_auth_cb, device);
 
@@ -484,7 +484,7 @@ static void ag_confirm(GIOChannel *chan, gpointer data)
 		goto drop;
 
 	if (!manager_allow_headset_connection(device)) {
-		debug("Refusing headset: too many existing connections");
+		DBG("Refusing headset: too many existing connections");
 		goto drop;
 	}
 
@@ -495,7 +495,7 @@ static void ag_confirm(GIOChannel *chan, gpointer data)
 	}
 
 	if (headset_get_state(device) > HEADSET_STATE_DISCONNECTED) {
-		debug("Refusing new connection since one already exists");
+		DBG("Refusing new connection since one already exists");
 		goto drop;
 	}
 
@@ -511,7 +511,7 @@ static void ag_confirm(GIOChannel *chan, gpointer data)
 	perr = audio_device_request_authorization(device, server_uuid,
 						headset_auth_cb, device);
 	if (perr < 0) {
-		debug("Authorization denied: %s", strerror(-perr));
+		DBG("Authorization denied: %s", strerror(-perr));
 		headset_set_state(device, HEADSET_STATE_DISCONNECTED);
 		return;
 	}
@@ -538,7 +538,7 @@ static void gateway_auth_cb(DBusError *derr, void *user_data)
 		char ag_address[18];
 
 		ba2str(&device->dst, ag_address);
-		debug("Accepted AG connection from %s for %s",
+		DBG("Accepted AG connection from %s for %s",
 			ag_address, device->path);
 
 		gateway_start_service(device);
@@ -582,7 +582,7 @@ static void hf_io_cb(GIOChannel *chan, gpointer data)
 	}
 
 	if (gateway_is_connected(device)) {
-		debug("Refusing new connection since one already exists");
+		DBG("Refusing new connection since one already exists");
 		goto drop;
 	}
 
@@ -594,7 +594,7 @@ static void hf_io_cb(GIOChannel *chan, gpointer data)
 	perr = audio_device_request_authorization(device, server_uuid,
 						gateway_auth_cb, device);
 	if (perr < 0) {
-		debug("Authorization denied!");
+		DBG("Authorization denied!");
 		goto drop;
 	}
 
@@ -622,7 +622,7 @@ static int headset_server_init(struct audio_adapter *adapter)
 		tmp = g_key_file_get_boolean(config, "General", "Master",
 						&err);
 		if (err) {
-			debug("audio.conf: %s", err->message);
+			DBG("audio.conf: %s", err->message);
 			g_clear_error(&err);
 		} else
 			master = tmp;
@@ -720,7 +720,7 @@ static int gateway_server_init(struct audio_adapter *adapter)
 		tmp = g_key_file_get_boolean(config, "General", "Master",
 						&err);
 		if (err) {
-			debug("audio.conf: %s", err->message);
+			DBG("audio.conf: %s", err->message);
 			g_clear_error(&err);
 		} else
 			master = tmp;
@@ -771,7 +771,7 @@ static int audio_probe(struct btd_device *device, GSList *uuids)
 
 	audio_dev = manager_get_device(&src, &dst, TRUE);
 	if (!audio_dev) {
-		debug("audio_probe: unable to get a device object");
+		DBG("audio_probe: unable to get a device object");
 		return -1;
 	}
 
@@ -801,7 +801,7 @@ static struct audio_adapter *audio_adapter_ref(struct audio_adapter *adp)
 {
 	adp->ref++;
 
-	debug("audio_adapter_ref(%p): ref=%d", adp, adp->ref);
+	DBG("audio_adapter_ref(%p): ref=%d", adp, adp->ref);
 
 	return adp;
 }
@@ -810,7 +810,7 @@ static void audio_adapter_unref(struct audio_adapter *adp)
 {
 	adp->ref--;
 
-	debug("audio_adapter_unref(%p): ref=%d", adp, adp->ref);
+	DBG("audio_adapter_unref(%p): ref=%d", adp, adp->ref);
 
 	if (adp->ref > 0)
 		return;
@@ -1095,7 +1095,7 @@ int audio_manager_init(DBusConnection *conn, GKeyFile *conf,
 
 	b = g_key_file_get_boolean(config, "General", "AutoConnect", &err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else
 		auto_connect = b;
@@ -1111,7 +1111,7 @@ int audio_manager_init(DBusConnection *conn, GKeyFile *conf,
 	i = g_key_file_get_integer(config, "Headset", "MaxConnected",
 					&err);
 	if (err) {
-		debug("audio.conf: %s", err->message);
+		DBG("audio.conf: %s", err->message);
 		g_clear_error(&err);
 	} else
 		max_connected_headsets = i;
diff --git a/audio/sink.c b/audio/sink.c
index 4d46e52..0ca0519 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -176,7 +176,7 @@ static void disconnect_cb(struct btd_device *btd_dev, gboolean removal,
 	struct audio_device *device = user_data;
 	struct sink *sink = device->sink;
 
-	debug("Sink: disconnect %s", device->path);
+	DBG("Sink: disconnect %s", device->path);
 
 	avdtp_close(sink->session, sink->stream, TRUE);
 }
@@ -282,14 +282,14 @@ static gboolean stream_setup_retry(gpointer user_data)
 	sink->retry_id = 0;
 
 	if (sink->stream_state >= AVDTP_STATE_OPEN) {
-		debug("Stream successfully created, after XCASE connect:connect");
+		DBG("Stream successfully created, after XCASE connect:connect");
 		if (pending->msg) {
 			DBusMessage *reply;
 			reply = dbus_message_new_method_return(pending->msg);
 			g_dbus_send_message(pending->conn, reply);
 		}
 	} else {
-		debug("Stream setup failed, after XCASE connect:connect");
+		DBG("Stream setup failed, after XCASE connect:connect");
 		if (pending->msg)
 			error_failed(pending->conn, pending->msg, "Stream setup failed");
 	}
@@ -312,7 +312,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 	pending->id = 0;
 
 	if (stream) {
-		debug("Stream successfully created");
+		DBG("Stream successfully created");
 
 		if (pending->msg) {
 			DBusMessage *reply;
@@ -330,7 +330,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 	sink->session = NULL;
 	if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO
 			&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
-		debug("connect:connect XCASE detected");
+		DBG("connect:connect XCASE detected");
 		sink->retry_id = g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
 							stream_setup_retry,
 							sink);
@@ -339,7 +339,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 			error_failed(pending->conn, pending->msg, "Stream setup failed");
 		sink->connect = NULL;
 		pending_request_free(sink->dev, pending);
-		debug("Stream setup failed : %s", avdtp_strerror(err));
+		DBG("Stream setup failed : %s", avdtp_strerror(err));
 	}
 }
 
@@ -503,7 +503,7 @@ static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp
 		sink->session = NULL;
 		if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO
 				&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
-			debug("connect:connect XCASE detected");
+			DBG("connect:connect XCASE detected");
 			sink->retry_id =
 				g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
 							stream_setup_retry,
@@ -513,7 +513,7 @@ static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp
 		return;
 	}
 
-	debug("Discovery complete");
+	DBG("Discovery complete");
 
 	if (avdtp_get_seps(session, AVDTP_SEP_TYPE_SINK, AVDTP_MEDIA_TYPE_AUDIO,
 				A2DP_CODEC_SBC, &lsep, &rsep) < 0) {
@@ -603,7 +603,7 @@ static DBusMessage *sink_connect(DBusConnection *conn,
 	pending->conn = dbus_connection_ref(conn);
 	pending->msg = dbus_message_ref(msg);
 
-	debug("stream creation in progress");
+	DBG("stream creation in progress");
 
 	return NULL;
 }
@@ -759,7 +759,7 @@ static void path_unregister(void *data)
 {
 	struct audio_device *dev = data;
 
-	debug("Unregistered interface %s on path %s",
+	DBG("Unregistered interface %s on path %s",
 		AUDIO_SINK_INTERFACE, dev->path);
 
 	sink_free(dev);
@@ -781,7 +781,7 @@ struct sink *sink_init(struct audio_device *dev)
 					dev, path_unregister))
 		return NULL;
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 		AUDIO_SINK_INTERFACE, dev->path);
 
 	if (avdtp_callback_id == 0)
diff --git a/audio/source.c b/audio/source.c
index 0ea0f00..ea4610f 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -169,7 +169,7 @@ static void disconnect_cb(struct btd_device *btd_dev, gboolean removal,
 	struct audio_device *device = user_data;
 	struct source *source = device->source;
 
-	debug("Source: disconnect %s", device->path);
+	DBG("Source: disconnect %s", device->path);
 
 	avdtp_close(source->session, source->stream, TRUE);
 }
@@ -249,14 +249,14 @@ static gboolean stream_setup_retry(gpointer user_data)
 	source->retry_id = 0;
 
 	if (source->stream_state >= AVDTP_STATE_OPEN) {
-		debug("Stream successfully created, after XCASE connect:connect");
+		DBG("Stream successfully created, after XCASE connect:connect");
 		if (pending->msg) {
 			DBusMessage *reply;
 			reply = dbus_message_new_method_return(pending->msg);
 			g_dbus_send_message(pending->conn, reply);
 		}
 	} else {
-		debug("Stream setup failed, after XCASE connect:connect");
+		DBG("Stream setup failed, after XCASE connect:connect");
 		if (pending->msg)
 			error_failed(pending->conn, pending->msg, "Stream setup failed");
 	}
@@ -279,7 +279,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 	pending->id = 0;
 
 	if (stream) {
-		debug("Stream successfully created");
+		DBG("Stream successfully created");
 
 		if (pending->msg) {
 			DBusMessage *reply;
@@ -297,7 +297,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 	source->session = NULL;
 	if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO
 			&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
-		debug("connect:connect XCASE detected");
+		DBG("connect:connect XCASE detected");
 		source->retry_id = g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
 							stream_setup_retry,
 							source);
@@ -306,7 +306,7 @@ static void stream_setup_complete(struct avdtp *session, struct a2dp_sep *sep,
 			error_failed(pending->conn, pending->msg, "Stream setup failed");
 		source->connect = NULL;
 		pending_request_free(source->dev, pending);
-		debug("Stream setup failed : %s", avdtp_strerror(err));
+		DBG("Stream setup failed : %s", avdtp_strerror(err));
 	}
 }
 
@@ -464,7 +464,7 @@ static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp
 		source->session = NULL;
 		if (avdtp_error_type(err) == AVDTP_ERROR_ERRNO
 				&& avdtp_error_posix_errno(err) != EHOSTDOWN) {
-			debug("connect:connect XCASE detected");
+			DBG("connect:connect XCASE detected");
 			source->retry_id =
 				g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
 							stream_setup_retry,
@@ -474,7 +474,7 @@ static void discovery_complete(struct avdtp *session, GSList *seps, struct avdtp
 		return;
 	}
 
-	debug("Discovery complete");
+	DBG("Discovery complete");
 
 	if (avdtp_get_seps(session, AVDTP_SEP_TYPE_SOURCE, AVDTP_MEDIA_TYPE_AUDIO,
 				A2DP_CODEC_SBC, &lsep, &rsep) < 0) {
@@ -565,7 +565,7 @@ static DBusMessage *source_connect(DBusConnection *conn,
 	pending->conn = dbus_connection_ref(conn);
 	pending->msg = dbus_message_ref(msg);
 
-	debug("stream creation in progress");
+	DBG("stream creation in progress");
 
 	return NULL;
 }
@@ -685,7 +685,7 @@ static void path_unregister(void *data)
 {
 	struct audio_device *dev = data;
 
-	debug("Unregistered interface %s on path %s",
+	DBG("Unregistered interface %s on path %s",
 		AUDIO_SOURCE_INTERFACE, dev->path);
 
 	source_free(dev);
@@ -707,7 +707,7 @@ struct source *source_init(struct audio_device *dev)
 					dev, path_unregister))
 		return NULL;
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 		AUDIO_SOURCE_INTERFACE, dev->path);
 
 	if (avdtp_callback_id == 0)
diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c
index 6298068..f20aa79 100644
--- a/audio/telephony-dummy.c
+++ b/audio/telephony-dummy.c
@@ -77,12 +77,12 @@ static inline DBusMessage *invalid_args(DBusMessage *msg)
 
 void telephony_device_connected(void *telephony_device)
 {
-	debug("telephony-dummy: device %p connected", telephony_device);
+	DBG("telephony-dummy: device %p connected", telephony_device);
 }
 
 void telephony_device_disconnected(void *telephony_device)
 {
-	debug("telephony-dummy: device %p disconnected", telephony_device);
+	DBG("telephony-dummy: device %p disconnected", telephony_device);
 	events_enabled = FALSE;
 }
 
@@ -147,7 +147,7 @@ void telephony_dial_number_req(void *telephony_device, const char *number)
 	g_free(active_call_number);
 	active_call_number = g_strdup(number);
 
-	debug("telephony-dummy: dial request to %s", active_call_number);
+	DBG("telephony-dummy: dial request to %s", active_call_number);
 
 	telephony_dial_number_rsp(telephony_device, CME_ERROR_NONE);
 
@@ -163,13 +163,13 @@ void telephony_dial_number_req(void *telephony_device, const char *number)
 
 void telephony_transmit_dtmf_req(void *telephony_device, char tone)
 {
-	debug("telephony-dummy: transmit dtmf: %c", tone);
+	DBG("telephony-dummy: transmit dtmf: %c", tone);
 	telephony_transmit_dtmf_rsp(telephony_device, CME_ERROR_NONE);
 }
 
 void telephony_subscriber_number_req(void *telephony_device)
 {
-	debug("telephony-dummy: subscriber number request");
+	DBG("telephony-dummy: subscriber number request");
 	if (subscriber_number)
 		telephony_subscriber_number_ind(subscriber_number,
 						NUMBER_TYPE_TELEPHONY,
@@ -179,7 +179,7 @@ void telephony_subscriber_number_req(void *telephony_device)
 
 void telephony_list_current_calls_req(void *telephony_device)
 {
-	debug("telephony-dummy: list current calls request");
+	DBG("telephony-dummy: list current calls request");
 	if (active_call_number)
 		telephony_list_current_call_ind(1, active_call_dir,
 						active_call_status,
@@ -198,13 +198,13 @@ void telephony_operator_selection_req(void *telephony_device)
 
 void telephony_call_hold_req(void *telephony_device, const char *cmd)
 {
-	debug("telephony-dymmy: got call hold request %s", cmd);
+	DBG("telephony-dymmy: got call hold request %s", cmd);
 	telephony_call_hold_rsp(telephony_device, CME_ERROR_NONE);
 }
 
 void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-dummy: got %s NR and EC request",
+	DBG("telephony-dummy: got %s NR and EC request",
 			enable ? "enable" : "disable");
 
 	telephony_nr_and_ec_rsp(telephony_device, CME_ERROR_NONE);
@@ -212,7 +212,7 @@ void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)
 
 void telephony_voice_dial_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-dummy: got %s voice dial request",
+	DBG("telephony-dummy: got %s voice dial request",
 			enable ? "enable" : "disable");
 
 	g_dbus_emit_signal(connection, TELEPHONY_DUMMY_PATH,
@@ -224,7 +224,7 @@ void telephony_voice_dial_req(void *telephony_device, gboolean enable)
 
 void telephony_key_press_req(void *telephony_device, const char *keys)
 {
-	debug("telephony-dummy: got key press request for %s", keys);
+	DBG("telephony-dummy: got key press request for %s", keys);
 	telephony_key_press_rsp(telephony_device, CME_ERROR_NONE);
 }
 
@@ -238,7 +238,7 @@ static DBusMessage *outgoing_call(DBusConnection *conn, DBusMessage *msg,
 						DBUS_TYPE_INVALID))
 		return invalid_args(msg);
 
-	debug("telephony-dummy: outgoing call to %s", number);
+	DBG("telephony-dummy: outgoing call to %s", number);
 
 	g_free(active_call_number);
 	active_call_number = g_strdup(number);
@@ -263,7 +263,7 @@ static DBusMessage *incoming_call(DBusConnection *conn, DBusMessage *msg,
 						DBUS_TYPE_INVALID))
 		return invalid_args(msg);
 
-	debug("telephony-dummy: incoming call to %s", number);
+	DBG("telephony-dummy: incoming call to %s", number);
 
 	g_free(active_call_number);
 	active_call_number = g_strdup(number);
@@ -282,7 +282,7 @@ static DBusMessage *incoming_call(DBusConnection *conn, DBusMessage *msg,
 static DBusMessage *cancel_call(DBusConnection *conn, DBusMessage *msg,
 					void *data)
 {
-	debug("telephony-dummy: cancel call");
+	DBG("telephony-dummy: cancel call");
 
 	g_free(active_call_number);
 	active_call_number = NULL;
@@ -314,7 +314,7 @@ static DBusMessage *signal_strength(DBusConnection *conn, DBusMessage *msg,
 
 	telephony_update_indicator(dummy_indicators, "signal", strength);
 
-	debug("telephony-dummy: signal strength set to %u", strength);
+	DBG("telephony-dummy: signal strength set to %u", strength);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -333,7 +333,7 @@ static DBusMessage *battery_level(DBusConnection *conn, DBusMessage *msg,
 
 	telephony_update_indicator(dummy_indicators, "battchg", level);
 
-	debug("telephony-dummy: battery level set to %u", level);
+	DBG("telephony-dummy: battery level set to %u", level);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -352,7 +352,7 @@ static DBusMessage *roaming_status(DBusConnection *conn, DBusMessage *msg,
 
 	telephony_update_indicator(dummy_indicators, "roam", val);
 
-	debug("telephony-dummy: roaming status set to %d", val);
+	DBG("telephony-dummy: roaming status set to %d", val);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -371,7 +371,7 @@ static DBusMessage *registration_status(DBusConnection *conn, DBusMessage *msg,
 
 	telephony_update_indicator(dummy_indicators, "service", val);
 
-	debug("telephony-dummy: registration status set to %d", val);
+	DBG("telephony-dummy: registration status set to %d", val);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -389,7 +389,7 @@ static DBusMessage *set_subscriber_number(DBusConnection *conn,
 	g_free(subscriber_number);
 	subscriber_number = g_strdup(number);
 
-	debug("telephony-dummy: subscriber number set to %s", number);
+	DBG("telephony-dummy: subscriber number set to %s", number);
 
 	return dbus_message_new_method_return(msg);
 }
diff --git a/audio/telephony-maemo5.c b/audio/telephony-maemo5.c
index a169ea0..910fa32 100644
--- a/audio/telephony-maemo5.c
+++ b/audio/telephony-maemo5.c
@@ -318,7 +318,7 @@ static int release_conference(void)
 {
 	DBusMessage *msg;
 
-	debug("telephony-maemo: releasing conference call");
+	DBG("telephony-maemo: releasing conference call");
 
 	msg = dbus_message_new_method_call(CSD_CALL_BUS_NAME,
 						CSD_CALL_CONFERENCE_PATH,
@@ -488,7 +488,7 @@ void telephony_device_connected(void *telephony_device)
 {
 	struct csd_call *coming;
 
-	debug("telephony-maemo: device %p connected", telephony_device);
+	DBG("telephony-maemo: device %p connected", telephony_device);
 
 	coming = find_call_with_status(CSD_CALL_STATUS_MT_ALERTING);
 	if (coming) {
@@ -503,7 +503,7 @@ void telephony_device_connected(void *telephony_device)
 
 void telephony_device_disconnected(void *telephony_device)
 {
-	debug("telephony-maemo: device %p disconnected", telephony_device);
+	DBG("telephony-maemo: device %p disconnected", telephony_device);
 	events_enabled = FALSE;
 }
 
@@ -525,7 +525,7 @@ void telephony_response_and_hold_req(void *telephony_device, int rh)
 
 void telephony_last_dialed_number_req(void *telephony_device)
 {
-	debug("telephony-maemo: last dialed number request");
+	DBG("telephony-maemo: last dialed number request");
 
 	if (last_dialed_number)
 		telephony_dial_number_req(telephony_device,
@@ -646,7 +646,7 @@ void telephony_dial_number_req(void *telephony_device, const char *number)
 	uint32_t flags = callerid;
 	int ret;
 
-	debug("telephony-maemo: dial request to %s", number);
+	DBG("telephony-maemo: dial request to %s", number);
 
 	if (strncmp(number, "*31#", 4) == 0) {
 		number += 4;
@@ -686,7 +686,7 @@ void telephony_transmit_dtmf_req(void *telephony_device, char tone)
 	int ret;
 	char buf[2] = { tone, '\0' }, *buf_ptr = buf;
 
-	debug("telephony-maemo: transmit dtmf: %s", buf);
+	DBG("telephony-maemo: transmit dtmf: %s", buf);
 
 	ret = send_method_call(CSD_CALL_BUS_NAME, CSD_CALL_PATH,
 				CSD_CALL_INTERFACE, "SendDTMF",
@@ -704,7 +704,7 @@ void telephony_transmit_dtmf_req(void *telephony_device, char tone)
 
 void telephony_subscriber_number_req(void *telephony_device)
 {
-	debug("telephony-maemo: subscriber number request");
+	DBG("telephony-maemo: subscriber number request");
 	if (msisdn)
 		telephony_subscriber_number_ind(msisdn,
 						number_type(msisdn),
@@ -755,7 +755,7 @@ void telephony_list_current_calls_req(void *telephony_device)
 	GSList *l;
 	int i;
 
-	debug("telephony-maemo: list current calls request");
+	DBG("telephony-maemo: list current calls request");
 
 	for (l = calls, i = 1; l != NULL; l = l->next, i++) {
 		struct csd_call *call = l->data;
@@ -806,7 +806,7 @@ void telephony_call_hold_req(void *telephony_device, const char *cmd)
 	struct csd_call *call;
 	int err = 0;
 
-	debug("telephony-maemo: got call hold request %s", cmd);
+	DBG("telephony-maemo: got call hold request %s", cmd);
 
 	if (strlen(cmd) > 1)
 		idx = &cmd[1];
@@ -867,7 +867,7 @@ void telephony_call_hold_req(void *telephony_device, const char *cmd)
 		err = call_transfer();
 		break;
 	default:
-		debug("Unknown call hold request");
+		DBG("Unknown call hold request");
 		break;
 	}
 
@@ -880,7 +880,7 @@ void telephony_call_hold_req(void *telephony_device, const char *cmd)
 
 void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-maemo: got %s NR and EC request",
+	DBG("telephony-maemo: got %s NR and EC request",
 			enable ? "enable" : "disable");
 	telephony_nr_and_ec_rsp(telephony_device, CME_ERROR_NONE);
 }
@@ -890,7 +890,7 @@ void telephony_key_press_req(void *telephony_device, const char *keys)
 	struct csd_call *active, *waiting;
 	int err;
 
-	debug("telephony-maemo: got key press request for %s", keys);
+	DBG("telephony-maemo: got key press request for %s", keys);
 
 	waiting = find_call_with_status(CSD_CALL_STATUS_COMING);
 	if (!waiting)
@@ -916,7 +916,7 @@ void telephony_key_press_req(void *telephony_device, const char *keys)
 
 void telephony_voice_dial_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-maemo: got %s voice dial request",
+	DBG("telephony-maemo: got %s voice dial request",
 			enable ? "enable" : "disable");
 
 	telephony_voice_dial_rsp(telephony_device, CME_ERROR_NOT_SUPPORTED);
@@ -942,7 +942,7 @@ static void handle_incoming_call(DBusMessage *msg)
 		return;
 	}
 
-	debug("Incoming call to %s from number %s", call_path, number);
+	DBG("Incoming call to %s from number %s", call_path, number);
 
 	g_free(call->number);
 	call->number = g_strdup(number);
@@ -978,7 +978,7 @@ static void handle_outgoing_call(DBusMessage *msg)
 		return;
 	}
 
-	debug("Outgoing call from %s to number %s", call_path, number);
+	DBG("Outgoing call from %s to number %s", call_path, number);
 
 	g_free(call->number);
 	call->number = g_strdup(number);
@@ -1002,7 +1002,7 @@ static gboolean create_timeout(gpointer user_data)
 
 static void handle_create_requested(DBusMessage *msg)
 {
-	debug("Call.CreateRequested()");
+	DBG("Call.CreateRequested()");
 
 	if (create_request_timer)
 		g_source_remove(create_request_timer);
@@ -1040,11 +1040,11 @@ static void handle_call_status(DBusMessage *msg, const char *call_path)
 		return;
 	}
 
-	debug("Call %s changed from %s to %s", call_path,
+	DBG("Call %s changed from %s to %s", call_path,
 		call_status_str[call->status], call_status_str[status]);
 
 	if (call->status == (int) status) {
-		debug("Ignoring CSD Call state change to existing state");
+		DBG("Ignoring CSD Call state change to existing state");
 		return;
 	}
 
@@ -1182,7 +1182,7 @@ static void handle_conference(DBusMessage *msg, gboolean joined)
 		return;
 	}
 
-	debug("Call %s %s the conference", path, joined ? "joined" : "left");
+	DBG("Call %s %s the conference", path, joined ? "joined" : "left");
 
 	call->conference = joined;
 }
@@ -1227,7 +1227,7 @@ static void get_operator_name_reply(DBusPendingCall *pending_call,
 	g_free(net.operator_name);
 	net.operator_name = g_strdup(name);
 
-	debug("telephony-maemo: operator name updated: %s", name);
+	DBG("telephony-maemo: operator name updated: %s", name);
 
 done:
 	dbus_message_unref(reply);
@@ -1335,7 +1335,7 @@ static void update_signal_strength(uint8_t signals_bar)
 	int signal;
 
 	if (signals_bar > 100) {
-		debug("signals_bar greater than expected: %u", signals_bar);
+		DBG("signals_bar greater than expected: %u", signals_bar);
 		signals_bar = 100;
 	}
 
@@ -1349,7 +1349,7 @@ static void update_signal_strength(uint8_t signals_bar)
 
 	net.signals_bar = signals_bar;
 
-	debug("Signal strength updated: %u/100, %d/5", signals_bar, signal);
+	DBG("Signal strength updated: %u/100, %d/5", signals_bar, signal);
 }
 
 static void handle_signal_strength_change(DBusMessage *msg)
@@ -1425,13 +1425,13 @@ static void hal_battery_level_reply(DBusPendingCall *call, void *user_data)
 	*value = (int) level;
 
 	if (value == &battchg_last)
-		debug("telephony-maemo: battery.charge_level.last_full is %d",
+		DBG("telephony-maemo: battery.charge_level.last_full is %d",
 				*value);
 	else if (value == &battchg_design)
-		debug("telephony-maemo: battery.charge_level.design is %d",
+		DBG("telephony-maemo: battery.charge_level.design is %d",
 				*value);
 	else
-		debug("telephony-maemo: battery.charge_level.current is %d",
+		DBG("telephony-maemo: battery.charge_level.current is %d",
 				*value);
 
 	if ((battchg_design > 0 || battchg_last > 0) && battchg_cur >= 0) {
@@ -1559,7 +1559,7 @@ static void parse_call_list(DBusMessageIter *iter)
 			call->object_path = g_strdup(object_path);
 			call->status = (int) status;
 			calls = g_slist_append(calls, call);
-			debug("telephony-maemo: new csd call instance at %s",
+			DBG("telephony-maemo: new csd call instance at %s",
 								object_path);
 		}
 
@@ -1762,7 +1762,7 @@ static void hal_find_device_reply(DBusPendingCall *call, void *user_data)
 
 	dbus_message_iter_get_basic(&sub, &path);
 
-	debug("telephony-maemo: found battery device at %s", path);
+	DBG("telephony-maemo: found battery device at %s", path);
 
 	snprintf(match_string, sizeof(match_string),
 			"type='signal',"
@@ -1820,11 +1820,11 @@ static void phonebook_read_reply(DBusPendingCall *call, void *user_data)
 	if (number_type == &msisdn) {
 		g_free(msisdn);
 		msisdn = g_strdup(number);
-		debug("Got MSISDN %s (%s)", number, name);
+		DBG("Got MSISDN %s (%s)", number, name);
 	} else {
 		g_free(vmbx);
 		vmbx = g_strdup(number);
-		debug("Got voice mailbox number %s (%s)", number, name);
+		DBG("Got voice mailbox number %s (%s)", number, name);
 	}
 
 done:
@@ -1957,7 +1957,7 @@ static DBusMessage *set_callerid(DBusConnection *conn, DBusMessage *msg,
 			g_str_equal(callerid_setting, "none")) {
 		save_callerid_to_file(callerid_setting);
 		callerid = get_callflag(callerid_setting);
-		debug("telephony-maemo setting callerid flag: %s",
+		DBG("telephony-maemo setting callerid flag: %s",
 							callerid_setting);
 		return dbus_message_new_method_return(msg);
 	}
@@ -1983,7 +1983,7 @@ static void handle_modem_state(DBusMessage *msg)
 		return;
 	}
 
-	debug("SSC modem state: %s", state);
+	DBG("SSC modem state: %s", state);
 
 	if (calls != NULL || get_calls_active)
 		return;
@@ -2088,7 +2088,7 @@ int telephony_init(void)
 			TELEPHONY_MAEMO_INTERFACE, TELEPHONY_MAEMO_PATH);
 	}
 
-	debug("telephony-maemo registering %s interface on path %s",
+	DBG("telephony-maemo registering %s interface on path %s",
 			TELEPHONY_MAEMO_INTERFACE, TELEPHONY_MAEMO_PATH);
 
 	telephony_ready_ind(features, maemo_indicators, response_and_hold,
diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index e40d6e3..a48b7e2 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
@@ -274,7 +274,7 @@ static int release_conference(void)
 {
 	DBusMessage *msg;
 
-	debug("telephony-maemo6: releasing conference call");
+	DBG("telephony-maemo6: releasing conference call");
 
 	msg = dbus_message_new_method_call(CSD_CALL_BUS_NAME,
 						CSD_CALL_CONFERENCE_PATH,
@@ -444,7 +444,7 @@ void telephony_device_connected(void *telephony_device)
 {
 	struct csd_call *coming;
 
-	debug("telephony-maemo6: device %p connected", telephony_device);
+	DBG("telephony-maemo6: device %p connected", telephony_device);
 
 	coming = find_call_with_status(CSD_CALL_STATUS_MT_ALERTING);
 	if (coming) {
@@ -459,7 +459,7 @@ void telephony_device_connected(void *telephony_device)
 
 void telephony_device_disconnected(void *telephony_device)
 {
-	debug("telephony-maemo6: device %p disconnected", telephony_device);
+	DBG("telephony-maemo6: device %p disconnected", telephony_device);
 	events_enabled = FALSE;
 }
 
@@ -481,7 +481,7 @@ void telephony_response_and_hold_req(void *telephony_device, int rh)
 
 void telephony_last_dialed_number_req(void *telephony_device)
 {
-	debug("telephony-maemo6: last dialed number request");
+	DBG("telephony-maemo6: last dialed number request");
 
 	if (last_dialed_number)
 		telephony_dial_number_req(telephony_device,
@@ -602,7 +602,7 @@ void telephony_dial_number_req(void *telephony_device, const char *number)
 	uint32_t flags = callerid;
 	int ret;
 
-	debug("telephony-maemo6: dial request to %s", number);
+	DBG("telephony-maemo6: dial request to %s", number);
 
 	if (strncmp(number, "*31#", 4) == 0) {
 		number += 4;
@@ -642,7 +642,7 @@ void telephony_transmit_dtmf_req(void *telephony_device, char tone)
 	int ret;
 	char buf[2] = { tone, '\0' }, *buf_ptr = buf;
 
-	debug("telephony-maemo6: transmit dtmf: %s", buf);
+	DBG("telephony-maemo6: transmit dtmf: %s", buf);
 
 	ret = send_method_call(CSD_CALL_BUS_NAME, CSD_CALL_PATH,
 				CSD_CALL_INTERFACE, "SendDTMF",
@@ -660,7 +660,7 @@ void telephony_transmit_dtmf_req(void *telephony_device, char tone)
 
 void telephony_subscriber_number_req(void *telephony_device)
 {
-	debug("telephony-maemo6: subscriber number request");
+	DBG("telephony-maemo6: subscriber number request");
 	if (msisdn)
 		telephony_subscriber_number_ind(msisdn,
 						number_type(msisdn),
@@ -711,7 +711,7 @@ void telephony_list_current_calls_req(void *telephony_device)
 	GSList *l;
 	int i;
 
-	debug("telephony-maemo6: list current calls request");
+	DBG("telephony-maemo6: list current calls request");
 
 	for (l = calls, i = 1; l != NULL; l = l->next, i++) {
 		struct csd_call *call = l->data;
@@ -762,7 +762,7 @@ void telephony_call_hold_req(void *telephony_device, const char *cmd)
 	struct csd_call *call;
 	int err = 0;
 
-	debug("telephony-maemo6: got call hold request %s", cmd);
+	DBG("telephony-maemo6: got call hold request %s", cmd);
 
 	if (strlen(cmd) > 1)
 		idx = &cmd[1];
@@ -823,7 +823,7 @@ void telephony_call_hold_req(void *telephony_device, const char *cmd)
 		err = call_transfer();
 		break;
 	default:
-		debug("Unknown call hold request");
+		DBG("Unknown call hold request");
 		break;
 	}
 
@@ -836,7 +836,7 @@ void telephony_call_hold_req(void *telephony_device, const char *cmd)
 
 void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-maemo6: got %s NR and EC request",
+	DBG("telephony-maemo6: got %s NR and EC request",
 			enable ? "enable" : "disable");
 	telephony_nr_and_ec_rsp(telephony_device, CME_ERROR_NONE);
 }
@@ -846,7 +846,7 @@ void telephony_key_press_req(void *telephony_device, const char *keys)
 	struct csd_call *active, *waiting;
 	int err;
 
-	debug("telephony-maemo6: got key press request for %s", keys);
+	DBG("telephony-maemo6: got key press request for %s", keys);
 
 	waiting = find_call_with_status(CSD_CALL_STATUS_COMING);
 	if (!waiting)
@@ -872,7 +872,7 @@ void telephony_key_press_req(void *telephony_device, const char *keys)
 
 void telephony_voice_dial_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-maemo6: got %s voice dial request",
+	DBG("telephony-maemo6: got %s voice dial request",
 			enable ? "enable" : "disable");
 
 	telephony_voice_dial_rsp(telephony_device, CME_ERROR_NOT_SUPPORTED);
@@ -898,7 +898,7 @@ static void handle_incoming_call(DBusMessage *msg)
 		return;
 	}
 
-	debug("Incoming call to %s from number %s", call_path, number);
+	DBG("Incoming call to %s from number %s", call_path, number);
 
 	g_free(call->number);
 	call->number = g_strdup(number);
@@ -934,7 +934,7 @@ static void handle_outgoing_call(DBusMessage *msg)
 		return;
 	}
 
-	debug("Outgoing call from %s to number %s", call_path, number);
+	DBG("Outgoing call from %s to number %s", call_path, number);
 
 	g_free(call->number);
 	call->number = g_strdup(number);
@@ -958,7 +958,7 @@ static gboolean create_timeout(gpointer user_data)
 
 static void handle_create_requested(DBusMessage *msg)
 {
-	debug("Call.CreateRequested()");
+	DBG("Call.CreateRequested()");
 
 	if (create_request_timer)
 		g_source_remove(create_request_timer);
@@ -996,11 +996,11 @@ static void handle_call_status(DBusMessage *msg, const char *call_path)
 		return;
 	}
 
-	debug("Call %s changed from %s to %s", call_path,
+	DBG("Call %s changed from %s to %s", call_path,
 		call_status_str[call->status], call_status_str[status]);
 
 	if (call->status == (int) status) {
-		debug("Ignoring CSD Call state change to existing state");
+		DBG("Ignoring CSD Call state change to existing state");
 		return;
 	}
 
@@ -1138,7 +1138,7 @@ static void handle_conference(DBusMessage *msg, gboolean joined)
 		return;
 	}
 
-	debug("Call %s %s the conference", path, joined ? "joined" : "left");
+	DBG("Call %s %s the conference", path, joined ? "joined" : "left");
 
 	call->conference = joined;
 }
@@ -1209,7 +1209,7 @@ static void update_registration_status(const char *status)
 
 	net.status = new_status;
 
-	debug("telephony-maemo6: registration status changed: %s", status);
+	DBG("telephony-maemo6: registration status changed: %s", status);
 }
 
 static void handle_registration_changed(DBusMessage *msg)
@@ -1233,7 +1233,7 @@ static void update_signal_strength(int32_t signals_bar)
 	if (signals_bar < 0)
 		signals_bar = 0;
 	else if (signals_bar > 100) {
-		debug("signals_bar greater than expected: %u", signals_bar);
+		DBG("signals_bar greater than expected: %u", signals_bar);
 		signals_bar = 100;
 	}
 
@@ -1247,7 +1247,7 @@ static void update_signal_strength(int32_t signals_bar)
 
 	net.signals_bar = signals_bar;
 
-	debug("telephony-maemo6: signal strength updated: %u/100, %d/5", signals_bar, signal);
+	DBG("telephony-maemo6: signal strength updated: %u/100, %d/5", signals_bar, signal);
 }
 
 static void handle_signal_strength_changed(DBusMessage *msg)
@@ -1317,13 +1317,13 @@ static void hal_battery_level_reply(DBusPendingCall *call, void *user_data)
 	*value = (int) level;
 
 	if (value == &battchg_last)
-		debug("telephony-maemo6: battery.charge_level.last_full is %d",
+		DBG("telephony-maemo6: battery.charge_level.last_full is %d",
 				*value);
 	else if (value == &battchg_design)
-		debug("telephony-maemo6: battery.charge_level.design is %d",
+		DBG("telephony-maemo6: battery.charge_level.design is %d",
 				*value);
 	else
-		debug("telephony-maemo6: battery.charge_level.current is %d",
+		DBG("telephony-maemo6: battery.charge_level.current is %d",
 				*value);
 
 	if ((battchg_design > 0 || battchg_last > 0) && battchg_cur >= 0) {
@@ -1451,7 +1451,7 @@ static void parse_call_list(DBusMessageIter *iter)
 			call->object_path = g_strdup(object_path);
 			call->status = (int) status;
 			calls = g_slist_append(calls, call);
-			debug("telephony-maemo6: new csd call instance at %s",
+			DBG("telephony-maemo6: new csd call instance at %s",
 								object_path);
 		}
 
@@ -1483,7 +1483,7 @@ static void update_operator_name(const char *name)
 	g_free(net.operator_name);
 	net.operator_name = g_strdup(name);
 
-	debug("telephony-maemo6: operator name updated: %s", name);
+	DBG("telephony-maemo6: operator name updated: %s", name);
 }
 
 static void get_property_reply(DBusPendingCall *call, void *user_data)
@@ -1633,7 +1633,7 @@ static void hal_find_device_reply(DBusPendingCall *call, void *user_data)
 
 	dbus_message_iter_get_basic(&sub, &path);
 
-	debug("telephony-maemo6: found battery device at %s", path);
+	DBG("telephony-maemo6: found battery device at %s", path);
 
 	snprintf(match_string, sizeof(match_string),
 			"type='signal',"
@@ -1688,11 +1688,11 @@ static void phonebook_read_reply(DBusPendingCall *call, void *user_data)
 	if (number_type == &msisdn) {
 		g_free(msisdn);
 		msisdn = g_strdup(number);
-		debug("Got MSISDN %s (%s)", number, name);
+		DBG("Got MSISDN %s (%s)", number, name);
 	} else {
 		g_free(vmbx);
 		vmbx = g_strdup(number);
-		debug("Got voice mailbox number %s (%s)", number, name);
+		DBG("Got voice mailbox number %s (%s)", number, name);
 	}
 
 done:
@@ -1817,7 +1817,7 @@ static DBusMessage *set_callerid(DBusConnection *conn, DBusMessage *msg,
 			g_str_equal(callerid_setting, "none")) {
 		save_callerid_to_file(callerid_setting);
 		callerid = get_callflag(callerid_setting);
-		debug("telephony-maemo6 setting callerid flag: %s",
+		DBG("telephony-maemo6 setting callerid flag: %s",
 							callerid_setting);
 		return dbus_message_new_method_return(msg);
 	}
@@ -1843,7 +1843,7 @@ static void handle_modem_state(DBusMessage *msg)
 		return;
 	}
 
-	debug("SSC modem state: %s", state);
+	DBG("SSC modem state: %s", state);
 
 	if (calls != NULL || get_calls_active)
 		return;
@@ -1958,7 +1958,7 @@ int telephony_init(void)
 			TELEPHONY_MAEMO_INTERFACE, TELEPHONY_MAEMO_PATH);
 	}
 
-	debug("telephony-maemo6 registering %s interface on path %s",
+	DBG("telephony-maemo6 registering %s interface on path %s",
 			TELEPHONY_MAEMO_INTERFACE, TELEPHONY_MAEMO_PATH);
 
 	telephony_ready_ind(features, maemo_indicators, response_and_hold,
diff --git a/audio/telephony-ofono.c b/audio/telephony-ofono.c
index 52fa121..4511ab6 100644
--- a/audio/telephony-ofono.c
+++ b/audio/telephony-ofono.c
@@ -138,12 +138,12 @@ static struct voice_call *find_vc_with_status(int status)
 
 void telephony_device_connected(void *telephony_device)
 {
-	debug("telephony-ofono: device %p connected", telephony_device);
+	DBG("telephony-ofono: device %p connected", telephony_device);
 }
 
 void telephony_device_disconnected(void *telephony_device)
 {
-	debug("telephony-ofono: device %p disconnected", telephony_device);
+	DBG("telephony-ofono: device %p disconnected", telephony_device);
 	events_enabled = FALSE;
 }
 
@@ -165,7 +165,7 @@ void telephony_response_and_hold_req(void *telephony_device, int rh)
 
 void telephony_last_dialed_number_req(void *telephony_device)
 {
-	debug("telephony-ofono: last dialed number request");
+	DBG("telephony-ofono: last dialed number request");
 
 	if (last_dialed_number)
 		telephony_dial_number_req(telephony_device, last_dialed_number);
@@ -279,7 +279,7 @@ void telephony_dial_number_req(void *telephony_device, const char *number)
 	const char *clir;
 	int ret;
 
-	debug("telephony-ofono: dial request to %s", number);
+	DBG("telephony-ofono: dial request to %s", number);
 
 	if (!modem_obj_path) {
 		telephony_dial_number_rsp(telephony_device,
@@ -315,7 +315,7 @@ void telephony_transmit_dtmf_req(void *telephony_device, char tone)
 	char *tone_string;
 	int ret;
 
-	debug("telephony-ofono: transmit dtmf: %c", tone);
+	DBG("telephony-ofono: transmit dtmf: %c", tone);
 
 	if (!modem_obj_path) {
 		telephony_transmit_dtmf_rsp(telephony_device,
@@ -340,7 +340,7 @@ void telephony_transmit_dtmf_req(void *telephony_device, char tone)
 
 void telephony_subscriber_number_req(void *telephony_device)
 {
-	debug("telephony-ofono: subscriber number request");
+	DBG("telephony-ofono: subscriber number request");
 
 	if (subscriber_number)
 		telephony_subscriber_number_ind(subscriber_number,
@@ -354,7 +354,7 @@ void telephony_list_current_calls_req(void *telephony_device)
 	GSList *l;
 	int i;
 
-	debug("telephony-ofono: list current calls request");
+	DBG("telephony-ofono: list current calls request");
 
 	for (l = calls, i = 1; l != NULL; l = l->next, i++) {
 		struct voice_call *vc = l->data;
@@ -372,7 +372,7 @@ void telephony_list_current_calls_req(void *telephony_device)
 
 void telephony_operator_selection_req(void *telephony_device)
 {
-	debug("telephony-ofono: operator selection request");
+	DBG("telephony-ofono: operator selection request");
 
 	telephony_operator_selection_ind(OPERATOR_MODE_AUTO,
 				net.operator_name ? net.operator_name : "");
@@ -381,13 +381,13 @@ void telephony_operator_selection_req(void *telephony_device)
 
 void telephony_call_hold_req(void *telephony_device, const char *cmd)
 {
-	debug("telephony-ofono: got call hold request %s", cmd);
+	DBG("telephony-ofono: got call hold request %s", cmd);
 	telephony_call_hold_rsp(telephony_device, CME_ERROR_NONE);
 }
 
 void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-ofono: got %s NR and EC request",
+	DBG("telephony-ofono: got %s NR and EC request",
 			enable ? "enable" : "disable");
 
 	telephony_nr_and_ec_rsp(telephony_device, CME_ERROR_NONE);
@@ -395,13 +395,13 @@ void telephony_nr_and_ec_req(void *telephony_device, gboolean enable)
 
 void telephony_key_press_req(void *telephony_device, const char *keys)
 {
-	debug("telephony-ofono: got key press request for %s", keys);
+	DBG("telephony-ofono: got key press request for %s", keys);
 	telephony_key_press_rsp(telephony_device, CME_ERROR_NONE);
 }
 
 void telephony_voice_dial_req(void *telephony_device, gboolean enable)
 {
-	debug("telephony-ofono: got %s voice dial request",
+	DBG("telephony-ofono: got %s voice dial request",
 			enable ? "enable" : "disable");
 
 	telephony_voice_dial_rsp(telephony_device, CME_ERROR_NOT_SUPPORTED);
@@ -442,7 +442,7 @@ static void handle_registration_property(const char *property, DBusMessageIter s
 
 	if (g_str_equal(property, "Status")) {
 		dbus_message_iter_get_basic(&sub, &status);
-		debug("Status is %s", status);
+		DBG("Status is %s", status);
 		if (g_str_equal(status, "registered")) {
 			net.status = NETWORK_REG_STATUS_HOME;
 			telephony_update_indicator(ofono_indicators,
@@ -464,12 +464,12 @@ static void handle_registration_property(const char *property, DBusMessageIter s
 		}
 	} else if (g_str_equal(property, "Operator")) {
 		dbus_message_iter_get_basic(&sub, &operator);
-		debug("Operator is %s", operator);
+		DBG("Operator is %s", operator);
 		g_free(net.operator_name);
 		net.operator_name = g_strdup(operator);
 	} else if (g_str_equal(property, "SignalStrength")) {
 		dbus_message_iter_get_basic(&sub, &signals_bar);
-		debug("SignalStrength is %d", signals_bar);
+		DBG("SignalStrength is %d", signals_bar);
 		net.signals_bar = signals_bar;
 		telephony_update_indicator(ofono_indicators, "signal",
 						(signals_bar + 20) / 21);
@@ -560,7 +560,7 @@ static void list_modem_reply(DBusPendingCall *call, void *user_data)
 	char *property, *modem_obj_path_local;
 	int ret;
 
-	debug("list_modem_reply is called\n");
+	DBG("list_modem_reply is called\n");
 	reply = dbus_pending_call_steal_reply(call);
 
 	dbus_error_init(&err);
@@ -598,7 +598,7 @@ static void list_modem_reply(DBusPendingCall *call, void *user_data)
 
 		dbus_message_iter_get_basic(&sub, &modem_obj_path_local);
 		modem_obj_path = g_strdup(modem_obj_path_local);
-		debug("modem_obj_path is %p, %s\n", modem_obj_path,
+		DBG("modem_obj_path is %p, %s\n", modem_obj_path,
 						modem_obj_path);
 		dbus_message_iter_next(&sub);
 	}
@@ -624,7 +624,7 @@ static gboolean handle_registration_property_changed(DBusConnection *conn,
 		return TRUE;
 	}
 	dbus_message_iter_get_basic(&iter, &property);
-	debug("in handle_registration_property_changed(),"
+	DBG("in handle_registration_property_changed(),"
 					" the property is %s", property);
 
 	dbus_message_iter_next(&iter);
@@ -643,7 +643,7 @@ static void vc_getproperties_reply(DBusPendingCall *call, void *user_data)
 	const char *path = user_data;
 	struct voice_call *vc;
 
-	debug("in vc_getproperties_reply");
+	DBG("in vc_getproperties_reply");
 
 	reply = dbus_pending_call_steal_reply(call);
 	dbus_error_init(&err);
@@ -694,11 +694,11 @@ static void vc_getproperties_reply(DBusPendingCall *call, void *user_data)
 		dbus_message_iter_recurse(&iter_property, &sub);
 		if (g_str_equal(property, "LineIdentification")) {
 			dbus_message_iter_get_basic(&sub, &cli);
-			debug("in vc_getproperties_reply(), cli is %s", cli);
+			DBG("in vc_getproperties_reply(), cli is %s", cli);
 			vc->number = g_strdup(cli);
 		} else if (g_str_equal(property, "State")) {
 			dbus_message_iter_get_basic(&sub, &state);
-			debug("in vc_getproperties_reply(),"
+			DBG("in vc_getproperties_reply(),"
 					" state is %s", state);
 			if (g_str_equal(state, "incoming"))
 				vc->status = CALL_STATUS_INCOMING;
@@ -738,7 +738,7 @@ static void vc_getproperties_reply(DBusPendingCall *call, void *user_data)
 					EV_CALLSETUP_ALERTING);
 		break;
 	case CALL_STATUS_WAITING:
-		debug("in CALL_STATUS_WAITING: case");
+		DBG("in CALL_STATUS_WAITING: case");
 		vc->originating = FALSE;
 		telephony_update_indicator(ofono_indicators, "callsetup",
 					EV_CALLSETUP_INCOMING);
@@ -768,7 +768,7 @@ static gboolean handle_vc_property_changed(DBusConnection *conn,
 	DBusMessageIter iter, sub;
 	const char *property, *state;
 
-	debug("in handle_vc_property_changed, obj_path is %s", obj_path);
+	DBG("in handle_vc_property_changed, obj_path is %s", obj_path);
 
 	dbus_message_iter_init(msg, &iter);
 
@@ -778,13 +778,13 @@ static gboolean handle_vc_property_changed(DBusConnection *conn,
 	}
 
 	dbus_message_iter_get_basic(&iter, &property);
-	debug("in handle_vc_property_changed(), the property is %s", property);
+	DBG("in handle_vc_property_changed(), the property is %s", property);
 
 	dbus_message_iter_next(&iter);
 	dbus_message_iter_recurse(&iter, &sub);
 	if (g_str_equal(property, "State")) {
 		dbus_message_iter_get_basic(&sub, &state);
-		debug("in handle_vc_property_changed(), State is %s", state);
+		DBG("in handle_vc_property_changed(), State is %s", state);
 		if (g_str_equal(state, "disconnected")) {
 			printf("in disconnected case\n");
 			if (vc->status == CALL_STATUS_ACTIVE)
@@ -806,12 +806,12 @@ static gboolean handle_vc_property_changed(DBusConnection *conn,
 			if (vc->status == CALL_STATUS_INCOMING)
 				telephony_calling_stopped_ind();
 			vc->status = CALL_STATUS_ACTIVE;
-			debug("vc status is CALL_STATUS_ACTIVE");
+			DBG("vc status is CALL_STATUS_ACTIVE");
 		} else if (g_str_equal(state, "alerting")) {
 			telephony_update_indicator(ofono_indicators,
 					"callsetup", EV_CALLSETUP_ALERTING);
 			vc->status = CALL_STATUS_ALERTING;
-			debug("vc status is CALL_STATUS_ALERTING");
+			DBG("vc status is CALL_STATUS_ALERTING");
 		} else if (g_str_equal(state, "incoming")) {
 			/* state change from waiting to incoming */
 			telephony_update_indicator(ofono_indicators,
@@ -819,7 +819,7 @@ static gboolean handle_vc_property_changed(DBusConnection *conn,
 			telephony_incoming_call_ind(vc->number,
 						NUMBER_TYPE_TELEPHONY);
 			vc->status = CALL_STATUS_INCOMING;
-			debug("vc status is CALL_STATUS_INCOMING");
+			DBG("vc status is CALL_STATUS_INCOMING");
 		}
 	}
 
@@ -833,7 +833,7 @@ static gboolean handle_vcmanager_property_changed(DBusConnection *conn,
 	const char *property, *vc_obj_path = NULL;
 	struct voice_call *vc, *vc_new = NULL;
 
-	debug("in handle_vcmanager_property_changed");
+	DBG("in handle_vcmanager_property_changed");
 
 	dbus_message_iter_init(msg, &iter);
 
@@ -844,7 +844,7 @@ static gboolean handle_vcmanager_property_changed(DBusConnection *conn,
 	}
 
 	dbus_message_iter_get_basic(&iter, &property);
-	debug("in handle_vcmanager_property_changed(),"
+	DBG("in handle_vcmanager_property_changed(),"
 				" the property is %s", property);
 
 	dbus_message_iter_next(&iter);
@@ -859,7 +859,7 @@ static gboolean handle_vcmanager_property_changed(DBusConnection *conn,
 		dbus_message_iter_get_basic(&array, &vc_obj_path);
 		vc = find_vc(vc_obj_path);
 		if (vc) {
-			debug("in handle_vcmanager_property_changed,"
+			DBG("in handle_vcmanager_property_changed,"
 					" found an existing vc");
 		} else {
 			vc_new = g_new0(struct voice_call, 1);
@@ -916,13 +916,13 @@ static void hal_battery_level_reply(DBusPendingCall *call, void *user_data)
 	*value = (int) level;
 
 	if (value == &battchg_last)
-		debug("telephony-ofono: battery.charge_level.last_full"
+		DBG("telephony-ofono: battery.charge_level.last_full"
 					" is %d", *value);
 	else if (value == &battchg_design)
-		debug("telephony-ofono: battery.charge_level.design"
+		DBG("telephony-ofono: battery.charge_level.design"
 					" is %d", *value);
 	else
-		debug("telephony-ofono: battery.charge_level.current"
+		DBG("telephony-ofono: battery.charge_level.current"
 					" is %d", *value);
 
 	if ((battchg_design > 0 || battchg_last > 0) && battchg_cur >= 0) {
@@ -1014,7 +1014,7 @@ static void hal_find_device_reply(DBusPendingCall *call, void *user_data)
 	int type;
 	const char *path;
 
-	debug("begin of hal_find_device_reply()");
+	DBG("begin of hal_find_device_reply()");
 	reply = dbus_pending_call_steal_reply(call);
 
 	dbus_error_init(&err);
@@ -1044,7 +1044,7 @@ static void hal_find_device_reply(DBusPendingCall *call, void *user_data)
 
 	dbus_message_iter_get_basic(&sub, &path);
 
-	debug("telephony-ofono: found battery device at %s", path);
+	DBG("telephony-ofono: found battery device at %s", path);
 
 	device_watch = g_dbus_add_signal_watch(connection, NULL, path,
 					"org.freedesktop.Hal.Device",
@@ -1094,7 +1094,7 @@ int telephony_init(void)
 	if (ret < 0)
 		return ret;
 
-	debug("telephony_init() successfully");
+	DBG("telephony_init() successfully");
 
 	return ret;
 }
diff --git a/audio/telephony.h b/audio/telephony.h
index 0bc4769..5343e8c 100644
--- a/audio/telephony.h
+++ b/audio/telephony.h
@@ -207,10 +207,10 @@ static inline int telephony_update_indicator(struct indicator *indicators,
 	if (!ind)
 		return -ENOENT;
 
-	debug("Telephony indicator \"%s\" %d->%d", desc, ind->val, new_val);
+	DBG("Telephony indicator \"%s\" %d->%d", desc, ind->val, new_val);
 
 	if (ind->ignore_redundant && ind->val == new_val) {
-		debug("Ignoring no-change indication");
+		DBG("Ignoring no-change indication");
 		return 0;
 	}
 
diff --git a/audio/unix.c b/audio/unix.c
index c2d6623..3fdf5c8 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -97,7 +97,7 @@ static int unix_sock = -1;
 
 static void client_free(struct unix_client *client)
 {
-	debug("client_free(%p)", client);
+	DBG("client_free(%p)", client);
 
 	if (client->cancel && client->dev && client->req_id > 0)
 		client->cancel(client->dev, client->req_id);
@@ -147,7 +147,7 @@ static void unix_ipc_sendmsg(struct unix_client *client,
 	const char *type = bt_audio_strtype(msg->type);
 	const char *name = bt_audio_strname(msg->name);
 
-	debug("Audio API: %s -> %s", type, name);
+	DBG("Audio API: %s -> %s", type, name);
 
 	if (send(client->sock, msg, msg->length, 0) < 0)
 		error("Error %s(%d)", strerror(errno), errno);
@@ -168,7 +168,7 @@ static void unix_ipc_error(struct unix_client *client, uint8_t name, int err)
 
 	rsp->posix_errno = err;
 
-	debug("sending error %s(%d)", strerror(err), err);
+	DBG("sending error %s(%d)", strerror(err), err);
 	unix_ipc_sendmsg(client, &rsp->h);
 }
 
@@ -448,7 +448,7 @@ failed:
 
 static void print_mpeg12(struct mpeg_codec_cap *mpeg)
 {
-	debug("Media Codec: MPEG12"
+	DBG("Media Codec: MPEG12"
 		" Channel Modes: %s%s%s%s"
 		" Frequencies: %s%s%s%s%s%s"
 		" Layers: %s%s%s"
@@ -473,7 +473,7 @@ static void print_mpeg12(struct mpeg_codec_cap *mpeg)
 
 static void print_sbc(struct sbc_codec_cap *sbc)
 {
-	debug("Media Codec: SBC"
+	DBG("Media Codec: SBC"
 		" Channel Modes: %s%s%s%s"
 		" Frequencies: %s%s%s%s"
 		" Subbands: %s%s"
@@ -593,7 +593,7 @@ static int a2dp_append_codec(struct bt_get_capabilities_rsp *rsp,
 	codec->lock = lock;
 	rsp->h.length += codec->length;
 
-	debug("Append %s seid %d - length %d - total %d",
+	DBG("Append %s seid %d - length %d - total %d",
 		configured ? "configured" : "", seid, codec->length,
 		rsp->h.length);
 
@@ -611,7 +611,7 @@ static void a2dp_discovery_complete(struct avdtp *session, GSList *seps,
 	GSList *l;
 
 	if (!g_slist_find(clients, client)) {
-		debug("Client disconnected during discovery");
+		DBG("Client disconnected during discovery");
 		return;
 	}
 
@@ -1361,7 +1361,7 @@ static int handle_sco_open(struct unix_client *client, struct bt_open_req *req)
 		!g_str_equal(client->interface, AUDIO_GATEWAY_INTERFACE))
 		return -EIO;
 
-	debug("open sco - object=%s source=%s destination=%s lock=%s%s",
+	DBG("open sco - object=%s source=%s destination=%s lock=%s%s",
 			strcmp(req->object, "") ? req->object : "ANY",
 			strcmp(req->source, "") ? req->source : "ANY",
 			strcmp(req->destination, "") ? req->destination : "ANY",
@@ -1380,7 +1380,7 @@ static int handle_a2dp_open(struct unix_client *client, struct bt_open_req *req)
 			!g_str_equal(client->interface, AUDIO_SOURCE_INTERFACE))
 		return -EIO;
 
-	debug("open a2dp - object=%s source=%s destination=%s lock=%s%s",
+	DBG("open a2dp - object=%s source=%s destination=%s lock=%s%s",
 			strcmp(req->object, "") ? req->object : "ANY",
 			strcmp(req->source, "") ? req->source : "ANY",
 			strcmp(req->destination, "") ? req->destination : "ANY",
@@ -1688,7 +1688,7 @@ static gboolean client_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
 		return FALSE;
 
 	if (cond & (G_IO_HUP | G_IO_ERR)) {
-		debug("Unix client disconnected (fd=%d)", client->sock);
+		DBG("Unix client disconnected (fd=%d)", client->sock);
 
 		goto failed;
 	}
@@ -1704,7 +1704,7 @@ static gboolean client_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
 	type = bt_audio_strtype(msghdr->type);
 	name = bt_audio_strname(msghdr->name);
 
-	debug("Audio API: %s <- %s", type, name);
+	DBG("Audio API: %s <- %s", type, name);
 
 	if (msghdr->length != len) {
 		error("Invalid message: length mismatch");
@@ -1785,7 +1785,7 @@ static gboolean server_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
 		return TRUE;
 	}
 
-	debug("Accepted new client connection on unix socket (fd=%d)", cli_sk);
+	DBG("Accepted new client connection on unix socket (fd=%d)", cli_sk);
 	set_nonblocking(cli_sk);
 
 	client = g_new0(struct unix_client, 1);
@@ -1804,7 +1804,7 @@ void unix_device_removed(struct audio_device *dev)
 {
 	GSList *l;
 
-	debug("unix_device_removed(%p)", dev);
+	DBG("unix_device_removed(%p)", dev);
 
 	l = clients;
 	while (l) {
@@ -1825,7 +1825,7 @@ void unix_delay_report(struct audio_device *dev, uint8_t seid, uint16_t delay)
 	GSList *l;
 	struct bt_delay_report_ind ind;
 
-	debug("unix_delay_report(%p): %u.%ums", dev, delay / 10, delay % 10);
+	DBG("unix_delay_report(%p): %u.%ums", dev, delay / 10, delay % 10);
 
 	memset(&ind, 0, sizeof(ind));
 	ind.h.type = BT_INDICATION;
@@ -1882,7 +1882,7 @@ int unix_init(void)
 							server_cb, NULL);
 	g_io_channel_unref(io);
 
-	debug("Unix socket created: %d", sk);
+	DBG("Unix socket created: %d", sk);
 
 	return 0;
 }
diff --git a/input/device.c b/input/device.c
index e047009..511ac95 100644
--- a/input/device.c
+++ b/input/device.c
@@ -298,7 +298,7 @@ static gboolean rfcomm_io_cb(GIOChannel *chan, GIOCondition cond, gpointer data)
 		goto failed;
 	}
 
-	debug("Received: %s", buf);
+	DBG("Received: %s", buf);
 
 	if (g_io_channel_write(chan, ok, 6, &bwritten) != G_IO_ERROR_NONE) {
 		error("IO Channel write error");
@@ -1004,7 +1004,7 @@ static void device_unregister(void *data)
 {
 	struct input_device *idev = data;
 
-	debug("Unregistered interface %s on path %s", INPUT_DEVICE_INTERFACE,
+	DBG("Unregistered interface %s on path %s", INPUT_DEVICE_INTERFACE,
 								idev->path);
 
 	devices = g_slist_remove(devices, idev);
@@ -1091,7 +1091,7 @@ static struct input_device *input_device_new(DBusConnection *conn,
 		return NULL;
 	}
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 			INPUT_DEVICE_INTERFACE, idev->path);
 
 	return idev;
diff --git a/input/manager.c b/input/manager.c
index a1c229f..30cdd3e 100644
--- a/input/manager.c
+++ b/input/manager.c
@@ -179,7 +179,7 @@ int input_manager_init(DBusConnection *conn, GKeyFile *config)
 		idle_timeout = g_key_file_get_integer(config, "General",
 						"IdleTimeout", &err);
 		if (err) {
-			debug("input.conf: %s", err->message);
+			DBG("input.conf: %s", err->message);
 			g_error_free(err);
 		}
 	}
diff --git a/input/server.c b/input/server.c
index 7eddf93..1197379 100644
--- a/input/server.c
+++ b/input/server.c
@@ -82,7 +82,7 @@ static void connect_event_cb(GIOChannel *chan, GError *err, gpointer data)
 		return;
 	}
 
-	debug("Incoming connection on PSM %d", psm);
+	DBG("Incoming connection on PSM %d", psm);
 
 	ret = input_device_set_channel(&src, &dst, psm, chan);
 	if (ret == 0)
diff --git a/network/common.c b/network/common.c
index 2d2fb69..6340883 100644
--- a/network/common.c
+++ b/network/common.c
@@ -79,9 +79,9 @@ static gint find_devname(gconstpointer a, gconstpointer b)
 static void script_exited(GPid pid, gint status, gpointer data)
 {
 	if (WIFEXITED(status))
-		debug("%d exited with status %d", pid, WEXITSTATUS(status));
+		DBG("%d exited with status %d", pid, WEXITSTATUS(status));
 	else
-		debug("%d was killed by signal %d", pid, WTERMSIG(status));
+		DBG("%d was killed by signal %d", pid, WTERMSIG(status));
 
 	g_spawn_close_pid(pid);
 }
diff --git a/network/connection.c b/network/connection.c
index 3e52d2a..17c3396 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -539,7 +539,7 @@ static void path_unregister(void *data)
 {
 	struct network_peer *peer = data;
 
-	debug("Unregistered interface %s on path %s",
+	DBG("Unregistered interface %s on path %s",
 		NETWORK_PEER_INTERFACE, peer->path);
 
 	peers = g_slist_remove(peers, peer);
@@ -603,7 +603,7 @@ static struct network_peer *create_peer(struct btd_device *device,
 		return NULL;
 	}
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 		NETWORK_PEER_INTERFACE, path);
 
 	return peer;
diff --git a/network/manager.c b/network/manager.c
index bc84de0..ee19c03 100644
--- a/network/manager.c
+++ b/network/manager.c
@@ -102,7 +102,7 @@ static void read_config(const char *file)
 	disabled = g_key_file_get_string_list(keyfile, "General",
 						"Disable", NULL, &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	} else {
 		int i;
@@ -118,7 +118,7 @@ static void read_config(const char *file)
 	conf.security = !g_key_file_get_boolean(keyfile, "General",
 						"DisableSecurity", &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	}
 
@@ -126,21 +126,21 @@ static void read_config(const char *file)
 	conf.panu_script = g_key_file_get_string(keyfile, "PANU Role",
 						"Script", &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	}
 
 	conf.gn_script = g_key_file_get_string(keyfile, "GN Role",
 						"Script", &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	}
 
 	conf.nap_script = g_key_file_get_string(keyfile, "NAP Role",
 						"Script", &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	}
 #endif
@@ -148,21 +148,21 @@ static void read_config(const char *file)
 	conf.iface_prefix = g_key_file_get_string(keyfile, "PANU Role",
 						"Interface", &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	}
 
 	conf.gn_iface = g_key_file_get_string(keyfile, "GN Role",
 						"Interface", &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	}
 
 	conf.nap_iface = g_key_file_get_string(keyfile, "NAP Role",
 						"Interface", &err);
 	if (err) {
-		debug("%s: %s", file, err->message);
+		DBG("%s: %s", file, err->message);
 		g_clear_error(&err);
 	}
 
@@ -177,7 +177,7 @@ done:
 	if (!conf.nap_iface)
 		conf.nap_iface = g_strdup(NAP_IFACE);
 
-	debug("Config options: InterfacePrefix=%s, PANU_Script=%s, "
+	DBG("Config options: InterfacePrefix=%s, PANU_Script=%s, "
 		"GN_Script=%s, NAP_Script=%s, GN_Interface=%s, "
 		"NAP_Interface=%s, Security=%s",
 		conf.iface_prefix, conf.panu_script, conf.gn_script,
diff --git a/network/server.c b/network/server.c
index 8a3ee6a..475f12c 100644
--- a/network/server.c
+++ b/network/server.c
@@ -500,7 +500,7 @@ static void confirm_event(GIOChannel *chan, gpointer user_data)
 		goto drop;
 	}
 
-	debug("BNEP: incoming connect from %s", address);
+	DBG("BNEP: incoming connect from %s", address);
 
 	if (na->setup) {
 		error("Refusing connect from %s: setup in progress", address);
@@ -564,7 +564,7 @@ static uint32_t register_server_record(struct network_server *ns)
 		return 0;
 	}
 
-	debug("register_server_record: got record id 0x%x", record->handle);
+	DBG("register_server_record: got record id 0x%x", record->handle);
 
 	return record->handle;
 }
@@ -786,7 +786,7 @@ static void path_unregister(void *data)
 	struct network_server *ns = data;
 	struct network_adapter *na = ns->na;
 
-	debug("Unregistered interface %s on path %s",
+	DBG("Unregistered interface %s on path %s",
 		ns->iface, adapter_get_path(na->adapter));
 
 	na->servers = g_slist_remove(na->servers, ns);
@@ -893,7 +893,7 @@ int server_register(struct btd_adapter *adapter, uint16_t id)
 	ns->enable = TRUE;
 	na->servers = g_slist_append(na->servers, ns);
 
-	debug("Registered interface %s on path %s", ns->iface, path);
+	DBG("Registered interface %s on path %s", ns->iface, path);
 
 	return 0;
 }
diff --git a/plugins/echo.c b/plugins/echo.c
index 79cf548..d884d41 100644
--- a/plugins/echo.c
+++ b/plugins/echo.c
@@ -151,14 +151,14 @@ static struct btd_adapter_driver echo_server = {
 
 static int echo_init(void)
 {
-	debug("Setup echo plugin");
+	DBG("Setup echo plugin");
 
 	return btd_register_adapter_driver(&echo_server);
 }
 
 static void echo_exit(void)
 {
-	debug("Cleanup echo plugin");
+	DBG("Cleanup echo plugin");
 
 	btd_unregister_adapter_driver(&echo_server);
 }
diff --git a/plugins/hal.c b/plugins/hal.c
index a04ba59..73355d5 100644
--- a/plugins/hal.c
+++ b/plugins/hal.c
@@ -59,7 +59,7 @@ static void formfactor_reply(DBusPendingCall *call, void *user_data)
 		return;
 	}
 
-	debug("Computer is classified as %s", formfactor);
+	DBG("Computer is classified as %s", formfactor);
 
 	if (formfactor != NULL) {
 		if (g_str_equal(formfactor, "laptop") == TRUE)
@@ -75,7 +75,7 @@ static void formfactor_reply(DBusPendingCall *call, void *user_data)
 	dbus_message_unref(reply);
 
 	/* Computer major class */
-	debug("Setting 0x%06x for major/minor device class", (1 << 8) | minor);
+	DBG("Setting 0x%06x for major/minor device class", (1 << 8) | minor);
 
 	btd_adapter_set_class(adapter, 0x01, minor);
 }
diff --git a/plugins/hciops.c b/plugins/hciops.c
index 05c3d4e..9190c80 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -63,7 +63,7 @@ static gboolean child_exit(GIOChannel *io, GIOCondition cond, void *user_data)
 	if (waitpid(child_pid, &status, 0) != child_pid)
 		error("waitpid(%d) failed", child_pid);
 	else
-		debug("child %d exited", child_pid);
+		DBG("child %d exited", child_pid);
 
 	return TRUE;
 }
@@ -131,7 +131,7 @@ static void init_device(int index)
 			error("Fork failed. Can't init device hci%d: %s (%d)",
 					index, strerror(err), err);
 		default:
-			debug("child %d forked", pid);
+			DBG("child %d forked", pid);
 			return;
 	}
 
diff --git a/plugins/netlink.c b/plugins/netlink.c
index ee10816..5b4915b 100644
--- a/plugins/netlink.c
+++ b/plugins/netlink.c
@@ -53,7 +53,7 @@ static gboolean channel_callback(GIOChannel *chan,
 	if (cond & (G_IO_ERR | G_IO_HUP | G_IO_NVAL))
 		return FALSE;
 
-	debug("Message available on netlink channel");
+	DBG("Message available on netlink channel");
 
 	err = nl_recvmsgs_default(handle);
 
diff --git a/plugins/pnat.c b/plugins/pnat.c
index 6ff1d56..4a06582 100644
--- a/plugins/pnat.c
+++ b/plugins/pnat.c
@@ -143,7 +143,7 @@ static gboolean client_event(GIOChannel *chan,
 
 	ba2str(&client->bda, addr);
 
-	debug("Disconnected DUN from %s (%s)", addr, client->tty_name);
+	DBG("Disconnected DUN from %s (%s)", addr, client->tty_name);
 
 	client->io_watch = 0;
 	disconnect(server);
@@ -157,10 +157,10 @@ static void pnatd_exit(GPid pid, gint status, gpointer user_data)
 	struct dun_client *client = &server->client;
 
         if (WIFEXITED(status))
-                debug("pnatd (%d) exited with status %d", pid,
+                DBG("pnatd (%d) exited with status %d", pid,
 							WEXITSTATUS(status));
         else
-                debug("pnatd (%d) was killed by signal %d", pid,
+                DBG("pnatd (%d) was killed by signal %d", pid,
 							WTERMSIG(status));
 
 	client->pnatd_watch = 0;
@@ -183,7 +183,7 @@ static gboolean start_pnatd(struct dun_server *server)
 		return FALSE;
 	}
 
-	debug("pnatd started for %s with pid %d", client->tty_name, pid);
+	DBG("pnatd started for %s with pid %d", client->tty_name, pid);
 
 	client->pnatd_pid = pid;
 	client->pnatd_watch = g_child_watch_add(pid, pnatd_exit, server);
@@ -210,7 +210,7 @@ static gboolean tty_try_open(gpointer user_data)
 		return TRUE;
 	}
 
-	debug("%s created for DUN", client->tty_name);
+	DBG("%s created for DUN", client->tty_name);
 
 	client->tty_open = TRUE;
 	client->tty_timer = 0;
@@ -505,14 +505,14 @@ static struct btd_adapter_driver pnat_server = {
 
 static int pnat_init(void)
 {
-	debug("Setup Phonet AT (DUN) plugin");
+	DBG("Setup Phonet AT (DUN) plugin");
 
 	return btd_register_adapter_driver(&pnat_server);
 }
 
 static void pnat_exit(void)
 {
-	debug("Cleanup Phonet AT (DUN) plugin");
+	DBG("Cleanup Phonet AT (DUN) plugin");
 
 	btd_unregister_adapter_driver(&pnat_server);
 }
diff --git a/plugins/service.c b/plugins/service.c
index ba10b02..182b829 100644
--- a/plugins/service.c
+++ b/plugins/service.c
@@ -107,7 +107,7 @@ static void element_start(GMarkupParseContext *context,
 				break;
 			}
 		}
-		debug("New attribute 0x%04x", ctx_data->attr_id);
+		DBG("New attribute 0x%04x", ctx_data->attr_id);
 		return;
 	}
 
@@ -174,13 +174,13 @@ static void element_end(GMarkupParseContext *context,
 			int ret = sdp_attr_add(ctx_data->record, ctx_data->attr_id,
 							ctx_data->stack_head->data);
 			if (ret == -1)
-				debug("Trouble adding attribute\n");
+				DBG("Trouble adding attribute\n");
 
 			ctx_data->stack_head->data = NULL;
 			sdp_xml_data_free(ctx_data->stack_head);
 			ctx_data->stack_head = NULL;
 		} else {
-			debug("No data for attribute 0x%04x\n", ctx_data->attr_id);
+			DBG("No data for attribute 0x%04x\n", ctx_data->attr_id);
 		}
 		return;
 	}
@@ -321,7 +321,7 @@ static void exit_callback(DBusConnection *conn, void *user_data)
 	struct service_adapter *serv_adapter = user_record->serv_adapter;
 	struct pending_auth *auth;
 
-	debug("remove record");
+	DBG("remove record");
 
 	serv_adapter->records = g_slist_remove(serv_adapter->records,
 						user_record);
@@ -409,7 +409,7 @@ static int add_xml_record(DBusConnection *conn, const char *sender,
 	serv_adapter->records = g_slist_append(serv_adapter->records,
 								user_record);
 
-	debug("listener_id %d", user_record->listener_id);
+	DBG("listener_id %d", user_record->listener_id);
 
 	*handle = user_record->handle;
 
@@ -493,13 +493,13 @@ static int remove_record(DBusConnection *conn, const char *sender,
 {
 	struct record_data *user_record;
 
-	debug("remove record 0x%x", handle);
+	DBG("remove record 0x%x", handle);
 
 	user_record = find_record(serv_adapter, handle, sender);
 	if (!user_record)
 		return -1;
 
-	debug("listner_id %d", user_record->listener_id);
+	DBG("listner_id %d", user_record->listener_id);
 
 	g_dbus_remove_watch(conn, user_record->listener_id);
 
@@ -789,7 +789,7 @@ static int register_interface(const char *path, struct btd_adapter *adapter)
 		return -EIO;
 	}
 
-	debug("Registered interface %s on path %s", SERVICE_INTERFACE, path);
+	DBG("Registered interface %s on path %s", SERVICE_INTERFACE, path);
 
 	if (serv_adapter->adapter == NULL)
 		serv_adapter_any = serv_adapter;
diff --git a/serial/port.c b/serial/port.c
index b29aab3..7382cf3 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -155,7 +155,7 @@ static int port_release(struct serial_port *port)
 		return 0;
 	}
 
-	debug("Serial port %s released", port->dev);
+	DBG("Serial port %s released", port->dev);
 
 	rfcomm_ctl = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_RFCOMM);
 	if (rfcomm_ctl < 0)
@@ -223,7 +223,7 @@ static void path_unregister(void *data)
 {
 	struct serial_device *device = data;
 
-	debug("Unregistered interface %s on path %s", SERIAL_PORT_INTERFACE,
+	DBG("Unregistered interface %s on path %s", SERIAL_PORT_INTERFACE,
 		device->path);
 
 	devices = g_slist_remove(devices, device);
@@ -358,7 +358,7 @@ static void rfcomm_connect_cb(GIOChannel *chan, GError *conn_err,
 
 	port->dev = g_strdup_printf("/dev/rfcomm%d", port->id);
 
-	debug("Serial port %s created", port->dev);
+	DBG("Serial port %s created", port->dev);
 
 	g_io_channel_shutdown(chan, TRUE, NULL);
 
@@ -592,7 +592,7 @@ static struct serial_device *create_serial_device(DBusConnection *conn,
 		return NULL;
 	}
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 		SERIAL_PORT_INTERFACE, path);
 
 	return device;
diff --git a/serial/proxy.c b/serial/proxy.c
index 41bd331..442ce5d 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -493,7 +493,7 @@ static void confirm_event_cb(GIOChannel *chan, gpointer user_data)
 		goto drop;
 	}
 
-	debug("Serial Proxy: incoming connect from %s", address);
+	DBG("Serial Proxy: incoming connect from %s", address);
 
 	prx->rfcomm = g_io_channel_ref(chan);
 
@@ -539,7 +539,7 @@ static int enable_proxy(struct serial_proxy *prx)
 		goto failed;
 	}
 
-	debug("Allocated channel %d", prx->channel);
+	DBG("Allocated channel %d", prx->channel);
 
 	g_io_channel_set_close_on_unref(prx->io, TRUE);
 
@@ -794,7 +794,7 @@ static void proxy_path_unregister(gpointer data)
 	struct serial_proxy *prx = data;
 	int sk;
 
-	debug("Unregistered proxy: %s", prx->address);
+	DBG("Unregistered proxy: %s", prx->address);
 
 	if (prx->type != TTY_PROXY)
 		goto done;
@@ -829,7 +829,7 @@ static int register_proxy_object(struct serial_proxy *prx)
 	prx->path = g_strdup(path);
 	adapter->proxies = g_slist_append(adapter->proxies, prx);
 
-	debug("Registered proxy: %s", path);
+	DBG("Registered proxy: %s", path);
 
 	return 0;
 }
@@ -1225,7 +1225,7 @@ static void serial_proxy_init(struct serial_adapter *adapter)
 		uuid_str = g_key_file_get_string(config, group_str, "UUID",
 									&gerr);
 		if (gerr) {
-			debug("%s: %s", file, gerr->message);
+			DBG("%s: %s", file, gerr->message);
 			g_error_free(gerr);
 			g_key_file_free(config);
 			g_strfreev(group_list);
@@ -1235,7 +1235,7 @@ static void serial_proxy_init(struct serial_adapter *adapter)
 		address = g_key_file_get_string(config, group_str, "Address",
 									&gerr);
 		if (gerr) {
-			debug("%s: %s", file, gerr->message);
+			DBG("%s: %s", file, gerr->message);
 			g_error_free(gerr);
 			g_key_file_free(config);
 			g_free(uuid_str);
@@ -1247,7 +1247,7 @@ static void serial_proxy_init(struct serial_adapter *adapter)
 		if (err == -EINVAL)
 			error("Invalid address.");
 		else if (err == -EALREADY)
-			debug("Proxy already exists.");
+			DBG("Proxy already exists.");
 		else if (err < 0)
 			error("Proxy creation failed (%s)", strerror(-err));
 		else {
@@ -1291,7 +1291,7 @@ int proxy_register(DBusConnection *conn, struct btd_adapter *btd_adapter)
 
 	adapters = g_slist_append(adapters, adapter);
 
-	debug("Registered interface %s on path %s",
+	DBG("Registered interface %s on path %s",
 		SERIAL_MANAGER_INTERFACE, path);
 
 	serial_proxy_init(adapter);
diff --git a/src/adapter.c b/src/adapter.c
index f246a79..d4887aa 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -220,7 +220,7 @@ static int adapter_set_service_classes(struct btd_adapter *adapter, uint8_t valu
 			adapter->cache_enable || adapter->pending_cod)
 		return 0;
 
-	debug("Changing service classes to 0x%06x", adapter->wanted_cod);
+	DBG("Changing service classes to 0x%06x", adapter->wanted_cod);
 
 	err = adapter_ops->set_class(adapter->dev_id, adapter->wanted_cod);
 	if (err < 0)
@@ -246,7 +246,7 @@ int btd_adapter_set_class(struct btd_adapter *adapter, uint8_t major,
 			adapter->cache_enable || adapter->pending_cod)
 		return 0;
 
-	debug("Changing Major/Minor class to 0x%06x", adapter->wanted_cod);
+	DBG("Changing Major/Minor class to 0x%06x", adapter->wanted_cod);
 
 	err = adapter_ops->set_class(adapter->dev_id, adapter->wanted_cod);
 	if (err < 0)
@@ -616,7 +616,7 @@ static void session_remove(struct session_req *req)
 		if (mode == adapter->mode)
 			return;
 
-		debug("Switching to '%s' mode", mode2str(mode));
+		DBG("Switching to '%s' mode", mode2str(mode));
 
 		set_mode(adapter, mode);
 	} else {
@@ -626,7 +626,7 @@ static void session_remove(struct session_req *req)
 		if (adapter->disc_sessions)
 			return;
 
-		debug("Stopping discovery");
+		DBG("Stopping discovery");
 
 		pending_remote_name_cancel(adapter);
 
@@ -646,7 +646,7 @@ static void session_remove(struct session_req *req)
 
 static void session_free(struct session_req *req)
 {
-	debug("%s session %p with %s deactivated",
+	DBG("%s session %p with %s deactivated",
 		req->mode ? "Mode" : "Discovery", req, req->owner);
 
 	if (req->id)
@@ -675,7 +675,7 @@ static struct session_req *session_ref(struct session_req *req)
 {
 	req->refcount++;
 
-	debug("session_ref(%p): ref=%d", req, req->refcount);
+	DBG("session_ref(%p): ref=%d", req, req->refcount);
 
 	return req;
 }
@@ -684,7 +684,7 @@ static void session_unref(struct session_req *req)
 {
 	req->refcount--;
 
-	debug("session_unref(%p): ref=%d", req, req->refcount);
+	DBG("session_unref(%p): ref=%d", req, req->refcount);
 
 	if (req->refcount)
 		return;
@@ -894,7 +894,7 @@ void adapter_update_tx_power(bdaddr_t *bdaddr, uint8_t status, void *ptr)
 
 	adapter->tx_power = *((int8_t *) ptr);
 
-	debug("inquiry respone tx power level is %d", adapter->tx_power);
+	DBG("inquiry respone tx power level is %d", adapter->tx_power);
 
 	update_ext_inquiry_response(adapter);
 }
@@ -1116,7 +1116,7 @@ struct btd_device *adapter_create_device(DBusConnection *conn,
 	struct btd_device *device;
 	const char *path;
 
-	debug("adapter_create_device(%s)", address);
+	DBG("adapter_create_device(%s)", address);
 
 	device = device_create(conn, adapter, address);
 	if (!device)
@@ -1177,7 +1177,7 @@ struct btd_device *adapter_get_device(DBusConnection *conn,
 {
 	struct btd_device *device;
 
-	debug("adapter_get_device(%s)", address);
+	DBG("adapter_get_device(%s)", address);
 
 	if (!adapter)
 		return NULL;
@@ -1593,7 +1593,7 @@ static DBusMessage *create_device(DBusConnection *conn,
 				ERROR_INTERFACE ".AlreadyExists",
 				"Device already exists");
 
-	debug("create_device(%s)", address);
+	DBG("create_device(%s)", address);
 
 	device = adapter_create_device(conn, adapter, address);
 	if (!device)
@@ -1772,7 +1772,7 @@ static DBusMessage *register_agent(DBusConnection *conn,
 
 	adapter->agent = agent;
 
-	debug("Agent registered for hci%d at %s:%s", adapter->dev_id, name,
+	DBG("Agent registered for hci%d at %s:%s", adapter->dev_id, name,
 			path);
 
 	return dbus_message_new_method_return(msg);
@@ -2250,7 +2250,7 @@ int adapter_start(struct btd_adapter *adapter)
 	if (!bacmp(&di.bdaddr, BDADDR_ANY)) {
 		int err;
 
-		debug("Adapter %s without an address", adapter->path);
+		DBG("Adapter %s without an address", adapter->path);
 
 		err = adapter_read_bdaddr(adapter->dev_id, &di.bdaddr);
 		if (err < 0)
@@ -2328,7 +2328,7 @@ setup:
 	adapter_setup(adapter, mode);
 
 	if (!adapter->initialized && adapter->already_up) {
-		debug("Stopping Inquiry at adapter startup");
+		DBG("Stopping Inquiry at adapter startup");
 		adapter_ops->stop_discovery(adapter->dev_id);
 	}
 
@@ -2466,7 +2466,7 @@ static void adapter_free(gpointer user_data)
 	agent_free(adapter->agent);
 	adapter->agent = NULL;
 
-	debug("adapter_free(%p)", adapter);
+	DBG("adapter_free(%p)", adapter);
 
 	if (adapter->auth_idle_id)
 		g_source_remove(adapter->auth_idle_id);
@@ -2479,7 +2479,7 @@ struct btd_adapter *btd_adapter_ref(struct btd_adapter *adapter)
 {
 	adapter->ref++;
 
-	debug("btd_adapter_ref(%p): ref=%d", adapter, adapter->ref);
+	DBG("btd_adapter_ref(%p): ref=%d", adapter, adapter->ref);
 
 	return adapter;
 }
@@ -2490,7 +2490,7 @@ void btd_adapter_unref(struct btd_adapter *adapter)
 
 	adapter->ref--;
 
-	debug("btd_adapter_unref(%p): ref=%d", adapter, adapter->ref);
+	DBG("btd_adapter_unref(%p): ref=%d", adapter, adapter->ref);
 
 	if (adapter->ref > 0)
 		return;
@@ -2543,7 +2543,7 @@ void adapter_remove(struct btd_adapter *adapter)
 {
 	GSList *l;
 
-	debug("Removing adapter %s", adapter->path);
+	DBG("Removing adapter %s", adapter->path);
 
 	for (l = adapter->devices; l; l = l->next)
 		device_remove(l->data, FALSE);
@@ -2921,7 +2921,7 @@ void adapter_remove_connection(struct btd_adapter *adapter,
 	if (device_is_temporary(device)) {
 		const char *path = device_get_path(device);
 
-		debug("Removing temporary device %s", path);
+		DBG("Removing temporary device %s", path);
 		adapter_remove_device(connection, adapter, device, TRUE);
 	}
 }
diff --git a/src/agent.c b/src/agent.c
index 49e015c..5ce0ec9 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -89,7 +89,7 @@ static void agent_release(struct agent *agent)
 {
 	DBusMessage *message;
 
-	debug("Releasing agent %s, %s", agent->name, agent->path);
+	DBG("Releasing agent %s, %s", agent->name, agent->path);
 
 	if (agent->request)
 		agent_cancel(agent);
@@ -137,7 +137,7 @@ static void agent_exited(DBusConnection *conn, void *user_data)
 {
 	struct agent *agent = user_data;
 
-	debug("Agent exited without calling Unregister");
+	DBG("Agent exited without calling Unregister");
 
 	agent->exited = TRUE;
 
@@ -349,7 +349,7 @@ int agent_authorize(struct agent *agent,
 
 	agent->request = req;
 
-	debug("authorize request was sent for %s", path);
+	DBG("authorize request was sent for %s", path);
 
 	return 0;
 }
@@ -512,7 +512,7 @@ int agent_confirm_mode_change(struct agent *agent, const char *new_mode,
 	if (agent->request)
 		return -EBUSY;
 
-	debug("Calling Agent.ConfirmModeChange: name=%s, path=%s, mode=%s",
+	DBG("Calling Agent.ConfirmModeChange: name=%s, path=%s, mode=%s",
 			agent->name, agent->path, new_mode);
 
 	req = agent_request_new(agent, AGENT_REQUEST_CONFIRM_MODE,
@@ -617,7 +617,7 @@ int agent_request_passkey(struct agent *agent, struct btd_device *device,
 	if (agent->request)
 		return -EBUSY;
 
-	debug("Calling Agent.RequestPasskey: name=%s, path=%s",
+	DBG("Calling Agent.RequestPasskey: name=%s, path=%s",
 			agent->name, agent->path);
 
 	req = agent_request_new(agent, AGENT_REQUEST_PASSKEY, cb,
@@ -676,7 +676,7 @@ int agent_request_confirmation(struct agent *agent, struct btd_device *device,
 	if (agent->request)
 		return -EBUSY;
 
-	debug("Calling Agent.RequestConfirmation: name=%s, path=%s, passkey=%06u",
+	DBG("Calling Agent.RequestConfirmation: name=%s, path=%s, passkey=%06u",
 			agent->name, agent->path, passkey);
 
 	req = agent_request_new(agent, AGENT_REQUEST_CONFIRMATION, cb,
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 176e27b..58da70a 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -299,7 +299,7 @@ static int get_auth_requirements(bdaddr_t *local, bdaddr_t *remote,
 
 	err = ioctl(dd, HCIGETAUTHINFO, (unsigned long) &req);
 	if (err < 0) {
-		debug("HCIGETAUTHINFO failed: %s (%d)",
+		DBG("HCIGETAUTHINFO failed: %s (%d)",
 					strerror(errno), errno);
 		hci_close_dev(dd);
 		return err;
@@ -342,13 +342,13 @@ int hcid_dbus_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey)
 		return 0;
 	}
 
-	debug("confirm authentication requirement is 0x%02x", type);
+	DBG("confirm authentication requirement is 0x%02x", type);
 
 	remcap = device_get_cap(device);
 	remauth = device_get_auth(device);
 
-	debug("remote IO capabilities are 0x%02x", remcap);
-	debug("remote authentication requirement is 0x%02x", remauth);
+	DBG("remote IO capabilities are 0x%02x", remcap);
+	DBG("remote authentication requirement is 0x%02x", remauth);
 
 	/* If no side requires MITM protection; auto-accept */
 	if (!(remauth & 0x01) &&
@@ -369,7 +369,7 @@ int hcid_dbus_user_confirm(bdaddr_t *sba, bdaddr_t *dba, uint32_t passkey)
 
 		hci_close_dev(dd);
 
-		debug("auto accept of confirmation");
+		DBG("auto accept of confirmation");
 
 		return device_request_authentication(device,
 						AUTH_TYPE_AUTO, 0, NULL);
@@ -409,7 +409,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer,
 	struct btd_adapter *adapter;
 	struct btd_device *device;
 
-	debug("hcid_dbus_bonding_process_complete: status=%02x", status);
+	DBG("hcid_dbus_bonding_process_complete: status=%02x", status);
 
 	if (!get_adapter_and_device(local, peer, &adapter, &device, TRUE))
 		return;
@@ -418,7 +418,7 @@ void hcid_dbus_bonding_process_complete(bdaddr_t *local, bdaddr_t *peer,
 		/* This means that there was no pending PIN or SSP token
 		 * request from the controller, i.e. this is not a new
 		 * pairing */
-		debug("hcid_dbus_bonding_process_complete: no pending auth request");
+		DBG("hcid_dbus_bonding_process_complete: no pending auth request");
 		return;
 	}
 
@@ -433,7 +433,7 @@ void hcid_dbus_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer,
 	struct btd_adapter *adapter;
 	struct btd_device *device;
 
-	debug("hcid_dbus_simple_pairing_complete: status=%02x", status);
+	DBG("hcid_dbus_simple_pairing_complete: status=%02x", status);
 
 	if (!get_adapter_and_device(local, peer, &adapter, &device, TRUE))
 		return;
@@ -674,7 +674,7 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
 	remote_auth = device_get_auth(device);
 	bonding = device_is_bonding(device, NULL);
 
-	debug("local auth 0x%02x and remote auth 0x%02x",
+	DBG("local auth 0x%02x and remote auth 0x%02x",
 					local_auth, remote_auth);
 
 	/* Only store the link key if one of the following is true:
@@ -692,7 +692,7 @@ int hcid_dbus_link_key_notify(bdaddr_t *local, bdaddr_t *peer,
 				(remote_auth == 0x02 || remote_auth == 0x03)) {
 		int err;
 
-		debug("storing link key of type 0x%02x", key_type);
+		DBG("storing link key of type 0x%02x", key_type);
 
 		err = write_link_key(local, peer, key, new_key_type,
 								pin_length);
@@ -766,7 +766,7 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
 
 	device = adapter_find_connection(adapter, handle);
 	if (!device) {
-		debug("No matching connection found for handle %u", handle);
+		DBG("No matching connection found for handle %u", handle);
 		return;
 	}
 
@@ -886,7 +886,7 @@ int hcid_dbus_get_io_cap(bdaddr_t *local, bdaddr_t *remote,
 	if (get_auth_requirements(local, remote, auth) < 0)
 		return -1;
 
-	debug("initial authentication requirement is 0x%02x", *auth);
+	DBG("initial authentication requirement is 0x%02x", *auth);
 
 	if (*auth == 0xff)
 		*auth = device_get_auth(device);
@@ -896,7 +896,7 @@ int hcid_dbus_get_io_cap(bdaddr_t *local, bdaddr_t *remote,
 	if (!adapter_is_pairable(adapter) &&
 				!device_is_bonding(device, NULL)) {
 		if (*auth < 0x02 && device_get_auth(device) < 0x02) {
-			debug("Allowing no bonding in non-bondable mode");
+			DBG("Allowing no bonding in non-bondable mode");
 			/* No input, no output */
 			*cap = 0x03;
 			goto done;
@@ -912,13 +912,13 @@ int hcid_dbus_get_io_cap(bdaddr_t *local, bdaddr_t *remote,
 	if (!agent) {
 		/* This is the non bondable mode case */
 		if (device_get_auth(device) > 0x01) {
-			debug("Bonding request, but no agent present");
+			DBG("Bonding request, but no agent present");
 			return -1;
 		}
 
 		/* No agent available, and no bonding case */
 		if (*auth == 0x00) {
-			debug("Allowing no bonding without agent");
+			DBG("Allowing no bonding without agent");
 			/* No input, no output */
 			*cap = 0x03;
 			goto done;
@@ -952,7 +952,7 @@ int hcid_dbus_get_io_cap(bdaddr_t *local, bdaddr_t *remote,
 	*cap = agent_get_io_capability(agent);
 
 done:
-	debug("final authentication requirement is 0x%02x", *auth);
+	DBG("final authentication requirement is 0x%02x", *auth);
 
 	return 0;
 }
diff --git a/src/device.c b/src/device.c
index 6ba1612..4a27545 100644
--- a/src/device.c
+++ b/src/device.c
@@ -246,7 +246,7 @@ static void device_free(gpointer user_data)
 	if (device->discov_timer)
 		g_source_remove(device->discov_timer);
 
-	debug("device_free(%p)", device);
+	DBG("device_free(%p)", device);
 
 	g_free(device->authr);
 	g_free(device->path);
@@ -476,7 +476,7 @@ static void discover_services_req_exit(DBusConnection *conn, void *user_data)
 {
 	struct browse_req *req = user_data;
 
-	debug("DiscoverServices requestor exited");
+	DBG("DiscoverServices requestor exited");
 
 	browse_request_cancel(req);
 }
@@ -880,7 +880,7 @@ struct btd_device *device_create(DBusConnection *conn,
 	g_strdelimit(device->path, ":", '_');
 	g_free(address_up);
 
-	debug("Creating device %s", device->path);
+	DBG("Creating device %s", device->path);
 
 	if (g_dbus_register_interface(conn, device->path, DEVICE_INTERFACE,
 				device_methods, device_signals, NULL,
@@ -981,7 +981,7 @@ void device_remove(struct btd_device *device, gboolean remove_stored)
 	GSList *list;
 	struct btd_device_driver *driver;
 
-	debug("Removing device %s", device->path);
+	DBG("Removing device %s", device->path);
 
 	if (device->bonding)
 		device_cancel_bonding(device, HCI_OE_USER_ENDED_CONNECTION);
@@ -1096,7 +1096,7 @@ void device_probe_drivers(struct btd_device *device, GSList *profiles)
 	GSList *list;
 	int err;
 
-	debug("Probe drivers for %s", device->path);
+	DBG("Probe drivers for %s", device->path);
 
 	for (list = device_drivers; list; list = list->next) {
 		struct btd_device_driver *driver = list->data;
@@ -1157,7 +1157,7 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)
 
 	records = read_records(&src, &device->bdaddr);
 
-	debug("Remove drivers for %s", device->path);
+	DBG("Remove drivers for %s", device->path);
 
 	for (list = device->drivers; list; list = next) {
 		struct btd_driver_data *driver_data = list->data;
@@ -1171,7 +1171,7 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)
 						(GCompareFunc) strcasecmp))
 				continue;
 
-			debug("UUID %s was removed from device %s",
+			DBG("UUID %s was removed from device %s",
 							*uuid, dstaddr);
 
 			driver->remove(device);
@@ -1254,7 +1254,7 @@ static void update_services(struct browse_req *req, sdp_list_t *recs)
 
 		/* Check for empty service classes list */
 		if (svcclass == NULL) {
-			debug("Skipping record with no service classes");
+			DBG("Skipping record with no service classes");
 			continue;
 		}
 
@@ -1369,7 +1369,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
 	}
 
 	if (!req->profiles_added && !req->profiles_removed) {
-		debug("%s: No service update", device->path);
+		DBG("%s: No service update", device->path);
 		goto send_reply;
 	}
 
@@ -1736,7 +1736,7 @@ static struct bonding_req *bonding_request_new(DBusConnection *conn,
 	const char *name = dbus_message_get_sender(msg);
 	struct agent *agent;
 
-	debug("%s: requesting bonding", device->path);
+	DBG("%s: requesting bonding", device->path);
 
 	if (!agent_path)
 		goto proceed;
@@ -1752,7 +1752,7 @@ static struct bonding_req *bonding_request_new(DBusConnection *conn,
 
 	device->agent = agent;
 
-	debug("Temporary agent registered for %s at %s:%s",
+	DBG("Temporary agent registered for %s at %s:%s",
 			device->path, name, agent_path);
 
 proceed:
@@ -1875,7 +1875,7 @@ static void create_bond_req_exit(DBusConnection *conn, void *user_data)
 {
 	struct btd_device *device = user_data;
 
-	debug("%s: requestor exited before bonding was completed", device->path);
+	DBG("%s: requestor exited before bonding was completed", device->path);
 
 	if (device->authr)
 		device_cancel_authentication(device, FALSE);
@@ -2007,7 +2007,7 @@ void device_bonding_complete(struct btd_device *device, uint8_t status)
 			/* If we are not initiators and there is no currently
 			 * active discovery or discovery timer, set discovery
 			 * timer */
-			debug("setting timer for reverse service discovery");
+			DBG("setting timer for reverse service discovery");
 			device->discov_timer = g_timeout_add_seconds(
 							DISCOVERY_TIMER,
 							start_discovery,
@@ -2067,7 +2067,7 @@ void device_cancel_bonding(struct btd_device *device, uint8_t status)
 	if (!bonding)
 		return;
 
-	debug("%s: canceling bonding request", device->path);
+	DBG("%s: canceling bonding request", device->path);
 
 	if (device->authr)
 		device_cancel_authentication(device, FALSE);
@@ -2133,7 +2133,7 @@ int device_request_authentication(struct btd_device *device, auth_type_t type,
 	struct agent *agent;
 	int ret;
 
-	debug("%s: requesting agent authentication", device->path);
+	DBG("%s: requesting agent authentication", device->path);
 
 	agent = device->agent;
 
@@ -2226,7 +2226,7 @@ void device_cancel_authentication(struct btd_device *device, gboolean aborted)
 	if (!auth)
 		return;
 
-	debug("%s: canceling authentication request", device->path);
+	DBG("%s: canceling authentication request", device->path);
 
 	if (auth->agent)
 		agent_cancel(auth->agent);
@@ -2312,7 +2312,7 @@ struct btd_device *btd_device_ref(struct btd_device *device)
 {
 	device->ref++;
 
-	debug("btd_device_ref(%p): ref=%d", device, device->ref);
+	DBG("btd_device_ref(%p): ref=%d", device, device->ref);
 
 	return device;
 }
@@ -2324,7 +2324,7 @@ void btd_device_unref(struct btd_device *device)
 
 	device->ref--;
 
-	debug("btd_device_unref(%p): ref=%d", device, device->ref);
+	DBG("btd_device_unref(%p): ref=%d", device, device->ref);
 
 	if (device->ref > 0)
 		return;
diff --git a/src/main.c b/src/main.c
index ac14165..7a573bc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -93,15 +93,15 @@ static void parse_config(GKeyFile *config)
 	if (!config)
 		return;
 
-	debug("parsing main.conf");
+	DBG("parsing main.conf");
 
 	val = g_key_file_get_integer(config, "General",
 						"DiscoverableTimeout", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else {
-		debug("discovto=%d", val);
+		DBG("discovto=%d", val);
 		main_opts.discovto = val;
 		main_opts.flags |= 1 << HCID_SET_DISCOVTO;
 	}
@@ -109,29 +109,29 @@ static void parse_config(GKeyFile *config)
 	val = g_key_file_get_integer(config, "General",
 						"PairableTimeout", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else {
-		debug("pairto=%d", val);
+		DBG("pairto=%d", val);
 		main_opts.pairto = val;
 	}
 
 	val = g_key_file_get_integer(config, "General", "PageTimeout", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else {
-		debug("pageto=%d", val);
+		DBG("pageto=%d", val);
 		main_opts.pageto = val;
 		main_opts.flags |= 1 << HCID_SET_PAGETO;
 	}
 
 	str = g_key_file_get_string(config, "General", "Name", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else {
-		debug("name=%s", str);
+		DBG("name=%s", str);
 		g_free(main_opts.name);
 		main_opts.name = g_strdup(str);
 		main_opts.flags |= 1 << HCID_SET_NAME;
@@ -140,10 +140,10 @@ static void parse_config(GKeyFile *config)
 
 	str = g_key_file_get_string(config, "General", "Class", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else {
-		debug("class=%s", str);
+		DBG("class=%s", str);
 		main_opts.class = strtol(str, NULL, 16);
 		main_opts.flags |= 1 << HCID_SET_CLASS;
 		g_free(str);
@@ -152,17 +152,17 @@ static void parse_config(GKeyFile *config)
 	val = g_key_file_get_integer(config, "General",
 					"DiscoverSchedulerInterval", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else {
-		debug("discov_interval=%d", val);
+		DBG("discov_interval=%d", val);
 		main_opts.discov_interval = val;
 	}
 
 	boolean = g_key_file_get_boolean(config, "General",
 						"InitiallyPowered", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else if (boolean == FALSE)
 		main_opts.mode = MODE_OFF;
@@ -170,17 +170,17 @@ static void parse_config(GKeyFile *config)
 	boolean = g_key_file_get_boolean(config, "General",
 						"RememberPowered", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else
 		main_opts.remember_powered = boolean;
 
 	str = g_key_file_get_string(config, "General", "DeviceID", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else {
-		debug("deviceid=%s", str);
+		DBG("deviceid=%s", str);
 		strncpy(main_opts.deviceid, str,
 					sizeof(main_opts.deviceid) - 1);
 		g_free(str);
@@ -189,7 +189,7 @@ static void parse_config(GKeyFile *config)
 	boolean = g_key_file_get_boolean(config, "General",
 						"ReverseServiceDiscovery", &err);
 	if (err) {
-		debug("%s", err->message);
+		DBG("%s", err->message);
 		g_clear_error(&err);
 	} else
 		main_opts.reverse_sdp = boolean;
diff --git a/src/plugin.c b/src/plugin.c
index 0de854a..5bc2bb2 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -67,7 +67,7 @@ static gboolean add_plugin(void *handle, struct bluetooth_plugin_desc *desc)
 		return FALSE;
 	}
 
-	debug("Loading %s plugin", desc->name);
+	DBG("Loading %s plugin", desc->name);
 
 	plugin = g_try_new0(struct bluetooth_plugin, 1);
 	if (plugin == NULL)
@@ -130,7 +130,7 @@ gboolean plugin_init(GKeyFile *config)
 	else
 		disabled = NULL;
 
-	debug("Loading builtin plugins");
+	DBG("Loading builtin plugins");
 
 	for (i = 0; __bluetooth_builtin[i]; i++) {
 		if (is_disabled(__bluetooth_builtin[i]->name, disabled))
@@ -144,7 +144,7 @@ gboolean plugin_init(GKeyFile *config)
 		goto start;
 	}
 
-	debug("Loading plugins %s", PLUGINDIR);
+	DBG("Loading plugins %s", PLUGINDIR);
 
 	dir = g_dir_open(PLUGINDIR, 0, NULL);
 	if (!dir) {
@@ -210,7 +210,7 @@ void plugin_cleanup(void)
 {
 	GSList *list;
 
-	debug("Cleanup plugins");
+	DBG("Cleanup plugins");
 
 	for (list = plugins; list; list = list->next) {
 		struct bluetooth_plugin *plugin = list->data;
diff --git a/src/rfkill.c b/src/rfkill.c
index a707f2f..2d0629b 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -90,7 +90,7 @@ static gboolean rfkill_event(GIOChannel *chan,
 	if (len != sizeof(struct rfkill_event))
 		return TRUE;
 
-	debug("RFKILL event idx %u type %u op %u soft %u hard %u",
+	DBG("RFKILL event idx %u type %u op %u soft %u hard %u",
 					event->idx, event->type, event->op,
 						event->soft, event->hard);
 
@@ -131,7 +131,7 @@ static gboolean rfkill_event(GIOChannel *chan,
 	if (!adapter)
 		return TRUE;
 
-	debug("RFKILL unblock for hci%d", id);
+	DBG("RFKILL unblock for hci%d", id);
 
 	btd_adapter_restore_powered(adapter);
 
diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index d8f8dce..a1caa2c 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -415,7 +415,7 @@ int add_record_to_server(const bdaddr_t *src, sdp_record_t *rec)
 			return -1;
 	}
 
-	debug("Adding record with handle 0x%05x", rec->handle);
+	DBG("Adding record with handle 0x%05x", rec->handle);
 
 	sdp_record_add(src, rec);
 
@@ -435,7 +435,7 @@ int add_record_to_server(const bdaddr_t *src, sdp_record_t *rec)
 			continue;
 
 		sdp_uuid2strn((uuid_t *) pattern->data, uuid, sizeof(uuid));
-		debug("Record pattern UUID %s", uuid);
+		DBG("Record pattern UUID %s", uuid);
 	}
 
 	update_db_timestamp();
@@ -448,7 +448,7 @@ int remove_record_from_server(uint32_t handle)
 {
 	sdp_record_t *rec;
 
-	debug("Removing record with handle 0x%05x", handle);
+	DBG("Removing record with handle 0x%05x", handle);
 
 	rec = sdp_record_find(handle);
 	if (!rec)
diff --git a/src/security.c b/src/security.c
index 652eea6..f2756c5 100644
--- a/src/security.c
+++ b/src/security.c
@@ -314,12 +314,12 @@ static void link_key_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
 	err = ioctl(dev, HCIGETAUTHINFO, (unsigned long) &req);
 	if (err < 0) {
 		if (errno != EINVAL)
-			debug("HCIGETAUTHINFO failed %s (%d)",
+			DBG("HCIGETAUTHINFO failed %s (%d)",
 						strerror(errno), errno);
 		req.type = 0x00;
 	}
 
-	debug("kernel auth requirements = 0x%02x", req.type);
+	DBG("kernel auth requirements = 0x%02x", req.type);
 
 	err = read_link_key(sba, dba, key, &type);
 	if (err < 0) {
@@ -331,7 +331,7 @@ static void link_key_request(int dev, bdaddr_t *sba, bdaddr_t *dba)
 		memcpy(lr.link_key, key, 16);
 		bacpy(&lr.bdaddr, dba);
 
-		debug("stored link key type = 0x%02x", type);
+		DBG("stored link key type = 0x%02x", type);
 
 		/* Don't use debug link keys (0x03) and also don't use
 		 * unauthenticated combination keys if MITM is required */
-- 
1.7.1

^ permalink raw reply related

* [PATCH 4/4] Move logging.{c,h} to log.{c,h}
From: Gustavo F. Padovan @ 2010-05-18  2:27 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: gustavo, marcel
In-Reply-To: <1274149638-31580-3-git-send-email-gustavo@padovan.org>

Try to make log stuff more similar to ConnMan and oFono.
---
 Makefile.am              |    2 +-
 audio/a2dp.c             |    2 +-
 audio/avdtp.c            |    2 +-
 audio/control.c          |    2 +-
 audio/device.c           |    2 +-
 audio/gateway.c          |    2 +-
 audio/headset.c          |    2 +-
 audio/main.c             |    2 +-
 audio/manager.c          |    2 +-
 audio/sink.c             |    2 +-
 audio/source.c           |    2 +-
 audio/telephony-dummy.c  |    2 +-
 audio/telephony-maemo5.c |    2 +-
 audio/telephony-maemo6.c |    2 +-
 audio/telephony-ofono.c  |    2 +-
 audio/unix.c             |    2 +-
 input/device.c           |    2 +-
 input/fakehid.c          |    2 +-
 input/main.c             |    2 +-
 input/manager.c          |    2 +-
 input/server.c           |    2 +-
 network/bridge.c         |    2 +-
 network/common.c         |    2 +-
 network/connection.c     |    2 +-
 network/manager.c        |    2 +-
 network/server.c         |    2 +-
 plugins/echo.c           |    2 +-
 plugins/hal.c            |    2 +-
 plugins/hciops.c         |    2 +-
 plugins/netlink.c        |    2 +-
 plugins/pnat.c           |    2 +-
 plugins/service.c        |    2 +-
 plugins/storage.c        |    2 +-
 serial/manager.c         |    2 +-
 serial/port.c            |    2 +-
 serial/proxy.c           |    2 +-
 src/adapter.c            |    2 +-
 src/agent.c              |    2 +-
 src/dbus-common.c        |    2 +-
 src/dbus-hci.c           |    2 +-
 src/device.c             |    2 +-
 src/log.c                |  133 ++++++++++++++++++++++++++++++++++++++++++++++
 src/log.h                |   60 +++++++++++++++++++++
 src/logging.c            |  133 ----------------------------------------------
 src/logging.h            |   60 ---------------------
 src/main.c               |    2 +-
 src/manager.c            |    2 +-
 src/plugin.c             |    2 +-
 src/rfkill.c             |    2 +-
 src/sdpd-database.c      |    2 +-
 src/sdpd-request.c       |    2 +-
 src/sdpd-server.c        |    2 +-
 src/sdpd-service.c       |    2 +-
 src/security.c           |    2 +-
 54 files changed, 243 insertions(+), 243 deletions(-)
 create mode 100644 src/log.c
 create mode 100644 src/log.h
 delete mode 100644 src/logging.c
 delete mode 100644 src/logging.h

diff --git a/Makefile.am b/Makefile.am
index f991121..75cee3d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -180,7 +180,7 @@ builtin_sources += plugins/storage.c
 sbin_PROGRAMS += src/bluetoothd
 
 src_bluetoothd_SOURCES = $(gdbus_sources) $(builtin_sources) \
-			src/main.c src/logging.h src/logging.c \
+			src/main.c src/log.h src/log.c \
 			src/security.c src/rfkill.c src/hcid.h src/sdpd.h \
 			src/sdpd-server.c src/sdpd-request.c \
 			src/sdpd-service.c src/sdpd-database.c \
diff --git a/audio/a2dp.c b/audio/a2dp.c
index fd12fbe..6221c14 100644
--- a/audio/a2dp.c
+++ b/audio/a2dp.c
@@ -36,7 +36,7 @@
 #include <bluetooth/sdp.h>
 #include <bluetooth/sdp_lib.h>
 
-#include "logging.h"
+#include "log.h"
 #include "device.h"
 #include "manager.h"
 #include "avdtp.h"
diff --git a/audio/avdtp.c b/audio/avdtp.c
index 19a15a4..540bdf3 100644
--- a/audio/avdtp.c
+++ b/audio/avdtp.c
@@ -42,7 +42,7 @@
 #include <glib.h>
 #include <dbus/dbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "../src/manager.h"
 #include "../src/adapter.h"
diff --git a/audio/control.c b/audio/control.c
index da2bb5f..c8aba53 100644
--- a/audio/control.c
+++ b/audio/control.c
@@ -46,7 +46,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "error.h"
 #include "uinput.h"
 #include "adapter.h"
diff --git a/audio/device.c b/audio/device.c
index fceb7a1..b59be6a 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -43,7 +43,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 #include "../src/adapter.h"
 #include "../src/device.h"
diff --git a/audio/gateway.c b/audio/gateway.c
index 62b3f60..dfe7145 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -48,7 +48,7 @@
 #include "glib-helper.h"
 #include "device.h"
 #include "gateway.h"
-#include "logging.h"
+#include "log.h"
 #include "error.h"
 #include "btio.h"
 #include "dbus-common.h"
diff --git a/audio/headset.c b/audio/headset.c
index 7bcaa96..9a5d767 100644
--- a/audio/headset.c
+++ b/audio/headset.c
@@ -51,7 +51,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "device.h"
 #include "manager.h"
 #include "error.h"
diff --git a/audio/main.c b/audio/main.c
index 34b45a8..9d316ec 100644
--- a/audio/main.c
+++ b/audio/main.c
@@ -40,7 +40,7 @@
 #include "glib-helper.h"
 #include "btio.h"
 #include "plugin.h"
-#include "logging.h"
+#include "log.h"
 #include "device.h"
 #include "unix.h"
 #include "headset.h"
diff --git a/audio/manager.c b/audio/manager.c
index ec795e6..32b7d03 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -55,7 +55,7 @@
 #include "../src/adapter.h"
 #include "../src/device.h"
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 #include "ipc.h"
 #include "device.h"
diff --git a/audio/sink.c b/audio/sink.c
index 0ca0519..f4dce28 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -36,7 +36,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "device.h"
 #include "avdtp.h"
diff --git a/audio/source.c b/audio/source.c
index ea4610f..35d8136 100644
--- a/audio/source.c
+++ b/audio/source.c
@@ -37,7 +37,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "device.h"
 #include "avdtp.h"
diff --git a/audio/telephony-dummy.c b/audio/telephony-dummy.c
index f20aa79..06cb798 100644
--- a/audio/telephony-dummy.c
+++ b/audio/telephony-dummy.c
@@ -33,7 +33,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "telephony.h"
 
 #define TELEPHONY_DUMMY_IFACE "org.bluez.TelephonyTest"
diff --git a/audio/telephony-maemo5.c b/audio/telephony-maemo5.c
index 910fa32..4d0134c 100644
--- a/audio/telephony-maemo5.c
+++ b/audio/telephony-maemo5.c
@@ -36,7 +36,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "telephony.h"
 
 /* SSC D-Bus definitions */
diff --git a/audio/telephony-maemo6.c b/audio/telephony-maemo6.c
index a48b7e2..1decf41 100644
--- a/audio/telephony-maemo6.c
+++ b/audio/telephony-maemo6.c
@@ -36,7 +36,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "telephony.h"
 
 /* SSC D-Bus definitions */
diff --git a/audio/telephony-ofono.c b/audio/telephony-ofono.c
index 4511ab6..e710ce8 100644
--- a/audio/telephony-ofono.c
+++ b/audio/telephony-ofono.c
@@ -35,7 +35,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "telephony.h"
 
 enum net_registration_status {
diff --git a/audio/unix.c b/audio/unix.c
index 3fdf5c8..42c0d80 100644
--- a/audio/unix.c
+++ b/audio/unix.c
@@ -39,7 +39,7 @@
 #include <dbus/dbus.h>
 #include <glib.h>
 
-#include "logging.h"
+#include "log.h"
 #include "ipc.h"
 #include "device.h"
 #include "manager.h"
diff --git a/input/device.c b/input/device.c
index 511ac95..8daf8b2 100644
--- a/input/device.c
+++ b/input/device.c
@@ -46,7 +46,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 #include "uinput.h"
 
diff --git a/input/fakehid.c b/input/fakehid.c
index 69a9abb..ee1f77a 100644
--- a/input/fakehid.c
+++ b/input/fakehid.c
@@ -43,7 +43,7 @@
 #include "../src/adapter.h"
 #include "../src/device.h"
 
-#include "logging.h"
+#include "log.h"
 #include "device.h"
 #include "fakehid.h"
 #include "uinput.h"
diff --git a/input/main.c b/input/main.c
index 7c058f2..e165ab4 100644
--- a/input/main.c
+++ b/input/main.c
@@ -32,7 +32,7 @@
 #include <gdbus.h>
 
 #include "plugin.h"
-#include "logging.h"
+#include "log.h"
 #include "manager.h"
 
 static GKeyFile *load_config_file(const char *file)
diff --git a/input/manager.c b/input/manager.c
index 30cdd3e..a98a080 100644
--- a/input/manager.c
+++ b/input/manager.c
@@ -34,7 +34,7 @@
 
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "../src/adapter.h"
 #include "../src/device.h"
 
diff --git a/input/server.c b/input/server.c
index 1197379..d98018b 100644
--- a/input/server.c
+++ b/input/server.c
@@ -34,7 +34,7 @@
 #include <glib.h>
 #include <dbus/dbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "glib-helper.h"
 #include "btio.h"
diff --git a/network/bridge.c b/network/bridge.c
index f3528ad..9166975 100644
--- a/network/bridge.c
+++ b/network/bridge.c
@@ -38,7 +38,7 @@
 #include <bluetooth/l2cap.h>
 #include <bluetooth/bnep.h>
 
-#include "logging.h"
+#include "log.h"
 #include "bridge.h"
 #include "common.h"
 
diff --git a/network/common.c b/network/common.c
index 6340883..f5e0ee8 100644
--- a/network/common.c
+++ b/network/common.c
@@ -41,7 +41,7 @@
 
 #include <glib.h>
 
-#include "logging.h"
+#include "log.h"
 #include "common.h"
 
 static int ctl;
diff --git a/network/connection.c b/network/connection.c
index 17c3396..01178d7 100644
--- a/network/connection.c
+++ b/network/connection.c
@@ -38,7 +38,7 @@
 #include <glib.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "glib-helper.h"
 #include "btio.h"
 #include "dbus-common.h"
diff --git a/network/manager.c b/network/manager.c
index ee19c03..80a5ded 100644
--- a/network/manager.c
+++ b/network/manager.c
@@ -33,7 +33,7 @@
 #include <glib.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "adapter.h"
 #include "device.h"
diff --git a/network/server.c b/network/server.c
index 475f12c..a82d4ff 100644
--- a/network/server.c
+++ b/network/server.c
@@ -44,7 +44,7 @@
 #include "../src/dbus-common.h"
 #include "../src/adapter.h"
 
-#include "logging.h"
+#include "log.h"
 #include "error.h"
 #include "sdpd.h"
 #include "btio.h"
diff --git a/plugins/echo.c b/plugins/echo.c
index d884d41..23f6e49 100644
--- a/plugins/echo.c
+++ b/plugins/echo.c
@@ -38,7 +38,7 @@
 
 #include "plugin.h"
 #include "adapter.h"
-#include "logging.h"
+#include "log.h"
 
 static gboolean session_event(GIOChannel *chan,
 					GIOCondition cond, gpointer data)
diff --git a/plugins/hal.c b/plugins/hal.c
index 73355d5..f6121c5 100644
--- a/plugins/hal.c
+++ b/plugins/hal.c
@@ -34,7 +34,7 @@
 
 #include "plugin.h"
 #include "adapter.h"
-#include "logging.h"
+#include "log.h"
 #include "dbus-hci.h"
 
 static void formfactor_reply(DBusPendingCall *call, void *user_data)
diff --git a/plugins/hciops.c b/plugins/hciops.c
index 9190c80..da2e3d0 100644
--- a/plugins/hciops.c
+++ b/plugins/hciops.c
@@ -42,7 +42,7 @@
 #include "sdpd.h"
 #include "adapter.h"
 #include "plugin.h"
-#include "logging.h"
+#include "log.h"
 #include "manager.h"
 
 static int child_pipe[2] = { -1, -1 };
diff --git a/plugins/netlink.c b/plugins/netlink.c
index 5b4915b..081ffa2 100644
--- a/plugins/netlink.c
+++ b/plugins/netlink.c
@@ -37,7 +37,7 @@
 #include <glib.h>
 
 #include "plugin.h"
-#include "logging.h"
+#include "log.h"
 
 static struct nl_handle *handle;
 static struct nl_cache *cache;
diff --git a/plugins/pnat.c b/plugins/pnat.c
index 4a06582..987008f 100644
--- a/plugins/pnat.c
+++ b/plugins/pnat.c
@@ -48,7 +48,7 @@
 #include "sdpd.h"
 #include "btio.h"
 #include "adapter.h"
-#include "logging.h"
+#include "log.h"
 
 /* FIXME: This location should be build-time configurable */
 #define PNATD "/usr/sbin/phonet-at"
diff --git a/plugins/service.c b/plugins/service.c
index 182b829..96280bd 100644
--- a/plugins/service.c
+++ b/plugins/service.c
@@ -43,7 +43,7 @@
 #include "plugin.h"
 #include "adapter.h"
 #include "error.h"
-#include "logging.h"
+#include "log.h"
 
 #define SERVICE_INTERFACE "org.bluez.Service"
 
diff --git a/plugins/storage.c b/plugins/storage.c
index 6c1cd45..04a02c7 100644
--- a/plugins/storage.c
+++ b/plugins/storage.c
@@ -28,7 +28,7 @@
 #include <bluetooth/bluetooth.h>
 
 #include "plugin.h"
-#include "logging.h"
+#include "log.h"
 
 static int storage_init(void)
 {
diff --git a/serial/manager.c b/serial/manager.c
index d4ebf2e..a7deab1 100644
--- a/serial/manager.c
+++ b/serial/manager.c
@@ -55,7 +55,7 @@
 #include "adapter.h"
 #include "device.h"
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 
 #include "error.h"
diff --git a/serial/port.c b/serial/port.c
index 7382cf3..48a60b4 100644
--- a/serial/port.c
+++ b/serial/port.c
@@ -47,7 +47,7 @@
 
 #include "../src/dbus-common.h"
 
-#include "logging.h"
+#include "log.h"
 #include "glib-helper.h"
 #include "btio.h"
 
diff --git a/serial/proxy.c b/serial/proxy.c
index 442ce5d..80c1189 100644
--- a/serial/proxy.c
+++ b/serial/proxy.c
@@ -54,7 +54,7 @@
 #include "../src/dbus-common.h"
 #include "../src/adapter.h"
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 
 #include "error.h"
diff --git a/src/adapter.c b/src/adapter.c
index d4887aa..e885879 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -43,7 +43,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 
 #include "hcid.h"
diff --git a/src/agent.c b/src/agent.c
index 5ce0ec9..c7fdbd4 100644
--- a/src/agent.c
+++ b/src/agent.c
@@ -41,7 +41,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "hcid.h"
 #include "adapter.h"
diff --git a/src/dbus-common.c b/src/dbus-common.c
index c6eedf9..1245b4f 100644
--- a/src/dbus-common.c
+++ b/src/dbus-common.c
@@ -42,7 +42,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "manager.h"
 #include "adapter.h"
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 58da70a..caa91ec 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -45,7 +45,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 
 #include "hcid.h"
diff --git a/src/device.c b/src/device.c
index 4a27545..66b0310 100644
--- a/src/device.c
+++ b/src/device.c
@@ -44,7 +44,7 @@
 #include <dbus/dbus.h>
 #include <gdbus.h>
 
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 
 #include "hcid.h"
diff --git a/src/log.c b/src/log.c
new file mode 100644
index 0000000..29e2d7d
--- /dev/null
+++ b/src/log.c
@@ -0,0 +1,133 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stdarg.h>
+#include <syslog.h>
+
+#include <glib.h>
+
+#include "log.h"
+
+static inline void vinfo(const char *format, va_list ap)
+{
+	vsyslog(LOG_INFO, format, ap);
+}
+
+void info(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+
+	vinfo(format, ap);
+
+	va_end(ap);
+}
+
+void error(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+
+	vsyslog(LOG_ERR, format, ap);
+
+	va_end(ap);
+}
+
+void debug(const char *format, ...)
+{
+	va_list ap;
+
+	va_start(ap, format);
+
+	vsyslog(LOG_DEBUG, format, ap);
+
+	va_end(ap);
+}
+
+extern struct btd_debug_desc __start___debug[];
+extern struct btd_debug_desc __stop___debug[];
+
+static gchar **enabled = NULL;
+
+static gboolean is_enabled(struct btd_debug_desc *desc)
+{
+        int i;
+
+        if (enabled == NULL)
+                return 0;
+
+        for (i = 0; enabled[i] != NULL; i++) {
+                if (desc->name != NULL && g_pattern_match_simple(enabled[i],
+                                                        desc->name) == TRUE)
+                        return 1;
+                if (desc->file != NULL && g_pattern_match_simple(enabled[i],
+                                                        desc->file) == TRUE)
+                        return 1;
+        }
+
+        return 0;
+}
+
+void __btd_log_init(const char *debug, int detach)
+{
+	int option = LOG_NDELAY | LOG_PID;
+	struct btd_debug_desc *desc;
+	const char *name = NULL, *file = NULL;
+
+	if (debug != NULL)
+		enabled = g_strsplit_set(debug, ":, ", 0);
+
+	for (desc = __start___debug; desc < __stop___debug; desc++) {
+		if (file != NULL || name != NULL) {
+			if (g_strcmp0(desc->file, file) == 0) {
+				if (desc->name == NULL)
+					desc->name = name;
+			} else
+				file = NULL;
+		}
+
+		if (is_enabled(desc))
+			desc->flags |= BTD_DEBUG_FLAG_PRINT;
+	}
+
+	if (!detach)
+		option |= LOG_PERROR;
+
+	openlog("bluetoothd", option, LOG_DAEMON);
+
+	syslog(LOG_INFO, "Bluetooth deamon %s", VERSION);
+}
+
+void __btd_log_cleanup(void)
+{
+	closelog();
+
+	g_strfreev(enabled);
+}
diff --git a/src/log.h b/src/log.h
new file mode 100644
index 0000000..9af51e7
--- /dev/null
+++ b/src/log.h
@@ -0,0 +1,60 @@
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
+ *
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ *
+ */
+
+#ifndef __LOGGING_H
+#define __LOGGING_H
+
+void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
+void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
+void debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
+
+void __btd_log_init(const char *debug, int detach);
+void __btd_log_cleanup(void);
+
+struct btd_debug_desc {
+        const char *name;
+        const char *file;
+#define BTD_DEBUG_FLAG_DEFAULT (0)
+#define BTD_DEBUG_FLAG_PRINT   (1 << 0)
+        unsigned int flags;
+} __attribute__((aligned(8)));
+
+/**
+ * DBG:
+ * @fmt: format string
+ * @arg...: list of arguments
+ *
+ * Simple macro around debug() which also include the function
+ * name it is called in.
+ */
+#define DBG(fmt, arg...) do { \
+        static struct btd_debug_desc __btd_debug_desc \
+        __attribute__((used, section("__debug"), aligned(8))) = { \
+                .file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
+        }; \
+        if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
+                debug("%s:%s() " fmt, \
+                                        __FILE__, __FUNCTION__ , ## arg); \
+} while (0)
+
+#endif /* __LOGGING_H */
diff --git a/src/logging.c b/src/logging.c
deleted file mode 100644
index 39a5142..0000000
--- a/src/logging.c
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
- *
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdarg.h>
-#include <syslog.h>
-
-#include <glib.h>
-
-#include "logging.h"
-
-static inline void vinfo(const char *format, va_list ap)
-{
-	vsyslog(LOG_INFO, format, ap);
-}
-
-void info(const char *format, ...)
-{
-	va_list ap;
-
-	va_start(ap, format);
-
-	vinfo(format, ap);
-
-	va_end(ap);
-}
-
-void error(const char *format, ...)
-{
-	va_list ap;
-
-	va_start(ap, format);
-
-	vsyslog(LOG_ERR, format, ap);
-
-	va_end(ap);
-}
-
-void debug(const char *format, ...)
-{
-	va_list ap;
-
-	va_start(ap, format);
-
-	vsyslog(LOG_DEBUG, format, ap);
-
-	va_end(ap);
-}
-
-extern struct btd_debug_desc __start___debug[];
-extern struct btd_debug_desc __stop___debug[];
-
-static gchar **enabled = NULL;
-
-static gboolean is_enabled(struct btd_debug_desc *desc)
-{
-        int i;
-
-        if (enabled == NULL)
-                return 0;
-
-        for (i = 0; enabled[i] != NULL; i++) {
-                if (desc->name != NULL && g_pattern_match_simple(enabled[i],
-                                                        desc->name) == TRUE)
-                        return 1;
-                if (desc->file != NULL && g_pattern_match_simple(enabled[i],
-                                                        desc->file) == TRUE)
-                        return 1;
-        }
-
-        return 0;
-}
-
-void __btd_log_init(const char *debug, int detach)
-{
-	int option = LOG_NDELAY | LOG_PID;
-	struct btd_debug_desc *desc;
-	const char *name = NULL, *file = NULL;
-
-	if (debug != NULL)
-		enabled = g_strsplit_set(debug, ":, ", 0);
-
-	for (desc = __start___debug; desc < __stop___debug; desc++) {
-		if (file != NULL || name != NULL) {
-			if (g_strcmp0(desc->file, file) == 0) {
-				if (desc->name == NULL)
-					desc->name = name;
-			} else
-				file = NULL;
-		}
-
-		if (is_enabled(desc))
-			desc->flags |= BTD_DEBUG_FLAG_PRINT;
-	}
-
-	if (!detach)
-		option |= LOG_PERROR;
-
-	openlog("bluetoothd", option, LOG_DAEMON);
-
-	syslog(LOG_INFO, "Bluetooth deamon %s", VERSION);
-}
-
-void __btd_log_cleanup(void)
-{
-	closelog();
-
-	g_strfreev(enabled);
-}
diff --git a/src/logging.h b/src/logging.h
deleted file mode 100644
index 9af51e7..0000000
--- a/src/logging.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- *  BlueZ - Bluetooth protocol stack for Linux
- *
- *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
- *
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- *
- */
-
-#ifndef __LOGGING_H
-#define __LOGGING_H
-
-void info(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void error(const char *format, ...) __attribute__((format(printf, 1, 2)));
-void debug(const char *format, ...) __attribute__((format(printf, 1, 2)));
-
-void __btd_log_init(const char *debug, int detach);
-void __btd_log_cleanup(void);
-
-struct btd_debug_desc {
-        const char *name;
-        const char *file;
-#define BTD_DEBUG_FLAG_DEFAULT (0)
-#define BTD_DEBUG_FLAG_PRINT   (1 << 0)
-        unsigned int flags;
-} __attribute__((aligned(8)));
-
-/**
- * DBG:
- * @fmt: format string
- * @arg...: list of arguments
- *
- * Simple macro around debug() which also include the function
- * name it is called in.
- */
-#define DBG(fmt, arg...) do { \
-        static struct btd_debug_desc __btd_debug_desc \
-        __attribute__((used, section("__debug"), aligned(8))) = { \
-                .file = __FILE__, .flags = BTD_DEBUG_FLAG_DEFAULT, \
-        }; \
-        if (__btd_debug_desc.flags & BTD_DEBUG_FLAG_PRINT) \
-                debug("%s:%s() " fmt, \
-                                        __FILE__, __FUNCTION__ , ## arg); \
-} while (0)
-
-#endif /* __LOGGING_H */
diff --git a/src/main.c b/src/main.c
index 7a573bc..3118a34 100644
--- a/src/main.c
+++ b/src/main.c
@@ -46,7 +46,7 @@
 
 #include <dbus/dbus.h>
 
-#include "logging.h"
+#include "log.h"
 
 #include "hcid.h"
 #include "sdpd.h"
diff --git a/src/manager.c b/src/manager.c
index 0c75ff7..ea1180a 100644
--- a/src/manager.c
+++ b/src/manager.c
@@ -45,7 +45,7 @@
 
 #include "hcid.h"
 #include "dbus-common.h"
-#include "logging.h"
+#include "log.h"
 #include "adapter.h"
 #include "error.h"
 #include "manager.h"
diff --git a/src/plugin.c b/src/plugin.c
index 5bc2bb2..a63ce8e 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -35,7 +35,7 @@
 #include <glib.h>
 
 #include "plugin.h"
-#include "logging.h"
+#include "log.h"
 #include "hcid.h"
 #include "btio.h"
 
diff --git a/src/rfkill.c b/src/rfkill.c
index 2d0629b..7810846 100644
--- a/src/rfkill.c
+++ b/src/rfkill.c
@@ -35,7 +35,7 @@
 
 #include <glib.h>
 
-#include "logging.h"
+#include "log.h"
 #include "manager.h"
 #include "adapter.h"
 #include "hcid.h"
diff --git a/src/sdpd-database.c b/src/sdpd-database.c
index 263b16e..4c8acb7 100644
--- a/src/sdpd-database.c
+++ b/src/sdpd-database.c
@@ -39,7 +39,7 @@
 #include <bluetooth/sdp_lib.h>
 
 #include "sdpd.h"
-#include "logging.h"
+#include "log.h"
 #include "adapter.h"
 
 static sdp_list_t *service_db;
diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index a8af8e4..8c88d6e 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -43,7 +43,7 @@
 #include <netinet/in.h>
 
 #include "sdpd.h"
-#include "logging.h"
+#include "log.h"
 
 #define MIN(x, y) ((x) < (y)) ? (x): (y)
 
diff --git a/src/sdpd-server.c b/src/sdpd-server.c
index 207bd47..efd6fd0 100644
--- a/src/sdpd-server.c
+++ b/src/sdpd-server.c
@@ -45,7 +45,7 @@
 
 #include <glib.h>
 
-#include "logging.h"
+#include "log.h"
 #include "sdpd.h"
 
 static GIOChannel *l2cap_io = NULL, *unix_io = NULL;
diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index a1caa2c..cdbb4f4 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -45,7 +45,7 @@
 #include <dbus/dbus.h>
 
 #include "sdpd.h"
-#include "logging.h"
+#include "log.h"
 #include "manager.h"
 #include "adapter.h"
 
diff --git a/src/security.c b/src/security.c
index f2756c5..1d0da45 100644
--- a/src/security.c
+++ b/src/security.c
@@ -47,7 +47,7 @@
 #include <dbus/dbus.h>
 
 #include "hcid.h"
-#include "logging.h"
+#include "log.h"
 #include "textfile.h"
 
 #include "adapter.h"
-- 
1.7.1

^ permalink raw reply related

* Re: HDP proposed API(0.5)
From: Nathan Holstein @ 2010-05-18  2:42 UTC (permalink / raw)
  To: Gustavo F. Padovan
  Cc: Elvis Pfützenreuter, João Paulo Rechi Vita,
	linux-bluetooth, jcaden
In-Reply-To: <20100517232056.GC19907@vigoh>

On Mon, 2010-05-17 at 20:20 -0300, Gustavo F. Padovan wrote:
> Hi Elvis,
> 
> * Elvis Pfützenreuter <epx@signove.com> [2010-05-17 19:02:33 -0300]:
> 
> > 
> > On 17/05/2010, at 18:38, Gustavo F. Padovan wrote:
> > 
> > > Hi,
> > > 
> > > * João Paulo Rechi Vita <jprvita@gmail.com> [2010-05-17 18:17:58 -0300]:
> > > 
> > > <snip>
> > > 
> > >> On Mon, May 17, 2010 at 11:54, José Antonio Santos Cadenas
> > >> <jcaden@libresoft.es> wrote:
> > >>> 
> > >>>                array GetDataChannelFileDescriptor(uint16 mdlid)
> > >>> 
> > >> 
> > >> Wouldn't be better to pass the fd through the LinkConnected call on
> > >> Agent? Doing it here allows any process to get the fds.
> > > 
> > > I was thinking about the MCAP in kernel implementation, my conclusion is
> > > that we can solve one of the biggest problem of HDP API if we do it in
> > > kernel: the transparency of MCAP reconnection. HDP will open an MCAP
> > > socket and pass it to the user(IEEE app). Then if we need a
> > > reconnection, MCAP will transparently reconnect changing the L2CAP
> > > channel to transmit the data without the need to change the socket
> > > opened with the userspace.
> > > 
> > > Keep the MCAP socket open means that we are keeping the MCL state for
> > > further reconnection.
> > > 
> > > Doing it inside the kernel removes a big amount of complexity of HDP and
> > > IEEE profiles, since we won't need any pipe or change of fd. That could
> > > be a killer feature to make it in the kernel.
> > > 
> > > Any comments? Is this reasonable?
> > 
> > 
> > The fd passed to the application could actually be an UNIX socket,
> so these semantics could be implemented with MCAP in user space. I
> guess the pipes only appeared in discussion because of the possibility
> of zero-copy communication.
> 
> MCAP in kernel gives zero-copy communication and just one socket to the
> HDP API. The better of both UNIX socket and pipes options.
>  
> > That semantics would be implemented in MCAP part. The HDP profile
> code itself is (or should be) free from these worries.
> > 
> > Moving MCAP to kernel hides the complexity from userspace HDP
> profile, but it continues to exist. Then I worry about more complex
> debugging, dependency on kernel version (or need to put efforts on
> backporting). MCAP sits above L2CAP, not besides it.
> 
> The complexity will exist anyway, I'm proposing a less complex option.
> Is not that complex change the L2CAP channels used by the MCL inside the
> kernel. Between all the proposed options to handle reconnection it
> looks the less complex one.

One advantage of MCAP within the kernel is the ability to reject an
invalid incoming L2CAP before a call to accept().  (An example of this
is a duplicated control channel or a data channel with incorrect
ERTM/Streaming configuration.)

> We should not care about backporting now. We are working directly
> with upstream and upstream is what really matters here. :)
> 
> You will depend on kernel version anyway since ERTM is inside the
> kernel. About backport if you backport ERTM, then backport MCAP will be
> easy.
> 
> Also MCAP will keep sitting on top of L2CAP, that won't change.
> 
> > 
> > I acknowledge that it would work, but honestly I prefer to see
> things being moved to the outside of the kernel than to the inside :)
> 
> The real question here is where MCAP will fit better. And where it adds
> less complexity to its users.

The solution I've used for MCAP utilizes the epoll family of calls to
provide a single fd which multiplexes all listening, control, and data
sockets.  The primary advantage of this approach is simple integration
into the application's main loop.  In my experience, such a model is
much easier to integrate into i.e. a JNI interface.  However, it appears
much of this complexity is hidden by the proposed HDP API

As for the proposed API itself, it looks to provide the necessary
functionality to implement a 20601 device.  One little quibble I'll add
is the choice of name "HealthAgent".  As someone who comes from the
20601 side of things, this could cause some confusion with the 20601
term "agent".  Since I believe this is a standard Bluez term, I'd just
request that this gotcha is well documented.

Has any thought been given regarding support for MCAP clock
synchronization?  IEEE-20601 is mostly agnostic to the transport, but
this is one point where transport-specific information is exposed within
the 20601 protocol (via the MDS object's Mds-Time-Info attribute).  I'm
not aware of any devices which currently support clock synch (my code
included), so I'd argue this isn't a blocking feature for the first
release.



    --nathan


^ permalink raw reply

* Re: [PATCH] Kernel crash when krfcomm is preempted by l2cap tasklet
From: Andrei Emeltchenko @ 2010-05-18  7:15 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: Bluettooth Linux, marcel
In-Reply-To: <20100517190607.GA19907@vigoh>

Hi Gustavo,

On Mon, May 17, 2010 at 10:06 PM, Gustavo F. Padovan
<gustavo@padovan.org> wrote:
>> >> We have a bug with race condition between l2cap tasklet and krfcomm p=
rocess.
>> >>
>> >> When sending following sequence:
>> >>
>> >> ...
>> >> No. =A0 =A0 Time =A0 =A0 =A0 =A0Source =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0Destination =A0 =A0 =A0 =A0 =A0 Protocol Info
>> >> =A0 =A0 =A089 1.951202 =A0 =A0 =A0 =A0 =A0 =A0RFCOMM =A0 Rcvd DISC DL=
CI=3D20
>> >> =A0 =A0 =A090 1.951324 =A0 =A0 =A0 =A0 =A0 =A0RFCOMM =A0 Sent UA DLCI=
=3D20
>> >> =A0 =A0 =A091 1.959381 =A0 =A0 =A0 =A0 =A0 =A0HCI_EVT =A0 Number of C=
ompleted Packets
>> >> =A0 =A0 =A092 1.966461 =A0 =A0 =A0 =A0 =A0 =A0RFCOMM =A0 Rcvd DISC DL=
CI=3D0
>> >> =A0 =A0 =A093 1.966492 =A0 =A0 =A0 =A0 =A0 =A0L2CAP =A0 =A0Rcvd Disco=
nnect Request
>> >> =A0 =A0 =A094 1.972595 =A0 =A0 =A0 =A0 =A0 =A0L2CAP =A0 =A0Sent Disco=
nnect Response
>> >>
>> >> ...
>> >>
>> >> krfcommd kernel thread is preempted with l2cap tasklet which remove l=
2cap_conn
>> >> (L2CAP connection handler structure). Then rfcomm thread tries to sen=
d RFCOMM
>> >> UA which is reply to RFCOMM DISC and when de-referencing l2cap_conn c=
rash
>> >> happens.
>> >>
>> >> ...
>> >> [ =A0694.175933] Unable to handle kernel NULL pointer dereference at
>> >> virtual address 00000000
>> >> [ =A0694.184936] pgd =3D c0004000
>> >> [ =A0694.187683] [00000000] *pgd=3D00000000
>> >> [ =A0694.191711] Internal error: Oops: 5 [#1] PREEMPT
>> >> [ =A0694.196350] last sysfs file:
>> >> /sys/devices/platform/hci_h4p/firmware/hci_h4p/loading
>> >> [ =A0694.260375] CPU: 0 =A0 =A0Not tainted =A0(2.6.32.10 #1)
>> >> [ =A0694.265106] PC is at l2cap_sock_sendmsg+0x43c/0x73c [l2cap]
>> >> [ =A0694.270721] LR is at 0xd7017303
>> >> ...
>> >> [ =A0694.525085] Backtrace:
>> >> [ =A0694.527587] [<bf266be0>] (l2cap_sock_sendmsg+0x0/0x73c [l2cap])
>> >> from [<c02f2cc8>] (sock_sendmsg+0xb8
>> >> [ =A0694.537292] [<c02f2c10>] (sock_sendmsg+0x0/0xd8) from [<c02f3044=
>]
>> >> (kernel_sendmsg+0x48/0x80)
>> >> ...
>> >>
>> >> I have a patch which fixes the issue but not sure that there is no
>> >> better way. Waiting for comments.
>> >>
>> >> Currently I am investigating possibility to:
>> >> - implement l2cap_conn reference counting
>> >
>> > sock_owned_by_user() gives the same effect as a ref count. See comment=
s below.
>> >
>>
>> Yes. For this cases this is enough. But proper refcounting is always
>> better than this "effects" ;)
>>
>> >> - use socket backlog queue to process l2cap packets later when socket=
 is not
>> >> owned by the process.
>> >
>> > You actually don't need a backlog queue here. You can process the sign=
al
>> > packet, skipping the l2cap_chan_del() call;
>> >
>> ...
>> >> + =A0 =A0 /* sk is locked in krfcomm process */
>> >> + =A0 =A0 if (sock_owned_by_user(sk)) {
>> >> + =A0 =A0 =A0 =A0 =A0 =A0 BT_DBG("sk %p is owned by user", sk);
>> >> + =A0 =A0 =A0 =A0 =A0 =A0 bh_unlock_sock(sk);
>> >> + =A0 =A0 =A0 =A0 =A0 =A0 return 0;
>> >> + =A0 =A0 }
>> >
>> > That's wrong. Use the sock_owned_by_user() only to avoid the
>> > l2cap_chan_del() call, so you can process all the rest of the function
>> > and send the Disconnect Response.
>>
>> I have changed the patch so that it only prevents l2cap_chan_del
>> - =A0 =A0 =A0 =A0 =A0 =A0 l2cap_chan_del(sk, ECONNREFUSED);
>> + =A0 =A0 =A0 =A0 =A0 =A0 /* delete l2cap channel if sk is not owned by =
user */
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (!sock_owned_by_user(sk))
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 l2cap_chan_del(sk, ECONNREFUSE=
D);
>>
>> Then still l2cap_sock_kill(sk) removes sk but in the second patch sk is
>> hold with sock_hold(sk) until rfcomm is still processing packet.
>
> Hmm, I missed the l2cap_sock_kill(). So I guess you can invert the if
> condition and unlock the socket and return if sock is owned by user,
> right?

I am still thinking that my proposal is better.

l2cap_sock_kill(sk) does not delete socket but unlink it from the list
and defer deleting
to the time we get to sock_put(sk) in the other place sk is used.
Socket shall be deleted and this defer deletion is a good solution
IMO.

But I can also create patch with your proposed change.

> Marcel, do you agree with that change?

So what would be the right solution?

Regards,
Andrei

>
>>
>> > The same check should be added to l2cap_connect_rsp() and
>> > l2cap_disconnect_rsp(), since they call l2cap_chan_del() under bh
>> > context as well. ;)
>>
>> Added.
>>
>> Regards,
>> Andrei Emeltchenko
>
>> From 8531c8add8a378fc24b92f2c2311b01a7b1f63fc Mon Sep 17 00:00:00 2001
>> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>> Date: Mon, 17 May 2010 12:10:46 +0300
>> Subject: [PATCH 1/2] Bluetooth: Check sk is not owned before freeing l2c=
ap_conn
>>
>> Check that socket sk is not locked in user process before removing
>> l2cap connection handler.
>>
>> krfcommd kernel thread may be preempted with l2cap tasklet which remove
>> l2cap_conn structure. If krfcommd is in process of sending of RFCOMM rep=
ly
>> (like "RFCOMM UA" reply to "RFCOMM DISC") then kernel crash happens.
>>
>> ...
>> [ =A0694.175933] Unable to handle kernel NULL pointer dereference at vir=
tual address 00000000
>> [ =A0694.184936] pgd =3D c0004000
>> [ =A0694.187683] [00000000] *pgd=3D00000000
>> [ =A0694.191711] Internal error: Oops: 5 [#1] PREEMPT
>> [ =A0694.196350] last sysfs file: /sys/devices/platform/hci_h4p/firmware=
/hci_h4p/loading
>> [ =A0694.260375] CPU: 0 =A0 =A0Not tainted =A0(2.6.32.10 #1)
>> [ =A0694.265106] PC is at l2cap_sock_sendmsg+0x43c/0x73c [l2cap]
>> [ =A0694.270721] LR is at 0xd7017303
>> ...
>> [ =A0694.525085] Backtrace:
>> [ =A0694.527587] [<bf266be0>] (l2cap_sock_sendmsg+0x0/0x73c [l2cap]) fro=
m [<c02f2cc8>] (sock_sendmsg+0xb8/0xd8)
>> [ =A0694.537292] [<c02f2c10>] (sock_sendmsg+0x0/0xd8) from [<c02f3044>] =
(kernel_sendmsg+0x48/0x80)
>> ...
>>
>> Modified version after comments of Gustavo F. Padovan <gustavo@padovan.o=
rg>
>>
>> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>> ---
>> =A0net/bluetooth/l2cap.c | =A0 14 +++++++++++---
>> =A01 files changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
>> index bb00015..794f2b7 100644
>> --- a/net/bluetooth/l2cap.c
>> +++ b/net/bluetooth/l2cap.c
>> @@ -2927,7 +2927,9 @@ static inline int l2cap_connect_rsp(struct l2cap_c=
onn *conn, struct l2cap_cmd_hd
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
>>
>> =A0 =A0 =A0 default:
>> - =A0 =A0 =A0 =A0 =A0 =A0 l2cap_chan_del(sk, ECONNREFUSED);
>> + =A0 =A0 =A0 =A0 =A0 =A0 /* delete l2cap channel if sk is not owned by =
user */
>> + =A0 =A0 =A0 =A0 =A0 =A0 if (!sock_owned_by_user(sk))
>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 l2cap_chan_del(sk, ECONNREFUSE=
D);
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 break;
>> =A0 =A0 =A0 }
>>
>> @@ -3135,7 +3137,10 @@ static inline int l2cap_disconnect_req(struct l2c=
ap_conn *conn, struct l2cap_cmd
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 del_timer(&l2cap_pi(sk)->ack_timer);
>> =A0 =A0 =A0 }
>>
>> - =A0 =A0 l2cap_chan_del(sk, ECONNRESET);
>> + =A0 =A0 /* delete l2cap channel if sk is not owned by user */
>> + =A0 =A0 if (!sock_owned_by_user(sk))
>> + =A0 =A0 =A0 =A0 =A0 =A0 l2cap_chan_del(sk, ECONNRESET);
>> +
>> =A0 =A0 =A0 bh_unlock_sock(sk);
>>
>> =A0 =A0 =A0 l2cap_sock_kill(sk);
>> @@ -3167,7 +3172,10 @@ static inline int l2cap_disconnect_rsp(struct l2c=
ap_conn *conn, struct l2cap_cmd
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 del_timer(&l2cap_pi(sk)->ack_timer);
>> =A0 =A0 =A0 }
>>
>> - =A0 =A0 l2cap_chan_del(sk, 0);
>> + =A0 =A0 /* delete l2cap channel if sk is not owned by user */
>> + =A0 =A0 if (!sock_owned_by_user(sk))
>> + =A0 =A0 =A0 =A0 =A0 =A0 l2cap_chan_del(sk, 0);
>> +
>> =A0 =A0 =A0 bh_unlock_sock(sk);
>>
>> =A0 =A0 =A0 l2cap_sock_kill(sk);
>> --
>> 1.7.0.4
>>
>
>> From 99ffb4e41ff46022cbc52f3c947425791de7fa39 Mon Sep 17 00:00:00 2001
>> From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>> Date: Mon, 17 May 2010 12:28:06 +0300
>> Subject: [PATCH 2/2] Bluetooth: Prevent sk freeing in tasklet using refc=
ount
>>
>> Socket sk may be freed in tasklet while still be in use in krfcommd
>> process. Use refcount to mark sk as used.
>>
>> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
>> ---
>> =A0net/bluetooth/l2cap.c | =A0 =A02 ++
>> =A01 files changed, 2 insertions(+), 0 deletions(-)
>>
>> diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
>> index 794f2b7..bf762d6 100644
>> --- a/net/bluetooth/l2cap.c
>> +++ b/net/bluetooth/l2cap.c
>> @@ -1724,6 +1724,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, =
struct socket *sock, struct ms
>> =A0 =A0 =A0 if (msg->msg_flags & MSG_OOB)
>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 return -EOPNOTSUPP;
>>
>> + =A0 =A0 sock_hold(sk);
>> =A0 =A0 =A0 lock_sock(sk);
>>
>> =A0 =A0 =A0 if (sk->sk_state !=3D BT_CONNECTED) {
>> @@ -1808,6 +1809,7 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, =
struct socket *sock, struct ms
>>
>> =A0done:
>> =A0 =A0 =A0 release_sock(sk);
>> + =A0 =A0 sock_put(sk);
>> =A0 =A0 =A0 return err;
>> =A0}
>>
>> --
>> 1.7.0.4
>>
>
>
> --
> Gustavo F. Padovan
> http://padovan.org
>

^ permalink raw reply

* Re: HDP proposed API(0.5)
From: José Antonio Santos Cadenas @ 2010-05-18  7:33 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: João Paulo Rechi Vita, linux-bluetooth
In-Reply-To: <20100517213838.GB19907@vigoh>

Hi Gustavo,

El Monday 17 May 2010 23:38:38 Gustavo F. Padovan escribió:
> Hi,
> 
> * João Paulo Rechi Vita <jprvita@gmail.com> [2010-05-17 18:17:58 -0300]:
> 
> <snip>
> 
> > On Mon, May 17, 2010 at 11:54, José Antonio Santos Cadenas
> > 
> > <jcaden@libresoft.es> wrote:
> > >                array GetDataChannelFileDescriptor(uint16 mdlid)
> > 
> > Wouldn't be better to pass the fd through the LinkConnected call on
> > Agent? Doing it here allows any process to get the fds.
> 
> I was thinking about the MCAP in kernel implementation, my conclusion is
> that we can solve one of the biggest problem of HDP API if we do it in
> kernel: the transparency of MCAP reconnection. HDP will open an MCAP
> socket and pass it to the user(IEEE app). Then if we need a
> reconnection, MCAP will transparently reconnect changing the L2CAP
> channel to transmit the data without the need to change the socket
> opened with the userspace.

This that you proposed is something that we thought when we started with 
MCAP/HDP. We finally decided to put MCAP outside the kernel because of the 
following reasons:
	-  The first and the most important is that everything that can be done in 
user space should be done in user space. We talked about this issue in the 
list some time ago and Marcel suggested us that if MCAP doesn't have 
interaction with other kernel subsystems, it should be implemented outside the 
kernel. You can read these mails here [1]. Basing on our experience with MCAP 
that's true, MCAP does not interact with any kernel subsystem.
	- An other reason is that reconnections *should not* be transparent at 
MCAP level. Any profile using MCAP should be concerned about the data channel 
disconnection and reconnection. In the case of HDP reconnections should be 
hide to the application layer.
	- Finally the kernel implementation will require a very complex API 
because MCAP require notifying lots of events some of the requiring a 
response(i.e., incoming mdl connection that need a response from the next 
level using MCAP with the configuration). Probably MCAP in the kernel space 
will be so complicated to used an you will require a user space library that 
make simpler the use of this API.

> 
> Keep the MCAP socket open means that we are keeping the MCL state for
> further reconnection.
> 
> Doing it inside the kernel removes a big amount of complexity of HDP and
> IEEE profiles, since we won't need any pipe or change of fd. That could
> be a killer feature to make it in the kernel.
> 
> Any comments? Is this reasonable?

In our opinion reconnections are not a reason to implement MCAP in kernel 
space because reconections should not be transparent at this level.

> 
> <snip>


[1] http://www.spinics.net/lists/linux-bluetooth/msg03001.html

^ permalink raw reply

* Re: HDP proposed API(0.5)
From: José Antonio Santos Cadenas @ 2010-05-18  8:10 UTC (permalink / raw)
  To: ngh
  Cc: Gustavo F. Padovan, Elvis Pfützenreuter,
	João Paulo Rechi Vita, linux-bluetooth
In-Reply-To: <1274150562.3559.78.camel@strawberry>

El Tuesday 18 May 2010 04:42:42 Nathan Holstein escribió:
> On Mon, 2010-05-17 at 20:20 -0300, Gustavo F. Padovan wrote:
> > Hi Elvis,
> > 
> > * Elvis Pfützenreuter <epx@signove.com> [2010-05-17 19:02:33 -0300]:
> > > On 17/05/2010, at 18:38, Gustavo F. Padovan wrote:
> > > > Hi,
> > > > 
> > > > * João Paulo Rechi Vita <jprvita@gmail.com> [2010-05-17 18:17:58
> > > > -0300]:
> > > > 
> > > > <snip>
> > > > 
> > > >> On Mon, May 17, 2010 at 11:54, José Antonio Santos Cadenas
> > > >> 
> > > >> <jcaden@libresoft.es> wrote:
> > > >>>                array GetDataChannelFileDescriptor(uint16 mdlid)
> > > >> 
> > > >> Wouldn't be better to pass the fd through the LinkConnected call on
> > > >> Agent? Doing it here allows any process to get the fds.
> > > > 
> > > > I was thinking about the MCAP in kernel implementation, my conclusion
> > > > is that we can solve one of the biggest problem of HDP API if we do
> > > > it in kernel: the transparency of MCAP reconnection. HDP will open
> > > > an MCAP socket and pass it to the user(IEEE app). Then if we need a
> > > > reconnection, MCAP will transparently reconnect changing the L2CAP
> > > > channel to transmit the data without the need to change the socket
> > > > opened with the userspace.
> > > > 
> > > > Keep the MCAP socket open means that we are keeping the MCL state for
> > > > further reconnection.
> > > > 
> > > > Doing it inside the kernel removes a big amount of complexity of HDP
> > > > and IEEE profiles, since we won't need any pipe or change of fd.
> > > > That could be a killer feature to make it in the kernel.
> > > > 
> > > > Any comments? Is this reasonable?
> > > 
> > > The fd passed to the application could actually be an UNIX socket,
> > 
> > so these semantics could be implemented with MCAP in user space. I
> > guess the pipes only appeared in discussion because of the possibility
> > of zero-copy communication.
> > 
> > MCAP in kernel gives zero-copy communication and just one socket to the
> > HDP API. The better of both UNIX socket and pipes options.
> > 
> > > That semantics would be implemented in MCAP part. The HDP profile
> > 
> > code itself is (or should be) free from these worries.
> > 
> > > Moving MCAP to kernel hides the complexity from userspace HDP
> > 
> > profile, but it continues to exist. Then I worry about more complex
> > debugging, dependency on kernel version (or need to put efforts on
> > backporting). MCAP sits above L2CAP, not besides it.
> > 
> > The complexity will exist anyway, I'm proposing a less complex option.
> > Is not that complex change the L2CAP channels used by the MCL inside the
> > kernel. Between all the proposed options to handle reconnection it
> > looks the less complex one.
> 
> One advantage of MCAP within the kernel is the ability to reject an
> invalid incoming L2CAP before a call to accept().  (An example of this
> is a duplicated control channel or a data channel with incorrect
> ERTM/Streaming configuration.)

That's not completely true, you can do this from user space too. In fact, the 
MCAP implementation that we send to this mailing list do this. You can have a 
look to the code and test that if you try to establish two mcap connections 
with the same instance, MCAP will refuse the second one before the accept, 
just as you mentioned.

He tested the current implementation even with real devices (Oximeter and 
blood pressure) and this behaviour is being done correctly.

> 
> > We should not care about backporting now. We are working directly
> > with upstream and upstream is what really matters here. :)
> > 
> > You will depend on kernel version anyway since ERTM is inside the
> > kernel. About backport if you backport ERTM, then backport MCAP will be
> > easy.
> > 
> > Also MCAP will keep sitting on top of L2CAP, that won't change.
> > 
> > > I acknowledge that it would work, but honestly I prefer to see
> > 
> > things being moved to the outside of the kernel than to the inside :)
> > 
> > The real question here is where MCAP will fit better. And where it adds
> > less complexity to its users.
> 
> The solution I've used for MCAP utilizes the epoll family of calls to
> provide a single fd which multiplexes all listening, control, and data
> sockets.  The primary advantage of this approach is simple integration
> into the application's main loop.  In my experience, such a model is
> much easier to integrate into i.e. a JNI interface.  However, it appears
> much of this complexity is hidden by the proposed HDP API

Your are right, HDP is doing this work for the upper layer and the integration 
should be as easy as you mentioned. Also you have to take in count that MCAP 
can be used by other profiles in the future, so you *should not* do HDP specific 
work at MCAP layer.

About the epoll implementation, we did a preliminary version or MCAP using 
"select" that I think that is similar to epoll. The experience says us that 
this is not the best approach. A repository containing this code is here [1].

> 
> As for the proposed API itself, it looks to provide the necessary
> functionality to implement a 20601 device.  One little quibble I'll add
> is the choice of name "HealthAgent".  As someone who comes from the
> 20601 side of things, this could cause some confusion with the 20601
> term "agent".  Since I believe this is a standard Bluez term, I'd just
> request that this gotcha is well documented.

We know that, in fact we started working in HDP/MCAP because we had previously 
developed a manger. In our firs approach we refused that nomenclature because 
we think that is confused, but BlueZ uses it and as this is being included in 
BlueZ we should use its nomenclature. We will try to document it in order to 
clarify this issue.

> 
> Has any thought been given regarding support for MCAP clock
> synchronization?  IEEE-20601 is mostly agnostic to the transport, but
> this is one point where transport-specific information is exposed within
> the 20601 protocol (via the MDS object's Mds-Time-Info attribute).  I'm
> not aware of any devices which currently support clock synch (my code
> included), so I'd argue this isn't a blocking feature for the first
> release.

Yes, we (Santiago and me) and Elvis (and his team) are planning to continue 
this work over MCAP in the next weeks.

Elvis, can you give more details about this?

> 
> 
> 
>     --nathan
>

[1] http://openhealth.morfeo-project.org/


^ permalink raw reply

* Re: HDP proposed API(0.5)
From: Santiago Carot-Nemesio @ 2010-05-18  9:28 UTC (permalink / raw)
  To: Gustavo F. Padovan
  Cc: Elvis Pfützenreuter, João Paulo Rechi Vita, jcaden,
	linux-bluetooth
In-Reply-To: <20100517232056.GC19907@vigoh>

Hello Gustavo,

> 
> MCAP in kernel gives zero-copy communication and just one socket to the
> HDP API. The better of both UNIX socket and pipes options.
>  

That's right I agree with you, but the main question here is not based
in hiding MCAP reconnection, because future profiles using MCAP may be
concern about above reconnection. Please, remember that nothing about
hiding reconnections are mentioned in MCAP specification. However,
reconnection are exposed as deseable capability in MCAP that upper
profiles can use.

In other hands, in particular case of HDP, we want to hide reconnection
process to application layer because ISO/IEEE11073-20601 is transport
agnostic, that means for example, a manager or agent sending or
receiving APDUs don't be concern about such issues in transpiort layer
(neither MCAP nor HDP). As you can see, the problem isn't in MCAP but in
HDP<-->App to achieve reconnection transparency. That's is better
explained in ISO/IEEE11073-20601 and some references can be found in HDP
white paper.


> > That semantics would be implemented in MCAP part. The HDP profile code itself is (or should be) free from these worries.
> > 
> > Moving MCAP to kernel hides the complexity from userspace HDP profile, but it continues to exist. Then I worry about more complex debugging, dependency on kernel version (or need to put efforts on backporting). MCAP sits above L2CAP, not besides it.
> 
> The complexity will exist anyway, I'm proposing a less complex option.
> Is not that complex change the L2CAP channels used by the MCL inside the
> kernel. Between all the proposed options to handle reconnection it
> looks the less complex one.
> 
> We should not care about backporting now. We are working directly
> with upstream and upstream is what really matters here. :)
> 
> You will depend on kernel version anyway since ERTM is inside the
> kernel. About backport if you backport ERTM, then backport MCAP will be
> easy.
> 
> Also MCAP will keep sitting on top of L2CAP, that won't change.
> 
> > 
> > I acknowledge that it would work, but honestly I prefer to see things being moved to the outside of the kernel than to the inside :)
> 
> The real question here is where MCAP will fit better. And where it adds
> less complexity to its users.

>>From my point of view we should avoid implement MCAP in kernel space 
for the same reason exposed by Jose Antonio and Elvis in other emails.
IMHO hidding reconnections in MCAP is not an good reason to implement it
in kernel space because transparency is required in HDP nor in MCAP.

If you hide reconnection to upper profiles in MCAP, you are closing the
door to future specifications if they require doing aditional precessing
when a reconnection takes place in MCAP.

Thanks for your comments.

Regards,


^ permalink raw reply

* Re: [PATCH] Avoid multiple inclusions of adapter.h
From: José Antonio Santos Cadenas @ 2010-05-18  9:57 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20100517160658.GA3788@jh-x301>

Hi, 

El Monday 17 May 2010 18:06:58 Johan Hedberg escribió:
> Hi,
> 
> On Thu, May 13, 2010, Jose Antonio Santos Cadenas wrote:
> > ---
> > 
> >  src/adapter.h |    5 +++++
> >  1 files changed, 5 insertions(+), 0 deletions(-)
> > 
> > diff --git a/src/adapter.h b/src/adapter.h
> > index 9b4ce10..8812ed8 100644
> > --- a/src/adapter.h
> > +++ b/src/adapter.h
> > @@ -22,6 +22,9 @@
> > 
> >   *
> >   */
> > 
> > +#ifndef __ADAPTER_H__
> > +#define __ADAPTER_H__
> > +
> > 
> >  #include <bluetooth/bluetooth.h>
> >  #include <dbus/dbus.h>
> >  #include <glib.h>
> > 
> > @@ -183,3 +186,5 @@ struct btd_adapter_ops {
> > 
> >  int btd_register_adapter_ops(struct btd_adapter_ops *btd_adapter_ops);
> >  void btd_adapter_cleanup_ops(struct btd_adapter_ops *btd_adapter_ops);
> >  int adapter_ops_setup(void);
> > 
> > +
> > +#endif /* __ADAPTER_H__ */
> 
> Lack of these defines is actually intentional for headsers which aren't
> part of any public library. The intention is to keep the header
> dependencies simple and get errors as soon as there's a circular
> dependency between them.

Thank you for the response. I guess I have to review how I do the include :)

> 
> Johan
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth"
> in the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH v3] Bluetooth: Add blacklist support for incoming connections
From: johan.hedberg @ 2010-05-18 11:20 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Johan Hedberg

From: Johan Hedberg <johan.hedberg@nokia.com>

In some circumstances it could be desirable to reject incoming
connections on the baseband level. This patch adds this feature through
two new ioctl's: HCIBLOCKADDR and HCIUNBLOCKADDR. Both take a simple
Bluetooth address as a parameter. BDADDR_ANY can be used with
HCIUNBLOCKADDR to remove all devices from the blacklist.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
---
v3 fixes a memory leak when an HCI device gets unregistered. The
blacklist list is now free'd in hci_dev_do_close along with the other
lists of struct hci_dev.

 fs/compat_ioctl.c                |    2 +
 include/net/bluetooth/hci.h      |    3 +
 include/net/bluetooth/hci_core.h |    9 ++++
 net/bluetooth/hci_core.c         |    3 +
 net/bluetooth/hci_event.c        |    2 +-
 net/bluetooth/hci_sock.c         |   90 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 108 insertions(+), 1 deletions(-)

diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 641640d..1863896 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -1328,6 +1328,8 @@ COMPATIBLE_IOCTL(HCISETLINKPOL)
 COMPATIBLE_IOCTL(HCISETLINKMODE)
 COMPATIBLE_IOCTL(HCISETACLMTU)
 COMPATIBLE_IOCTL(HCISETSCOMTU)
+COMPATIBLE_IOCTL(HCIBLOCKADDR)
+COMPATIBLE_IOCTL(HCIUNBLOCKADDR)
 COMPATIBLE_IOCTL(HCIINQUIRY)
 COMPATIBLE_IOCTL(HCIUARTSETPROTO)
 COMPATIBLE_IOCTL(HCIUARTGETPROTO)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index fc0c502..ca2518e 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -100,6 +100,9 @@ enum {
 #define HCISETACLMTU	_IOW('H', 227, int)
 #define HCISETSCOMTU	_IOW('H', 228, int)
 
+#define HCIBLOCKADDR	_IOW('H', 230, int)
+#define HCIUNBLOCKADDR	_IOW('H', 231, int)
+
 #define HCIINQUIRY	_IOR('H', 240, int)
 
 /* HCI timeouts */
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ce3c99e..fba5b74 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -62,6 +62,11 @@ struct hci_conn_hash {
 	unsigned int     sco_num;
 };
 
+struct bdaddr_list {
+	struct list_head list;
+	bdaddr_t bdaddr;
+};
+
 struct hci_dev {
 	struct list_head list;
 	spinlock_t	lock;
@@ -125,6 +130,7 @@ struct hci_dev {
 
 	struct inquiry_cache	inq_cache;
 	struct hci_conn_hash	conn_hash;
+	struct bdaddr_list	blacklist;
 
 	struct hci_dev_stats	stat;
 
@@ -422,6 +428,9 @@ int hci_get_conn_info(struct hci_dev *hdev, void __user *arg);
 int hci_get_auth_info(struct hci_dev *hdev, void __user *arg);
 int hci_inquiry(void __user *arg);
 
+struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);
+int hci_blacklist_clear(struct hci_dev *hdev);
+
 void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
 
 int hci_recv_frame(struct sk_buff *skb);
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 4ad2319..053a9e9 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -561,6 +561,7 @@ static int hci_dev_do_close(struct hci_dev *hdev)
 	hci_dev_lock_bh(hdev);
 	inquiry_cache_flush(hdev);
 	hci_conn_hash_flush(hdev);
+	hci_blacklist_clear(hdev);
 	hci_dev_unlock_bh(hdev);
 
 	hci_notify(hdev, HCI_DEV_DOWN);
@@ -922,6 +923,8 @@ int hci_register_dev(struct hci_dev *hdev)
 
 	hci_conn_hash_init(hdev);
 
+	INIT_LIST_HEAD(&hdev->blacklist.list);
+
 	memset(&hdev->stat, 0, sizeof(struct hci_dev_stats));
 
 	atomic_set(&hdev->promisc, 0);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 6c57fc7..1efaf50 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -952,7 +952,7 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
 
 	mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
 
-	if (mask & HCI_LM_ACCEPT) {
+	if ((mask & HCI_LM_ACCEPT) && !hci_blacklist_lookup(hdev, &ev->bdaddr)) {
 		/* Connection accepted */
 		struct inquiry_entry *ie;
 		struct hci_conn *conn;
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 38f08f6..4f170a5 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -165,6 +165,86 @@ static int hci_sock_release(struct socket *sock)
 	return 0;
 }
 
+struct bdaddr_list *hci_blacklist_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr)
+{
+	struct list_head *p;
+	struct bdaddr_list *blacklist = &hdev->blacklist;
+
+	list_for_each(p, &blacklist->list) {
+		struct bdaddr_list *b;
+
+		b = list_entry(p, struct bdaddr_list, list);
+
+		if (bacmp(bdaddr, &b->bdaddr) == 0)
+			return b;
+	}
+
+	return NULL;
+}
+
+static int hci_blacklist_add(struct hci_dev *hdev, void __user *arg)
+{
+	bdaddr_t bdaddr;
+	struct bdaddr_list *entry;
+
+	if (copy_from_user(&bdaddr, arg, sizeof(bdaddr)))
+		return -EFAULT;
+
+	if (bacmp(&bdaddr, BDADDR_ANY) == 0)
+		return -EBADF;
+
+	if (hci_blacklist_lookup(hdev, &bdaddr))
+		return -EEXIST;
+
+	entry = kzalloc(sizeof(struct bdaddr_list), GFP_KERNEL);
+	if (!entry)
+		return -ENOMEM;
+
+	bacpy(&entry->bdaddr, &bdaddr);
+
+	list_add(&entry->list, &hdev->blacklist.list);
+
+	return 0;
+}
+
+int hci_blacklist_clear(struct hci_dev *hdev)
+{
+	struct list_head *p, *n;
+	struct bdaddr_list *blacklist = &hdev->blacklist;
+
+	list_for_each_safe(p, n, &blacklist->list) {
+		struct bdaddr_list *b;
+
+		b = list_entry(p, struct bdaddr_list, list);
+
+		list_del(p);
+		kfree(b);
+	}
+
+	return 0;
+}
+
+static int hci_blacklist_del(struct hci_dev *hdev, void __user *arg)
+{
+	bdaddr_t bdaddr;
+	struct bdaddr_list *entry;
+
+	if (copy_from_user(&bdaddr, arg, sizeof(bdaddr)))
+		return -EFAULT;
+
+	if (bacmp(&bdaddr, BDADDR_ANY) == 0)
+		return hci_blacklist_clear(hdev);
+
+	entry = hci_blacklist_lookup(hdev, &bdaddr);
+	if (!entry)
+		return -ENOENT;
+
+	list_del(&entry->list);
+	kfree(entry);
+
+	return 0;
+}
+
 /* Ioctls that require bound socket */
 static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsigned long arg)
 {
@@ -194,6 +274,16 @@ static inline int hci_sock_bound_ioctl(struct sock *sk, unsigned int cmd, unsign
 	case HCIGETAUTHINFO:
 		return hci_get_auth_info(hdev, (void __user *) arg);
 
+	case HCIBLOCKADDR:
+		if (!capable(CAP_NET_ADMIN))
+			return -EACCES;
+		return hci_blacklist_add(hdev, (void __user *) arg);
+
+	case HCIUNBLOCKADDR:
+		if (!capable(CAP_NET_ADMIN))
+			return -EACCES;
+		return hci_blacklist_del(hdev, (void __user *) arg);
+
 	default:
 		if (hdev->ioctl)
 			return hdev->ioctl(hdev, cmd, arg);
-- 
1.7.0.4


^ permalink raw reply related

* Re: [PATCH v5] Add support for the Atheros AR300x Bluetooth Chip
From: suraj @ 2010-05-18 11:39 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: marcel, Luis.Rodriguez, Jothikumar.Mothilal, gfpadovan
In-Reply-To: <1273566548.7023.2.camel@atheros013-desktop>

Hi Marcel,

On Tue, 2010-05-11 at 13:59 +0530, suraj wrote:
> Hi marcel,
> 
> On Wed, 2010-05-05 at 18:03 +0530, suraj wrote:
> > Hi Marcel,
> > 
> > Can you take a look at the patch? Your review has been pending for
> > sometime.
> > 
> > On Mon, 2010-04-26 at 16:30 +0530, suraj wrote:
> > > Hi marcel,
> > > 
> > > On Thu, 2010-04-22 at 14:40 +0530, suraj wrote:
> > > > This implements the Atheros Bluetooth serial protocol to
> > > > support the AR300x Bluetooth chipsets.
> > > > The serial protocol implements enhanced power management
> > > > features for the AR300x chipsets. 
> > > > 
> > > > Reviewed-by: Luis R. Rodriguez <lrodriguez@atheros.com>
> > > > Reviewed-by: Gustavo F. Padovan <gustavo@padovan.org>
> > > > Signed-off-by: Suraj <suraj@atheros.com>
> > > > 
> > > > ---
> > > >  drivers/bluetooth/Kconfig     |   14 ++
> > > >  drivers/bluetooth/Makefile    |    1 +
> > > >  drivers/bluetooth/hci_ath.c   |  378 +++++++++++++++++++++++++++++++++++++++++
> > > >  drivers/bluetooth/hci_ldisc.c |    6 +
> > > >  drivers/bluetooth/hci_uart.h  |    8 +-
> > > >  5 files changed, 406 insertions(+), 1 deletions(-)
> > > >  create mode 100755 drivers/bluetooth/hci_ath.c
> > > > 
> > > Can you verify the patch let me know your comments? 
> > > 
> > > Regards
> > > Suraj
> > > 
> > 
> > 
> 
> your review has been pending for a long time. Please let me know what
> should be done regarding this.
> 
> Regards
> Suraj
> 
> 
This patch has been pending your approval/disapproval for so much time
that it runs the risk of being obsolete. Please do let me know if you
have any plans of doing something about it.

Regards
Suraj

^ permalink raw reply

* [PATCH] Bluetooth: Add debugfs support for showing the blacklist
From: johan.hedberg @ 2010-05-18 11:54 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Johan Hedberg

From: Johan Hedberg <johan.hedberg@nokia.com>

This patch adds a debugfs blacklist entry for each HCI device which can
be used to list the current content of the blacklist.

Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>
---
 net/bluetooth/hci_sysfs.c |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/hci_sysfs.c b/net/bluetooth/hci_sysfs.c
index 0e8e1a5..4fd47e9 100644
--- a/net/bluetooth/hci_sysfs.c
+++ b/net/bluetooth/hci_sysfs.c
@@ -444,6 +444,41 @@ static const struct file_operations inquiry_cache_fops = {
 	.release	= single_release,
 };
 
+static int blacklist_show(struct seq_file *f, void *p)
+{
+	struct hci_dev *hdev = f->private;
+	struct bdaddr_list *blacklist = &hdev->blacklist;
+	struct list_head *l;
+
+	hci_dev_lock_bh(hdev);
+
+	list_for_each(l, &blacklist->list) {
+		struct bdaddr_list *b;
+		bdaddr_t bdaddr;
+
+		b = list_entry(l, struct bdaddr_list, list);
+
+		baswap(&bdaddr, &b->bdaddr);
+
+		seq_printf(f, "%s\n", batostr(&bdaddr));
+	}
+
+	hci_dev_unlock_bh(hdev);
+
+	return 0;
+}
+
+static int blacklist_open(struct inode *inode, struct file *file)
+{
+	return single_open(file, blacklist_show, inode->i_private);
+}
+
+static const struct file_operations blacklist_fops = {
+	.open		= blacklist_open,
+	.read		= seq_read,
+	.llseek		= seq_lseek,
+	.release	= single_release,
+};
 int hci_register_sysfs(struct hci_dev *hdev)
 {
 	struct device *dev = &hdev->dev;
@@ -473,6 +508,9 @@ int hci_register_sysfs(struct hci_dev *hdev)
 	debugfs_create_file("inquiry_cache", 0444, hdev->debugfs,
 						hdev, &inquiry_cache_fops);
 
+	debugfs_create_file("blacklist", 0444, hdev->debugfs,
+						hdev, &blacklist_fops);
+
 	return 0;
 }
 
-- 
1.7.0.4


^ permalink raw reply related

* Need for workaround for buggy device.
From: Andrey Vainberger @ 2010-05-18 12:40 UTC (permalink / raw)
  To: linux-bluetooth

I have USB bluetooth adapter with little bug. This device always
reports about Stored Link Key.
For example log, got with the help of hcidump:

After the device is pluged in, and the command "Read Stored Link Key" is sent:

< HCI Command: Read Stored Link Key (0x03|0x000d) plen 7
  00 00 00 00 00 00 01concrete
> HCI Event: Return Link Keys (0x15) plen 23
  01 02 FF 00 00 0F 5E 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 8B 1A 02 10 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 05 00 00 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 03 F4 01 03 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 BC 66 47 2F C4 5E 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 32 18 1A 09 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 2B 08 14 28 60 FA 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Command Complete (0x0e) plen 8
  01 0D 0C 00 08 00 07 00

Then I try to delete all keys:
< HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7
  00 00 00 00 00 00 01
> HCI Event: Command Complete (0x0e) plen 6
  01 12 0C 00 07 00

Then I send Read Stored Link Key again, but... nothing changes:

 HCI Command: Read Stored Link Key (0x03|0x000d) plen 7
  00 00 00 00 00 00 01
> HCI Event: Return Link Keys (0x15) plen 23
  01 02 FF 00 00 0F 5E 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 8B 1A 02 10 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 05 00 00 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 03 F4 01 03 42 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 BC 66 47 2F C4 5E 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 32 18 1A 09 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Return Link Keys (0x15) plen 23
  01 2B 08 14 28 60 FA 00 00 00 00 00 00 00 00 00 00 00 00 00
  00 00 00
> HCI Event: Command Complete (0x0e) plen 8
  01 0D 0C 00 08 00 07 00

I also try to delete the specific key:
< HCI Command: Delete Stored Link Key (0x03|0x0012) plen 7
  02 FF 00 00 0F 5E 00
> HCI Event: Command Complete (0x0e) plen 6
  01 12 0C 00 01 00

And again - nothing changes. The device in reply to the command "Read
Stored Link Key",
gives back the same list of the stored keys as above.

Because of this defect, on the adapter's plug, bluez immediately
starts reporting about 7
coupled devices:

dbus-send --system --type=method_call --print-reply --dest=org.bluez
/org/bluez/5548/hci0 org.bluez.Adapter.GetProperties
<skipped>
      dict entry(
         string "Devices"
         variant             array [
               object path "/org/bluez/5548/hci0/dev_5E_0F_00_00_FF_02"
               object path "/org/bluez/5548/hci0/dev_30_30_10_02_1A_8B"
               object path "/org/bluez/5548/hci0/dev_00_00_60_00_00_05"
               object path "/org/bluez/5548/hci0/dev_00_42_03_01_F4_03"
               object path "/org/bluez/5548/hci0/dev_5E_C4_2F_47_66_BC"
               object path "/org/bluez/5548/hci0/dev_20_00_09_1A_18_32"
               object path "/org/bluez/5548/hci0/dev_FA_60_28_14_08_2B"
            ]
      )
</skipped>
that I cannot remove:
dbus-send --system --type=method_call --print-reply --dest=org.bluez
/org/bluez/5548/hci0 org.bluez.Adapter.RemoveDevice
objpath:/org/bluez/4393/hci0/dev_00_17_83_6B_5E_54
Error org.bluez.Error.DoesNotExist: Device does not exist
Moreover bluez starts crashing regularly.

After this hack everything works fine:
--- bluez-4.58.orig/src/security.c      2009-10-10 10:17:29.000000000 +0600
+++ bluez-4.58/src/security.c   2010-05-17 20:55:40.000000000 +0600
@@ -413,7 +413,7 @@

                info("return_link_keys (sba=%s, dba=%s)", sa, da);

-               hcid_dbus_returned_link_key(sba, &dba);
+               //hcid_dbus_returned_link_key(sba, &dba);

                ptr += 22;
        }

With another operating systems this adapter is functioning correctly.
Apparently, it is necessary to add some additional checking of the
keys that are returned by the command "Read Stored Link Key" or to add
to the config file the option for ignoring Return Link Keys Event.

^ permalink raw reply

* Re: HDP proposed API(0.5)
From: Elvis Pfützenreuter @ 2010-05-18 14:05 UTC (permalink / raw)
  To: jcaden
  Cc: ngh, Gustavo F. Padovan, João Paulo Rechi Vita,
	linux-bluetooth, raul.herbster
In-Reply-To: <201005181010.06376.jcaden@libresoft.es>


On May 18, 2010, at 5:10 AM, José Antonio Santos Cadenas wrote:

<snip>

>> Has any thought been given regarding support for MCAP clock
>> synchronization?  IEEE-20601 is mostly agnostic to the transport, but
>> this is one point where transport-specific information is exposed within
>> the 20601 protocol (via the MDS object's Mds-Time-Info attribute).  I'm
>> not aware of any devices which currently support clock synch (my code
>> included), so I'd argue this isn't a blocking feature for the first
>> release.
> 
> Yes, we (Santiago and me) and Elvis (and his team) are planning to continue 
> this work over MCAP in the next weeks.
> 
> Elvis, can you give more details about this?

Not yet, we plan to begin working on CSP this week.


^ permalink raw reply

* [PATCH 05/29] pcmcia: re-work pcmcia_request_irq()
From: Dominik Brodowski @ 2010-05-19  6:42 UTC (permalink / raw)
  To: linux-pcmcia
  Cc: Dominik Brodowski, linux-bluetooth, netdev, linux-wireless,
	linux-serial, alsa-devel, linux-usb, linux-ide
In-Reply-To: <20100519064149.GA5755@comet.dominikbrodowski.net>

Instead of the old pcmcia_request_irq() interface, drivers may now
choose between:

- calling request_irq/free_irq directly. Use the IRQ from *p_dev->irq.

- use pcmcia_request_irq(p_dev, handler_t); the PCMCIA core will
  clean up automatically on calls to pcmcia_disable_device() or
  device ejection.

- drivers still not capable of IRQF_SHARED (or not telling us so) may
  use the deprecated pcmcia_request_exclusive_irq() for the time
  being; they might receive a shared IRQ nonetheless.

CC: linux-bluetooth@vger.kernel.org
CC: netdev@vger.kernel.org
CC: linux-wireless@vger.kernel.org
CC: linux-serial@vger.kernel.org
CC: alsa-devel@alsa-project.org
CC: linux-usb@vger.kernel.org
CC: linux-ide@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 Documentation/pcmcia/driver-changes.txt          |   10 ++
 drivers/ata/pata_pcmcia.c                        |    6 +-
 drivers/bluetooth/bluecard_cs.c                  |    7 +-
 drivers/bluetooth/bt3c_cs.c                      |    7 +-
 drivers/bluetooth/btuart_cs.c                    |    7 +-
 drivers/bluetooth/dtl1_cs.c                      |    7 +-
 drivers/char/pcmcia/ipwireless/main.c            |   11 +--
 drivers/char/pcmcia/synclink_cs.c                |   12 +--
 drivers/ide/ide-cs.c                             |    8 +-
 drivers/isdn/hardware/avm/avm_cs.c               |   17 +--
 drivers/isdn/hisax/avma1_cs.c                    |   12 +--
 drivers/isdn/hisax/elsa_cs.c                     |   13 +--
 drivers/isdn/hisax/sedlbauer_cs.c                |   23 +---
 drivers/isdn/hisax/teles_cs.c                    |   13 +--
 drivers/net/pcmcia/3c574_cs.c                    |    6 +-
 drivers/net/pcmcia/3c589_cs.c                    |    7 +-
 drivers/net/pcmcia/axnet_cs.c                    |   13 +--
 drivers/net/pcmcia/com20020_cs.c                 |    8 +-
 drivers/net/pcmcia/fmvj18x_cs.c                  |   10 +--
 drivers/net/pcmcia/ibmtr_cs.c                    |    8 +-
 drivers/net/pcmcia/nmclan_cs.c                   |    6 +-
 drivers/net/pcmcia/pcnet_cs.c                    |    8 +-
 drivers/net/pcmcia/smc91c92_cs.c                 |    8 +-
 drivers/net/pcmcia/xirc2ps_cs.c                  |    7 +-
 drivers/net/wireless/airo_cs.c                   |   25 +---
 drivers/net/wireless/atmel_cs.c                  |   28 +----
 drivers/net/wireless/b43/pcmcia.c                |    5 +-
 drivers/net/wireless/hostap/hostap_cs.c          |   29 +----
 drivers/net/wireless/libertas/if_cs.c            |   21 +---
 drivers/net/wireless/orinoco/orinoco_cs.c        |   13 +--
 drivers/net/wireless/orinoco/spectrum_cs.c       |   13 +--
 drivers/net/wireless/ray_cs.c                    |    8 +-
 drivers/net/wireless/wl3501_cs.c                 |    8 +-
 drivers/parport/parport_cs.c                     |    8 +-
 drivers/pcmcia/ds.c                              |    3 +-
 drivers/pcmcia/pcmcia_resource.c                 |  137 +++++++++-------------
 drivers/scsi/pcmcia/aha152x_stub.c               |    6 +-
 drivers/scsi/pcmcia/fdomain_stub.c               |    6 +-
 drivers/scsi/pcmcia/nsp_cs.c                     |   20 +---
 drivers/scsi/pcmcia/qlogic_stub.c                |   10 +-
 drivers/scsi/pcmcia/sym53c500_cs.c               |    6 +-
 drivers/serial/serial_cs.c                       |   27 ++---
 drivers/ssb/main.c                               |    2 +-
 drivers/staging/comedi/drivers/cb_das16_cs.c     |   26 +---
 drivers/staging/comedi/drivers/das08_cs.c        |   16 +--
 drivers/staging/comedi/drivers/ni_daq_700.c      |   23 +---
 drivers/staging/comedi/drivers/ni_daq_dio24.c    |   23 +---
 drivers/staging/comedi/drivers/ni_labpc_cs.c     |   24 +---
 drivers/staging/comedi/drivers/ni_mio_cs.c       |    9 +-
 drivers/staging/comedi/drivers/quatech_daqp_cs.c |   22 +---
 drivers/staging/netwave/netwave_cs.c             |    8 +-
 drivers/staging/wavelan/wavelan_cs.c             |   15 +--
 drivers/staging/wlags49_h2/wl_cs.c               |    9 +-
 drivers/usb/host/sl811_cs.c                      |   18 +--
 include/pcmcia/cs.h                              |    7 -
 include/pcmcia/ds.h                              |   11 ++-
 sound/pcmcia/pdaudiocf/pdaudiocf.c               |    9 +-
 sound/pcmcia/vx/vxpocket.c                       |    8 +-
 58 files changed, 244 insertions(+), 593 deletions(-)

diff --git a/Documentation/pcmcia/driver-changes.txt b/Documentation/pcmcia/driver-changes.txt
index 446f43b..3268a9a 100644
--- a/Documentation/pcmcia/driver-changes.txt
+++ b/Documentation/pcmcia/driver-changes.txt
@@ -1,4 +1,14 @@
 This file details changes in 2.6 which affect PCMCIA card driver authors:
+* New IRQ request rules (as of 2.6.35)
+   Instead of the old pcmcia_request_irq() interface, drivers may now
+   choose between:
+   - calling request_irq/free_irq directly. Use the IRQ from *p_dev->irq.
+   - use pcmcia_request_irq(p_dev, handler_t); the PCMCIA core will
+     clean up automatically on calls to pcmcia_disable_device() or
+     device ejection.
+   - drivers still not capable of IRQF_SHARED (or not telling us so) may
+     use the deprecated pcmcia_request_exclusive_irq() for the time
+     being; they might receive a shared IRQ nonetheless.
 
 * no cs_error / CS_CHECK / CONFIG_PCMCIA_DEBUG (as of 2.6.33)
    Instead of the cs_error() callback or the CS_CHECK() macro, please use
diff --git a/drivers/ata/pata_pcmcia.c b/drivers/ata/pata_pcmcia.c
index d94b8f0..2aab1e0 100644
--- a/drivers/ata/pata_pcmcia.c
+++ b/drivers/ata/pata_pcmcia.c
@@ -268,7 +268,6 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
 	pdev->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
 	pdev->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
 	pdev->io.IOAddrLines = 3;
-	pdev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
 	pdev->conf.Attributes = CONF_ENABLE_IRQ;
 	pdev->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -293,8 +292,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
 	}
 	io_base = pdev->io.BasePort1;
 	ctl_base = stk->ctl_base;
-	ret = pcmcia_request_irq(pdev, &pdev->irq);
-	if (ret)
+	if (!pdev->irq)
 		goto failed;
 
 	ret = pcmcia_request_configuration(pdev, &pdev->conf);
@@ -344,7 +342,7 @@ static int pcmcia_init_one(struct pcmcia_device *pdev)
 	}
 
 	/* activate */
-	ret = ata_host_activate(host, pdev->irq.AssignedIRQ, ata_sff_interrupt,
+	ret = ata_host_activate(host, pdev->irq, ata_sff_interrupt,
 				IRQF_SHARED, &pcmcia_sht);
 	if (ret)
 		goto failed;
diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index d9bf87c..a34653d 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -869,9 +869,6 @@ static int bluecard_probe(struct pcmcia_device *link)
 
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
 	link->io.NumPorts1 = 8;
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-
-	link->irq.Handler = bluecard_interrupt;
 
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
@@ -908,9 +905,9 @@ static int bluecard_config(struct pcmcia_device *link)
 	if (i != 0)
 		goto failed;
 
-	i = pcmcia_request_irq(link, &link->irq);
+	i = pcmcia_request_irq(link, bluecard_interrupt);
 	if (i != 0)
-		link->irq.AssignedIRQ = 0;
+		goto failed;
 
 	i = pcmcia_request_configuration(link, &link->conf);
 	if (i != 0)
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 027cb8b..1ad9694 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -661,9 +661,6 @@ static int bt3c_probe(struct pcmcia_device *link)
 
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
 	link->io.NumPorts1 = 8;
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-
-	link->irq.Handler = bt3c_interrupt;
 
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
@@ -743,9 +740,9 @@ static int bt3c_config(struct pcmcia_device *link)
 	goto failed;
 
 found_port:
-	i = pcmcia_request_irq(link, &link->irq);
+	i = pcmcia_request_irq(link, &bt3c_interrupt);
 	if (i != 0)
-		link->irq.AssignedIRQ = 0;
+		goto failed;
 
 	i = pcmcia_request_configuration(link, &link->conf);
 	if (i != 0)
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 60c0953..1073d66 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -590,9 +590,6 @@ static int btuart_probe(struct pcmcia_device *link)
 
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
 	link->io.NumPorts1 = 8;
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-
-	link->irq.Handler = btuart_interrupt;
 
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
@@ -672,9 +669,9 @@ static int btuart_config(struct pcmcia_device *link)
 	goto failed;
 
 found_port:
-	i = pcmcia_request_irq(link, &link->irq);
+	i = pcmcia_request_irq(link, btuart_interrupt);
 	if (i != 0)
-		link->irq.AssignedIRQ = 0;
+		goto failed;
 
 	i = pcmcia_request_configuration(link, &link->conf);
 	if (i != 0)
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 1778831..3d72afd 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -575,9 +575,6 @@ static int dtl1_probe(struct pcmcia_device *link)
 
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
 	link->io.NumPorts1 = 8;
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-
-	link->irq.Handler = dtl1_interrupt;
 
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
@@ -621,9 +618,9 @@ static int dtl1_config(struct pcmcia_device *link)
 	if (pcmcia_loop_config(link, dtl1_confcheck, NULL) < 0)
 		goto failed;
 
-	i = pcmcia_request_irq(link, &link->irq);
+	i = pcmcia_request_irq(link, dtl1_interrupt);
 	if (i != 0)
-		link->irq.AssignedIRQ = 0;
+		goto failed;
 
 	i = pcmcia_request_configuration(link, &link->conf);
 	if (i != 0)
diff --git a/drivers/char/pcmcia/ipwireless/main.c b/drivers/char/pcmcia/ipwireless/main.c
index dff24da..2237890 100644
--- a/drivers/char/pcmcia/ipwireless/main.c
+++ b/drivers/char/pcmcia/ipwireless/main.c
@@ -195,9 +195,6 @@ static int config_ipwireless(struct ipw_dev *ipw)
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = ipwireless_interrupt;
-
 	INIT_WORK(&ipw->work_reboot, signalled_reboot_work);
 
 	ipwireless_init_hardware_v1(ipw->hardware, link->io.BasePort1,
@@ -205,8 +202,7 @@ static int config_ipwireless(struct ipw_dev *ipw)
 				    ipw->is_v2_card, signalled_reboot_callback,
 				    ipw);
 
-	ret = pcmcia_request_irq(link, &link->irq);
-
+	ret = pcmcia_request_irq(link, ipwireless_interrupt);
 	if (ret != 0)
 		goto exit;
 
@@ -217,7 +213,7 @@ static int config_ipwireless(struct ipw_dev *ipw)
 			(unsigned int) link->io.BasePort1,
 			(unsigned int) (link->io.BasePort1 +
 				link->io.NumPorts1 - 1),
-			(unsigned int) link->irq.AssignedIRQ);
+			(unsigned int) link->irq);
 	if (ipw->attr_memory && ipw->common_memory)
 		printk(KERN_INFO IPWIRELESS_PCCARD_NAME
 			": attr memory 0x%08lx-0x%08lx, common memory 0x%08lx-0x%08lx\n",
@@ -271,8 +267,6 @@ exit:
 
 static void release_ipwireless(struct ipw_dev *ipw)
 {
-	pcmcia_disable_device(ipw->link);
-
 	if (ipw->common_memory) {
 		release_mem_region(ipw->request_common_memory.Base,
 				ipw->request_common_memory.Size);
@@ -288,7 +282,6 @@ static void release_ipwireless(struct ipw_dev *ipw)
 	if (ipw->attr_memory)
 		pcmcia_release_window(ipw->link, ipw->handle_attr_memory);
 
-	/* Break the link with Card Services */
 	pcmcia_disable_device(ipw->link);
 }
 
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
index c31a0d9..027690b 100644
--- a/drivers/char/pcmcia/synclink_cs.c
+++ b/drivers/char/pcmcia/synclink_cs.c
@@ -552,10 +552,6 @@ static int mgslpc_probe(struct pcmcia_device *link)
 
     /* Initialize the struct pcmcia_device structure */
 
-    /* Interrupt setup */
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = NULL;
-
     link->conf.Attributes = 0;
     link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -608,9 +604,7 @@ static int mgslpc_config(struct pcmcia_device *link)
     link->conf.ConfigIndex = 8;
     link->conf.Present = PRESENT_OPTION;
 
-    link->irq.Handler     = mgslpc_isr;
-
-    ret = pcmcia_request_irq(link, &link->irq);
+    ret = pcmcia_request_irq(link, mgslpc_isr);
     if (ret)
 	    goto failed;
     ret = pcmcia_request_configuration(link, &link->conf);
@@ -618,7 +612,7 @@ static int mgslpc_config(struct pcmcia_device *link)
 	    goto failed;
 
     info->io_base = link->io.BasePort1;
-    info->irq_level = link->irq.AssignedIRQ;
+    info->irq_level = link->irq;
 
     /* add to linked list of devices */
     sprintf(info->node.dev_name, "mgslpc0");
@@ -628,7 +622,7 @@ static int mgslpc_config(struct pcmcia_device *link)
     printk(KERN_INFO "%s: index 0x%02x:",
 	   info->node.dev_name, link->conf.ConfigIndex);
     if (link->conf.Attributes & CONF_ENABLE_IRQ)
-	    printk(", irq %d", link->irq.AssignedIRQ);
+	    printk(", irq %d", link->irq);
     if (link->io.NumPorts1)
 	    printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		   link->io.BasePort1+link->io.NumPorts1-1);
diff --git a/drivers/ide/ide-cs.c b/drivers/ide/ide-cs.c
index b854508..17ad91e 100644
--- a/drivers/ide/ide-cs.c
+++ b/drivers/ide/ide-cs.c
@@ -102,7 +102,6 @@ static int ide_probe(struct pcmcia_device *link)
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
     link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
     link->io.IOAddrLines = 3;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -285,8 +284,7 @@ static int ide_config(struct pcmcia_device *link)
     io_base = link->io.BasePort1;
     ctl_base = stk->ctl_base;
 
-    ret = pcmcia_request_irq(link, &link->irq);
-    if (ret)
+    if (!link->irq)
 	    goto failed;
     ret = pcmcia_request_configuration(link, &link->conf);
     if (ret)
@@ -299,11 +297,11 @@ static int ide_config(struct pcmcia_device *link)
     if (is_kme)
 	outb(0x81, ctl_base+1);
 
-     host = idecs_register(io_base, ctl_base, link->irq.AssignedIRQ, link);
+     host = idecs_register(io_base, ctl_base, link->irq, link);
      if (host == NULL && link->io.NumPorts1 == 0x20) {
 	    outb(0x02, ctl_base + 0x10);
 	    host = idecs_register(io_base + 0x10, ctl_base + 0x10,
-				  link->irq.AssignedIRQ, link);
+				  link->irq, link);
     }
 
     if (host == NULL)
diff --git a/drivers/isdn/hardware/avm/avm_cs.c b/drivers/isdn/hardware/avm/avm_cs.c
index 94b796d..0d485f6 100644
--- a/drivers/isdn/hardware/avm/avm_cs.c
+++ b/drivers/isdn/hardware/avm/avm_cs.c
@@ -107,9 +107,6 @@ static int avmcs_probe(struct pcmcia_device *p_dev)
     p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
     p_dev->io.NumPorts2 = 0;
 
-    /* Interrupt setup */
-    p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-
     /* General socket configuration */
     p_dev->conf.Attributes = CONF_ENABLE_IRQ;
     p_dev->conf.IntType = INT_MEMORY_AND_IO;
@@ -172,7 +169,7 @@ static int avmcs_configcheck(struct pcmcia_device *p_dev,
 static int avmcs_config(struct pcmcia_device *link)
 {
     local_info_t *dev;
-    int i;
+    int i = -1;
     char devname[128];
     int cardtype;
     int (*addcard)(unsigned int port, unsigned irq);
@@ -190,11 +187,7 @@ static int avmcs_config(struct pcmcia_device *link)
 	    return -ENODEV;
 
     do {
-	/*
-	 * allocate an interrupt line
-	 */
-	i = pcmcia_request_irq(link, &link->irq);
-	if (i != 0) {
+	if (!link->irq) {
 	    /* undo */
 	    pcmcia_disable_device(link);
 	    break;
@@ -249,9 +242,9 @@ static int avmcs_config(struct pcmcia_device *link)
 	default:
         case AVM_CARDTYPE_B1: addcard = b1pcmcia_addcard_b1; break;
     }
-    if ((i = (*addcard)(link->io.BasePort1, link->irq.AssignedIRQ)) < 0) {
+    if ((i = (*addcard)(link->io.BasePort1, link->irq)) < 0) {
         printk(KERN_ERR "avm_cs: failed to add AVM-%s-Controller at i/o %#x, irq %d\n",
-		dev->node.dev_name, link->io.BasePort1, link->irq.AssignedIRQ);
+		dev->node.dev_name, link->io.BasePort1, link->irq);
 	avmcs_release(link);
 	return -ENODEV;
     }
@@ -270,7 +263,7 @@ static int avmcs_config(struct pcmcia_device *link)
 
 static void avmcs_release(struct pcmcia_device *link)
 {
-	b1pcmcia_delcard(link->io.BasePort1, link->irq.AssignedIRQ);
+	b1pcmcia_delcard(link->io.BasePort1, link->irq);
 	pcmcia_disable_device(link);
 } /* avmcs_release */
 
diff --git a/drivers/isdn/hisax/avma1_cs.c b/drivers/isdn/hisax/avma1_cs.c
index 8d1d63a..3ae2176 100644
--- a/drivers/isdn/hisax/avma1_cs.c
+++ b/drivers/isdn/hisax/avma1_cs.c
@@ -119,9 +119,6 @@ static int __devinit avma1cs_probe(struct pcmcia_device *p_dev)
     p_dev->io.Attributes2 = IO_DATA_PATH_WIDTH_16;
     p_dev->io.IOAddrLines = 5;
 
-    /* Interrupt setup */
-    p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-
     /* General socket configuration */
     p_dev->conf.Attributes = CONF_ENABLE_IRQ;
     p_dev->conf.IntType = INT_MEMORY_AND_IO;
@@ -177,7 +174,7 @@ static int avma1cs_configcheck(struct pcmcia_device *p_dev,
 static int __devinit avma1cs_config(struct pcmcia_device *link)
 {
     local_info_t *dev;
-    int i;
+    int i = -1;
     char devname[128];
     IsdnCard_t	icard;
     int busy = 0;
@@ -197,8 +194,7 @@ static int __devinit avma1cs_config(struct pcmcia_device *link)
 	/*
 	 * allocate an interrupt line
 	 */
-	i = pcmcia_request_irq(link, &link->irq);
-	if (i != 0) {
+	if (!link->irq) {
 	    /* undo */
 	    pcmcia_disable_device(link);
 	    break;
@@ -230,9 +226,9 @@ static int __devinit avma1cs_config(struct pcmcia_device *link)
     }
 
     printk(KERN_NOTICE "avma1_cs: checking at i/o %#x, irq %d\n",
-				link->io.BasePort1, link->irq.AssignedIRQ);
+				link->io.BasePort1, link->irq);
 
-    icard.para[0] = link->irq.AssignedIRQ;
+    icard.para[0] = link->irq;
     icard.para[1] = link->io.BasePort1;
     icard.protocol = isdnprot;
     icard.typ = ISDN_CTYPE_A1_PCMCIA;
diff --git a/drivers/isdn/hisax/elsa_cs.c b/drivers/isdn/hisax/elsa_cs.c
index c9f2279..8e170e4 100644
--- a/drivers/isdn/hisax/elsa_cs.c
+++ b/drivers/isdn/hisax/elsa_cs.c
@@ -136,10 +136,6 @@ static int __devinit elsa_cs_probe(struct pcmcia_device *link)
 
     local->cardnr = -1;
 
-    /* Interrupt setup */
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = NULL;
-
     /*
       General socket configuration defaults can go here.  In this
       client, we assume very little, and rely on the CIS for almost
@@ -223,11 +219,8 @@ static int __devinit elsa_cs_config(struct pcmcia_device *link)
     if (i != 0)
 	goto failed;
 
-    i = pcmcia_request_irq(link, &link->irq);
-    if (i != 0) {
-        link->irq.AssignedIRQ = 0;
+    if (!link->irq)
 	goto failed;
-    }
 
     i = pcmcia_request_configuration(link, &link->conf);
     if (i != 0)
@@ -244,7 +237,7 @@ static int __devinit elsa_cs_config(struct pcmcia_device *link)
     printk(KERN_INFO "%s: index 0x%02x: ",
            dev->node.dev_name, link->conf.ConfigIndex);
     if (link->conf.Attributes & CONF_ENABLE_IRQ)
-        printk(", irq %d", link->irq.AssignedIRQ);
+	printk(", irq %d", link->irq);
     if (link->io.NumPorts1)
         printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                link->io.BasePort1+link->io.NumPorts1-1);
@@ -253,7 +246,7 @@ static int __devinit elsa_cs_config(struct pcmcia_device *link)
                link->io.BasePort2+link->io.NumPorts2-1);
     printk("\n");
 
-    icard.para[0] = link->irq.AssignedIRQ;
+    icard.para[0] = link->irq;
     icard.para[1] = link->io.BasePort1;
     icard.protocol = protocol;
     icard.typ = ISDN_CTYPE_ELSA_PCMCIA;
diff --git a/drivers/isdn/hisax/sedlbauer_cs.c b/drivers/isdn/hisax/sedlbauer_cs.c
index 71b3dde..7778385 100644
--- a/drivers/isdn/hisax/sedlbauer_cs.c
+++ b/drivers/isdn/hisax/sedlbauer_cs.c
@@ -143,10 +143,6 @@ static int __devinit sedlbauer_probe(struct pcmcia_device *link)
     local->p_dev = link;
     link->priv = local;
 
-    /* Interrupt setup */
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = NULL;
-
     /*
       General socket configuration defaults can go here.  In this
       client, we assume very little, and rely on the CIS for almost
@@ -227,9 +223,7 @@ static int sedlbauer_config_check(struct pcmcia_device *p_dev,
 	else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
 		p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
 
-	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -313,17 +307,6 @@ static int __devinit sedlbauer_config(struct pcmcia_device *link)
 	    goto failed;
 
     /*
-       Allocate an interrupt line.  Note that this does not assign a
-       handler to the interrupt, unless the 'Handler' member of the
-       irq structure is initialized.
-    */
-    if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-	    ret = pcmcia_request_irq(link, &link->irq);
-	    if (ret)
-		    goto failed;
-    }
-	
-    /*
        This actually configures the PCMCIA socket -- setting up
        the I/O windows and the interrupt mapping, and putting the
        card and host interface into "Memory and IO" mode.
@@ -346,7 +329,7 @@ static int __devinit sedlbauer_config(struct pcmcia_device *link)
     if (link->conf.Vpp)
 	printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
     if (link->conf.Attributes & CONF_ENABLE_IRQ)
-	printk(", irq %d", link->irq.AssignedIRQ);
+	printk(", irq %d", link->irq);
     if (link->io.NumPorts1)
 	printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 	       link->io.BasePort1+link->io.NumPorts1-1);
@@ -358,7 +341,7 @@ static int __devinit sedlbauer_config(struct pcmcia_device *link)
 	       req->Base+req->Size-1);
     printk("\n");
 
-    icard.para[0] = link->irq.AssignedIRQ;
+    icard.para[0] = link->irq;
     icard.para[1] = link->io.BasePort1;
     icard.protocol = protocol;
     icard.typ = ISDN_CTYPE_SEDLBAUER_PCMCIA;
diff --git a/drivers/isdn/hisax/teles_cs.c b/drivers/isdn/hisax/teles_cs.c
index d010a0d..02dec13 100644
--- a/drivers/isdn/hisax/teles_cs.c
+++ b/drivers/isdn/hisax/teles_cs.c
@@ -126,10 +126,6 @@ static int __devinit teles_probe(struct pcmcia_device *link)
     local->p_dev = link;
     link->priv = local;
 
-    /* Interrupt setup */
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = NULL;
-
     /*
       General socket configuration defaults can go here.  In this
       client, we assume very little, and rely on the CIS for almost
@@ -213,11 +209,8 @@ static int __devinit teles_cs_config(struct pcmcia_device *link)
     if (i != 0)
 	goto cs_failed;
 
-    i = pcmcia_request_irq(link, &link->irq);
-    if (i != 0) {
-        link->irq.AssignedIRQ = 0;
+    if (!link->irq)
         goto cs_failed;
-    }
 
     i = pcmcia_request_configuration(link, &link->conf);
     if (i != 0)
@@ -234,7 +227,7 @@ static int __devinit teles_cs_config(struct pcmcia_device *link)
     printk(KERN_INFO "%s: index 0x%02x:",
            dev->node.dev_name, link->conf.ConfigIndex);
     if (link->conf.Attributes & CONF_ENABLE_IRQ)
-        printk(", irq %d", link->irq.AssignedIRQ);
+	    printk(", irq %d", link->irq);
     if (link->io.NumPorts1)
         printk(", io 0x%04x-0x%04x", link->io.BasePort1,
                link->io.BasePort1+link->io.NumPorts1-1);
@@ -243,7 +236,7 @@ static int __devinit teles_cs_config(struct pcmcia_device *link)
                link->io.BasePort2+link->io.NumPorts2-1);
     printk("\n");
 
-    icard.para[0] = link->irq.AssignedIRQ;
+    icard.para[0] = link->irq;
     icard.para[1] = link->io.BasePort1;
     icard.protocol = protocol;
     icard.typ = ISDN_CTYPE_TELESPCMCIA;
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 757f87b..1442831 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -283,8 +283,6 @@ static int tc574_probe(struct pcmcia_device *link)
 	spin_lock_init(&lp->window_lock);
 	link->io.NumPorts1 = 32;
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = &el3_interrupt;
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 	link->conf.ConfigIndex = 1;
@@ -353,7 +351,7 @@ static int tc574_config(struct pcmcia_device *link)
 	if (i != 0)
 		goto failed;
 
-	ret = pcmcia_request_irq(link, &link->irq);
+	ret = pcmcia_request_irq(link, el3_interrupt);
 	if (ret)
 		goto failed;
 
@@ -361,7 +359,7 @@ static int tc574_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	dev->irq = link->irq.AssignedIRQ;
+	dev->irq = link->irq;
 	dev->base_addr = link->io.BasePort1;
 
 	ioaddr = dev->base_addr;
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 091e0b0..405d772 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -194,8 +194,7 @@ static int tc589_probe(struct pcmcia_device *link)
     spin_lock_init(&lp->lock);
     link->io.NumPorts1 = 16;
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = &el3_interrupt;
+
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
     link->conf.ConfigIndex = 1;
@@ -271,7 +270,7 @@ static int tc589_config(struct pcmcia_device *link)
     if (i != 0)
 	goto failed;
 
-    ret = pcmcia_request_irq(link, &link->irq);
+    ret = pcmcia_request_irq(link, el3_interrupt);
     if (ret)
 	    goto failed;
 
@@ -279,7 +278,7 @@ static int tc589_config(struct pcmcia_device *link)
     if (ret)
 	    goto failed;
 	
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
     dev->base_addr = link->io.BasePort1;
     ioaddr = dev->base_addr;
     EL3WINDOW(0);
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c
index 9f3d593..967547a 100644
--- a/drivers/net/pcmcia/axnet_cs.c
+++ b/drivers/net/pcmcia/axnet_cs.c
@@ -168,7 +168,6 @@ static int axnet_probe(struct pcmcia_device *link)
     info = PRIV(dev);
     info->p_dev = link;
     link->priv = dev;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -265,12 +264,9 @@ static int try_io_port(struct pcmcia_device *link)
     int j, ret;
     if (link->io.NumPorts1 == 32) {
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
-	if (link->io.NumPorts2 > 0) {
-	    /* for master/slave multifunction cards */
+	/* for master/slave multifunction cards */
+	if (link->io.NumPorts2 > 0)
 	    link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
-	    link->irq.Attributes =
-		IRQ_TYPE_DYNAMIC_SHARING;
-	}
     } else {
 	/* This should be two 16-port windows */
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
@@ -336,8 +332,7 @@ static int axnet_config(struct pcmcia_device *link)
     if (ret != 0)
 	goto failed;
 
-    ret = pcmcia_request_irq(link, &link->irq);
-    if (ret)
+    if (!link->irq)
 	    goto failed;
     
     if (link->io.NumPorts2 == 8) {
@@ -349,7 +344,7 @@ static int axnet_config(struct pcmcia_device *link)
     if (ret)
 	    goto failed;
 
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
     dev->base_addr = link->io.BasePort1;
 
     if (!get_prom(link)) {
diff --git a/drivers/net/pcmcia/com20020_cs.c b/drivers/net/pcmcia/com20020_cs.c
index 21d9c9d..278438b 100644
--- a/drivers/net/pcmcia/com20020_cs.c
+++ b/drivers/net/pcmcia/com20020_cs.c
@@ -163,7 +163,6 @@ static int com20020_probe(struct pcmcia_device *p_dev)
     p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
     p_dev->io.NumPorts1 = 16;
     p_dev->io.IOAddrLines = 16;
-    p_dev->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
     p_dev->conf.Attributes = CONF_ENABLE_IRQ;
     p_dev->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -275,15 +274,14 @@ static int com20020_config(struct pcmcia_device *link)
     dev_dbg(&link->dev, "got ioaddr %Xh\n", ioaddr);
 
     dev_dbg(&link->dev, "request IRQ %d\n",
-	    link->irq.AssignedIRQ);
-    i = pcmcia_request_irq(link, &link->irq);
-    if (i != 0)
+	    link->irq);
+    if (!link->irq)
     {
 	dev_dbg(&link->dev, "requestIRQ failed totally!\n");
 	goto failed;
     }
 
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
 
     ret = pcmcia_request_configuration(link, &link->conf);
     if (ret)
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c
index b9dc80b..31f1a03 100644
--- a/drivers/net/pcmcia/fmvj18x_cs.c
+++ b/drivers/net/pcmcia/fmvj18x_cs.c
@@ -254,10 +254,6 @@ static int fmvj18x_probe(struct pcmcia_device *link)
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
     link->io.IOAddrLines = 5;
 
-    /* Interrupt setup */
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = fjn_interrupt;
-
     /* General socket configuration */
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
@@ -425,8 +421,6 @@ static int fmvj18x_config(struct pcmcia_device *link)
     }
 
     if (link->io.NumPorts2 != 0) {
-    	link->irq.Attributes =
-		IRQ_TYPE_DYNAMIC_SHARING;
 	ret = mfc_try_io_port(link);
 	if (ret != 0) goto failed;
     } else if (cardtype == UNGERMANN) {
@@ -437,14 +431,14 @@ static int fmvj18x_config(struct pcmcia_device *link)
 	    if (ret)
 		    goto failed;
     }
-    ret = pcmcia_request_irq(link, &link->irq);
+    ret = pcmcia_request_irq(link, fjn_interrupt);
     if (ret)
 	    goto failed;
     ret = pcmcia_request_configuration(link, &link->conf);
     if (ret)
 	    goto failed;
 
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
     dev->base_addr = link->io.BasePort1;
 
     if (link->io.BasePort2 != 0) {
diff --git a/drivers/net/pcmcia/ibmtr_cs.c b/drivers/net/pcmcia/ibmtr_cs.c
index 37f4a6f..0225cdf 100644
--- a/drivers/net/pcmcia/ibmtr_cs.c
+++ b/drivers/net/pcmcia/ibmtr_cs.c
@@ -156,8 +156,6 @@ static int __devinit ibmtr_attach(struct pcmcia_device *link)
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
     link->io.NumPorts1 = 4;
     link->io.IOAddrLines = 16;
-    link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-    link->irq.Handler = ibmtr_interrupt;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
     link->conf.Present = PRESENT_OPTION;
@@ -238,11 +236,11 @@ static int __devinit ibmtr_config(struct pcmcia_device *link)
     }
     dev->base_addr = link->io.BasePort1;
 
-    ret = pcmcia_request_irq(link, &link->irq);
+    ret = pcmcia_request_exclusive_irq(link, ibmtr_interrupt);
     if (ret)
 	    goto failed;
-    dev->irq = link->irq.AssignedIRQ;
-    ti->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
+    ti->irq = link->irq;
     ti->global_int_enable=GLOBAL_INT_ENABLE+((dev->irq==9) ? 2 : dev->irq);
 
     /* Allocate the MMIO memory window */
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c
index c717b14..b779e3a 100644
--- a/drivers/net/pcmcia/nmclan_cs.c
+++ b/drivers/net/pcmcia/nmclan_cs.c
@@ -463,8 +463,6 @@ static int nmclan_probe(struct pcmcia_device *link)
     link->io.NumPorts1 = 32;
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
     link->io.IOAddrLines = 5;
-    link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-    link->irq.Handler = mace_interrupt;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
     link->conf.ConfigIndex = 1;
@@ -652,14 +650,14 @@ static int nmclan_config(struct pcmcia_device *link)
   ret = pcmcia_request_io(link, &link->io);
   if (ret)
 	  goto failed;
-  ret = pcmcia_request_irq(link, &link->irq);
+  ret = pcmcia_request_exclusive_irq(link, mace_interrupt);
   if (ret)
 	  goto failed;
   ret = pcmcia_request_configuration(link, &link->conf);
   if (ret)
 	  goto failed;
 
-  dev->irq = link->irq.AssignedIRQ;
+  dev->irq = link->irq;
   dev->base_addr = link->io.BasePort1;
 
   ioaddr = dev->base_addr;
diff --git a/drivers/net/pcmcia/pcnet_cs.c b/drivers/net/pcmcia/pcnet_cs.c
index 4c0368d..af09be4 100644
--- a/drivers/net/pcmcia/pcnet_cs.c
+++ b/drivers/net/pcmcia/pcnet_cs.c
@@ -264,7 +264,6 @@ static int pcnet_probe(struct pcmcia_device *link)
     info->p_dev = link;
     link->priv = dev;
 
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -488,8 +487,6 @@ static int try_io_port(struct pcmcia_device *link)
 	if (link->io.NumPorts2 > 0) {
 	    /* for master/slave multifunction cards */
 	    link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
-	    link->irq.Attributes =
-		IRQ_TYPE_DYNAMIC_SHARING;
 	}
     } else {
 	/* This should be two 16-port windows */
@@ -559,8 +556,7 @@ static int pcnet_config(struct pcmcia_device *link)
     if (ret)
 	goto failed;
 
-    ret = pcmcia_request_irq(link, &link->irq);
-    if (ret)
+    if (!link->irq)
 	    goto failed;
 
     if (link->io.NumPorts2 == 8) {
@@ -574,7 +570,7 @@ static int pcnet_config(struct pcmcia_device *link)
     ret = pcmcia_request_configuration(link, &link->conf);
     if (ret)
 	    goto failed;
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
     dev->base_addr = link->io.BasePort1;
     if (info->flags & HAS_MISC_REG) {
 	if ((if_port == 1) || (if_port == 2))
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c
index ccc5537..ad061c7 100644
--- a/drivers/net/pcmcia/smc91c92_cs.c
+++ b/drivers/net/pcmcia/smc91c92_cs.c
@@ -329,8 +329,6 @@ static int smc91c92_probe(struct pcmcia_device *link)
     link->io.NumPorts1 = 16;
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
     link->io.IOAddrLines = 4;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = &smc_interrupt;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -453,7 +451,6 @@ static int mhz_mfc_config(struct pcmcia_device *link)
 
     link->conf.Attributes |= CONF_ENABLE_SPKR;
     link->conf.Status = CCSR_AUDIO_ENA;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
     link->io.IOAddrLines = 16;
     link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
     link->io.NumPorts2 = 8;
@@ -652,7 +649,6 @@ static int osi_config(struct pcmcia_device *link)
 
     link->conf.Attributes |= CONF_ENABLE_SPKR;
     link->conf.Status = CCSR_AUDIO_ENA;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
     link->io.NumPorts1 = 64;
     link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
     link->io.NumPorts2 = 8;
@@ -877,7 +873,7 @@ static int smc91c92_config(struct pcmcia_device *link)
     if (i)
 	    goto config_failed;
 
-    i = pcmcia_request_irq(link, &link->irq);
+    i = pcmcia_request_irq(link, smc_interrupt);
     if (i)
 	    goto config_failed;
     i = pcmcia_request_configuration(link, &link->conf);
@@ -887,7 +883,7 @@ static int smc91c92_config(struct pcmcia_device *link)
     if (smc->manfid == MANFID_MOTOROLA)
 	mot_config(link);
 
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
 
     if ((if_port >= 0) && (if_port <= 2))
 	dev->if_port = if_port;
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c
index 4d1802e..c9e7d7d 100644
--- a/drivers/net/pcmcia/xirc2ps_cs.c
+++ b/drivers/net/pcmcia/xirc2ps_cs.c
@@ -555,7 +555,6 @@ xirc2ps_probe(struct pcmcia_device *link)
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
     link->conf.ConfigIndex = 1;
-    link->irq.Handler = xirc2ps_interrupt;
 
     /* Fill in card specific entries */
     dev->netdev_ops = &netdev_ops;
@@ -841,7 +840,6 @@ xirc2ps_config(struct pcmcia_device * link)
 	    link->conf.Attributes |= CONF_ENABLE_SPKR;
 	    link->conf.Status |= CCSR_AUDIO_ENA;
 	}
-	link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
 	link->io.NumPorts2 = 8;
 	link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
 	if (local->dingo) {
@@ -866,7 +864,6 @@ xirc2ps_config(struct pcmcia_device * link)
 	}
 	printk(KNOT_XIRC "no ports available\n");
     } else {
-	link->irq.Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
 	link->io.NumPorts1 = 16;
 	for (ioaddr = 0x300; ioaddr < 0x400; ioaddr += 0x10) {
 	    link->io.BasePort1 = ioaddr;
@@ -885,7 +882,7 @@ xirc2ps_config(struct pcmcia_device * link)
      * Now allocate an interrupt line.	Note that this does not
      * actually assign a handler to the interrupt.
      */
-    if ((err=pcmcia_request_irq(link, &link->irq)))
+    if ((err=pcmcia_request_irq(link, xirc2ps_interrupt)))
 	goto config_error;
 
     /****************
@@ -982,7 +979,7 @@ xirc2ps_config(struct pcmcia_device * link)
 	printk(KNOT_XIRC "invalid if_port requested\n");
 
     /* we can now register the device with the net subsystem */
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
     dev->base_addr = link->io.BasePort1;
 
     if (local->dingo)
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index f6036fb..7867c51 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -132,10 +132,6 @@ static int airo_probe(struct pcmcia_device *p_dev)
 
 	dev_dbg(&p_dev->dev, "airo_attach()\n");
 
-	/* Interrupt setup */
-	p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	p_dev->irq.Handler = NULL;
-
 	/*
 	  General socket configuration defaults can go here.  In this
 	  client, we assume very little, and rely on the CIS for almost
@@ -212,9 +208,7 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev,
 	else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
 		p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
 
-	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -300,16 +294,8 @@ static int airo_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	/*
-	  Allocate an interrupt line.  Note that this does not assign a
-	  handler to the interrupt, unless the 'Handler' member of the
-	  irq structure is initialized.
-	*/
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	if (!link->irq)
+		goto failed;
 
 	/*
 	  This actually configures the PCMCIA socket -- setting up
@@ -320,7 +306,7 @@ static int airo_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 	((local_info_t *)link->priv)->eth_dev =
-		init_airo_card(link->irq.AssignedIRQ,
+		init_airo_card(link->irq,
 			       link->io.BasePort1, 1, &link->dev);
 	if (!((local_info_t *)link->priv)->eth_dev)
 		goto failed;
@@ -338,8 +324,7 @@ static int airo_config(struct pcmcia_device *link)
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Vpp)
 		printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
-	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %d", link->irq.AssignedIRQ);
+	printk(", irq %d", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1+link->io.NumPorts1-1);
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 3240791..759cdc4 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -141,10 +141,6 @@ static int atmel_probe(struct pcmcia_device *p_dev)
 
 	dev_dbg(&p_dev->dev, "atmel_attach()\n");
 
-	/* Interrupt setup */
-	p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	p_dev->irq.Handler = NULL;
-
 	/*
 	  General socket configuration defaults can go here.  In this
 	  client, we assume very little, and rely on the CIS for almost
@@ -226,9 +222,7 @@ static int atmel_config_check(struct pcmcia_device *p_dev,
 	else if (dflt->vpp1.present & (1<<CISTPL_POWER_VNOM))
 		p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
 
-	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -278,15 +272,9 @@ static int atmel_config(struct pcmcia_device *link)
 	if (pcmcia_loop_config(link, atmel_config_check, NULL))
 		goto failed;
 
-	/*
-	  Allocate an interrupt line.  Note that this does not assign a
-	  handler to the interrupt, unless the 'Handler' member of the
-	  irq structure is initialized.
-	*/
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
+	if (!link->irq) {
+		dev_err(&link->dev, "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
+		goto failed;
 	}
 
 	/*
@@ -298,14 +286,8 @@ static int atmel_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	if (link->irq.AssignedIRQ == 0) {
-		printk(KERN_ALERT
-		       "atmel: cannot assign IRQ: check that CONFIG_ISA is set in kernel config.");
-		goto failed;
-	}
-
 	((local_info_t*)link->priv)->eth_dev =
-		init_atmel_card(link->irq.AssignedIRQ,
+		init_atmel_card(link->irq,
 				link->io.BasePort1,
 				did ? did->driver_info : ATMEL_FW_TYPE_NONE,
 				&link->dev,
diff --git a/drivers/net/wireless/b43/pcmcia.c b/drivers/net/wireless/b43/pcmcia.c
index 609e705..0e99b63 100644
--- a/drivers/net/wireless/b43/pcmcia.c
+++ b/drivers/net/wireless/b43/pcmcia.c
@@ -98,10 +98,7 @@ static int __devinit b43_pcmcia_probe(struct pcmcia_device *dev)
 	if (res != 0)
 		goto err_disable;
 
-	dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	dev->irq.Handler = NULL; /* The handler is registered later. */
-	res = pcmcia_request_irq(dev, &dev->irq);
-	if (res != 0)
+	if (!dev->irq)
 		goto err_disable;
 
 	res = pcmcia_request_configuration(dev, &dev->conf);
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index a36501d..5e2efbb 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -556,15 +556,7 @@ static int prism2_config_check(struct pcmcia_device *p_dev,
 		p_dev->conf.Vpp = dflt->vpp1.param[CISTPL_POWER_VNOM] / 10000;
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
-	else if (!(p_dev->conf.Attributes & CONF_ENABLE_IRQ)) {
-		/* At least Compaq WL200 does not have IRQInfo1 set,
-		 * but it does not work without interrupts.. */
-		printk(KERN_WARNING "Config has no IRQ info, but trying to "
-		       "enable IRQ anyway..\n");
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
-	}
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	PDEBUG(DEBUG_EXTRA, "IO window settings: cfg->io.nwin=%d "
@@ -636,18 +628,9 @@ static int prism2_config(struct pcmcia_device *link)
 	strcpy(hw_priv->node.dev_name, dev->name);
 	link->dev_node = &hw_priv->node;
 
-	/*
-	 * Allocate an interrupt line.  Note that this does not assign a
-	 * handler to the interrupt, unless the 'Handler' member of the
-	 * irq structure is initialized.
-	 */
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-		link->irq.Handler = prism2_interrupt;
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	ret = pcmcia_request_irq(link, prism2_interrupt);
+	if (ret)
+		goto failed;
 
 	/*
 	 * This actually configures the PCMCIA socket -- setting up
@@ -658,7 +641,7 @@ static int prism2_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	dev->irq = link->irq.AssignedIRQ;
+	dev->irq = link->irq;
 	dev->base_addr = link->io.BasePort1;
 
 	/* Finally, report what we've done */
@@ -668,7 +651,7 @@ static int prism2_config(struct pcmcia_device *link)
 		printk(", Vpp %d.%d", link->conf.Vpp / 10,
 		       link->conf.Vpp % 10);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %d", link->irq.AssignedIRQ);
+		printk(", irq %d", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1+link->io.NumPorts1-1);
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c
index 6d55439..08e4e39 100644
--- a/drivers/net/wireless/libertas/if_cs.c
+++ b/drivers/net/wireless/libertas/if_cs.c
@@ -777,7 +777,7 @@ static void if_cs_release(struct pcmcia_device *p_dev)
 
 	lbs_deb_enter(LBS_DEB_CS);
 
-	free_irq(p_dev->irq.AssignedIRQ, card);
+	free_irq(p_dev->irq, card);
 	pcmcia_disable_device(p_dev);
 	if (card->iobase)
 		ioport_unmap(card->iobase);
@@ -807,8 +807,7 @@ static int if_cs_ioprobe(struct pcmcia_device *p_dev,
 	p_dev->io.NumPorts1 = cfg->io.win[0].len;
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	if (cfg->io.nwin != 1) {
@@ -837,9 +836,6 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
 	card->p_dev = p_dev;
 	p_dev->priv = card;
 
-	p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	p_dev->irq.Handler = NULL;
-
 	p_dev->conf.Attributes = 0;
 	p_dev->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -854,13 +850,8 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
 	 * a handler to the interrupt, unless the 'Handler' member of
 	 * the irq structure is initialized.
 	 */
-	if (p_dev->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(p_dev, &p_dev->irq);
-		if (ret) {
-			lbs_pr_err("error in pcmcia_request_irq\n");
-			goto out1;
-		}
-	}
+	if (!p_dev->irq)
+		goto out1;
 
 	/* Initialize io access */
 	card->iobase = ioport_map(p_dev->io.BasePort1, p_dev->io.NumPorts1);
@@ -883,7 +874,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
 
 	/* Finally, report what we've done */
 	lbs_deb_cs("irq %d, io 0x%04x-0x%04x\n",
-	       p_dev->irq.AssignedIRQ, p_dev->io.BasePort1,
+	       p_dev->irq, p_dev->io.BasePort1,
 	       p_dev->io.BasePort1 + p_dev->io.NumPorts1 - 1);
 
 	/*
@@ -940,7 +931,7 @@ static int if_cs_probe(struct pcmcia_device *p_dev)
 	priv->fw_ready = 1;
 
 	/* Now actually get the IRQ */
-	ret = request_irq(p_dev->irq.AssignedIRQ, if_cs_interrupt,
+	ret = request_irq(p_dev->irq, if_cs_interrupt,
 		IRQF_SHARED, DRV_NAME, card);
 	if (ret) {
 		lbs_pr_err("error in request_irq\n");
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c
index 1d4ada1..5d29b11 100644
--- a/drivers/net/wireless/orinoco/orinoco_cs.c
+++ b/drivers/net/wireless/orinoco/orinoco_cs.c
@@ -119,10 +119,6 @@ orinoco_cs_probe(struct pcmcia_device *link)
 	card->p_dev = link;
 	link->priv = priv;
 
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = orinoco_interrupt;
-
 	/* General socket configuration defaults can go here.  In this
 	 * client, we assume very little, and rely on the CIS for
 	 * almost everything.  In most clients, many details (i.e.,
@@ -258,12 +254,7 @@ orinoco_cs_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	/*
-	 * Allocate an interrupt line.  Note that this does not assign
-	 * a handler to the interrupt, unless the 'Handler' member of
-	 * the irq structure is initialized.
-	 */
-	ret = pcmcia_request_irq(link, &link->irq);
+	ret = pcmcia_request_irq(link, orinoco_interrupt);
 	if (ret)
 		goto failed;
 
@@ -296,7 +287,7 @@ orinoco_cs_config(struct pcmcia_device *link)
 
 	/* Register an interface with the stack */
 	if (orinoco_if_add(priv, link->io.BasePort1,
-			   link->irq.AssignedIRQ) != 0) {
+			   link->irq) != 0) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto failed;
 	}
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c
index 59bda24..7a8e056 100644
--- a/drivers/net/wireless/orinoco/spectrum_cs.c
+++ b/drivers/net/wireless/orinoco/spectrum_cs.c
@@ -193,10 +193,6 @@ spectrum_cs_probe(struct pcmcia_device *link)
 	card->p_dev = link;
 	link->priv = priv;
 
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = orinoco_interrupt;
-
 	/* General socket configuration defaults can go here.  In this
 	 * client, we assume very little, and rely on the CIS for
 	 * almost everything.  In most clients, many details (i.e.,
@@ -332,12 +328,7 @@ spectrum_cs_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	/*
-	 * Allocate an interrupt line.  Note that this does not assign
-	 * a handler to the interrupt, unless the 'Handler' member of
-	 * the irq structure is initialized.
-	 */
-	ret = pcmcia_request_irq(link, &link->irq);
+	ret = pcmcia_request_irq(link, orinoco_interrupt);
 	if (ret)
 		goto failed;
 
@@ -374,7 +365,7 @@ spectrum_cs_config(struct pcmcia_device *link)
 
 	/* Register an interface with the stack */
 	if (orinoco_if_add(priv, link->io.BasePort1,
-			   link->irq.AssignedIRQ) != 0) {
+			   link->irq) != 0) {
 		printk(KERN_ERR PFX "orinoco_if_add() failed\n");
 		goto failed;
 	}
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 11865ea..fe4642a 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -321,10 +321,6 @@ static int ray_probe(struct pcmcia_device *p_dev)
 	p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
 	p_dev->io.IOAddrLines = 5;
 
-	/* Interrupt setup. For PCMCIA, driver takes what's given */
-	p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	p_dev->irq.Handler = &ray_interrupt;
-
 	/* General socket configuration */
 	p_dev->conf.Attributes = CONF_ENABLE_IRQ;
 	p_dev->conf.IntType = INT_MEMORY_AND_IO;
@@ -417,10 +413,10 @@ static int ray_config(struct pcmcia_device *link)
 	/* Now allocate an interrupt line.  Note that this does not
 	   actually assign a handler to the interrupt.
 	 */
-	ret = pcmcia_request_irq(link, &link->irq);
+	ret = pcmcia_request_irq(link, ray_interrupt);
 	if (ret)
 		goto failed;
-	dev->irq = link->irq.AssignedIRQ;
+	dev->irq = link->irq;
 
 	/* This actually configures the PCMCIA socket -- setting up
 	   the I/O windows and the interrupt mapping.
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c
index 7b9621d..c43f05b 100644
--- a/drivers/net/wireless/wl3501_cs.c
+++ b/drivers/net/wireless/wl3501_cs.c
@@ -1897,10 +1897,6 @@ static int wl3501_probe(struct pcmcia_device *p_dev)
 	p_dev->io.Attributes1	= IO_DATA_PATH_WIDTH_8;
 	p_dev->io.IOAddrLines	= 5;
 
-	/* Interrupt setup */
-	p_dev->irq.Attributes	= IRQ_TYPE_DYNAMIC_SHARING;
-	p_dev->irq.Handler = wl3501_interrupt;
-
 	/* General socket configuration */
 	p_dev->conf.Attributes	= CONF_ENABLE_IRQ;
 	p_dev->conf.IntType	= INT_MEMORY_AND_IO;
@@ -1961,7 +1957,7 @@ static int wl3501_config(struct pcmcia_device *link)
 	/* Now allocate an interrupt line. Note that this does not actually
 	 * assign a handler to the interrupt. */
 
-	ret = pcmcia_request_irq(link, &link->irq);
+	ret = pcmcia_request_irq(link, wl3501_interrupt);
 	if (ret)
 		goto failed;
 
@@ -1972,7 +1968,7 @@ static int wl3501_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	dev->irq = link->irq.AssignedIRQ;
+	dev->irq = link->irq;
 	dev->base_addr = link->io.BasePort1;
 	SET_NETDEV_DEV(dev, &link->dev);
 	if (register_netdev(dev)) {
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 7dd370f..80c9052 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -105,7 +105,6 @@ static int parport_probe(struct pcmcia_device *link)
 
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
     link->io.Attributes2 = IO_DATA_PATH_WIDTH_8;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -174,20 +173,19 @@ static int parport_config(struct pcmcia_device *link)
     if (ret)
 	    goto failed;
 
-    ret = pcmcia_request_irq(link, &link->irq);
-    if (ret)
+    if (!link->irq)
 	    goto failed;
     ret = pcmcia_request_configuration(link, &link->conf);
     if (ret)
 	    goto failed;
 
     p = parport_pc_probe_port(link->io.BasePort1, link->io.BasePort2,
-			      link->irq.AssignedIRQ, PARPORT_DMA_NONE,
+			      link->irq, PARPORT_DMA_NONE,
 			      &link->dev, IRQF_SHARED);
     if (p == NULL) {
 	printk(KERN_NOTICE "parport_cs: parport_pc_probe_port() at "
 	       "0x%3x, irq %u failed\n", link->io.BasePort1,
-	       link->irq.AssignedIRQ);
+	       link->irq);
 	goto failed;
     }
 
diff --git a/drivers/pcmcia/ds.c b/drivers/pcmcia/ds.c
index 5fd2948..a2649c7 100644
--- a/drivers/pcmcia/ds.c
+++ b/drivers/pcmcia/ds.c
@@ -546,7 +546,6 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
 			p_dev->function_config = tmp_dev->function_config;
 			p_dev->io = tmp_dev->io;
 			p_dev->irq = tmp_dev->irq;
-			p_dev->irq_v = tmp_dev->irq_v;
 			kref_get(&p_dev->function_config->ref);
 		}
 
@@ -571,7 +570,7 @@ struct pcmcia_device *pcmcia_device_add(struct pcmcia_socket *s, unsigned int fu
 
 	dev_printk(KERN_NOTICE, &p_dev->dev,
 		   "pcmcia: registering new device %s (IRQ: %d)\n",
-		   p_dev->devname, p_dev->irq_v);
+		   p_dev->devname, p_dev->irq);
 
 	pcmcia_device_query(p_dev);
 
diff --git a/drivers/pcmcia/pcmcia_resource.c b/drivers/pcmcia/pcmcia_resource.c
index 8dce223..f355c5a 100644
--- a/drivers/pcmcia/pcmcia_resource.c
+++ b/drivers/pcmcia/pcmcia_resource.c
@@ -408,41 +408,6 @@ out:
 } /* pcmcia_release_io */
 
 
-static int pcmcia_release_irq(struct pcmcia_device *p_dev, irq_req_t *req)
-{
-	struct pcmcia_socket *s = p_dev->socket;
-	config_t *c;
-	int ret = -EINVAL;
-
-	mutex_lock(&s->ops_mutex);
-
-	c = p_dev->function_config;
-
-	if (!p_dev->_irq)
-		goto out;
-
-	p_dev->_irq = 0;
-
-	if (c->state & CONFIG_LOCKED)
-		goto out;
-
-	if (s->pcmcia_irq != req->AssignedIRQ) {
-		dev_dbg(&s->dev, "IRQ must match assigned one\n");
-		goto out;
-	}
-
-	if (req->Handler)
-		free_irq(req->AssignedIRQ, p_dev->priv);
-
-	ret = 0;
-
-out:
-	mutex_unlock(&s->ops_mutex);
-
-	return ret;
-} /* pcmcia_release_irq */
-
-
 int pcmcia_release_window(struct pcmcia_device *p_dev, window_handle_t wh)
 {
 	struct pcmcia_socket *s = p_dev->socket;
@@ -681,61 +646,66 @@ out:
 EXPORT_SYMBOL(pcmcia_request_io);
 
 
-/** pcmcia_request_irq
+/**
+ * pcmcia_request_irq() - attempt to request a IRQ for a PCMCIA device
  *
- * Request_irq() reserves an irq for this client.
+ * pcmcia_request_irq() is a wrapper around request_irq which will allow
+ * the PCMCIA core to clean up the registration in pcmcia_disable_device().
+ * Drivers are free to use request_irq() directly, but then they need to
+ * call free_irq themselfves, too. Also, only IRQF_SHARED capable IRQ
+ * handlers are allowed.
  */
-
-int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req)
+int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
+				    irq_handler_t handler)
 {
-	struct pcmcia_socket *s = p_dev->socket;
-	config_t *c;
-	int ret = -EINVAL, irq = p_dev->irq_v;
-	int type = IRQF_SHARED;
+	int ret;
 
-	mutex_lock(&s->ops_mutex);
+	if (!p_dev->irq)
+		return -EINVAL;
 
-	if (!(s->state & SOCKET_PRESENT)) {
-		dev_dbg(&s->dev, "No card present\n");
-		goto out;
-	}
-	c = p_dev->function_config;
-	if (c->state & CONFIG_LOCKED) {
-		dev_dbg(&s->dev, "Configuration is locked\n");
-		goto out;
-	}
+	ret = request_irq(p_dev->irq, handler, IRQF_SHARED,
+			p_dev->devname, p_dev->priv);
+	if (!ret)
+		p_dev->_irq = 1;
 
-	if (!irq) {
-		dev_dbg(&s->dev, "no IRQ available\n");
-		goto out;
-	}
+	return ret;
+}
+EXPORT_SYMBOL(pcmcia_request_irq);
 
-	if (!(req->Attributes & IRQ_TYPE_DYNAMIC_SHARING)) {
-		req->Attributes |= IRQ_TYPE_DYNAMIC_SHARING;
-		dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: the driver "
-			"needs updating to supported shared IRQ lines.\n");
-	}
 
-	if (req->Handler) {
-		ret = request_irq(irq, req->Handler, type,
-				  p_dev->devname, p_dev->priv);
-		if (ret) {
-			dev_printk(KERN_INFO, &s->dev,
-				"request_irq() failed\n");
-			goto out;
-		}
-	}
+/**
+ * pcmcia_request_exclusive_irq() - attempt to request an exclusive IRQ first
+ *
+ * pcmcia_request_exclusive_irq() is a wrapper around request_irq which
+ * attempts first to request an exclusive IRQ. If it fails, it also accepts
+ * a shared IRQ, but prints out a warning. PCMCIA drivers should allow for
+ * IRQ sharing and either use request_irq directly (then they need to call
+ * free_irq themselves, too), or the pcmcia_request_irq() function.
+ */
+int __must_check
+pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev, irq_handler_t handler)
+{
+	int ret;
 
-	req->AssignedIRQ = irq;
+	if (!p_dev->irq)
+		return -EINVAL;
 
-	p_dev->_irq = 1;
+	ret = request_irq(p_dev->irq, handler, 0, p_dev->devname, p_dev->priv);
+	if (ret) {
+		ret = pcmcia_request_irq(p_dev, handler);
+		dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: "
+			"request for exclusive IRQ could not be fulfilled.\n");
+		dev_printk(KERN_WARNING, &p_dev->dev, "pcmcia: the driver "
+			"needs updating to supported shared IRQ lines.\n");
+	}
+	if (ret)
+		dev_printk(KERN_INFO, &p_dev->dev, "request_irq() failed\n");
+	else
+		p_dev->_irq = 1;
 
-	ret = 0;
-out:
-	mutex_unlock(&s->ops_mutex);
 	return ret;
-} /* pcmcia_request_irq */
-EXPORT_SYMBOL(pcmcia_request_irq);
+} /* pcmcia_request_exclusive_irq */
+EXPORT_SYMBOL(pcmcia_request_exclusive_irq);
 
 
 #ifdef CONFIG_PCMCIA_PROBE
@@ -779,7 +749,7 @@ static int pcmcia_setup_isa_irq(struct pcmcia_device *p_dev, int type)
 				  p_dev);
 		if (!ret) {
 			free_irq(irq, p_dev);
-			p_dev->irq_v = s->pcmcia_irq = irq;
+			p_dev->irq = s->pcmcia_irq = irq;
 			pcmcia_used_irq[irq]++;
 			break;
 		}
@@ -820,12 +790,12 @@ int pcmcia_setup_irq(struct pcmcia_device *p_dev)
 {
 	struct pcmcia_socket *s = p_dev->socket;
 
-	if (p_dev->irq_v)
+	if (p_dev->irq)
 		return 0;
 
 	/* already assigned? */
 	if (s->pcmcia_irq) {
-		p_dev->irq_v = s->pcmcia_irq;
+		p_dev->irq = s->pcmcia_irq;
 		return 0;
 	}
 
@@ -839,7 +809,7 @@ int pcmcia_setup_irq(struct pcmcia_device *p_dev)
 
 	/* but use the PCI irq otherwise */
 	if (s->pci_irq) {
-		p_dev->irq_v = s->pcmcia_irq = s->pci_irq;
+		p_dev->irq = s->pcmcia_irq = s->pci_irq;
 		return 0;
 	}
 
@@ -947,7 +917,8 @@ void pcmcia_disable_device(struct pcmcia_device *p_dev)
 {
 	pcmcia_release_configuration(p_dev);
 	pcmcia_release_io(p_dev, &p_dev->io);
-	pcmcia_release_irq(p_dev, &p_dev->irq);
+	if (p_dev->_irq)
+		free_irq(p_dev->irq, p_dev->priv);
 	if (p_dev->win)
 		pcmcia_release_window(p_dev, p_dev->win);
 }
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index 528733b..c1de4ba 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -105,7 +105,6 @@ static int aha152x_probe(struct pcmcia_device *link)
     link->io.NumPorts1 = 0x20;
     link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
     link->io.IOAddrLines = 10;
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
     link->conf.Present = PRESENT_OPTION;
@@ -160,8 +159,7 @@ static int aha152x_config_cs(struct pcmcia_device *link)
     if (ret)
 	    goto failed;
 
-    ret = pcmcia_request_irq(link, &link->irq);
-    if (ret)
+    if (!link->irq)
 	    goto failed;
 
     ret = pcmcia_request_configuration(link, &link->conf);
@@ -172,7 +170,7 @@ static int aha152x_config_cs(struct pcmcia_device *link)
     memset(&s, 0, sizeof(s));
     s.conf        = "PCMCIA setup";
     s.io_port     = link->io.BasePort1;
-    s.irq         = link->irq.AssignedIRQ;
+    s.irq         = link->irq;
     s.scsiid      = host_id;
     s.reconnect   = reconnect;
     s.parity      = parity;
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 9140406..8cb6d71 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -88,7 +88,6 @@ static int fdomain_probe(struct pcmcia_device *link)
 	link->io.NumPorts1 = 0x10;
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
 	link->io.IOAddrLines = 10;
-	link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 	link->conf.Present = PRESENT_OPTION;
@@ -133,8 +132,7 @@ static int fdomain_config(struct pcmcia_device *link)
     if (ret)
 	    goto failed;
 
-    ret = pcmcia_request_irq(link, &link->irq);
-    if (ret)
+    if (!link->irq)
 	    goto failed;
     ret = pcmcia_request_configuration(link, &link->conf);
     if (ret)
@@ -144,7 +142,7 @@ static int fdomain_config(struct pcmcia_device *link)
     release_region(link->io.BasePort1, link->io.NumPorts1);
 
     /* Set configuration options for the fdomain driver */
-    sprintf(str, "%d,%d", link->io.BasePort1, link->irq.AssignedIRQ);
+    sprintf(str, "%d,%d", link->io.BasePort1, link->irq);
     fdomain_setup(str);
 
     host = __fdomain_16x0_detect(&fdomain_driver_template);
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 0212464..24c78ed 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1563,13 +1563,6 @@ static int nsp_cs_probe(struct pcmcia_device *link)
 	link->io.Attributes1	 = IO_DATA_PATH_WIDTH_AUTO;
 	link->io.IOAddrLines	 = 10;	/* not used */
 
-	/* Interrupt setup */
-	link->irq.Attributes	 = IRQ_TYPE_EXCLUSIVE;
-
-	/* Interrupt handler */
-	link->irq.Handler	 = &nspintr;
-	link->irq.Attributes     |= IRQF_SHARED;
-
 	/* General socket configuration */
 	link->conf.Attributes	 = CONF_ENABLE_IRQ;
 	link->conf.IntType	 = INT_MEMORY_AND_IO;
@@ -1646,8 +1639,7 @@ static int nsp_cs_config_check(struct pcmcia_device *p_dev,
 		}
 
 		/* Do we need to allocate an interrupt? */
-		if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-			p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 		/* IO window settings */
 		p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -1720,10 +1712,8 @@ static int nsp_cs_config(struct pcmcia_device *link)
 	if (ret)
 		goto cs_failed;
 
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		if (pcmcia_request_irq(link, &link->irq))
-			goto cs_failed;
-	}
+	if (pcmcia_request_irq(link, nspintr))
+		goto cs_failed;
 
 	ret = pcmcia_request_configuration(link, &link->conf);
 	if (ret)
@@ -1741,7 +1731,7 @@ static int nsp_cs_config(struct pcmcia_device *link)
 	/* Set port and IRQ */
 	data->BaseAddress = link->io.BasePort1;
 	data->NumAddress  = link->io.NumPorts1;
-	data->IrqNumber   = link->irq.AssignedIRQ;
+	data->IrqNumber   = link->irq;
 
 	nsp_dbg(NSP_DEBUG_INIT, "I/O[0x%x+0x%x] IRQ %d",
 		data->BaseAddress, data->NumAddress, data->IrqNumber);
@@ -1775,7 +1765,7 @@ static int nsp_cs_config(struct pcmcia_device *link)
 		printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
 	}
 	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		printk(", irq %d", link->irq.AssignedIRQ);
+		printk(", irq %d", link->irq);
 	}
 	if (link->io.NumPorts1) {
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index f85f094..c3a4428 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -161,7 +161,6 @@ static int qlogic_probe(struct pcmcia_device *link)
 	link->io.NumPorts1 = 16;
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
 	link->io.IOAddrLines = 10;
-	link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 	link->conf.Present = PRESENT_OPTION;
@@ -209,8 +208,7 @@ static int qlogic_config(struct pcmcia_device * link)
 	if (ret)
 		goto failed;
 
-	ret = pcmcia_request_irq(link, &link->irq);
-	if (ret)
+	if (!link->irq)
 		goto failed;
 
 	ret = pcmcia_request_configuration(link, &link->conf);
@@ -227,10 +225,10 @@ static int qlogic_config(struct pcmcia_device * link)
 	/* The KXL-810AN has a bigger IO port window */
 	if (link->io.NumPorts1 == 32)
 		host = qlogic_detect(&qlogicfas_driver_template, link,
-			link->io.BasePort1 + 16, link->irq.AssignedIRQ);
+			link->io.BasePort1 + 16, link->irq);
 	else
 		host = qlogic_detect(&qlogicfas_driver_template, link,
-			link->io.BasePort1, link->irq.AssignedIRQ);
+			link->io.BasePort1, link->irq);
 	
 	if (!host) {
 		printk(KERN_INFO "%s: no SCSI devices found\n", qlogic_name);
@@ -258,7 +256,7 @@ static void qlogic_release(struct pcmcia_device *link)
 
 	scsi_remove_host(info->host);
 
-	free_irq(link->irq.AssignedIRQ, info->host);
+	free_irq(link->irq, info->host);
 	pcmcia_disable_device(link);
 
 	scsi_host_put(info->host);
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index e7564d8..6eacf4c 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -719,8 +719,7 @@ SYM53C500_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	ret = pcmcia_request_irq(link, &link->irq);
-	if (ret)
+	if (!link->irq)
 		goto failed;
 
 	ret = pcmcia_request_configuration(link, &link->conf);
@@ -752,7 +751,7 @@ SYM53C500_config(struct pcmcia_device *link)
 	*	0x320, 0x330, 0x340, 0x350
 	*/
 	port_base = link->io.BasePort1;
-	irq_level = link->irq.AssignedIRQ;
+	irq_level = link->irq;
 
 	DEB(printk("SYM53C500: port_base=0x%x, irq=%d, fast_pio=%d\n",
 	    port_base, irq_level, USE_FAST_PIO);)
@@ -866,7 +865,6 @@ SYM53C500_probe(struct pcmcia_device *link)
 	link->io.NumPorts1 = 16;
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
 	link->io.IOAddrLines = 10;
-	link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 8cfa5b1..6459252 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -343,7 +343,6 @@ static int serial_probe(struct pcmcia_device *link)
 
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
 	link->io.NumPorts1 = 8;
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	if (do_sound) {
 		link->conf.Attributes |= CONF_ENABLE_SPKR;
@@ -486,7 +485,7 @@ static int simple_config(struct pcmcia_device *link)
 		}
 		if (info->slave) {
 			return setup_serial(link, info, port,
-					    link->irq.AssignedIRQ);
+					    link->irq);
 		}
 	}
 
@@ -507,10 +506,6 @@ static int simple_config(struct pcmcia_device *link)
 	return -1;
 
 found_port:
-	i = pcmcia_request_irq(link, &link->irq);
-	if (i != 0)
-		link->irq.AssignedIRQ = 0;
-
 	if (info->multi && (info->manfid == MANFID_3COM))
 		link->conf.ConfigIndex &= ~(0x08);
 
@@ -523,7 +518,7 @@ found_port:
 	i = pcmcia_request_configuration(link, &link->conf);
 	if (i != 0)
 		return -1;
-	return setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ);
+	return setup_serial(link, info, link->io.BasePort1, link->irq);
 }
 
 static int multi_config_check(struct pcmcia_device *p_dev,
@@ -586,13 +581,9 @@ static int multi_config(struct pcmcia_device *link)
 		}
 	}
 
-	i = pcmcia_request_irq(link, &link->irq);
-	if (i != 0) {
-		/* FIXME: comment does not fit, error handling does not fit */
-		printk(KERN_NOTICE
-		       "serial_cs: no usable port range found, giving up\n");
-		link->irq.AssignedIRQ = 0;
-	}
+	if (!link->irq)
+		dev_warn(&link->dev,
+			"serial_cs: no usable IRQ found, continuing...\n");
 
 	/*
 	 * Apply any configuration quirks.
@@ -615,11 +606,11 @@ static int multi_config(struct pcmcia_device *link)
 		if (link->conf.ConfigIndex == 1 ||
 		    link->conf.ConfigIndex == 3) {
 			err = setup_serial(link, info, base2,
-					link->irq.AssignedIRQ);
+					link->irq);
 			base2 = link->io.BasePort1;
 		} else {
 			err = setup_serial(link, info, link->io.BasePort1,
-					link->irq.AssignedIRQ);
+					link->irq);
 		}
 		info->c950ctrl = base2;
 
@@ -633,10 +624,10 @@ static int multi_config(struct pcmcia_device *link)
 		return 0;
 	}
 
-	setup_serial(link, info, link->io.BasePort1, link->irq.AssignedIRQ);
+	setup_serial(link, info, link->io.BasePort1, link->irq);
 	for (i = 0; i < info->multi - 1; i++)
 		setup_serial(link, info, base2 + (8 * i),
-				link->irq.AssignedIRQ);
+				link->irq);
 	return 0;
 }
 
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 80ff7d9..bc9bdb2 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -490,7 +490,7 @@ static int ssb_devices_register(struct ssb_bus *bus)
 			break;
 		case SSB_BUSTYPE_PCMCIA:
 #ifdef CONFIG_SSB_PCMCIAHOST
-			sdev->irq = bus->host_pcmcia->irq.AssignedIRQ;
+			sdev->irq = bus->host_pcmcia->irq;
 			dev->parent = &bus->host_pcmcia->dev;
 #endif
 			break;
diff --git a/drivers/staging/comedi/drivers/cb_das16_cs.c b/drivers/staging/comedi/drivers/cb_das16_cs.c
index 5632991..e0352c6 100644
--- a/drivers/staging/comedi/drivers/cb_das16_cs.c
+++ b/drivers/staging/comedi/drivers/cb_das16_cs.c
@@ -180,12 +180,12 @@ static int das16cs_attach(struct comedi_device *dev,
 	}
 	printk("\n");
 
-	ret = request_irq(link->irq.AssignedIRQ, das16cs_interrupt,
+	ret = request_irq(link->irq, das16cs_interrupt,
 			  IRQF_SHARED, "cb_das16_cs", dev);
 	if (ret < 0) {
 		return ret;
 	}
-	dev->irq = link->irq.AssignedIRQ;
+	dev->irq = link->irq;
 	printk("irq=%u ", dev->irq);
 
 	dev->board_ptr = das16cs_probe(dev, link);
@@ -702,10 +702,6 @@ static int das16cs_pcmcia_attach(struct pcmcia_device *link)
 	link->priv = local;
 
 	/* Initialize the pcmcia_device structure */
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = NULL;
-
 	link->conf.Attributes = 0;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -740,8 +736,7 @@ static int das16cs_pcmcia_config_loop(struct pcmcia_device *p_dev,
 		return -EINVAL;
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -780,16 +775,9 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	/*
-	   Allocate an interrupt line.  Note that this does not assign a
-	   handler to the interrupt, unless the 'Handler' member of the
-	   irq structure is initialized.
-	 */
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	if (!link->irq)
+		goto failed;
+
 	/*
 	   This actually configures the PCMCIA socket -- setting up
 	   the I/O windows and the interrupt mapping, and putting the
@@ -811,7 +799,7 @@ static void das16cs_pcmcia_config(struct pcmcia_device *link)
 	printk(KERN_INFO "%s: index 0x%02x",
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %u", link->irq.AssignedIRQ);
+		printk(", irq %u", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1 + link->io.NumPorts1 - 1);
diff --git a/drivers/staging/comedi/drivers/das08_cs.c b/drivers/staging/comedi/drivers/das08_cs.c
index 9164ce1..bd69c4f 100644
--- a/drivers/staging/comedi/drivers/das08_cs.c
+++ b/drivers/staging/comedi/drivers/das08_cs.c
@@ -172,10 +172,6 @@ static int das08_pcmcia_attach(struct pcmcia_device *link)
 	local->link = link;
 	link->priv = local;
 
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-	link->irq.Handler = NULL;
-
 	/*
 	   General socket configuration defaults can go here.  In this
 	   client, we assume very little, and rely on the CIS for almost
@@ -229,8 +225,7 @@ static int das08_pcmcia_config_loop(struct pcmcia_device *p_dev,
 		return -ENODEV;
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -277,11 +272,8 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	if (!link->irq)
+		goto failed;
 
 	/*
 	   This actually configures the PCMCIA socket -- setting up
@@ -304,7 +296,7 @@ static void das08_pcmcia_config(struct pcmcia_device *link)
 	printk(KERN_INFO "%s: index 0x%02x",
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %u", link->irq.AssignedIRQ);
+		printk(", irq %u", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1 + link->io.NumPorts1 - 1);
diff --git a/drivers/staging/comedi/drivers/ni_daq_700.c b/drivers/staging/comedi/drivers/ni_daq_700.c
index 7ea6453..072bc4b 100644
--- a/drivers/staging/comedi/drivers/ni_daq_700.c
+++ b/drivers/staging/comedi/drivers/ni_daq_700.c
@@ -380,7 +380,7 @@ static int dio700_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			return -EIO;
 		iobase = link->io.BasePort1;
 #ifdef incomplete
-		irq = link->irq.AssignedIRQ;
+		irq = link->irq;
 #endif
 		break;
 	default:
@@ -502,10 +502,6 @@ static int dio700_cs_attach(struct pcmcia_device *link)
 	local->link = link;
 	link->priv = local;
 
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = NULL;
-
 	/*
 	   General socket configuration defaults can go here.  In this
 	   client, we assume very little, and rely on the CIS for almost
@@ -577,8 +573,7 @@ static int dio700_pcmcia_config_loop(struct pcmcia_device *p_dev,
 	}
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -639,16 +634,8 @@ static void dio700_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	/*
-	   Allocate an interrupt line.  Note that this does not assign a
-	   handler to the interrupt, unless the 'Handler' member of the
-	   irq structure is initialized.
-	 */
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	if (!link->irq)
+		goto failed;
 
 	/*
 	   This actually configures the PCMCIA socket -- setting up
@@ -671,7 +658,7 @@ static void dio700_config(struct pcmcia_device *link)
 	printk(KERN_INFO "%s: index 0x%02x",
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %d", link->irq.AssignedIRQ);
+		printk(", irq %d", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1 + link->io.NumPorts1 - 1);
diff --git a/drivers/staging/comedi/drivers/ni_daq_dio24.c b/drivers/staging/comedi/drivers/ni_daq_dio24.c
index ddc312b..2259fb4 100644
--- a/drivers/staging/comedi/drivers/ni_daq_dio24.c
+++ b/drivers/staging/comedi/drivers/ni_daq_dio24.c
@@ -131,7 +131,7 @@ static int dio24_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 			return -EIO;
 		iobase = link->io.BasePort1;
 #ifdef incomplete
-		irq = link->irq.AssignedIRQ;
+		irq = link->irq;
 #endif
 		break;
 	default:
@@ -253,10 +253,6 @@ static int dio24_cs_attach(struct pcmcia_device *link)
 	local->link = link;
 	link->priv = local;
 
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = NULL;
-
 	/*
 	   General socket configuration defaults can go here.  In this
 	   client, we assume very little, and rely on the CIS for almost
@@ -328,8 +324,7 @@ static int dio24_pcmcia_config_loop(struct pcmcia_device *p_dev,
 	}
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -390,16 +385,8 @@ static void dio24_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	/*
-	   Allocate an interrupt line.  Note that this does not assign a
-	   handler to the interrupt, unless the 'Handler' member of the
-	   irq structure is initialized.
-	 */
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	if (!link->irq)
+		goto failed;
 
 	/*
 	   This actually configures the PCMCIA socket -- setting up
@@ -422,7 +409,7 @@ static void dio24_config(struct pcmcia_device *link)
 	printk(KERN_INFO "%s: index 0x%02x",
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %d", link->irq.AssignedIRQ);
+		printk(", irq %d", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1 + link->io.NumPorts1 - 1);
diff --git a/drivers/staging/comedi/drivers/ni_labpc_cs.c b/drivers/staging/comedi/drivers/ni_labpc_cs.c
index 6e4ed0d..907b2ae 100644
--- a/drivers/staging/comedi/drivers/ni_labpc_cs.c
+++ b/drivers/staging/comedi/drivers/ni_labpc_cs.c
@@ -144,7 +144,7 @@ static int labpc_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 		if (!link)
 			return -EIO;
 		iobase = link->io.BasePort1;
-		irq = link->irq.AssignedIRQ;
+		irq = link->irq;
 		break;
 	default:
 		printk("bug! couldn't determine board type\n");
@@ -229,10 +229,6 @@ static int labpc_cs_attach(struct pcmcia_device *link)
 	local->link = link;
 	link->priv = local;
 
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = NULL;
-
 	/*
 	   General socket configuration defaults can go here.  In this
 	   client, we assume very little, and rely on the CIS for almost
@@ -306,9 +302,7 @@ static int labpc_pcmcia_config_loop(struct pcmcia_device *p_dev,
 	}
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |=
-			(CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ);
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -368,16 +362,8 @@ static void labpc_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	/*
-	   Allocate an interrupt line.  Note that this does not assign a
-	   handler to the interrupt, unless the 'Handler' member of the
-	   irq structure is initialized.
-	 */
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	if (!link->irq)
+		goto failed;
 
 	/*
 	   This actually configures the PCMCIA socket -- setting up
@@ -400,7 +386,7 @@ static void labpc_config(struct pcmcia_device *link)
 	printk(KERN_INFO "%s: index 0x%02x",
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %d", link->irq.AssignedIRQ);
+		printk(", irq %d", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1 + link->io.NumPorts1 - 1);
diff --git a/drivers/staging/comedi/drivers/ni_mio_cs.c b/drivers/staging/comedi/drivers/ni_mio_cs.c
index dc4849a..a6007ab 100644
--- a/drivers/staging/comedi/drivers/ni_mio_cs.c
+++ b/drivers/staging/comedi/drivers/ni_mio_cs.c
@@ -272,7 +272,6 @@ static int cs_attach(struct pcmcia_device *link)
 {
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_16;
 	link->io.NumPorts1 = 16;
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 
@@ -344,10 +343,8 @@ static void mio_cs_config(struct pcmcia_device *link)
 		return;
 	}
 
-	ret = pcmcia_request_irq(link, &link->irq);
-	if (ret) {
-		printk("pcmcia_request_irq() returned error: %i\n", ret);
-	}
+	if (!link->irq)
+		dev_info(&link->dev, "no IRQ available\n");
 
 	ret = pcmcia_request_configuration(link, &link->conf);
 
@@ -369,7 +366,7 @@ static int mio_cs_attach(struct comedi_device *dev, struct comedi_devconfig *it)
 	dev->driver = &driver_ni_mio_cs;
 	dev->iobase = link->io.BasePort1;
 
-	irq = link->irq.AssignedIRQ;
+	irq = link->irq;
 
 	printk("comedi%d: %s: DAQCard: io 0x%04lx, irq %u, ",
 	       dev->minor, dev->driver->driver_name, dev->iobase, irq);
diff --git a/drivers/staging/comedi/drivers/quatech_daqp_cs.c b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
index 3325f24..7aa17f9 100644
--- a/drivers/staging/comedi/drivers/quatech_daqp_cs.c
+++ b/drivers/staging/comedi/drivers/quatech_daqp_cs.c
@@ -1040,10 +1040,6 @@ static int daqp_cs_attach(struct pcmcia_device *link)
 	local->link = link;
 	link->priv = local;
 
-	/* Interrupt setup */
-	link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-	link->irq.Handler = daqp_interrupt;
-
 	/*
 	   General socket configuration defaults can go here.  In this
 	   client, we assume very little, and rely on the CIS for almost
@@ -1105,8 +1101,7 @@ static int daqp_pcmcia_config_loop(struct pcmcia_device *p_dev,
 		return -ENODEV;
 
 	/* Do we need to allocate an interrupt? */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -1144,16 +1139,9 @@ static void daqp_cs_config(struct pcmcia_device *link)
 		goto failed;
 	}
 
-	/*
-	   Allocate an interrupt line.  Note that this does not assign a
-	   handler to the interrupt, unless the 'Handler' member of the
-	   irq structure is initialized.
-	 */
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	}
+	ret = pcmcia_request_irq(link, daqp_interrupt);
+	if (ret)
+		goto failed;
 
 	/*
 	   This actually configures the PCMCIA socket -- setting up
@@ -1180,7 +1168,7 @@ static void daqp_cs_config(struct pcmcia_device *link)
 	printk(KERN_INFO "%s: index 0x%02x",
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Attributes & CONF_ENABLE_IRQ)
-		printk(", irq %u", link->irq.AssignedIRQ);
+		printk(", irq %u", link->irq);
 	if (link->io.NumPorts1)
 		printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 		       link->io.BasePort1 + link->io.NumPorts1 - 1);
diff --git a/drivers/staging/netwave/netwave_cs.c b/drivers/staging/netwave/netwave_cs.c
index 3875a72..449e6a5 100644
--- a/drivers/staging/netwave/netwave_cs.c
+++ b/drivers/staging/netwave/netwave_cs.c
@@ -382,10 +382,6 @@ static int netwave_probe(struct pcmcia_device *link)
        link->io.Attributes2 = IO_DATA_PATH_WIDTH_16; */
     link->io.IOAddrLines = 5;
     
-    /* Interrupt setup */
-    link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-    link->irq.Handler = &netwave_interrupt;
-    
     /* General socket configuration */
     link->conf.Attributes = CONF_ENABLE_IRQ;
     link->conf.IntType = INT_MEMORY_AND_IO;
@@ -732,7 +728,7 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
      *  Now allocate an interrupt line.  Note that this does not
      *  actually assign a handler to the interrupt.
      */
-    ret = pcmcia_request_irq(link, &link->irq);
+    ret = pcmcia_request_irq(link, netwave_interrupt);
     if (ret)
 	    goto failed;
 
@@ -767,7 +763,7 @@ static int netwave_pcmcia_config(struct pcmcia_device *link) {
     ramBase = ioremap(req.Base, 0x8000);
     priv->ramBase = ramBase;
 
-    dev->irq = link->irq.AssignedIRQ;
+    dev->irq = link->irq;
     dev->base_addr = link->io.BasePort1;
     SET_NETDEV_DEV(dev, &link->dev);
 
diff --git a/drivers/staging/wavelan/wavelan_cs.c b/drivers/staging/wavelan/wavelan_cs.c
index 04f691d..37fa855 100644
--- a/drivers/staging/wavelan/wavelan_cs.c
+++ b/drivers/staging/wavelan/wavelan_cs.c
@@ -3850,12 +3850,8 @@ wv_pcmcia_config(struct pcmcia_device *	link)
       if (i != 0)
 	  break;
 
-      /*
-       * Now allocate an interrupt line.  Note that this does not
-       * actually assign a handler to the interrupt.
-       */
-      i = pcmcia_request_irq(link, &link->irq);
-      if (i != 0)
+      i = pcmcia_request_interrupt(link, wavelan_interrupt);
+      if (!i)
 	  break;
 
       /*
@@ -3890,7 +3886,7 @@ wv_pcmcia_config(struct pcmcia_device *	link)
 	  break;
 
       /* Feed device with this info... */
-      dev->irq = link->irq.AssignedIRQ;
+      dev->irq = link->irq;
       dev->base_addr = link->io.BasePort1;
       netif_start_queue(dev);
 
@@ -4437,10 +4433,6 @@ wavelan_probe(struct pcmcia_device *p_dev)
   p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
   p_dev->io.IOAddrLines = 3;
 
-  /* Interrupt setup */
-  p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING;
-  p_dev->irq.Handler = wavelan_interrupt;
-
   /* General socket configuration */
   p_dev->conf.Attributes = CONF_ENABLE_IRQ;
   p_dev->conf.IntType = INT_MEMORY_AND_IO;
@@ -4487,7 +4479,6 @@ wavelan_probe(struct pcmcia_device *p_dev)
 
   ret = wv_hw_config(dev);
   if (ret) {
-	  dev->irq = 0;
 	  pcmcia_disable_device(p_dev);
 	  return ret;
   }
diff --git a/drivers/staging/wlags49_h2/wl_cs.c b/drivers/staging/wlags49_h2/wl_cs.c
index 9da42e6..c9d99d8 100644
--- a/drivers/staging/wlags49_h2/wl_cs.c
+++ b/drivers/staging/wlags49_h2/wl_cs.c
@@ -156,15 +156,12 @@ static int wl_adapter_attach(struct pcmcia_device *link)
     link->io.NumPorts1      = HCF_NUM_IO_PORTS;
     link->io.Attributes1    = IO_DATA_PATH_WIDTH_16;
     link->io.IOAddrLines    = 6;
-    link->irq.Attributes    = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
-    link->irq.IRQInfo1      = IRQ_INFO2_VALID | IRQ_LEVEL_ID;
-    link->irq.Handler       = &wl_isr;
     link->conf.Attributes   = CONF_ENABLE_IRQ;
     link->conf.IntType      = INT_MEMORY_AND_IO;
     link->conf.ConfigIndex  = 5;
     link->conf.Present      = PRESENT_OPTION;
 
-    link->priv = link->irq.Instance = dev;
+    link->priv = dev;
     lp = wl_priv(dev);
     lp->link = link;
 
@@ -318,11 +315,11 @@ void wl_adapter_insert( struct pcmcia_device *link )
     link->conf.Attributes |= CONF_ENABLE_IRQ;
 
     CS_CHECK(RequestIO, pcmcia_request_io(link, &link->io));
-    CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
+    CS_CHECK(RequestIRQ, pcmcia_request_irq(link, wl_isr));
     CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
 
 
-    dev->irq        = link->irq.AssignedIRQ;
+    dev->irq        = link->irq;
     dev->base_addr  = link->io.BasePort1;
 
     SET_NETDEV_DEV(dev, &handle_to_dev(link));
diff --git a/drivers/usb/host/sl811_cs.c b/drivers/usb/host/sl811_cs.c
index 39d253e..a712788 100644
--- a/drivers/usb/host/sl811_cs.c
+++ b/drivers/usb/host/sl811_cs.c
@@ -163,8 +163,7 @@ static int sl811_cs_config_check(struct pcmcia_device *p_dev,
 			dflt->vpp1.param[CISTPL_POWER_VNOM]/10000;
 
 	/* we need an interrupt */
-	if (cfg->irq.IRQInfo1 || dflt->irq.IRQInfo1)
-		p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
+	p_dev->conf.Attributes |= CONF_ENABLE_IRQ;
 
 	/* IO window settings */
 	p_dev->io.NumPorts1 = p_dev->io.NumPorts2 = 0;
@@ -197,11 +196,8 @@ static int sl811_cs_config(struct pcmcia_device *link)
 	/* require an IRQ and two registers */
 	if (!link->io.NumPorts1 || link->io.NumPorts1 < 2)
 		goto failed;
-	if (link->conf.Attributes & CONF_ENABLE_IRQ) {
-		ret = pcmcia_request_irq(link, &link->irq);
-		if (ret)
-			goto failed;
-	} else
+
+	if (!link->irq)
 		goto failed;
 
 	ret = pcmcia_request_configuration(link, &link->conf);
@@ -216,12 +212,12 @@ static int sl811_cs_config(struct pcmcia_device *link)
 	       dev->node.dev_name, link->conf.ConfigIndex);
 	if (link->conf.Vpp)
 		printk(", Vpp %d.%d", link->conf.Vpp/10, link->conf.Vpp%10);
-	printk(", irq %d", link->irq.AssignedIRQ);
+	printk(", irq %d", link->irq);
 	printk(", io 0x%04x-0x%04x", link->io.BasePort1,
 	       link->io.BasePort1+link->io.NumPorts1-1);
 	printk("\n");
 
-	if (sl811_hc_init(parent, link->io.BasePort1, link->irq.AssignedIRQ)
+	if (sl811_hc_init(parent, link->io.BasePort1, link->irq)
 			< 0) {
 failed:
 		printk(KERN_WARNING "sl811_cs_config failed\n");
@@ -241,10 +237,6 @@ static int sl811_cs_probe(struct pcmcia_device *link)
 	local->p_dev = link;
 	link->priv = local;
 
-	/* Initialize */
-	link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-	link->irq.Handler = NULL;
-
 	link->conf.Attributes = 0;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 
diff --git a/include/pcmcia/cs.h b/include/pcmcia/cs.h
index af61571..a04e6ca 100644
--- a/include/pcmcia/cs.h
+++ b/include/pcmcia/cs.h
@@ -114,13 +114,6 @@ typedef struct io_req_t {
 #define IO_DATA_PATH_WIDTH_16	0x08
 #define IO_DATA_PATH_WIDTH_AUTO	0x10
 
-/* For RequestIRQ and ReleaseIRQ */
-typedef struct irq_req_t {
-	u_int		Attributes;
-	u_int		AssignedIRQ;
-	irq_handler_t	Handler;
-} irq_req_t;
-
 /* Attributes for RequestIRQ and ReleaseIRQ */
 #define IRQ_TYPE			0x03
 #define IRQ_TYPE_EXCLUSIVE		0x00
diff --git a/include/pcmcia/ds.h b/include/pcmcia/ds.h
index 52ebe75..d18330b 100644
--- a/include/pcmcia/ds.h
+++ b/include/pcmcia/ds.h
@@ -91,12 +91,11 @@ struct pcmcia_device {
 	dev_node_t		*dev_node;
 	u_int			open;
 	io_req_t		io;
-	irq_req_t		irq;
 	config_req_t		conf;
 	window_handle_t		win;
 
 	/* device setup */
-	unsigned int		irq_v; /* do not use directly yet */
+	unsigned int		irq;
 
 	/* Is the device suspended? */
 	u16			suspended:1;
@@ -194,7 +193,13 @@ int pcmcia_access_configuration_register(struct pcmcia_device *p_dev,
 
 /* device configuration */
 int pcmcia_request_io(struct pcmcia_device *p_dev, io_req_t *req);
-int pcmcia_request_irq(struct pcmcia_device *p_dev, irq_req_t *req);
+
+int __must_check __deprecated
+pcmcia_request_exclusive_irq(struct pcmcia_device *p_dev,
+				irq_handler_t handler);
+int __must_check pcmcia_request_irq(struct pcmcia_device *p_dev,
+				irq_handler_t handler);
+
 int pcmcia_request_configuration(struct pcmcia_device *p_dev,
 				 config_req_t *req);
 
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index dcf8539..60fddf3 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -142,11 +142,6 @@ static int snd_pdacf_probe(struct pcmcia_device *link)
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
 	link->io.NumPorts1 = 16;
 
-	link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-	/* FIXME: This driver should be updated to allow for dynamic IRQ sharing */
-	/* link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING; */
-
-	link->irq.Handler = pdacf_interrupt;
 	link->conf.Attributes = CONF_ENABLE_IRQ | CONF_ENABLE_PULSE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 	link->conf.ConfigIndex = 1;
@@ -228,7 +223,7 @@ static int pdacf_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	ret = pcmcia_request_irq(link, &link->irq);
+	ret = pcmcia_request_exclusive_irq(link, pdacf_interrupt);
 	if (ret)
 		goto failed;
 
@@ -236,7 +231,7 @@ static int pdacf_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
+	if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq) < 0)
 		goto failed;
 
 	link->dev_node = &pdacf->node;
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index cfd1438..5eced7a 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -162,10 +162,6 @@ static int snd_vxpocket_new(struct snd_card *card, int ibl,
 	link->io.Attributes1 = IO_DATA_PATH_WIDTH_AUTO;
 	link->io.NumPorts1 = 16;
 
-	link->irq.Attributes = IRQ_TYPE_EXCLUSIVE;
-
-	link->irq.Handler = &snd_vx_irq_handler;
-
 	link->conf.Attributes = CONF_ENABLE_IRQ;
 	link->conf.IntType = INT_MEMORY_AND_IO;
 	link->conf.ConfigIndex = 1;
@@ -235,7 +231,7 @@ static int vxpocket_config(struct pcmcia_device *link)
 	if (ret)
 		goto failed;
 
-	ret = pcmcia_request_irq(link, &link->irq);
+	ret = pcmcia_request_exclusive_irq(link, snd_vx_irq_handler);
 	if (ret)
 		goto failed;
 
@@ -246,7 +242,7 @@ static int vxpocket_config(struct pcmcia_device *link)
 	chip->dev = &link->dev;
 	snd_card_set_dev(chip->card, chip->dev);
 
-	if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq.AssignedIRQ) < 0)
+	if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq) < 0)
 		goto failed;
 
 	link->dev_node = &vxp->node;
-- 
1.6.3.3


^ permalink raw reply related

* [PATCH 07/29] pcmcia: dev_node removal (write-only drivers)
From: Dominik Brodowski @ 2010-05-19  6:42 UTC (permalink / raw)
  To: linux-pcmcia
  Cc: Dominik Brodowski, linux-bluetooth, Harald Welte, linux-mtd,
	linux-wireless, netdev, linux-serial, alsa-devel
In-Reply-To: <20100519064149.GA5755@comet.dominikbrodowski.net>

dev_node_t was only used to transport some minor/major numbers
from the PCMCIA device drivers to deprecated userspace helpers.
However, only a few drivers made use of it, and the userspace
helpers are deprecated anyways. Therefore, get rid of dev_node_t .

As a first step, remove any usage of dev_node_t from drivers which
only wrote to this typedef/struct, but did not make use of it.

CC: linux-bluetooth@vger.kernel.org
CC: Harald Welte <laforge@gnumonks.org>
CC: linux-mtd@lists.infradead.org
CC: linux-wireless@vger.kernel.org
CC: netdev@vger.kernel.org
CC: linux-serial@vger.kernel.org
CC: alsa-devel@alsa-project.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
 drivers/bluetooth/bluecard_cs.c         |    4 ---
 drivers/bluetooth/bt3c_cs.c             |    4 ---
 drivers/bluetooth/btuart_cs.c           |    4 ---
 drivers/bluetooth/dtl1_cs.c             |    4 ---
 drivers/char/pcmcia/cm4040_cs.c         |    5 ---
 drivers/mtd/maps/pcmciamtd.c            |    3 --
 drivers/net/wireless/atmel_cs.c         |   42 -------------------------------
 drivers/net/wireless/hostap/hostap_cs.c |    9 +-----
 drivers/parport/parport_cs.c            |    5 ---
 drivers/scsi/pcmcia/aha152x_stub.c      |    3 --
 drivers/scsi/pcmcia/fdomain_stub.c      |    3 --
 drivers/scsi/pcmcia/nsp_cs.c            |    3 --
 drivers/scsi/pcmcia/nsp_cs.h            |    1 -
 drivers/scsi/pcmcia/qlogic_stub.c       |    3 --
 drivers/scsi/pcmcia/sym53c500_cs.c      |    3 --
 drivers/serial/serial_cs.c              |    9 ------
 drivers/telephony/ixj_pcmcia.c          |    3 --
 sound/pcmcia/pdaudiocf/pdaudiocf.c      |    1 -
 sound/pcmcia/pdaudiocf/pdaudiocf.h      |    1 -
 sound/pcmcia/vx/vxpocket.c              |    2 -
 sound/pcmcia/vx/vxpocket.h              |    1 -
 21 files changed, 2 insertions(+), 111 deletions(-)

diff --git a/drivers/bluetooth/bluecard_cs.c b/drivers/bluetooth/bluecard_cs.c
index a34653d..6f907eb 100644
--- a/drivers/bluetooth/bluecard_cs.c
+++ b/drivers/bluetooth/bluecard_cs.c
@@ -65,7 +65,6 @@ MODULE_LICENSE("GPL");
 
 typedef struct bluecard_info_t {
 	struct pcmcia_device *p_dev;
-	dev_node_t node;
 
 	struct hci_dev *hdev;
 
@@ -916,9 +915,6 @@ static int bluecard_config(struct pcmcia_device *link)
 	if (bluecard_open(info) != 0)
 		goto failed;
 
-	strcpy(info->node.dev_name, info->hdev->name);
-	link->dev_node = &info->node;
-
 	return 0;
 
 failed:
diff --git a/drivers/bluetooth/bt3c_cs.c b/drivers/bluetooth/bt3c_cs.c
index 1ad9694..21e05fd 100644
--- a/drivers/bluetooth/bt3c_cs.c
+++ b/drivers/bluetooth/bt3c_cs.c
@@ -72,7 +72,6 @@ MODULE_FIRMWARE("BT3CPCC.bin");
 
 typedef struct bt3c_info_t {
 	struct pcmcia_device *p_dev;
-	dev_node_t node;
 
 	struct hci_dev *hdev;
 
@@ -751,9 +750,6 @@ found_port:
 	if (bt3c_open(info) != 0)
 		goto failed;
 
-	strcpy(info->node.dev_name, info->hdev->name);
-	link->dev_node = &info->node;
-
 	return 0;
 
 failed:
diff --git a/drivers/bluetooth/btuart_cs.c b/drivers/bluetooth/btuart_cs.c
index 1073d66..4ed7288 100644
--- a/drivers/bluetooth/btuart_cs.c
+++ b/drivers/bluetooth/btuart_cs.c
@@ -67,7 +67,6 @@ MODULE_LICENSE("GPL");
 
 typedef struct btuart_info_t {
 	struct pcmcia_device *p_dev;
-	dev_node_t node;
 
 	struct hci_dev *hdev;
 
@@ -680,9 +679,6 @@ found_port:
 	if (btuart_open(info) != 0)
 		goto failed;
 
-	strcpy(info->node.dev_name, info->hdev->name);
-	link->dev_node = &info->node;
-
 	return 0;
 
 failed:
diff --git a/drivers/bluetooth/dtl1_cs.c b/drivers/bluetooth/dtl1_cs.c
index 3d72afd..ef044d5 100644
--- a/drivers/bluetooth/dtl1_cs.c
+++ b/drivers/bluetooth/dtl1_cs.c
@@ -67,7 +67,6 @@ MODULE_LICENSE("GPL");
 
 typedef struct dtl1_info_t {
 	struct pcmcia_device *p_dev;
-	dev_node_t node;
 
 	struct hci_dev *hdev;
 
@@ -629,9 +628,6 @@ static int dtl1_config(struct pcmcia_device *link)
 	if (dtl1_open(info) != 0)
 		goto failed;
 
-	strcpy(info->node.dev_name, info->hdev->name);
-	link->dev_node = &info->node;
-
 	return 0;
 
 failed:
diff --git a/drivers/char/pcmcia/cm4040_cs.c b/drivers/char/pcmcia/cm4040_cs.c
index a6a70e4..c0775c8 100644
--- a/drivers/char/pcmcia/cm4040_cs.c
+++ b/drivers/char/pcmcia/cm4040_cs.c
@@ -72,7 +72,6 @@ static struct class *cmx_class;
 
 struct reader_dev {
 	struct pcmcia_device	*p_dev;
-	dev_node_t		node;
 	wait_queue_head_t	devq;
 	wait_queue_head_t	poll_wait;
 	wait_queue_head_t	read_wait;
@@ -568,10 +567,6 @@ static int reader_config(struct pcmcia_device *link, int devno)
 	}
 
 	dev = link->priv;
-	sprintf(dev->node.dev_name, DEVICE_NAME "%d", devno);
-	dev->node.major = major;
-	dev->node.minor = devno;
-	dev->node.next = &dev->node;
 
 	DEBUGP(2, dev, "device " DEVICE_NAME "%d at 0x%.4x-0x%.4x\n", devno,
 	      link->io.BasePort1, link->io.BasePort1+link->io.NumPorts1);
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c
index 689d6a7..87b2b8f 100644
--- a/drivers/mtd/maps/pcmciamtd.c
+++ b/drivers/mtd/maps/pcmciamtd.c
@@ -52,7 +52,6 @@ static const int debug = 0;
 
 struct pcmciamtd_dev {
 	struct pcmcia_device	*p_dev;
-	dev_node_t	node;		/* device node */
 	caddr_t		win_base;	/* ioremapped address of PCMCIA window */
 	unsigned int	win_size;	/* size of window */
 	unsigned int	offset;		/* offset into card the window currently points at */
@@ -647,9 +646,7 @@ static int pcmciamtd_config(struct pcmcia_device *link)
 		pcmciamtd_release(link);
 		return -ENODEV;
 	}
-	snprintf(dev->node.dev_name, sizeof(dev->node.dev_name), "mtd%d", mtd->index);
 	info("mtd%d: %s", mtd->index, mtd->name);
-	link->dev_node = &dev->node;
 	return 0;
 
  failed:
diff --git a/drivers/net/wireless/atmel_cs.c b/drivers/net/wireless/atmel_cs.c
index 759cdc4..c2746fc 100644
--- a/drivers/net/wireless/atmel_cs.c
+++ b/drivers/net/wireless/atmel_cs.c
@@ -85,41 +85,7 @@ static void atmel_release(struct pcmcia_device *link);
 
 static void atmel_detach(struct pcmcia_device *p_dev);
 
-/*
-   You'll also need to prototype all the functions that will actually
-   be used to talk to your device.  See 'pcmem_cs' for a good example
-   of a fully self-sufficient driver; the other drivers rely more or
-   less on other parts of the kernel.
-*/
-
-/*
-   A linked list of "instances" of the  atmelnet device.  Each actual
-   PCMCIA card corresponds to one device instance, and is described
-   by one struct pcmcia_device structure (defined in ds.h).
-
-   You may not want to use a linked list for this -- for example, the
-   memory card driver uses an array of struct pcmcia_device pointers, where minor
-   device numbers are used to derive the corresponding array index.
-*/
-
-/*
-   A driver needs to provide a dev_node_t structure for each device
-   on a card.  In some cases, there is only one device per card (for
-   example, ethernet cards, modems).  In other cases, there may be
-   many actual or logical devices (SCSI adapters, memory cards with
-   multiple partitions).  The dev_node_t structures need to be kept
-   in a linked list starting at the 'dev' field of a struct pcmcia_device
-   structure.  We allocate them in the card's private data structure,
-   because they generally shouldn't be allocated dynamically.
-
-   In this case, we also provide a flag to indicate if a device is
-   "stopped" due to a power management event, or card ejection.  The
-   device IO routines can use a flag like this to throttle IO to a
-   card that is not ready to accept it.
-*/
-
 typedef struct local_info_t {
-	dev_node_t	node;
 	struct net_device *eth_dev;
 } local_info_t;
 
@@ -297,14 +263,6 @@ static int atmel_config(struct pcmcia_device *link)
 			goto failed;
 
 
-	/*
-	  At this point, the dev_node_t structure(s) need to be
-	  initialized and arranged in a linked list at link->dev_node.
-	*/
-	strcpy(dev->node.dev_name, ((local_info_t*)link->priv)->eth_dev->name );
-	dev->node.major = dev->node.minor = 0;
-	link->dev_node = &dev->node;
-
 	return 0;
 
  failed:
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c
index 5e2efbb..db72461 100644
--- a/drivers/net/wireless/hostap/hostap_cs.c
+++ b/drivers/net/wireless/hostap/hostap_cs.c
@@ -39,7 +39,6 @@ MODULE_PARM_DESC(ignore_cis_vcc, "Ignore broken CIS VCC entry");
 
 /* struct local_info::hw_priv */
 struct hostap_cs_priv {
-	dev_node_t node;
 	struct pcmcia_device *link;
 	int sandisk_connectplus;
 };
@@ -625,8 +624,6 @@ static int prism2_config(struct pcmcia_device *link)
 	local = iface->local;
 	local->hw_priv = hw_priv;
 	hw_priv->link = link;
-	strcpy(hw_priv->node.dev_name, dev->name);
-	link->dev_node = &hw_priv->node;
 
 	ret = pcmcia_request_irq(link, prism2_interrupt);
 	if (ret)
@@ -665,11 +662,9 @@ static int prism2_config(struct pcmcia_device *link)
 	sandisk_enable_wireless(dev);
 
 	ret = prism2_hw_config(dev, 1);
-	if (!ret) {
+	if (!ret)
 		ret = hostap_hw_ready(dev);
-		if (ret == 0 && local->ddev)
-			strcpy(hw_priv->node.dev_name, local->ddev->name);
-	}
+
 	return ret;
 
  failed:
diff --git a/drivers/parport/parport_cs.c b/drivers/parport/parport_cs.c
index 80c9052..fd8cfe9 100644
--- a/drivers/parport/parport_cs.c
+++ b/drivers/parport/parport_cs.c
@@ -75,7 +75,6 @@ INT_MODULE_PARM(epp_mode, 1);
 typedef struct parport_info_t {
 	struct pcmcia_device	*p_dev;
     int			ndev;
-    dev_node_t		node;
     struct parport	*port;
 } parport_info_t;
 
@@ -193,11 +192,7 @@ static int parport_config(struct pcmcia_device *link)
     if (epp_mode)
 	p->modes |= PARPORT_MODE_TRISTATE | PARPORT_MODE_EPP;
     info->ndev = 1;
-    info->node.major = LP_MAJOR;
-    info->node.minor = p->number;
     info->port = p;
-    strcpy(info->node.dev_name, p->name);
-    link->dev_node = &info->node;
 
     return 0;
 
diff --git a/drivers/scsi/pcmcia/aha152x_stub.c b/drivers/scsi/pcmcia/aha152x_stub.c
index c1de4ba..9d70aef 100644
--- a/drivers/scsi/pcmcia/aha152x_stub.c
+++ b/drivers/scsi/pcmcia/aha152x_stub.c
@@ -80,7 +80,6 @@ MODULE_LICENSE("Dual MPL/GPL");
 
 typedef struct scsi_info_t {
 	struct pcmcia_device	*p_dev;
-    dev_node_t		node;
     struct Scsi_Host	*host;
 } scsi_info_t;
 
@@ -185,8 +184,6 @@ static int aha152x_config_cs(struct pcmcia_device *link)
 	goto failed;
     }
 
-    sprintf(info->node.dev_name, "scsi%d", host->host_no);
-    link->dev_node = &info->node;
     info->host = host;
 
     return 0;
diff --git a/drivers/scsi/pcmcia/fdomain_stub.c b/drivers/scsi/pcmcia/fdomain_stub.c
index 8cb6d71..21b1411 100644
--- a/drivers/scsi/pcmcia/fdomain_stub.c
+++ b/drivers/scsi/pcmcia/fdomain_stub.c
@@ -63,7 +63,6 @@ MODULE_LICENSE("Dual MPL/GPL");
 
 typedef struct scsi_info_t {
 	struct pcmcia_device	*p_dev;
-    dev_node_t		node;
     struct Scsi_Host	*host;
 } scsi_info_t;
 
@@ -155,8 +154,6 @@ static int fdomain_config(struct pcmcia_device *link)
 	    goto failed;
     scsi_scan_host(host);
 
-    sprintf(info->node.dev_name, "scsi%d", host->host_no);
-    link->dev_node = &info->node;
     info->host = host;
 
     return 0;
diff --git a/drivers/scsi/pcmcia/nsp_cs.c b/drivers/scsi/pcmcia/nsp_cs.c
index 24c78ed..0f0e112 100644
--- a/drivers/scsi/pcmcia/nsp_cs.c
+++ b/drivers/scsi/pcmcia/nsp_cs.c
@@ -1754,8 +1754,6 @@ static int nsp_cs_config(struct pcmcia_device *link)
 
 	scsi_scan_host(host);
 
-	snprintf(info->node.dev_name, sizeof(info->node.dev_name), "scsi%d", host->host_no);
-	link->dev_node  = &info->node;
 	info->host = host;
 
 	/* Finally, report what we've done */
@@ -1813,7 +1811,6 @@ static void nsp_cs_release(struct pcmcia_device *link)
 	if (info->host != NULL) {
 		scsi_remove_host(info->host);
 	}
-	link->dev_node = NULL;
 
 	if (link->win) {
 		if (data != NULL) {
diff --git a/drivers/scsi/pcmcia/nsp_cs.h b/drivers/scsi/pcmcia/nsp_cs.h
index 8c61a4f..d68c9f2 100644
--- a/drivers/scsi/pcmcia/nsp_cs.h
+++ b/drivers/scsi/pcmcia/nsp_cs.h
@@ -224,7 +224,6 @@
 typedef struct scsi_info_t {
 	struct pcmcia_device	*p_dev;
 	struct Scsi_Host      *host;
-	dev_node_t             node;
 	int                    stop;
 } scsi_info_t;
 
diff --git a/drivers/scsi/pcmcia/qlogic_stub.c b/drivers/scsi/pcmcia/qlogic_stub.c
index c3a4428..f0fc6ba 100644
--- a/drivers/scsi/pcmcia/qlogic_stub.c
+++ b/drivers/scsi/pcmcia/qlogic_stub.c
@@ -82,7 +82,6 @@ static struct scsi_host_template qlogicfas_driver_template = {
 
 typedef struct scsi_info_t {
 	struct pcmcia_device	*p_dev;
-	dev_node_t node;
 	struct Scsi_Host *host;
 	unsigned short manf_id;
 } scsi_info_t;
@@ -235,8 +234,6 @@ static int qlogic_config(struct pcmcia_device * link)
 		goto failed;
 	}
 
-	sprintf(info->node.dev_name, "scsi%d", host->host_no);
-	link->dev_node = &info->node;
 	info->host = host;
 
 	return 0;
diff --git a/drivers/scsi/pcmcia/sym53c500_cs.c b/drivers/scsi/pcmcia/sym53c500_cs.c
index 6eacf4c..a511641 100644
--- a/drivers/scsi/pcmcia/sym53c500_cs.c
+++ b/drivers/scsi/pcmcia/sym53c500_cs.c
@@ -191,7 +191,6 @@
 
 struct scsi_info_t {
 	struct pcmcia_device	*p_dev;
-	dev_node_t node;
 	struct Scsi_Host *host;
 	unsigned short manf_id;
 };
@@ -792,8 +791,6 @@ SYM53C500_config(struct pcmcia_device *link)
 	*/
 	data->fast_pio = USE_FAST_PIO;
 
-	sprintf(info->node.dev_name, "scsi%d", host->host_no);
-	link->dev_node = &info->node;
 	info->host = host;
 
 	if (scsi_add_host(host, NULL))
diff --git a/drivers/serial/serial_cs.c b/drivers/serial/serial_cs.c
index 6459252..dadd686 100644
--- a/drivers/serial/serial_cs.c
+++ b/drivers/serial/serial_cs.c
@@ -89,7 +89,6 @@ struct serial_info {
 	int			manfid;
 	int			prodid;
 	int			c950ctrl;
-	dev_node_t		node[4];
 	int			line[4];
 	const struct serial_quirk *quirk;
 };
@@ -289,8 +288,6 @@ static void serial_remove(struct pcmcia_device *link)
 	for (i = 0; i < info->ndev; i++)
 		serial8250_unregister_port(info->line[i]);
 
-	info->p_dev->dev_node = NULL;
-
 	if (!info->slave)
 		pcmcia_disable_device(link);
 }
@@ -410,11 +407,6 @@ static int setup_serial(struct pcmcia_device *handle, struct serial_info * info,
 	}
 
 	info->line[info->ndev] = line;
-	sprintf(info->node[info->ndev].dev_name, "ttyS%d", line);
-	info->node[info->ndev].major = TTY_MAJOR;
-	info->node[info->ndev].minor = 0x40 + line;
-	if (info->ndev > 0)
-		info->node[info->ndev - 1].next = &info->node[info->ndev];
 	info->ndev++;
 
 	return 0;
@@ -711,7 +703,6 @@ static int serial_config(struct pcmcia_device * link)
 		if (info->quirk->post(link))
 			goto failed;
 
-	link->dev_node = &info->node[0];
 	return 0;
 
 failed:
diff --git a/drivers/telephony/ixj_pcmcia.c b/drivers/telephony/ixj_pcmcia.c
index d442fd3..99cb224 100644
--- a/drivers/telephony/ixj_pcmcia.c
+++ b/drivers/telephony/ixj_pcmcia.c
@@ -22,7 +22,6 @@
 
 typedef struct ixj_info_t {
 	int ndev;
-	dev_node_t node;
 	struct ixj *port;
 } ixj_info_t;
 
@@ -155,8 +154,6 @@ static int ixj_config(struct pcmcia_device * link)
 	j = ixj_pcmcia_probe(link->io.BasePort1, link->io.BasePort1 + 0x10);
 
 	info->ndev = 1;
-	info->node.major = PHONE_MAJOR;
-	link->dev_node = &info->node;
 	ixj_get_serial(link, j);
 	return 0;
 
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.c b/sound/pcmcia/pdaudiocf/pdaudiocf.c
index 60fddf3..df110df 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.c
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.c
@@ -234,7 +234,6 @@ static int pdacf_config(struct pcmcia_device *link)
 	if (snd_pdacf_assign_resources(pdacf, link->io.BasePort1, link->irq) < 0)
 		goto failed;
 
-	link->dev_node = &pdacf->node;
 	return 0;
 
 failed:
diff --git a/sound/pcmcia/pdaudiocf/pdaudiocf.h b/sound/pcmcia/pdaudiocf/pdaudiocf.h
index b060183..a0a7ec6 100644
--- a/sound/pcmcia/pdaudiocf/pdaudiocf.h
+++ b/sound/pcmcia/pdaudiocf/pdaudiocf.h
@@ -117,7 +117,6 @@ struct snd_pdacf {
 	
 	/* pcmcia stuff */
 	struct pcmcia_device	*p_dev;
-	dev_node_t node;
 };
 
 static inline void pdacf_reg_write(struct snd_pdacf *chip, unsigned char reg, unsigned short val)
diff --git a/sound/pcmcia/vx/vxpocket.c b/sound/pcmcia/vx/vxpocket.c
index 5eced7a..624b47a 100644
--- a/sound/pcmcia/vx/vxpocket.c
+++ b/sound/pcmcia/vx/vxpocket.c
@@ -211,7 +211,6 @@ static int snd_vxpocket_assign_resources(struct vx_core *chip, int port, int irq
 static int vxpocket_config(struct pcmcia_device *link)
 {
 	struct vx_core *chip = link->priv;
-	struct snd_vxpocket *vxp = (struct snd_vxpocket *)chip;
 	int ret;
 
 	snd_printdd(KERN_DEBUG "vxpocket_config called\n");
@@ -245,7 +244,6 @@ static int vxpocket_config(struct pcmcia_device *link)
 	if (snd_vxpocket_assign_resources(chip, link->io.BasePort1, link->irq) < 0)
 		goto failed;
 
-	link->dev_node = &vxp->node;
 	return 0;
 
 failed:
diff --git a/sound/pcmcia/vx/vxpocket.h b/sound/pcmcia/vx/vxpocket.h
index 27ea002..ea4df16 100644
--- a/sound/pcmcia/vx/vxpocket.h
+++ b/sound/pcmcia/vx/vxpocket.h
@@ -43,7 +43,6 @@ struct snd_vxpocket {
 
 	/* pcmcia stuff */
 	struct pcmcia_device	*p_dev;
-	dev_node_t node;
 };
 
 extern struct snd_vx_ops snd_vxpocket_ops;
-- 
1.6.3.3


^ permalink raw reply related

* Re: [PATCH v3] Bluetooth: Add blacklist support for incoming connections
From: Gustavo F. Padovan @ 2010-05-19  8:10 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth, Johan Hedberg
In-Reply-To: <1274181632-29873-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

* johan.hedberg@gmail.com <johan.hedberg@gmail.com> [2010-05-18 13:20:32 +0200]:

> From: Johan Hedberg <johan.hedberg@nokia.com>
> 
> In some circumstances it could be desirable to reject incoming
> connections on the baseband level. This patch adds this feature through
> two new ioctl's: HCIBLOCKADDR and HCIUNBLOCKADDR. Both take a simple
> Bluetooth address as a parameter. BDADDR_ANY can be used with
> HCIUNBLOCKADDR to remove all devices from the blacklist.

Which circumstances?



-- 
Gustavo F. Padovan
http://padovan.org

^ permalink raw reply

* Re: [PATCH v3] Bluetooth: Add blacklist support for incoming connections
From: Johan Hedberg @ 2010-05-19  8:22 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <20100519081037.GE6219@vigoh>

Hi Gustavo,

On Wed, May 19, 2010, Gustavo F. Padovan wrote:
> > In some circumstances it could be desirable to reject incoming
> > connections on the baseband level. This patch adds this feature through
> > two new ioctl's: HCIBLOCKADDR and HCIUNBLOCKADDR. Both take a simple
> > Bluetooth address as a parameter. BDADDR_ANY can be used with
> > HCIUNBLOCKADDR to remove all devices from the blacklist.
> 
> Which circumstances?

Whenever you have a badly behaving remote device that keeps on trying to
connect to you (e.g. an OPP spambot or someone trying to actively DoS
you). I gave some more details in my reply to Jaikumar a few days ago on
this mailing list.

Johan

^ permalink raw reply

* Re: [PATCH v3] Bluetooth: Add blacklist support for incoming connections
From: Gustavo F. Padovan @ 2010-05-19  8:48 UTC (permalink / raw)
  To: linux-bluetooth@vger.kernel.org
In-Reply-To: <20100519082205.GA18772@jh-x301>

Hi Johan,

* Johan Hedberg <johan.hedberg@nokia.com> [2010-05-19 10:22:05 +0200]:

> Hi Gustavo,
> 
> On Wed, May 19, 2010, Gustavo F. Padovan wrote:
> > > In some circumstances it could be desirable to reject incoming
> > > connections on the baseband level. This patch adds this feature through
> > > two new ioctl's: HCIBLOCKADDR and HCIUNBLOCKADDR. Both take a simple
> > > Bluetooth address as a parameter. BDADDR_ANY can be used with
> > > HCIUNBLOCKADDR to remove all devices from the blacklist.
> > 
> > Which circumstances?
> 
> Whenever you have a badly behaving remote device that keeps on trying to
> connect to you (e.g. an OPP spambot or someone trying to actively DoS
> you). I gave some more details in my reply to Jaikumar a few days ago on
> this mailing list.

Nice. Patch looks ok to me by the way. ;)

-- 
Gustavo F. Padovan
http://padovan.org

^ permalink raw reply

* Re: [PATCH] Bluetooth: Add debugfs support for showing the blacklist
From: Marcel Holtmann @ 2010-05-19 11:20 UTC (permalink / raw)
  To: johan.hedberg; +Cc: linux-bluetooth, Johan Hedberg
In-Reply-To: <1274183689-28238-1-git-send-email-johan.hedberg@gmail.com>

Hi Johan,

> This patch adds a debugfs blacklist entry for each HCI device which can
> be used to list the current content of the blacklist.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@nokia.com>

patch looks straitht forward.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



^ permalink raw reply

* Re: [PATCH v3] Bluetooth: Add blacklist support for incoming connections
From: Luiz Augusto von Dentz @ 2010-05-19 13:55 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <20100519084715.GA11110@vigoh>

Hi Gustavo,

On Wed, May 19, 2010 at 10:48 AM, Gustavo F. Padovan
<gustavo@padovan.org> wrote:
> Hi Johan,
>
> * Johan Hedberg <johan.hedberg@nokia.com> [2010-05-19 10:22:05 +0200]:
>
>> Hi Gustavo,
>>
>> On Wed, May 19, 2010, Gustavo F. Padovan wrote:
>> > > In some circumstances it could be desirable to reject incoming
>> > > connections on the baseband level. This patch adds this feature through
>> > > two new ioctl's: HCIBLOCKADDR and HCIUNBLOCKADDR. Both take a simple
>> > > Bluetooth address as a parameter. BDADDR_ANY can be used with
>> > > HCIUNBLOCKADDR to remove all devices from the blacklist.
>> >
>> > Which circumstances?
>>
>> Whenever you have a badly behaving remote device that keeps on trying to
>> connect to you (e.g. an OPP spambot or someone trying to actively DoS
>> you). I gave some more details in my reply to Jaikumar a few days ago on
>> this mailing list.
>
> Nice. Patch looks ok to me by the way. ;)

Its also very, almost a must, convenient when doing interoperability
testing in some events like upf where we have a lot (annoying) devices
trying to reconnect to us while we are testing with other devices.

@ Johan, Blocked does supersedes Trusted right? Maybe we should rework
those properties (deprecate them?) to something like Authorization
which takes a string where lets say can assume these values: "deny"
("block"), "ask" or "allow".

-- 
Luiz Augusto von Dentz
Computer Engineer

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox