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

Ignore:
Timestamp:
2012-08-17T11:37:03Z (9 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
1d5a540
Parents:
be2a38ad
Message:

Make ddf_dev_t and ddf_fun_t opaque. This further tighthens the DDF interface.

File:
1 edited

Legend:

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

    rbe2a38ad r56fd7cf  
    5353
    5454#define NAME "rootpc"
    55 
    56 /** Obtain function soft-state from DDF function node */
    57 #define ROOTPC_FUN(fnode) ((rootpc_fun_t *) (fnode)->driver_data)
    5855
    5956typedef struct rootpc_fun {
     
    10198};
    10299
     100/** Obtain function soft-state from DDF function node */
     101static rootpc_fun_t *rootpc_fun(ddf_fun_t *fnode)
     102{
     103        return ddf_fun_data_get(fnode);
     104}
     105
    103106static hw_resource_list_t *rootpc_get_resources(ddf_fun_t *fnode)
    104107{
    105         rootpc_fun_t *fun = ROOTPC_FUN(fnode);
     108        rootpc_fun_t *fun = rootpc_fun(fnode);
    106109       
    107110        assert(fun != NULL);
     
    126129static bool
    127130rootpc_add_fun(ddf_dev_t *dev, const char *name, const char *str_match_id,
    128     rootpc_fun_t *fun)
     131    rootpc_fun_t *fun_proto)
    129132{
    130133        ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name);
    131134       
    132135        ddf_fun_t *fnode = NULL;
    133         match_id_t *match_id = NULL;
     136        int rc;
    134137       
    135138        /* Create new device. */
     
    138141                goto failure;
    139142       
    140         fnode->driver_data = fun;
    141        
    142         /* Initialize match id list */
    143         match_id = create_match_id();
    144         if (match_id == NULL)
     143        rootpc_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(rootpc_fun_t));
     144        *fun = *fun_proto;
     145       
     146        /* Add match ID */
     147        rc = ddf_fun_add_match_id(fnode, str_match_id, 100);
     148        if (rc != EOK)
    145149                goto failure;
    146150       
    147         match_id->id = str_match_id;
    148         match_id->score = 100;
    149         add_match_id(&fnode->match_ids, match_id);
    150        
    151151        /* Set provided operations to the device. */
    152         fnode->ops = &rootpc_fun_ops;
     152        ddf_fun_set_ops(fnode, &rootpc_fun_ops);
    153153       
    154154        /* Register function. */
     
    161161       
    162162failure:
    163         if (match_id != NULL)
    164                 match_id->id = NULL;
    165        
    166163        if (fnode != NULL)
    167164                ddf_fun_destroy(fnode);
     
    186183{
    187184        ddf_msg(LVL_DEBUG, "rootpc_dev_add, device handle = %d",
    188             (int)dev->handle);
     185            (int)ddf_dev_get_handle(dev));
    189186       
    190187        /* Register functions. */
Note: See TracChangeset for help on using the changeset viewer.