Changeset 55e388a1 in mainline for uspace/lib/usb/src/usb.c


Ignore:
Timestamp:
2011-03-24T14:57:53Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b53d3b7
Parents:
361e61b (diff), e18e0d6 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Check of initialization of report parser structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/usb.c

    r361e61b r55e388a1  
    3636#include <errno.h>
    3737
     38#define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
     39
     40static const char *str_speed[] = {
     41        "low",
     42        "full",
     43        "high"
     44};
     45
     46static const char *str_transfer_type[] = {
     47        "control",
     48        "isochronous",
     49        "bulk",
     50        "interrupt"
     51};
     52
     53static const char *str_transfer_type_short[] = {
     54        "ctrl",
     55        "iso",
     56        "bulk",
     57        "intr"
     58};
    3859
    3960/** String representation for USB transfer type.
     
    4263 * @return Transfer type as a string (in English).
    4364 */
    44 const char * usb_str_transfer_type(usb_transfer_type_t t)
     65const char *usb_str_transfer_type(usb_transfer_type_t t)
    4566{
    46         switch (t) {
    47                 case USB_TRANSFER_ISOCHRONOUS:
    48                         return "isochronous";
    49                 case USB_TRANSFER_INTERRUPT:
    50                         return "interrupt";
    51                 case USB_TRANSFER_CONTROL:
    52                         return "control";
    53                 case USB_TRANSFER_BULK:
    54                         return "bulk";
    55                 default:
    56                         return "unknown";
     67        if (t >= ARR_SIZE(str_transfer_type)) {
     68                return "invalid";
    5769        }
     70        return str_transfer_type[t];
     71}
     72
     73/** String representation for USB transfer type (short version).
     74 *
     75 * @param t Transfer type.
     76 * @return Transfer type as a short string for debugging messages.
     77 */
     78const char *usb_str_transfer_type_short(usb_transfer_type_t t)
     79{
     80        if (t >= ARR_SIZE(str_transfer_type_short)) {
     81                return "invl";
     82        }
     83        return str_transfer_type_short[t];
     84}
     85
     86/** String representation of USB speed.
     87 *
     88 * @param s The speed.
     89 * @return USB speed as a string (in English).
     90 */
     91const char *usb_str_speed(usb_speed_t s)
     92{
     93        if (s >= ARR_SIZE(str_speed)) {
     94                return "invalid";
     95        }
     96        return str_speed[s];
    5897}
    5998
Note: See TracChangeset for help on using the changeset viewer.