You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2022/10/02 21:14:10 UTC

[incubator-nuttx] 04/05: bluetooth: Implement hciuart_ioctl for btuart lowerhalf shim driver

This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit fe38cb1bada68d35cf7431db4dcf7965279fae93
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Sun Oct 2 03:50:45 2022 +0800

    bluetooth: Implement hciuart_ioctl for btuart lowerhalf shim driver
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
 drivers/wireless/bluetooth/bt_uart_shim.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/wireless/bluetooth/bt_uart_shim.c b/drivers/wireless/bluetooth/bt_uart_shim.c
index 4f86131754..fc96e63fcb 100644
--- a/drivers/wireless/bluetooth/bt_uart_shim.c
+++ b/drivers/wireless/bluetooth/bt_uart_shim.c
@@ -89,6 +89,8 @@ static ssize_t hciuart_read(FAR const struct btuart_lowerhalf_s *lower,
 static ssize_t hciuart_write(FAR const struct btuart_lowerhalf_s *lower,
                              FAR const void *buffer, size_t buflen);
 static ssize_t hciuart_rxdrain(FAR const struct btuart_lowerhalf_s *lower);
+static int hciuart_ioctl(FAR const struct btuart_lowerhalf_s *lower,
+                         int cmd, unsigned long arg);
 
 /****************************************************************************
  * Private Functions
@@ -188,12 +190,10 @@ static int
 hciuart_setbaud(FAR const struct btuart_lowerhalf_s *lower, uint32_t baud)
 {
 #ifdef CONFIG_SERIAL_TERMIOS
-  FAR struct hciuart_config_s *config = (FAR struct hciuart_config_s *)lower;
-  FAR struct hciuart_state_s *state = &config->state;
   struct termios tio;
   int ret;
 
-  ret = file_ioctl(&state->f, TCGETS, (long unsigned int)&tio);
+  ret = hciuart_ioctl(lower, TCGETS, (unsigned long)&tio);
   if (ret)
     {
       wlerr("ERROR during TCGETS\n");
@@ -209,7 +209,7 @@ hciuart_setbaud(FAR const struct btuart_lowerhalf_s *lower, uint32_t baud)
 
   tio.c_cflag |= CRTS_IFLOW | CCTS_OFLOW;
 
-  ret = file_ioctl(&state->f, TCSETS, (unsigned long int)&tio);
+  ret = hciuart_ioctl(lower, TCSETS, (unsigned long)&tio);
   if (ret)
     {
       wlerr("ERROR during TCSETS, does UART support CTS/RTS?\n");
@@ -285,11 +285,21 @@ hciuart_write(FAR const struct btuart_lowerhalf_s *lower,
  ****************************************************************************/
 
 static ssize_t hciuart_rxdrain(FAR const struct btuart_lowerhalf_s *lower)
+{
+  return hciuart_ioctl(lower, TCDRN, 0);
+}
+
+/****************************************************************************
+ * Name: hciuart_ioctl
+ ****************************************************************************/
+
+static int hciuart_ioctl(FAR const struct btuart_lowerhalf_s *lower,
+                         int cmd, unsigned long arg)
 {
   FAR struct hciuart_config_s *config = (FAR struct hciuart_config_s *)lower;
   FAR struct hciuart_state_s *s = &config->state;
 
-  return file_ioctl(&s->f, TCDRN, 0);
+  return file_ioctl(&s->f, cmd, arg);
 }
 
 /****************************************************************************
@@ -414,6 +424,7 @@ FAR struct btuart_lowerhalf_s *btuart_shim_getdevice(FAR const char *path)
   n->lower.read     = hciuart_read;
   n->lower.write    = hciuart_write;
   n->lower.rxdrain  = hciuart_rxdrain;
+  n->lower.ioctl    = hciuart_ioctl;
 
   /* Create the monitor thread */