From 66a29998de1d35ed72405f8f6a16bddd64e9b7f1 Mon Sep 17 00:00:00 2001 From: Marc Kleine-Budde Date: Sun, 20 Nov 2022 20:09:32 +0100 Subject: [PATCH] usbd_gs_can: USBD_GS_CAN_ReceiveFromHost(): remove some levels of indention --- src/usbd_gs_can.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/usbd_gs_can.c b/src/usbd_gs_can.c index 9ba2988..8f65749 100644 --- a/src/usbd_gs_can.c +++ b/src/usbd_gs_can.c @@ -712,17 +712,23 @@ bool USBD_GS_CAN_CustomInterfaceRequest(USBD_HandleTypeDef *pdev, USBD_SetupReqT void USBD_GS_CAN_ReceiveFromHost(USBD_HandleTypeDef *pdev) { USBD_GS_CAN_HandleTypeDef *hcan = (USBD_GS_CAN_HandleTypeDef*)pdev->pClassData; + bool was_irq_enabled = disable_irq(); - if (!hcan->from_host_buf) { - hcan->from_host_buf = list_first_entry_or_null(&hcan->list_frame_pool, - struct gs_host_frame_object, - list); - if (hcan->from_host_buf) { - list_del(&hcan->from_host_buf->list); - USBD_GS_CAN_PrepareReceive(pdev); - } + if (hcan->from_host_buf) { + restore_irq(was_irq_enabled); + return; } + hcan->from_host_buf = list_first_entry_or_null(&hcan->list_frame_pool, + struct gs_host_frame_object, + list); + if (!hcan->from_host_buf) { + restore_irq(was_irq_enabled); + return; + } + + list_del(&hcan->from_host_buf->list); + USBD_GS_CAN_PrepareReceive(pdev); restore_irq(was_irq_enabled); }