From c0fe5ae5877e1af1cae7d595ac482eb8e7b8432f Mon Sep 17 00:00:00 2001 From: 17786508361 Date: Thu, 7 Dec 2023 10:29:19 +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 | 8 ++++++++ 3 files changed, 10 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..cc6483546 100644 --- a/framework/model/input/driver/hdf_input_device_manager.c +++ b/framework/model/input/driver/hdf_input_device_manager.c @@ -107,13 +107,21 @@ static void HotPlugNotify(const InputDevice *inputDev, uint32_t status) static int32_t CreateDeviceNode(InputDevice *inputDev) { + static bool existNonHid = false ; if (IsHidDevice(inputDev)) { + if (!existNonHid) { + 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 { + existNonHid = true ; } HDF_LOGI("%s: create node succ, devId is %d ", __func__, inputDev->devId); -- Gitee