source: mainline/uspace/drv/usbhub/usblist.h@ f40a1e2

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since f40a1e2 was e080332, checked in by Matus Dekanek <smekideki@…>, 15 years ago

usb hub code refactoring

  • Property mode set to 100644
File size: 2.8 KB
Line 
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 */
46typedef 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 */
52usb_general_list_t * usb_lst_create(void);
53
54/** initialize head of usb general list */
55void usb_lst_init(usb_general_list_t * lst);
56
57
58/** is the list empty? */
59static inline bool usb_lst_empty(usb_general_list_t * lst){
60 return lst?(lst->next==lst):true;
61}
62
63/** append data behind item */
64void usb_lst_append(usb_general_list_t * lst, void * data);
65
66/** prepend data beore item */
67void usb_lst_prepend(usb_general_list_t * lst, void * data);
68
69/** remove list item from list */
70void 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 */
76static 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
Note: See TracBrowser for help on using the repository browser.