summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorBernard Xiong <[email protected]>2017-01-19 23:10:59 +0800
committerBernard Xiong <[email protected]>2017-01-19 23:10:59 +0800
commitbbcac31118b6121f13fdd7c5d44a9734175b0793 (patch)
tree441de05f38995846a660ea0eb8bae1ac0368d304 /components
parentde3cf4195addf7f101023353e537ab86f86068bd (diff)
parentad02d293f66ebe683047db4915b82ed16f9edf7d (diff)
Merge branch 'master' of https://github.com/RT-Thread/rt-thread
Diffstat (limited to 'components')
-rw-r--r--components/drivers/serial/serial.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index a7f1bcfc08..c55406bcd6 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -31,6 +31,7 @@
* in open function.
* 2015-11-10 bernard fix the poll rx issue when there is no data.
* 2016-05-10 armink add fifo mode to DMA rx when serial->config.bufsz != 0.
+ * 2017-01-19 aubr.cool prevent change serial rx bufsz when serial is opened.
*/
#include <rthw.h>
@@ -603,17 +604,22 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
break;
case RT_DEVICE_CTRL_CONFIG:
- if (args)
- {
- /* set serial configure */
- serial->config = *(struct serial_configure *)args;
-
- if (dev->ref_count)
- {
- /* serial device has been opened, to configure it */
- serial->ops->configure(serial, (struct serial_configure *)args);
- }
- }
+ if (args)
+ {
+ struct serial_configure *pconfig = (struct serial_configure *) args;
+ if(pconfig->bufsz != serial->config.bufsz && serial->parent.ref_count)
+ {
+ /*can not change buffer size*/
+ return RT_EBUSY;
+ }
+ /* set serial configure */
+ serial->config = *pconfig;
+ if(serial->parent.ref_count)
+ {
+ /* serial device has been opened, to configure it */
+ serial->ops->configure(serial, (struct serial_configure *)args);
+ }
+ }
break;