Changeset 56fd7cf in mainline for uspace/drv/infrastructure
- Timestamp:
- 2012-08-17T11:37:03Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1d5a540
- Parents:
- be2a38ad
- Location:
- uspace/drv/infrastructure
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/infrastructure/root/root.c
rbe2a38ad r56fd7cf 204 204 { 205 205 ddf_msg(LVL_DEBUG, "root_dev_add, device handle=%" PRIun, 206 d ev->handle);206 ddf_dev_get_handle(dev)); 207 207 208 208 /* -
uspace/drv/infrastructure/rootmac/rootmac.c
rbe2a38ad r56fd7cf 44 44 #define NAME "rootmac" 45 45 46 /** Obtain function soft-state from DDF function node */47 #define ROOTMAC_FUN(fnode) \48 ((rootmac_fun_t *) (fnode)->driver_data)49 50 46 typedef struct { 51 47 hw_resource_list_t hw_resources; … … 80 76 static ddf_dev_ops_t rootmac_fun_ops; 81 77 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 82 84 static bool rootmac_add_fun(ddf_dev_t *dev, const char *name, 83 const char *str_match_id, rootmac_fun_t *fun )85 const char *str_match_id, rootmac_fun_t *fun_proto) 84 86 { 85 87 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name); 86 88 87 89 ddf_fun_t *fnode = NULL; 88 match_id_t *match_id = NULL;90 int rc; 89 91 90 92 /* Create new device. */ … … 93 95 goto failure; 94 96 95 fnode->driver_data = fun; 97 rootmac_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(rootmac_fun_t)); 98 *fun = *fun_proto; 96 99 97 /* Initialize match id list*/98 match_id = create_match_id();99 if ( match_id == NULL)100 /* Add match ID */ 101 rc = ddf_fun_add_match_id(fnode, str_match_id, 100); 102 if (rc != EOK) 100 103 goto failure; 101 104 102 match_id->id = str_match_id;103 match_id->score = 100;104 add_match_id(&fnode->match_ids, match_id);105 106 105 /* Set provided operations to the device. */ 107 fnode->ops = &rootmac_fun_ops;106 ddf_fun_set_ops(fnode, &rootmac_fun_ops); 108 107 109 108 /* Register function. */ … … 116 115 117 116 failure: 118 if (match_id != NULL)119 match_id->id = NULL;120 121 117 if (fnode != NULL) 122 118 ddf_fun_destroy(fnode); … … 162 158 static hw_resource_list_t *rootmac_get_resources(ddf_fun_t *fnode) 163 159 { 164 rootmac_fun_t *fun = ROOTMAC_FUN(fnode);160 rootmac_fun_t *fun = rootmac_fun(fnode); 165 161 assert(fun != NULL); 166 162 -
uspace/drv/infrastructure/rootpc/rootpc.c
rbe2a38ad r56fd7cf 53 53 54 54 #define NAME "rootpc" 55 56 /** Obtain function soft-state from DDF function node */57 #define ROOTPC_FUN(fnode) ((rootpc_fun_t *) (fnode)->driver_data)58 55 59 56 typedef struct rootpc_fun { … … 101 98 }; 102 99 100 /** Obtain function soft-state from DDF function node */ 101 static rootpc_fun_t *rootpc_fun(ddf_fun_t *fnode) 102 { 103 return ddf_fun_data_get(fnode); 104 } 105 103 106 static hw_resource_list_t *rootpc_get_resources(ddf_fun_t *fnode) 104 107 { 105 rootpc_fun_t *fun = ROOTPC_FUN(fnode);108 rootpc_fun_t *fun = rootpc_fun(fnode); 106 109 107 110 assert(fun != NULL); … … 126 129 static bool 127 130 rootpc_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) 129 132 { 130 133 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name); 131 134 132 135 ddf_fun_t *fnode = NULL; 133 match_id_t *match_id = NULL;136 int rc; 134 137 135 138 /* Create new device. */ … … 138 141 goto failure; 139 142 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) 145 149 goto failure; 146 150 147 match_id->id = str_match_id;148 match_id->score = 100;149 add_match_id(&fnode->match_ids, match_id);150 151 151 /* Set provided operations to the device. */ 152 fnode->ops = &rootpc_fun_ops;152 ddf_fun_set_ops(fnode, &rootpc_fun_ops); 153 153 154 154 /* Register function. */ … … 161 161 162 162 failure: 163 if (match_id != NULL)164 match_id->id = NULL;165 166 163 if (fnode != NULL) 167 164 ddf_fun_destroy(fnode); … … 186 183 { 187 184 ddf_msg(LVL_DEBUG, "rootpc_dev_add, device handle = %d", 188 (int)d ev->handle);185 (int)ddf_dev_get_handle(dev)); 189 186 190 187 /* Register functions. */ -
uspace/drv/infrastructure/rootvirt/rootvirt.c
rbe2a38ad r56fd7cf 151 151 { 152 152 int rc; 153 const char *name = rvfun->fun->name;153 const char *name = ddf_fun_get_name(rvfun->fun); 154 154 155 155 ddf_msg(LVL_DEBUG, "rootvirt_fun_remove('%s')", name); … … 183 183 } 184 184 185 ddf_msg(LVL_DEBUG, "dev_add(handle=%d)", (int)d ev->handle);185 ddf_msg(LVL_DEBUG, "dev_add(handle=%d)", (int)ddf_dev_get_handle(dev)); 186 186 187 187 rootvirt = ddf_dev_data_alloc(dev, sizeof(rootvirt_t)); … … 207 207 static int rootvirt_dev_remove(ddf_dev_t *dev) 208 208 { 209 rootvirt_t *rootvirt = (rootvirt_t *)d ev->driver_data;209 rootvirt_t *rootvirt = (rootvirt_t *)ddf_dev_data_get(dev); 210 210 int rc; 211 211
Note:
See TracChangeset
for help on using the changeset viewer.