Merge pull request !216 from 野生毛霉君/master
This commit is contained in:
openharmony_ci 2021-05-06 20:46:12 +08:00 committed by Gitee
commit 27ab6247a6
1 changed files with 9 additions and 1 deletions

View File

@ -1005,6 +1005,7 @@ STATIC INT32 OsConsoleDevInit(CONSOLE_CB *consoleCB, const CHAR *deviceName)
INT32 ret;
struct file *filep = NULL;
struct Vnode *vnode = NULL;
struct file_operations_vfs *devOps = NULL;
/* allocate memory for filep,in order to unchange the value of filep */
filep = (struct file *)LOS_MemAlloc(m_aucSysMem0, sizeof(struct file));
@ -1040,6 +1041,13 @@ STATIC INT32 OsConsoleDevInit(CONSOLE_CB *consoleCB, const CHAR *deviceName)
* Use filep to connect console and uart, we can find uart driver function throught filep.
* now we can operate /dev/console to operate /dev/ttyS0 through filep.
*/
devOps = (struct file_operations_vfs *)((struct drv_data*)vnode->data)->ops;
if (devOps != NULL && devOps->open != NULL) {
(VOID)devOps->open(filep);
} else {
ret = ENOSYS;
goto ERROUT;
}
ret = register_driver(consoleCB->name, &g_consoleDevOps, DEFFILEMODE, filep);
if (ret != LOS_OK) {
@ -1204,7 +1212,7 @@ STATIC CONSOLE_CB *OsConsoleCreate(UINT32 consoleID, const CHAR *deviceName)
ret = OsConsoleDevInit(consoleCB, deviceName);
if (ret != LOS_OK) {
PRINT_ERR("console OsConsoleDevInitlloc error. %d\n", ret);
PRINT_ERR("console OsConsoleDevInit error. %d\n", ret);
goto ERR_WITH_SEM;
}