build: LOG_TAG consistency, include order, build fixes

Fix the order of includes across a bunch of files, and declare LOG_TAG
at the top of every file in which it is used.

Consistently use bt_ as a LOG_TAG prefix.
Fix issues with LOG macro usage.
Remove unused includes and double-includes (when in related .h)

Add includes as necessary to compile cleanly (problems surfaced by
reordering includes)

Change-Id: Ic55520c8302b06bbc1942c10c448b20844669da6
diff --git a/bta/av/bta_av_act.c b/bta/av/bta_av_act.c
index 6816d8b..75dbb10 100644
--- a/bta/av/bta_av_act.c
+++ b/bta/av/bta_av_act.c
@@ -23,6 +23,8 @@
  *
  ******************************************************************************/
 
+#define LOG_TAG "bt_bta_av"
+
 #include "bt_target.h"
 
 #if defined(BTA_AV_INCLUDED) && (BTA_AV_INCLUDED == TRUE)
@@ -41,7 +43,6 @@
 #include "bta_ar_api.h"
 #endif
 
-#define LOG_TAG "bt_bta_av"
 #include "osi/include/log.h"
 
 /*****************************************************************************
@@ -142,7 +143,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         bta_av_close_all_rc
@@ -334,7 +334,6 @@
     /* note: BTA_AV_FEAT_RCTG = AVRC_CT_TARGET, BTA_AV_FEAT_RCCT = AVRC_CT_CONTROL */
     ccb.control = p_cb->features & (BTA_AV_FEAT_RCTG | BTA_AV_FEAT_RCCT | AVRC_CT_PASSIVE);
 
-
     if (AVRC_Open(&rc_handle, &ccb, bda) != AVRC_SUCCESS)
         return BTA_AV_RC_HANDLE_NONE;
 
@@ -522,7 +521,6 @@
         return;
     }
 
-
     if (p_cb->rcb[i].lidx == (BTA_AV_NUM_LINKS + 1) && shdl != 0)
     {
         /* rc is opened on the RC only ACP channel, but is for a specific
@@ -581,7 +579,6 @@
 
 }
 
-
 /*******************************************************************************
 **
 ** Function         bta_av_rc_remote_cmd
@@ -718,8 +715,6 @@
     UNUSED(p_data);
 }
 
-
-
 /*******************************************************************************
 **
 ** Function         bta_av_chk_notif_evt_id
@@ -839,7 +834,6 @@
             }
             break;
 
-
         case AVRC_PDU_REGISTER_NOTIFICATION:
             /* make sure the event_id is implemented */
             p_rc_rsp->rsp.status = bta_av_chk_notif_evt_id (p_vendor);
@@ -859,7 +853,6 @@
     return evt;
 }
 
-
 /*******************************************************************************
 **
 ** Function         bta_av_rc_msg
@@ -1155,7 +1148,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         bta_av_conn_chg
@@ -1226,7 +1218,6 @@
                 bta_av_cb.audio_open_cnt++;
             }
 
-
             APPL_TRACE_DEBUG("rc_acp_handle:%d rc_acp_idx:%d", p_cb->rc_acp_handle, p_cb->rc_acp_idx);
             /* check if the AVRCP ACP channel is already connected */
             if(p_lcb && p_cb->rc_acp_handle != BTA_AV_RC_HANDLE_NONE && p_cb->rc_acp_idx)
@@ -1471,7 +1462,6 @@
                         /* Possible collision : need to avoid outgoing processing while the timer is running */
                         p_cb->p_scb[xx]->coll_mask = BTA_AV_COLL_INC_TMR;
 
-
                         // TODO(armansito): Why is this variable called "xx" and
                         // why is it a signed integer? The callback reinterprets
                         // it as a UINT8 and then reassigns it as param that
diff --git a/bta/av/bta_av_main.c b/bta/av/bta_av_main.c
index ad371a8..d3aa79f 100644
--- a/bta/av/bta_av_main.c
+++ b/bta/av/bta_av_main.c
@@ -22,7 +22,7 @@
  *
  ******************************************************************************/
 
-#define LOG_TAG "bta_av"
+#define LOG_TAG "bt_bta_av"
 
 #include <assert.h>
 #include <string.h>
@@ -48,7 +48,6 @@
 /* AVDTP protocol timeout values */
 #define BTIF_AVK_SERVICE_NAME "Advanced Audio Sink"
 
-
 #ifndef BTA_AV_RET_TOUT
 #define BTA_AV_RET_TOUT     4
 #endif
@@ -171,7 +170,6 @@
                                  app_id, BD_ADDR peer_addr);
 static void bta_av_sys_rs_cback (tBTA_SYS_CONN_STATUS status,UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
 
-
 /* action functions */
 const tBTA_AV_NSM_ACT bta_av_nsm_act[] =
 {
@@ -1266,7 +1264,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         bta_av_hdl_event
@@ -1317,7 +1314,6 @@
     return TRUE;
 }
 
-
 /*****************************************************************************
 **  Debug Functions
 *****************************************************************************/
diff --git a/bta/gatt/bta_gattc_act.c b/bta/gatt/bta_gattc_act.c
old mode 100755
new mode 100644
index f647cc6..1ab084a
--- a/bta/gatt/bta_gattc_act.c
+++ b/bta/gatt/bta_gattc_act.c
@@ -28,7 +28,6 @@
 #include <string.h>
 
 #include "bt_target.h"
-
 #include "bta_gattc_int.h"
 #include "bta_sys.h"
 #include "btif/include/btif_debug_conn.h"
@@ -120,7 +119,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         bta_gattc_disable
@@ -185,7 +183,6 @@
     tBTA_GATTC_INT_START_IF  *p_buf;
     tBTA_GATT_STATUS         status = BTA_GATT_NO_RESOURCES;
 
-
     APPL_TRACE_DEBUG("bta_gattc_register state %d",p_cb->state);
     memset(&cb_data, 0, sizeof(cb_data));
     cb_data.reg_oper.status = BTA_GATT_NO_RESOURCES;
@@ -772,7 +769,6 @@
         cb_data.close.status    = BTA_GATT_ERROR;
         cb_data.close.reason    = BTA_GATT_CONN_NONE;
 
-
         (*p_clcb->p_rcb->p_cback)(BTA_GATTC_CLOSE_EVT, &cb_data);
     }
 }
@@ -1451,7 +1447,6 @@
 
     utl_freebuf((void **)&p_clcb->p_q_cmd);
 
-
     if (p_data->p_cmpl  &&  p_data->status == BTA_GATT_OK)
         p_clcb->p_srcb->mtu  = p_data->p_cmpl->mtu;
 
diff --git a/bta/gatt/bta_gattc_utils.c b/bta/gatt/bta_gattc_utils.c
index d38aa09..1000b46 100644
--- a/bta/gatt/bta_gattc_utils.c
+++ b/bta/gatt/bta_gattc_utils.c
@@ -29,16 +29,17 @@
 #if defined(BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE)
 
 #include <string.h>
-#include "utl.h"
-#include "gki.h"
-#include "bta_sys.h"
+
 #include "bta_gattc_int.h"
+#include "bta_sys.h"
+#include "gki.h"
 #include "l2c_api.h"
+#include "utl.h"
+
 /*****************************************************************************
 **  Constants
 *****************************************************************************/
 
-
 static const UINT8  base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
     0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
 
@@ -856,7 +857,6 @@
     return NULL;
 }
 
-
 /*******************************************************************************
 **
 ** Function         bta_gattc_conn_find_alloc
diff --git a/bta/hh/bta_hh_api.c b/bta/hh/bta_hh_api.c
index 0df20f3..a6a8ecf 100644
--- a/bta/hh/bta_hh_api.c
+++ b/bta/hh/bta_hh_api.c
@@ -22,6 +22,10 @@
  *
  ******************************************************************************/
 
+#define LOG_TAG "bt_bta_hh"
+
+#include "bta_hh_api.h"
+
 #include "bt_target.h"
 
 #if defined(BTA_HH_INCLUDED) && (BTA_HH_INCLUDED == TRUE)
@@ -30,13 +34,10 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "bta_hh_api.h"
 #include "bta_hh_int.h"
 #include "l2c_api.h"
-#include "utl.h"
-
-#define LOG_TAG "bt_bta_hh"
 #include "osi/include/log.h"
+#include "utl.h"
 
 /*****************************************************************************
 **  Constants
diff --git a/btif/include/btif_gatt_util.h b/btif/include/btif_gatt_util.h
index b0292b8..2b77a1f 100644
--- a/btif/include/btif_gatt_util.h
+++ b/btif/include/btif_gatt_util.h
@@ -16,11 +16,13 @@
  *
  ******************************************************************************/
 
-
 #ifndef BTIF_GATT_UTIL_H
 #define BTIF_GATT_UTIL_H
 
-#include "bta_api.h"
+#include <hardware/bluetooth.h>
+#include <hardware/bt_gatt.h>
+
+#include "bta/include/bta_gatt_api.h"
 
 void btif_to_bta_uuid(tBT_UUID *p_dest, bt_uuid_t *p_src);
 void btif_to_bta_gatt_id(tBTA_GATT_ID *p_dest, btgatt_gatt_id_t *p_src);
diff --git a/btif/include/btif_hl.h b/btif/include/btif_hl.h
index c4d8e81..05f01ab 100644
--- a/btif/include/btif_hl.h
+++ b/btif/include/btif_hl.h
@@ -19,6 +19,9 @@
 #ifndef BTIF_HL_H
 #define BTIF_HL_H
 
+#include "bt_types.h"
+#include "bta_hl_api.h"
+
 /*******************************************************************************
 **  Constants & Macros
 ********************************************************************************/
@@ -39,8 +42,6 @@
 #define BTIF_HL_CCH_NUM_FILTER_ELEMS            3
 #define BTIF_HL_APPLICATION_NAME_LEN          512
 
-
-
 /*******************************************************************************
 **  Type definitions and return values
 ********************************************************************************/
@@ -277,7 +278,6 @@
     int                     fd;
 } btif_hl_send_chan_state_cb_t;
 
-
 typedef struct
 {
     UINT8 app_idx;
@@ -294,7 +294,6 @@
     btif_hl_update_mdl_t    update_mdl;
 } btif_hl_evt_cb_t;
 
-
 /*******************************************************************************
 **  Functions
 ********************************************************************************/
diff --git a/btif/include/btif_profile_queue.h b/btif/include/btif_profile_queue.h
index f28daac..5cc3d0a 100644
--- a/btif/include/btif_profile_queue.h
+++ b/btif/include/btif_profile_queue.h
@@ -27,6 +27,8 @@
 #ifndef BTIF_PROFILE_QUEUE_H
 #define BTIF_PROFILE_QUEUE_H
 
+#include <hardware/bluetooth.h>
+
 typedef bt_status_t (*btif_connect_cb_t) (bt_bdaddr_t *bda, uint16_t uuid);
 
 bt_status_t btif_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda, btif_connect_cb_t connect_cb);
diff --git a/btif/include/btif_sm.h b/btif/include/btif_sm.h
index baad0d9..b4caf9e 100644
--- a/btif/include/btif_sm.h
+++ b/btif/include/btif_sm.h
@@ -27,6 +27,10 @@
 #ifndef BTIF_SM_H
 #define BTIF_SM_H
 
+#include <hardware/bluetooth.h>
+
+#include "stack/include/bt_types.h"
+
 /*****************************************************************************
 **  Constants & Macros
 ******************************************************************************/
@@ -35,7 +39,6 @@
 #define BTIF_SM_ENTER_EVT 0xFFFF
 #define BTIF_SM_EXIT_EVT  0xFFFE
 
-
 /*****************************************************************************
 **  Type definitions and return values
 ******************************************************************************/
@@ -44,7 +47,6 @@
 typedef void* btif_sm_handle_t;
 typedef BOOLEAN(*btif_sm_handler_t)(btif_sm_event_t event, void *data);
 
-
 /*****************************************************************************
 **  Functions
 **
diff --git a/btif/include/btif_sock_l2cap.h b/btif/include/btif_sock_l2cap.h
index 9425dc9..065aa48 100644
--- a/btif/include/btif_sock_l2cap.h
+++ b/btif/include/btif_sock_l2cap.h
@@ -5,11 +5,10 @@
 #ifndef BTIF_SOCK_L2CAP_H
 #define BTIF_SOCK_L2CAP_H
 
-
+#include <hardware/bluetooth.h>
 
 #define L2CAP_MASK_FIXED_CHANNEL    0x10000
 
-
 bt_status_t btsock_l2cap_init(int handle);
 bt_status_t btsock_l2cap_cleanup();
 bt_status_t btsock_l2cap_listen(const char* name, int channel,
diff --git a/btif/include/btif_sock_sdp.h b/btif/include/btif_sock_sdp.h
index 9c09b0f..7353cc9 100644
--- a/btif/include/btif_sock_sdp.h
+++ b/btif/include/btif_sock_sdp.h
@@ -20,6 +20,8 @@
 #define BTIF_SOCK_SDP_H
 
 #include <string.h>
+#include <stdint.h>
+#include <stdbool.h>
 
 static const uint8_t  UUID_OBEX_OBJECT_PUSH[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
                                                  0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
diff --git a/btif/include/btif_sock_thread.h b/btif/include/btif_sock_thread.h
index 1b5e241..b81c494 100644
--- a/btif/include/btif_sock_thread.h
+++ b/btif/include/btif_sock_thread.h
@@ -20,6 +20,8 @@
 #define BTIF_SOCK_THREAD_H
 
 #include <stdbool.h>
+
+#include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 
 /*******************************************************************************
diff --git a/btif/include/btif_storage.h b/btif/include/btif_storage.h
index 54dc5d6..758436f 100644
--- a/btif/include/btif_storage.h
+++ b/btif/include/btif_storage.h
@@ -19,6 +19,9 @@
 #ifndef BTIF_STORAGE_H
 #define BTIF_STORAGE_H
 
+#include <hardware/bluetooth.h>
+
+#include "bt_target.h"
 #include "bt_types.h"
 
 /*******************************************************************************
diff --git a/btif/include/stack_manager.h b/btif/include/stack_manager.h
index 1cb87fe..08f7f00 100644
--- a/btif/include/stack_manager.h
+++ b/btif/include/stack_manager.h
@@ -19,6 +19,7 @@
 #pragma once
 
 #include "future.h"
+#include <stdbool.h>
 
 typedef struct {
   void (*init_stack)(void);
diff --git a/btif/src/bluetooth.c b/btif/src/bluetooth.c
index 6312ace..22ba41c 100644
--- a/btif/src/bluetooth.c
+++ b/btif/src/bluetooth.c
@@ -24,35 +24,35 @@
  *
  ***********************************************************************************/
 
+#define LOG_NDDEBUG 0
+#define LOG_TAG "bt_bluedroid"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
 #include <hardware/bluetooth.h>
+#include <hardware/bt_av.h>
+#include <hardware/bt_gatt.h>
 #include <hardware/bt_hf.h>
 #include <hardware/bt_hf_client.h>
-#include <hardware/bt_av.h>
-#include <hardware/bt_sock.h>
 #include <hardware/bt_hh.h>
 #include <hardware/bt_hl.h>
-#include <hardware/bt_pan.h>
 #include <hardware/bt_mce.h>
-#include <hardware/bt_gatt.h>
+#include <hardware/bt_pan.h>
 #include <hardware/bt_rc.h>
 #include <hardware/bt_sdp.h>
+#include <hardware/bt_sock.h>
 
-#define LOG_NDDEBUG 0
-#define LOG_TAG "bt_bluedroid"
-
+#include "bt_utils.h"
 #include "btif_api.h"
 #include "btif_debug.h"
 #include "btsnoop.h"
 #include "btsnoop_mem.h"
-#include "bt_utils.h"
-#include "osi/include/osi.h"
 #include "osi/include/allocation_tracker.h"
 #include "osi/include/log.h"
+#include "osi/include/osi.h"
 #include "stack_manager.h"
 
 /************************************************************************************
@@ -489,7 +489,6 @@
   return 0;
 }
 
-
 static struct hw_module_methods_t bt_stack_module_methods = {
     .open = open_bluetooth_stack,
 };
diff --git a/btif/src/btif_av.c b/btif/src/btif_av.c
index acb7716..acd03c4 100644
--- a/btif/src/btif_av.c
+++ b/btif/src/btif_av.c
@@ -16,7 +16,6 @@
  *
  ******************************************************************************/
 
-
 /*****************************************************************************
  *
  *  Filename:      btif_av.c
@@ -25,22 +24,23 @@
  *
  *****************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <system/audio.h>
-#include <string.h>
-#include "hardware/bt_av.h"
-
 #define LOG_TAG "bt_btif_av"
 
 #include "btif_av.h"
-#include "btif_util.h"
-#include "btif_profile_queue.h"
+
+#include <system/audio.h>
+#include <string.h>
+
+#include <hardware/bluetooth.h>
+#include <hardware/bt_av.h>
+
+#include "bt_utils.h"
 #include "bta_api.h"
 #include "btif_media.h"
-#include "bta_av_api.h"
-#include "gki.h"
+#include "btif_profile_queue.h"
+#include "btif_util.h"
 #include "btu.h"
-#include "bt_utils.h"
+#include "gki.h"
 
 /*****************************************************************************
 **  Constants & Macros
@@ -456,7 +456,6 @@
    return TRUE;
 }
 
-
 /*****************************************************************************
 **
 ** Function        btif_av_state_closing_handler
@@ -527,7 +526,6 @@
    return TRUE;
 }
 
-
 /*****************************************************************************
 **
 ** Function     btif_av_state_opened_handler
diff --git a/btif/src/btif_config.c b/btif/src/btif_config.c
index 0dc95b8..9417140 100644
--- a/btif/src/btif_config.c
+++ b/btif/src/btif_config.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_btif_config"
 
+#include "btif_config.h"
+
 #include <assert.h>
 #include <ctype.h>
 #include <pthread.h>
@@ -28,7 +30,6 @@
 #include "bt_types.h"
 #include "btcore/include/bdaddr.h"
 #include "btcore/include/module.h"
-#include "btif_config.h"
 #include "btif_config_transcode.h"
 #include "btif_util.h"
 #include "osi/include/alarm.h"
diff --git a/btif/src/btif_dm.c b/btif/src/btif_dm.c
index c4df4a6..c918e5e 100644
--- a/btif/src/btif_dm.c
+++ b/btif/src/btif_dm.c
@@ -27,6 +27,8 @@
 
 #define LOG_TAG "bt_btif_dm"
 
+#include "btif_dm.h"
+
 #include <assert.h>
 #include <signal.h>
 #include <stdio.h>
@@ -47,11 +49,9 @@
 #endif  /* !defined(OS_GENERIC) */
 
 #include "bdaddr.h"
-#include "bta_api.h"
 #include "bta_gatt_api.h"
 #include "btif_api.h"
 #include "btif_config.h"
-#include "btif_dm.h"
 #include "btif_hh.h"
 #include "btif_sdp.h"
 #include "btif_storage.h"
@@ -104,7 +104,6 @@
 #define COD_AV_PORTABLE_AUDIO               0x041C
 #define COD_AV_HIFI_AUDIO                   0x0428
 
-
 #define BTIF_DM_DEFAULT_INQ_MAX_RESULTS     0
 #define BTIF_DM_DEFAULT_INQ_MAX_DURATION    10
 #define BTIF_DM_MAX_SDP_ATTEMPTS_AFTER_PAIRING 2
@@ -154,7 +153,6 @@
 #endif
 } btif_dm_pairing_cb_t;
 
-
 typedef struct
 {
     UINT8       ir[BT_OCTET16_LEN];
@@ -215,8 +213,6 @@
 /* This flag will be true if HCI_Inquiry is in progress */
 static BOOLEAN btif_dm_inquiry_in_progress = FALSE;
 
-
-
 /************************************************************************************
 **  Static variables
 ************************************************************************************/
@@ -258,7 +254,6 @@
 extern int btif_hh_connect(bt_bdaddr_t *bd_addr);
 extern void bta_gatt_convert_uuid16_to_uuid128(UINT8 uuid_128[LEN_UUID_128], UINT16 uuid_16);
 
-
 /******************************************************************************
 **  Functions
 ******************************************************************************/
@@ -487,7 +482,6 @@
     bt_property_t prop_name;
     bt_remote_version_t info;
 
-
     if (remote_bdaddr == NULL)
         return FALSE;
 
@@ -495,8 +489,6 @@
     BTM_ReadRemoteVersion(*(BD_ADDR*)remote_bdaddr, &lmp_ver,
                     &manufacturer, &lmp_subver);
 
-
-
  /* if not available yet, try fetching from config database */
     BTIF_STORAGE_FILL_PROPERTY(&prop_name, BT_PROPERTY_REMOTE_VERSION_INFO,
                             sizeof(bt_remote_version_t), &info);
@@ -517,7 +509,6 @@
     return FALSE;
 }
 
-
 static void bond_state_changed(bt_status_t status, bt_bdaddr_t *bd_addr, bt_bond_state_t state)
 {
     // Send bonding state only once - based on outgoing/incoming we may receive duplicates
@@ -584,7 +575,6 @@
     }
 }
 
-
 static void btif_update_remote_properties(BD_ADDR bd_addr, BD_NAME bd_name,
                                           DEV_CLASS dev_class, tBT_DEVICE_TYPE device_type)
 {
@@ -1338,7 +1328,6 @@
                 /* TODO:  Get the service list and check to see which uuids we got and send it back to the client. */
             }
 
-
             {
                 bt_property_t properties[5];
                 bt_device_type_t dev_type;
@@ -2665,7 +2654,6 @@
     UNUSED (p_io_cap);
     UNUSED (p_oob_data);
 
-
     BTIF_TRACE_DEBUG("+%s: p_auth_req=%d", __FUNCTION__, *p_auth_req);
     if(pairing_cb.is_local_initiated)
     {
@@ -2946,8 +2934,6 @@
     bond_state_changed(status, &bd_addr, state);
 }
 
-
-
 void    btif_dm_load_ble_local_keys(void)
 {
     memset(&ble_local_key_cb, 0, sizeof(btif_dm_local_key_cb_t));
@@ -3015,7 +3001,6 @@
                                          sizeof(tBTM_LE_PID_KEYS));
     }
 
-
     if (pairing_cb.ble.is_pcsrk_key_rcvd)
     {
         btif_storage_add_ble_bonding_key(&bd_addr,
@@ -3024,7 +3009,6 @@
                                          sizeof(tBTM_LE_PCSRK_KEYS));
     }
 
-
     if (pairing_cb.ble.is_lenc_key_rcvd)
     {
         btif_storage_add_ble_bonding_key(&bd_addr,
@@ -3051,7 +3035,6 @@
 
 }
 
-
 void btif_dm_remove_ble_bonding_keys(void)
 {
     bt_bdaddr_t bd_addr;
@@ -3062,7 +3045,6 @@
     btif_storage_remove_ble_bonding_keys(&bd_addr);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_dm_ble_sec_req_evt
@@ -3111,8 +3093,6 @@
               BT_SSP_VARIANT_CONSENT, 0);
 }
 
-
-
 /*******************************************************************************
 **
 ** Function         btif_dm_ble_passkey_req_evt
diff --git a/btif/src/btif_gatt.c b/btif/src/btif_gatt.c
index 50ebaee..ccb1704 100644
--- a/btif/src/btif_gatt.c
+++ b/btif/src/btif_gatt.c
@@ -16,7 +16,6 @@
  *
  ******************************************************************************/
 
-
 /*******************************************************************************
  *
  *  Filename:      btif_gatt.c
@@ -25,15 +24,15 @@
  *
  *******************************************************************************/
 
+#define LOG_TAG "bt_btif_gatt"
+
+#include <errno.h>
 #include <hardware/bluetooth.h>
 #include <hardware/bt_gatt.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <string.h>
 
-#define LOG_TAG "bt_btif_gatt"
-
 #include "btif_common.h"
 #include "btif_util.h"
 
@@ -41,10 +40,9 @@
 
 #include "bta_api.h"
 #include "bta_gatt_api.h"
-#include "btif_storage.h"
-
 #include "btif_gatt.h"
 #include "btif_gatt_util.h"
+#include "btif_storage.h"
 
 const btgatt_callbacks_t *bt_gatt_callbacks = NULL;
 
diff --git a/btif/src/btif_gatt_client.c b/btif/src/btif_gatt_client.c
index 8daf544..e560595 100644
--- a/btif/src/btif_gatt_client.c
+++ b/btif/src/btif_gatt_client.c
@@ -16,7 +16,6 @@
  *
  ******************************************************************************/
 
-
 /*******************************************************************************
  *
  *  Filename:      btif_gatt_client.c
@@ -27,10 +26,10 @@
 
 #define LOG_TAG "bt_btif_gattc"
 
+#include <errno.h>
 #include <hardware/bluetooth.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <string.h>
 
 #include "btcore/include/bdaddr.h"
@@ -150,7 +149,6 @@
     btgatt_batch_reports  read_reports;
 } btgatt_batch_track_cb_t;
 
-
 typedef tBTA_DM_BLE_PF_FILT_PARAMS btgatt_adv_filt_param_t;
 
 typedef struct
@@ -2351,7 +2349,6 @@
     return btif_gattc_test_command_impl(command, params);
 }
 
-
 const btgatt_client_interface_t btgattClientInterface = {
     btif_gattc_register_app,
     btif_gattc_unregister_app,
diff --git a/btif/src/btif_gatt_multi_adv_util.c b/btif/src/btif_gatt_multi_adv_util.c
index 692945d..7e050f2 100644
--- a/btif/src/btif_gatt_multi_adv_util.c
+++ b/btif/src/btif_gatt_multi_adv_util.c
@@ -16,7 +16,6 @@
  *
  ******************************************************************************/
 
-
 /*******************************************************************************
  *
  *  Filename:      btif_gatt_multi_adv_util.c
@@ -25,19 +24,23 @@
  *
  *******************************************************************************/
 
+#define LOG_TAG "bt_btif_gatt"
+
+#include "btif_gatt_multi_adv_util.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+
 #include "btu.h"
 #include "bt_target.h"
 
-#define LOG_TAG "bt_btif_gatt"
 #if (BLE_INCLUDED == TRUE)
 
-#include "btif_gatt_multi_adv_util.h"
-#include "btif_common.h"
 #include <hardware/bt_gatt.h>
+
 #include "bta_gatt_api.h"
+#include "btif_common.h"
 #include "btif_gatt_util.h"
 
 /*******************************************************************************
@@ -213,7 +216,6 @@
     return INVALID_ADV_INST;
 }
 
-
 void btif_gattc_adv_data_packager(int client_if, bool set_scan_rsp,
                 bool include_name, bool include_txpower, int min_interval, int max_interval,
                 int appearance, int manufacturer_len, char* manufacturer_data,
@@ -264,7 +266,6 @@
         GKI_freebuf(adv->p_manufacturer_data);
 }
 
-
 BOOLEAN btif_gattc_copy_datacb(int cbindex, const btif_adv_data_t *p_adv_data,
                                BOOLEAN bInstData) {
     btgatt_multi_adv_common_data *p_multi_adv_data_cb = btif_obtain_multi_adv_data_cb();
diff --git a/btif/src/btif_gatt_server.c b/btif/src/btif_gatt_server.c
index 1f9e7ae..cc5576f 100644
--- a/btif/src/btif_gatt_server.c
+++ b/btif/src/btif_gatt_server.c
@@ -16,7 +16,6 @@
  *
  ******************************************************************************/
 
-
 /************************************************************************************
  *
  *  Filename:      btif_gatt_server.c
@@ -25,9 +24,11 @@
  *
  ***********************************************************************************/
 
+#define LOG_TAG "bt_btif_gatt"
+
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <string.h>
 
 #include <hardware/bluetooth.h>
@@ -38,8 +39,6 @@
 
 #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
 
-#define LOG_TAG "bt_btif_gatt"
-
 #include "bta_api.h"
 #include "bta_gatt_api.h"
 #include "btif_config.h"
@@ -62,7 +61,6 @@
         LOG_VERBOSE(LOG_TAG, "%s", __FUNCTION__);\
     }
 
-
 typedef enum {
     BTIF_GATTS_REGISTER_APP = 2000,
     BTIF_GATTS_UNREGISTER_APP,
@@ -107,14 +105,12 @@
 
 } __attribute__((packed)) btif_gatts_cb_t;
 
-
 /************************************************************************************
 **  Static variables
 ************************************************************************************/
 
 extern const btgatt_callbacks_t *bt_gatt_callbacks;
 
-
 /************************************************************************************
 **  Static functions
 ************************************************************************************/
diff --git a/btif/src/btif_gatt_test.c b/btif/src/btif_gatt_test.c
index 447819f..349674e 100644
--- a/btif/src/btif_gatt_test.c
+++ b/btif/src/btif_gatt_test.c
@@ -16,10 +16,11 @@
  *
  ******************************************************************************/
 
+#define LOG_TAG "bt_btif_gatt"
 
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <string.h>
 
 #include <hardware/bluetooth.h>
@@ -30,9 +31,6 @@
 
 #if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
 
-#define LOG_TAG "bt_btif_gatt"
-
-#include "bta_api.h"
 #include "bta_gatt_api.h"
 #include "bte_appl.h"
 #include "btif_dm.h"
@@ -136,7 +134,6 @@
     }
 }
 
-
 static void btif_test_discovery_result_cback(UINT16 conn_id, tGATT_DISC_TYPE disc_type,
                                            tGATT_DISC_RES *p_data)
 {
diff --git a/btif/src/btif_gatt_util.c b/btif/src/btif_gatt_util.c
index 246d9fd..c155478 100644
--- a/btif/src/btif_gatt_util.c
+++ b/btif/src/btif_gatt_util.c
@@ -18,9 +18,11 @@
 
 #define LOG_TAG "bt_btif_gatt"
 
+#include "btif_gatt_util.h"
+
+#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <string.h>
 
 #include <hardware/bluetooth.h>
@@ -34,7 +36,6 @@
 #include "btif_config.h"
 #include "btif_dm.h"
 #include "btif_gatt.h"
-#include "btif_gatt_util.h"
 #include "btif_storage.h"
 #include "btif_util.h"
 #include "gki.h"
@@ -198,7 +199,6 @@
     }
 }
 
-
 void bta_to_btif_gatt_id(btgatt_gatt_id_t *p_dest, tBTA_GATT_ID *p_src)
 {
     p_dest->inst_id = p_src->inst_id;
@@ -212,7 +212,6 @@
     p_dest->is_primary = p_src->is_primary;
 }
 
-
 /*******************************************************************************
  * Utility functions
  *******************************************************************************/
diff --git a/btif/src/btif_hf.c b/btif/src/btif_hf.c
index 69b76a5..144068c 100644
--- a/btif/src/btif_hf.c
+++ b/btif/src/btif_hf.c
@@ -25,19 +25,20 @@
  *
  ***********************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_hf.h>
+#define LOG_TAG "bt_btif_hf"
+
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
 
-#define LOG_TAG "bt_btif_hf"
-#include "btif_common.h"
-#include "btif_util.h"
-#include "btif_profile_queue.h"
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hf.h>
 
-#include "btcore/include/bdaddr.h"
 #include "bta_ag_api.h"
+#include "btcore/include/bdaddr.h"
+#include "btif_common.h"
+#include "btif_profile_queue.h"
+#include "btif_util.h"
 
 /************************************************************************************
 **  Constants & Macros
@@ -164,7 +165,6 @@
 
 static btif_hf_cb_t btif_hf_cb[BTIF_HF_NUM_CB];
 
-
 /************************************************************************************
 **  Static functions
 ************************************************************************************/
@@ -376,7 +376,6 @@
 **
 *****************************************************************************/
 
-
 /*******************************************************************************
 **
 ** Function         btif_hf_upstreams_evt
@@ -662,7 +661,6 @@
     ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed", status);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_in_hf_generic_evt
@@ -699,7 +697,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hf_init
@@ -1175,7 +1172,6 @@
         return BT_STATUS_SUCCESS;
     }
 
-
     return BT_STATUS_FAIL;
 }
 
@@ -1466,7 +1462,6 @@
     return status;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hf_call_terminated_recently
diff --git a/btif/src/btif_hf_client.c b/btif/src/btif_hf_client.c
index 0fe3699..0419013 100644
--- a/btif/src/btif_hf_client.c
+++ b/btif/src/btif_hf_client.c
@@ -26,11 +26,14 @@
  *
  ***********************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_hf_client.h>
+#define LOG_TAG "bt_btif_hfc"
+
 #include <stdlib.h>
 #include <string.h>
 
+#include <hardware/bluetooth.h>
+#include <hardware/bt_hf_client.h>
+
 /**
  * TODO(armansito): On OSs other than Android, the sys/properties.h system
  * does not exist. Remove this conditional include once we have a generic way
@@ -40,13 +43,12 @@
 #include <cutils/properties.h>
 #endif  /* !defined(OS_GENERIC) */
 
-#define LOG_TAG "bt_btif_hfc"
-#include "btif_common.h"
-#include "btif_util.h"
-#include "btif_profile_queue.h"
 #include "bt_utils.h"
-#include "btcore/include/bdaddr.h"
 #include "bta_hf_client_api.h"
+#include "btcore/include/bdaddr.h"
+#include "btif_common.h"
+#include "btif_profile_queue.h"
+#include "btif_util.h"
 
 /************************************************************************************
 **  Constants & Macros
@@ -133,7 +135,6 @@
 
 static btif_hf_client_cb_t btif_hf_client_cb;
 
-
 /************************************************************************************
 **  Static functions
 ************************************************************************************/
diff --git a/btif/src/btif_hh.c b/btif/src/btif_hh.c
index 3817358..b92a3f8 100644
--- a/btif/src/btif_hh.c
+++ b/btif/src/btif_hh.c
@@ -27,19 +27,16 @@
 
 #define LOG_TAG "bt_btif_hh"
 
+#include "btif_hh.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <errno.h>
 #include <string.h>
 #include <unistd.h>
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_hh.h>
-
 #include "bta_api.h"
-#include "bta_hh_api.h"
 #include "btif_common.h"
-#include "btif_hh.h"
 #include "btif_storage.h"
 #include "btif_util.h"
 #include "gki.h"
@@ -76,7 +73,6 @@
 
 #define BTIF_TIMEOUT_VUP_SECS   3
 
-
 #ifndef BTUI_HH_SECURITY
 #define BTUI_HH_SECURITY (BTA_SEC_AUTHENTICATE | BTA_SEC_ENCRYPT)
 #endif
@@ -93,14 +89,11 @@
     BTIF_HH_VUP_REQ_EVT
 } btif_hh_req_evt_t;
 
-
 /************************************************************************************
 **  Constants & Macros
 ************************************************************************************/
 #define BTIF_HH_SERVICES    (BTA_HID_SERVICE_MASK)
 
-
-
 /************************************************************************************
 **  Local type definitions
 ************************************************************************************/
@@ -129,7 +122,6 @@
     "Logitech MX5500 Keyboard"}
 };
 
-
 #define CHECK_BTHH_INIT() if (bt_hh_callbacks == NULL)\
     {\
         BTIF_TRACE_WARNING("BTHH: %s: BTHH not initialized", __FUNCTION__);\
@@ -140,8 +132,6 @@
         BTIF_TRACE_EVENT("BTHH: %s", __FUNCTION__);\
     }
 
-
-
 /************************************************************************************
 **  Static functions
 ************************************************************************************/
@@ -170,7 +160,6 @@
 //static void hh_update_keyboard_lockstates(btif_hh_device_t *p_dev);
 void btif_hh_tmr_hdlr(TIMER_LIST_ENT *tle);
 
-
 /************************************************************************************
 **  Functions
 ************************************************************************************/
@@ -545,7 +534,6 @@
     }
 }
 
-
 BOOLEAN btif_hh_copy_hid_info(tBTA_HH_DEV_DSCP_INFO* dest , tBTA_HH_DEV_DSCP_INFO* src)
 {
     dest->descriptor.dl_len = 0;
@@ -569,7 +557,6 @@
     return TRUE;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hh_virtual_unplug
@@ -727,7 +714,6 @@
 **
 *****************************************************************************/
 
-
 /*******************************************************************************
 **
 ** Function         btif_hh_upstreams_evt
@@ -1043,7 +1029,6 @@
                      p_data->dev_info.bda[3], p_data->dev_info.bda[4], p_data->dev_info.bda[5]);
                 break;
 
-
         case BTA_HH_VC_UNPLUG_EVT:
                 BTIF_TRACE_DEBUG("BTA_HH_VC_UNPLUG_EVT: status = %d, handle = %d",
                      p_data->dev_status.status, p_data->dev_status.handle);
@@ -1081,8 +1066,6 @@
                 LOG_INFO(LOG_TAG, "BTA_HH API_ERR");
                 break;
 
-
-
             default:
                 BTIF_TRACE_WARNING("%s: Unhandled event: %d", __FUNCTION__, event);
                 break;
@@ -1332,7 +1315,6 @@
     return BT_STATUS_SUCCESS;
 }
 
-
 /*******************************************************************************
 **
 ** Function         set_info
@@ -1462,7 +1444,6 @@
         BTA_HhSetProtoMode(p_dev->dev_handle, protocolMode);
     }
 
-
     return BT_STATUS_SUCCESS;
 }
 
@@ -1492,7 +1473,6 @@
         return BT_STATUS_FAIL;
     }
 
-
     p_dev = btif_hh_find_connected_dev_by_bda(bd_addr);
     if (p_dev == NULL) {
         BTIF_TRACE_ERROR("%s: Error, device %02X:%02X:%02X:%02X:%02X:%02X not opened.",
@@ -1532,7 +1512,6 @@
     BTIF_TRACE_DEBUG("addr = %02X:%02X:%02X:%02X:%02X:%02X",
          (*bda)[0], (*bda)[1], (*bda)[2], (*bda)[3], (*bda)[4], (*bda)[5]);
 
-
     if (btif_hh_cb.status == BTIF_HH_DISABLED) {
         BTIF_TRACE_ERROR("%s: Error, HH status = %d", __FUNCTION__, btif_hh_cb.status);
         return BT_STATUS_FAIL;
@@ -1650,7 +1629,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         cleanup
diff --git a/btif/src/btif_hl.c b/btif/src/btif_hl.c
index 2d24aae..d92ea9e 100644
--- a/btif/src/btif_hl.c
+++ b/btif/src/btif_hl.c
@@ -26,6 +26,8 @@
  ***********************************************************************************/
 #define LOG_TAG "bt_btif_hl"
 
+#include "btif_hl.h"
+
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
@@ -50,7 +52,6 @@
 #include "bta_api.h"
 #include "bta_hl_api.h"
 #include "btif_common.h"
-#include "btif_hl.h"
 #include "btif_storage.h"
 #include "btif_util.h"
 #include "btu.h"
@@ -115,7 +116,6 @@
         ASSERTC(0, "Callback is NULL", 0);  \
     }
 
-
 #define BTIF_HL_CALL_CBACK(P_CB, P_CBACK, ...)\
      if((p_btif_hl_cb->state != BTIF_HL_STATE_DISABLING) &&\
          (p_btif_hl_cb->state != BTIF_HL_STATE_DISABLED))  \
@@ -128,7 +128,6 @@
         }                                                  \
     }
 
-
 #define CHECK_BTHL_INIT() if (bt_hl_callbacks == NULL)\
     {\
         BTIF_TRACE_WARNING("BTHL: %s: BTHL not initialized", __FUNCTION__);\
@@ -139,7 +138,6 @@
         BTIF_TRACE_EVENT("BTHL: %s", __FUNCTION__);\
     }
 
-
 static const btif_hl_data_type_cfg_t data_type_table[] = {
     /* Data Specilization                   Ntx     Nrx (from Bluetooth SIG's HDP whitepaper)*/
     {BTIF_HL_DATA_TYPE_PULSE_OXIMETER,      9216,   256},
@@ -499,7 +497,6 @@
     memset(p_pcb, 0 , sizeof(btif_hl_pending_chan_cb_t));
 }
 
-
 /*******************************************************************************
 **
 ** Function      btif_hl_clean_mdl_cb
@@ -517,7 +514,6 @@
     memset(p_dcb, 0 , sizeof(btif_hl_mdl_cb_t));
 }
 
-
 /*******************************************************************************
 **
 ** Function      btif_hl_reset_mcb
@@ -535,7 +531,6 @@
     memset(p_mcb, 0, sizeof(btif_hl_mcl_cb_t));
 }
 
-
 /*******************************************************************************
 **
 ** Function      btif_hl_find_sdp_idx_using_mdep_filter
@@ -656,7 +651,6 @@
     tBTA_HL_MDEP_ID      peer_mdep_id = p_dch_open_api->peer_mdep_id;
     UINT8                mdl_idx;
 
-
     BTIF_TRACE_DEBUG("%s app_idx=%d mcl_idx=%d mdep_cfg_idx=%d",
                       __FUNCTION__, app_idx, mcl_idx, mdep_cfg_idx  );
     switch (local_cfg)
@@ -985,7 +979,6 @@
     return status;
 }
 
-
 /*******************************************************************************
 **
 ** Function      btif_hl_find_mdl_idx_using_handle
@@ -1110,7 +1103,6 @@
     return found;
 }
 
-
 /*******************************************************************************
 **
 ** Function      btif_hl_find_mdl_idx_using_handle
@@ -1156,7 +1148,6 @@
         }
     }
 
-
     BTIF_TRACE_EVENT("%s found=%d app_idx=%d mcl_idx=%d mdl_idx=%d  ",
                       __FUNCTION__,found,i,j,k );
     return found;
@@ -1181,7 +1172,6 @@
     BOOLEAN             found = FALSE;
     tBTA_HL_MDEP_ROLE   peer_mdep_role;
 
-
     BTIF_TRACE_DEBUG("%s app_id=%d local_mdep_role=%d, data_type=%d",
                       __FUNCTION__, app_id, local_mdep_role, data_type);
 
@@ -1190,7 +1180,6 @@
                       bd_addr[2],  bd_addr[3],
                       bd_addr[4],  bd_addr[5]);
 
-
     BTIF_TRACE_DEBUG("local_mdep_role=%d", local_mdep_role);
     BTIF_TRACE_DEBUG("data_type=%d", data_type);
 
@@ -1267,8 +1256,6 @@
     return found;
 }
 
-
-
 /*******************************************************************************
 **
 ** Function      btif_hl_find_mcl_idx
@@ -1296,7 +1283,6 @@
         }
     }
 
-
     BTIF_TRACE_DEBUG("%s found=%d idx=%d",__FUNCTION__, found, i);
     return found;
 }
@@ -1470,7 +1456,6 @@
             max_tx_apdu_size = BTIF_HL_DEFAULT_SRC_RX_APDU_SIZE;
         }
 
-
     }
 
     BTIF_TRACE_DEBUG("%s mdep_role=%d data_type=0x%4x size=%d",
@@ -1478,7 +1463,6 @@
     return max_tx_apdu_size;
 }
 
-
 /*******************************************************************************
 **
 ** Function      btif_hl_get_max_rx_apdu_size
@@ -1517,7 +1501,6 @@
         }
     }
 
-
     BTIF_TRACE_DEBUG("%s mdep_role=%d data_type=0x%4x size=%d",
                       __FUNCTION__, mdep_role, data_type, max_rx_apdu_size);
 
@@ -1659,7 +1642,6 @@
     btif_hl_cb.next_channel_id = 1;
 }
 
-
 /*******************************************************************************
 **
 ** Function      btif_hl_find_app_idx_using_handle
@@ -2088,7 +2070,6 @@
     return found;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hl_proc_dereg_cfm
@@ -2185,7 +2166,6 @@
         BTIF_TRACE_DEBUG("%s state %d--->%d",__FUNCTION__, cur_state, state);
     }
 
-
 }
 /*******************************************************************************
 **
@@ -2433,7 +2413,6 @@
     return status;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hl_proc_cch_open_ind
@@ -2641,7 +2620,6 @@
     btif_hl_clean_mcb_using_handle(p_data->cch_close_ind.mcl_handle);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hl_proc_cch_close_cfm
@@ -3095,7 +3073,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hl_proc_abort_ind
@@ -3205,7 +3182,6 @@
 
     BTIF_TRACE_DEBUG("btif_hl_proc_dch_cong_ind");
 
-
     if (btif_hl_find_mdl_idx_using_handle(p_data->dch_cong_ind.mdl_handle, &app_idx, &mcl_idx, &mdl_idx))
     {
         p_dcb =BTIF_HL_GET_MDL_CB_PTR(app_idx, mcl_idx, mdl_idx);
@@ -3238,7 +3214,6 @@
         BTA_HlRegister(app_id, p_reg_param, btif_hl_cback);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_hl_proc_cb_evt
@@ -3426,7 +3401,6 @@
 
             break;
 
-
         case BTA_HL_CCH_OPEN_CFM_EVT:
             BTIF_TRACE_DEBUG("Rcv BTA_HL_CCH_OPEN_CFM_EVT");
             BTIF_TRACE_DEBUG("app_id=%d,app_handle=%d mcl_handle=%d status =%d",
@@ -3515,7 +3489,6 @@
             }
             break;
 
-
         case BTA_HL_CCH_OPEN_IND_EVT:
             BTIF_TRACE_DEBUG("Rcv BTA_HL_CCH_OPEN_IND_EVT");
             BTIF_TRACE_DEBUG("app_handle=%d mcl_handle=%d",
@@ -3590,7 +3563,6 @@
                               p_data->dch_reconnect_cfm.mdl_id,
                               p_data->dch_reconnect_cfm.mtu);
 
-
             if (p_data->dch_reconnect_cfm.status == BTA_HL_STATUS_OK)
             {
                 status = btif_hl_proc_dch_reconnect_cfm(p_data);
@@ -3670,7 +3642,6 @@
             /* not supported */
             break;
 
-
         case BTA_HL_DCH_RECONNECT_IND_EVT:
             BTIF_TRACE_DEBUG("Rcv BTA_HL_DCH_RECONNECT_IND_EVT");
 
@@ -3856,7 +3827,6 @@
             {
                 btif_hl_set_state(BTIF_HL_STATE_ENABLED);
 
-
                 for (i=0; i < BTA_HL_NUM_APPS ; i ++)
                 {
                     p_acb = BTIF_HL_GET_APP_CB_PTR(i);
@@ -3945,7 +3915,6 @@
     BTIF_TRACE_EVENT("%s", __FUNCTION__);
     btif_hl_display_calling_process_name();
 
-
     for (i=0; i<6; i++)
     {
         bda[i] = (UINT8) bd_addr->address[i];
@@ -4044,7 +4013,6 @@
     BTIF_TRACE_EVENT("%s channel_id=0x%08x", __FUNCTION__, channel_id);
     btif_hl_display_calling_process_name();
 
-
     if (btif_hl_if_channel_setup_pending(channel_id, &app_idx, &mcl_idx))
     {
         btif_hl_dch_abort(app_idx, mcl_idx);
@@ -4190,7 +4158,6 @@
     p_acb = BTIF_HL_GET_APP_CB_PTR(app_idx);
     p_acb->in_use = TRUE;
 
-
     p_acb->app_id = btif_hl_get_next_app_id();
 
     if (p_reg_param->application_name != NULL )
@@ -4438,7 +4405,6 @@
     cleanup,
 };
 
-
 /*******************************************************************************
 **
 ** Function         btif_hl_get_interface
diff --git a/btif/src/btif_mce.c b/btif/src/btif_mce.c
index c50ef8b..fd73b0a 100644
--- a/btif/src/btif_mce.c
+++ b/btif/src/btif_mce.c
@@ -26,20 +26,21 @@
  *
  ***********************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_mce.h>
+#define LOG_TAG "bt_btif_mce"
+
 #include <stdlib.h>
 #include <string.h>
 
-#define LOG_TAG "bt_btif_mce"
-#include "btif_common.h"
-#include "btif_util.h"
-#include "btif_profile_queue.h"
-#include "bta_api.h"
-#include "bta_mce_api.h"
+#include <hardware/bluetooth.h>
+#include <hardware/bt_mce.h>
 
 #include "bt_types.h"
+#include "bta_api.h"
+#include "bta_mce_api.h"
 #include "btcore/include/bdaddr.h"
+#include "btif_common.h"
+#include "btif_profile_queue.h"
+#include "btif_util.h"
 
 /*****************************************************************************
 **  Static variables
diff --git a/btif/src/btif_profile_queue.c b/btif/src/btif_profile_queue.c
index 32a399c..505394a 100644
--- a/btif/src/btif_profile_queue.c
+++ b/btif/src/btif_profile_queue.c
@@ -26,13 +26,12 @@
 
 #define LOG_TAG "bt_btif_queue"
 
+#include "btif_profile_queue.h"
+
 #include <assert.h>
 #include <string.h>
 
-#include <hardware/bluetooth.h>
-
 #include "btif_common.h"
-#include "btif_profile_queue.h"
 #include "gki.h"
 #include "osi/include/allocator.h"
 #include "osi/include/list.h"
@@ -161,7 +160,6 @@
     return p_head->connect_cb(&p_head->bda, p_head->uuid);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_queue_release
diff --git a/btif/src/btif_rc.c b/btif/src/btif_rc.c
index 10b6738..3a1565d 100644
--- a/btif/src/btif_rc.c
+++ b/btif/src/btif_rc.c
@@ -16,7 +16,6 @@
  *
  ******************************************************************************/
 
-
 /*****************************************************************************
  *
  *  Filename:      btif_rc.c
@@ -24,22 +23,24 @@
  *  Description:   Bluetooth AVRC implementation
  *
  *****************************************************************************/
-#include <hardware/bluetooth.h>
+
+#define LOG_TAG "bt_btif_avrc"
+
 #include <fcntl.h>
 #include <pthread.h>
 #include <string.h>
 #include <unistd.h>
 
+#include <hardware/bluetooth.h>
+#include <hardware/bt_rc.h>
+
+#include "avrc_defs.h"
 #include "bta_api.h"
 #include "bta_av_api.h"
-#include "avrc_defs.h"
-#include "gki.h"
-
-#define LOG_TAG "bt_btif_avrc"
+#include "btif_av.h"
 #include "btif_common.h"
 #include "btif_util.h"
-#include "btif_av.h"
-#include "hardware/bt_rc.h"
+#include "gki.h"
 #include "uinput.h"
 
 /*****************************************************************************
@@ -133,7 +134,6 @@
     rc_transaction_t transaction[MAX_TRANSACTIONS_PER_SESSION];
 } rc_device_t;
 
-
 rc_device_t device;
 
 #define MAX_UINPUT_PATHS 3
@@ -219,7 +219,6 @@
 extern BOOLEAN btif_hf_call_terminated_recently();
 extern BOOLEAN check_cod(const bt_bdaddr_t *remote_bdaddr, uint32_t cod);
 
-
 /*****************************************************************************
 **  Functions
 ******************************************************************************/
@@ -404,7 +403,6 @@
 #endif
 }
 
-
 /***************************************************************************
  *  Function       handle_rc_connect
  *
@@ -677,7 +675,6 @@
 
 }
 
-
 /***************************************************************************
  *  Function       handle_rc_metamsg_cmd
  *
@@ -1180,7 +1177,6 @@
 
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_rc_upstreams_rsp_evt
@@ -1473,7 +1469,6 @@
     return status;
 }
 
-
 /***************************************************************************
 **
 ** Function         register_volumechange
@@ -1518,7 +1513,6 @@
         BTIF_TRACE_ERROR("%s failed to build command:%d",__FUNCTION__,BldResp);
 }
 
-
 /***************************************************************************
 **
 ** Function         handle_rc_metamsg_rsp
@@ -1595,7 +1589,6 @@
                                 pmeta_msg->label);
 }
 
-
 /***************************************************************************
 **
 ** Function         cleanup
@@ -1845,7 +1838,6 @@
     return result;
 }
 
-
 /*******************************************************************************
 **
 ** Function         release_transaction
diff --git a/btif/src/btif_sdp.c b/btif/src/btif_sdp.c
index f953327..08980e9 100644
--- a/btif/src/btif_sdp.c
+++ b/btif/src/btif_sdp.c
@@ -25,17 +25,19 @@
  *
  ***********************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sdp.h>
+#define LOG_TAG "bt_btif_sdp"
+
 #include <stdlib.h>
 #include <string.h>
 
-#define LOG_TAG "bt_btif_sdp"
-#include "btif_common.h"
-#include "btif_util.h"
-#include "btif_profile_queue.h"
+#include <hardware/bluetooth.h>
+#include <hardware/bt_sdp.h>
+
 #include "bta_api.h"
 #include "bta_sdp_api.h"
+#include "btif_common.h"
+#include "btif_profile_queue.h"
+#include "btif_util.h"
 
 /*****************************************************************************
 **  Functions implemented in sdp_server.c
@@ -52,7 +54,6 @@
 void copy_sdp_records(bluetooth_sdp_record* in_records,
         bluetooth_sdp_record* out_records, int count);
 
-
 /*****************************************************************************
 **  Static variables
 ******************************************************************************/
@@ -144,7 +145,6 @@
     return BT_STATUS_SUCCESS;
 }
 
-
 static bt_status_t search(bt_bdaddr_t *bd_addr, const uint8_t *uuid)
 {
     tSDP_UUID sdp_uuid;
diff --git a/btif/src/btif_sdp_server.c b/btif/src/btif_sdp_server.c
index b159eb5..10fdada 100644
--- a/btif/src/btif_sdp_server.c
+++ b/btif/src/btif_sdp_server.c
@@ -25,24 +25,25 @@
  *
  ***********************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sdp.h>
+#define LOG_TAG "bt_btif_sdp_server"
+
+#include <pthread.h>
 #include <stdlib.h>
 #include <string.h>
-#include <pthread.h>
 
-#define LOG_TAG "bt_btif_sdp_server"
-#include "btif_common.h"
-#include "btif_util.h"
+#include <hardware/bluetooth.h>
+#include <hardware/bt_sdp.h>
+
 #include "bta_sdp_api.h"
 #include "bta_sys.h"
+#include "btif_common.h"
 #include "btif_sock_util.h"
+#include "btif_util.h"
 #include "osi/include/allocator.h"
 #include "utl.h"
 
 static pthread_mutex_t sdp_lock = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
 
-
 /**
  * The need for a state variable have been reduced to two states.
  * The remaining state control is handled by program flow
@@ -118,7 +119,6 @@
     pthread_mutex_unlock(&sdp_lock);
 }
 
-
 int get_sdp_records_size(bluetooth_sdp_record* in_record, int count) {
     bluetooth_sdp_record* record = in_record;
     int records_size = 0;
@@ -273,7 +273,6 @@
 
 }
 
-
 bt_status_t create_sdp_record(bluetooth_sdp_record *record, int* record_handle) {
     int handle;
 
@@ -307,7 +306,6 @@
     return BT_STATUS_FAIL;
 }
 
-
 /******************************************************************************
  * CALLBACK FUNCTIONS
  * Called in BTA context to create/remove SDP records.
@@ -620,7 +618,6 @@
     return sdp_handle;
 }
 
-
 /* Create a OPP Server SDP record based on information stored in a bluetooth_sdp_ops_record */
 static int add_opps_sdp(const bluetooth_sdp_ops_record* rec)
 {
@@ -716,4 +713,3 @@
     return sdp_handle;
 }
 
-
diff --git a/btif/src/btif_sm.c b/btif/src/btif_sm.c
index 61409ae..7e6eafb 100644
--- a/btif/src/btif_sm.c
+++ b/btif/src/btif_sm.c
@@ -16,7 +16,6 @@
  *
  ******************************************************************************/
 
-
 /*****************************************************************************
  *
  *  Filename:      btif_sm.c
@@ -27,17 +26,11 @@
 
 #define LOG_TAG "bt_btif"
 
-#include <hardware/bluetooth.h>
-
-#include "osi/include/allocator.h"
-#include "btif_common.h"
 #include "btif_sm.h"
+
+#include "btif_common.h"
 #include "gki.h"
-
-/*****************************************************************************
-**  Constants & Macros
-******************************************************************************/
-
+#include "osi/include/allocator.h"
 
 /*****************************************************************************
 **  Local type definitions
@@ -48,18 +41,6 @@
 } btif_sm_cb_t;
 
 /*****************************************************************************
-**  Static variables
-******************************************************************************/
-
-/*****************************************************************************
-**  Static functions
-******************************************************************************/
-
-/*****************************************************************************
-**  Externs
-******************************************************************************/
-
-/*****************************************************************************
 **  Functions
 ******************************************************************************/
 
diff --git a/btif/src/btif_sock_l2cap.c b/btif/src/btif_sock_l2cap.c
index abf930c..4148843 100644
--- a/btif/src/btif_sock_l2cap.c
+++ b/btif/src/btif_sock_l2cap.c
@@ -15,6 +15,10 @@
 * limitations under the License.
 */
 
+#define LOG_TAG "bt_btif_sock"
+
+#include "btif_sock_l2cap.h"
+
 #include <errno.h>
 #include <pthread.h>
 #include <stdlib.h>
@@ -23,10 +27,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 
-#define LOG_TAG "bt_btif_sock"
 #include "osi/include/allocator.h"
 #include "osi/include/log.h"
 
@@ -35,7 +37,6 @@
 #include "bta_jv_api.h"
 #include "bta_jv_co.h"
 #include "btif_common.h"
-#include "btif_sock_l2cap.h"
 #include "btif_sock_sdp.h"
 #include "btif_sock_thread.h"
 #include "btif_sock_util.h"
@@ -218,7 +219,6 @@
 {
     char ret;
 
-
     pthread_mutex_lock(&state_lock);
     ret = pth != -1;
     pthread_mutex_unlock(&state_lock);
@@ -668,8 +668,6 @@
     pthread_mutex_unlock(&state_lock);
 }
 
-
-
 static void on_l2cap_data_ind(tBTA_JV *evt, uint32_t id)
 {
     l2cap_socket *sock;
@@ -1048,5 +1046,3 @@
     pthread_mutex_unlock(&state_lock);
 }
 
-
-
diff --git a/btif/src/btif_sock_sdp.c b/btif/src/btif_sock_sdp.c
index 44897a6..549c9dd 100644
--- a/btif/src/btif_sock_sdp.c
+++ b/btif/src/btif_sock_sdp.c
@@ -18,32 +18,30 @@
 
 #define LOG_TAG "bt_btif_sock_sdp"
 
-#include <stdint.h>
-#include <stdbool.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
+#include "btif_sock_sdp.h"
+
 #include <errno.h>
+#include <sys/socket.h>
+#include <sys/types.h>
 
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 
-#include "btif_common.h"
-#include "btif_util.h"
-#include "btif_sock_util.h"
-#include "bta_api.h"
+#include "../bta/pb/bta_pbs_int.h"
+#include "../include/bta_op_api.h"
 #include "bt_target.h"
+#include "bta_api.h"
+#include "bta_jv_api.h"
+#include "btif_common.h"
+#include "btif_sock_util.h"
+#include "btif_util.h"
+#include "btm_api.h"
+#include "btm_int.h"
+#include "btu.h"
 #include "gki.h"
 #include "hcimsgs.h"
 #include "sdp_api.h"
-#include "btu.h"
-#include "btm_api.h"
-#include "btm_int.h"
-#include "btif_sock_sdp.h"
 #include "utl.h"
-#include "../bta/pb/bta_pbs_int.h"
-#include "../include/bta_op_api.h"
-#include "bta_jv_api.h"
 
 // This module provides an abstraction on top of the lower-level SDP database
 // code for registration and discovery of various bluetooth sockets.
@@ -93,8 +91,6 @@
                           | BTA_OP_ANY_MASK)
 #endif
 
-
-
 #define RESERVED_SCN_PBS 19
 #define RESERVED_SCN_OPS 12
 
@@ -202,7 +198,6 @@
                        1, &type, &type_len, &type_buf_ptr))
     goto error;
 
-
   APPL_TRACE_DEBUG("add_sdp_by_uuid: service registered successfully, "
                    "service_name: %s, handle: 0x%08x", name, handle);
   return handle;
diff --git a/btif/src/btif_sock_thread.c b/btif/src/btif_sock_thread.c
index 8b39186..e9e745c 100644
--- a/btif/src/btif_sock_thread.c
+++ b/btif/src/btif_sock_thread.c
@@ -25,8 +25,9 @@
  *
  ***********************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_sock.h>
+#define LOG_TAG "bt_btif_sock"
+
+#include "btif_sock_thread.h"
 
 #include <alloca.h>
 #include <ctype.h>
@@ -46,12 +47,9 @@
 #include <time.h>
 #include <unistd.h>
 
-#define LOG_TAG "bt_btif_sock"
-
 #include "bta_api.h"
 #include "btif_common.h"
 #include "btif_sock.h"
-#include "btif_sock_thread.h"
 #include "btif_sock_util.h"
 #include "btif_util.h"
 #include "osi/include/socket_utils/sockets.h"
@@ -99,8 +97,6 @@
 } thread_slot_t;
 static thread_slot_t ts[MAX_THREAD];
 
-
-
 static void *sock_poll_thread(void *arg);
 static inline void close_cmd_fd(int h);
 
diff --git a/btif/src/btif_sock_util.c b/btif/src/btif_sock_util.c
index b997131..ab2fd7a 100644
--- a/btif/src/btif_sock_util.c
+++ b/btif/src/btif_sock_util.c
@@ -16,6 +16,8 @@
  *
  ******************************************************************************/
 
+#define LOG_TAG "bt_btif_sock"
+
 #include "btif_sock_util.h"
 
 #include <arpa/inet.h>
@@ -34,8 +36,6 @@
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 
-#define LOG_TAG "bt_btif_sock"
-
 #include "bt_target.h"
 #include "bta_api.h"
 #include "bta_jv_api.h"
@@ -55,7 +55,6 @@
 
 #define asrt(s) if(!(s)) BTIF_TRACE_ERROR("## %s assert %s failed at line:%d ##",__FUNCTION__, #s, __LINE__)
 
-
 int sock_send_all(int sock_fd, const uint8_t* buf, int len)
 {
     int s = len;
diff --git a/btif/src/btif_storage.c b/btif/src/btif_storage.c
index 9e99901..de1b305 100644
--- a/btif/src/btif_storage.c
+++ b/btif/src/btif_storage.c
@@ -30,6 +30,8 @@
 
 #define LOG_TAG "bt_btif_storage"
 
+#include "btif_storage.h"
+
 #include <alloca.h>
 #include <assert.h>
 #include <ctype.h>
@@ -37,14 +39,11 @@
 #include <string.h>
 #include <time.h>
 
-#include <hardware/bluetooth.h>
-
 #include "bta_hh_api.h"
 #include "btcore/include/bdaddr.h"
 #include "btif_api.h"
 #include "btif_config.h"
 #include "btif_hh.h"
-#include "btif_storage.h"
 #include "btif_util.h"
 #include "gki.h"
 #include "osi/include/allocator.h"
@@ -78,7 +77,6 @@
 #define BTIF_STORAGE_KEY_ADAPTER_SCANMODE "ScanMode"
 #define BTIF_STORAGE_KEY_ADAPTER_DISC_TIMEOUT "DiscoveryTimeout"
 
-
 #if defined(OS_GENERIC)
 // TODO(armansito): Find a better way than searching by a hardcoded path.
 #define BTIF_AUTO_PAIR_CONF_FILE "auto_pair_devlist.conf"
@@ -94,7 +92,6 @@
 
 #define BTIF_AUTO_PAIR_CONF_VALUE_SEPARATOR ","
 
-
 /* This is a local property to add a device found */
 #define BT_PROPERTY_REMOTE_DEVICE_TIMESTAMP 0xFF
 
@@ -143,17 +140,14 @@
                                          STORAGE_HID_DESC_LEN_SIZE+ 1 +\
                                          STORAGE_HID_DESC_MAX_SIZE+ 1 )
 
-
 /* currently remote services is the potentially largest entry */
 #define BTIF_STORAGE_MAX_LINE_SZ BTIF_REMOTE_SERVICES_ENTRY_SIZE_MAX
 
-
 /* check against unv max entry size at compile time */
 #if (BTIF_STORAGE_ENTRY_MAX_SIZE > UNV_MAXLINE_LENGTH)
     #error "btif storage entry size exceeds unv max line size"
 #endif
 
-
 #define BTIF_STORAGE_HL_APP          "hl_app"
 #define BTIF_STORAGE_HL_APP_CB       "hl_app_cb"
 #define BTIF_STORAGE_HL_APP_DATA     "hl_app_data_"
@@ -1483,7 +1477,6 @@
     return bt_status;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btif_storage_load_autopair_device_list
diff --git a/btif/src/btif_util.c b/btif/src/btif_util.c
index 42576eb..eb94eee 100644
--- a/btif/src/btif_util.c
+++ b/btif/src/btif_util.c
@@ -26,29 +26,29 @@
  *
  ***********************************************************************************/
 
-#include <hardware/bluetooth.h>
-#include <hardware/bt_hf.h>
-#include <hardware/bt_av.h>
+#define LOG_TAG "bt_btif_util"
+
+#include "btif_util.h"
+
+#include <ctype.h>
 #include <netinet/in.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <ctype.h>
 
+#include <hardware/bt_av.h>
 
-#define LOG_TAG "bt_btif_util"
-#include "btif_common.h"
-#include "bta_api.h"
-#include "gki.h"
-#include "btu.h"
-#include "bte.h"
-#include "btif_dm.h"
-#include "btif_util.h"
-#include "bta_ag_api.h"
-#include "bta_av_api.h"
-#include "bta_hh_api.h"
-#include "bta_hf_client_api.h"
 #include "avrc_defs.h"
+#include "bta_ag_api.h"
+#include "bta_api.h"
+#include "bta_av_api.h"
+#include "bta_hf_client_api.h"
+#include "bta_hh_api.h"
+#include "bte.h"
+#include "btif_common.h"
+#include "btif_dm.h"
+#include "btu.h"
+#include "gki.h"
 
 /************************************************************************************
 **  Constants & Macros
@@ -191,7 +191,6 @@
     return (x);
 }
 
-
 const char* dump_dm_search_event(UINT16 event)
 {
     switch(event)
@@ -209,7 +208,6 @@
      }
 }
 
-
 const char* dump_property_type(bt_property_type_t type)
 {
     switch(type)
@@ -364,7 +362,6 @@
      }
 }
 
-
 const char* dump_hf_conn_state(UINT16 event)
 {
     switch(event)
@@ -407,7 +404,6 @@
     }
 }
 
-
 const char* dump_hf_audio_state(UINT16 event)
 {
     switch(event)
diff --git a/btif/src/stack_manager.c b/btif/src/stack_manager.c
index fd2046f..0f80657 100644
--- a/btif/src/stack_manager.c
+++ b/btif/src/stack_manager.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_stack_manager"
 
+#include "stack_manager.h"
+
 #include <hardware/bluetooth.h>
 
 #include "btcore/include/module.h"
@@ -29,7 +31,6 @@
 #include "osi/include/osi.h"
 #include "osi/include/semaphore.h"
 #include "osi/include/thread.h"
-#include "stack_manager.h"
 
 // Temp includes
 #include "btif_config.h"
diff --git a/device/src/classic/peer.c b/device/src/classic/peer.c
index d2de679..1bab300 100644
--- a/device/src/classic/peer.c
+++ b/device/src/classic/peer.c
@@ -18,13 +18,14 @@
 
 #define LOG_TAG "bt_classic_peer"
 
+#include "device/include/classic/peer.h"
+
 #include <assert.h>
 #include <cutils/log.h>
 #include <pthread.h>
 #include <stdbool.h>
 
 #include "btcore/include/module.h"
-#include "device/include/classic/peer.h"
 #include "osi/include/allocator.h"
 #include "osi/include/future.h"
 #include "osi/include/hash_map.h"
diff --git a/device/src/controller.c b/device/src/controller.c
index 89c0133..853647b 100644
--- a/device/src/controller.c
+++ b/device/src/controller.c
@@ -18,21 +18,17 @@
 
 #define LOG_TAG "bt_controller"
 
-#include <assert.h>
-#include <stdbool.h>
-
-#include "btcore/include/bdaddr.h"
-#include "bt_types.h"
 #include "device/include/controller.h"
+
+#include <assert.h>
+
+#include "bt_types.h"
 #include "btcore/include/event_mask.h"
-#include "osi/include/future.h"
-#include "hcimsgs.h"
-#include "hci/include/hci_layer.h"
-#include "hci/include/hci_packet_factory.h"
-#include "hci/include/hci_packet_parser.h"
 #include "btcore/include/module.h"
-#include "stack/include/btm_ble_api.h"
 #include "btcore/include/version.h"
+#include "hcimsgs.h"
+#include "osi/include/future.h"
+#include "stack/include/btm_ble_api.h"
 
 const bt_event_mask_t BLE_EVENT_MASK = { "\x00\x00\x00\x00\x00\x00\x04\x7f" };
 
diff --git a/hci/include/hci_audio.h b/hci/include/hci_audio.h
index 6e8063a..3eb1d61 100644
--- a/hci/include/hci_audio.h
+++ b/hci/include/hci_audio.h
@@ -18,6 +18,8 @@
 
 #pragma once
 
+#include <stdint.h>
+
 // Audio state definitions.
 typedef enum {
     SCO_STATE_OFF = 0,      // Audio is off.
diff --git a/hci/src/btsnoop_net.c b/hci/src/btsnoop_net.c
index bd0448b..f797558 100644
--- a/hci/src/btsnoop_net.c
+++ b/hci/src/btsnoop_net.c
@@ -29,8 +29,8 @@
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "osi/include/osi.h"
 #include "osi/include/log.h"
+#include "osi/include/osi.h"
 
 static void safe_close_(int *fd);
 static void *listen_fn_(void *context);
diff --git a/hci/src/hci_audio.c b/hci/src/hci_audio.c
index e818982..ec126b8 100644
--- a/hci/src/hci_audio.c
+++ b/hci/src/hci_audio.c
@@ -18,10 +18,9 @@
 
 #define LOG_TAG "bt_hci_audio"
 
-#include <stdint.h>
+#include "hci/include/hci_audio.h"
 
 #include "hci/include/bt_vendor_lib.h"
-#include "hci/include/hci_audio.h"
 #include "hci/include/vendor.h"
 #include "osi/include/log.h"
 
diff --git a/hci/src/hci_inject.c b/hci/src/hci_inject.c
index a41517f..63a5200 100644
--- a/hci/src/hci_inject.c
+++ b/hci/src/hci_inject.c
@@ -18,13 +18,14 @@
 
 #define LOG_TAG "bt_hci_inject"
 
+#include "hci_inject.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <string.h>
 
 #include "bt_types.h"
 #include "buffer_allocator.h"
-#include "hci_inject.h"
 #include "hci_layer.h"
 #include "osi/include/allocator.h"
 #include "osi/include/list.h"
diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.c
index d1b5dae..5a34f01 100644
--- a/hci/src/hci_layer.c
+++ b/hci/src/hci_layer.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_hci"
 
+#include "hci_layer.h"
+
 #include <assert.h>
 #include <pthread.h>
 #include <signal.h>
@@ -38,16 +40,12 @@
 #include "hci_hal.h"
 #include "hci_inject.h"
 #include "hci_internals.h"
-#include "hci_layer.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
 #include "low_power_manager.h"
-#include "osi/include/fixed_queue.h"
-#include "osi/include/future.h"
 #include "osi/include/list.h"
 #include "osi/include/log.h"
 #include "osi/include/non_repeating_timer.h"
-#include "osi/include/osi.h"
 #include "osi/include/reactor.h"
 #include "packet_fragmenter.h"
 #include "vendor.h"
diff --git a/hci/src/packet_fragmenter.c b/hci/src/packet_fragmenter.c
index acc45ca..6dfebe2 100644
--- a/hci/src/packet_fragmenter.c
+++ b/hci/src/packet_fragmenter.c
@@ -26,7 +26,6 @@
 #include "buffer_allocator.h"
 #include "device/include/controller.h"
 #include "hci_internals.h"
-#include "hci_layer.h"
 #include "osi/include/hash_functions.h"
 #include "osi/include/hash_map.h"
 #include "osi/include/log.h"
diff --git a/hci/src/vendor.c b/hci/src/vendor.c
index e0a0b7f..ace76b3 100644
--- a/hci/src/vendor.c
+++ b/hci/src/vendor.c
@@ -18,14 +18,14 @@
 
 #define LOG_TAG "bt_vendor"
 
+#include "vendor.h"
+
 #include <assert.h>
 #include <dlfcn.h>
 
 #include "buffer_allocator.h"
-#include "bt_vendor_lib.h"
-#include "osi/include/osi.h"
 #include "osi/include/log.h"
-#include "vendor.h"
+#include "osi/include/osi.h"
 
 #define LAST_VENDOR_OPCODE_VALUE VENDOR_DO_EPILOG
 
diff --git a/main/bte_logmsg.c b/main/bte_logmsg.c
index c56e22d..1ec4e8b 100644
--- a/main/bte_logmsg.c
+++ b/main/bte_logmsg.c
@@ -16,7 +16,7 @@
  *
  ******************************************************************************/
 
-#define LOG_TAG "bte_logmsg"
+#define LOG_TAG "bt_bte"
 
 #include <assert.h>
 #include <stdio.h>
diff --git a/osi/include/fixed_queue.h b/osi/include/fixed_queue.h
index 5c32ac7..52862bf 100644
--- a/osi/include/fixed_queue.h
+++ b/osi/include/fixed_queue.h
@@ -19,6 +19,7 @@
 #pragma once
 
 #include <stdbool.h>
+#include <stdlib.h>
 
 struct fixed_queue_t;
 typedef struct fixed_queue_t fixed_queue_t;
diff --git a/osi/src/alarm.c b/osi/src/alarm.c
index 32b18b2..416916b 100644
--- a/osi/src/alarm.c
+++ b/osi/src/alarm.c
@@ -18,17 +18,19 @@
 
 #define LOG_TAG "bt_osi_alarm"
 
+#include "osi/include/alarm.h"
+
 #include <assert.h>
 #include <errno.h>
-#include <hardware/bluetooth.h>
 #include <inttypes.h>
 #include <malloc.h>
-#include <string.h>
-#include <signal.h>
-#include <time.h>
 #include <pthread.h>
+#include <signal.h>
+#include <string.h>
+#include <time.h>
 
-#include "osi/include/alarm.h"
+#include <hardware/bluetooth.h>
+
 #include "osi/include/allocator.h"
 #include "osi/include/list.h"
 #include "osi/include/log.h"
diff --git a/osi/src/allocation_tracker.c b/osi/src/allocation_tracker.c
index 67fe8f7..bb0b219 100644
--- a/osi/src/allocation_tracker.c
+++ b/osi/src/allocation_tracker.c
@@ -18,18 +18,18 @@
 
 #define LOG_TAG "bt_osi_allocation_tracker"
 
+#include "osi/include/allocation_tracker.h"
+
 #include <assert.h>
 #include <pthread.h>
-#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
-#include "osi/include/allocation_tracker.h"
 #include "osi/include/allocator.h"
 #include "osi/include/hash_functions.h"
 #include "osi/include/hash_map.h"
-#include "osi/include/osi.h"
 #include "osi/include/log.h"
+#include "osi/include/osi.h"
 
 typedef struct {
   uint8_t allocator_id;
diff --git a/osi/src/array.c b/osi/src/array.c
index f8e11e8..8291dbb 100644
--- a/osi/src/array.c
+++ b/osi/src/array.c
@@ -18,12 +18,13 @@
 
 #define LOG_TAG "bt_osi_array"
 
+#include "osi/include/array.h"
+
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include "osi/include/allocator.h"
-#include "osi/include/array.h"
 #include "osi/include/log.h"
 
 struct array_t {
diff --git a/osi/src/buffer.c b/osi/src/buffer.c
index 4d6bcf0..cbd1e23 100644
--- a/osi/src/buffer.c
+++ b/osi/src/buffer.c
@@ -18,11 +18,12 @@
 
 #define LOG_TAG "bt_osi_buffer"
 
+#include "osi/include/buffer.h"
+
 #include <assert.h>
 #include <stdint.h>
 
 #include "osi/include/allocator.h"
-#include "osi/include/buffer.h"
 #include "osi/include/log.h"
 
 struct buffer_t {
diff --git a/osi/src/config.c b/osi/src/config.c
index 7af398f..43f65a1 100644
--- a/osi/src/config.c
+++ b/osi/src/config.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_osi_config"
 
+#include "osi/include/config.h"
+
 #include <assert.h>
 #include <ctype.h>
 #include <errno.h>
@@ -27,7 +29,6 @@
 #include <unistd.h>
 
 #include "osi/include/allocator.h"
-#include "osi/include/config.h"
 #include "osi/include/list.h"
 #include "osi/include/log.h"
 
diff --git a/osi/src/data_dispatcher.c b/osi/src/data_dispatcher.c
index 59265fa..659769b 100644
--- a/osi/src/data_dispatcher.c
+++ b/osi/src/data_dispatcher.c
@@ -18,10 +18,11 @@
 
 #define LOG_TAG "bt_osi_data_dispatcher"
 
+#include "osi/include/data_dispatcher.h"
+
 #include <assert.h>
 
 #include "osi/include/allocator.h"
-#include "osi/include/data_dispatcher.h"
 #include "osi/include/hash_functions.h"
 #include "osi/include/hash_map.h"
 #include "osi/include/osi.h"
diff --git a/osi/src/eager_reader.c b/osi/src/eager_reader.c
index 250f394..78d6eac 100644
--- a/osi/src/eager_reader.c
+++ b/osi/src/eager_reader.c
@@ -18,18 +18,17 @@
 
 #define LOG_TAG "bt_osi_eager_reader"
 
+#include "osi/include/eager_reader.h"
+
 #include <assert.h>
 #include <errno.h>
-#include <stddef.h>
 #include <string.h>
-#include <unistd.h>
 #include <sys/eventfd.h>
+#include <unistd.h>
 
-#include "osi/include/allocator.h"
-#include "osi/include/eager_reader.h"
 #include "osi/include/fixed_queue.h"
-#include "osi/include/osi.h"
 #include "osi/include/log.h"
+#include "osi/include/osi.h"
 #include "osi/include/reactor.h"
 #include "osi/include/thread.h"
 
diff --git a/osi/src/fixed_queue.c b/osi/src/fixed_queue.c
index 009e185..4ab5b92 100644
--- a/osi/src/fixed_queue.c
+++ b/osi/src/fixed_queue.c
@@ -18,7 +18,6 @@
 
 #include <assert.h>
 #include <pthread.h>
-#include <stdlib.h>
 
 #include "osi/include/allocator.h"
 #include "osi/include/fixed_queue.h"
diff --git a/osi/src/future.c b/osi/src/future.c
index 3e02462..e91cdb3 100644
--- a/osi/src/future.c
+++ b/osi/src/future.c
@@ -18,12 +18,13 @@
 
 #define LOG_TAG "bt_osi_future"
 
+#include "osi/include/future.h"
+
 #include <assert.h>
 
 #include "osi/include/allocator.h"
-#include "osi/include/future.h"
-#include "osi/include/osi.h"
 #include "osi/include/log.h"
+#include "osi/include/osi.h"
 #include "osi/include/semaphore.h"
 
 struct future_t {
diff --git a/osi/src/reactor.c b/osi/src/reactor.c
index f213a40..b216fec 100644
--- a/osi/src/reactor.c
+++ b/osi/src/reactor.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_osi_reactor"
 
+#include "osi/include/reactor.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <pthread.h>
@@ -30,7 +32,6 @@
 #include "osi/include/allocator.h"
 #include "osi/include/list.h"
 #include "osi/include/log.h"
-#include "osi/include/reactor.h"
 
 #if !defined(EFD_SEMAPHORE)
 #  define EFD_SEMAPHORE (1 << 0)
diff --git a/osi/src/semaphore.c b/osi/src/semaphore.c
index 5ea2f05..8693c9c 100644
--- a/osi/src/semaphore.c
+++ b/osi/src/semaphore.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_osi_semaphore"
 
+#include "osi/include/semaphore.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -27,9 +29,8 @@
 #include <unistd.h>
 
 #include "osi/include/allocator.h"
-#include "osi/include/osi.h"
 #include "osi/include/log.h"
-#include "osi/include/semaphore.h"
+#include "osi/include/osi.h"
 
 #if !defined(EFD_SEMAPHORE)
 #  define EFD_SEMAPHORE (1 << 0)
diff --git a/osi/src/socket.c b/osi/src/socket.c
index fa62868..60dceca 100644
--- a/osi/src/socket.c
+++ b/osi/src/socket.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_osi_socket"
 
+#include "osi/include/socket.h"
+
 #include <asm/ioctls.h>
 #include <assert.h>
 #include <errno.h>
@@ -25,14 +27,12 @@
 #include <string.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <sys/types.h>
 #include <unistd.h>
 
 #include "osi/include/allocator.h"
-#include "osi/include/osi.h"
 #include "osi/include/log.h"
+#include "osi/include/osi.h"
 #include "osi/include/reactor.h"
-#include "osi/include/socket.h"
 
 struct socket_t {
   int fd;
diff --git a/osi/src/thread.c b/osi/src/thread.c
index 2747e30..9410acb 100644
--- a/osi/src/thread.c
+++ b/osi/src/thread.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_osi_thread"
 
+#include "osi/include/thread.h"
+
 #include <assert.h>
 #include <errno.h>
 #include <malloc.h>
@@ -32,7 +34,6 @@
 #include "osi/include/log.h"
 #include "osi/include/reactor.h"
 #include "osi/include/semaphore.h"
-#include "osi/include/thread.h"
 
 struct thread_t {
   bool is_joined;
diff --git a/service/a2dp_source.cpp b/service/a2dp_source.cpp
index 1b21cc1..1d1b2d9 100644
--- a/service/a2dp_source.cpp
+++ b/service/a2dp_source.cpp
@@ -13,13 +13,14 @@
 //  See the License for the specific language governing permissions and
 //  limitations under the License.
 //
-#include "a2dp_source.h"
 
 #define LOG_TAG "bt_a2dp_source"
-#include "osi/include/log.h"
+
+#include "a2dp_source.h"
 
 #include "core_stack.h"
 #include "logging_helpers.h"
+#include "osi/include/log.h"
 #include "osi/include/osi.h"
 
 namespace {
diff --git a/service/core_stack.cpp b/service/core_stack.cpp
index 21081de..9173b96 100644
--- a/service/core_stack.cpp
+++ b/service/core_stack.cpp
@@ -13,6 +13,9 @@
 //  See the License for the specific language governing permissions and
 //  limitations under the License.
 //
+
+#define LOG_TAG "bluetooth_daemon"
+
 #include "core_stack.h"
 
 #include <signal.h>
@@ -27,9 +30,6 @@
 #include <hardware/bluetooth.h>
 #include <hardware/hardware.h>
 
-// TODO(armansito): Remove this line and use base/logging.h instead.
-#define LOG_TAG "bluetooth_daemon"
-
 #include "logging_helpers.h"
 
 extern "C" {
diff --git a/service/gatt_server.cpp b/service/gatt_server.cpp
index 3abdff9..40db111 100644
--- a/service/gatt_server.cpp
+++ b/service/gatt_server.cpp
@@ -13,6 +13,9 @@
 //  See the License for the specific language governing permissions and
 //  limitations under the License.
 //
+
+#define LOG_TAG "bt_gatts"
+
 #include "gatt_server.h"
 
 #include <stdio.h>
@@ -30,13 +33,11 @@
 #include <unordered_map>
 #include <vector>
 
-#define LOG_TAG "bt_gatt_server"
-#include "osi/include/log.h"
-
 #include "core_stack.h"
 #include "hardware/bluetooth.h"
 #include "hardware/bt_gatt.h"
 #include "logging_helpers.h"
+#include "osi/include/log.h"
 #include "osi/include/osi.h"
 #include "uuid.h"
 
diff --git a/service/ipc/unix_ipc_host.cpp b/service/ipc/unix_ipc_host.cpp
index 3ebc44a..bd1570d 100644
--- a/service/ipc/unix_ipc_host.cpp
+++ b/service/ipc/unix_ipc_host.cpp
@@ -14,6 +14,8 @@
 //  limitations under the License.
 //
 
+#define LOG_TAG "bt_bluetooth_host"
+
 #include "service/ipc/unix_ipc_host.h"
 
 #include <errno.h>
@@ -31,7 +33,6 @@
 #include <base/strings/string_number_conversions.h>
 #include <base/strings/string_split.h>
 
-#define LOG_TAG "bt_bluetooth_host"
 #include "osi/include/log.h"
 #include "service/core_stack.h"
 #include "service/gatt_server.h"
diff --git a/service/main.cpp b/service/main.cpp
index b8245f6..2f28815 100644
--- a/service/main.cpp
+++ b/service/main.cpp
@@ -13,7 +13,6 @@
 //  See the License for the specific language governing permissions and
 //  limitations under the License.
 //
-
 #include <base/at_exit.h>
 #include <base/command_line.h>
 #include <base/files/scoped_file.h>
diff --git a/stack/btm/btm_ble.c b/stack/btm/btm_ble.c
index b450df1..0b56dfa 100644
--- a/stack/btm/btm_ble.c
+++ b/stack/btm/btm_ble.c
@@ -22,6 +22,9 @@
  *  security functions.
  *
  ******************************************************************************/
+
+#define LOG_TAG "bt_btm_ble"
+
 #include "bt_target.h"
 
 #if BLE_INCLUDED == TRUE
@@ -29,18 +32,16 @@
 #include <string.h>
 
 #include "bt_types.h"
-#include "hcimsgs.h"
-#include "btu.h"
-#include "btm_int.h"
-#include "btm_ble_api.h"
-#include "smp_api.h"
-#include "l2c_int.h"
-#include "gap_api.h"
 #include "bt_utils.h"
+#include "btm_ble_api.h"
+#include "btm_int.h"
+#include "btu.h"
 #include "device/include/controller.h"
-
-#define LOG_TAG "bt_btm_ble"
+#include "gap_api.h"
+#include "hcimsgs.h"
+#include "l2c_int.h"
 #include "osi/include/log.h"
+#include "smp_api.h"
 
 #if SMP_INCLUDED == TRUE
 extern BOOLEAN aes_cipher_msg_auth_code(BT_OCTET16 key, UINT8 *input, UINT16 length,
@@ -666,7 +667,6 @@
     BTM_TRACE_DEBUG ("btm_find_dev_type - device_type = %d addr_type = %d", *p_dev_type , *p_addr_type);
 }
 
-
 /*******************************************************************************
 **
 ** Function         BTM_ReadConnectedTransportAddress
@@ -824,7 +824,6 @@
     return use_le;
 }
 
-
 /*******************************************************************************
 **
 ** Function         BTM_SetBleDataLength
@@ -913,7 +912,6 @@
     }
 }
 
-
     #if (SMP_INCLUDED == TRUE)
 
 /*******************************************************************************
@@ -1831,8 +1829,6 @@
     btm_ble_update_mode_operation(role, bda, status);
 }
 
-
-
 /*****************************************************************************
 ** Function btm_ble_create_ll_conn_complete
 **
@@ -1969,7 +1965,6 @@
                 BTM_TRACE_DEBUG ("unknown event = %d", event);
                 break;
 
-
         }
     }
     else
@@ -2444,7 +2439,6 @@
         memcpy(&btm_cb.devcb.id_keys.ir[8], p->param_buf, BT_OCTET8_LEN);
         /* generate DHK= Eir({0x03, 0x00, 0x00 ...}) */
 
-
         SMP_Encrypt(btm_cb.devcb.id_keys.ir, BT_OCTET16_LEN, &btm_ble_dhk_pt,
                     1, &output);
         btm_ble_process_dhk(&output);
@@ -2581,7 +2575,6 @@
     if (adv_mode  == BTM_BLE_ADV_ENABLE)
         btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE);
 
-
 }
 
 /*******************************************************************************
diff --git a/stack/btm/btm_ble_adv_filter.c b/stack/btm/btm_ble_adv_filter.c
index 74ddddd..333f1f4 100644
--- a/stack/btm/btm_ble_adv_filter.c
+++ b/stack/btm/btm_ble_adv_filter.c
@@ -19,17 +19,19 @@
 #define LOG_TAG "bt_btm_ble"
 
 #include <string.h>
+
 #include "bt_target.h"
 
 #if (BLE_INCLUDED == TRUE)
+
 #include "bt_types.h"
-#include "hcimsgs.h"
-#include "btu.h"
-#include "btm_int.h"
 #include "bt_utils.h"
-#include "hcidefs.h"
 #include "btm_ble_api.h"
+#include "btm_int.h"
+#include "btu.h"
 #include "device/include/controller.h"
+#include "hcidefs.h"
+#include "hcimsgs.h"
 
 #define BTM_BLE_ADV_FILT_META_HDR_LENGTH 3
 #define BTM_BLE_ADV_FILT_FEAT_SELN_LEN  13
@@ -47,7 +49,6 @@
 
 #define BTM_BLE_PF_BIT_TO_MASK(x)          (UINT16)(1 << (x))
 
-
 tBTM_BLE_ADV_FILTER_CB btm_ble_adv_filt_cb;
 tBTM_BLE_VSC_CB cmn_ble_vsc_cb;
 static const BD_ADDR     na_bda= {0};
@@ -60,7 +61,6 @@
 #define BTM_BLE_GET_SCAN_PF_ACTION(x)    ((x) & 0x0f)
 #define BTM_BLE_INVALID_COUNTER     0xff
 
-
 /* length of each multi adv sub command */
 #define BTM_BLE_ADV_FILTER_ENB_LEN                       3
 
@@ -502,7 +502,6 @@
     return st;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_ble_update_srvc_data_change
@@ -721,7 +720,6 @@
     return BTM_BLE_INVALID_COUNTER;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_ble_update_addr_filter
@@ -925,7 +923,6 @@
     return st;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_ble_clear_scan_pf_filter
diff --git a/stack/btm/btm_ble_gap.c b/stack/btm/btm_ble_gap.c
index 41be717..9f0d3d1 100644
--- a/stack/btm/btm_ble_gap.c
+++ b/stack/btm/btm_ble_gap.c
@@ -22,27 +22,27 @@
  *
  ******************************************************************************/
 
+#define LOG_TAG "bt_btm_ble"
+
 #include <string.h>
 #include <stdio.h>
 #include <stddef.h>
 
 #include "bt_types.h"
 #include "bt_utils.h"
-#include "btm_int.h"
 #include "btm_ble_api.h"
+#include "btm_int.h"
 #include "btu.h"
 #include "device/include/controller.h"
-#include "hcimsgs.h"
 #include "gap_api.h"
+#include "hcimsgs.h"
 
 #if BLE_INCLUDED == TRUE
-#include "l2c_int.h"
-
-#include "gattdefs.h"
-#include "gatt_int.h"
 
 #include "btm_ble_int.h"
-#define LOG_TAG "bt_btm_ble"
+#include "gatt_int.h"
+#include "gattdefs.h"
+#include "l2c_int.h"
 #include "osi/include/log.h"
 
 #define BTM_BLE_NAME_SHORT                  0x01
@@ -221,7 +221,6 @@
 /* check LE combo state supported */
 #define BTM_LE_STATES_SUPPORTED(x, y, z)      ((x)[(z)] & (y))
 
-
 /*******************************************************************************
 **
 ** Function         BTM_BleUpdateAdvWhitelist
@@ -1883,7 +1882,6 @@
     return status;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_ble_start_inquiry
@@ -2951,7 +2949,6 @@
     return rt;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_ble_start_adv
@@ -3027,7 +3024,6 @@
     return rt;
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_ble_start_slow_adv
@@ -3118,7 +3114,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_ble_read_remote_features_complete
@@ -3412,5 +3407,4 @@
     return rt;
 }
 
-
 #endif  /* BLE_INCLUDED */
diff --git a/stack/btm/btm_pm.c b/stack/btm/btm_pm.c
index e3588eb..df51e58 100644
--- a/stack/btm/btm_pm.c
+++ b/stack/btm/btm_pm.c
@@ -30,20 +30,20 @@
 
 #define LOG_TAG "bt_btm_pm"
 
+#include <stddef.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdio.h>
-#include <stddef.h>
 
 #include "bt_types.h"
-#include "gki.h"
-#include "hcimsgs.h"
-#include "btu.h"
+#include "bt_utils.h"
 #include "btm_api.h"
 #include "btm_int.h"
-#include "l2c_int.h"
+#include "btu.h"
+#include "gki.h"
 #include "hcidefs.h"
-#include "bt_utils.h"
+#include "hcimsgs.h"
+#include "l2c_int.h"
 #include "osi/include/log.h"
 
 /*****************************************************************************/
@@ -184,7 +184,6 @@
     tBTM_PM_MODE        mode;
     int                 temp_pm_id;
 
-
     if(pm_id >= BTM_MAX_PM_RECORDS)
         pm_id = BTM_PM_SET_ONLY_ID;
 
@@ -259,8 +258,6 @@
         return BTM_CMD_STORED;
     }
 
-
-
     return btm_pm_snd_md_req(pm_id, acl_ind, p_mode);
 }
 
@@ -363,7 +360,6 @@
         cb = btm_cb.pm_reg_db[btm_cb.pm_pend_id].cback;
     }
 
-
     /* clear the register record */
     for(xx=0; xx<BTM_MAX_PM_RECORDS; xx++)
     {
@@ -715,7 +711,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_pm_proc_cmd_status
@@ -846,7 +841,6 @@
         }
     }
 
-
     /* notify registered parties */
     for(yy=0; yy<BTM_MAX_PM_RECORDS; yy++)
     {
diff --git a/stack/btm/btm_sec.c b/stack/btm/btm_sec.c
index 50e80b2..4d134dc 100644
--- a/stack/btm/btm_sec.c
+++ b/stack/btm/btm_sec.c
@@ -28,12 +28,12 @@
 #include <string.h>
 
 #include "bt_types.h"
+#include "bt_utils.h"
+#include "btm_int.h"
+#include "btu.h"
 #include "device/include/controller.h"
 #include "hcimsgs.h"
-#include "btu.h"
-#include "btm_int.h"
 #include "l2c_int.h"
-#include "bt_utils.h"
 #include "osi/include/log.h"
 
 #if (BT_USE_TRACES == TRUE && BT_TRACE_VERBOSE == FALSE)
@@ -51,7 +51,6 @@
 BOOLEAN (APPL_AUTH_WRITE_EXCEPTION)(BD_ADDR bd_addr);
 #endif
 
-
 /********************************************************************************
 **              L O C A L    F U N C T I O N     P R O T O T Y P E S            *
 *********************************************************************************/
@@ -285,7 +284,6 @@
     return(FALSE);
 }
 
-
 /*******************************************************************************
 **
 ** Function         BTM_SecDeleteRmtNameNotifyCallback
@@ -525,7 +523,6 @@
 
     p_srec = &btm_cb.sec_serv_rec[0];
 
-
     for (index = 0; index < BTM_SEC_MAX_SERVICE_RECORDS; index++, p_srec++)
     {
         /* Check if there is already a record for this service */
@@ -694,7 +691,6 @@
 #endif
 #endif
 
-
     return(record_allocated);
 }
 
@@ -958,7 +954,6 @@
 
     BTM_TRACE_DEBUG("btm_sec_bond_by_transport: Transport used %d" , transport);
 
-
     /* Other security process is in progress */
     if (btm_cb.pairing_state != BTM_PAIR_STATE_IDLE)
     {
@@ -1029,7 +1024,6 @@
     p_dev_rec->sec_flags &= ~(BTM_SEC_LINK_KEY_KNOWN | BTM_SEC_AUTHENTICATED | BTM_SEC_ENCRYPTED
                                   | BTM_SEC_ROLE_SWITCHED  | BTM_SEC_LINK_KEY_AUTHED);
 
-
     BTM_TRACE_DEBUG ("after update sec_flags=0x%x", p_dev_rec->sec_flags);
     if (!controller_get_interface()->supports_simple_pairing())
     {
@@ -3060,7 +3054,6 @@
             p_dev_rec = NULL;
     }
 
-
     /* Commenting out trace due to obf/compilation problems.
     */
 #if (BT_USE_TRACES == TRUE)
@@ -4531,7 +4524,6 @@
             p_dev_rec->security_required &= ~BTM_SEC_OUT_AUTHENTICATE;
             p_dev_rec->sec_flags &= ~ (BTM_SEC_LE_LINK_KEY_KNOWN << bit_shift);
 
-
 #ifdef BRCM_NOT_4_BTE
             /* If we rejected pairing, pass this special result code */
             if (btm_cb.acl_disc_reason == HCI_ERR_HOST_REJECT_SECURITY)
@@ -5282,7 +5274,6 @@
     p_inq_info->results.clock_offset = clock_offset | BTM_CLOCK_OFFSET_VALID;
 }
 
-
 /******************************************************************
 ** S T A T I C     F U N C T I O N S
 *******************************************************************/
@@ -5408,7 +5399,6 @@
     return(BTM_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_sec_start_get_name
@@ -5470,7 +5460,6 @@
     return(TRUE);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_sec_start_authorization
@@ -5603,7 +5592,6 @@
     return(NULL);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_sec_find_next_serv
@@ -5633,7 +5621,6 @@
     return(NULL);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_sec_find_mx_serv
@@ -5676,7 +5663,6 @@
     return(NULL);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_sec_collision_timeout
@@ -5768,7 +5754,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_sec_find_dev_by_sec_state
@@ -5837,7 +5822,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btm_pair_state_descr
@@ -6070,7 +6054,6 @@
     BTM_TRACE_API("%s: sm4: 0x%02x, rmt_support_for_secure_connections %d", __FUNCTION__,
                   p_dev_rec->sm4, p_dev_rec->remote_supports_secure_connections);
 
-
     if (p_dev_rec->remote_features_needed)
     {
         BTM_TRACE_EVENT("%s: Now device in SC Only mode, waiting for peer remote features!",
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c
index 163687a..426749a 100644
--- a/stack/btu/btu_hcif.c
+++ b/stack/btu/btu_hcif.c
@@ -28,22 +28,22 @@
 #define LOG_TAG "bt_btu_hcif"
 
 #include <assert.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdio.h>
 
-#include "gki.h"
 #include "bt_types.h"
-#include "hcimsgs.h"
-#include "btu.h"
-#include "l2c_int.h"
+#include "bt_utils.h"
 #include "btm_api.h"
 #include "btm_int.h"
-#include "bt_utils.h"
+#include "btu.h"
 #include "device/include/controller.h"
+#include "gki.h"
+#include "hci_layer.h"
+#include "hcimsgs.h"
+#include "l2c_int.h"
 #include "osi.h"
 #include "osi/include/log.h"
-#include "hci_layer.h"
 
 // TODO(zachoverflow): remove this horrible hack
 #include "btu.h"
@@ -346,7 +346,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_send_cmd
@@ -389,7 +388,6 @@
 #endif
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_send_host_rdy_for_data
@@ -438,7 +436,6 @@
     btm_process_inq_complete(status, BTM_BR_INQUIRY_MASK);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_inquiry_result_evt
@@ -529,7 +526,6 @@
 #endif /* BTM_SCO_INCLUDED */
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_connection_request_evt
@@ -563,7 +559,6 @@
 #endif /* BTM_SCO_INCLUDED */
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_disconnection_comp_evt
@@ -616,7 +611,6 @@
     btm_sec_auth_complete (handle, status);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_rmt_name_request_comp_evt
@@ -641,7 +635,6 @@
     btm_sec_rmt_name_request_complete (bd_addr, p, status);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_encryption_change_evt
@@ -719,7 +712,6 @@
     btm_read_remote_version_complete (p);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_qos_setup_comp_evt
@@ -747,7 +739,6 @@
     btm_qos_setup_complete(status, handle, &flow);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_esco_connection_comp_evt
@@ -781,7 +772,6 @@
 #endif
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_esco_connection_chg_evt
@@ -866,7 +856,6 @@
 #endif
             break;
 
-
         case HCI_READ_INQ_TX_POWER_LEVEL:
             btm_read_linq_tx_power_complete (p);
             break;
@@ -980,7 +969,6 @@
     fixed_queue_enqueue(btu_hci_msg_queue, event);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_hdl_command_status
@@ -1200,7 +1188,6 @@
         BTM_DeviceReset (NULL);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_flush_occured_evt
@@ -1214,7 +1201,6 @@
 {
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_role_change_evt
@@ -1238,7 +1224,6 @@
     btm_acl_role_changed(status, bda, role);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_num_compl_data_pkts_evt
@@ -1326,7 +1311,6 @@
     btm_sec_pin_code_request (bda);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_link_key_request_evt
@@ -1344,7 +1328,6 @@
     btm_sec_link_key_request (bda);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_link_key_notification_evt
@@ -1367,7 +1350,6 @@
     btm_sec_link_key_notification (bda, key, key_type);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_loopback_command_evt
@@ -1381,7 +1363,6 @@
 {
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_data_buf_overflow_evt
@@ -1395,7 +1376,6 @@
 {
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_max_slots_changed_evt
@@ -1409,7 +1389,6 @@
 {
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_read_clock_off_comp_evt
@@ -1440,7 +1419,6 @@
     btm_sec_update_clock_offset (handle, clock_offset);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_conn_pkt_type_change_evt
@@ -1454,7 +1432,6 @@
 {
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_qos_violation_evt
@@ -1472,11 +1449,9 @@
 
     handle = HCID_GET_HANDLE (handle);
 
-
     l2c_link_hci_qos_violation (handle);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_page_scan_mode_change_evt
@@ -1490,7 +1465,6 @@
 {
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_page_scan_rep_mode_chng_evt
@@ -1536,7 +1510,6 @@
     btm_io_capabilities_req(p);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_io_cap_response_evt
@@ -1551,7 +1524,6 @@
     btm_io_capabilities_rsp(p);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_user_conf_request_evt
@@ -1566,7 +1538,6 @@
     btm_proc_sp_req_evt(BTM_SP_CFM_REQ_EVT, p);
 }
 
-
 /*******************************************************************************
 **
 ** Function         btu_hcif_user_passkey_request_evt
@@ -1658,7 +1629,6 @@
 ** End of Simple Pairing Events
 ***********************************************/
 
-
 /**********************************************
 ** BLE Events
 ***********************************************/
diff --git a/stack/btu/btu_init.c b/stack/btu/btu_init.c
index cb7ad50..8e50b65 100644
--- a/stack/btu/btu_init.c
+++ b/stack/btu/btu_init.c
@@ -19,23 +19,22 @@
 #define LOG_TAG "bt_task"
 
 #include <assert.h>
-
-#include "bt_target.h"
 #include <pthread.h>
 #include <string.h>
-#include "dyn_mem.h"
 
-#include "osi/include/alarm.h"
-#include "device/include/controller.h"
-#include "osi/include/fixed_queue.h"
-#include "osi/include/hash_map.h"
-#include "btu.h"
+#include "bt_target.h"
 #include "btm_int.h"
-#include "osi/include/hash_functions.h"
-#include "sdpint.h"
-#include "osi/include/thread.h"
+#include "btu.h"
+#include "device/include/controller.h"
+#include "dyn_mem.h"
 #include "l2c_int.h"
+#include "osi/include/alarm.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/hash_functions.h"
+#include "osi/include/hash_map.h"
 #include "osi/include/log.h"
+#include "osi/include/thread.h"
+#include "sdpint.h"
 
 #if (BLE_INCLUDED == TRUE)
 #include "gatt_api.h"
diff --git a/stack/btu/btu_task.c b/stack/btu/btu_task.c
index 982f5df..a7861c7 100644
--- a/stack/btu/btu_task.c
+++ b/stack/btu/btu_task.c
@@ -20,35 +20,33 @@
 
 #include <assert.h>
 #include <pthread.h>
-#include <stdlib.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
-#include "osi/include/alarm.h"
 #include "bt_target.h"
 #include "bt_trace.h"
 #include "bt_types.h"
 #include "bt_utils.h"
+#include "btcore/include/module.h"
 #include "btif_common.h"
 #include "btm_api.h"
 #include "btm_int.h"
 #include "btu.h"
-#include "osi/include/fixed_queue.h"
-#include "osi/include/future.h"
+#include "gap_int.h"
 #include "gki.h"
-#include "osi/include/hash_map.h"
 #include "hcimsgs.h"
 #include "l2c_int.h"
-#include "btcore/include/module.h"
-#include "osi/include/osi.h"
+#include "osi/include/alarm.h"
+#include "osi/include/fixed_queue.h"
+#include "osi/include/future.h"
+#include "osi/include/hash_map.h"
 #include "osi/include/log.h"
-#include "sdpint.h"
+#include "osi/include/osi.h"
 #include "osi/include/thread.h"
-
 #include "port_api.h"
 #include "port_ext.h"
-
-#include "gap_int.h"
+#include "sdpint.h"
 
 #if (defined(BNEP_INCLUDED) && BNEP_INCLUDED == TRUE)
 #include "bnep_int.h"
@@ -373,7 +371,6 @@
             break;
 #endif
 
-
 #if (defined(AVDT_INCLUDED) && AVDT_INCLUDED == TRUE)
         case BTU_TTYPE_AVDT_CCB_RET:
         case BTU_TTYPE_AVDT_CCB_RSP:
diff --git a/stack/include/avrc_defs.h b/stack/include/avrc_defs.h
index d6ff8a0..e3e7f6e 100644
--- a/stack/include/avrc_defs.h
+++ b/stack/include/avrc_defs.h
@@ -24,6 +24,8 @@
 #ifndef _AVRC_DEFS_H
 #define _AVRC_DEFS_H
 
+#include "stack/include/bt_types.h"
+
 /*****************************************************************************
 **  constants
 *****************************************************************************/
@@ -248,7 +250,6 @@
 #define AVRC_STS_ADDR_PLAYER_CHG 0x16   /* Addressed Player Changed - Register Notification */
 typedef UINT8 tAVRC_STS;
 
-
 /* Define the Capability IDs
 */
 #define AVRC_CAP_COMPANY_ID                     0x02
@@ -864,7 +865,6 @@
 #define AVRC_MAX_CHARSET_SIZE       16
 #define AVRC_MAX_ELEM_ATTR_SIZE     8
 
-
 /*****************************************************************************
 **  Metadata transfer Building/Parsing definitions
 *****************************************************************************/
@@ -880,7 +880,6 @@
     UINT8               *p_str;
 } tAVRC_NAME;
 
-
 #ifndef AVRC_CAP_MAX_NUM_COMP_ID
 #define AVRC_CAP_MAX_NUM_COMP_ID    4
 #endif
@@ -1375,7 +1374,6 @@
     UINT32              num_items;
 } tAVRC_SEARCH_RSP;
 
-
 typedef struct
 {
     UINT8       pdu;
@@ -1413,5 +1411,4 @@
     tAVRC_RSP                       add_to_play;            /* AddToNowPlaying */
 } tAVRC_RESPONSE;
 
-
 #endif
diff --git a/stack/l2cap/l2c_api.c b/stack/l2cap/l2c_api.c
index 3c95af7..abfbc2b 100644
--- a/stack/l2cap/l2c_api.c
+++ b/stack/l2cap/l2c_api.c
@@ -25,19 +25,19 @@
 #define LOG_TAG "bt_l2cap"
 
 #include <assert.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdio.h>
 
-#include "gki.h"
 #include "bt_types.h"
 #include "btcore/include/counter.h"
+#include "btm_api.h"
+#include "btu.h"
+#include "gki.h"
 #include "hcidefs.h"
 #include "hcimsgs.h"
-#include "l2cdefs.h"
 #include "l2c_int.h"
-#include "btu.h"
-#include "btm_api.h"
+#include "l2cdefs.h"
 #include "osi/include/allocator.h"
 #include "osi/include/log.h"
 
@@ -112,8 +112,6 @@
     return (vpsm);
 }
 
-
-
 /*******************************************************************************
 **
 ** Function         L2CA_Deregister
@@ -389,7 +387,6 @@
     return L2CA_ErtmConnectRsp (p_bd_addr, id, lcid, result, status, NULL);
 }
 
-
 /*******************************************************************************
 **
 ** Function         L2CA_ErtmConnectRsp
@@ -475,7 +472,6 @@
     return (TRUE);
 }
 
-
 /*******************************************************************************
 **
 ** Function         L2CA_ConfigReq
@@ -528,7 +524,6 @@
     return (TRUE);
 }
 
-
 /*******************************************************************************
 **
 ** Function         L2CA_ConfigRsp
@@ -574,7 +569,6 @@
     return (TRUE);
 }
 
-
 /*******************************************************************************
 **
 ** Function         L2CA_DisconnectReq
@@ -888,7 +882,6 @@
     return (l2cb.l2cap_trace_level);
 }
 
-
 /*******************************************************************************
 **
 ** Function     L2CA_SetDesireRole
@@ -1084,7 +1077,6 @@
     return (TRUE);
 }
 
-
 /*******************************************************************************
 **
 ** Function         L2CA_SetTxPriority
diff --git a/stack/l2cap/l2c_main.c b/stack/l2cap/l2c_main.c
index f719527..047815a 100644
--- a/stack/l2cap/l2c_main.c
+++ b/stack/l2cap/l2c_main.c
@@ -22,7 +22,7 @@
  *
  ******************************************************************************/
 
-#define LOG_TAG "l2c_main"
+#define LOG_TAG "bt_l2c_main"
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -110,7 +110,6 @@
     }
 }
 
-
 /*******************************************************************************
 **
 ** Function         l2c_rcv_acl_data
@@ -680,7 +679,6 @@
             }
             break;
 
-
         case L2CAP_CMD_DISC_REQ:
             STREAM_TO_UINT16 (lcid, p);
             STREAM_TO_UINT16 (rcid, p);
@@ -763,7 +761,6 @@
 #endif
             }
 
-
 #if (L2CAP_NUM_FIXED_CHNLS > 0)
             if (info_type == L2CAP_FIXED_CHANNELS_INFO_TYPE)
             {
@@ -839,7 +836,6 @@
         btu_start_timer (&l2cb.rcv_hold_tle, BTU_TTYPE_L2CAP_HOLD, BT_1SEC_TIMEOUT);
 }
 
-
 /*******************************************************************************
 **
 ** Function         l2c_init
@@ -869,7 +865,6 @@
     l2cb.non_flushable_pbf = L2CAP_PKT_START << L2CAP_PKT_TYPE_SHIFT;
 #endif
 
-
     l2cb.p_free_ccb_first = &l2cb.ccb_pool[0];
     l2cb.p_free_ccb_last  = &l2cb.ccb_pool[MAX_L2CAP_CHANNELS - 1];
 
diff --git a/stack/l2cap/l2cap_client.c b/stack/l2cap/l2cap_client.c
index 0b2f0ed..af7990b 100644
--- a/stack/l2cap/l2cap_client.c
+++ b/stack/l2cap/l2cap_client.c
@@ -18,6 +18,8 @@
 
 #define LOG_TAG "bt_l2cap_client"
 
+#include "stack/include/l2cap_client.h"
+
 #include <assert.h>
 #include <string.h>
 
@@ -28,7 +30,6 @@
 #include "osi/include/list.h"
 #include "osi/include/log.h"
 #include "osi/include/osi.h"
-#include "stack/include/l2cap_client.h"
 #include "stack/include/l2c_api.h"
 
 struct l2cap_client_t {
diff --git a/stack/rfcomm/port_api.c b/stack/rfcomm/port_api.c
index bb05018..5fa5013 100644
--- a/stack/rfcomm/port_api.c
+++ b/stack/rfcomm/port_api.c
@@ -22,21 +22,22 @@
  *
  ******************************************************************************/
 
-#define LOG_TAG "port_api"
+#define LOG_TAG "bt_port_api"
+
+#include "port_api.h"
 
 #include <string.h>
-#include "bt_target.h"
+
 #include "btcore/include/counter.h"
-#include "gki.h"
-#include "rfcdefs.h"
-#include "port_api.h"
-#include "port_int.h"
-#include "btm_int.h"
 #include "btm_api.h"
-#include "rfc_int.h"
+#include "btm_int.h"
+#include "gki.h"
 #include "l2c_api.h"
-#include "sdp_api.h"
 #include "osi/include/log.h"
+#include "port_int.h"
+#include "rfc_int.h"
+#include "rfcdefs.h"
+#include "sdp_api.h"
 
 /* duration of break in 200ms units */
 #define PORT_BREAK_DURATION     1
@@ -231,7 +232,6 @@
     return port_open_continue (p_port);
 }
 
-
 /*******************************************************************************
 **
 ** Function         RFCOMM_RemoveConnection
@@ -447,8 +447,6 @@
     return (PORT_SUCCESS);
 }
 
-
-
 /*******************************************************************************
 **
 ** Function         PORT_SetEventMask
@@ -483,7 +481,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_CheckConnection
@@ -719,7 +716,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_Control
@@ -805,7 +801,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_FlowControl
@@ -963,7 +958,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_GetModemStatus
@@ -1000,7 +994,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_ClearError
@@ -1045,7 +1038,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_SendError
@@ -1083,7 +1075,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_GetQueueStatus
@@ -1132,7 +1123,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_Purge
@@ -1208,7 +1198,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_ReadData
@@ -1316,7 +1305,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_Read
@@ -1374,7 +1362,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         port_write
@@ -1630,7 +1617,6 @@
             return (PORT_UNKNOWN_ERROR);
         }
 
-
         RFCOMM_TRACE_EVENT ("PORT_WriteData %d bytes", length);
 
         rc = port_write (p_port, p_buf);
@@ -1660,8 +1646,6 @@
     return (PORT_SUCCESS);
 }
 
-
-
 /*******************************************************************************
 **
 ** Function         PORT_WriteData
@@ -1786,7 +1770,6 @@
     return (PORT_SUCCESS);
 }
 
-
 /*******************************************************************************
 **
 ** Function         PORT_Test
diff --git a/stack/srvc/srvc_dis.c b/stack/srvc/srvc_dis.c
index 788051e..8cfbd70 100644
--- a/stack/srvc/srvc_dis.c
+++ b/stack/srvc/srvc_dis.c
@@ -16,15 +16,15 @@
  *
  ******************************************************************************/
 
+#define LOG_TAG "bt_srvc"
+
 #include "bt_target.h"
 #include "bt_utils.h"
 #include "gatt_api.h"
 #include "gatt_int.h"
-#include "srvc_eng_int.h"
-#include "srvc_dis_int.h"
-
-#define LOG_TAG "bt_srvc"
 #include "osi/include/log.h"
+#include "srvc_dis_int.h"
+#include "srvc_eng_int.h"
 
 #if BLE_INCLUDED == TRUE
 
@@ -42,8 +42,6 @@
 #define STREAM_TO_UINT64(u64, p) {u64 = (((UINT64)(*(p))) + ((((UINT64)(*((p) + 1)))) << 8) + ((((UINT64)(*((p) + 2)))) << 16) + ((((UINT64)(*((p) + 3)))) << 24) \
                                   + ((((UINT64)(*((p) + 4)))) << 32) + ((((UINT64)(*((p) + 5)))) << 40) + ((((UINT64)(*((p) + 6)))) << 48) + ((((UINT64)(*((p) + 7)))) << 56)); (p) += 8;}
 
-
-
 static const UINT16  dis_attr_uuid[DIS_MAX_CHAR_NUM] =
 {
     GATT_UUID_SYSTEM_ID,
@@ -169,7 +167,6 @@
                     }
                     break;
 
-
                 case GATT_UUID_SYSTEM_ID:
                     UINT64_TO_STREAM(p, dis_cb.dis_value.system_id); /* int_min */
                     p_value->len = DIS_SYSTEM_ID_SIZE;
@@ -339,7 +336,6 @@
     dis_gatt_c_read_dis_req(conn_id);
 }
 
-
 /*******************************************************************************
 **
 ** Function         DIS_SrInit
@@ -478,7 +474,6 @@
                       (peer_bda[0]<<24)+(peer_bda[1]<<16)+(peer_bda[2]<<8)+peer_bda[3],
                       (peer_bda[4]<<8)+peer_bda[5], dis_attr_uuid[dis_cb.dis_read_uuid_idx]);
 
-
     GATT_GetConnIdIfConnected(srvc_eng_cb.gatt_if, peer_bda, &conn_id, BT_TRANSPORT_LE);
 
     /* need to enhance it as multiple service is needed */
@@ -494,4 +489,3 @@
 }
 #endif  /* BLE_INCLUDED */
 
-
diff --git a/stack/srvc/srvc_dis_int.h b/stack/srvc/srvc_dis_int.h
index 7457319..67a6468 100644
--- a/stack/srvc/srvc_dis_int.h
+++ b/stack/srvc/srvc_dis_int.h
@@ -20,12 +20,12 @@
 #define SRVC_DIS_INT_H
 
 #include "bt_target.h"
-#include "srvc_api.h"
 #include "gatt_api.h"
+#include "srvc_api.h"
+#include "srvc_eng_int.h"
 
 #define DIS_MAX_CHAR_NUM            9
 
-
 typedef struct
 {
     UINT16      uuid;
@@ -35,8 +35,6 @@
 #define DIS_SYSTEM_ID_SIZE      8
 #define DIS_PNP_ID_SIZE         7
 
-
-
 typedef struct
 {
     tDIS_DB_ENTRY           dis_attr[DIS_MAX_CHAR_NUM];
@@ -54,8 +52,6 @@
     tDIS_ATTR_MASK          request_mask;
 }tDIS_CB;
 
-
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -68,7 +64,6 @@
 #define dis_cb (*dis_cb_ptr)
 #endif
 
-
 extern BOOLEAN dis_valid_handle_range(UINT16 handle);
 extern UINT8 dis_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value,
                            BOOLEAN is_long, tGATT_STATUS *p_status);
@@ -77,7 +72,6 @@
 extern void dis_c_cmpl_cback (tSRVC_CLCB *p_clcb, tGATTC_OPTYPE op,
                                     tGATT_STATUS status, tGATT_CL_COMPLETE *p_data);
 
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/utils/src/bt_utils.c b/utils/src/bt_utils.c
index d2962c9..69106a1 100644
--- a/utils/src/bt_utils.c
+++ b/utils/src/bt_utils.c
@@ -27,6 +27,18 @@
 
 #define LOG_TAG "bt_utils"
 
+#include "bt_utils.h"
+
+#include <errno.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+#include <utils/ThreadDefs.h>
+#include <cutils/sched_policy.h>
+
 // TODO(armansito): cutils/properties.h is only being used to pull-in runtime
 // settings on Android. Remove this conditional include once we have a generic
 // way to obtain system properties.
@@ -34,17 +46,7 @@
 #include <cutils/properties.h>
 #endif  // !defined(OS_GENERIC)
 
-#include <cutils/sched_policy.h>
-#include <errno.h>
-#include <pthread.h>
-#include <sys/resource.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <utils/ThreadDefs.h>
-
 #include "bt_types.h"
-#include "bt_utils.h"
 #include "btcore/include/module.h"
 #include "osi/include/compat.h"
 #include "osi/include/log.h"