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

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

commit 0fafd0bc7fb7827e05f35f8886c68f521849cd2c
Author: Erik Englund <[email protected]>
AuthorDate: Mon Sep 28 22:53:42 2026 +0200

    arch/risc-v/espressif: Fix nxstyle issues in esp_serial.c.
    
    Indent the case labels of the esp_ioctl() switch one level deeper, as
    nxstyle expects, fix the odd indentation of the TIOCSERGSTRUCT case
    and add the missing blank lines after declarations.  No functional
    change.
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: Erik Englund <[email protected]>
---
 arch/risc-v/src/common/espressif/esp_serial.c | 258 +++++++++++++-------------
 1 file changed, 130 insertions(+), 128 deletions(-)

diff --git a/arch/risc-v/src/common/espressif/esp_serial.c 
b/arch/risc-v/src/common/espressif/esp_serial.c
index c9f5c57c8e4..c23d3381c7f 100644
--- a/arch/risc-v/src/common/espressif/esp_serial.c
+++ b/arch/risc-v/src/common/espressif/esp_serial.c
@@ -987,190 +987,192 @@ static int esp_ioctl(struct file *filep, int cmd, 
unsigned long arg)
     {
 #ifdef CONFIG_SERIAL_TIOCSERGSTRUCT
 
-    /* Get the internal driver data structure for debug purposes */
-
-    case TIOCSERGSTRUCT:
-      {
-         struct esp_uart_s *user = (struct esp_uart_s *)arg;
-         if (user == NULL)
-           {
-             ret = -EINVAL;
-           }
-         else
-           {
-             memcpy(user, dev->priv, sizeof(struct esp_uart_s));
-           }
-       }
-       break;
+      /* Get the internal driver data structure for debug purposes */
+
+      case TIOCSERGSTRUCT:
+        {
+          struct esp_uart_s *user = (struct esp_uart_s *)arg;
+
+          if (user == NULL)
+            {
+              ret = -EINVAL;
+            }
+          else
+            {
+              memcpy(user, dev->priv, sizeof(struct esp_uart_s));
+            }
+        }
+        break;
 #endif
 
 #ifdef CONFIG_SERIAL_TERMIOS
 
-    /* Fill a termios structure with the required information */
+      /* Fill a termios structure with the required information */
 
-    case TCGETS:
-      {
-        struct termios *termiosp = (struct termios *)arg;
-        struct esp_uart_s *priv  = (struct esp_uart_s *)dev->priv;
-        if (termiosp == NULL)
-          {
-            ret = -EINVAL;
-            break;
-          }
+      case TCGETS:
+        {
+          struct termios *termiosp = (struct termios *)arg;
+          struct esp_uart_s *priv  = (struct esp_uart_s *)dev->priv;
 
-        /* Return parity (0 = no parity, 1 = odd parity, 2 = even parity) */
+          if (termiosp == NULL)
+            {
+              ret = -EINVAL;
+              break;
+            }
+
+          /* Return parity (0 = no parity, 1 = odd parity, 2 = even parity) */
 
-        termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
-                            ((priv->parity == 1) ? PARODD : 0);
+          termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
+                              ((priv->parity == 1) ? PARODD : 0);
 
-        /* Return stop bits */
+          /* Return stop bits */
 
-        termiosp->c_cflag |= (priv->stop_b2) ? CSTOPB : 0;
+          termiosp->c_cflag |= (priv->stop_b2) ? CSTOPB : 0;
 
 #ifdef CONFIG_SERIAL_OFLOWCONTROL
-        termiosp->c_cflag |= (priv->oflow) ? CCTS_OFLOW : 0;
+          termiosp->c_cflag |= (priv->oflow) ? CCTS_OFLOW : 0;
 #endif
 #ifdef CONFIG_SERIAL_IFLOWCONTROL
-        termiosp->c_cflag |= (priv->iflow) ? CRTS_IFLOW : 0;
+          termiosp->c_cflag |= (priv->iflow) ? CRTS_IFLOW : 0;
 #endif
 
-        /* Set the baud rate in termiosp using the cfsetispeed interface */
+          /* Set the baud rate in termiosp using the cfsetispeed interface */
 
-        cfsetispeed(termiosp, priv->baud);
+          cfsetispeed(termiosp, priv->baud);
 
-        /* Return number of bits */
+          /* Return number of bits */
 
-        switch (priv->bits)
-          {
-            case 5:
-              termiosp->c_cflag |= CS5;
-              break;
+          switch (priv->bits)
+            {
+              case 5:
+                termiosp->c_cflag |= CS5;
+                break;
 
-            case 6:
-              termiosp->c_cflag |= CS6;
-              break;
+              case 6:
+                termiosp->c_cflag |= CS6;
+                break;
 
-            case 7:
-              termiosp->c_cflag |= CS7;
-              break;
+              case 7:
+                termiosp->c_cflag |= CS7;
+                break;
 
-            case 8:
-            default:
-              termiosp->c_cflag |= CS8;
-              break;
-          }
-      }
-      break;
-
-    case TCSETS:
-      {
-        struct termios *termiosp = (struct termios *)arg;
-        struct esp_uart_s *priv  = (struct esp_uart_s *)dev->priv;
-        uint32_t baud;
-        uint32_t current_int_sts;
-        uint8_t  parity;
-        uint8_t  bits;
-        uint8_t  stop2;
+              case 8:
+              default:
+                termiosp->c_cflag |= CS8;
+                break;
+            }
+        }
+        break;
+
+      case TCSETS:
+        {
+          struct termios *termiosp = (struct termios *)arg;
+          struct esp_uart_s *priv  = (struct esp_uart_s *)dev->priv;
+          uint32_t baud;
+          uint32_t current_int_sts;
+          uint8_t  parity;
+          uint8_t  bits;
+          uint8_t  stop2;
 #ifdef CONFIG_SERIAL_IFLOWCONTROL
-        bool iflow;
+          bool iflow;
 #endif
 #ifdef CONFIG_SERIAL_OFLOWCONTROL
-        bool oflow;
+          bool oflow;
 #endif
 
-        if (termiosp == NULL)
-          {
-            ret = -EINVAL;
-            break;
-          }
+          if (termiosp == NULL)
+            {
+              ret = -EINVAL;
+              break;
+            }
 
-        /* Get the target baud rate to change */
+          /* Get the target baud rate to change */
 
-        baud = cfgetispeed(termiosp);
+          baud = cfgetispeed(termiosp);
 
-        /* Decode number of bits */
+          /* Decode number of bits */
 
-        switch (termiosp->c_cflag & CSIZE)
-          {
-            case CS5:
-              bits = 5;
-              break;
+          switch (termiosp->c_cflag & CSIZE)
+            {
+              case CS5:
+                bits = 5;
+                break;
 
-            case CS6:
-              bits = 6;
-              break;
+              case CS6:
+                bits = 6;
+                break;
 
-            case CS7:
-              bits = 7;
-              break;
+              case CS7:
+                bits = 7;
+                break;
 
-            case CS8:
-              bits = 8;
-              break;
+              case CS8:
+                bits = 8;
+                break;
 
-            default:
-              ret = -EINVAL;
-              break;
-          }
+              default:
+                ret = -EINVAL;
+                break;
+            }
 
-        /* Decode parity */
+          /* Decode parity */
 
-        if ((termiosp->c_cflag & PARENB) != 0)
-          {
-            parity = (termiosp->c_cflag & PARODD) ? 1 : 2;
-          }
-        else
-          {
-            parity = 0;
-          }
+          if ((termiosp->c_cflag & PARENB) != 0)
+            {
+              parity = (termiosp->c_cflag & PARODD) ? 1 : 2;
+            }
+          else
+            {
+              parity = 0;
+            }
 
-        /* Decode stop bits */
+          /* Decode stop bits */
 
-        stop2 = (termiosp->c_cflag & CSTOPB) ? 1 : 0;
+          stop2 = (termiosp->c_cflag & CSTOPB) ? 1 : 0;
 
 #ifdef CONFIG_SERIAL_IFLOWCONTROL
-        iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0;
+          iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0;
 #endif
 #ifdef CONFIG_SERIAL_OFLOWCONTROL
-        oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0;
+          oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0;
 #endif
 
-        /* Verify if all settings are valid before performing the changes */
+          /* Verify if all settings are valid before performing the changes */
 
-        if (ret == OK)
-          {
-            /* Fill the private struct fields */
+          if (ret == OK)
+            {
+              /* Fill the private struct fields */
 
-            priv->baud    = baud;
-            priv->parity  = parity;
-            priv->bits    = bits;
-            priv->stop_b2 = stop2;
+              priv->baud    = baud;
+              priv->parity  = parity;
+              priv->bits    = bits;
+              priv->stop_b2 = stop2;
 #ifdef CONFIG_SERIAL_IFLOWCONTROL
-            priv->iflow   = iflow;
+              priv->iflow   = iflow;
 #endif
 #ifdef CONFIG_SERIAL_OFLOWCONTROL
-            priv->oflow   = oflow;
+              priv->oflow   = oflow;
 #endif
 
-            /* Effect the changes immediately - note that we do not implement
-             * TCSADRAIN or TCSAFLUSH, only TCSANOW option.
-             * See nuttx/libs/libc/termios/lib_tcsetattr.c
-             */
+              /* Effect the changes immediately - note that we do not
+               * implement TCSADRAIN or TCSAFLUSH, only TCSANOW option.
+               * See nuttx/libs/libc/termios/lib_tcsetattr.c
+               */
 
-            esp_lowputc_disable_all_uart_int(priv, &current_int_sts);
-            ret = esp_setup(dev);
+              esp_lowputc_disable_all_uart_int(priv, &current_int_sts);
+              ret = esp_setup(dev);
 
-            /* Restore the interrupt state */
+              /* Restore the interrupt state */
 
-            esp_lowputc_restore_all_uart_int(priv, &current_int_sts);
-          }
-      }
-      break;
+              esp_lowputc_restore_all_uart_int(priv, &current_int_sts);
+            }
+        }
+        break;
 #endif /* CONFIG_SERIAL_TERMIOS */
 
-    default:
-      ret = -ENOTTY;
-      break;
+      default:
+        ret = -ENOTTY;
+        break;
     }
 
   return ret;

Reply via email to