You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/01/04 13:44:55 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5161: arch/risc-v/src/mpfs/mpfs_serial.c: Correct setting of nbits

pkarashchenko commented on a change in pull request #5161:
URL: https://github.com/apache/incubator-nuttx/pull/5161#discussion_r778091306



##########
File path: arch/risc-v/src/mpfs/mpfs_serial.c
##########
@@ -907,10 +907,28 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
 
         priv->stopbits2 = (termiosp->c_cflag & CSTOPB) != 0;
 
-        priv->bits = (termiosp->c_cflag & CS5) ? 5 : 0;
-        priv->bits = (termiosp->c_cflag & CS6) ? 6 : 0;
-        priv->bits = (termiosp->c_cflag & CS7) ? 7 : 0;
-        priv->bits = (termiosp->c_cflag & CS8) ? 8 : 0;
+        switch (termiosp->c_cflag & CSIZE)
+          {
+          case CS5:
+            priv->bits = 5;
+            break;
+
+          case CS6:
+            priv->bits = 6;
+            break;
+
+          case CS7:
+            priv->bits = 7;
+            break;
+
+          case CS8:
+            priv->bits = 8;
+            break;
+
+          default:
+            priv->bits = 0;
+            ret = -EINVAL;
+          }

Review comment:
       Do we need to move
   ```
           /* Note that only cfgetispeed is used because we have knowledge
            * that only one speed is supported.
            */
           priv->baud = cfgetispeed(termiosp);
           /* Effect the changes immediately - note that we do not implement
            * TCSADRAIN / TCSAFLUSH
            */
           up_set_format(dev);
   ```
   under `if (ret == OK)`?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org