usb_error.c revision 188048
1184610Salfred/* $FreeBSD: head/sys/dev/usb2/core/usb2_error.c 188048 2009-02-03 05:50:36Z thompsa $ */ 2184610Salfred/*- 3184610Salfred * Copyright (c) 2008 Hans Petter Selasky. All rights reserved. 4184610Salfred * 5184610Salfred * Redistribution and use in source and binary forms, with or without 6184610Salfred * modification, are permitted provided that the following conditions 7184610Salfred * are met: 8184610Salfred * 1. Redistributions of source code must retain the above copyright 9184610Salfred * notice, this list of conditions and the following disclaimer. 10184610Salfred * 2. Redistributions in binary form must reproduce the above copyright 11184610Salfred * notice, this list of conditions and the following disclaimer in the 12184610Salfred * documentation and/or other materials provided with the distribution. 13184610Salfred * 14184610Salfred * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15184610Salfred * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16184610Salfred * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17184610Salfred * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18184610Salfred * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19184610Salfred * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20184610Salfred * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21184610Salfred * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22184610Salfred * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23184610Salfred * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24184610Salfred * SUCH DAMAGE. 25184610Salfred */ 26184610Salfred 27184610Salfred#include <dev/usb2/include/usb2_mfunc.h> 28184610Salfred#include <dev/usb2/include/usb2_error.h> 29184610Salfred 30184610Salfred#include <dev/usb2/core/usb2_core.h> 31184610Salfred 32188048Sthompsastatic const char* usb_errstr_table[USB_ERR_MAX] = { 33188048Sthompsa [USB_ERR_NORMAL_COMPLETION] = "USB_ERR_NORMAL_COMPLETION", 34188048Sthompsa [USB_ERR_BAD_ADDRESS] = "USB_ERR_BAD_ADDRESS", 35188048Sthompsa [USB_ERR_BAD_BUFSIZE] = "USB_ERR_BAD_BUFSIZE", 36188048Sthompsa [USB_ERR_BAD_CONTEXT] = "USB_ERR_BAD_CONTEXT", 37188048Sthompsa [USB_ERR_BAD_FLAG] = "USB_ERR_BAD_FLAG", 38188048Sthompsa [USB_ERR_CANCELLED] = "USB_ERR_CANCELLED", 39188048Sthompsa [USB_ERR_DMA_LOAD_FAILED] = "USB_ERR_DMA_LOAD_FAILED", 40188048Sthompsa [USB_ERR_INTERRUPTED] = "USB_ERR_INTERRUPTED", 41188048Sthompsa [USB_ERR_INVAL] = "USB_ERR_INVAL", 42188048Sthompsa [USB_ERR_IN_USE] = "USB_ERR_IN_USE", 43188048Sthompsa [USB_ERR_IOERROR] = "USB_ERR_IOERROR", 44188048Sthompsa [USB_ERR_NOMEM] = "USB_ERR_NOMEM", 45188048Sthompsa [USB_ERR_NOT_CONFIGURED] = "USB_ERR_NOT_CONFIGURED", 46188048Sthompsa [USB_ERR_NOT_LOCKED] = "USB_ERR_NOT_LOCKED", 47188048Sthompsa [USB_ERR_NOT_STARTED] = "USB_ERR_NOT_STARTED", 48188048Sthompsa [USB_ERR_NO_ADDR] = "USB_ERR_NO_ADDR", 49188048Sthompsa [USB_ERR_NO_CALLBACK] = "USB_ERR_NO_CALLBACK", 50188048Sthompsa [USB_ERR_NO_INTR_THREAD] = "USB_ERR_NO_INTR_THREAD", 51188048Sthompsa [USB_ERR_NO_PIPE] = "USB_ERR_NO_PIPE", 52188048Sthompsa [USB_ERR_NO_POWER] = "USB_ERR_NO_POWER", 53188048Sthompsa [USB_ERR_NO_ROOT_HUB] = "USB_ERR_NO_ROOT_HUB", 54188048Sthompsa [USB_ERR_PENDING_REQUESTS] = "USB_ERR_PENDING_REQUESTS", 55188048Sthompsa [USB_ERR_SET_ADDR_FAILED] = "USB_ERR_SET_ADDR_FAILED", 56188048Sthompsa [USB_ERR_SHORT_XFER] = "USB_ERR_SHORT_XFER", 57188048Sthompsa [USB_ERR_STALLED] = "USB_ERR_STALLED", 58188048Sthompsa [USB_ERR_TIMEOUT] = "USB_ERR_TIMEOUT", 59188048Sthompsa [USB_ERR_TOO_DEEP] = "USB_ERR_TOO_DEEP", 60188048Sthompsa [USB_ERR_ZERO_MAXP] = "USB_ERR_ZERO_MAXP", 61188048Sthompsa [USB_ERR_ZERO_NFRAMES] = "USB_ERR_ZERO_NFRAMES", 62188048Sthompsa}; 63184610Salfred/*------------------------------------------------------------------------* 64184610Salfred * usb2_errstr 65184610Salfred * 66184610Salfred * This function converts an USB error code into a string. 67184610Salfred *------------------------------------------------------------------------*/ 68184610Salfredconst char * 69184610Salfredusb2_errstr(usb2_error_t err) 70184610Salfred{ 71188048Sthompsa return (err < USB_ERR_MAX ? usb_errstr_table[err] : "USB_ERR_UNKNOWN"); 72184610Salfred} 73