source: mainline/uspace/drv/bus/usb/ohci/hw_struct/completion_codes.h

Last change on this file was 870841cf, checked in by Jiri Svoboda <jiri@…>, 5 months ago

Style issues related to improper use of 'inline' keyword.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2 * Copyright (c) 2025 Jiri Svoboda
3 * Copyright (c) 2011 Jan Vesely
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * - Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * - Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * - The name of the author may not be used to endorse or promote products
16 * derived from this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29/** @addtogroup drvusbohci
30 * @{
31 */
32/** @file
33 * @brief OHCI driver
34 */
35#ifndef DRV_OHCI_HW_STRUCT_COMPLETION_CODES_H
36#define DRV_OHCI_HW_STRUCT_COMPLETION_CODES_H
37
38#include <errno.h>
39
40enum {
41 CC_NOERROR = 0x0,
42 CC_CRC = 0x1,
43 CC_BITSTUFF = 0x2,
44 CC_TOGGLE = 0x3,
45 CC_STALL = 0x4,
46 CC_NORESPONSE = 0x5,
47 CC_PIDFAIL = 0x6,
48 CC_PIDUNEXPECTED = 0x7,
49 CC_DATAOVERRRUN = 0x8,
50 CC_DATAUNDERRRUN = 0x9,
51 CC_BUFFEROVERRRUN = 0xc,
52 CC_BUFFERUNDERRUN = 0xd,
53 CC_NOACCESS1 = 0xe,
54 CC_NOACCESS2 = 0xf,
55};
56
57static inline errno_t cc_to_rc(unsigned int cc)
58{
59 switch (cc) {
60 case CC_NOERROR:
61 return EOK;
62
63 case CC_CRC:
64 return EBADCHECKSUM;
65
66 case CC_PIDUNEXPECTED:
67 case CC_PIDFAIL:
68 case CC_BITSTUFF:
69 return EIO;
70
71 case CC_TOGGLE:
72 case CC_STALL:
73 return ESTALL;
74
75 case CC_NORESPONSE:
76 return ETIMEOUT;
77
78 case CC_DATAOVERRRUN:
79 case CC_DATAUNDERRRUN:
80 case CC_BUFFEROVERRRUN:
81 case CC_BUFFERUNDERRUN:
82 return EOVERFLOW;
83
84 case CC_NOACCESS1:
85 case CC_NOACCESS2:
86 default:
87 return ENOTSUP;
88 }
89}
90
91#endif
92/**
93 * @}
94 */
Note: See TracBrowser for help on using the repository browser.