| 1 | /*
|
|---|
| 2 | * Copyright (c) 2010 Matus Dekanek
|
|---|
| 3 | * All rights reserved.
|
|---|
| 4 | *
|
|---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
|---|
| 6 | * modification, are permitted provided that the following conditions
|
|---|
| 7 | * are met:
|
|---|
| 8 | *
|
|---|
| 9 | * - Redistributions of source code must retain the above copyright
|
|---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
|---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
|---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
|---|
| 13 | * documentation and/or other materials provided with the distribution.
|
|---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
|---|
| 15 | * derived from this software without specific prior written permission.
|
|---|
| 16 | *
|
|---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|---|
| 27 | */
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | #ifndef USBLIST_H
|
|---|
| 31 | #define USBLIST_H
|
|---|
| 32 | /** @addtogroup usb hub driver
|
|---|
| 33 | * @{
|
|---|
| 34 | */
|
|---|
| 35 | /** @file
|
|---|
| 36 | * @brief HC driver and hub driver.
|
|---|
| 37 | *
|
|---|
| 38 | * My private list implementation; I did not like the original helenos list.
|
|---|
| 39 | * This one does not depend on the structure of stored data and has
|
|---|
| 40 | * much simpler and more straight-forward semantics.
|
|---|
| 41 | */
|
|---|
| 42 |
|
|---|
| 43 | /**
|
|---|
| 44 | * general list structure
|
|---|
| 45 | */
|
|---|
| 46 | typedef struct usb_general_list{
|
|---|
| 47 | void * data;
|
|---|
| 48 | struct usb_general_list * prev, * next;
|
|---|
| 49 | } usb_general_list_t;
|
|---|
| 50 |
|
|---|
| 51 | /** create head of usb general list */
|
|---|
| 52 | usb_general_list_t * usb_lst_create(void);
|
|---|
| 53 |
|
|---|
| 54 | /** initialize head of usb general list */
|
|---|
| 55 | void usb_lst_init(usb_general_list_t * lst);
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | /** is the list empty? */
|
|---|
| 59 | static inline bool usb_lst_empty(usb_general_list_t * lst){
|
|---|
| 60 | return lst?(lst->next==lst):true;
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | /** append data behind item */
|
|---|
| 64 | void usb_lst_append(usb_general_list_t * lst, void * data);
|
|---|
| 65 |
|
|---|
| 66 | /** prepend data beore item */
|
|---|
| 67 | void usb_lst_prepend(usb_general_list_t * lst, void * data);
|
|---|
| 68 |
|
|---|
| 69 | /** remove list item from list */
|
|---|
| 70 | void usb_lst_remove(usb_general_list_t * item);
|
|---|
| 71 |
|
|---|
| 72 | /** get data o specified type from list item */
|
|---|
| 73 | #define usb_lst_get_data(item, type) (type *) (item->data)
|
|---|
| 74 |
|
|---|
| 75 | /** get usb_hub_info_t data from list item */
|
|---|
| 76 | static inline usb_hub_info_t * usb_hub_lst_get_data(usb_general_list_t * item) {
|
|---|
| 77 | return usb_lst_get_data(item,usb_hub_info_t);
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 | /**
|
|---|
| 82 | * @}
|
|---|
| 83 | */
|
|---|
| 84 |
|
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 | #endif /* USBLIST_H */
|
|---|
| 88 |
|
|---|