diff --git a/model/usb/device/f_generic.c b/model/usb/device/f_generic.c index 1f7ce86ee8db94584707d16057e1c7f01047352e..c19fab2c5d62aba855a6219066fddd1d57c33c3b 100644 --- a/model/usb/device/f_generic.c +++ b/model/usb/device/f_generic.c @@ -2412,7 +2412,7 @@ static int __ffs_data_got_descs(struct ffs_data *ffs, os_descs_count = get_unaligned_le32(data); data += 4; len -= 4; - }; + } /* Read descriptors */ raw_descs = data; diff --git a/model/usb/host/src/usb_pnp_notify.c b/model/usb/host/src/usb_pnp_notify.c index 7e08b37df5e1b0ad20f19fefbf9bcb1a433d1f8f..890a848046d7a9cc26ba9521ddfde99134f092a3 100644 --- a/model/usb/host/src/usb_pnp_notify.c +++ b/model/usb/host/src/usb_pnp_notify.c @@ -47,7 +47,7 @@ struct OsalMutex g_gadgetSendEventLock; struct usb_device *g_usbDevice = NULL; struct UsbPnpAddRemoveInfo g_usbPnpInfo; struct DListHead g_usbPnpInfoListHead; -#if USB_PNP_NOTIFY_TEST_MODE == true +#if USB_PNP_NOTIFY_TEST_MODE struct UsbPnpNotifyMatchInfoTable *g_testUsbPnpInfo = NULL; #endif @@ -115,17 +115,16 @@ static struct UsbPnpDeviceInfo *UsbPnpNotifyFindInfo(struct UsbInfoQueryPara que break; } - if (findFlag == true) { + if (findFlag) { break; } } - if (findFlag == false) { + if (!findFlag) { HDF_LOGE("%s:%d the usb pnp info to be find does not exist. ", __func__, __LINE__); return NULL; - } else { - return infoPos; } + return infoPos; } static HDF_STATUS UsbPnpNotifyDestroyInfo(struct UsbPnpDeviceInfo *deviceInfo) @@ -156,7 +155,7 @@ static HDF_STATUS UsbPnpNotifyDestroyInfo(struct UsbPnpDeviceInfo *deviceInfo) } } - if (findFlag == false) { + if (!findFlag) { ret = HDF_FAILURE; HDF_LOGE("%s:%d the deviceInfoto be destroyed does not exist, ret=%d ", __func__, __LINE__, ret); } @@ -166,15 +165,13 @@ static HDF_STATUS UsbPnpNotifyDestroyInfo(struct UsbPnpDeviceInfo *deviceInfo) static int32_t UsbPnpNotifyAddInitInfo(struct UsbPnpDeviceInfo *deviceInfo, union UsbPnpDeviceInfoData infoData) { - int32_t ret = HDF_SUCCESS; uint8_t i; deviceInfo->info.usbDevAddr = (uint64_t)infoData.usbDev; deviceInfo->info.devNum = infoData.usbDev->devnum; if (infoData.usbDev->bus == NULL) { - HDF_LOGE("%s infoData.usbDev->bus=%px is NULL", __func__, infoData.usbDev->bus); - ret = HDF_ERR_INVALID_PARAM; - goto OUT; + HDF_LOGE("%s:%d infoData.usbDev->bus is NULL", __func__, __LINE__); + return HDF_ERR_INVALID_PARAM; } deviceInfo->info.busNum = infoData.usbDev->bus->busnum; @@ -187,9 +184,8 @@ static int32_t UsbPnpNotifyAddInitInfo(struct UsbPnpDeviceInfo *deviceInfo, unio deviceInfo->info.deviceInfo.deviceProtocol = infoData.usbDev->descriptor.bDeviceProtocol; if (infoData.usbDev->actconfig == NULL) { - HDF_LOGE("%s infoData.usbDev->actconfig=%p is NULL", __func__, infoData.usbDev->actconfig); - ret = HDF_ERR_INVALID_PARAM; - goto OUT; + HDF_LOGE("%s:%d infoData.usbDev->actconfig is NULL", __func__, __LINE__); + return HDF_ERR_INVALID_PARAM; } deviceInfo->info.numInfos = infoData.usbDev->actconfig->desc.bNumInterfaces; for (i = 0; i < deviceInfo->info.numInfos; i++) { @@ -197,8 +193,7 @@ static int32_t UsbPnpNotifyAddInitInfo(struct UsbPnpDeviceInfo *deviceInfo, unio (infoData.usbDev->actconfig->interface[i]->cur_altsetting == NULL)) { HDF_LOGE("%{public}s interface[%{public}d] or interface[%{public}d]->cur_altsetting is NULL", __func__, i, i); - ret = HDF_ERR_INVALID_PARAM; - goto OUT; + return HDF_ERR_INVALID_PARAM; } deviceInfo->info.interfaceInfo[i].interfaceClass = infoData.usbDev->actconfig->interface[i]->cur_altsetting->desc.bInterfaceClass; @@ -216,8 +211,7 @@ static int32_t UsbPnpNotifyAddInitInfo(struct UsbPnpDeviceInfo *deviceInfo, unio deviceInfo->info.interfaceInfo[i].interfaceNumber); } -OUT: - return ret; + return HDF_SUCCESS; } static void UsbPnpNotifyAddInterfaceInitInfo(struct UsbPnpDeviceInfo *deviceInfo, @@ -247,8 +241,8 @@ static void UsbPnpNotifyAddInterfaceInitInfo(struct UsbPnpDeviceInfo *deviceInfo infoTable->interfaceInfo[0].interfaceNumber = infoData.infoData->interfaceNumber; } else { for (i = 0, j = 0; i < deviceInfo->info.numInfos; i++) { - if (deviceInfo->interfaceRemoveStatus[i] == true) { - HDF_LOGI("%s:%d j=%d deviceInfo->interfaceRemoveStatus[%d] is true!", __func__, __LINE__, j, i); + if (deviceInfo->interfaceRemoveStatus[i]) { + HDF_LOGI("%s:%d j=%hhu deviceInfo->interfaceRemoveStatus[%hhu] is true!", __func__, __LINE__, j, i); continue; } infoTable->interfaceInfo[j].interfaceClass = deviceInfo->info.interfaceInfo[i].interfaceClass; @@ -411,16 +405,15 @@ ERROR_DEVICE_INFO: return ret; } -#if USB_PNP_NOTIFY_TEST_MODE == true +#if USB_PNP_NOTIFY_TEST_MODE static void TestReadPnpInfo(struct HdfSBuf *data) { uint32_t infoSize; bool flag; flag = HdfSbufReadBuffer(data, (const void **)(&g_testUsbPnpInfo), &infoSize); - if ((flag == false) || (g_testUsbPnpInfo == NULL)) { - HDF_LOGE("%s: fail to read g_testUsbPnpInfo, flag=%d, g_testUsbPnpInfo=%px", \ - __func__, flag, g_testUsbPnpInfo); + if ((!flag) || (g_testUsbPnpInfo == NULL)) { + HDF_LOGE("%s:%d fail to read g_testUsbPnpInfo, flag=%d", __func__, __LINE__, flag); return; } @@ -505,7 +498,7 @@ OUT: static int32_t GadgetPnpNotifyHdfSendEvent(const struct HdfDeviceObject *deviceObject) { if (deviceObject == NULL) { - HDF_LOGE("%s deviceObject=%p", __func__, deviceObject); + HDF_LOGE("%s:%d deviceObject is null", __func__, __LINE__); return HDF_ERR_INVALID_PARAM; } @@ -547,7 +540,7 @@ static int32_t UsbPnpNotifyReportThread(void* arg) struct HdfDeviceObject *deviceObject = (struct HdfDeviceObject *)arg; while (!kthread_should_stop()) { -#if USB_PNP_NOTIFY_TEST_MODE == false +#if !USB_PNP_NOTIFY_TEST_MODE ret = wait_event_interruptible(g_usbPnpNotifyReportWait, g_usbDevice != NULL); #else ret = wait_event_interruptible(g_usbPnpNotifyReportWait, @@ -558,7 +551,7 @@ static int32_t UsbPnpNotifyReportThread(void* arg) } OsalMutexLock(&g_usbSendEventLock); -#if USB_PNP_NOTIFY_TEST_MODE == true +#if USB_PNP_NOTIFY_TEST_MODE if ((g_usbPnpNotifyCmdType == USB_PNP_NOTIFY_ADD_TEST) || \ (g_usbPnpNotifyCmdType == USB_PNP_NOTIFY_REMOVE_TEST)) { ret = TestPnpNotifyHdfSendEvent(deviceObject); @@ -570,7 +563,7 @@ static int32_t UsbPnpNotifyReportThread(void* arg) } else { ret = UsbPnpNotifyHdfSendEvent(deviceObject, g_usbDevice); } -#if USB_PNP_NOTIFY_TEST_MODE == true +#if USB_PNP_NOTIFY_TEST_MODE } #endif if (ret != HDF_SUCCESS) { @@ -578,7 +571,7 @@ static int32_t UsbPnpNotifyReportThread(void* arg) } g_usbDevice = NULL; -#if USB_PNP_NOTIFY_TEST_MODE == true +#if USB_PNP_NOTIFY_TEST_MODE g_testUsbPnpInfo = NULL; #endif OsalMutexUnlock(&g_usbSendEventLock); @@ -680,7 +673,7 @@ static int32_t UsbPnpNotifyCallback(struct notifier_block *self, unsigned long a g_gadgetPnpNotifyType = USB_PNP_DRIVER_GADGET_REMOVE; } OsalMutexUnlock(&g_gadgetSendEventLock); - HDF_LOGI("%s:%d g_gadgetPnpNotifyType = %d", __func__, __LINE__, g_gadgetPnpNotifyType); + HDF_LOGI("%s:%d g_gadgetPnpNotifyType = %hhu", __func__, __LINE__, g_gadgetPnpNotifyType); wake_up_interruptible(&g_gadgetPnpNotifyReportWait); g_preAcion = action; break; @@ -705,9 +698,8 @@ static void UsbPnpNotifyReadPnpInfo(struct HdfSBuf *data) bool flag; flag = HdfSbufReadBuffer(data, (const void **)(&usbPnpInfo), &infoSize); - if ((flag == false) || (usbPnpInfo == NULL)) { - HDF_LOGE("%s: fail to read g_usbPnpInfo, flag=%d, usbPnpInfo=%px", \ - __func__, flag, usbPnpInfo); + if ((!flag) || (usbPnpInfo == NULL)) { + HDF_LOGE("%s:%d fail to read g_usbPnpInfo, flag=%d", __func__, __LINE__, flag); return; } @@ -799,7 +791,7 @@ static int32_t UsbPnpNotifyDispatch(struct HdfDeviceIoClient *client, int32_t cm case USB_PNP_NOTIFY_REPORT_INTERFACE: usb_for_each_dev((void *)client, UsbPnpNotifyFirstReport); break; -#if USB_PNP_NOTIFY_TEST_MODE == true +#if USB_PNP_NOTIFY_TEST_MODE case USB_PNP_NOTIFY_ADD_TEST: TestReadPnpInfo(data); wake_up_interruptible(&g_usbPnpNotifyReportWait); @@ -855,7 +847,7 @@ static int32_t UsbPnpNotifyInit(struct HdfDeviceObject *device) return HDF_ERR_INVALID_OBJECT; } - if (firstInitFlag == true) { + if (firstInitFlag) { firstInitFlag = false; DListHeadInit(&g_usbPnpInfoListHead); @@ -870,8 +862,8 @@ static int32_t UsbPnpNotifyInit(struct HdfDeviceObject *device) /* Add a new notify for usb pnp notify module. */ usb_register_notify(&g_usbPnpNotifyNb); - /* Creat thread to handle send usb interface information. */ - if (NULL == g_usbPnpNotifyReportThread) { + /* Create thread to handle send usb interface information. */ + if (g_usbPnpNotifyReportThread == NULL) { g_usbPnpNotifyReportThread = kthread_run(UsbPnpNotifyReportThread, (void *)device, "usb pnp notify handle kthread"); if (g_usbPnpNotifyReportThread == NULL) { @@ -881,8 +873,8 @@ static int32_t UsbPnpNotifyInit(struct HdfDeviceObject *device) HDF_LOGI("%s: g_usbPnpNotifyReportThread is already running!", __func__); } - /* Creat thread to handle gadeget information. */ - if (NULL == g_gadgetPnpNotifyReportThread) { + /* Create thread to handle gadeget information. */ + if (g_gadgetPnpNotifyReportThread == NULL) { g_gadgetPnpNotifyReportThread = kthread_run(GadgetPnpNotifyReportThread, (void *)device, "gadget pnp notify handle kthread"); if (g_usbPnpNotifyReportThread == NULL) {