summaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorFabian Schindlatz <fabian.schindlatz@fau.de>2019-07-01 16:57:13 -0400
committerMarcel Holtmann <marcel@holtmann.org>2019-07-06 06:30:51 -0400
commit6322f377bc4a0e3dac040c1c6d01761514f42187 (patch)
tree33d8569029e31fce567f5221492a1611677e96ef /drivers/bluetooth
parenta2e02f38eff84f199c8e32359eb213f81f270047 (diff)
Bluetooth: hci_ll: Refactor download_firmware
Extract the new function send_command_from_firmware from download_firmware, which helps with the readability of the switch statement. This way the code is less deeply nested and also no longer exceeds the 80 character limit. Co-developed-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de> Signed-off-by: Thomas Röthenbacher <thomas.roethenbacher@fau.de> Signed-off-by: Fabian Schindlatz <fabian.schindlatz@fau.de> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/hci_ll.c45
1 files changed, 28 insertions, 17 deletions
diff --git a/drivers/bluetooth/hci_ll.c b/drivers/bluetooth/hci_ll.c
index cbd7bc539d5e..938ba2737b63 100644
--- a/drivers/bluetooth/hci_ll.c
+++ b/drivers/bluetooth/hci_ll.c
@@ -474,6 +474,32 @@ out:
474 return err ? err : version; 474 return err ? err : version;
475} 475}
476 476
477static int send_command_from_firmware(struct ll_device *lldev,
478 struct hci_command *cmd)
479{
480 struct sk_buff *skb;
481
482 if (cmd->opcode == HCI_VS_UPDATE_UART_HCI_BAUDRATE) {
483 /* ignore remote change
484 * baud rate HCI VS command
485 */
486 bt_dev_warn(lldev->hu.hdev,
487 "change remote baud rate command in firmware");
488 return 0;
489 }
490 if (cmd->prefix != 1)
491 bt_dev_dbg(lldev->hu.hdev, "command type %d", cmd->prefix);
492
493 skb = __hci_cmd_sync(lldev->hu.hdev, cmd->opcode, cmd->plen,
494 &cmd->speed, HCI_INIT_TIMEOUT);
495 if (IS_ERR(skb)) {
496 bt_dev_err(lldev->hu.hdev, "send command failed");
497 return PTR_ERR(skb);
498 }
499 kfree_skb(skb);
500 return 0;
501}
502
477/** 503/**
478 * download_firmware - 504 * download_firmware -
479 * internal function which parses through the .bts firmware 505 * internal function which parses through the .bts firmware
@@ -486,7 +512,6 @@ static int download_firmware(struct ll_device *lldev)
486 unsigned char *ptr, *action_ptr; 512 unsigned char *ptr, *action_ptr;
487 unsigned char bts_scr_name[40]; /* 40 char long bts scr name? */ 513 unsigned char bts_scr_name[40]; /* 40 char long bts scr name? */
488 const struct firmware *fw; 514 const struct firmware *fw;
489 struct sk_buff *skb;
490 struct hci_command *cmd; 515 struct hci_command *cmd;
491 516
492 version = read_local_version(lldev->hu.hdev); 517 version = read_local_version(lldev->hu.hdev);
@@ -528,23 +553,9 @@ static int download_firmware(struct ll_device *lldev)
528 case ACTION_SEND_COMMAND: /* action send */ 553 case ACTION_SEND_COMMAND: /* action send */
529 bt_dev_dbg(lldev->hu.hdev, "S"); 554 bt_dev_dbg(lldev->hu.hdev, "S");
530 cmd = (struct hci_command *)action_ptr; 555 cmd = (struct hci_command *)action_ptr;
531 if (cmd->opcode == HCI_VS_UPDATE_UART_HCI_BAUDRATE) { 556 err = send_command_from_firmware(lldev, cmd);
532 /* ignore remote change 557 if (err)
533 * baud rate HCI VS command
534 */
535 bt_dev_warn(lldev->hu.hdev, "change remote baud rate command in firmware");
536 break;
537 }
538 if (cmd->prefix != 1)
539 bt_dev_dbg(lldev->hu.hdev, "command type %d", cmd->prefix);
540
541 skb = __hci_cmd_sync(lldev->hu.hdev, cmd->opcode, cmd->plen, &cmd->speed, HCI_INIT_TIMEOUT);
542 if (IS_ERR(skb)) {
543 bt_dev_err(lldev->hu.hdev, "send command failed");
544 err = PTR_ERR(skb);
545 goto out_rel_fw; 558 goto out_rel_fw;
546 }
547 kfree_skb(skb);
548 break; 559 break;
549 case ACTION_WAIT_EVENT: /* wait */ 560 case ACTION_WAIT_EVENT: /* wait */
550 /* no need to wait as command was synchronous */ 561 /* no need to wait as command was synchronous */