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 21:18:10 UTC

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

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



##########
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:
       This makes sense; calling up_set_format wouldn't do any good if the previous setting fails.




-- 
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