| 152 | |
| 153 | #if defined(CONFIG_USBDEV_TRACE) || (defined(CONFIG_DEBUG_FEATURES) && defined(CONFIG_DEBUG_USB)) |
| 154 | void usbtrace(uint16_t event, uint16_t value) |
| 155 | { |
| 156 | irqstate_t flags; |
| 157 | |
| 158 | /* Check if tracing is enabled for this ID */ |
| 159 | |
| 160 | flags = spin_lock_irqsave(&g_lock); |
| 161 | if ((g_maskedidset & TRACE_ID2BIT(event)) != 0) |
| 162 | { |
| 163 | #ifdef CONFIG_USBDEV_TRACE |
| 164 | /* Yes... save the new trace data at the head */ |
| 165 | |
| 166 | g_trace[g_head].event = event; |
| 167 | g_trace[g_head].value = value; |
| 168 | |
| 169 | /* Increment the head and (probably) the tail index */ |
| 170 | |
| 171 | if (++g_head >= CONFIG_USBDEV_TRACE_NRECORDS) |
| 172 | { |
| 173 | g_head = 0; |
| 174 | } |
| 175 | |
| 176 | if (g_head == g_tail) |
| 177 | { |
| 178 | if (++g_tail >= CONFIG_USBDEV_TRACE_NRECORDS) |
| 179 | { |
| 180 | g_tail = 0; |
| 181 | } |
| 182 | } |
| 183 | |
| 184 | spin_unlock_irqrestore(&g_lock, flags); |
| 185 | #else |
| 186 | /* Just print the data using syslog */ |
| 187 | |
| 188 | spin_unlock_irqrestore(&g_lock, flags); |
| 189 | usbtrace_trprintf(usbtrace_syslog, event, value); |
| 190 | #endif |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | spin_unlock_irqrestore(&g_lock, flags); |
| 195 | } |
| 196 | } |
| 197 | #endif /* CONFIG_USBDEV_TRACE || CONFIG_DEBUG_FEATURES && CONFIG_DEBUG_USB */ |
| 198 | |
| 199 | /**************************************************************************** |
no test coverage detected