From 36b00f28a9e9bfad67c877754c5227d8b5920a47 Mon Sep 17 00:00:00 2001 From: 17786508361 Date: Wed, 6 Dec 2023 09:13:47 +0800 Subject: [PATCH] fix:the bug that the HID device was deadlocked Signed-off-by: 17786508361 --- framework/model/input/driver/hdf_hid_adapter.c | 2 +- framework/model/input/driver/hdf_hid_adapter.h | 2 +- framework/model/input/driver/hdf_input_device_manager.c | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/framework/model/input/driver/hdf_hid_adapter.c b/framework/model/input/driver/hdf_hid_adapter.c index a5f714c62..35f80e173 100644 --- a/framework/model/input/driver/hdf_hid_adapter.c +++ b/framework/model/input/driver/hdf_hid_adapter.c @@ -219,7 +219,7 @@ static void DoRegisterInputDev(InputDevice* inputDev) } } -static void CacheHid(InputDevice* inputDev) +void CacheHid(InputDevice* inputDev) { int32_t i = 0; while ((i < MAX_INPUT_DEV_NUM) && (cachedHid[i] != NULL)) { diff --git a/framework/model/input/driver/hdf_hid_adapter.h b/framework/model/input/driver/hdf_hid_adapter.h index 83efe6140..2b4a5af2c 100644 --- a/framework/model/input/driver/hdf_hid_adapter.h +++ b/framework/model/input/driver/hdf_hid_adapter.h @@ -96,5 +96,5 @@ void SendInfoToHdf(HidInfo *info); void* HidRegisterHdfInputDev(HidInfo *info); void HidUnregisterHdfInputDev(const void *inputDev); void HidReportEvent(const void *inputDev, uint32_t type, uint32_t code, int32_t value); - +void CacheHid(InputDevice* inputDev); #endif diff --git a/framework/model/input/driver/hdf_input_device_manager.c b/framework/model/input/driver/hdf_input_device_manager.c index 175a74d78..805742da0 100644 --- a/framework/model/input/driver/hdf_input_device_manager.c +++ b/framework/model/input/driver/hdf_input_device_manager.c @@ -13,6 +13,7 @@ #include "hdf_device_object.h" #include "hdf_log.h" #include "osal_mem.h" +#include "hdf_hid_adapter.h" #define NODE_MODE 0660 #define SERVICE_NAME_LEN 24 @@ -107,13 +108,21 @@ static void HotPlugNotify(const InputDevice *inputDev, uint32_t status) static int32_t CreateDeviceNode(InputDevice *inputDev) { + static bool isFirstHid = false ; if (IsHidDevice(inputDev)) { + if (!isFirstHid) { + CacheHid(inputDev); + HDF_LOGI("%s: is first hid dev add cache, devId is %d ", __func__, inputDev->devId); + return HDF_SUCCESS; + } HDF_LOGI("%s: prepare to register hdf device", __func__); inputDev->hdfDevObj = HidRegisterHdfDevice(inputDev); if (inputDev->hdfDevObj == NULL) { return HDF_DEV_ERR_NO_DEVICE; } inputDev->hdfDevObj->priv = (void *)inputDev; + } else { + isFirstHid = true ; } HDF_LOGI("%s: create node succ, devId is %d ", __func__, inputDev->devId); -- Gitee