arch: serial: fix all TCGETS retrieving zero baud rate

cfsetispeed() now stores baud rate to c_cflag member of
struct termios, so it must not be overridden later on.

Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
Juha Niskanen 2020-10-19 18:39:49 +03:00 committed by Xiang Xiao
parent 9928088868
commit 94f0f55911
22 changed files with 52 additions and 64 deletions

View File

@ -1270,8 +1270,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
* that only one speed is supported.
*/
/* Get the c_speed field in the termios struct */
priv->baud = cfgetispeed(termiosp);
/* TODO: Re-calculate the optimal CCLK divisor for the new baud and

View File

@ -1090,8 +1090,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
* that only one speed is supported.
*/
/* Get the c_speed field in the termios struct */
priv->baud = cfgetispeed(termiosp);
/* TODO: Re-calculate the optimal CCLK divisor for the new baud and

View File

@ -778,8 +778,6 @@ static int up_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
flags = spin_lock_irqsave();
cfsetispeed(termiosp, priv->baud);
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
((priv->parity == 1) ? PARODD : 0) |
#ifdef CONFIG_SERIAL_OFLOWCONTROL
@ -790,6 +788,8 @@ static int up_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
#endif
((priv->stopbits2) ? CSTOPB : 0);
cfsetispeed(termiosp, priv->baud);
switch (priv->bits)
{
case 5:

View File

@ -839,8 +839,6 @@ static int efm32_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
cfsetispeed(termiosp, priv->config->baud);
/* Note that since we only support 8/9 bit modes and
* there is no way to report 9-bit mode, we always claim 8.
*/
@ -848,6 +846,8 @@ static int efm32_ioctl(struct file *filep, int cmd, unsigned long arg)
termiosp->c_cflag = CS8;
/* TODO: PARENB, PARODD, CSTOPB, CCTS_IFLOW, CCTS_OFLOW */
cfsetispeed(termiosp, priv->config->baud);
}
break;

View File

@ -1155,10 +1155,6 @@ static int imxrt_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
@ -1176,6 +1172,10 @@ static int imxrt_ioctl(struct file *filep, int cmd, unsigned long arg)
#ifdef CONFIG_SERIAL_IFLOWCONTROL
termiosp->c_cflag |= ((priv->iflow) ? CRTS_IFLOW : 0);
#endif
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return number of bits */
switch (priv->bits)

View File

@ -1341,8 +1341,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
cfsetispeed(termiosp, priv->baud);
/* Note: CSIZE only supports 5-8 bits. The driver only support 8/9 bit
* modes and therefore is no way to report 9-bit mode, we always claim
* 8 bit mode.
@ -1360,6 +1358,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
# endif
CS8;
cfsetispeed(termiosp, priv->baud);
/* TODO: CCTS_IFLOW, CCTS_OFLOW */
}
break;

View File

@ -757,8 +757,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
cfsetispeed(termiosp, priv->baud);
/* Note that since we only support 8/9 bit modes and
* there is no way to report 9-bit mode, we always claim 8.
*/
@ -773,6 +771,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
((priv->iflow) ? CRTS_IFLOW : 0) |
#endif
CS8;
cfsetispeed(termiosp, priv->baud);
}
break;

View File

@ -1391,8 +1391,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
* that only one speed is supported.
*/
/* Get the c_speed field in the termios struct */
priv->baud = cfgetispeed(termiosp);
/* TODO: Re-calculate the optimal CCLK divisor for the new baud and

View File

@ -475,12 +475,6 @@ static int nrf52_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Get baud */
cfsetispeed(termiosp, config->baud);
/* Get flags */
termiosp->c_cflag = ((config->parity != 0) ? PARENB : 0)
| ((config->parity == 1) ? PARODD : 0)
| ((config->stopbits2) ? CSTOPB : 0) |
@ -492,6 +486,8 @@ static int nrf52_ioctl(struct file *filep, int cmd, unsigned long arg)
#endif
CS8;
cfsetispeed(termiosp, config->baud);
break;
}

View File

@ -797,8 +797,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
* that only one speed is supported.
*/
/* Get the c_speed field in the termios struct */
priv->baud = cfgetispeed(termiosp);
/* Reset the baud */

View File

@ -727,10 +727,6 @@ static int s32k1xx_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
@ -748,6 +744,10 @@ static int s32k1xx_ioctl(struct file *filep, int cmd, unsigned long arg)
#ifdef CONFIG_SERIAL_IFLOWCONTROL
termiosp->c_cflag |= ((priv->iflow) ? CRTS_IFLOW : 0);
#endif
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return number of bits */
switch (priv->bits)

View File

@ -1013,10 +1013,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
@ -1031,6 +1027,10 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
termiosp->c_cflag |= (priv->flowc) ? (CCTS_OFLOW | CRTS_IFLOW): 0;
#endif
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return number of bits */
switch (priv->bits)

View File

@ -820,10 +820,6 @@ static int flexus_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
@ -838,6 +834,10 @@ static int flexus_ioctl(struct file *filep, int cmd, unsigned long arg)
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
termiosp->c_cflag |= (priv->flowc) ? (CCTS_OFLOW | CRTS_IFLOW): 0;
#endif
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return number of bits */
switch (priv->bits)

View File

@ -1270,10 +1270,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
@ -1288,6 +1284,10 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
termiosp->c_cflag |= (priv->flowc) ? (CCTS_OFLOW | CRTS_IFLOW): 0;
#endif
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return number of bits */
switch (priv->bits)

View File

@ -1081,10 +1081,6 @@ static int sam_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
@ -1099,6 +1095,10 @@ static int sam_ioctl(struct file *filep, int cmd, unsigned long arg)
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
termiosp->c_cflag |= (priv->flowc) ? (CCTS_OFLOW | CRTS_IFLOW): 0;
#endif
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return number of bits */
switch (priv->bits)

View File

@ -2019,8 +2019,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
cfsetispeed(termiosp, priv->baud);
/* Note that since we only support 8/9 bit modes and
* there is no way to report 9-bit mode, we always claim 8.
*/
@ -2037,6 +2035,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
#endif
CS8;
cfsetispeed(termiosp, priv->baud);
/* TODO: CCTS_IFLOW, CCTS_OFLOW */
}
break;

View File

@ -2568,8 +2568,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
cfsetispeed(termiosp, priv->baud);
/* Note that since we only support 8/9 bit modes and
* there is no way to report 9-bit mode, we always claim 8.
*/
@ -2586,6 +2584,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
#endif
CS8;
cfsetispeed(termiosp, priv->baud);
/* TODO: CCTS_IFLOW, CCTS_OFLOW */
}
break;

View File

@ -1670,8 +1670,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
cfsetispeed(termiosp, priv->baud);
/* Note that since we only support 8/9 bit modes and
* there is no way to report 9-bit mode, we always claim 8.
*/
@ -1688,6 +1686,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
#endif
CS8;
cfsetispeed(termiosp, priv->baud);
/* TODO: CCTS_IFLOW, CCTS_OFLOW */
}
break;

View File

@ -2013,8 +2013,6 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd,
break;
}
cfsetispeed(termiosp, priv->baud);
/* Note that since we only support 8/9 bit modes and
* there is no way to report 9-bit mode, we always claim 8.
*/
@ -2031,6 +2029,8 @@ static int stm32l4serial_ioctl(FAR struct file *filep, int cmd,
#endif
CS8;
cfsetispeed(termiosp, priv->baud);
/* TODO: CCTS_IFLOW, CCTS_OFLOW */
}
break;

View File

@ -1073,8 +1073,6 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
cfsetispeed(termiosp, priv->baud);
if (priv->bits >= 5 && priv->bits <= 8)
{
ccflag |= (CS5 + (priv->bits - 5));
@ -1099,6 +1097,8 @@ static int up_ioctl(struct file *filep, int cmd, unsigned long arg)
*/
termiosp->c_cflag = ccflag;
cfsetispeed(termiosp, priv->baud);
}
break;

View File

@ -551,10 +551,6 @@ static int tms570_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->config.baud);
/* Return parity */
termiosp->c_cflag = ((priv->config.parity != 0) ? PARENB : 0) |
@ -564,6 +560,10 @@ static int tms570_ioctl(struct file *filep, int cmd, unsigned long arg)
termiosp->c_cflag |= (priv->config.stopbits2) ? CSTOPB : 0;
/* Return baud */
cfsetispeed(termiosp, priv->config.baud);
/* Return number of bits */
switch (priv->config.bits)

View File

@ -845,10 +845,6 @@ static int esp32_ioctl(struct file *filep, int cmd, unsigned long arg)
break;
}
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return parity */
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
@ -863,6 +859,10 @@ static int esp32_ioctl(struct file *filep, int cmd, unsigned long arg)
#if defined(CONFIG_SERIAL_IFLOWCONTROL) || defined(CONFIG_SERIAL_OFLOWCONTROL)
termiosp->c_cflag |= (priv->flowc) ? (CCTS_OFLOW | CRTS_IFLOW): 0;
#endif
/* Return baud */
cfsetispeed(termiosp, priv->baud);
/* Return number of bits */
switch (priv->bits)