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:11:57 UTC

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

jlaitine opened a new pull request #5161:
URL: https://github.com/apache/incubator-nuttx/pull/5161


   Number of bits was set wrongly in TCSETS for mpfs
   
   Signed-off-by: Jukka Laitinen <ju...@ssrc.tii.ae>
   
   
   


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



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

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5161:
URL: https://github.com/apache/incubator-nuttx/pull/5161#discussion_r778091572



##########
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:
       ```suggestion
             default:
               priv->bits = 0;
               ret = -EINVAL;
               break;
   ```
   just to keep style




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



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

Posted by GitBox <gi...@apache.org>.
jlaitine commented on a change in pull request #5161:
URL: https://github.com/apache/incubator-nuttx/pull/5161#discussion_r778394798



##########
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:
       sure




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



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #5161: arch/risc-v/src/mpfs/mpfs_serial.c: Correct setting of nbits

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #5161:
URL: https://github.com/apache/incubator-nuttx/pull/5161


   


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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
jlaitine commented on pull request #5161:
URL: https://github.com/apache/incubator-nuttx/pull/5161#issuecomment-1005177929


   Thanks for reviews everyone, I still addressed points which @pkarashchenko raised


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



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

Posted by GitBox <gi...@apache.org>.
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