GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: core/src/ux_host_stack_class_call.c Lines: 10 10 100.0 %
Date: 2026-03-06 18:57:10 Branches: 6 6 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   Host Stack                                                          */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
#include "ux_host_stack.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _ux_host_stack_class_call                           PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Chaoqiong Xiao, Microsoft Corporation                               */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This function will call all the registered classes to the USBX      */
45
/*    stack. Each class will have the possibility to own the device or    */
46
/*    one of the interfaces of a device.                                  */
47
/*                                                                        */
48
/*  INPUT                                                                 */
49
/*                                                                        */
50
/*    class_command                         Class command structure       */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    Number of owners                                                    */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    (ux_host_class_entry_function)        Class entry function          */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    USBX Components                                                     */
63
/*                                                                        */
64
/**************************************************************************/
65
3316
UX_HOST_CLASS  *_ux_host_stack_class_call(UX_HOST_CLASS_COMMAND *class_command)
66
{
67
68
3316
UINT            status = UX_NO_CLASS_MATCH;
69
UX_HOST_CLASS   *class_inst;
70
#if UX_MAX_CLASS_DRIVER > 1
71
ULONG           class_index;
72
#endif
73
74
    /* Start from the 1st registered classes with USBX.  */
75
3316
    class_inst =  _ux_system_host -> ux_system_host_class_array;
76
77
    /* Parse all the class drivers.  */
78
#if UX_MAX_CLASS_DRIVER > 1
79
17849
    for (class_index = 0; class_index < _ux_system_host -> ux_system_host_max_class; class_index++)
80
    {
81
#endif
82
83
        /* Check if this class driver is used.  */
84
16036
        if (class_inst -> ux_host_class_status == UX_USED)
85
        {
86
87
            /* We have found a potential candidate. Call this registered class entry function.  */
88
3437
            status = class_inst -> ux_host_class_entry_function(class_command);
89
90
            /* The status tells us if the registered class wants to own this class.  */
91
3437
            if (status == UX_SUCCESS)
92
            {
93
94
                /* Yes, return this class pointer.  */
95
1503
                return(class_inst);
96
            }
97
        }
98
#if UX_MAX_CLASS_DRIVER > 1
99
        /* Move to the next registered class. */
100
14533
        class_inst ++;
101
    }
102
#endif
103
104
    /* There is no driver who want to own this class!  */
105
1813
    return(UX_NULL);
106
}