diff --git a/model/input/driver/event_hub.c b/model/input/driver/event_hub.c index 264e63c7fb9624a938279aff54e0ea2c58bffa03..3055b95e169a59e6395838d46ca006d2295c07fb 100644 --- a/model/input/driver/event_hub.c +++ b/model/input/driver/event_hub.c @@ -31,7 +31,7 @@ void PushOnePackage(InputDevice *inputDev, uint32_t type, uint32_t code, int32_t HDF_LOGE("%s: parm is null", __func__); return; } - + OsalMutexLock(&inputDev->mutex); package.type = type; package.code = code; package.value = value; @@ -65,4 +65,5 @@ void PushOnePackage(InputDevice *inputDev, uint32_t type, uint32_t code, int32_t HdfSbufFlush(inputDev->pkgBuf); inputDev->errFrameFlag = false; } + OsalMutexUnlock(&inputDev->mutex); } \ No newline at end of file diff --git a/model/input/driver/hdf_hid_adapter.c b/model/input/driver/hdf_hid_adapter.c index 6449a9420f754ee7cdd87ef87a3d2939e736d90e..ca3d4e8e8cc3796d55f8fcd09943d1799d1ec8fc 100644 --- a/model/input/driver/hdf_hid_adapter.c +++ b/model/input/driver/hdf_hid_adapter.c @@ -167,6 +167,13 @@ static InputDevice* HidConstructInputDev(HidInfo *info) } (void)memset_s(inputDev, sizeof(InputDevice), 0, sizeof(InputDevice)); + int32_t ret = OsalMutexInit(&inputDev->mutex); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: Init mutex error", __func__); + OsalMemFree(inputDev); + return NULL; + } + inputDev->devType = info->devType; inputDev->devName = info->devName; SetInputDevAbility(inputDev); diff --git a/model/input/driver/hdf_input_device_manager.c b/model/input/driver/hdf_input_device_manager.c index 35ae028fae0ced9dbe71911f5202b501a87cae24..c3e762c5f6a0f498c74c291ba10fd2098823e596 100644 --- a/model/input/driver/hdf_input_device_manager.c +++ b/model/input/driver/hdf_input_device_manager.c @@ -335,8 +335,8 @@ void UnregisterInputDevice(InputDevice *inputDev) } HdfSBufRecycle(inputDev->eventBuf); inputDev->eventBuf = NULL; + OsalMutexDestroy(&inputDev->mutex); OsalMemFree(inputDev); - inputDev = NULL; OsalMutexUnlock(&g_inputManager->mutex); HDF_LOGI("%s: exit succ, devCount is %d", __func__, g_inputManager->devCount); return; diff --git a/model/input/driver/hdf_input_device_manager.h b/model/input/driver/hdf_input_device_manager.h index f18cf6545626ffe481eb16d072eefd35e00323a0..be36197abe59534535b80fa23856389268af5954 100644 --- a/model/input/driver/hdf_input_device_manager.h +++ b/model/input/driver/hdf_input_device_manager.h @@ -112,6 +112,7 @@ typedef struct InputDeviceInfo { void *pvtData; DevAttr attrSet; DevAbility abilitySet; + struct OsalMutex mutex; struct InputDeviceInfo *next; } InputDevice; diff --git a/model/input/driver/hdf_key.c b/model/input/driver/hdf_key.c index 4188b25b37f9298cee18c1b05bcdeaaec15ff138..7df3cd819bd09b3bd707ae155e2709992a1f17d4 100644 --- a/model/input/driver/hdf_key.c +++ b/model/input/driver/hdf_key.c @@ -23,7 +23,7 @@ int32_t KeyIrqHandle(uint16_t intGpioNum, void *data) { - uint16_t gpioValue; + uint16_t gpioValue = 0; KeyDriver *driver = (KeyDriver *)data; if (driver == NULL) { return HDF_FAILURE; diff --git a/model/input/driver/hdf_touch.c b/model/input/driver/hdf_touch.c index acaadd92cb00190e13d6de9b84a51cb8a03f73a9..e3e6e49bf78c3899e8ce70023b465a2b199ee671 100644 --- a/model/input/driver/hdf_touch.c +++ b/model/input/driver/hdf_touch.c @@ -294,7 +294,12 @@ static InputDevice *InputDeviceInstance(ChipDevice *chipDev) inputDev->devType = chipDev->driver->boardCfg->attr.devType; inputDev->devName = chipDev->driver->devName; - HDF_LOGI("%s: inputDev->devName = %s", __func__, inputDev->devName); + int32_t ret = OsalMutexInit(&inputDev->mutex); + if (ret != HDF_SUCCESS) { + HDF_LOGE("%s: Init mutex error", __func__); + OsalMemFree(inputDev); + return NULL; + } return inputDev; }