Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 08d9c4e6 in mainline for uspace/srv/devman/devman.h


Ignore:
Timestamp:
2010-02-15T21:04:59Z (12 years ago)
Author:
Lenka Trochtova <trochtova.lenka@…>
Branches:
lfn, master
Children:
e85920d
Parents:
e2b9a993
Message:

device manager - initialization of the list of available drivers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/devman/devman.h

    re2b9a993 r08d9c4e6  
    3030 * @{
    3131 */
    32  
     32
    3333#ifndef DEVMAN_H_
    3434#define DEVMAN_H_
     
    4141#include <ipc/ipc.h>
    4242
     43#include "util.h"
    4344
    4445#define NAME "devman"
     
    9798        node_t *parent;
    9899        /** Pointers to previous and next child devices in the linked list of parent device's node.*/
    99         link_t sibling; 
     100        link_t sibling;
    100101        /** List of child device nodes. */
    101102        link_t children;
    102103        /** List of device ids for device-to-driver matching.*/
    103         match_id_list_t match_ids;     
     104        match_id_list_t match_ids;
    104105        /** Driver of this device.*/
    105         driver_t *drv; 
     106        driver_t *drv;
    106107        /** Pointer to the previous and next device in the list of devices
    107108            owned by one driver */
    108         link_t driver_devices; 
     109        link_t driver_devices;
    109110};
    110111
     
    130131
    131132
    132 static inline match_id_t * create_match_id() 
     133static inline match_id_t * create_match_id()
    133134{
    134135        match_id_t *id = malloc(sizeof(match_id_t));
    135136        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
     140static inline void delete_match_id(match_id_t *id)
     141{
     142        if (id) {
     143                free_not_null(id->id);
     144                free(id);
     145        }
    143146}
    144147
     
    152155bool assign_driver(node_t *node, link_t *drivers_list);
    153156
    154 void attach_driver(node_t *node, driver_t *drv); 
     157void attach_driver(node_t *node, driver_t *drv);
    155158bool add_device(driver_t *drv, node_t *node);
    156159bool start_driver(driver_t *drv);
    157160
    158161
    159 static inline void init_driver(driver_t *drv)
    160 {
    161         assert(drv != NULL);   
    162        
    163         memset(drv, 0, sizeof(driver_t));       
     162static 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));
    164168        list_initialize(&drv->match_ids.ids);
    165169        list_initialize(&drv->devices);
    166170}
    167171
    168 static inline void clean_driver(driver_t *drv)
    169 {
     172static inline void clean_driver(driver_t *drv)
     173{
     174        printf(NAME ": clean_driver\n");
    170175        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
     185static inline void delete_driver(driver_t *drv)
     186{
     187        printf(NAME ": delete_driver\n");
     188        assert(NULL != drv);
    171189       
    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 {
    182190        clean_driver(drv);
    183191        free(drv);
     
    187195{
    188196        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);
    190198}
    191199
     
    198206        node_t *res = malloc(sizeof(node_t));
    199207        if (res != NULL) {
    200                 memset(res, 0, sizeof(node_t)); 
     208                memset(res, 0, sizeof(node_t));
    201209        }
    202210        return res;
    203211}
    204212
    205 static inline void init_dev_node(node_t *node, node_t *parent) 
     213static inline void init_dev_node(node_t *node, node_t *parent)
    206214{
    207215        assert(NULL != node);
    208        
     216
    209217        node->parent = parent;
    210218        if (NULL != parent) {
    211219                list_append(&node->sibling, &parent->children);
    212220        }
    213        
     221
    214222        list_initialize(&node->children);
    215        
    216         list_initialize(&node->match_ids.ids); 
     223
     224        list_initialize(&node->match_ids.ids);
    217225}
    218226
Note: See TracChangeset for help on using the changeset viewer.