You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/04/12 07:26:49 UTC

[2/4] incubator-mynewt-core git commit: Remove space at end of line

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_ctrl.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_ctrl.c b/net/nimble/controller/src/ble_ll_ctrl.c
index b07a32f..a7c2cd9 100644
--- a/net/nimble/controller/src/ble_ll_ctrl.c
+++ b/net/nimble/controller/src/ble_ll_ctrl.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -27,7 +27,7 @@
 #include "controller/ble_ll_ctrl.h"
 #include "ble_ll_conn_priv.h"
 
-/* 
+/*
  * XXX: TODO
  *  1) Do I need to keep track of which procedures have already been done?
  *     Do I need to worry about repeating procedures?
@@ -52,7 +52,7 @@
  *  slave supports that feature
  */
 
-/* 
+/*
  * XXX: I definitely have an issue with control procedures and connection
  * param request procedure and connection update procedure. This was
  * noted when receiving an unknown response. Right now, I am getting confused
@@ -62,7 +62,7 @@
  * the correct thing.
  */
 
-/* 
+/*
  * This array contains the length of the CtrData field in LL control PDU's.
  * Note that there is a one byte opcode which precedes this field in the LL
  * control PDU, so total data channel payload length for the control pdu is
@@ -78,7 +78,7 @@ ble_ll_ctrl_chk_supp_bytes(uint16_t bytes)
 {
     int rc;
 
-    if ((bytes < BLE_LL_CONN_SUPP_BYTES_MIN) || 
+    if ((bytes < BLE_LL_CONN_SUPP_BYTES_MIN) ||
         (bytes > BLE_LL_CONN_SUPP_BYTES_MAX)) {
         rc = 0;
     } else {
@@ -109,7 +109,7 @@ ble_ll_ctrl_len_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
     struct ble_ll_len_req ctrl_req;
 
     /* Extract parameters and check if valid */
-    ctrl_req.max_rx_bytes = le16toh(dptr); 
+    ctrl_req.max_rx_bytes = le16toh(dptr);
     ctrl_req.max_rx_time = le16toh(dptr + 2);
     ctrl_req.max_tx_bytes = le16toh(dptr + 4);
     ctrl_req.max_tx_time = le16toh(dptr + 6);
@@ -129,14 +129,14 @@ ble_ll_ctrl_len_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
 }
 
 /**
- * Called when we receive either a connection parameter request or response. 
- * 
- * @param connsm 
- * @param dptr 
- * @param rspbuf 
- * @param opcode 
- * 
- * @return int 
+ * Called when we receive either a connection parameter request or response.
+ *
+ * @param connsm
+ * @param dptr
+ * @param rspbuf
+ * @param opcode
+ *
+ * @return int
  */
 static int
 ble_ll_ctrl_conn_param_pdu_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
@@ -166,21 +166,21 @@ ble_ll_ctrl_conn_param_pdu_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 
     /* Check if parameters are valid */
     ble_err = BLE_ERR_SUCCESS;
-    rc = ble_ll_conn_hci_chk_conn_params(req->interval_min, 
+    rc = ble_ll_conn_hci_chk_conn_params(req->interval_min,
                                          req->interval_max,
-                                         req->latency, 
+                                         req->latency,
                                          req->timeout);
     if (rc) {
         ble_err = BLE_ERR_INV_LMP_LL_PARM;
         goto conn_param_pdu_exit;
     }
 
-    /* 
+    /*
      * Check if there is a requested change to either the interval, timeout
      * or latency. If not, this may just be an anchor point change and we do
      * not have to notify the host.
      *  XXX: what if we dont like the parameters? When do we check that out?
-     */ 
+     */
     indicate = 1;
     if (opcode == BLE_LL_CTRL_CONN_PARM_REQ) {
         if ((connsm->conn_itvl >= req->interval_min) &&
@@ -192,17 +192,17 @@ ble_ll_ctrl_conn_param_pdu_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
         }
     }
 
-    /* 
+    /*
      * A change has been requested. Is it within the values specified by
      * the host? Note that for a master we will not be processing a
      * connect param request from a slave if we are currently trying to
      * update the connection parameters. This means that the previous
      * check is all we need for a master (when receiving a request).
      */
-    if ((connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) || 
+    if ((connsm->conn_role == BLE_LL_CONN_ROLE_SLAVE) ||
         (opcode == BLE_LL_CTRL_CONN_PARM_RSP)) {
-        /* 
-         * Not sure what to do about the slave. It is possible that the 
+        /*
+         * Not sure what to do about the slave. It is possible that the
          * current connection parameters are not the same ones as the local host
          * has provided? Not sure what to do here. Do we need to remember what
          * host sent us? For now, I will assume that we need to remember what
@@ -222,15 +222,15 @@ ble_ll_ctrl_conn_param_pdu_proc(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
     }
 
 conn_parm_req_do_indicate:
-    /* 
+    /*
      * XXX: are the connection update parameters acceptable? If not, we will
      * need to know before we indicate to the host that they are acceptable.
-     */ 
+     */
     if (indicate) {
-        /* 
+        /*
          * Send event to host. At this point we leave and wait to get
          * an answer.
-         */ 
+         */
         /* XXX: what about masked out event? */
         ble_ll_hci_ev_rem_conn_parm_req(connsm, req);
         connsm->host_reply_opcode = opcode;
@@ -252,10 +252,10 @@ conn_param_pdu_exit:
 
 /**
  * Called to process and UNKNOWN_RSP LL control packet.
- * 
- * Context: Link Layer Task 
- *  
- * @param dptr 
+ *
+ * Context: Link Layer Task
+ *
+ * @param dptr
  */
 static void
 ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
@@ -303,12 +303,12 @@ ble_ll_ctrl_proc_unk_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
 }
 
 /**
- * Create a link layer length request or length response PDU. 
- *  
- * NOTE: this function does not set the LL data pdu header nor does it 
- * set the opcode in the buffer. 
- * 
- * @param connsm 
+ * Create a link layer length request or length response PDU.
+ *
+ * NOTE: this function does not set the LL data pdu header nor does it
+ * set the opcode in the buffer.
+ *
+ * @param connsm
  * @param dptr: Pointer to where control pdu payload starts
  */
 static void
@@ -322,10 +322,10 @@ ble_ll_ctrl_datalen_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
 
 /**
  * Called to make a connection parameter request or response control pdu.
- * 
- * @param connsm 
- * @param dptr Pointer to start of data. NOTE: the opcode is not part 
- *             of the data. 
+ *
+ * @param connsm
+ * @param dptr Pointer to start of data. NOTE: the opcode is not part
+ *             of the data.
  */
 static void
 ble_ll_ctrl_conn_param_pdu_make(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
@@ -385,7 +385,7 @@ ble_ll_ctrl_version_ind_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
 
 /**
  * Called to make a LL control channel map request PDU.
- * 
+ *
  * @param connsm    Pointer to connection state machine
  * @param pyld      Pointer to payload of LL control PDU
  */
@@ -406,11 +406,11 @@ ble_ll_ctrl_chanmap_req_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld)
 
 /**
  * Called to make a connection update request LL control PDU
- *  
- * Context: Link Layer 
- * 
- * @param connsm 
- * @param rsp 
+ *
+ * Context: Link Layer
+ *
+ * @param connsm
+ * @param rsp
  */
 static void
 ble_ll_ctrl_conn_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld,
@@ -424,16 +424,16 @@ ble_ll_ctrl_conn_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld,
     struct hci_conn_update *hcu;
     struct ble_ll_conn_upd_req *req;
 
-    /* 
+    /*
      * Set instant. We set the instant to the current event counter plus
      * the amount of slave latency as the slave may not be listening
      * at every connection interval and we are not sure when the connect
      * request will actually get sent. We add one more event plus the
      * minimum as per the spec of 6 connection events.
-     */ 
+     */
     instant = connsm->event_cntr + connsm->slave_latency + 6 + 1;
 
-    /* 
+    /*
      * XXX: This should change in the future, but for now we will just
      * start the new instant at the same anchor using win offset 0.
      */
@@ -490,14 +490,14 @@ ble_ll_ctrl_conn_upd_make(struct ble_ll_conn_sm *connsm, uint8_t *pyld,
 }
 
 /**
- * Called to respond to a LL control PDU connection parameter request or 
- * response. 
- * 
- * @param connsm 
- * @param rsp 
- * @param req 
- * 
- * @return uint8_t 
+ * Called to respond to a LL control PDU connection parameter request or
+ * response.
+ *
+ * @param connsm
+ * @param rsp
+ * @param req
+ *
+ * @return uint8_t
  */
 uint8_t
 ble_ll_ctrl_conn_param_reply(struct ble_ll_conn_sm *connsm, uint8_t *rsp,
@@ -520,12 +520,12 @@ ble_ll_ctrl_conn_param_reply(struct ble_ll_conn_sm *connsm, uint8_t *rsp,
 
 /**
  * Called when we receive a connection update event
- * 
- * @param connsm 
- * @param dptr 
- * @param rspbuf 
- * 
- * @return int 
+ *
+ * @param connsm
+ * @param dptr
+ * @param rspbuf
+ *
+ * @return int
  */
 static int
 ble_ll_ctrl_rx_conn_update(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
@@ -542,7 +542,7 @@ ble_ll_ctrl_rx_conn_update(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 
     /* Retrieve parameters */
     reqdata = &connsm->conn_update_req;
-    reqdata->winsize = dptr[0]; 
+    reqdata->winsize = dptr[0];
     reqdata->winoffset = le16toh(dptr + 1);
     reqdata->interval = le16toh(dptr + 3);
     reqdata->latency = le16toh(dptr + 5);
@@ -565,16 +565,16 @@ ble_ll_ctrl_rx_conn_update(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 }
 
 /**
- * Called when we receive a feature request or a slave initiated feature 
- * request. 
- * 
- * 
- * @param connsm 
- * @param dptr 
- * @param rspbuf 
+ * Called when we receive a feature request or a slave initiated feature
+ * request.
+ *
+ *
+ * @param connsm
+ * @param dptr
+ * @param rspbuf
  * @param opcode
- * 
- * @return int 
+ *
+ * @return int
  */
 static int
 ble_ll_ctrl_rx_feature_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
@@ -582,7 +582,7 @@ ble_ll_ctrl_rx_feature_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 {
     uint8_t rsp_opcode;
 
-    /* 
+    /*
      * Only accept slave feature requests if we are a master and feature
      * requests if we are a slave.
      */
@@ -607,15 +607,15 @@ ble_ll_ctrl_rx_feature_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 }
 
 /**
- * 
- * 
- * Context: Link Layer task 
- *  
- * @param connsm 
- * @param dptr 
- * @param rspbuf 
- * 
- * @return int 
+ *
+ *
+ * Context: Link Layer task
+ *
+ * @param connsm
+ * @param dptr
+ * @param rspbuf
+ *
+ * @return int
  */
 static int
 ble_ll_ctrl_rx_conn_param_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
@@ -623,7 +623,7 @@ ble_ll_ctrl_rx_conn_param_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 {
     uint8_t rsp_opcode;
 
-    /* 
+    /*
      * This is not in the specification per se but it simplifies the
      * implementation. If we get a connection parameter request and we
      * are awaiting a reply from the host, simply ignore the request. This
@@ -649,7 +649,7 @@ ble_ll_ctrl_rx_conn_param_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
      * and we receive a request we "consider the slave initiated
      * procedure as complete". This means send a connection update complete
      * event (with error).
-     * 
+     *
      * If a master, we send reject with a
      * transaction collision error code.
      */
@@ -666,10 +666,10 @@ ble_ll_ctrl_rx_conn_param_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
         }
     }
 
-    /* 
+    /*
      * If we are a master and we currently performing a channel map
      * update procedure we need to return an error
-     */ 
+     */
     if ((connsm->conn_role == BLE_LL_CONN_ROLE_MASTER) &&
         (connsm->csmflags.cfbit.chanmap_update_scheduled)) {
         rsp_opcode = BLE_LL_CTRL_REJECT_IND_EXT;
@@ -695,12 +695,12 @@ ble_ll_ctrl_rx_conn_param_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
         return BLE_ERR_MAX;
     }
 
-    /* 
+    /*
      * This case should never happen! It means that the slave initiated a
      * procedure and the master initiated one as well. If we do get in this
      * state just clear the awaiting reply. The slave will hopefully stop its
      * procedure when we reply.
-     */ 
+     */
     if (connsm->csmflags.cfbit.awaiting_host_reply) {
         connsm->csmflags.cfbit.awaiting_host_reply = 0;
     }
@@ -718,17 +718,17 @@ ble_ll_ctrl_rx_conn_param_rsp(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 
 /**
  * Called to process the LL control PDU VERSION_IND
- *  
- * Context: Link Layer task 
- * 
- * @param connsm 
- * @param dptr 
- * @param rspbuf 
- * 
- * @return int 
+ *
+ * Context: Link Layer task
+ *
+ * @param connsm
+ * @param dptr
+ * @param rspbuf
+ *
+ * @return int
  */
 static int
-ble_ll_ctrl_rx_version_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr, 
+ble_ll_ctrl_rx_version_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
                            uint8_t *rspbuf)
 {
     uint8_t rsp_opcode;
@@ -754,12 +754,12 @@ ble_ll_ctrl_rx_version_ind(struct ble_ll_conn_sm *connsm, uint8_t *dptr,
 }
 
 /**
- * Called to process a received channel map request control pdu. 
- *  
- * Context: Link Layer task 
- * 
- * @param connsm 
- * @param dptr 
+ * Called to process a received channel map request control pdu.
+ *
+ * Context: Link Layer task
+ *
+ * @param connsm
+ * @param dptr
  */
 static void
 ble_ll_ctrl_rx_chanmap_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
@@ -782,12 +782,12 @@ ble_ll_ctrl_rx_chanmap_req(struct ble_ll_conn_sm *connsm, uint8_t *dptr)
 }
 
 /**
- * Callback when LL control procedure times out (for a given connection). If 
- * this is called, it means that we need to end the connection because it 
- * has not responded to a LL control request. 
- *  
- * Context: Link Layer 
- * 
+ * Callback when LL control procedure times out (for a given connection). If
+ * this is called, it means that we need to end the connection because it
+ * has not responded to a LL control request.
+ *
+ * Context: Link Layer
+ *
  * @param arg Pointer to connection state machine.
  */
 void
@@ -798,16 +798,16 @@ ble_ll_ctrl_proc_rsp_timer_cb(void *arg)
 }
 
 /**
- * Initiate LL control procedure. 
- *  
- * This function is called to obtain a mbuf to send a LL control PDU. The data 
- * channel PDU header is not part of the mbuf data; it is part of the BLE 
- * header (which is part of the mbuf). 
- *  
- * Context: LL task. 
- * 
- * @param connsm 
- * @param ctrl_proc 
+ * Initiate LL control procedure.
+ *
+ * This function is called to obtain a mbuf to send a LL control PDU. The data
+ * channel PDU header is not part of the mbuf data; it is part of the BLE
+ * header (which is part of the mbuf).
+ *
+ * Context: LL task.
+ *
+ * @param connsm
+ * @param ctrl_proc
  */
 static struct os_mbuf *
 ble_ll_ctrl_proc_init(struct ble_ll_conn_sm *connsm, int ctrl_proc)
@@ -873,12 +873,12 @@ ble_ll_ctrl_proc_init(struct ble_ll_conn_sm *connsm, int ctrl_proc)
 }
 
 /**
- * Called to determine if the pdu is a TERMINATE_IND 
- * 
- * @param hdr 
- * @param opcode 
- * 
- * @return int 
+ * Called to determine if the pdu is a TERMINATE_IND
+ *
+ * @param hdr
+ * @param opcode
+ *
+ * @return int
  */
 int
 ble_ll_ctrl_is_terminate_ind(uint8_t hdr, uint8_t opcode)
@@ -895,12 +895,12 @@ ble_ll_ctrl_is_terminate_ind(uint8_t hdr, uint8_t opcode)
 }
 
 /**
- * Called to determine if the pdu is a TERMINATE_IND 
- * 
- * @param hdr 
- * @param opcode 
- * 
- * @return int 
+ * Called to determine if the pdu is a TERMINATE_IND
+ *
+ * @param hdr
+ * @param opcode
+ *
+ * @return int
  */
 int
 ble_ll_ctrl_is_reject_ind_ext(uint8_t hdr, uint8_t opcode)
@@ -918,12 +918,12 @@ ble_ll_ctrl_is_reject_ind_ext(uint8_t hdr, uint8_t opcode)
 
 
 /**
- * Stops the LL control procedure indicated by 'ctrl_proc'. 
- *  
- * Context: Link Layer task 
- * 
- * @param connsm 
- * @param ctrl_proc 
+ * Stops the LL control procedure indicated by 'ctrl_proc'.
+ *
+ * Context: Link Layer task
+ *
+ * @param connsm
+ * @param ctrl_proc
  */
 void
 ble_ll_ctrl_proc_stop(struct ble_ll_conn_sm *connsm, int ctrl_proc)
@@ -939,11 +939,11 @@ ble_ll_ctrl_proc_stop(struct ble_ll_conn_sm *connsm, int ctrl_proc)
 }
 
 /**
- * Called to start the terminate procedure. 
- *  
- * Context: Link Layer task. 
- *  
- * @param connsm 
+ * Called to start the terminate procedure.
+ *
+ * Context: Link Layer task.
+ *
+ * @param connsm
  */
 void
 ble_ll_ctrl_terminate_start(struct ble_ll_conn_sm *connsm)
@@ -961,7 +961,7 @@ ble_ll_ctrl_terminate_start(struct ble_ll_conn_sm *connsm)
 
         /* Set terminate "timeout" */
         usecs = connsm->supervision_tmo * BLE_HCI_CONN_SPVN_TMO_UNITS * 1000;
-        connsm->terminate_timeout = cputime_get32() + 
+        connsm->terminate_timeout = cputime_get32() +
             cputime_usecs_to_ticks(usecs);
     }
 }
@@ -969,10 +969,10 @@ ble_ll_ctrl_terminate_start(struct ble_ll_conn_sm *connsm)
 /**
  * Called to start a LL control procedure except for the terminate procedure. We
  * always set the control procedure pending bit even if the control procedure
- * has been initiated. 
- *  
- * Context: Link Layer task. 
- * 
+ * has been initiated.
+ *
+ * Context: Link Layer task.
+ *
  * @param connsm Pointer to connection state machine.
  */
 void
@@ -993,12 +993,12 @@ ble_ll_ctrl_proc_start(struct ble_ll_conn_sm *connsm, int ctrl_proc)
             /* Initialize the procedure response timeout */
             if (ctrl_proc != BLE_LL_CTRL_PROC_CHAN_MAP_UPD) {
                 os_callout_func_init(&connsm->ctrl_proc_rsp_timer,
-                                     &g_ble_ll_data.ll_evq, 
-                                     ble_ll_ctrl_proc_rsp_timer_cb, 
+                                     &g_ble_ll_data.ll_evq,
+                                     ble_ll_ctrl_proc_rsp_timer_cb,
                                      connsm);
 
                 /* Re-start timer. Control procedure timeout is 40 seconds */
-                os_callout_reset(&connsm->ctrl_proc_rsp_timer.cf_c, 
+                os_callout_reset(&connsm->ctrl_proc_rsp_timer.cf_c,
                                  OS_TICKS_PER_SEC * BLE_LL_CTRL_PROC_TIMEOUT);
             }
         }
@@ -1009,11 +1009,11 @@ ble_ll_ctrl_proc_start(struct ble_ll_conn_sm *connsm, int ctrl_proc)
 }
 
 /**
- * Called to determine if we need to start a LL control procedure for the given 
- * connection. 
- *  
- * Context: Link Layer 
- *  
+ * Called to determine if we need to start a LL control procedure for the given
+ * connection.
+ *
+ * Context: Link Layer
+ *
  * @param connsm Pointer to connection state machine.
  */
 void
@@ -1023,11 +1023,11 @@ ble_ll_ctrl_chk_proc_start(struct ble_ll_conn_sm *connsm)
 
     /* If we are terminating, dont start any new procedures */
     if (connsm->disconnect_reason) {
-        /* 
+        /*
          * If the terminate procedure is not pending it means we were not
          * able to start it right away (no control pdu was available).
          * Start it now.
-         */ 
+         */
         ble_ll_ctrl_terminate_start(connsm);
         return;
     }
@@ -1035,17 +1035,17 @@ ble_ll_ctrl_chk_proc_start(struct ble_ll_conn_sm *connsm)
     /* If there is a running procedure or no pending, do nothing */
     if ((connsm->cur_ctrl_proc == BLE_LL_CTRL_PROC_IDLE) &&
         (connsm->pending_ctrl_procs != 0)) {
-        /* 
+        /*
          * The specification says there is no priority to control procedures
          * so just start from the first one for now.
          */
         for (i = 0; i < BLE_LL_CTRL_PROC_NUM; ++i) {
             if (IS_PENDING_CTRL_PROC(connsm, i)) {
-                /* 
+                /*
                  * The version exchange is a special case. If we have already
                  * received the information dont start it.
-                 */ 
-                if ((i == BLE_LL_CTRL_PROC_VERSION_XCHG) && 
+                 */
+                if ((i == BLE_LL_CTRL_PROC_VERSION_XCHG) &&
                     (connsm->csmflags.cfbit.rxd_version_ind)) {
                     ble_ll_hci_ev_rd_rem_ver(connsm, BLE_ERR_SUCCESS);
                     CLR_PENDING_CTRL_PROC(connsm, i);
@@ -1059,15 +1059,15 @@ ble_ll_ctrl_chk_proc_start(struct ble_ll_conn_sm *connsm)
 }
 
 /**
- * Called when the Link Layer receives a LL control PDU. 
- *  
- * NOTE: this function uses the received PDU for the response in some cases. If 
- * the received PDU is not used it needs to be freed here. 
- *  
- * Context: Link Layer 
- * 
- * @param om 
- * @param connsm 
+ * Called when the Link Layer receives a LL control PDU.
+ *
+ * NOTE: this function uses the received PDU for the response in some cases. If
+ * the received PDU is not used it needs to be freed here.
+ *
+ * Context: Link Layer
+ *
+ * @param om
+ * @param connsm
  */
 int
 ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
@@ -1094,7 +1094,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
     /* Move data pointer to start of control data (2 byte PDU hdr + opcode) */
     dptr += (BLE_LL_PDU_HDR_LEN + 1);
 
-    /* 
+    /*
      * Subtract the opcode from the length. Note that if the length was zero,
      * which would be an error, we will fail the check against the length
      * of the control packet.
@@ -1102,7 +1102,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
     --len;
 
     /* opcode must be good */
-    if ((opcode >= BLE_LL_CTRL_OPCODES) || 
+    if ((opcode >= BLE_LL_CTRL_OPCODES) ||
         (len != g_ble_ll_ctrl_pkt_lengths[opcode])) {
         goto rx_malformed_ctrl;
     }
@@ -1153,7 +1153,7 @@ ble_ll_ctrl_rx_pdu(struct ble_ll_conn_sm *connsm, struct os_mbuf *om)
             goto rx_malformed_ctrl;
         }
 
-        /* 
+        /*
          * If we have not started this procedure ourselves and it is
          * pending, no need to perform it.
          */
@@ -1250,13 +1250,13 @@ rx_malformed_ctrl:
 
 /**
  * Called to creeate and send a REJECT_IND_EXT control PDU
- * 
- * 
- * @param connsm 
- * @param rej_opcode 
- * @param err 
- * 
- * @return int 
+ *
+ *
+ * @param connsm
+ * @param rej_opcode
+ * @param err
+ *
+ * @return int
  */
 int
 ble_ll_ctrl_reject_ind_ext_send(struct ble_ll_conn_sm *connsm,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci.c b/net/nimble/controller/src/ble_ll_hci.c
index 8e141aa..1c94a1e 100644
--- a/net/nimble/controller/src/ble_ll_hci.c
+++ b/net/nimble/controller/src/ble_ll_hci.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -37,12 +37,12 @@ static uint8_t g_ble_ll_hci_le_event_mask[BLE_HCI_SET_LE_EVENT_MASK_LEN];
 static uint8_t g_ble_ll_hci_event_mask[BLE_HCI_SET_EVENT_MASK_LEN];
 
 /**
- * ll hci get num cmd pkts 
- *  
- * Returns the number of command packets that the host is allowed to send 
- * to the controller. 
- * 
- * @return uint8_t 
+ * ll hci get num cmd pkts
+ *
+ * Returns the number of command packets that the host is allowed to send
+ * to the controller.
+ *
+ * @return uint8_t
  */
 static uint8_t
 ble_ll_hci_get_num_cmd_pkts(void)
@@ -51,10 +51,10 @@ ble_ll_hci_get_num_cmd_pkts(void)
 }
 
 /**
- * Send an event to the host. 
- * 
+ * Send an event to the host.
+ *
  * @param evbuf Pointer to event buffer to send
- * 
+ *
  * @return int 0: success; -1 otherwise.
  */
 int
@@ -72,9 +72,9 @@ ble_ll_hci_event_send(uint8_t *evbuf)
 }
 
 /**
- * Created and sends a command complete event with the no-op opcode to the 
- * host. 
- * 
+ * Created and sends a command complete event with the no-op opcode to the
+ * host.
+ *
  * @return int 0: ok, ble error code otherwise.
  */
 int
@@ -104,12 +104,12 @@ ble_ll_hci_send_noop(void)
 #if defined(BLE_LL_CFG_FEAT_LE_ENCRYPTION)
 /**
  * LE encrypt command
- * 
- * @param cmdbuf 
- * @param rspbuf 
- * @param rsplen 
- * 
- * @return int 
+ *
+ * @param cmdbuf
+ * @param rspbuf
+ * @param rsplen
+ *
+ * @return int
  */
 static int
 ble_ll_hci_le_encrypt(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
@@ -135,12 +135,12 @@ ble_ll_hci_le_encrypt(uint8_t *cmdbuf, uint8_t *rspbuf, uint8_t *rsplen)
 
 /**
  * LE rand command
- * 
- * @param cmdbuf 
- * @param rspbuf 
- * @param rsplen 
- * 
- * @return int 
+ *
+ * @param cmdbuf
+ * @param rspbuf
+ * @param rsplen
+ *
+ * @return int
  */
 static int
 ble_ll_hci_le_rand(uint8_t *rspbuf, uint8_t *rsplen)
@@ -154,15 +154,15 @@ ble_ll_hci_le_rand(uint8_t *rspbuf, uint8_t *rsplen)
 
 /**
  * Read local version
- * 
- * @param rspbuf 
- * @param rsplen 
- * 
- * @return int 
+ *
+ * @param rspbuf
+ * @param rsplen
+ *
+ * @return int
  */
 static int
 ble_ll_hci_rd_local_version(uint8_t *rspbuf, uint8_t *rsplen)
-{    
+{
     uint16_t hci_rev;
     uint16_t lmp_subver;
     uint16_t mfrg;
@@ -183,20 +183,20 @@ ble_ll_hci_rd_local_version(uint8_t *rspbuf, uint8_t *rsplen)
 
 /**
  * Read local supported features
- * 
- * @param rspbuf 
- * @param rsplen 
- * 
- * @return int 
+ *
+ * @param rspbuf
+ * @param rsplen
+ *
+ * @return int
  */
 static int
 ble_ll_hci_rd_local_supp_feat(uint8_t *rspbuf, uint8_t *rsplen)
 {
-    /* 
+    /*
      * The only two bits we set here currently are:
      *      BR/EDR not supported        (bit 5)
      *      LE supported (controller)   (bit 6)
-     */ 
+     */
     memset(rspbuf, 0, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN);
     rspbuf[4] = 0x60;
     *rsplen = BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN;
@@ -205,11 +205,11 @@ ble_ll_hci_rd_local_supp_feat(uint8_t *rspbuf, uint8_t *rsplen)
 
 /**
  * Read local supported commands
- * 
- * @param rspbuf 
- * @param rsplen 
- * 
- * @return int 
+ *
+ * @param rspbuf
+ * @param rsplen
+ *
+ * @return int
  */
 static int
 ble_ll_hci_rd_local_supp_cmd(uint8_t *rspbuf, uint8_t *rsplen)
@@ -222,20 +222,20 @@ ble_ll_hci_rd_local_supp_cmd(uint8_t *rspbuf, uint8_t *rsplen)
 
 /**
  * Called to read the public device address of the device
- * 
- * 
- * @param rspbuf 
- * @param rsplen 
- * 
- * @return int 
+ *
+ *
+ * @param rspbuf
+ * @param rsplen
+ *
+ * @return int
  */
 static int
 ble_ll_hci_rd_bd_addr(uint8_t *rspbuf, uint8_t *rsplen)
-{    
-    /* 
+{
+    /*
      * XXX: for now, assume we always have a public device address. If we
      * dont, we should set this to zero
-     */ 
+     */
     memcpy(rspbuf, g_dev_addr, BLE_DEV_ADDR_LEN);
     *rsplen = BLE_DEV_ADDR_LEN;
     return BLE_ERR_SUCCESS;
@@ -243,13 +243,13 @@ ble_ll_hci_rd_bd_addr(uint8_t *rspbuf, uint8_t *rsplen)
 
 /**
  * ll hci set le event mask
- *  
+ *
  * Called when the LL controller receives a set LE event mask command.
- *  
- * Context: Link Layer task (HCI command parser) 
- * 
+ *
+ * Context: Link Layer task (HCI command parser)
+ *
  * @param cmdbuf Pointer to command buf.
- * 
+ *
  * @return int BLE_ERR_SUCCESS. Does not return any errors.
  */
 static int
@@ -261,17 +261,17 @@ ble_ll_hci_set_le_event_mask(uint8_t *cmdbuf)
 }
 
 /**
- * HCI read buffer size command. Returns the ACL data packet length and 
- * num data packets. 
- * 
+ * HCI read buffer size command. Returns the ACL data packet length and
+ * num data packets.
+ *
  * @param rspbuf Pointer to response buffer
  * @param rsplen Length of response buffer
- * 
+ *
  * @return int BLE error code
  */
 static int
 ble_ll_hci_le_read_bufsize(uint8_t *rspbuf, uint8_t *rsplen)
-{    
+{
     /* Place the data packet length and number of packets in the buffer */
     htole16(rspbuf, g_ble_ll_data.ll_acl_pkt_size);
     rspbuf[2] = g_ble_ll_data.ll_num_acl_pkts;
@@ -281,17 +281,17 @@ ble_ll_hci_le_read_bufsize(uint8_t *rspbuf, uint8_t *rsplen)
 
 #ifdef BLE_LL_CFG_FEAT_DATA_LEN_EXT
 /**
- * HCI write suggested default data length command. Returns the controllers 
- * initial max tx octet/time. 
- * 
+ * HCI write suggested default data length command. Returns the controllers
+ * initial max tx octet/time.
+ *
  * @param rspbuf Pointer to response buffer
  * @param rsplen Length of response buffer
- * 
+ *
  * @return int BLE error code
  */
 static int
 ble_ll_hci_le_wr_sugg_data_len(uint8_t *cmdbuf)
-{    
+{
     int rc;
     uint16_t tx_oct;
     uint16_t tx_time;
@@ -315,17 +315,17 @@ ble_ll_hci_le_wr_sugg_data_len(uint8_t *cmdbuf)
 }
 
 /**
- * HCI read suggested default data length command. Returns the controllers 
- * initial max tx octet/time. 
- * 
+ * HCI read suggested default data length command. Returns the controllers
+ * initial max tx octet/time.
+ *
  * @param rspbuf Pointer to response buffer
  * @param rsplen Length of response buffer
- * 
+ *
  * @return int BLE error code
  */
 static int
 ble_ll_hci_le_rd_sugg_data_len(uint8_t *rspbuf, uint8_t *rsplen)
-{    
+{
     /* Place the data packet length and number of packets in the buffer */
     htole16(rspbuf, g_ble_ll_conn_params.sugg_tx_octets);
     htole16(rspbuf + 2, g_ble_ll_conn_params.sugg_tx_time);
@@ -334,17 +334,17 @@ ble_ll_hci_le_rd_sugg_data_len(uint8_t *rspbuf, uint8_t *rsplen)
 }
 
 /**
- * HCI read maximum data length command. Returns the controllers max supported 
- * rx/tx octets/times. 
- * 
+ * HCI read maximum data length command. Returns the controllers max supported
+ * rx/tx octets/times.
+ *
  * @param rspbuf Pointer to response buffer
  * @param rsplen Length of response buffer
- * 
+ *
  * @return int BLE error code
  */
 static int
 ble_ll_hci_le_rd_max_data_len(uint8_t *rspbuf, uint8_t *rsplen)
-{    
+{
     /* Place the data packet length and number of packets in the buffer */
     htole16(rspbuf, g_ble_ll_conn_params.supp_max_tx_octets);
     htole16(rspbuf + 2, g_ble_ll_conn_params.supp_max_tx_time);
@@ -356,17 +356,17 @@ ble_ll_hci_le_rd_max_data_len(uint8_t *rspbuf, uint8_t *rsplen)
 #endif
 
 /**
- * HCI read local supported features command. Returns the features 
+ * HCI read local supported features command. Returns the features
  * supported by the controller.
- * 
+ *
  * @param rspbuf Pointer to response buffer
  * @param rsplen Length of response buffer
- * 
+ *
  * @return int BLE error code
  */
 static int
 ble_ll_hci_le_read_local_features(uint8_t *rspbuf, uint8_t *rsplen)
-{    
+{
     /* Add list of supported features. */
     memset(rspbuf, 0, BLE_HCI_RD_LOC_SUPP_FEAT_RSPLEN);
     rspbuf[0] = ble_ll_read_supp_features();
@@ -375,17 +375,17 @@ ble_ll_hci_le_read_local_features(uint8_t *rspbuf, uint8_t *rsplen)
 }
 
 /**
- * HCI read local supported states command. Returns the states 
+ * HCI read local supported states command. Returns the states
  * supported by the controller.
- * 
+ *
  * @param rspbuf Pointer to response buffer
  * @param rsplen Length of response buffer
- * 
+ *
  * @return int BLE error code
  */
 static int
 ble_ll_hci_le_read_supp_states(uint8_t *rspbuf, uint8_t *rsplen)
-{    
+{
     uint64_t supp_states;
 
     /* Add list of supported states. */
@@ -396,11 +396,11 @@ ble_ll_hci_le_read_supp_states(uint8_t *rspbuf, uint8_t *rsplen)
 }
 
 /**
- * Checks to see if a LE event has been disabled by the host. 
- * 
- * @param subev Sub-event code of the LE Meta event. Note that this can 
- * be a value from 0 to 63, inclusive. 
- * 
+ * Checks to see if a LE event has been disabled by the host.
+ *
+ * @param subev Sub-event code of the LE Meta event. Note that this can
+ * be a value from 0 to 63, inclusive.
+ *
  * @return uint8_t 0: event is not enabled; otherwise event is enabled.
  */
 uint8_t
@@ -424,10 +424,10 @@ ble_ll_hci_is_le_event_enabled(int subev)
 }
 
 /**
- * Checks to see if an event has been disabled by the host. 
- * 
+ * Checks to see if an event has been disabled by the host.
+ *
  * @param evcode This is the event code for the event (0 - 63).
- * 
+ *
  * @return uint8_t 0: event is not enabled; otherwise event is enabled.
  */
 uint8_t
@@ -447,11 +447,11 @@ ble_ll_hci_is_event_enabled(int evcode)
 }
 
 /**
- * Called to determine if the reply to the command should be a command complete 
- * event or a command status event. 
- * 
- * @param ocf 
- * 
+ * Called to determine if the reply to the command should be a command complete
+ * event or a command status event.
+ *
+ * @param ocf
+ *
  * @return int 0: return command complete; 1: return command status event
  */
 static int
@@ -476,16 +476,16 @@ ble_ll_hci_le_cmd_send_cmd_status(uint16_t ocf)
 }
 
 /**
- * Process a LE command sent from the host to the controller. The HCI command 
- * has a 3 byte command header followed by data. The header is: 
+ * Process a LE command sent from the host to the controller. The HCI command
+ * has a 3 byte command header followed by data. The header is:
  *  -> opcode (2 bytes)
  *  -> Length of parameters (1 byte; does include command header bytes).
- * 
+ *
  * @param cmdbuf Pointer to command buffer. Points to start of command header.
  * @param ocf    Opcode command field.
  * @param *rsplen Pointer to length of response
- *  
- * @return int  This function returns a BLE error code. If a command status 
+ *
+ * @return int  This function returns a BLE error code. If a command status
  *              event should be returned as opposed to command complete,
  *              256 gets added to the return value.
  */
@@ -509,11 +509,11 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
         goto ll_hci_le_cmd_exit;
     }
 
-    /* 
+    /*
      * The command response pointer points into the same buffer as the
      * command data itself. That is fine, as each command reads all the data
      * before crafting a response.
-     */ 
+     */
     rspbuf = cmdbuf + BLE_HCI_EVENT_CMD_COMPLETE_MIN_LEN;
 
     /* Move past HCI command header */
@@ -627,11 +627,11 @@ ble_ll_hci_le_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
         break;
     }
 
-    /* 
+    /*
      * This code is here because we add 256 to the return code to denote
      * that the reply to this command should be command status (as opposed to
      * command complete).
-     */ 
+     */
 ll_hci_le_cmd_exit:
     if (ble_ll_hci_le_cmd_send_cmd_status(ocf)) {
         rc += (BLE_ERR_MAX + 1);
@@ -641,16 +641,16 @@ ll_hci_le_cmd_exit:
 }
 
 /**
- * Process a link control command sent from the host to the controller. The HCI 
- * command has a 3 byte command header followed by data. The header is: 
+ * Process a link control command sent from the host to the controller. The HCI
+ * command has a 3 byte command header followed by data. The header is:
  *  -> opcode (2 bytes)
  *  -> Length of parameters (1 byte; does include command header bytes).
- * 
+ *
  * @param cmdbuf Pointer to command buffer. Points to start of command header.
  * @param ocf    Opcode command field.
  * @param *rsplen Pointer to length of response
- *  
- * @return int  This function returns a BLE error code. If a command status 
+ *
+ * @return int  This function returns a BLE error code. If a command status
  *              event should be returned as opposed to command complete,
  *              256 gets added to the return value.
  */
@@ -742,11 +742,11 @@ ble_ll_hci_info_params_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen)
     /* Get length from command */
     len = cmdbuf[sizeof(uint16_t)];
 
-    /* 
+    /*
      * The command response pointer points into the same buffer as the
      * command data itself. That is fine, as each command reads all the data
      * before crafting a response.
-     */ 
+     */
     rspbuf = cmdbuf + BLE_HCI_EVENT_CMD_COMPLETE_MIN_LEN;
 
     /* Move past HCI command header */
@@ -794,11 +794,11 @@ ble_ll_hci_status_params_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen
     /* Get length from command */
     len = cmdbuf[sizeof(uint16_t)];
 
-    /* 
+    /*
      * The command response pointer points into the same buffer as the
      * command data itself. That is fine, as each command reads all the data
      * before crafting a response.
-     */ 
+     */
     rspbuf = cmdbuf + BLE_HCI_EVENT_CMD_COMPLETE_MIN_LEN;
 
     /* Move past HCI command header */
@@ -820,7 +820,7 @@ ble_ll_hci_status_params_cmd_proc(uint8_t *cmdbuf, uint16_t ocf, uint8_t *rsplen
 
 /**
  * Called to process an HCI command from the host.
- * 
+ *
  * @param ev Pointer to os event containing a pointer to command buffer
  */
 void
@@ -935,10 +935,10 @@ ble_hci_transport_host_acl_data_send(struct os_mbuf *om)
 }
 
 /**
- * Initalize the LL HCI. 
- *  
- * NOTE: This function is called by the HCI RESET command so if any code 
- * is added here it must be OK to be executed when the reset command is used. 
+ * Initalize the LL HCI.
+ *
+ * NOTE: This function is called by the HCI RESET command so if any code
+ * is added here it must be OK to be executed when the reset command is used.
  */
 void
 ble_ll_hci_init(void)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_hci_ev.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_hci_ev.c b/net/nimble/controller/src/ble_ll_hci_ev.c
index bb16705..4bad8a1 100644
--- a/net/nimble/controller/src/ble_ll_hci_ev.c
+++ b/net/nimble/controller/src/ble_ll_hci_ev.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -28,7 +28,7 @@
 
 /**
  * Send a data length change event for a connection to the host.
- * 
+ *
  * @param connsm Pointer to connection state machine
  */
 void
@@ -54,7 +54,7 @@ ble_ll_hci_ev_datalen_chg(struct ble_ll_conn_sm *connsm)
 
 /**
  * Send a connection parameter request event for a connection to the host.
- * 
+ *
  * @param connsm Pointer to connection state machine
  */
 void
@@ -81,9 +81,9 @@ ble_ll_hci_ev_rem_conn_parm_req(struct ble_ll_conn_sm *connsm,
 
 /**
  * Send a connection update event.
- * 
- * @param connsm Pointer to connection state machine 
- * @param status The error code. 
+ *
+ * @param connsm Pointer to connection state machine
+ * @param status The error code.
  */
 void
 ble_ll_hci_ev_conn_update(struct ble_ll_conn_sm *connsm, uint8_t status)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_rand.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_rand.c b/net/nimble/controller/src/ble_ll_rand.c
index 2cb33d3..f0e69f7 100644
--- a/net/nimble/controller/src/ble_ll_rand.c
+++ b/net/nimble/controller/src/ble_ll_rand.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -69,7 +69,7 @@ ble_ll_rand_data_get(uint8_t *buf, uint8_t len)
 
     while (len != 0) {
         OS_ENTER_CRITICAL(sr);
-        rnums = g_ble_ll_rnum_data.rnd_size; 
+        rnums = g_ble_ll_rnum_data.rnd_size;
         if (rnums > len) {
             rnums = len;
         }
@@ -92,7 +92,7 @@ ble_ll_rand_data_get(uint8_t *buf, uint8_t len)
 
         /* Wait till bytes are in buffer. */
         if (len) {
-            while ((g_ble_ll_rnum_data.rnd_size < len) && 
+            while ((g_ble_ll_rnum_data.rnd_size < len) &&
                    (g_ble_ll_rnum_data.rnd_size < NIMBLE_OPT_LL_RNG_BUFSIZE)) {
                 /* Spin here */
             }
@@ -104,8 +104,8 @@ ble_ll_rand_data_get(uint8_t *buf, uint8_t len)
 
 /**
  * Start the generation of random numbers
- * 
- * @return int 
+ *
+ * @return int
  */
 int
 ble_ll_rand_start(void)
@@ -118,10 +118,10 @@ ble_ll_rand_start(void)
 }
 
 /**
- * Initialize LL random number generation. Should be called only once on 
- * initialization. 
- * 
- * @return int 
+ * Initialize LL random number generation. Should be called only once on
+ * initialization.
+ *
+ * @return int
  */
 int
 ble_ll_rand_init(void)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_rng.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_rng.c b/net/nimble/controller/src/ble_ll_rng.c
index 3bbd456..b6f12f4 100644
--- a/net/nimble/controller/src/ble_ll_rng.c
+++ b/net/nimble/controller/src/ble_ll_rng.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_scan.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_scan.c b/net/nimble/controller/src/ble_ll_scan.c
index e0dfa3e..27805ba 100644
--- a/net/nimble/controller/src/ble_ll_scan.c
+++ b/net/nimble/controller/src/ble_ll_scan.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -35,13 +35,13 @@
 #include "hal/hal_cputime.h"
 #include "hal/hal_gpio.h"
 
-/* 
+/*
  * XXX:
  * 1) I think I can guarantee that we dont process things out of order if
  * I send an event when a scan request is sent. The scan_rsp_pending flag
  * code might be made simpler.
- * 
- * 2) Interleave sending scan requests to different advertisers? I guess I need 
+ *
+ * 2) Interleave sending scan requests to different advertisers? I guess I need
  * a list of advertisers to which I sent a scan request and have yet to
  * receive a scan response from? Implement this.
  */
@@ -57,7 +57,7 @@
 /* The scanning state machine global object */
 struct ble_ll_scan_sm g_ble_ll_scan_sm;
 
-/* 
+/*
  * Structure used to store advertisers. This is used to limit sending scan
  * requests to the same advertiser and also to filter duplicate events sent
  * to the host.
@@ -75,12 +75,12 @@ struct ble_ll_scan_advertisers
 
 /* Contains list of advertisers that we have heard scan responses from */
 static uint8_t g_ble_ll_scan_num_rsp_advs;
-struct ble_ll_scan_advertisers 
+struct ble_ll_scan_advertisers
 g_ble_ll_scan_rsp_advs[NIMBLE_OPT_LL_NUM_SCAN_RSP_ADVS];
 
 /* Used to filter duplicate advertising events to host */
 static uint8_t g_ble_ll_scan_num_dup_advs;
-struct ble_ll_scan_advertisers 
+struct ble_ll_scan_advertisers
 g_ble_ll_scan_dup_advs[NIMBLE_OPT_LL_NUM_SCAN_DUP_ADVS];
 
 /* See Vol 6 Part B Section 4.4.3.2. Active scanning backoff */
@@ -117,9 +117,9 @@ ble_ll_scan_req_backoff(struct ble_ll_scan_sm *scansm, int success)
 
 /**
  * ble ll scan req pdu make
- *  
- * Construct a SCAN_REQ PDU. 
- * 
+ *
+ * Construct a SCAN_REQ PDU.
+ *
  * @param scansm Pointer to scanning state machine
  * @param adv_addr Pointer to device address of advertiser
  * @param addr_type 0 if public; non-zero if random
@@ -164,12 +164,12 @@ ble_ll_scan_req_pdu_make(struct ble_ll_scan_sm *scansm, uint8_t *adv_addr,
 }
 
 /**
- * Checks to see if an advertiser is on the duplicate address list. 
- * 
+ * Checks to see if an advertiser is on the duplicate address list.
+ *
  * @param addr Pointer to address
  * @param txadd TxAdd bit. 0: public; random otherwise
- * 
- * @return uint8_t 0: not on list; any other value is 
+ *
+ * @return uint8_t 0: not on list; any other value is
  */
 static struct ble_ll_scan_advertisers *
 ble_ll_scan_find_dup_adv(uint8_t *addr, uint8_t txadd)
@@ -204,10 +204,10 @@ ble_ll_scan_find_dup_adv(uint8_t *addr, uint8_t txadd)
 
 /**
  * Check if a packet is a duplicate advertising packet.
- * 
- * @param pdu_type 
- * @param rxbuf 
- * 
+ *
+ * @param pdu_type
+ * @param rxbuf
+ *
  * @return int 0: not a duplicate. 1:duplicate
  */
 int
@@ -234,10 +234,10 @@ ble_ll_scan_is_dup_adv(uint8_t pdu_type, uint8_t txadd, uint8_t *addr)
 
 /**
  * Add an advertiser the list of duplicate advertisers. An address gets added to
- * the list of duplicate addresses when the controller sends an advertising 
- * report to the host. 
- * 
- * @param addr 
+ * the list of duplicate addresses when the controller sends an advertising
+ * report to the host.
+ *
+ * @param addr
  * @param Txadd. TxAdd bit (0 public, random otherwise)
  */
 void
@@ -266,7 +266,7 @@ ble_ll_scan_add_dup_adv(uint8_t *addr, uint8_t txadd)
         }
     }
 
-    /* 
+    /*
      * XXX: need to set correct flag based on type of report being sent
      * for now, we dont send direct advertising reports
      */
@@ -274,11 +274,11 @@ ble_ll_scan_add_dup_adv(uint8_t *addr, uint8_t txadd)
 }
 
 /**
- * Checks to see if we have received a scan response from this advertiser. 
- * 
+ * Checks to see if we have received a scan response from this advertiser.
+ *
  * @param adv_addr Address of advertiser
  * @param txadd TxAdd bit (0: public; random otherwise)
- * 
+ *
  * @return int 0: have not received a scan response; 1 otherwise.
  */
 static int
@@ -341,14 +341,14 @@ ble_ll_scan_add_scan_rsp_adv(uint8_t *addr, uint8_t txadd)
 
 /**
  * Send an advertising report to the host.
- * 
- * NOTE: while we are allowed to send multiple devices in one report, we 
- * will just send for one for now. 
- * 
- * @param pdu_type 
- * @param txadd 
- * @param rxbuf 
- * @param rssi 
+ *
+ * NOTE: while we are allowed to send multiple devices in one report, we
+ * will just send for one for now.
+ *
+ * @param pdu_type
+ * @param txadd
+ * @param rxbuf
+ * @param rssi
  */
 static void
 ble_ll_hci_send_adv_report(uint8_t pdu_type, uint8_t txadd, uint8_t *rxbuf,
@@ -417,14 +417,14 @@ ble_ll_hci_send_adv_report(uint8_t pdu_type, uint8_t txadd, uint8_t *rxbuf,
 }
 
 /**
- * Checks the scanner filter policy to determine if we should allow or discard 
- * the received PDU. 
- *  
- * NOTE: connect requests and scan requests are not passed here 
- *  
- * @param pdu_type 
- * @param rxbuf 
- * 
+ * Checks the scanner filter policy to determine if we should allow or discard
+ * the received PDU.
+ *
+ * NOTE: connect requests and scan requests are not passed here
+ *
+ * @param pdu_type
+ * @param rxbuf
+ *
  * @return int 0: pdu allowed by filter policy. 1: pdu not allowed
  */
 int
@@ -483,23 +483,23 @@ ble_ll_scan_chk_filter_policy(uint8_t pdu_type, uint8_t *rxbuf, uint8_t flags)
 
 /**
  * Called to enable the receiver for scanning.
- *  
+ *
  * Context: Link Layer task
- * 
- * @param sch 
- * 
- * @return int 
+ *
+ * @param sch
+ *
+ * @return int
  */
 static void
 ble_ll_scan_start(struct ble_ll_scan_sm *scansm, uint8_t chan)
 {
     int rc;
-    
+
     /* Set channel */
     rc = ble_phy_setchan(chan, 0, 0);
     assert(rc == 0);
 
-    /* 
+    /*
      * Set transmit end callback to NULL in case we transmit a scan request.
      * There is a callback for the connect request.
      */
@@ -530,14 +530,14 @@ ble_ll_scan_start(struct ble_ll_scan_sm *scansm, uint8_t chan)
 }
 
 /**
- * Called to determine if we are inside or outside the scan window. If we 
- * are inside the scan window it means that the device should be receiving 
- * on the scan channel. 
- * 
+ * Called to determine if we are inside or outside the scan window. If we
+ * are inside the scan window it means that the device should be receiving
+ * on the scan channel.
+ *
  * Context: Link Layer
- *  
- * @param scansm 
- * 
+ *
+ * @param scansm
+ *
  * @return int 0: inside scan window 1: outside scan window
  */
 static int
@@ -576,7 +576,7 @@ ble_ll_scan_window_chk(struct ble_ll_scan_sm *scansm, uint32_t cputime)
 }
 
 /**
- * Stop the scanning state machine 
+ * Stop the scanning state machine
  */
 void
 ble_ll_scan_sm_stop(int chk_disable)
@@ -613,13 +613,13 @@ ble_ll_scan_sm_stop(int chk_disable)
 static int
 ble_ll_scan_sm_start(struct ble_ll_scan_sm *scansm)
 {
-    /* 
+    /*
      * This is not in the specification. I will reject the command with a
      * command disallowed error if no random address has been sent by the
      * host. All the parameter errors refer to the command parameter
      * (which in this case is just enable or disable) so that is why I chose
      * command disallowed.
-     */ 
+     */
     if (scansm->own_addr_type == BLE_HCI_ADV_OWN_ADDR_RANDOM) {
         if (!ble_ll_is_valid_random_addr(g_random_addr)) {
             return BLE_ERR_CMD_DISALLOWED;
@@ -655,11 +655,11 @@ ble_ll_scan_sm_start(struct ble_ll_scan_sm *scansm)
 }
 
 /**
- * Called to process the scanning OS event which was posted to the LL task 
- *  
- * Context: Link Layer task. 
- * 
- * @param arg 
+ * Called to process the scanning OS event which was posted to the LL task
+ *
+ * Context: Link Layer task.
+ *
+ * @param arg
  */
 void
 ble_ll_scan_event_proc(void *arg)
@@ -676,7 +676,7 @@ ble_ll_scan_event_proc(void *arg)
     uint32_t next_event_time;
     struct ble_ll_scan_sm *scansm;
 
-    /* 
+    /*
      * Get the scanning state machine. If not enabled (this is possible), just
      * leave and do nothing (just make sure timer is stopped).
      */
@@ -717,7 +717,7 @@ ble_ll_scan_event_proc(void *arg)
     }
 
     OS_ENTER_CRITICAL(sr);
-    /* 
+    /*
      * If we are not in the standby state it means that the scheduled
      * scanning event was overlapped in the schedule. In this case all we do
      * is post the scan schedule end event.
@@ -748,16 +748,16 @@ ble_ll_scan_event_proc(void *arg)
 }
 
 /**
- * ble ll scan rx pdu start 
- *  
- * Called when a PDU reception has started and the Link Layer is in the 
- * scanning state. 
- * 
- * Context: Interrupt 
- *  
+ * ble ll scan rx pdu start
+ *
+ * Called when a PDU reception has started and the Link Layer is in the
+ * scanning state.
+ *
+ * Context: Interrupt
+ *
  * @param rxpdu Pointer to where received data is being stored.
- * 
- * @return int 
+ *
+ * @return int
  *  0: we will not attempt to reply to this frame
  *  1: we may send a response to this frame.
  */
@@ -779,13 +779,13 @@ ble_ll_scan_rx_isr_start(uint8_t pdu_type, struct os_mbuf *rxpdu)
             rc = 1;
         }
 
-        /* 
+        /*
          * If this is the first PDU after we sent the scan response (as
          * denoted by the scan rsp pending flag), we set a bit in the ble
          * header so the link layer can check to see if the scan request
          * was successful. We do it this way to let the Link Layer do the
          * work for successful scan requests. If failed, we do the work here.
-         */ 
+         */
         if (scansm->scan_rsp_pending) {
             if (pdu_type == BLE_ADV_PDU_TYPE_SCAN_RSP) {
                 ble_hdr = BLE_MBUF_HDR_PTR(rxpdu);
@@ -807,13 +807,13 @@ ble_ll_scan_rx_isr_start(uint8_t pdu_type, struct os_mbuf *rxpdu)
 }
 
 /**
- * Called when a receive PDU has ended. 
- *  
- * Context: Interrupt 
- * 
- * @param rxpdu 
- * 
- * @return int 
+ * Called when a receive PDU has ended.
+ *
+ * Context: Interrupt
+ *
+ * @param rxpdu
+ *
+ * @return int
  *       < 0: Disable the phy after reception.
  *      == 0: Success. Do not disable the PHY.
  *       > 0: Do not disable PHY as that has already been done.
@@ -834,7 +834,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
     /* Get scanning state machine */
     scansm = &g_ble_ll_scan_sm;
 
-    /* 
+    /*
      * The reason we do something different here (as opposed to failed CRC) is
      * that the received PDU will not be handed up in this case. So we have
      * to restart scanning and handle a failed scan request. Note that we
@@ -895,7 +895,7 @@ ble_ll_scan_rx_isr_end(struct os_mbuf *rxpdu, uint8_t crcok)
 
     /* Should we send a scan request? */
     if (chk_send_req) {
-        /* 
+        /*
          * Check to see if we have received a scan response from this
          * advertisor. If so, no need to send scan request.
          */
@@ -927,11 +927,11 @@ scan_rx_isr_exit:
 }
 
 /**
- * Called to resume scanning. This is called after an advertising event or 
- * connection event has ended. It is also called if we receive a packet while 
- * in the initiating or scanning state. 
- *  
- * Context: Link Layer task 
+ * Called to resume scanning. This is called after an advertising event or
+ * connection event has ended. It is also called if we receive a packet while
+ * in the initiating or scanning state.
+ *
+ * Context: Link Layer task
  */
 void
 ble_ll_scan_chk_resume(void)
@@ -951,10 +951,10 @@ ble_ll_scan_chk_resume(void)
 
 /**
  * Connection supervision timer callback; means that the connection supervision
- * timeout has been reached and we should perform the appropriate actions. 
- *  
+ * timeout has been reached and we should perform the appropriate actions.
+ *
  * Context: Interrupt (cputimer)
- * 
+ *
  * @param arg Pointer to connection state machine.
  */
 void
@@ -967,10 +967,10 @@ ble_ll_scan_timer_cb(void *arg)
 }
 
 /**
- * Called when the wait for response timer expires while in the scanning 
- * state. 
- *  
- * Context: Interrupt. 
+ * Called when the wait for response timer expires while in the scanning
+ * state.
+ *
+ * Context: Interrupt.
  */
 void
 ble_ll_scan_wfr_timer_exp(void)
@@ -979,10 +979,10 @@ ble_ll_scan_wfr_timer_exp(void)
 
     ble_phy_disable();
 
-    /* 
+    /*
      * If we timed out waiting for a response, the scan response pending
      * flag should be set. Deal with scan backoff. Put device back into rx.
-     */ 
+     */
     scansm = &g_ble_ll_scan_sm;
     if (scansm->scan_rsp_pending) {
         ble_ll_scan_req_backoff(scansm, 0);
@@ -992,11 +992,11 @@ ble_ll_scan_wfr_timer_exp(void)
 
 /**
  * Process a received PDU while in the scanning state.
- *  
- * Context: Link Layer task. 
- * 
- * @param pdu_type 
- * @param rxbuf 
+ *
+ * Context: Link Layer task.
+ *
+ * @param pdu_type
+ * @param rxbuf
  */
 void
 ble_ll_scan_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
@@ -1027,7 +1027,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
     txadd = rxbuf[0] & BLE_ADV_PDU_HDR_TXADD_MASK;
     adv_addr = rxbuf + BLE_LL_PDU_HDR_LEN;
 
-    /* 
+    /*
      * XXX: The BLE spec is a bit unclear here. What if we get a scan
      * response from an advertiser that we did not send a request to?
      * Do we send an advertising report? Do we add it to list of devices
@@ -1035,12 +1035,12 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
      */
     scansm = &g_ble_ll_scan_sm;
     if (ptype == BLE_ADV_PDU_TYPE_SCAN_RSP) {
-        /* 
+        /*
          * If this is a scan response in reply to a request we sent we need
          * to store this advertiser's address so we dont send a request to it.
          */
         if (scansm->scan_rsp_pending && scan_rsp_chk) {
-            /* 
+            /*
              * We could also check the timing of the scan reponse; make sure
              * that it is relatively close to the end of the scan request but
              * we wont for now.
@@ -1070,7 +1070,7 @@ ble_ll_scan_rx_pkt_in(uint8_t ptype, uint8_t *rxbuf, struct ble_mbuf_hdr *hdr)
     ble_ll_hci_send_adv_report(ptype, txadd, rxbuf, hdr->rxinfo.rssi);
 
 scan_continue:
-    /* 
+    /*
      * If the scan response check bit is set and we are pending a response,
      * we have failed the scan request (as we would have reset the scan rsp
      * pending flag if we received a valid response
@@ -1107,13 +1107,13 @@ ble_ll_scan_set_scan_params(uint8_t *cmd)
     filter_policy = cmd[6];
 
     /* Check scan type */
-    if ((scan_type != BLE_HCI_SCAN_TYPE_PASSIVE) && 
+    if ((scan_type != BLE_HCI_SCAN_TYPE_PASSIVE) &&
         (scan_type != BLE_HCI_SCAN_TYPE_ACTIVE)) {
         return BLE_ERR_INV_HCI_CMD_PARMS;
     }
 
     /* Check interval and window */
-    if ((scan_itvl < BLE_HCI_SCAN_ITVL_MIN) || 
+    if ((scan_itvl < BLE_HCI_SCAN_ITVL_MIN) ||
         (scan_itvl > BLE_HCI_SCAN_ITVL_MAX) ||
         (scan_window < BLE_HCI_SCAN_WINDOW_MIN) ||
         (scan_window > BLE_HCI_SCAN_WINDOW_MAX) ||
@@ -1142,15 +1142,15 @@ ble_ll_scan_set_scan_params(uint8_t *cmd)
 }
 
 /**
- * ble ll scan set enable 
- *  
+ * ble ll scan set enable
+ *
  *  HCI scan set enable command processing function
- *  
+ *
  *  Context: Link Layer task (HCI Command parser).
- * 
+ *
  * @param cmd Pointer to command buffer
- * 
- * @return int BLE error code. 
+ *
+ * @return int BLE error code.
  */
 int
 ble_ll_scan_set_enable(uint8_t *cmd)
@@ -1188,7 +1188,7 @@ ble_ll_scan_set_enable(uint8_t *cmd)
 /**
  * Checks if controller can change the whitelist. If scanning is enabled and
  * using the whitelist the controller is not allowed to change the whitelist.
- * 
+ *
  * @return int 0: not allowed to change whitelist; 1: change allowed.
  */
 int
@@ -1223,7 +1223,7 @@ ble_ll_scan_initiator_start(struct hci_create_conn *hcc)
 
 /**
  * Checks to see if the scanner is enabled.
- * 
+ *
  * @return int 0: not enabled; enabled otherwise
  */
 int
@@ -1254,10 +1254,10 @@ ble_ll_scan_whitelist_enabled(void)
 }
 
 /**
- * Called when the controller receives the reset command. Resets the 
- * scanning state machine to its initial state. 
- * 
- * @return int 
+ * Called when the controller receives the reset command. Resets the
+ * scanning state machine to its initial state.
+ *
+ * @return int
  */
 void
 ble_ll_scan_reset(void)
@@ -1285,10 +1285,10 @@ ble_ll_scan_reset(void)
 }
 
 /**
- * ble ll scan init 
- *  
- * Initialize a scanner. Must be called before scanning can be started. 
- * Expected to be called with a un-initialized or reset scanning state machine. 
+ * ble ll scan init
+ *
+ * Initialize a scanner. Must be called before scanning can be started.
+ * Expected to be called with a un-initialized or reset scanning state machine.
  */
 void
 ble_ll_scan_init(void)
@@ -1311,7 +1311,7 @@ ble_ll_scan_init(void)
     cputime_timer_init(&scansm->scan_timer, ble_ll_scan_timer_cb, scansm);
 
     /* Get a scan request mbuf (packet header) and attach to state machine */
-    scansm->scan_req_pdu = os_msys_get_pkthdr(BLE_MBUF_PAYLOAD_SIZE, 
+    scansm->scan_req_pdu = os_msys_get_pkthdr(BLE_MBUF_PAYLOAD_SIZE,
                                               sizeof(struct ble_mbuf_hdr));
     assert(scansm->scan_req_pdu != NULL);
 }

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_sched.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_sched.c b/net/nimble/controller/src/ble_ll_sched.c
index 11601d8..9b0ccea 100644
--- a/net/nimble/controller/src/ble_ll_sched.c
+++ b/net/nimble/controller/src/ble_ll_sched.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -34,29 +34,29 @@ struct cpu_timer g_ble_ll_sched_timer;
 /* XXX: TODO:
  *  1) Add some accounting to the schedule code to see how late we are
  *  (min/max?)
- * 
+ *
  *  2) Need to determine how we really want to handle the case when we execute
  *  a schedule item but there is a current event. We could:
  *      -> Reschedule the schedule item and let current event finish
  *      -> Kill the current event and run the scheduled item.
  *      -> Disable schedule timer while in an event; could cause us to be late.
- *      -> Wait for current event to finish hoping it does before schedule item. 
+ *      -> Wait for current event to finish hoping it does before schedule item.
  */
 
 /* Queue for timers */
 TAILQ_HEAD(ll_sched_qhead, ble_ll_sched_item) g_ble_ll_sched_q;
 
 /**
- * Checks if two events in the schedule will overlap in time. NOTE: consecutive 
- * schedule items can end and start at the same time. 
- * 
- * @param s1 
- * @param s2 
- * 
+ * Checks if two events in the schedule will overlap in time. NOTE: consecutive
+ * schedule items can end and start at the same time.
+ *
+ * @param s1
+ * @param s2
+ *
  * @return int 0: dont overlap 1:overlap
  */
 static int
-ble_ll_sched_is_overlap(struct ble_ll_sched_item *s1, 
+ble_ll_sched_is_overlap(struct ble_ll_sched_item *s1,
                         struct ble_ll_sched_item *s2)
 {
     int rc;
@@ -77,7 +77,7 @@ ble_ll_sched_is_overlap(struct ble_ll_sched_item *s1,
     return rc;
 }
 
-/* 
+/*
  * Determines if the schedule item overlaps the currently running schedule
  * item. We only care about connection schedule items
  */
@@ -150,7 +150,7 @@ ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm *connsm)
         usecs = XCVR_RX_SCHED_DELAY_USECS;
         usecs += connsm->slave_cur_window_widening;
     } else {
-        usecs = XCVR_TX_SCHED_DELAY_USECS; 
+        usecs = XCVR_TX_SCHED_DELAY_USECS;
     }
     sch->start_time = connsm->anchor_point - cputime_usecs_to_ticks(usecs);
     sch->end_time = connsm->ce_end_time;
@@ -178,7 +178,7 @@ ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm *connsm)
         if (ble_ll_sched_is_overlap(sch, entry)) {
             /* Only insert if this element is older than all that we overlap */
             if ((entry->sched_type == BLE_LL_SCHED_TYPE_ADV) ||
-                !ble_ll_conn_is_lru((struct ble_ll_conn_sm *)sch->cb_arg, 
+                !ble_ll_conn_is_lru((struct ble_ll_conn_sm *)sch->cb_arg,
                                     (struct ble_ll_conn_sm *)entry->cb_arg)) {
                 start_overlap = NULL;
                 rc = -1;
@@ -236,7 +236,7 @@ ble_ll_sched_conn_reschedule(struct ble_ll_conn_sm *connsm)
 }
 
 int
-ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend, 
+ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
                         uint8_t req_slots)
 {
     int rc;
@@ -258,14 +258,14 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
     rc = -1;
     sch = &connsm->conn_sch;
 
-    /* 
+    /*
      * The earliest start time is 1.25 msecs from the end of the connect
      * request transmission. Note that adv_rxend is the end of the received
      * advertisement, so we need to add an IFS plus the time it takes to send
      * the connection request
      */
     dur = cputime_usecs_to_ticks(req_slots * BLE_LL_SCHED_USECS_PER_SLOT);
-    earliest_start = adv_rxend + 
+    earliest_start = adv_rxend +
         cputime_usecs_to_ticks(BLE_LL_IFS + BLE_LL_CONN_REQ_DURATION +
                                BLE_LL_CONN_INITIAL_OFFSET);
     earliest_end = earliest_start + dur;
@@ -349,7 +349,7 @@ ble_ll_sched_master_new(struct ble_ll_conn_sm *connsm, uint32_t adv_rxend,
         sch->end_time = earliest_end;
         connsm->anchor_point = earliest_start +
             cputime_usecs_to_ticks(XCVR_TX_SCHED_DELAY_USECS);
-        connsm->ce_end_time = earliest_end; 
+        connsm->ce_end_time = earliest_end;
     }
 
     OS_EXIT_CRITICAL(sr);
@@ -373,8 +373,8 @@ ble_ll_sched_slave_new(struct ble_ll_conn_sm *connsm)
     sch = &connsm->conn_sch;
 
     /* Set schedule start and end times */
-    sch->start_time = connsm->anchor_point -  
-        cputime_usecs_to_ticks(XCVR_RX_SCHED_DELAY_USECS + 
+    sch->start_time = connsm->anchor_point -
+        cputime_usecs_to_ticks(XCVR_RX_SCHED_DELAY_USECS +
                                connsm->slave_cur_window_widening);
     sch->end_time = connsm->ce_end_time;
 
@@ -576,10 +576,10 @@ ble_ll_sched_adv_reschedule(struct ble_ll_sched_item *sch)
 
 /**
  * Remove a schedule element
- * 
- * @param sched_type 
- * 
- * @return int 
+ *
+ * @param sched_type
+ *
+ * @return int
  */
 void
 ble_ll_sched_rmv_elem(struct ble_ll_sched_item *sch)
@@ -612,12 +612,12 @@ ble_ll_sched_rmv_elem(struct ble_ll_sched_item *sch)
 }
 
 /**
- * Executes a schedule item by calling the schedule callback function. 
- *  
- * Context: Interrupt 
- * 
+ * Executes a schedule item by calling the schedule callback function.
+ *
+ * Context: Interrupt
+ *
  * @param sch Pointer to schedule item
- * 
+ *
  * @return int 0: schedule item is not over; otherwise schedule item is done.
  */
 static int
@@ -626,7 +626,7 @@ ble_ll_sched_execute_item(struct ble_ll_sched_item *sch)
     int rc;
     uint8_t lls;
 
-    /* 
+    /*
      * This is either an advertising event or connection event start. If
      * we are scanning or initiating just stop it.
      */
@@ -635,7 +635,7 @@ ble_ll_sched_execute_item(struct ble_ll_sched_item *sch)
         /* We have to disable the PHY no matter what */
         ble_phy_disable();
         ble_ll_wfr_disable();
-        if ((lls == BLE_LL_STATE_SCANNING) || 
+        if ((lls == BLE_LL_STATE_SCANNING) ||
             (lls == BLE_LL_STATE_INITIATING)) {
             ble_ll_state_set(BLE_LL_STATE_STANDBY);
         } else if (lls == BLE_LL_STATE_ADV) {
@@ -654,10 +654,10 @@ ble_ll_sched_execute_item(struct ble_ll_sched_item *sch)
 
 /**
  * Run the BLE scheduler. Iterate through all items on the schedule queue.
- *  
- * Context: interrupt (scheduler) 
- * 
- * @return int 
+ *
+ * Context: interrupt (scheduler)
+ *
+ * @return int
  */
 void
 ble_ll_sched_run(void *arg)
@@ -680,14 +680,14 @@ ble_ll_sched_run(void *arg)
 }
 
 /**
- * Called to determine when the next scheduled event will occur. 
- *  
- * If there are not scheduled events this function returns 0; otherwise it 
- * returns 1 and *next_event_time is set to the start time of the next event. 
- * 
- * @param next_event_time 
- * 
- * @return int 0: No events are scheduled 1: there is an upcoming event 
+ * Called to determine when the next scheduled event will occur.
+ *
+ * If there are not scheduled events this function returns 0; otherwise it
+ * returns 1 and *next_event_time is set to the start time of the next event.
+ *
+ * @param next_event_time
+ *
+ * @return int 0: No events are scheduled 1: there is an upcoming event
  */
 int
 ble_ll_sched_next_time(uint32_t *next_event_time)
@@ -710,8 +710,8 @@ ble_ll_sched_next_time(uint32_t *next_event_time)
 
 /**
  * Stop the scheduler
- *  
- * Context: Link Layer task 
+ *
+ * Context: Link Layer task
  */
 void
 ble_ll_sched_stop(void)
@@ -720,10 +720,10 @@ ble_ll_sched_stop(void)
 }
 
 /**
- * Initialize the scheduler. Should only be called once and should be called 
- * before any of the scheduler API are called. 
- * 
- * @return int 
+ * Initialize the scheduler. Should only be called once and should be called
+ * before any of the scheduler API are called.
+ *
+ * @return int
  */
 int
 ble_ll_sched_init(void)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_supp_cmd.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_supp_cmd.c b/net/nimble/controller/src/ble_ll_supp_cmd.c
index 5d93036..68a9fd5 100644
--- a/net/nimble/controller/src/ble_ll_supp_cmd.c
+++ b/net/nimble/controller/src/ble_ll_supp_cmd.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -167,21 +167,21 @@
 const uint8_t g_ble_ll_supp_cmds[BLE_LL_SUPP_CMD_LEN] =
 {
     BLE_LL_SUPP_CMD_OCTET_0,            /* Octet 0 */
-    0, 
-    0, 
-    0, 
-    0, 
-    BLE_LL_SUPP_CMD_OCTET_5, 
-    0, 
+    0,
+    0,
+    0,
+    0,
+    BLE_LL_SUPP_CMD_OCTET_5,
+    0,
     0,
     0,                                  /* Octet 8 */
-    0, 
-    BLE_LL_SUPP_CMD_OCTET_10, 
-    0, 
-    0, 
-    0, 
-    BLE_LL_SUPP_CMD_OCTET_14, 
-    BLE_LL_SUPP_CMD_OCTET_15, 
+    0,
+    BLE_LL_SUPP_CMD_OCTET_10,
+    0,
+    0,
+    0,
+    BLE_LL_SUPP_CMD_OCTET_14,
+    BLE_LL_SUPP_CMD_OCTET_15,
     0,                                  /* Octet 16 */
     0,
     0,

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/controller/src/ble_ll_whitelist.c
----------------------------------------------------------------------
diff --git a/net/nimble/controller/src/ble_ll_whitelist.c b/net/nimble/controller/src/ble_ll_whitelist.c
index e5cce12..5ee3e84 100644
--- a/net/nimble/controller/src/ble_ll_whitelist.c
+++ b/net/nimble/controller/src/ble_ll_whitelist.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -43,7 +43,7 @@ ble_ll_whitelist_chg_allowed(void)
 {
     int rc;
 
-    /* 
+    /*
      * This command is not allowed if:
      *  -> advertising uses the whitelist and we are currently advertising.
      *  -> scanning uses the whitelist and is enabled.
@@ -59,8 +59,8 @@ ble_ll_whitelist_chg_allowed(void)
 
 /**
  * Clear the whitelist.
- * 
- * @return int 0: success, BLE error code otherwise 
+ *
+ * @return int 0: success, BLE error code otherwise
  */
 int
 ble_ll_whitelist_clear(void)
@@ -89,11 +89,11 @@ ble_ll_whitelist_clear(void)
 }
 
 /**
- * Read the size of the whitelist. This is the total number of whitelist 
- * entries allowed by the controller. 
- * 
+ * Read the size of the whitelist. This is the total number of whitelist
+ * entries allowed by the controller.
+ *
  * @param rspbuf Pointer to response buffer
- * 
+ *
  * @return int 0: success.
  */
 int
@@ -110,14 +110,14 @@ ble_ll_whitelist_read_size(uint8_t *rspbuf, uint8_t *rsplen)
 
 #ifndef BLE_USES_HW_WHITELIST
 /**
- * Used to determine if the device is on the whitelist. 
- * 
- * @param addr 
+ * Used to determine if the device is on the whitelist.
+ *
+ * @param addr
  * @param addr_type Public address (0) or random address (1)
- * 
- * @return int 0: device is not on whitelist; otherwise the return value 
- * is the 'position' of the device in the whitelist (the index of the element 
- * plus 1). 
+ *
+ * @return int 0: device is not on whitelist; otherwise the return value
+ * is the 'position' of the device in the whitelist (the index of the element
+ * plus 1).
  */
 static int
 ble_ll_is_on_whitelist(uint8_t *addr, uint8_t addr_type)
@@ -139,12 +139,12 @@ ble_ll_is_on_whitelist(uint8_t *addr, uint8_t addr_type)
 #endif
 
 /**
- * Is there a match between the device and a device on the whitelist 
- * 
- * @param addr 
+ * Is there a match between the device and a device on the whitelist
+ *
+ * @param addr
  * @param addr_type Public address (0) or random address (1)
- * 
- * @return int 
+ *
+ * @return int
  */
 int
 ble_ll_whitelist_match(uint8_t *addr, uint8_t addr_type)
@@ -159,9 +159,9 @@ ble_ll_whitelist_match(uint8_t *addr, uint8_t addr_type)
 }
 
 /**
- * Add a device to the whitelist 
- * 
- * @return int 
+ * Add a device to the whitelist
+ *
+ * @return int
  */
 int
 ble_ll_whitelist_add(uint8_t *addr, uint8_t addr_type)
@@ -203,10 +203,10 @@ ble_ll_whitelist_add(uint8_t *addr, uint8_t addr_type)
 }
 
 /**
- * Remove a device from the whitelist 
- * 
- * @param cmdbuf 
- * 
+ * Remove a device from the whitelist
+ *
+ * @param cmdbuf
+ *
  * @return int 0: success, BLE error code otherwise
  */
 int
@@ -232,8 +232,8 @@ ble_ll_whitelist_rmv(uint8_t *addr, uint8_t addr_type)
 }
 
 /**
- * Enable whitelisting. 
- *  
+ * Enable whitelisting.
+ *
  * Note: This function has no effect if we are not using HW whitelisting
  */
 void
@@ -246,7 +246,7 @@ ble_ll_whitelist_enable(void)
 
 /**
  * Disable whitelisting.
- *  
+ *
  * Note: This function has no effect if we are not using HW whitelisting
  */
 void

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/drivers/native/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/native/src/ble_phy.c b/net/nimble/drivers/native/src/ble_phy.c
index d96d5e2..3cdca69 100644
--- a/net/nimble/drivers/native/src/ble_phy.c
+++ b/net/nimble/drivers/native/src/ble_phy.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -75,11 +75,11 @@ static struct xcvr_data g_xcvr_data;
 #define BLE_XCVR_TX_PWR_MIN_DBM     (-20)
 
 /* XXX: TODO:
- 
+
  * 1) Test the following to make sure it works: suppose an event is already
  * set to 1 and the interrupt is not enabled. What happens if you enable the
- * interrupt with the event bit already set to 1  
- * 2) how to deal with interrupts? 
+ * interrupt with the event bit already set to 1
+ * 2) how to deal with interrupts?
  */
 static uint32_t
 ble_xcvr_get_irq_status(void)
@@ -95,9 +95,9 @@ ble_xcvr_clear_irq(uint32_t mask)
 
 /**
  * ble phy rxpdu get
- *  
- * Gets a mbuf for PDU reception. 
- * 
+ *
+ * Gets a mbuf for PDU reception.
+ *
  * @return struct os_mbuf* Pointer to retrieved mbuf or NULL if none available
  */
 static struct os_mbuf *
@@ -210,10 +210,10 @@ ble_phy_isr(void)
 }
 
 /**
- * ble phy init 
- *  
- * Initialize the PHY. This is expected to be called once. 
- * 
+ * ble phy init
+ *
+ * Initialize the PHY. This is expected to be called once.
+ *
  * @return int 0: success; PHY error code otherwise
  */
 int
@@ -228,7 +228,7 @@ ble_phy_init(void)
     return 0;
 }
 
-int 
+int
 ble_phy_rx(void)
 {
     /* Check radio state */
@@ -294,7 +294,7 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t beg_trans, uint8_t end_trans)
         /* Set phy state to transmitting and count packet statistics */
         g_ble_phy_data.phy_state = BLE_PHY_STATE_TX;
         ++g_ble_phy_stats.tx_good;
-        g_ble_phy_stats.tx_bytes += OS_MBUF_PKTHDR(txpdu)->omp_len + 
+        g_ble_phy_stats.tx_bytes += OS_MBUF_PKTHDR(txpdu)->omp_len +
             BLE_LL_PDU_HDR_LEN;
         rc = BLE_ERR_SUCCESS;
     } else {
@@ -308,16 +308,16 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t beg_trans, uint8_t end_trans)
 }
 
 /**
- * ble phy txpwr set 
- *  
- * Set the transmit output power (in dBm). 
- *  
- * NOTE: If the output power specified is within the BLE limits but outside 
- * the chip limits, we "rail" the power level so we dont exceed the min/max 
- * chip values. 
- * 
+ * ble phy txpwr set
+ *
+ * Set the transmit output power (in dBm).
+ *
+ * NOTE: If the output power specified is within the BLE limits but outside
+ * the chip limits, we "rail" the power level so we dont exceed the min/max
+ * chip values.
+ *
  * @param dbm Power output in dBm.
- * 
+ *
  * @return int 0: success; anything else is an error
  */
 int
@@ -342,9 +342,9 @@ ble_phy_txpwr_set(int dbm)
 
 /**
  * ble phy txpwr get
- *  
- * Get the transmit power. 
- * 
+ *
+ * Get the transmit power.
+ *
  * @return int  The current PHY transmit power, in dBm
  */
 int
@@ -354,17 +354,17 @@ ble_phy_txpwr_get(void)
 }
 
 /**
- * ble phy setchan 
- *  
- * Sets the logical frequency of the transceiver. The input parameter is the 
- * BLE channel index (0 to 39, inclusive). The NRF52 frequency register 
- * works like this: logical frequency = 2400 + FREQ (MHz). 
- *  
- * Thus, to get a logical frequency of 2402 MHz, you would program the 
- * FREQUENCY register to 2. 
- * 
+ * ble phy setchan
+ *
+ * Sets the logical frequency of the transceiver. The input parameter is the
+ * BLE channel index (0 to 39, inclusive). The NRF52 frequency register
+ * works like this: logical frequency = 2400 + FREQ (MHz).
+ *
+ * Thus, to get a logical frequency of 2402 MHz, you would program the
+ * FREQUENCY register to 2.
+ *
  * @param chan This is the Data Channel Index or Advertising Channel index
- * 
+ *
  * @return int 0: success; PHY error code otherwise
  */
 int
@@ -389,7 +389,7 @@ ble_phy_setchan(uint8_t chan, uint32_t access_addr, uint32_t crcinit)
 }
 
 /**
- * Disable the PHY. This will do the following: 
+ * Disable the PHY. This will do the following:
  *  -> Turn off all phy interrupts.
  *  -> Disable internal shortcuts.
  *  -> Disable the radio.
@@ -409,19 +409,19 @@ uint32_t ble_phy_access_addr_get(void)
 
 /**
  * Return the phy state
- * 
+ *
  * @return int The current PHY state.
  */
-int 
+int
 ble_phy_state_get(void)
 {
     return g_ble_phy_data.phy_state;
 }
 
 /**
- * Called to see if a reception has started 
- * 
- * @return int 
+ * Called to see if a reception has started
+ *
+ * @return int
  */
 int
 ble_phy_rx_started(void)

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/bfcc17d5/net/nimble/drivers/nrf51/src/ble_phy.c
----------------------------------------------------------------------
diff --git a/net/nimble/drivers/nrf51/src/ble_phy.c b/net/nimble/drivers/nrf51/src/ble_phy.c
index e178832..52bdf94 100644
--- a/net/nimble/drivers/nrf51/src/ble_phy.c
+++ b/net/nimble/drivers/nrf51/src/ble_phy.c
@@ -6,7 +6,7 @@
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *  http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
@@ -31,7 +31,7 @@
 /* To disable all radio interrupts */
 #define NRF51_RADIO_IRQ_MASK_ALL    (0x34FF)
 
-/* 
+/*
  * We configure the nrf52 with a 1 byte S0 field, 8 bit length field, and
  * zero bit S1 field. The preamble is 8 bits long.
  */
@@ -82,8 +82,8 @@ struct ble_phy_statistics
 
 struct ble_phy_statistics g_ble_phy_stats;
 
-/* 
- * NOTE: 
+/*
+ * NOTE:
  * Tested the following to see what would happen:
  *  -> NVIC has radio irq enabled (interrupt # 1, mask 0x2).
  *  -> Set up nrf52 to receive. Clear ADDRESS event register.
@@ -92,11 +92,11 @@ struct ble_phy_statistics g_ble_phy_stats;
  *  -> Disable interrupts globally using OS_ENTER_CRITICAL().
  *  -> Wait until a packet is received and the ADDRESS event occurs.
  *  -> Call ble_phy_disable().
- * 
+ *
  *  At this point I wanted to see the state of the cortex NVIC. The IRQ
  *  pending bit was TRUE for the radio interrupt (as expected) as we never
  *  serviced the radio interrupt (interrupts were disabled).
- * 
+ *
  *  What was unexpected was this: without clearing the pending IRQ in the NVIC,
  *  when radio interrupts were re-enabled (address event bit in INTENSET set to
  *  1) and the radio ADDRESS event register read 1 (it was never cleared after
@@ -106,16 +106,16 @@ struct ble_phy_statistics g_ble_phy_stats;
  *      -> NVIC ISPR bit reads TRUE, meaning interrupt is pending.
  *      -> Radio peripheral interrupts are enabled for some event (or events).
  *      -> Corresponding event register(s) in radio peripheral read 1.
- * 
+ *
  *  Not sure what the end result of all this is. We will clear the pending
  *  bit in the NVIC just to be sure when we disable the PHY.
  */
 
 /**
  * ble phy rxpdu get
- *  
- * Gets a mbuf for PDU reception. 
- * 
+ *
+ * Gets a mbuf for PDU reception.
+ *
  * @return struct os_mbuf* Pointer to retrieved mbuf or NULL if none available
  */
 static struct os_mbuf *
@@ -129,7 +129,7 @@ ble_phy_rxpdu_get(void)
         if (!m) {
             ++g_ble_phy_stats.no_bufs;
         } else {
-            /* 
+            /*
              * NOTE: we add two bytes to the data pointer as we will prepend
              * two bytes if we hand this received pdu up to host.
              */
@@ -179,7 +179,7 @@ ble_phy_isr(void)
         /* Better be in TX state! */
         assert(g_ble_phy_data.phy_state == BLE_PHY_STATE_TX);
 
-        ble_ll_log(BLE_LL_LOG_ID_PHY_TXEND, (g_ble_phy_txrx_buf[0] >> 8) & 0xFF, 
+        ble_ll_log(BLE_LL_LOG_ID_PHY_TXEND, (g_ble_phy_txrx_buf[0] >> 8) & 0xFF,
                    0, NRF_TIMER0->CC[2]);
 
         /* Clear events and clear interrupt on disabled event */
@@ -203,7 +203,7 @@ ble_phy_isr(void)
                 NRF_RADIO->EVENTS_DEVMATCH = 0;
                 NRF_RADIO->EVENTS_BCMATCH = 0;
                 NRF_RADIO->EVENTS_RSSIEND = 0;
-                NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk | 
+                NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk |
                                     RADIO_SHORTS_READY_START_Msk |
                                     RADIO_SHORTS_ADDRESS_BCSTART_Msk |
                                     RADIO_SHORTS_ADDRESS_RSSISTART_Msk |
@@ -217,10 +217,10 @@ ble_phy_isr(void)
                 ble_phy_disable();
             }
 
-            /* 
+            /*
              * Enable the wait for response timer. Note that cc #2 on
              * timer 0 contains the transmit end time
-             */ 
+             */
             wfr_time = NRF_TIMER0->CC[2];
             wfr_time += cputime_usecs_to_ticks(BLE_LL_WFR_USECS);
             ble_ll_wfr_enable(wfr_time);
@@ -250,10 +250,10 @@ ble_phy_isr(void)
                 break;
             }
 
-            /* 
+            /*
              * If state is disabled, we should have the BCMATCH. If not,
              * something is wrong!
-             */ 
+             */
             if (state == RADIO_STATE_STATE_Disabled) {
                 NRF_RADIO->INTENCLR = NRF51_RADIO_IRQ_MASK_ALL;
                 NRF_RADIO->SHORTS = 0;
@@ -273,11 +273,11 @@ ble_phy_isr(void)
             g_ble_phy_data.phy_rx_started = 1;
             if (rc > 0) {
                 /* We need to go from disabled to TXEN */
-                NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk | 
+                NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk |
                                     RADIO_SHORTS_READY_START_Msk |
                                     RADIO_SHORTS_DISABLED_TXEN_Msk;
             } else {
-                NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk | 
+                NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk |
                                     RADIO_SHORTS_READY_START_Msk;
             }
 
@@ -334,10 +334,10 @@ phy_isr_exit:
 }
 
 /**
- * ble phy init 
- *  
- * Initialize the PHY. This is expected to be called once. 
- * 
+ * ble phy init
+ *
+ * Initialize the PHY. This is expected to be called once.
+ *
  * @return int 0: success; PHY error code otherwise
  */
 int
@@ -372,7 +372,7 @@ ble_phy_init(void)
     NRF_RADIO->MODE = RADIO_MODE_MODE_Ble_1Mbit;
     NRF_RADIO->PCNF0 = (NRF51_LFLEN_BITS << RADIO_PCNF0_LFLEN_Pos) |
                        (NRF51_S0_LEN << RADIO_PCNF0_S0LEN_Pos);
-    NRF_RADIO->PCNF1 = NRF51_MAXLEN | 
+    NRF_RADIO->PCNF1 = NRF51_MAXLEN |
                        (RADIO_PCNF1_ENDIAN_Little <<  RADIO_PCNF1_ENDIAN_Pos) |
                        (NRF51_BALEN << RADIO_PCNF1_BALEN_Pos) |
                        RADIO_PCNF1_WHITEEN_Msk;
@@ -390,10 +390,10 @@ ble_phy_init(void)
     /* Configure IFS */
     NRF_RADIO->TIFS = BLE_LL_IFS;
 
-    /* 
+    /*
      * Enable the pre-programmed PPI to capture the time when a receive
      * or transmit ends
-     */ 
+     */
     NRF_PPI->CHENSET = PPI_CHEN_CH27_Msk;
 
     /* Set isr in vector table and enable interrupt */
@@ -404,7 +404,7 @@ ble_phy_init(void)
     return 0;
 }
 
-int 
+int
 ble_phy_rx(void)
 {
     /* Check radio state */
@@ -436,7 +436,7 @@ ble_phy_rx(void)
 
     /* I want to know when 1st byte received (after address) */
     NRF_RADIO->BCC = 8; /* in bits */
-    NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk | 
+    NRF_RADIO->SHORTS = RADIO_SHORTS_END_DISABLE_Msk |
                         RADIO_SHORTS_READY_START_Msk |
                         RADIO_SHORTS_ADDRESS_BCSTART_Msk |
                         RADIO_SHORTS_ADDRESS_RSSISTART_Msk |
@@ -533,13 +533,13 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t beg_trans, uint8_t end_trans)
     state = NRF_RADIO->STATE;
     if (state == RADIO_STATE_STATE_TxRu) {
         /* Copy data from mbuf into transmit buffer */
-        os_mbuf_copydata(txpdu, ble_hdr->txinfo.offset, 
+        os_mbuf_copydata(txpdu, ble_hdr->txinfo.offset,
                          ble_hdr->txinfo.pyld_len, dptr);
 
         /* Set phy state to transmitting and count packet statistics */
         g_ble_phy_data.phy_state = BLE_PHY_STATE_TX;
         ++g_ble_phy_stats.tx_good;
-        g_ble_phy_stats.tx_bytes += ble_hdr->txinfo.pyld_len + 
+        g_ble_phy_stats.tx_bytes += ble_hdr->txinfo.pyld_len +
             BLE_LL_PDU_HDR_LEN;
         rc = BLE_ERR_SUCCESS;
     } else {
@@ -558,16 +558,16 @@ ble_phy_tx(struct os_mbuf *txpdu, uint8_t beg_trans, uint8_t end_trans)
 }
 
 /**
- * ble phy txpwr set 
- *  
- * Set the transmit output power (in dBm). 
- *  
- * NOTE: If the output power specified is within the BLE limits but outside 
- * the chip limits, we "rail" the power level so we dont exceed the min/max 
- * chip values. 
- * 
+ * ble phy txpwr set
+ *
+ * Set the transmit output power (in dBm).
+ *
+ * NOTE: If the output power specified is within the BLE limits but outside
+ * the chip limits, we "rail" the power level so we dont exceed the min/max
+ * chip values.
+ *
  * @param dbm Power output in dBm.
- * 
+ *
  * @return int 0: success; anything else is an error
  */
 int
@@ -593,9 +593,9 @@ ble_phy_txpwr_set(int dbm)
 
 /**
  * ble phy txpwr get
- *  
- * Get the transmit power. 
- * 
+ *
+ * Get the transmit power.
+ *
  * @return int  The current PHY transmit power, in dBm
  */
 int
@@ -605,17 +605,17 @@ ble_phy_txpwr_get(void)
 }
 
 /**
- * ble phy setchan 
- *  
- * Sets the logical frequency of the transceiver. The input parameter is the 
- * BLE channel index (0 to 39, inclusive). The NRF51 frequency register works 
- * like this: logical frequency = 2400 + FREQ (MHz). 
- *  
- * Thus, to get a logical frequency of 2402 MHz, you would program the 
- * FREQUENCY register to 2. 
- * 
+ * ble phy setchan
+ *
+ * Sets the logical frequency of the transceiver. The input parameter is the
+ * BLE channel index (0 to 39, inclusive). The NRF51 frequency register works
+ * like this: logical frequency = 2400 + FREQ (MHz).
+ *
+ * Thus, to get a logical frequency of 2402 MHz, you would program the
+ * FREQUENCY register to 2.
+ *
  * @param chan This is the Data Channel Index or Advertising Channel index
- * 
+ *
  * @return int 0: success; PHY error code otherwise
  */
 int
@@ -635,11 +635,11 @@ ble_phy_setchan(uint8_t chan, uint32_t access_addr, uint32_t crcinit)
     if (chan < BLE_PHY_NUM_DATA_CHANS) {
         if (chan < 11) {
             /* Data channel 0 starts at 2404. 0 - 10 are contiguous */
-            freq = (BLE_PHY_DATA_CHAN0_FREQ_MHZ - 2400) + 
+            freq = (BLE_PHY_DATA_CHAN0_FREQ_MHZ - 2400) +
                    (BLE_PHY_CHAN_SPACING_MHZ * chan);
         } else {
             /* Data channel 11 starts at 2428. 0 - 10 are contiguous */
-            freq = (BLE_PHY_DATA_CHAN0_FREQ_MHZ - 2400) + 
+            freq = (BLE_PHY_DATA_CHAN0_FREQ_MHZ - 2400) +
                    (BLE_PHY_CHAN_SPACING_MHZ * (chan + 1));
         }
 
@@ -686,7 +686,7 @@ ble_phy_setchan(uint8_t chan, uint32_t access_addr, uint32_t crcinit)
 }
 
 /**
- * Disable the PHY. This will do the following: 
+ * Disable the PHY. This will do the following:
  *  -> Turn off all phy interrupts.
  *  -> Disable internal shortcuts.
  *  -> Disable the radio.
@@ -714,19 +714,19 @@ uint32_t ble_phy_access_addr_get(void)
 
 /**
  * Return the phy state
- * 
+ *
  * @return int The current PHY state.
  */
-int 
+int
 ble_phy_state_get(void)
 {
     return g_ble_phy_data.phy_state;
 }
 
 /**
- * Called to see if a reception has started 
- * 
- * @return int 
+ * Called to see if a reception has started
+ *
+ * @return int
  */
 int
 ble_phy_rx_started(void)