Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 73a30cd9 authored by Andre Eisenbach's avatar Andre Eisenbach
Browse files

Remove "block" parameter from eager_reader_read()

Setting this parameter to true did not work and did not behave as
expected. The functionality provided by this parameter is also not
necessary, thus removing code.

Change-Id: I29e60da4adf1d1fc84d8ec9a590de89e94bb7900
parent 5b393052
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -57,10 +57,9 @@ typedef struct hci_hal_t {
  void (*close)(void);

  // Retrieve up to |max_size| bytes for ACL, SCO, or EVENT data packets into
  // |buffer|, blocking until max_size bytes read if |block| is true.
  // Only guaranteed to be correct in the context of a data_ready callback
  // of the corresponding type.
  size_t (*read_data)(serial_data_type_t type, uint8_t *buffer, size_t max_size, bool block);
  // |buffer|. Only guaranteed to be correct in the context of a data_ready
  // callback of the corresponding type.
  size_t (*read_data)(serial_data_type_t type, uint8_t *buffer, size_t max_size);
  // The upper layer must call this to notify the HAL that it has finished
  // reading a packet of the specified |type|. Underlying implementations that
  // use shared channels for multiple data types depend on this to know when
+3 −3
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ static void hal_close() {
  uart_fd = INVALID_FD;
}

static size_t read_data(serial_data_type_t type, uint8_t *buffer, size_t max_size, bool block) {
static size_t read_data(serial_data_type_t type, uint8_t *buffer, size_t max_size) {
  if (type < DATA_TYPE_ACL || type > DATA_TYPE_EVENT) {
    LOG_ERROR(LOG_TAG, "%s invalid data type: %d", __func__, type);
    return 0;
@@ -125,7 +125,7 @@ static size_t read_data(serial_data_type_t type, uint8_t *buffer, size_t max_siz
    return 0;
  }

  return eager_reader_read(uart_stream, buffer, max_size, block);
  return eager_reader_read(uart_stream, buffer, max_size);
}

static void packet_finished(serial_data_type_t type) {
@@ -223,7 +223,7 @@ static void event_uart_has_bytes(eager_reader_t *reader, UNUSED_ATTR void *conte
    callbacks->data_ready(current_data_type);
  } else {
    uint8_t type_byte;
    if (eager_reader_read(reader, &type_byte, 1, true) == 0) {
    if (eager_reader_read(reader, &type_byte, 1) == 0) {
      LOG_ERROR(LOG_TAG, "%s could not read HCI message type", __func__);
      return;
    }
+3 −3
Original line number Diff line number Diff line
@@ -126,11 +126,11 @@ static void hal_close() {
    uart_fds[i] = INVALID_FD;
}

static size_t read_data(serial_data_type_t type, uint8_t *buffer, size_t max_size, bool block) {
static size_t read_data(serial_data_type_t type, uint8_t *buffer, size_t max_size) {
  if (type == DATA_TYPE_ACL) {
    return eager_reader_read(acl_stream, buffer, max_size, block);
    return eager_reader_read(acl_stream, buffer, max_size);
  } else if (type == DATA_TYPE_EVENT) {
    return eager_reader_read(event_stream, buffer, max_size, block);
    return eager_reader_read(event_stream, buffer, max_size);
  }

  LOG_ERROR(LOG_TAG, "%s invalid data type: %d", __func__, type);
+2 −2
Original line number Diff line number Diff line
@@ -544,7 +544,7 @@ static void hal_says_data_ready(serial_data_type_t type) {
  packet_receive_data_t *incoming = &incoming_packets[PACKET_TYPE_TO_INBOUND_INDEX(type)];

  uint8_t byte;
  while (hal->read_data(type, &byte, 1, false) != 0) {
  while (hal->read_data(type, &byte, 1) != 0) {
    switch (incoming->state) {
      case BRAND_NEW:
        // Initialize and prepare to jump to the preamble reading state
@@ -587,7 +587,7 @@ static void hal_says_data_ready(serial_data_type_t type) {
        incoming->index++;
        incoming->bytes_remaining--;

        size_t bytes_read = hal->read_data(type, (incoming->buffer->data + incoming->index), incoming->bytes_remaining, false);
        size_t bytes_read = hal->read_data(type, (incoming->buffer->data + incoming->index), incoming->bytes_remaining);
        incoming->index += bytes_read;
        incoming->bytes_remaining -= bytes_read;

+2 −2
Original line number Diff line number Diff line
@@ -67,7 +67,7 @@ static void expect_packet_synchronous(serial_data_type_t type, char *packet_data
  int length = strlen(packet_data);
  for (int i = 0; i < length; i++) {
    uint8_t byte;
    EXPECT_EQ((size_t)1, hal->read_data(type, &byte, 1, true));
    EXPECT_EQ((size_t)1, hal->read_data(type, &byte, 1));
    EXPECT_EQ(packet_data[i], byte);
  }

@@ -116,7 +116,7 @@ STUB_FUNCTION(void, data_ready_callback, (serial_data_type_t type))

    uint8_t byte;
    size_t bytes_read;
    while ((bytes_read = hal->read_data(type, &byte, 1, false)) != 0) {
    while ((bytes_read = hal->read_data(type, &byte, 1)) != 0) {
      EXPECT_EQ(sample_data3[reentry_i], byte);
      semaphore_post(reentry_semaphore);
      reentry_i++;
Loading