summaryrefslogtreecommitdiff
path: root/components/drivers/serial
diff options
context:
space:
mode:
authorShell <[email protected]>2024-04-25 18:21:32 +0800
committerGitHub <[email protected]>2024-04-25 18:21:32 +0800
commit9e1a816f060c20bbd13cece7e3fa34be3cacede2 (patch)
tree5ad413d62f6db22c34d931a3fdf29c4f1a758334 /components/drivers/serial
parenta0e5526a555575fb3bf549e058cc07abca06dad6 (diff)
[smart] fix tty serial ioctl (#8861)
Using param callback to reduce unnecessary call. Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'components/drivers/serial')
-rw-r--r--components/drivers/serial/serial_tty.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/components/drivers/serial/serial_tty.c b/components/drivers/serial/serial_tty.c
index a4c3dbbe41..e3d81b77eb 100644
--- a/components/drivers/serial/serial_tty.c
+++ b/components/drivers/serial/serial_tty.c
@@ -262,15 +262,6 @@ static int serial_tty_ioctl(struct lwp_tty *tp, rt_ubase_t cmd, rt_caddr_t data,
int error;
switch (cmd)
{
- case TCSETS:
- case TCSETSW:
- case TCSETSF:
- RT_ASSERT(tp->t_devswsoftc);
- struct serial_tty_context *softc = (struct serial_tty_context *)(tp->t_devswsoftc);
- struct rt_serial_device *serial = softc->parent;
- struct termios *termios = (struct termios *)data;
- rt_device_control(&(serial->parent), cmd, termios);
- error = -ENOIOCTL;
default:
/**
* Note: for the most case, we don't let serial layer handle ioctl,
@@ -284,10 +275,22 @@ static int serial_tty_ioctl(struct lwp_tty *tp, rt_ubase_t cmd, rt_caddr_t data,
return error;
}
+static int serial_tty_param(struct lwp_tty *tp, struct termios *t)
+{
+ struct serial_tty_context *softc = (struct serial_tty_context *)(tp->t_devswsoftc);
+ struct rt_serial_device *serial;
+
+ RT_ASSERT(softc);
+ serial = softc->parent;
+
+ return rt_device_control(&(serial->parent), TCSETS, t);
+}
+
static struct lwp_ttydevsw serial_ttydevsw = {
.tsw_open = serial_tty_open,
.tsw_close = serial_tty_close,
.tsw_ioctl = serial_tty_ioctl,
+ .tsw_param = serial_tty_param,
.tsw_outwakeup = serial_tty_outwakeup,
};