OSDN Git Service

Use properly typed tHCI_MODE
authorChris Manton <cmanton@google.com>
Mon, 7 Dec 2020 21:52:48 +0000 (13:52 -0800)
committerChris Manton <cmanton@google.com>
Sat, 12 Dec 2020 19:08:11 +0000 (19:08 +0000)
Towards readable code

Bug: 163134718
Tag: #refactor
Test: gd/cert/run --host

Change-Id: I7be7d39002e01da7777360d1467d99ea7287565c

stack/acl/acl.h
stack/acl/btm_pm.cc
stack/btu/btu_hcif.cc
stack/include/acl_hci_link_interface.h

index ba03a91..1282f9e 100644 (file)
@@ -250,7 +250,7 @@ typedef struct {
                                    const RawAddress& bd_addr, uint8_t new_role);
   friend void btm_pm_proc_cmd_status(uint8_t status);
   friend void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
-                                      uint8_t mode, uint16_t interval);
+                                      tHCI_MODE mode, uint16_t interval);
   friend void btm_pm_proc_ssr_evt(uint8_t* p, uint16_t evt_len);
   friend void btm_pm_reset(void);
   friend void btm_pm_sm_alloc(uint8_t ind);
index 8ac5fd5..8f67eee 100644 (file)
@@ -638,7 +638,9 @@ void btm_pm_proc_cmd_status(uint8_t status) {
  *
  ******************************************************************************/
 void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
-                             uint8_t mode, uint16_t interval) {
+                             tHCI_MODE hci_mode, uint16_t interval) {
+  tBTM_PM_STATUS mode = static_cast<tBTM_PM_STATUS>(hci_mode);
+
   tBTM_PM_MCB* p_cb = NULL;
   int xx, yy, zz;
   tBTM_PM_STATE old_state;
index 818418e..c64a1ad 100644 (file)
@@ -1573,7 +1573,8 @@ static void btu_hcif_mode_change_evt(uint8_t* p) {
   STREAM_TO_UINT8(current_mode, p);
   STREAM_TO_UINT16(interval, p);
   btm_sco_chk_pend_unpark(status, handle);
-  btm_pm_proc_mode_change(status, handle, current_mode, interval);
+  btm_pm_proc_mode_change(status, handle, static_cast<tHCI_MODE>(current_mode),
+                          interval);
 
 #if (HID_DEV_INCLUDED == TRUE && HID_DEV_PM_INCLUDED == TRUE)
   hidd_pm_proc_mode_change(status, current_mode, interval);
index 2c7ace6..64ee886 100644 (file)
@@ -21,6 +21,7 @@
 
 #include "stack/include/bt_types.h"
 #include "stack/include/hci_error_code.h"
+#include "stack/include/hcidefs.h"
 
 // This header contains functions for HCIF-Acl Management to invoke
 //
@@ -39,7 +40,7 @@ void btm_blacklist_role_change_device(const RawAddress& bd_addr,
                                       uint8_t hci_status);
 void btm_pm_proc_cmd_status(uint8_t status);
 void btm_pm_proc_mode_change(uint8_t hci_status, uint16_t hci_handle,
-                             uint8_t mode, uint16_t interval);
+                             tHCI_MODE mode, uint16_t interval);
 void btm_pm_proc_ssr_evt(uint8_t* p, uint16_t evt_len);
 void btm_process_clk_off_comp_evt(uint16_t hci_handle, uint16_t clock_offset);
 void btm_read_automatic_flush_timeout_complete(uint8_t* p);