Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/infrastructure/rootmac/rootmac.c

    r56fd7cf r3795f9c  
    4444#define NAME  "rootmac"
    4545
     46/** Obtain function soft-state from DDF function node */
     47#define ROOTMAC_FUN(fnode) \
     48        ((rootmac_fun_t *) (fnode)->driver_data)
     49
    4650typedef struct {
    4751        hw_resource_list_t hw_resources;
     
    7680static ddf_dev_ops_t rootmac_fun_ops;
    7781
    78 /** Obtain function soft-state from DDF function node */
    79 static rootmac_fun_t *rootmac_fun(ddf_fun_t *fnode)
    80 {
    81         return ddf_fun_data_get(fnode);
    82 }
    83 
    8482static bool rootmac_add_fun(ddf_dev_t *dev, const char *name,
    85     const char *str_match_id, rootmac_fun_t *fun_proto)
     83    const char *str_match_id, rootmac_fun_t *fun)
    8684{
    8785        ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
    8886       
    8987        ddf_fun_t *fnode = NULL;
    90         int rc;
     88        match_id_t *match_id = NULL;
    9189       
    9290        /* Create new device. */
     
    9593                goto failure;
    9694       
    97         rootmac_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(rootmac_fun_t));
    98         *fun = *fun_proto;
     95        fnode->driver_data = fun;
    9996       
    100         /* Add match ID */
    101         rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
    102         if (rc != EOK)
     97        /* Initialize match id list */
     98        match_id = create_match_id();
     99        if (match_id == NULL)
    103100                goto failure;
    104101       
     102        match_id->id = str_match_id;
     103        match_id->score = 100;
     104        add_match_id(&fnode->match_ids, match_id);
     105       
    105106        /* Set provided operations to the device. */
    106         ddf_fun_set_ops(fnode, &rootmac_fun_ops);
     107        fnode->ops = &rootmac_fun_ops;
    107108       
    108109        /* Register function. */
     
    115116       
    116117failure:
     118        if (match_id != NULL)
     119                match_id->id = NULL;
     120       
    117121        if (fnode != NULL)
    118122                ddf_fun_destroy(fnode);
     
    158162static hw_resource_list_t *rootmac_get_resources(ddf_fun_t *fnode)
    159163{
    160         rootmac_fun_t *fun = rootmac_fun(fnode);
     164        rootmac_fun_t *fun = ROOTMAC_FUN(fnode);
    161165        assert(fun != NULL);
    162166       
Note: See TracChangeset for help on using the changeset viewer.