Skip to content

Commit 2db1b7b

Browse files
committed
Add check for optional device hid out endpoint
1 parent 68aee7d commit 2db1b7b

File tree

1 file changed

+46
-36
lines changed

1 file changed

+46
-36
lines changed

common/usbx_device_classes/src/ux_device_class_hid_deactivate.c

Lines changed: 46 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
/***************************************************************************
2-
* Copyright (c) 2024 Microsoft Corporation
3-
*
2+
* Copyright (c) 2024 Microsoft Corporation
3+
*
44
* This program and the accompanying materials are made available under the
55
* terms of the MIT License which is available at
66
* https://opensource.org/licenses/MIT.
7-
*
7+
*
88
* SPDX-License-Identifier: MIT
99
**************************************************************************/
1010

1111
/**************************************************************************/
1212
/**************************************************************************/
13-
/** */
14-
/** USBX Component */
13+
/** */
14+
/** USBX Component */
1515
/** */
1616
/** Device HID Class */
1717
/** */
@@ -28,40 +28,40 @@
2828
#include "ux_device_stack.h"
2929

3030

31-
/**************************************************************************/
32-
/* */
33-
/* FUNCTION RELEASE */
34-
/* */
35-
/* _ux_device_class_hid_deactivate PORTABLE C */
31+
/**************************************************************************/
32+
/* */
33+
/* FUNCTION RELEASE */
34+
/* */
35+
/* _ux_device_class_hid_deactivate PORTABLE C */
3636
/* 6.1.12 */
3737
/* AUTHOR */
3838
/* */
3939
/* Chaoqiong Xiao, Microsoft Corporation */
4040
/* */
4141
/* DESCRIPTION */
42-
/* */
43-
/* This function deactivate an instance of the hid class. */
44-
/* */
45-
/* INPUT */
46-
/* */
47-
/* command Pointer to a class command */
48-
/* */
49-
/* OUTPUT */
50-
/* */
51-
/* Completion Status */
52-
/* */
53-
/* CALLS */
54-
/* */
55-
/* _ux_device_stack_transfer_all_request_abort Abort all transfers */
56-
/* */
57-
/* CALLED BY */
58-
/* */
42+
/* */
43+
/* This function deactivate an instance of the hid class. */
44+
/* */
45+
/* INPUT */
46+
/* */
47+
/* command Pointer to a class command */
48+
/* */
49+
/* OUTPUT */
50+
/* */
51+
/* Completion Status */
52+
/* */
53+
/* CALLS */
54+
/* */
55+
/* _ux_device_stack_transfer_all_request_abort Abort all transfers */
56+
/* */
57+
/* CALLED BY */
58+
/* */
5959
/* HID Class */
60-
/* */
61-
/* RELEASE HISTORY */
62-
/* */
63-
/* DATE NAME DESCRIPTION */
64-
/* */
60+
/* */
61+
/* RELEASE HISTORY */
62+
/* */
63+
/* DATE NAME DESCRIPTION */
64+
/* */
6565
/* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
6666
/* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
6767
/* resulting in version 6.1 */
@@ -73,21 +73,31 @@
7373
/**************************************************************************/
7474
UINT _ux_device_class_hid_deactivate(UX_SLAVE_CLASS_COMMAND *command)
7575
{
76-
76+
7777
UX_SLAVE_CLASS_HID *hid;
7878
UX_SLAVE_CLASS *class_ptr;
79+
UX_SLAVE_ENDPOINT *endpoint;
7980

8081
/* Get the class container. */
8182
class_ptr = command -> ux_slave_class_command_class_ptr;
8283

8384
/* Get the class instance in the container. */
8485
hid = (UX_SLAVE_CLASS_HID *) class_ptr -> ux_slave_class_instance;
8586

86-
/* Terminate the transactions pending on the endpoints. */
87-
_ux_device_stack_transfer_all_request_abort(hid -> ux_device_class_hid_interrupt_endpoint, UX_TRANSFER_BUS_RESET);
87+
/* Locate the hid interrupt in endpoint. */
88+
endpoint = hid -> ux_device_class_hid_interrupt_endpoint;
89+
90+
/* Terminate the transactions pending on the endpoint. */
91+
if (endpoint)
92+
_ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET);
8893

8994
#if defined(UX_DEVICE_CLASS_HID_INTERRUPT_OUT_SUPPORT)
90-
_ux_device_stack_transfer_all_request_abort(hid -> ux_device_class_hid_read_endpoint, UX_TRANSFER_BUS_RESET);
95+
/* Locate the hid interrupt out endpoint. */
96+
endpoint = hid -> ux_device_class_hid_read_endpoint;
97+
98+
/* Terminate the transactions pending on the endpoint. */
99+
if (endpoint)
100+
_ux_device_stack_transfer_all_request_abort(endpoint, UX_TRANSFER_BUS_RESET);
91101
#endif
92102

93103
/* If there is a deactivate function call it. */

0 commit comments

Comments
 (0)