[e080332] | 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 |
|
---|
[281ebae] | 29 | /** @addtogroup drvusbhub
|
---|
[e080332] | 30 | * @{
|
---|
| 31 | */
|
---|
| 32 | /** @file
|
---|
| 33 | * @brief HC driver and hub driver.
|
---|
| 34 | *
|
---|
| 35 | * My private list implementation; I did not like the original helenos list.
|
---|
| 36 | * This one does not depend on the structure of stored data and has
|
---|
| 37 | * much simpler and more straight-forward semantics.
|
---|
| 38 | */
|
---|
[3b77628] | 39 | #ifndef USBLIST_H
|
---|
| 40 | #define USBLIST_H
|
---|
[e080332] | 41 |
|
---|
| 42 | /**
|
---|
| 43 | * general list structure
|
---|
| 44 | */
|
---|
| 45 | typedef struct usb_general_list{
|
---|
| 46 | void * data;
|
---|
| 47 | struct usb_general_list * prev, * next;
|
---|
| 48 | } usb_general_list_t;
|
---|
| 49 |
|
---|
| 50 | /** create head of usb general list */
|
---|
| 51 | usb_general_list_t * usb_lst_create(void);
|
---|
| 52 |
|
---|
| 53 | /** initialize head of usb general list */
|
---|
| 54 | void usb_lst_init(usb_general_list_t * lst);
|
---|
| 55 |
|
---|
| 56 |
|
---|
| 57 | /** is the list empty? */
|
---|
| 58 | static inline bool usb_lst_empty(usb_general_list_t * lst){
|
---|
| 59 | return lst?(lst->next==lst):true;
|
---|
| 60 | }
|
---|
| 61 |
|
---|
| 62 | /** append data behind item */
|
---|
| 63 | void usb_lst_append(usb_general_list_t * lst, void * data);
|
---|
| 64 |
|
---|
| 65 | /** prepend data beore item */
|
---|
| 66 | void usb_lst_prepend(usb_general_list_t * lst, void * data);
|
---|
| 67 |
|
---|
| 68 | /** remove list item from list */
|
---|
| 69 | void usb_lst_remove(usb_general_list_t * item);
|
---|
| 70 |
|
---|
| 71 | /** get data o specified type from list item */
|
---|
| 72 | #define usb_lst_get_data(item, type) (type *) (item->data)
|
---|
| 73 |
|
---|
| 74 | /** get usb_hub_info_t data from list item */
|
---|
| 75 | static inline usb_hub_info_t * usb_hub_lst_get_data(usb_general_list_t * item) {
|
---|
| 76 | return usb_lst_get_data(item,usb_hub_info_t);
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[3b77628] | 79 | #endif /* USBLIST_H */
|
---|
[e080332] | 80 | /**
|
---|
| 81 | * @}
|
---|
| 82 | */
|
---|