Changeset 08d9c4e6 in mainline for uspace/srv/devman/devman.h
- Timestamp:
- 2010-02-15T21:04:59Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e85920d
- Parents:
- e2b9a993
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/devman/devman.h
re2b9a993 r08d9c4e6 30 30 * @{ 31 31 */ 32 32 33 33 #ifndef DEVMAN_H_ 34 34 #define DEVMAN_H_ … … 41 41 #include <ipc/ipc.h> 42 42 43 #include "util.h" 43 44 44 45 #define NAME "devman" … … 97 98 node_t *parent; 98 99 /** Pointers to previous and next child devices in the linked list of parent device's node.*/ 99 link_t sibling; 100 link_t sibling; 100 101 /** List of child device nodes. */ 101 102 link_t children; 102 103 /** List of device ids for device-to-driver matching.*/ 103 match_id_list_t match_ids; 104 match_id_list_t match_ids; 104 105 /** Driver of this device.*/ 105 driver_t *drv; 106 driver_t *drv; 106 107 /** Pointer to the previous and next device in the list of devices 107 108 owned by one driver */ 108 link_t driver_devices; 109 link_t driver_devices; 109 110 }; 110 111 … … 130 131 131 132 132 static inline match_id_t * create_match_id() 133 static inline match_id_t * create_match_id() 133 134 { 134 135 match_id_t *id = malloc(sizeof(match_id_t)); 135 136 memset(id, 0, sizeof(match_id_t)); 136 return id; 137 } 138 139 static inline void delete_match_id(match_id_t *id) 140 { 141 free(id->id); 142 free(id); 137 return id; 138 } 139 140 static inline void delete_match_id(match_id_t *id) 141 { 142 if (id) { 143 free_not_null(id->id); 144 free(id); 145 } 143 146 } 144 147 … … 152 155 bool assign_driver(node_t *node, link_t *drivers_list); 153 156 154 void attach_driver(node_t *node, driver_t *drv); 157 void attach_driver(node_t *node, driver_t *drv); 155 158 bool add_device(driver_t *drv, node_t *node); 156 159 bool start_driver(driver_t *drv); 157 160 158 161 159 static inline void init_driver(driver_t *drv) 160 { 161 assert(drv != NULL); 162 163 memset(drv, 0, sizeof(driver_t)); 162 static inline void init_driver(driver_t *drv) 163 { 164 printf(NAME ": init_driver\n"); 165 assert(drv != NULL); 166 167 memset(drv, 0, sizeof(driver_t)); 164 168 list_initialize(&drv->match_ids.ids); 165 169 list_initialize(&drv->devices); 166 170 } 167 171 168 static inline void clean_driver(driver_t *drv) 169 { 172 static inline void clean_driver(driver_t *drv) 173 { 174 printf(NAME ": clean_driver\n"); 170 175 assert(drv != NULL); 176 177 free_not_null(drv->name); 178 free_not_null(drv->binary_path); 179 180 clean_match_ids(&drv->match_ids); 181 182 init_driver(drv); 183 } 184 185 static inline void delete_driver(driver_t *drv) 186 { 187 printf(NAME ": delete_driver\n"); 188 assert(NULL != drv); 171 189 172 free(drv->name);173 free(drv->binary_path);174 175 clean_match_ids(&drv->match_ids);176 177 init_driver(drv);178 }179 180 static inline void delete_driver(driver_t *drv)181 {182 190 clean_driver(drv); 183 191 free(drv); … … 187 195 { 188 196 list_prepend(&drv->drivers, drivers_list); 189 printf(NAME": the '%s' driver was added to the list of available drivers.\n", drv->name); 197 printf(NAME": the '%s' driver was added to the list of available drivers.\n", drv->name); 190 198 } 191 199 … … 198 206 node_t *res = malloc(sizeof(node_t)); 199 207 if (res != NULL) { 200 memset(res, 0, sizeof(node_t)); 208 memset(res, 0, sizeof(node_t)); 201 209 } 202 210 return res; 203 211 } 204 212 205 static inline void init_dev_node(node_t *node, node_t *parent) 213 static inline void init_dev_node(node_t *node, node_t *parent) 206 214 { 207 215 assert(NULL != node); 208 216 209 217 node->parent = parent; 210 218 if (NULL != parent) { 211 219 list_append(&node->sibling, &parent->children); 212 220 } 213 221 214 222 list_initialize(&node->children); 215 216 list_initialize(&node->match_ids.ids); 223 224 list_initialize(&node->match_ids.ids); 217 225 } 218 226
Note:
See TracChangeset
for help on using the changeset viewer.