diff options
author | Sharvil Nanavati <sharvil@google.com> | 2014-04-26 00:58:15 -0700 |
---|---|---|
committer | Sharvil Nanavati <sharvil@google.com> | 2014-05-08 03:36:20 +0000 |
commit | 1671598d31090ad045f2ca982fbb0a7d486521f3 (patch) | |
tree | eb93c187035a98a2402c154ead7d21967c2e37fe /hci | |
parent | d9e5b3490bf41f912823af920cc616e57e0fec28 (diff) | |
download | android_system_bt-1671598d31090ad045f2ca982fbb0a7d486521f3.tar.gz android_system_bt-1671598d31090ad045f2ca982fbb0a7d486521f3.tar.bz2 android_system_bt-1671598d31090ad045f2ca982fbb0a7d486521f3.zip |
Minor cleanup of userial code.
Change-Id: Ib8b094196f2de1515f79f17c4b87eb05f4c113dc
Diffstat (limited to 'hci')
-rw-r--r-- | hci/include/userial.h | 81 | ||||
-rw-r--r-- | hci/src/bt_hci_bdroid.c | 3 | ||||
-rw-r--r-- | hci/src/userial.c | 38 | ||||
-rw-r--r-- | hci/src/userial_mct.c | 35 |
4 files changed, 55 insertions, 102 deletions
diff --git a/hci/include/userial.h b/hci/include/userial.h index d3a5480c7..f04111bbf 100644 --- a/hci/include/userial.h +++ b/hci/include/userial.h @@ -24,61 +24,45 @@ * ******************************************************************************/ -#ifndef USERIAL_H -#define USERIAL_H +#pragma once -/****************************************************************************** -** Constants & Macros -******************************************************************************/ +#include <stdbool.h> +#include <stdint.h> -/**** port IDs ****/ -#define USERIAL_PORT_1 0 -#define USERIAL_PORT_2 1 -#define USERIAL_PORT_3 2 -#define USERIAL_PORT_4 3 -#define USERIAL_PORT_5 4 -#define USERIAL_PORT_6 5 -#define USERIAL_PORT_7 6 -#define USERIAL_PORT_8 7 -#define USERIAL_PORT_9 8 -#define USERIAL_PORT_10 9 -#define USERIAL_PORT_11 10 -#define USERIAL_PORT_12 11 -#define USERIAL_PORT_13 12 -#define USERIAL_PORT_14 13 -#define USERIAL_PORT_15 14 -#define USERIAL_PORT_16 15 -#define USERIAL_PORT_17 16 -#define USERIAL_PORT_18 17 +typedef enum { + USERIAL_PORT_1, + USERIAL_PORT_2, + USERIAL_PORT_3, + USERIAL_PORT_4, + USERIAL_PORT_5, + USERIAL_PORT_6, + USERIAL_PORT_7, + USERIAL_PORT_8, + USERIAL_PORT_9, + USERIAL_PORT_10, + USERIAL_PORT_11, + USERIAL_PORT_12, + USERIAL_PORT_13, + USERIAL_PORT_14, + USERIAL_PORT_15, + USERIAL_PORT_16, + USERIAL_PORT_17, + USERIAL_PORT_18, +} userial_port_t; typedef enum { - USERIAL_OP_INIT, USERIAL_OP_RXFLOW_ON, USERIAL_OP_RXFLOW_OFF, } userial_ioctl_op_t; -/****************************************************************************** -** Type definitions -******************************************************************************/ - -/****************************************************************************** -** Extern variables and functions -******************************************************************************/ - -/****************************************************************************** -** Functions -******************************************************************************/ - /******************************************************************************* ** ** Function userial_init ** ** Description Initializes the userial driver ** -** Returns TRUE/FALSE -** *******************************************************************************/ -uint8_t userial_init(void); +bool userial_init(void); /******************************************************************************* ** @@ -86,10 +70,8 @@ uint8_t userial_init(void); ** ** Description Open Bluetooth device with the port ID ** -** Returns TRUE/FALSE -** *******************************************************************************/ -uint8_t userial_open(uint8_t port); +bool userial_open(userial_port_t port); /******************************************************************************* ** @@ -101,7 +83,7 @@ uint8_t userial_open(uint8_t port); ** copied into p_data. This may be less than len. ** *******************************************************************************/ -uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len); +uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len); /******************************************************************************* ** @@ -113,7 +95,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len); ** may be less than len. ** *******************************************************************************/ -uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len); +uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len); /******************************************************************************* ** @@ -121,8 +103,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len); ** ** Description Close the userial port ** -** Returns None -** *******************************************************************************/ void userial_close(void); @@ -132,10 +112,5 @@ void userial_close(void); ** ** Description ioctl inteface ** -** Returns None -** *******************************************************************************/ -void userial_ioctl(userial_ioctl_op_t op, void *p_data); - -#endif /* USERIAL_H */ - +void userial_ioctl(userial_ioctl_op_t op); diff --git a/hci/src/bt_hci_bdroid.c b/hci/src/bt_hci_bdroid.c index ed98b3798..c5360adff 100644 --- a/hci/src/bt_hci_bdroid.c +++ b/hci/src/bt_hci_bdroid.c @@ -337,8 +337,7 @@ static int set_rxflow(bt_rx_flow_state_t state) BTHCDBG("set_rxflow %d", state); userial_ioctl(\ - ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF), \ - NULL); + ((state == BT_RXFLOW_ON) ? USERIAL_OP_RXFLOW_ON : USERIAL_OP_RXFLOW_OFF)); return BT_HC_STATUS_SUCCESS; } diff --git a/hci/src/userial.c b/hci/src/userial.c index 5dc4f847b..00ddef954 100644 --- a/hci/src/userial.c +++ b/hci/src/userial.c @@ -313,29 +313,24 @@ static void *userial_read_thread(void *arg) ** ** Description Initializes the userial driver ** -** Returns TRUE/FALSE -** *******************************************************************************/ -uint8_t userial_init(void) +bool userial_init(void) { USERIALDBG("userial_init"); memset(&userial_cb, 0, sizeof(tUSERIAL_CB)); userial_cb.fd = -1; utils_queue_init(&(userial_cb.rx_q)); - return TRUE; + return true; } - /******************************************************************************* ** ** Function userial_open ** ** Description Open Bluetooth device with the port ID ** -** Returns TRUE/FALSE -** *******************************************************************************/ -uint8_t userial_open(uint8_t port) +bool userial_open(userial_port_t port) { struct sched_param param; int policy, result; @@ -354,7 +349,7 @@ uint8_t userial_open(uint8_t port) if (port >= MAX_SERIAL_PORT) { ALOGE("Port > MAX_SERIAL_PORT"); - return FALSE; + return false; } /* Calling vendor-specific part */ @@ -368,7 +363,7 @@ uint8_t userial_open(uint8_t port) result); ALOGE("userial_open: HCI UART expects only one open fd"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); - return FALSE; + return false; } userial_cb.fd = fd_array[0]; @@ -377,13 +372,13 @@ uint8_t userial_open(uint8_t port) { ALOGE("userial_open: missing vendor lib interface !!!"); ALOGE("userial_open: unable to open UART port"); - return FALSE; + return false; } if (userial_cb.fd == -1) { ALOGE("userial_open: failed to open UART port"); - return FALSE; + return false; } USERIALDBG( "fd = %d", userial_cb.fd); @@ -396,7 +391,7 @@ uint8_t userial_open(uint8_t port) userial_read_thread, NULL) != 0 ) { ALOGE("pthread_create failed!"); - return FALSE; + return false; } if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0) @@ -415,7 +410,7 @@ uint8_t userial_open(uint8_t port) } } - return TRUE; + return true; } /******************************************************************************* @@ -428,7 +423,7 @@ uint8_t userial_open(uint8_t port) ** copied into p_data. This may be less than len. ** *******************************************************************************/ -uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) +uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) { uint16_t total_len = 0; uint16_t copy_len = 0; @@ -483,7 +478,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) ** may be less than len. ** *******************************************************************************/ -uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) +uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len) { int ret, total = 0; UNUSED(msg_id); @@ -507,8 +502,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) ** ** Description Close the userial port ** -** Returns None -** *******************************************************************************/ void userial_close(void) { @@ -544,13 +537,9 @@ void userial_close(void) ** ** Description ioctl inteface ** -** Returns None -** *******************************************************************************/ -void userial_ioctl(userial_ioctl_op_t op, void *p_data) +void userial_ioctl(userial_ioctl_op_t op) { - UNUSED(p_data); - switch(op) { case USERIAL_OP_RXFLOW_ON: @@ -563,9 +552,8 @@ void userial_ioctl(userial_ioctl_op_t op, void *p_data) send_wakeup_signal(USERIAL_RX_FLOW_OFF); break; - case USERIAL_OP_INIT: default: + ALOGE("%s invalid operation: %d", __func__, op); break; } } - diff --git a/hci/src/userial_mct.c b/hci/src/userial_mct.c index d7554ccf8..3c4f09f1f 100644 --- a/hci/src/userial_mct.c +++ b/hci/src/userial_mct.c @@ -226,10 +226,8 @@ static void *userial_read_thread(void *arg) ** ** Description Initializes the userial driver ** -** Returns TRUE/FALSE -** *******************************************************************************/ -uint8_t userial_init(void) +bool userial_init(void) { int idx; @@ -238,7 +236,7 @@ uint8_t userial_init(void) for (idx=0; idx < CH_MAX; idx++) userial_cb.fd[idx] = -1; utils_queue_init(&(userial_cb.rx_q)); - return TRUE; + return true; } @@ -248,10 +246,8 @@ uint8_t userial_init(void) ** ** Description Open Bluetooth device with the port ID ** -** Returns TRUE/FALSE -** *******************************************************************************/ -uint8_t userial_open(uint8_t port) +bool userial_open(userial_port_t port) { struct sched_param param; int policy, result; @@ -269,7 +265,7 @@ uint8_t userial_open(uint8_t port) if (port >= MAX_SERIAL_PORT) { ALOGE("Port > MAX_SERIAL_PORT"); - return FALSE; + return false; } /* Calling vendor-specific part */ @@ -283,14 +279,14 @@ uint8_t userial_open(uint8_t port) result); ALOGE("userial_open: HCI MCT expects 2 or 4 open file descriptors"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); - return FALSE; + return false; } } else { ALOGE("userial_open: missing vendor lib interface !!!"); ALOGE("userial_open: unable to open BT transport"); - return FALSE; + return false; } ALOGI("CMD=%d, EVT=%d, ACL_Out=%d, ACL_In=%d", \ @@ -302,7 +298,7 @@ uint8_t userial_open(uint8_t port) { ALOGE("userial_open: failed to open BT transport"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); - return FALSE; + return false; } userial_cb.port = port; @@ -315,7 +311,7 @@ uint8_t userial_open(uint8_t port) { ALOGE("pthread_create failed!"); bt_vnd_if->op(BT_VND_OP_USERIAL_CLOSE, NULL); - return FALSE; + return false; } if(pthread_getschedparam(userial_cb.read_thread, &policy, ¶m)==0) @@ -334,7 +330,7 @@ uint8_t userial_open(uint8_t port) } } - return TRUE; + return true; } /******************************************************************************* @@ -347,7 +343,7 @@ uint8_t userial_open(uint8_t port) ** copied into p_data. This may be less than len. ** *******************************************************************************/ -uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) +uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) { int ret = -1; int ch_idx = (msg_id == MSG_HC_TO_STACK_HCI_EVT) ? CH_EVT : CH_ACL_IN; @@ -369,7 +365,7 @@ uint16_t userial_read(uint16_t msg_id, uint8_t *p_buffer, uint16_t len) ** may be less than len. ** *******************************************************************************/ -uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) +uint16_t userial_write(uint16_t msg_id, const uint8_t *p_data, uint16_t len) { int ret, total = 0; int ch_idx = (msg_id == MSG_STACK_TO_HC_HCI_CMD) ? CH_CMD : CH_ACL_OUT; @@ -390,8 +386,6 @@ uint16_t userial_write(uint16_t msg_id, uint8_t *p_data, uint16_t len) ** ** Description Close the userial port ** -** Returns None -** *******************************************************************************/ void userial_close(void) { @@ -419,10 +413,8 @@ void userial_close(void) ** ** Description ioctl inteface ** -** Returns None -** *******************************************************************************/ -void userial_ioctl(userial_ioctl_op_t op, void *p_data) +void userial_ioctl(userial_ioctl_op_t op) { switch(op) { @@ -436,9 +428,8 @@ void userial_ioctl(userial_ioctl_op_t op, void *p_data) send_wakeup_signal(USERIAL_RX_FLOW_OFF); break; - case USERIAL_OP_INIT: default: + ALOGE("%s invalid operation: %d", __func__, op); break; } } - |