Skip to contentSkip to conversation

bluetooth: add btmrvl driver to support Marvell bluetooth devices

PATCH In review Bing Zhao 2 participants 10 messages Jun 2, 2009 – Jun 16, 2009

Subsystems (2)
lore
Share & tools
lore

Bing Zhao

author
#0 lore raw

PATCH v3 1/4 bluetooth: add btmrvl driver to support Marvell bluetooth devices

This driver provides basic definitions and library functions to support Marvell Bluetooth enabled devices, such as 88W8688 WLAN/BT combo chip.

This patch incorporates a lot of comments given by Nicolas Pitre <[email protected]>. Many thanks to Nicolas Pitre.

---
 drivers/bluetooth/Kconfig       |   12 +
 drivers/bluetooth/Makefile      |    3 +
 drivers/bluetooth/btmrvl_drv.h  |  138 ++++++++
 drivers/bluetooth/btmrvl_main.c |  714 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 867 insertions(+), 0 deletions(-)
 create mode 100644 drivers/bluetooth/btmrvl_drv.h
 create mode 100644 drivers/bluetooth/btmrvl_main.c
drivers/bluetooth/Kconfig +12 -0
index 1164837..b049a79 100644
@@ -170,5 +170,17 @@ config BT_HCIVHCI
 	  Say Y here to compile support for virtual HCI devices into the
 	  kernel or say M to compile it as module (hci_vhci).
 
+config BT_MRVL
+	tristate "Marvell Bluetooth driver support"
+	select FW_LOADER
+	help
+	  The core driver to support Marvell Bluetooth devices.
+
+	  This driver is required if you want to support
+	  Marvell Bluetooth devices, such as 8688.
+
+	  Say Y here to compile Marvell Bluetooth driver
+	  into the kernel or say M to compile it as module.
+
 endmenu
 
drivers/bluetooth/Makefile +3 -0
index 16930f9..3eff123 100644
@@ -15,6 +15,9 @@ obj-$(CONFIG_BT_HCIBTUART)	+= btuart_cs.o
 obj-$(CONFIG_BT_HCIBTUSB)	+= btusb.o
 obj-$(CONFIG_BT_HCIBTSDIO)	+= btsdio.o
 
+btmrvl-objs			:= btmrvl_main.o
+obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
+
 hci_uart-y				:= hci_ldisc.o
 hci_uart-$(CONFIG_BT_HCIUART_H4)	+= hci_h4.o
 hci_uart-$(CONFIG_BT_HCIUART_BCSP)	+= hci_bcsp.o
drivers/bluetooth/btmrvl_drv.h new file +138 -0

138 lines not on this page · raw message

drivers/bluetooth/btmrvl_main.c new file +714 -0

714 lines not on this page · raw message

Signature · 1 line
1.5.3.6
author
#1 lore raw

PATCH v3 2/4 bluetooth: btmrvl_sdio: Marvell BT-over-SDIO driver

This driver supports Marvell Bluetooth enabled devices with SDIO interface. Currently only SD8688 chip is supported.

The helper/firmware images of SD8688 can be downloaded from this tree:
git://git.infradead.org/users/dwmw2/linux-firmware.git

This patch incorporates a lot of comments given by Nicolas Pitre <[email protected]>. Many thanks to Nicolas Pitre.

---
 drivers/bluetooth/Kconfig       |   13 +
 drivers/bluetooth/Makefile      |    1 +
 drivers/bluetooth/btmrvl_sdio.c | 1128 +++++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btmrvl_sdio.h |  113 ++++
 4 files changed, 1255 insertions(+), 0 deletions(-)
 create mode 100644 drivers/bluetooth/btmrvl_sdio.c
 create mode 100644 drivers/bluetooth/btmrvl_sdio.h
drivers/bluetooth/Kconfig +13 -0
index b049a79..8c89bd4 100644
@@ -182,5 +182,18 @@ config BT_MRVL
 	  Say Y here to compile Marvell Bluetooth driver
 	  into the kernel or say M to compile it as module.
 
+config BT_MRVL_SDIO
+	tristate "Marvell BT-over-SDIO driver"
+	depends on BT_MRVL && MMC
+	help
+	  The driver for Marvell Bluetooth chipsets with SDIO interface.
+
+	  This driver is required if you want to use Marvell Bluetooth
+	  devices with SDIO interface. Currently only SD8688 chipset is
+	  supported.
+
+	  Say Y here to compile support for Marvell BT-over-SDIO driver
+	  into the kernel or say M to compile it as module.
+
 endmenu
 
drivers/bluetooth/Makefile +1 -0
index 3eff123..2dc12e7 100644
@@ -17,6 +17,7 @@ obj-$(CONFIG_BT_HCIBTSDIO)	+= btsdio.o
 
 btmrvl-objs			:= btmrvl_main.o
 obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
+obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 
 hci_uart-y				:= hci_ldisc.o
 hci_uart-$(CONFIG_BT_HCIUART_H4)	+= hci_h4.o
drivers/bluetooth/btmrvl_sdio.c new file +1128 -0

1,128 lines not on this page · raw message

drivers/bluetooth/btmrvl_sdio.h new file +113 -0

113 lines not on this page · raw message

Signature · 1 line
1.5.3.6
author
#2 lore raw

PATCH v3 3/4 bluetooth: Add debugfs support to btmrvl driver

In reply to Bing Zhao

/debug/btmrvl/config/
/debug/btmrvl/status/

See Documentation/btmrvl.txt for details.

This patch incorporates a lot of comments given by Nicolas Pitre <[email protected]>. Many thanks to Nicolas Pitre.

---
 drivers/bluetooth/Kconfig          |    1 +
 drivers/bluetooth/Makefile         |    2 +-
 drivers/bluetooth/btmrvl_debugfs.c |  469 ++++++++++++++++++++++++++++++++++++
 drivers/bluetooth/btmrvl_drv.h     |    8 +
 drivers/bluetooth/btmrvl_main.c    |    8 +
 5 files changed, 487 insertions(+), 1 deletions(-)
 create mode 100644 drivers/bluetooth/btmrvl_debugfs.c
drivers/bluetooth/Kconfig +1 -0
index 8c89bd4..5f04014 100644
@@ -173,6 +173,7 @@ config BT_HCIVHCI
 config BT_MRVL
 	tristate "Marvell Bluetooth driver support"
 	select FW_LOADER
+	select DEBUG_FS
 	help
 	  The core driver to support Marvell Bluetooth devices.
 
drivers/bluetooth/Makefile +1 -1
index 2dc12e7..75f70e0 100644
@@ -15,7 +15,7 @@ obj-$(CONFIG_BT_HCIBTUART)	+= btuart_cs.o
 obj-$(CONFIG_BT_HCIBTUSB)	+= btusb.o
 obj-$(CONFIG_BT_HCIBTSDIO)	+= btsdio.o
 
-btmrvl-objs			:= btmrvl_main.o
+btmrvl-objs			:= btmrvl_main.o btmrvl_debugfs.o
 obj-$(CONFIG_BT_MRVL)		+= btmrvl.o
 obj-$(CONFIG_BT_MRVL_SDIO)	+= btmrvl_sdio.o
 
drivers/bluetooth/btmrvl_debugfs.c new file +469 -0

469 lines not on this page · raw message

drivers/bluetooth/btmrvl_drv.h +8 -0
index 9ad71f4..7a12f68 100644
@@ -79,6 +79,9 @@ struct btmrvl_private {
 				u8 *payload, u16 nb);
 	int (*hw_wakeup_firmware) (struct btmrvl_private *priv);
 	spinlock_t driver_lock;		/* spinlock used by driver */
+#ifdef CONFIG_DEBUG_FS
+	void *debugfs_data;
+#endif
 };
 
 #define MRVL_VENDOR_PKT			0xFE
@@ -135,4 +138,9 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb);
 int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd);
 int btmrvl_prepare_command(struct btmrvl_private *priv);
 
+#ifdef CONFIG_DEBUG_FS
+void btmrvl_debugfs_init(struct hci_dev *hdev);
+void btmrvl_debugfs_remove(struct hci_dev *hdev);
+#endif
+
 #endif /* _BTMRVL_DRV_H_ */
drivers/bluetooth/btmrvl_main.c +8 -0
index 11c2f2c..b4f4445 100644
@@ -658,6 +658,10 @@ struct btmrvl_private *btmrvl_add_card(void *card)
 		goto err_hci_register_dev;
 	}
 
+#ifdef CONFIG_DEBUG_FS
+	btmrvl_debugfs_init(hdev);
+#endif
+
 	BT_DBG("Leave");
 	return priv;
 
@@ -692,6 +696,10 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
 
 	kthread_stop(priv->main_thread.task);
 
+#ifdef CONFIG_DEBUG_FS
+	btmrvl_debugfs_remove(hdev);
+#endif
+
 	hci_unregister_dev(hdev);
 
 	hci_free_dev(hdev);
Signature · 1 line
1.5.3.6
author
#3 lore raw

PATCH v3 4/4 bluetooth: Documentation for Marvell Bluetooth driver

In reply to Bing Zhao

add btmrvl.txt to Documentation/

This patch incorporates a lot of comments given by Nicolas Pitre <[email protected]>. Many thanks to Nicolas Pitre.

---
 Documentation/00-INDEX   |    2 +
 Documentation/btmrvl.txt |  119 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 121 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/btmrvl.txt
Documentation/00-INDEX +2 -0
index d05737a..06b982a 100644
@@ -82,6 +82,8 @@ block/
 	- info on the Block I/O (BIO) layer.
 blockdev/
 	- info on block devices & drivers
+btmrvl.txt
+	- info on Marvell Bluetooth driver usage.
 cachetlb.txt
 	- describes the cache/TLB flushing interfaces Linux uses.
 cdrom/
Documentation/btmrvl.txt new file +119 -0

119 lines not on this page · raw message

Signature · 1 line
1.5.3.6
maintainer
#4 lore raw
In reply to Bing Zhao

Hi Bing,

Quoted 3 lines

This driver provides basic definitions and library functions to support Marvell Bluetooth enabled devices, such as 88W8688 WLAN/BT combo chip.

so I created a bluetooth-mrvl-2.6 tree with your patches and already a major collection of cleanup patches.

The biggest problem right now is that your driver spits out casting warnings like crazy. This is not acceptable. So please send me a patch to fix these based on bluetooth-mrvl-2.6.

I did fix the firmware non-sense you had in there, but I haven't had time to test it with real hardware. So please do so.

Also I am considering to just remove all this Enter/Leave debug non-sense since it makes the code really hard to read.

Regards

Marcel

author
#5 lore raw

Hi Marcel,

Quoted 6 lines

-----Original Message-----
From: Marcel Holtmann [mailto:[email protected]]
Sent: Tuesday, June 09, 2009 8:20 AM
To: Bing Zhao
Cc: [email protected]
Subject: Re: [PATCH 1/4 v3] bluetooth: add btmrvl driver to support Marve=

ll bluetooth devices

Quoted 9 lines

=20
Hi Bing,
=20

Quoted 3 lines

This driver provides basic definitions and library functions to support Marvell Bluetooth enabled devices, such as 88W8688 WLAN/BT combo chip.

=20
so I created a bluetooth-mrvl-2.6 tree with your patches and already a major collection of cleanup patches.

Thanks for the cleanups.

Quoted 3 lines

The biggest problem right now is that your driver spits out casting warnings like crazy. This is not acceptable. So please send me a patch to fix these based on bluetooth-mrvl-2.6.

Could you please let me know how to catch these casting warnings? I'm using=
GCC 4.3.2 with sparse on x86 laptop (Fedora 8) but I couldn't get the warn=
ings.

Quoted 2 lines

I did fix the firmware non-sense you had in there, but I haven't had time to test it with real hardware. So please do so.

Thanks for the fix and it works well.

Quoted 2 lines

Also I am considering to just remove all this Enter/Leave debug non-sense since it makes the code really hard to read.

I can remove those Enter/Leave debug, if you prefer.

Quoted 4 lines

Regards
=20
Marcel
=20

Thanks,

Bing

maintainer
#6 lore raw

Hi Bing,

Quoted 7 lines
Quoted 6 lines
Quoted 3 lines

This driver provides basic definitions and library functions to support Marvell Bluetooth enabled devices, such as 88W8688 WLAN/BT combo chip.

so I created a bluetooth-mrvl-2.6 tree with your patches and already a major collection of cleanup patches.

Quoted 7 lines

Thanks for the cleanups.

Quoted 3 lines

The biggest problem right now is that your driver spits out casting warnings like crazy. This is not acceptable. So please send me a patch to fix these based on bluetooth-mrvl-2.6.

Could you please let me know how to catch these casting warnings? I'm using GCC 4.3.2 with sparse on x86 laptop (Fedora 8) but I couldn't get the warnings.

let me guess, you are running a 32-bit kernel. Just run a 64-bit kernel and you will see them. I am using Fedora 10.

I also have to compile this at least on one big endian machine. Will use my Quad G5 once I get home.

Quoted 4 lines
Quoted 2 lines

I did fix the firmware non-sense you had in there, but I haven't had time to test it with real hardware. So please do so.

Thanks for the fix and it works well.

Good. I wasn't sure I did this right. Stupid driver_data is unsigned long and that requires casting :(

Quoted 4 lines
Quoted 2 lines

Also I am considering to just remove all this Enter/Leave debug non-sense since it makes the code really hard to read.

I can remove those Enter/Leave debug, if you prefer.

Tell me what you need them for. I don't mind having the Enter part with BT_DBG since we are using that anyway to print debug information about the parameters we give to a function, but the Leave part is cluttering the code. Can you just follow the style the other drivers are using.

And again, after that you are not done since the whole driver needs more cleanups. That is just in a shape I consider merging it upstream so we can start fixing it there. I still consider it a little bit too complicated for what is really needed to drive your hardware.

Regards

Marcel

author
#7 lore raw

Hi Marcel,

Quoted 6 lines

-----Original Message-----
From: Marcel Holtmann [mailto:[email protected]]
Sent: Wednesday, June 10, 2009 12:07 AM
To: Bing Zhao
Cc: [email protected]
Subject: RE: [PATCH 1/4 v3] bluetooth: add btmrvl driver to support Marve=

ll bluetooth devices

Quoted 8 lines

Hi Bing,

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

This driver provides basic definitions and library functions to support Marvell Bluetooth enabled devices, such as 88W8688 WLAN/BT combo chip.

so I created a bluetooth-mrvl-2.6 tree with your patches and already =

a

Quoted 6 lines
Quoted 6 lines
Quoted 1 line

major collection of cleanup patches.

Thanks for the cleanups.

Quoted 2 lines

The biggest problem right now is that your driver spits out casting warnings like crazy. This is not acceptable. So please send me a patc=

h

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

to fix these based on bluetooth-mrvl-2.6.

Could you please let me know how to catch these casting warnings? I'm u=

sing GCC 4.3.2 with sparse

Quoted 4 lines

on x86 laptop (Fedora 8) but I couldn't get the warnings.

let me guess, you are running a 32-bit kernel. Just run a 64-bit kernel and you will see them. I am using Fedora 10.

Yes, I'm running 32-bit kernel. I'll try to install a 64-bit system and fix=
those warnings.

Quoted 14 lines

I also have to compile this at least on one big endian machine. Will use my Quad G5 once I get home.

Quoted 4 lines
Quoted 2 lines

I did fix the firmware non-sense you had in there, but I haven't had time to test it with real hardware. So please do so.

Thanks for the fix and it works well.

Good. I wasn't sure I did this right. Stupid driver_data is unsigned long and that requires casting :(

Quoted 3 lines
Quoted 2 lines

Also I am considering to just remove all this Enter/Leave debug non-sense since it makes the code really hard to read.

Quoted 6 lines
Quoted 1 line

I can remove those Enter/Leave debug, if you prefer.

Tell me what you need them for. I don't mind having the Enter part with BT_DBG since we are using that anyway to print debug information about the parameters we give to a function, but the Leave part is cluttering the code. Can you just follow the style the other drivers are using.

The whole btmrvl driver was ported from Marvell SD8688 Bluetooth reference = driver. The Enter/Leave debug messages have been in there since very beginn= ing. Sometimes these Enter/Leave things are useful for customers to debug w= hen our reference driver is ported onto their own platform/OS.

To make it easier to upstream kernel, I'm sending a patch to remove all Ent= er/Leave debug messages except for an Enter message with parameters passed = in.

Quoted 4 lines

And again, after that you are not done since the whole driver needs more cleanups. That is just in a shape I consider merging it upstream so we can start fixing it there. I still consider it a little bit too complicated for what is really needed to drive your hardware.

That's understood. Several items are remaining:

1) Proper handling of vendor commands/events
2) "rmmod" flag in exit_module()
3) more cleanups

Should you have any suggestions on any of these, I'd be happy to try.

Quoted 4 lines

Regards

Marcel

patch against bluetooth-mrvl-2.6.git tree:

Quoted 1 line

From 638a2d6f2dba0e1e23d2e2a61a15c48c36fd6b25 Mon Sep 17 00:00:00 2001

From: Bing Zhao <[email protected]>
Date: Tue, 9 Jun 2009 19:20:19 -0700
Subject: [PATCH] Bluetooth: Remove Enter/Leave debug messages for Marvell d= river

---

 drivers/bluetooth/btmrvl_main.c |   84 +----------------------------
 drivers/bluetooth/btmrvl_sdio.c |  110 +----------------------------------=
---
 2 files changed, 6 insertions(+), 188 deletions(-)
drivers/bluetooth/btmrvl_mai= renamed from drivers/bluetooth/btmrvl_main.c +0 -0

n.c
index 61168ec..c344300 100644

drivers/bluetooth/btmrvl_main.c +0 -4
@@ -32,8 +32,6 @@
  */
 void btmrvl_interrupt(struct btmrvl_private *priv)
 {
-       BT_DBG("Enter");
-
        priv->adapter->ps_state =3D PS_AWAKE;
 
        priv->adapter->wakeup_tries =3D 0;
@@ -41,8 +39,6 @@ void btmrvl_interrupt(struct btmrvl_private *priv)
        priv->adapter->int_count++;
 
        wake_up_interruptible(&priv->main_thread.wait_q);
-
-       BT_DBG("Leave");
 }
 EXPORT_SYMBOL_GPL(btmrvl_interrupt);
 
@@ -52,8 +48,6 @@ void btmrvl_check_evtpkt(struct btmrvl_private *priv, str=

uct sk_buff *skb)

        struct hci_ev_cmd_complete *ec;
        u16 opcode, ocf;

- BT_DBG("Enter");
-

        if (hdr->evt =3D=3D HCI_EV_CMD_COMPLETE) {
                ec =3D (void *) (skb->data + HCI_EVENT_HDR_SIZE);
                opcode =3D __le16_to_cpu(ec->opcode);
@@ -65,8 +59,6 @@ void btmrvl_check_evtpkt(struct btmrvl_private *priv, str=
uct sk_buff *skb)
                        wake_up_interruptible(&priv->adapter->cmd_wait_q);
                }
        }

-
- BT_DBG("Leave");
}
EXPORT_SYMBOL_GPL(btmrvl_check_evtpkt);

@@ -76,8 +68,6 @@ int btmrvl_process_event(struct btmrvl_private *priv, str= uct sk_buff *skb)

        struct btmrvl_event *event;
        u8 ret =3D 0;

- BT_DBG("Enter");
-

        event =3D (struct btmrvl_event *) skb->data;
        if (event->ec !=3D 0xff) {
                BT_DBG("Not Marvell Event=3D%x", event->ec);
@@ -151,8 +141,6 @@ exit:
        if (!ret)
                kfree_skb(skb);

- BT_DBG("Leave");
-

        return ret;

}
EXPORT_SYMBOL_GPL(btmrvl_process_event);
@@ -163,8 +151,6 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *p= riv, int subcmd)

        struct btmrvl_cmd *cmd;
        u8 ret =3D 0;

- BT_DBG("Enter");
-

        skb =3D bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
        if (skb =3D=3D NULL) {
                BT_ERR("No free skb");
@@ -202,8 +188,6 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *p=
riv, int subcmd)
        BT_DBG("module cfg Command done");

exit:
- BT_DBG("Leave");
-

        return ret;

}
EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
@@ -214,8 +198,6 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv= )

        struct btmrvl_cmd *cmd;
        u8 ret =3D 0;

- BT_DBG("Enter");
-

        skb =3D bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
        if (skb =3D=3D NULL) {
                BT_ERR("No free skb");
@@ -247,8 +229,6 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv=
)
        }

exit:
- BT_DBG("Leave");
-

        return ret;

}

@@ -258,8 +238,6 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)

        struct btmrvl_cmd *cmd;
        u8 ret =3D 0;

- BT_DBG("Enter");
-

        if (priv->btmrvl_dev.hscfgcmd) {
                priv->btmrvl_dev.hscfgcmd =3D 0;

@@ -328,8 +306,6 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)

        }

exit:
- BT_DBG("Leave");
-

        return ret;

}

@@ -337,17 +313,12 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv,=
struct sk_buff *skb)

 {
        u8 ret =3D 0;

- BT_DBG("Enter");
-
- if (!skb || !skb->data) {
- BT_DBG("Leave");
+ if (!skb || !skb->data)

                return -EINVAL;

- }

        if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) {
                BT_ERR("Tx Error: Bad skb length %d : %d",
                                                skb->len, BTM_UPLD_SIZE);
-               BT_DBG("Leave");
                return -EINVAL;
        }

@@ -359,7 +330,6 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv, s= truct sk_buff *skb)

                        BT_ERR("Tx Error: realloc_headroom failed %d",
                                BTM_HEADER_LEN);
                        skb =3D tmp;
-                       BT_DBG("Leave");
                        return -EINVAL;
                }

@@ -381,52 +351,35 @@ static int btmrvl_tx_pkt(struct btmrvl_private *priv,=
struct sk_buff *skb)

        if (priv->hw_host_to_card)
                ret =3D priv->hw_host_to_card(priv, skb->data, skb->len);

- BT_DBG("Leave");
-

        return ret;

}

static void btmrvl_init_adapter(struct btmrvl_private *priv) {
- BT_DBG("Enter");
-

        skb_queue_head_init(&priv->adapter->tx_queue);

        priv->adapter->ps_state =3D PS_AWAKE;

        init_waitqueue_head(&priv->adapter->cmd_wait_q);

-
- BT_DBG("Leave");
}

static void btmrvl_free_adapter(struct btmrvl_private *priv) {
- BT_DBG("Enter");
-

        skb_queue_purge(&priv->adapter->tx_queue);

        kfree(priv->adapter);

        priv->adapter =3D NULL;

-
- BT_DBG("Leave");
}

static int btmrvl_ioctl(struct hci_dev *hdev,
unsigned int cmd, unsigned long arg)
{
- BT_DBG("Enter");
-
- BT_DBG("Leave");
-

        return -ENOIOCTLCMD;

}

static void btmrvl_destruct(struct hci_dev *hdev) {
- BT_DBG("Enter");
-
- BT_DBG("Leave");
}

static int btmrvl_send_frame(struct sk_buff *skb)
@@ -434,11 +387,10 @@ static int btmrvl_send_frame(struct sk_buff *skb)

        struct hci_dev *hdev =3D (struct hci_dev *) skb->dev;
        struct btmrvl_private *priv =3D NULL;

- BT_DBG("Enter: type=3D%d, len=3D%d", skb->pkt_type, skb->len);
+ BT_DBG("packet type=3D%d, len=3D%d", skb->pkt_type, skb->len);

        if (!hdev || !hdev->driver_data) {
                BT_ERR("Frame for unknown HCI device");
-               BT_DBG("Leave");
                return -ENODEV;
        }

@@ -447,7 +399,6 @@ static int btmrvl_send_frame(struct sk_buff *skb)

                BT_ERR("Failed testing HCI_RUNING, flags=3D%lx", hdev->flag=

s);
print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
skb->data, skb->len=
);

-               BT_DBG("Leave");
                return -EBUSY;
        }

@@ -469,8 +420,6 @@ static int btmrvl_send_frame(struct sk_buff *skb)

        wake_up_interruptible(&priv->main_thread.wait_q);

- BT_DBG("Leave");
-

        return 0;

}

@@ -478,12 +427,8 @@ static int btmrvl_flush(struct hci_dev *hdev)

 {
        struct btmrvl_private *priv =3D hdev->driver_data;

- BT_DBG("Enter");
-

        skb_queue_purge(&priv->adapter->tx_queue);

- BT_DBG("Leave");
-

        return 0;

}

@@ -491,28 +436,18 @@ static int btmrvl_close(struct hci_dev *hdev)

 {
        struct btmrvl_private *priv =3D hdev->driver_data;

- BT_DBG("Enter");
-
- if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags)) {
- BT_DBG("Leave");
+ if (!test_and_clear_bit(HCI_RUNNING, &hdev->flags))

                return 0;

- }

        skb_queue_purge(&priv->adapter->tx_queue);

- BT_DBG("Leave");
-

        return 0;

}

static int btmrvl_open(struct hci_dev *hdev)
{
- BT_DBG("Enter");
-

        set_bit(HCI_RUNNING, &hdev->flags);

- BT_DBG("Leave");
-

        return 0;

}

@@ -529,8 +464,6 @@ static int btmrvl_service_main_thread(void *data)

        struct sk_buff *skb;
        ulong flags;

- BT_DBG("Enter");
-

        init_waitqueue_entry(&wait, current);

        current->flags |=3D PF_NOFREEZE;
@@ -588,8 +521,6 @@ static int btmrvl_service_main_thread(void *data)
                }
        }

- BT_DBG("Leave");
-

        return 0;

}

@@ -599,8 +530,6 @@ struct btmrvl_private *btmrvl_add_card(void *card)

        struct btmrvl_private *priv;
        int ret;

- BT_DBG("Enter");
-

        priv =3D kzalloc(sizeof(*priv), GFP_KERNEL);
        if (!priv) {
                BT_ERR("Can not allocate priv");
@@ -655,7 +584,6 @@ struct btmrvl_private *btmrvl_add_card(void *card)
        btmrvl_debugfs_init(hdev);

#endif

-       BT_DBG("Leave");
        return priv;

err_hci_register_dev:
@@ -671,8 +599,6 @@ err_adapter:

        kfree(priv);

err_priv:
- BT_DBG("Leave");
-

        return NULL;
 }
 EXPORT_SYMBOL_GPL(btmrvl_add_card);
@@ -681,8 +607,6 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
 {
        struct hci_dev *hdev;

- BT_DBG("Enter");
-

        hdev =3D priv->btmrvl_dev.hcidev;

        wake_up_interruptible(&priv->adapter->cmd_wait_q);

@@ -703,8 +627,6 @@ int btmrvl_remove_card(struct btmrvl_private *priv)

        kfree(priv);

- BT_DBG("Leave");
-

        return 0;

}
EXPORT_SYMBOL_GPL(btmrvl_remove_card);

drivers/bluetooth/btmrvl_sdi= renamed from drivers/bluetooth/btmrvl_sdio.c +0 -0

o.c
index 0dea23e..9fc973f 100644

drivers/bluetooth/btmrvl_sdio.c +0 -0
@@ -67,14 +67,10 @@ static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_c=

ard *card)

        u8 reg;
        int ret;

- BT_DBG("Enter");
-

        reg =3D sdio_readb(card->func, CARD_RX_UNIT_REG, &ret);
        if (!ret)
                card->rx_unit =3D reg;

- BT_DBG("Leave");
-

        return ret;

}

@@ -83,8 +79,6 @@ static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_= card *card, u16 *dat)

        int ret;
        u8 fws0, fws1;

- BT_DBG("Enter");
-

        *dat =3D 0;

        fws0 =3D sdio_readb(card->func, CARD_FW_STATUS0_REG, &ret);
@@ -92,15 +86,11 @@ static int btmrvl_sdio_read_fw_status(struct btmrvl_sdi=
o_card *card, u16 *dat)
        if (!ret)
                fws1 =3D sdio_readb(card->func, CARD_FW_STATUS1_REG, &ret);

- if (ret) {
- BT_DBG("Leave");
+ if (ret)

                return -EIO;

- }

        *dat =3D (((u16) fws1) << 8) | fws0;

- BT_DBG("Leave");
-

        return 0;

}

@@ -109,14 +99,10 @@ static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_= card *card, u16 *dat)

        int ret;
        u8 reg;

- BT_DBG("Enter");
-

        reg =3D sdio_readb(card->func, CARD_RX_LEN_REG, &ret);
        if (!ret)
                *dat =3D (u16) reg << card->rx_unit;

- BT_DBG("Leave");
-

        return ret;

}

@@ -125,16 +111,12 @@ static int btmrvl_sdio_enable_host_int_mask(struct bt= mrvl_sdio_card *card,

 {
        int ret;

- BT_DBG("Enter");
-

        sdio_writeb(card->func, mask, HOST_INT_MASK_REG, &ret);
        if (ret) {
                BT_ERR("Unable to enable the host interrupt!");
                ret =3D -EIO;
        }

- BT_DBG("Leave");
-

        return ret;

}

@@ -144,8 +126,6 @@ static int btmrvl_sdio_disable_host_int_mask(struct btm= rvl_sdio_card *card,

        int ret;
        u8 host_int_mask;

- BT_DBG("Enter");
-

        host_int_mask =3D sdio_readb(card->func, HOST_INT_MASK_REG, &ret);
        if (ret) {
                ret =3D -EIO;
@@ -164,8 +144,6 @@ static int btmrvl_sdio_disable_host_int_mask(struct btm=
rvl_sdio_card *card,
        ret =3D 0;

done:
- BT_DBG("Leave");
-

        return ret;

}

@@ -175,8 +153,6 @@ static int btmrvl_sdio_poll_card_status(struct btmrvl_s= dio_card *card, u8 bits)

        int ret;
        u8 status;

- BT_DBG("Enter");
-

        for (tries =3D 0; tries < MAX_POLL_TRIES * 1000; tries++) {
                status =3D sdio_readb(card->func, CARD_STATUS_REG, &ret);
                if (ret)
@@ -193,8 +169,6 @@ failed:
        BT_ERR("FAILED! ret=3D%d", ret);

done:
- BT_DBG("Leave");
-

        return ret;

}

@@ -205,8 +179,6 @@ static int btmrvl_sdio_verify_fw_download(struct btmrvl= _sdio_card *card,

        u16 firmwarestat;
        unsigned int tries;

- BT_DBG("Enter");
-

         /* Wait for firmware to become ready */
        for (tries =3D 0; tries < pollnum; tries++) {
                if (btmrvl_sdio_read_fw_status(card, &firmwarestat) < 0)
@@ -220,8 +192,6 @@ static int btmrvl_sdio_verify_fw_download(struct btmrvl=
_sdio_card *card,
                }
        }

- BT_DBG("Leave");
-

        return ret;

}

@@ -235,8 +205,6 @@ static int btmrvl_sdio_download_helper(struct btmrvl_sd= io_card *card)

        u8 *helperbuf;
        u32 tx_len;

- BT_DBG("Enter");
-

        ret =3D request_firmware(&fw_helper, card->helper,
                                                &card->func->dev);
        if ((ret < 0) || !fw_helper) {
@@ -326,8 +294,6 @@ done:
        if (fw_helper)
                release_firmware(fw_helper);

- BT_DBG("Leave");
-

        return ret;

}

@@ -343,8 +309,6 @@ static int btmrvl_sdio_download_fw_w_helper(struct btmr= vl_sdio_card *card)

        u16 len;
        int txlen =3D 0, tx_blocks =3D 0, count =3D 0;

- BT_DBG("Enter");
-

        ret =3D request_firmware(&fw_firmware, card->firmware,
                                                        &card->func->dev);
        if ((ret < 0) || !fw_firmware) {
@@ -479,8 +443,6 @@ done:
        if (fw_firmware)
                release_firmware(fw_firmware);

- BT_DBG("Leave");
-

        return ret;

}

@@ -494,8 +456,6 @@ static int btmrvl_sdio_card_to_host(struct btmrvl_priva= te *priv)

        struct hci_dev *hdev =3D priv->btmrvl_dev.hcidev;
        struct btmrvl_sdio_card *card =3D priv->btmrvl_dev.card;

- BT_DBG("Enter");
-

        if (!card || !card->func) {
                BT_ERR("card or function is NULL!");
                ret =3D -EINVAL;
@@ -596,8 +556,6 @@ exit:
                        kfree_skb(skb);
        }

- BT_DBG("Leave");
-

        return ret;

}

@@ -607,8 +565,6 @@ static int btmrvl_sdio_get_int_status(struct btmrvl_pri= vate *priv, u8 * ireg)

        u8 sdio_ireg =3D 0;
        struct btmrvl_sdio_card *card =3D priv->btmrvl_dev.card;

- BT_DBG("Enter");
-

        *ireg =3D 0;

        sdio_ireg =3D sdio_readb(card->func, HOST_INTSTATUS_REG, &ret);
@@ -653,8 +609,6 @@ static int btmrvl_sdio_get_int_status(struct btmrvl_pri=
vate *priv, u8 * ireg)
        ret =3D 0;

done:
- BT_DBG("Leave");
-

        return ret;

}

@@ -665,8 +619,6 @@ static void btmrvl_sdio_interrupt(struct sdio_func *fun=
c)

        struct btmrvl_sdio_card *card;
        u8 ireg =3D 0;

- BT_DBG("Enter");
-

        card =3D sdio_get_drvdata(func);
        if (card && card->priv) {
                priv =3D card->priv;

@@ -679,8 +631,6 @@ static void btmrvl_sdio_interrupt(struct sdio_func *fun=
c)

                btmrvl_interrupt(priv);
        }

-
- BT_DBG("Leave");
}

static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
@@ -689,8 +639,6 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_= card *card)

        u8 reg;
        int ret =3D 0;

- BT_DBG("Enter");
-

        if (!card || !card->func) {
                BT_ERR("Error: card or function is NULL!");
                ret =3D -EINVAL;

@@ -752,7 +700,6 @@ static int btmrvl_sdio_register_dev(struct btmrvl_sdio_= card *card)

        sdio_release_host(func);
-       BT_DBG("Leave");
        return 0;

release_irq:
@@ -765,14 +712,11 @@ release_host:

        sdio_release_host(func);

failed:

-       BT_DBG("Leave");
        return ret;

}

static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card *card) {
- BT_DBG("Enter");
-

        if (card && card->func) {
                sdio_claim_host(card->func);
                sdio_release_irq(card->func);
@@ -781,8 +725,6 @@ static int btmrvl_sdio_unregister_dev(struct btmrvl_sdi=
o_card *card)
                sdio_set_drvdata(card->func, NULL);
        }

- BT_DBG("Leave");
-

        return 0;

}

@@ -790,12 +732,8 @@ static int btmrvl_sdio_enable_host_int(struct btmrvl_s= dio_card *card)

 {
        int ret;

- BT_DBG("Enter");
-
- if (!card || !card->func) {
- BT_DBG("Leave");
+ if (!card || !card->func)

                return -EINVAL;

- }

        sdio_claim_host(card->func);

@@ -805,8 +743,6 @@ static int btmrvl_sdio_enable_host_int(struct btmrvl_sd= io_card *card)

        sdio_release_host(card->func);

- BT_DBG("Leave");
-

        return ret;

}

@@ -814,12 +750,8 @@ static int btmrvl_sdio_disable_host_int(struct btmrvl_= sdio_card *card)

 {
        int ret;

- BT_DBG("Enter");
-
- if (!card || !card->func) {
- BT_DBG("Leave");
+ if (!card || !card->func)

                return -EINVAL;

- }

        sdio_claim_host(card->func);

@@ -827,8 +759,6 @@ static int btmrvl_sdio_disable_host_int(struct btmrvl_s= dio_card *card)

        sdio_release_host(card->func);

- BT_DBG("Leave");
-

        return ret;

}

@@ -844,11 +774,8 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_priv= ate *priv,

        void *tmpbuf =3D NULL;
        int tmpbufsz;

- BT_DBG("Enter");
-

        if (!card || !card->func) {
                BT_ERR("card or function is NULL!");
-               BT_DBG("Leave");
                return -EINVAL;
        }

@@ -886,8 +813,6 @@ static int btmrvl_sdio_host_to_card(struct btmrvl_priva= te *priv,
exit:

        sdio_release_host(card->func);

- BT_DBG("Leave");
-

        return ret;

}

@@ -895,11 +820,8 @@ static int btmrvl_sdio_download_fw(struct btmrvl_sdio_= card *card)

 {
        int ret =3D 0;

- BT_DBG("Enter");
-

        if (!card || !card->func) {
                BT_ERR("card or function is NULL!");
-               BT_DBG("Leave");
                return -EINVAL;
        }
        sdio_claim_host(card->func);
@@ -931,8 +853,6 @@ static int btmrvl_sdio_download_fw(struct btmrvl_sdio_c=
ard *card)
 done:
        sdio_release_host(card->func);

- BT_DBG("Leave");
-

        return ret;

}

@@ -941,11 +861,8 @@ static int btmrvl_sdio_wakeup_fw(struct btmrvl_private=
*priv)

        struct btmrvl_sdio_card *card =3D priv->btmrvl_dev.card;
        int ret =3D 0;

- BT_DBG("Enter");
-

        if (!card || !card->func) {
                BT_ERR("card or function is NULL!");
-               BT_DBG("Leave");
                return -EINVAL;
        }

@@ -957,8 +874,6 @@ static int btmrvl_sdio_wakeup_fw(struct btmrvl_private = *priv)

        BT_DBG("wake up firmware");

- BT_DBG("Leave");
-

        return ret;

}

@@ -969,8 +884,6 @@ static int btmrvl_sdio_probe(struct sdio_func *func,

        struct btmrvl_private *priv =3D NULL;
        struct btmrvl_sdio_card *card =3D NULL;

- BT_DBG("Enter");
-

        BT_INFO("vendor=3D0x%x, device=3D0x%x, class=3D%d, fn=3D%d",
                        id->vendor, id->device, id->class, func->num);

@@ -1025,8 +938,6 @@ static int btmrvl_sdio_probe(struct sdio_func *func,

        btmrvl_send_module_cfg_cmd(priv, MODULE_BRINGUP_REQ);

- BT_DBG("Leave");
-

        return 0;

disable_host_int:
@@ -1036,8 +947,6 @@ unreg_dev:
free_card:

        kfree(card);
 done:
-       BT_DBG("Leave");
-
        return ret;

}

@@ -1045,8 +954,6 @@ static void btmrvl_sdio_remove(struct sdio_func *func)

 {
        struct btmrvl_sdio_card *card;

- BT_DBG("Enter");
-

        if (func) {
                card =3D sdio_get_drvdata(func);
                if (card) {
@@ -1064,8 +971,6 @@ static void btmrvl_sdio_remove(struct sdio_func *func)
                        kfree(card);
                }
        }

-
- BT_DBG("Leave");
}

static struct sdio_driver bt_mrvl_sdio =3D {
@@ -1077,32 +982,23 @@ static struct sdio_driver bt_mrvl_sdio =3D {

static int btmrvl_sdio_init_module(void)
{
- BT_DBG("Enter");
-

        if (sdio_register_driver(&bt_mrvl_sdio) !=3D 0) {
                BT_ERR("SDIO Driver Registration Failed");
-               BT_DBG("Leave");
                return -ENODEV;
        }

        /* Clear the flag in case user removes the card. */
        user_rmmod =3D 0;

- BT_DBG("Leave");
-

        return 0;

}

static void btmrvl_sdio_exit_module(void)
{
- BT_DBG("Enter");
-

        /* Set the flag as user is removing this module. */
        user_rmmod =3D 1;

        sdio_unregister_driver(&bt_mrvl_sdio);

-
- BT_DBG("Leave");
}

module_init(btmrvl_sdio_init_module);
--
1.5.3.6

Thanks,

Bing

maintainer
#8 lore raw

Hi Bing,

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 6 lines
Quoted 3 lines

This driver provides basic definitions and library functions to support Marvell Bluetooth enabled devices, such as 88W8688 WLAN/BT combo chip.

so I created a bluetooth-mrvl-2.6 tree with your patches and already a major collection of cleanup patches.

Thanks for the cleanups.

Quoted 3 lines

The biggest problem right now is that your driver spits out casting warnings like crazy. This is not acceptable. So please send me a patch to fix these based on bluetooth-mrvl-2.6.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Could you please let me know how to catch these casting warnings? I'm using GCC 4.3.2 with sparse

on x86 laptop (Fedora 8) but I couldn't get the warnings.

let me guess, you are running a 32-bit kernel. Just run a 64-bit kernel and you will see them. I am using Fedora 10.

Yes, I'm running 32-bit kernel. I'll try to install a 64-bit system and fix those warnings.

seriously don't do that. There is so many 32-bit stuff in the code that I am afraid it will fall over on 64-bit machines. I have cleaned up almost everything, but in btmrvl_sdio.c you have some nasty alignment thing going on. Please fix that and test it on 64-bit systems since it looks really scary.

Can you explain how the firmware loading process is suppose to work. The code looks way too complicated for what I can make out of it. We have to make this more readable.

Quoted 4 lines

The whole btmrvl driver was ported from Marvell SD8688 Bluetooth reference driver. The Enter/Leave debug messages have been in there since very beginning. Sometimes these Enter/Leave things are useful for customers to debug when our reference driver is ported onto their own platform/OS.

To make it easier to upstream kernel, I'm sending a patch to remove all Enter/Leave debug messages except for an Enter message with parameters passed in.

I removed them by myself since your patch was breaking with my cleanups. It is pushed now and to please test the latest bluetooth-mrvl-2.6.git tree.

Quoted 5 lines
Quoted 4 lines

And again, after that you are not done since the whole driver needs more cleanups. That is just in a shape I consider merging it upstream so we can start fixing it there. I still consider it a little bit too complicated for what is really needed to drive your hardware.

Quoted 7 lines

That's understood. Several items are remaining:

1) Proper handling of vendor commands/events
2) "rmmod" flag in exit_module()
3) more cleanups

Should you have any suggestions on any of these, I'd be happy to try.

I will work with you on them, but first we have to fix this alignment mess. So please go through your SDIO code and run it also on a 64-bit system.

Regards

Marcel

author
#9 lore raw

Hi Marcel,

Quoted 6 lines

-----Original Message-----
From: Marcel Holtmann [mailto:[email protected]]
Sent: Friday, June 12, 2009 11:24 PM
To: Bing Zhao
Cc: [email protected]
Subject: RE: [PATCH 1/4 v3] bluetooth: add btmrvl driver to support Marve=

ll bluetooth devices

Quoted 5 lines

=20
Hi Bing,
=20

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

This driver provides basic definitions and library functions to support Marvell Bluetooth enabled devices, such as 88W8688 WLAN=

/BT

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

combo chip.

so I created a bluetooth-mrvl-2.6 tree with your patches and alre=

ady a

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

major collection of cleanup patches.

Thanks for the cleanups.

Quoted 1 line

The biggest problem right now is that your driver spits out casti=

ng

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

warnings like crazy. This is not acceptable. So please send me a =

patch

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

to fix these based on bluetooth-mrvl-2.6.

Could you please let me know how to catch these casting warnings? I=

'm using GCC 4.3.2 with

Quoted 4 lines

sparse

Quoted 3 lines
Quoted 3 lines

on x86 laptop (Fedora 8) but I couldn't get the warnings.

let me guess, you are running a 32-bit kernel. Just run a 64-bit kern=

el

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

and you will see them. I am using Fedora 10.

Yes, I'm running 32-bit kernel. I'll try to install a 64-bit system and=

fix those warnings.

Quoted 6 lines

=20
seriously don't do that. There is so many 32-bit stuff in the code that I am afraid it will fall over on 64-bit machines. I have cleaned up almost everything, but in btmrvl_sdio.c you have some nasty alignment thing going on. Please fix that and test it on 64-bit systems since it looks really scary.

Thanks for the code cleanup. I'm ordering a new laptop for 64-bit developme= nt/debugging. I'll work on the alignment issues once my 64-bit system is re= ady.

Quoted 3 lines

Can you explain how the firmware loading process is suppose to work. The code looks way too complicated for what I can make out of it. We have to make this more readable.

There are two steps involving firmware downloading.
1) helper downloading; 2) firmware downloading through helper.

The helper is small size of image that needs to be downloaded first. The wh= ole image data is cut to multiple trunks which will be written (CMD53) to c= ard consecutively. Each trunk has fixed size of 124 bytes of helper image p= lus 4 bytes of header (totaling 128 bytes or 2 blocks with block size 64). = After all image data is downloaded an EOF block (1 block) is written to car= d to finish the helper downloading. The helper gets initialized afterwards.

After helper is downloaded, firmware downloading process starts. The firmwa= re image data is also cut to multiple trunks for CMD53. But the size of eve= ry trunk is not fixed. Each trunk size is determined by the helper. The dri= ver communicates with helper to get the trunk size and then download the re= quested image to the card.

Quoted 1 line
Quoted 1 line

The whole btmrvl driver was ported from Marvell SD8688 Bluetooth refere=

nce driver. The Enter/Leave

Quoted 1 line

debug messages have been in there since very beginning. Sometimes these E=

nter/Leave things are useful

Quoted 1 line

for customers to debug when our reference driver is ported onto their own=

platform/OS.

Quoted 3 lines
Quoted 3 lines

To make it easier to upstream kernel, I'm sending a patch to remove all=

Enter/Leave debug messages

Quoted 5 lines

except for an Enter message with parameters passed in.
=20
I removed them by myself since your patch was breaking with my cleanups. It is pushed now and to please test the latest bluetooth-mrvl-2.6.git tree.

Thanks. I'll pull the latest code.

Quoted 1 line
Quoted 1 line
Quoted 1 line

And again, after that you are not done since the whole driver needs m=

ore

Quoted 1 line
Quoted 1 line
Quoted 1 line

cleanups. That is just in a shape I consider merging it upstream so w=

e

Quoted 9 lines
Quoted 9 lines
Quoted 2 lines

can start fixing it there. I still consider it a little bit too complicated for what is really needed to drive your hardware.

That's understood. Several items are remaining:

1) Proper handling of vendor commands/events
2) "rmmod" flag in exit_module()
3) more cleanups

Quoted 5 lines
Quoted 1 line

Should you have any suggestions on any of these, I'd be happy to try.

=20
I will work with you on them, but first we have to fix this alignment mess. So please go through your SDIO code and run it also on a 64-bit system.

Will do.

Thanks,

Bing

Quoted 4 lines

Regards
=20
Marcel
=20