mirror of
https://github.com/apache/nuttx.git
synced 2026-10-04 04:38:10 +00:00
arch/risc-v/espressif: Fix nxstyle issues in esp_serial.c.
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
Some checks are pending
Build Documentation / build-html (push) Waiting to run
MemBrowse Memory Report / changes-filter (push) Waiting to run
MemBrowse Memory Report / load-targets (push) Waiting to run
MemBrowse Memory Report / identical (push) Blocked by required conditions
MemBrowse Memory Report / analyze (push) Blocked by required conditions
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 <erik.englund@gmail.com>
This commit is contained in:
parent
d0a86138ce
commit
0fafd0bc7f
1 changed files with 155 additions and 153 deletions
|
|
@ -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 */
|
||||
/* 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;
|
||||
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) */
|
||||
|
||||
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
|
||||
((priv->parity == 1) ? PARODD : 0);
|
||||
|
||||
/* Return stop bits */
|
||||
|
||||
termiosp->c_cflag |= (priv->stop_b2) ? CSTOPB : 0;
|
||||
|
||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||
termiosp->c_cflag |= (priv->oflow) ? CCTS_OFLOW : 0;
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
termiosp->c_cflag |= (priv->iflow) ? CRTS_IFLOW : 0;
|
||||
#endif
|
||||
|
||||
/* Set the baud rate in termiosp using the cfsetispeed interface */
|
||||
|
||||
cfsetispeed(termiosp, priv->baud);
|
||||
|
||||
/* Return number of bits */
|
||||
|
||||
switch (priv->bits)
|
||||
{
|
||||
case 5:
|
||||
termiosp->c_cflag |= CS5;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
termiosp->c_cflag |= CS6;
|
||||
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;
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
bool iflow;
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||
bool oflow;
|
||||
#endif
|
||||
|
||||
if (termiosp == NULL)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Get the target baud rate to change */
|
||||
|
||||
baud = cfgetispeed(termiosp);
|
||||
|
||||
/* Decode number of bits */
|
||||
|
||||
switch (termiosp->c_cflag & CSIZE)
|
||||
{
|
||||
case CS5:
|
||||
bits = 5;
|
||||
break;
|
||||
|
||||
case CS6:
|
||||
bits = 6;
|
||||
break;
|
||||
|
||||
case CS7:
|
||||
bits = 7;
|
||||
break;
|
||||
|
||||
case CS8:
|
||||
bits = 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (termiosp == NULL)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Decode parity */
|
||||
/* Return parity (0 = no parity, 1 = odd parity, 2 = even parity) */
|
||||
|
||||
if ((termiosp->c_cflag & PARENB) != 0)
|
||||
{
|
||||
parity = (termiosp->c_cflag & PARODD) ? 1 : 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
parity = 0;
|
||||
}
|
||||
termiosp->c_cflag = ((priv->parity != 0) ? PARENB : 0) |
|
||||
((priv->parity == 1) ? PARODD : 0);
|
||||
|
||||
/* Decode stop bits */
|
||||
/* Return stop bits */
|
||||
|
||||
stop2 = (termiosp->c_cflag & CSTOPB) ? 1 : 0;
|
||||
termiosp->c_cflag |= (priv->stop_b2) ? CSTOPB : 0;
|
||||
|
||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||
termiosp->c_cflag |= (priv->oflow) ? CCTS_OFLOW : 0;
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0;
|
||||
termiosp->c_cflag |= (priv->iflow) ? CRTS_IFLOW : 0;
|
||||
#endif
|
||||
|
||||
/* Set the baud rate in termiosp using the cfsetispeed interface */
|
||||
|
||||
cfsetispeed(termiosp, priv->baud);
|
||||
|
||||
/* Return number of bits */
|
||||
|
||||
switch (priv->bits)
|
||||
{
|
||||
case 5:
|
||||
termiosp->c_cflag |= CS5;
|
||||
break;
|
||||
|
||||
case 6:
|
||||
termiosp->c_cflag |= CS6;
|
||||
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;
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
bool iflow;
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||
oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0;
|
||||
bool oflow;
|
||||
#endif
|
||||
|
||||
/* Verify if all settings are valid before performing the changes */
|
||||
if (termiosp == NULL)
|
||||
{
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (ret == OK)
|
||||
{
|
||||
/* Fill the private struct fields */
|
||||
/* Get the target baud rate to change */
|
||||
|
||||
baud = cfgetispeed(termiosp);
|
||||
|
||||
/* Decode number of bits */
|
||||
|
||||
switch (termiosp->c_cflag & CSIZE)
|
||||
{
|
||||
case CS5:
|
||||
bits = 5;
|
||||
break;
|
||||
|
||||
case CS6:
|
||||
bits = 6;
|
||||
break;
|
||||
|
||||
case CS7:
|
||||
bits = 7;
|
||||
break;
|
||||
|
||||
case CS8:
|
||||
bits = 8;
|
||||
break;
|
||||
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Decode parity */
|
||||
|
||||
if ((termiosp->c_cflag & PARENB) != 0)
|
||||
{
|
||||
parity = (termiosp->c_cflag & PARODD) ? 1 : 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
parity = 0;
|
||||
}
|
||||
|
||||
/* Decode stop bits */
|
||||
|
||||
stop2 = (termiosp->c_cflag & CSTOPB) ? 1 : 0;
|
||||
|
||||
priv->baud = baud;
|
||||
priv->parity = parity;
|
||||
priv->bits = bits;
|
||||
priv->stop_b2 = stop2;
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
priv->iflow = iflow;
|
||||
iflow = (termiosp->c_cflag & CRTS_IFLOW) != 0;
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||
priv->oflow = oflow;
|
||||
oflow = (termiosp->c_cflag & CCTS_OFLOW) != 0;
|
||||
#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
|
||||
*/
|
||||
/* Verify if all settings are valid before performing the changes */
|
||||
|
||||
esp_lowputc_disable_all_uart_int(priv, ¤t_int_sts);
|
||||
ret = esp_setup(dev);
|
||||
if (ret == OK)
|
||||
{
|
||||
/* Fill the private struct fields */
|
||||
|
||||
/* Restore the interrupt state */
|
||||
priv->baud = baud;
|
||||
priv->parity = parity;
|
||||
priv->bits = bits;
|
||||
priv->stop_b2 = stop2;
|
||||
#ifdef CONFIG_SERIAL_IFLOWCONTROL
|
||||
priv->iflow = iflow;
|
||||
#endif
|
||||
#ifdef CONFIG_SERIAL_OFLOWCONTROL
|
||||
priv->oflow = oflow;
|
||||
#endif
|
||||
|
||||
esp_lowputc_restore_all_uart_int(priv, ¤t_int_sts);
|
||||
}
|
||||
}
|
||||
break;
|
||||
/* 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, ¤t_int_sts);
|
||||
ret = esp_setup(dev);
|
||||
|
||||
/* Restore the interrupt state */
|
||||
|
||||
esp_lowputc_restore_all_uart_int(priv, ¤t_int_sts);
|
||||
}
|
||||
}
|
||||
break;
|
||||
#endif /* CONFIG_SERIAL_TERMIOS */
|
||||
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
default:
|
||||
ret = -ENOTTY;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue