summaryrefslogtreecommitdiff
path: root/components/drivers/tty/console.c
diff options
context:
space:
mode:
authorxqyjlj <[email protected]>2023-10-25 20:31:25 +0800
committerGitHub <[email protected]>2023-10-25 20:31:25 +0800
commit3283f54c7a0444b2e51ec79a4da57e7871528f05 (patch)
treee4bcd748ad2362f16d0dea5c5da62922de466999 /components/drivers/tty/console.c
parent91fc52df3635d5dda8285616420f08efa79cea04 (diff)
🎈 perf: perf rt_hw_interrupt_disable/enable (#8042)
Signed-off-by: Shell <[email protected]> Co-authored-by: Shell <[email protected]>
Diffstat (limited to 'components/drivers/tty/console.c')
-rw-r--r--components/drivers/tty/console.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/components/drivers/tty/console.c b/components/drivers/tty/console.c
index ffc9ab71ec..a9c9b88731 100644
--- a/components/drivers/tty/console.c
+++ b/components/drivers/tty/console.c
@@ -149,14 +149,7 @@ static rt_err_t iodev_open(struct tty_struct *console)
struct rt_device *console_get_iodev(void)
{
- rt_base_t level = 0;
- struct rt_device *iodev = RT_NULL;
-
- level = rt_hw_interrupt_disable();
- iodev = console_dev.io_dev;
- rt_hw_interrupt_enable(level);
-
- return iodev;
+ return console_dev.io_dev;
}
struct rt_device *console_set_iodev(struct rt_device *iodev)
@@ -169,7 +162,7 @@ struct rt_device *console_set_iodev(struct rt_device *iodev)
console = &console_dev;
- level = rt_hw_interrupt_disable();
+ level = rt_spin_lock_irqsave(&console->spinlock);
RT_ASSERT(console->init_flag >= TTY_INIT_FLAG_REGED);
@@ -195,7 +188,7 @@ struct rt_device *console_set_iodev(struct rt_device *iodev)
}
exit:
- rt_hw_interrupt_enable(level);
+ rt_spin_unlock_irqrestore(&console->spinlock, level);
return io_before;
}
@@ -213,7 +206,7 @@ static rt_err_t rt_console_init(struct rt_device *dev)
console = (struct tty_struct *)dev;
- level = rt_hw_interrupt_disable();
+ level = rt_spin_lock_irqsave(&console->spinlock);
RT_ASSERT(console->init_flag == TTY_INIT_FLAG_REGED);
@@ -225,7 +218,7 @@ static rt_err_t rt_console_init(struct rt_device *dev)
console->init_flag = TTY_INIT_FLAG_INITED;
exit:
- rt_hw_interrupt_enable(level);
+ rt_spin_unlock_irqrestore(&console->spinlock, level);
return result;
}