Commit 4271e08d authored by Marcel Holtmann's avatar Marcel Holtmann

Bluetooth: Some coding style cleanup for Marvell core driver

The Marvell core Bluetooth driver has various weird casting and unneeded
braces in its code that makes it hard to read. Remove all of these to
make the code a little bit simpler.
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 54239903
...@@ -48,19 +48,18 @@ EXPORT_SYMBOL_GPL(btmrvl_interrupt); ...@@ -48,19 +48,18 @@ EXPORT_SYMBOL_GPL(btmrvl_interrupt);
void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb) void btmrvl_check_evtpkt(struct btmrvl_private *priv, struct sk_buff *skb)
{ {
struct hci_event_hdr *hdr = (struct hci_event_hdr *)skb->data; struct hci_event_hdr *hdr = (void *) skb->data;
struct hci_ev_cmd_complete *ec; struct hci_ev_cmd_complete *ec;
u16 opcode, ocf; u16 opcode, ocf;
BT_DBG("Enter"); BT_DBG("Enter");
if (hdr->evt == HCI_EV_CMD_COMPLETE) { if (hdr->evt == HCI_EV_CMD_COMPLETE) {
ec = (struct hci_ev_cmd_complete *)(skb->data + ec = (void *) (skb->data + HCI_EVENT_HDR_SIZE);
HCI_EVENT_HDR_SIZE);
opcode = __le16_to_cpu(ec->opcode); opcode = __le16_to_cpu(ec->opcode);
ocf = hci_opcode_ocf(opcode); ocf = hci_opcode_ocf(opcode);
if ((ocf == BT_CMD_MODULE_CFG_REQ) && if (ocf == BT_CMD_MODULE_CFG_REQ &&
(priv->btmrvl_dev.sendcmdflag)) { priv->btmrvl_dev.sendcmdflag) {
priv->btmrvl_dev.sendcmdflag = false; priv->btmrvl_dev.sendcmdflag = false;
priv->adapter->cmd_complete = true; priv->adapter->cmd_complete = true;
wake_up_interruptible(&priv->adapter->cmd_wait_q); wake_up_interruptible(&priv->adapter->cmd_wait_q);
...@@ -74,8 +73,8 @@ EXPORT_SYMBOL_GPL(btmrvl_check_evtpkt); ...@@ -74,8 +73,8 @@ EXPORT_SYMBOL_GPL(btmrvl_check_evtpkt);
int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb) int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
{ {
struct btmrvl_adapter *adapter = priv->adapter; struct btmrvl_adapter *adapter = priv->adapter;
u8 ret = 0;
struct btmrvl_event *event; struct btmrvl_event *event;
u8 ret = 0;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -121,12 +120,12 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb) ...@@ -121,12 +120,12 @@ int btmrvl_process_event(struct btmrvl_private *priv, struct sk_buff *skb)
break; break;
case BT_CMD_MODULE_CFG_REQ: case BT_CMD_MODULE_CFG_REQ:
if ((priv->btmrvl_dev.sendcmdflag) && if (priv->btmrvl_dev.sendcmdflag &&
(event->data[1] == MODULE_BRINGUP_REQ)) { event->data[1] == MODULE_BRINGUP_REQ) {
BT_DBG("EVENT:%s", (event->data[2]) ? BT_DBG("EVENT:%s", (event->data[2]) ?
"Bring-up failed" : "Bring-up succeed"); "Bring-up failed" : "Bring-up succeed");
} else if ((priv->btmrvl_dev.sendcmdflag) && } else if (priv->btmrvl_dev.sendcmdflag &&
(event->data[1] == MODULE_SHUTDOWN_REQ)) { event->data[1] == MODULE_SHUTDOWN_REQ) {
BT_DBG("EVENT:%s", (event->data[2]) ? BT_DBG("EVENT:%s", (event->data[2]) ?
"Shutdown failed" : "Shutdown succeed"); "Shutdown failed" : "Shutdown succeed");
} else { } else {
...@@ -160,9 +159,9 @@ EXPORT_SYMBOL_GPL(btmrvl_process_event); ...@@ -160,9 +159,9 @@ EXPORT_SYMBOL_GPL(btmrvl_process_event);
int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
{ {
struct sk_buff *skb = NULL; struct sk_buff *skb;
u8 ret = 0;
struct btmrvl_cmd *cmd; struct btmrvl_cmd *cmd;
u8 ret = 0;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -181,7 +180,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) ...@@ -181,7 +180,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
skb_put(skb, sizeof(*cmd)); skb_put(skb, sizeof(*cmd));
skb->dev = (void *)priv->btmrvl_dev.hcidev; skb->dev = (void *) priv->btmrvl_dev.hcidev;
skb_queue_head(&priv->adapter->tx_queue, skb); skb_queue_head(&priv->adapter->tx_queue, skb);
priv->btmrvl_dev.sendcmdflag = true; priv->btmrvl_dev.sendcmdflag = true;
...@@ -192,8 +191,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd) ...@@ -192,8 +191,7 @@ int btmrvl_send_module_cfg_cmd(struct btmrvl_private *priv, int subcmd)
wake_up_interruptible(&priv->main_thread.wait_q); wake_up_interruptible(&priv->main_thread.wait_q);
if (!wait_event_interruptible_timeout( if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
priv->adapter->cmd_wait_q,
priv->adapter->cmd_complete, priv->adapter->cmd_complete,
msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) { msecs_to_jiffies(WAIT_UNTIL_CMD_RESP))) {
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
...@@ -212,9 +210,9 @@ EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd); ...@@ -212,9 +210,9 @@ EXPORT_SYMBOL_GPL(btmrvl_send_module_cfg_cmd);
static int btmrvl_enable_hs(struct btmrvl_private *priv) static int btmrvl_enable_hs(struct btmrvl_private *priv)
{ {
struct sk_buff *skb = NULL; struct sk_buff *skb;
u8 ret = 0;
struct btmrvl_cmd *cmd; struct btmrvl_cmd *cmd;
u8 ret = 0;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -232,20 +230,18 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv) ...@@ -232,20 +230,18 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv)
bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
skb_put(skb, sizeof(*cmd)); skb_put(skb, sizeof(*cmd));
skb->dev = (void *)priv->btmrvl_dev.hcidev; skb->dev = (void *) priv->btmrvl_dev.hcidev;
skb_queue_head(&priv->adapter->tx_queue, skb); skb_queue_head(&priv->adapter->tx_queue, skb);
BT_DBG("Queue hs enable Command"); BT_DBG("Queue hs enable Command");
wake_up_interruptible(&priv->main_thread.wait_q); wake_up_interruptible(&priv->main_thread.wait_q);
if (!wait_event_interruptible_timeout( if (!wait_event_interruptible_timeout(priv->adapter->cmd_wait_q,
priv->adapter->cmd_wait_q,
priv->adapter->hs_state, priv->adapter->hs_state,
msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) { msecs_to_jiffies(WAIT_UNTIL_HS_STATE_CHANGED))) {
ret = -ETIMEDOUT; ret = -ETIMEDOUT;
BT_ERR("timeout: %d, %d,%d", BT_ERR("timeout: %d, %d,%d", priv->adapter->hs_state,
priv->adapter->hs_state,
priv->adapter->ps_state, priv->adapter->ps_state,
priv->adapter->wakeup_tries); priv->adapter->wakeup_tries);
} }
...@@ -259,8 +255,8 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv) ...@@ -259,8 +255,8 @@ static int btmrvl_enable_hs(struct btmrvl_private *priv)
int btmrvl_prepare_command(struct btmrvl_private *priv) int btmrvl_prepare_command(struct btmrvl_private *priv)
{ {
struct sk_buff *skb = NULL; struct sk_buff *skb = NULL;
u8 ret = 0;
struct btmrvl_cmd *cmd; struct btmrvl_cmd *cmd;
u8 ret = 0;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -284,7 +280,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv) ...@@ -284,7 +280,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
skb_put(skb, sizeof(*cmd)); skb_put(skb, sizeof(*cmd));
skb->dev = (void *)priv->btmrvl_dev.hcidev; skb->dev = (void *) priv->btmrvl_dev.hcidev;
skb_queue_head(&priv->adapter->tx_queue, skb); skb_queue_head(&priv->adapter->tx_queue, skb);
BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x", BT_DBG("Queue HSCFG Command, gpio=0x%x, gap=0x%x",
...@@ -314,7 +310,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv) ...@@ -314,7 +310,7 @@ int btmrvl_prepare_command(struct btmrvl_private *priv)
bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT; bt_cb(skb)->pkt_type = MRVL_VENDOR_PKT;
skb_put(skb, sizeof(*cmd)); skb_put(skb, sizeof(*cmd));
skb->dev = (void *)priv->btmrvl_dev.hcidev; skb->dev = (void *) priv->btmrvl_dev.hcidev;
skb_queue_head(&priv->adapter->tx_queue, skb); skb_queue_head(&priv->adapter->tx_queue, skb);
BT_DBG("Queue PSMODE Command:%d", cmd->data[0]); BT_DBG("Queue PSMODE Command:%d", cmd->data[0]);
...@@ -416,8 +412,8 @@ static void btmrvl_free_adapter(struct btmrvl_private *priv) ...@@ -416,8 +412,8 @@ static void btmrvl_free_adapter(struct btmrvl_private *priv)
BT_DBG("Leave"); BT_DBG("Leave");
} }
static int static int btmrvl_ioctl(struct hci_dev *hdev,
btmrvl_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg) unsigned int cmd, unsigned long arg)
{ {
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -435,7 +431,7 @@ static void btmrvl_destruct(struct hci_dev *hdev) ...@@ -435,7 +431,7 @@ static void btmrvl_destruct(struct hci_dev *hdev)
static int btmrvl_send_frame(struct sk_buff *skb) static int btmrvl_send_frame(struct sk_buff *skb)
{ {
struct hci_dev *hdev = (struct hci_dev *)skb->dev; struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct btmrvl_private *priv = NULL; struct btmrvl_private *priv = NULL;
BT_DBG("Enter: type=%d, len=%d", skb->pkt_type, skb->len); BT_DBG("Enter: type=%d, len=%d", skb->pkt_type, skb->len);
...@@ -446,7 +442,7 @@ static int btmrvl_send_frame(struct sk_buff *skb) ...@@ -446,7 +442,7 @@ static int btmrvl_send_frame(struct sk_buff *skb)
return -ENODEV; return -ENODEV;
} }
priv = (struct btmrvl_private *)hdev->driver_data; priv = (struct btmrvl_private *) hdev->driver_data;
if (!test_bit(HCI_RUNNING, &hdev->flags)) { if (!test_bit(HCI_RUNNING, &hdev->flags)) {
BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags); BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET, print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
...@@ -480,8 +476,7 @@ static int btmrvl_send_frame(struct sk_buff *skb) ...@@ -480,8 +476,7 @@ static int btmrvl_send_frame(struct sk_buff *skb)
static int btmrvl_flush(struct hci_dev *hdev) static int btmrvl_flush(struct hci_dev *hdev)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = hdev->driver_data;
(struct btmrvl_private *) hdev->driver_data;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -494,8 +489,7 @@ static int btmrvl_flush(struct hci_dev *hdev) ...@@ -494,8 +489,7 @@ static int btmrvl_flush(struct hci_dev *hdev)
static int btmrvl_close(struct hci_dev *hdev) static int btmrvl_close(struct hci_dev *hdev)
{ {
struct btmrvl_private *priv = struct btmrvl_private *priv = hdev->driver_data;
(struct btmrvl_private *) hdev->driver_data;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -568,7 +562,7 @@ static int btmrvl_service_main_thread(void *data) ...@@ -568,7 +562,7 @@ static int btmrvl_service_main_thread(void *data)
spin_lock_irqsave(&priv->driver_lock, flags); spin_lock_irqsave(&priv->driver_lock, flags);
if (adapter->int_count) { if (adapter->int_count) {
adapter->int_count = 0; adapter->int_count = 0;
} else if ((adapter->ps_state == PS_SLEEP) && } else if (adapter->ps_state == PS_SLEEP &&
!skb_queue_empty(&adapter->tx_queue)) { !skb_queue_empty(&adapter->tx_queue)) {
spin_unlock_irqrestore(&priv->driver_lock, flags); spin_unlock_irqrestore(&priv->driver_lock, flags);
adapter->wakeup_tries++; adapter->wakeup_tries++;
...@@ -588,8 +582,7 @@ static int btmrvl_service_main_thread(void *data) ...@@ -588,8 +582,7 @@ static int btmrvl_service_main_thread(void *data)
if (btmrvl_tx_pkt(priv, skb)) if (btmrvl_tx_pkt(priv, skb))
priv->btmrvl_dev.hcidev->stat.err_tx++; priv->btmrvl_dev.hcidev->stat.err_tx++;
else else
priv->btmrvl_dev.hcidev->stat.byte_tx priv->btmrvl_dev.hcidev->stat.byte_tx += skb->len;
+= skb->len;
kfree_skb(skb); kfree_skb(skb);
} }
...@@ -603,7 +596,7 @@ static int btmrvl_service_main_thread(void *data) ...@@ -603,7 +596,7 @@ static int btmrvl_service_main_thread(void *data)
struct btmrvl_private *btmrvl_add_card(void *card) struct btmrvl_private *btmrvl_add_card(void *card)
{ {
struct hci_dev *hdev = NULL; struct hci_dev *hdev = NULL;
struct btmrvl_private *priv = NULL; struct btmrvl_private *priv;
int ret; int ret;
BT_DBG("Enter"); BT_DBG("Enter");
...@@ -717,6 +710,6 @@ int btmrvl_remove_card(struct btmrvl_private *priv) ...@@ -717,6 +710,6 @@ int btmrvl_remove_card(struct btmrvl_private *priv)
EXPORT_SYMBOL_GPL(btmrvl_remove_card); EXPORT_SYMBOL_GPL(btmrvl_remove_card);
MODULE_AUTHOR("Marvell International Ltd."); MODULE_AUTHOR("Marvell International Ltd.");
MODULE_DESCRIPTION("Marvell Bluetooth Driver v" VERSION); MODULE_DESCRIPTION("Marvell Bluetooth Driver ver" VERSION);
MODULE_VERSION(VERSION); MODULE_VERSION(VERSION);
MODULE_LICENSE("GPL v2"); MODULE_LICENSE("GPL v2");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment