[drivers][serial] 保留共享串口的接收回调 (#11931)

仅在最后一个使用者关闭串口时清理接收回调。
This commit is contained in:
陈泽堂 authored and GitHub committed 2026-11-05 11:16:53 +08:00
1 parent d42ffde1b5
commit 0aae54ae97
1 file changed
+9 -1
+9 -1
View File
@@ -117,9 +117,17 @@ static int serial_fops_close(struct dfs_file *fd)
device = (rt_device_t)fd->vnode->data;
rt_device_set_rx_indicate(device, RT_NULL);
/* close this file descriptor, but only drop the rx indication callback when
* the device is really released. The callback wakes readers (see
* serial_fops_rx_ind), so clearing it while another user still holds the
* device would make that user stop receiving input. */
rt_device_close(device);
if (device->ref_count == 0)
{
rt_device_set_rx_indicate(device, RT_NULL);
}
return 0;
}