Changeset 2be2506a in mainline
- Timestamp:
- 2012-08-31T17:32:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0cf5246
- Parents:
- 96e01fbc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/infrastructure/rootamdm37x/rootamdm37x.c
r96e01fbc r2be2506a 35 35 /** @file 36 36 */ 37 #define _DDF_DATA_IMPLANT 37 38 38 39 #include <ddf/driver.h> … … 49 50 50 51 #define NAME "rootamdm37x" 51 52 /** Obtain function soft-state from DDF function node */53 #define ROOTARM_FUN(fnode) \54 ((rootamdm37x_fun_t *) (fnode)->driver_data)55 52 56 53 typedef struct { … … 258 255 ddf_msg(LVL_DEBUG, "Adding new function '%s'.", name); 259 256 260 ddf_fun_t *fnode = NULL; 261 match_id_t *match_id = NULL; 262 263 /* Create new device. */ 264 fnode = ddf_fun_create(dev, fun_inner, name); 257 /* Create new device function. */ 258 ddf_fun_t *fnode = ddf_fun_create(dev, fun_inner, name); 265 259 if (fnode == NULL) 266 goto failure; 267 268 fnode->driver_data = (void*)fun; 269 270 /* Initialize match id list */ 271 match_id = create_match_id(); 272 if (match_id == NULL) 273 goto failure; 274 275 match_id->id = str_match_id; 276 match_id->score = 100; 277 add_match_id(&fnode->match_ids, match_id); 260 return ENOMEM; 261 262 263 /* Add match id */ 264 if (ddf_fun_add_match_id(fnode, str_match_id, 100) != EOK) { 265 // TODO This will try to free our data! 266 ddf_fun_destroy(fnode); 267 return false; 268 } 278 269 279 270 /* Set provided operations to the device. */ 280 fnode->ops = &rootamdm37x_fun_ops; 271 ddf_fun_data_implant(fnode, (void*)fun); 272 ddf_fun_set_ops(fnode, &rootamdm37x_fun_ops); 281 273 282 274 /* Register function. */ 283 275 if (ddf_fun_bind(fnode) != EOK) { 284 276 ddf_msg(LVL_ERROR, "Failed binding function %s.", name); 285 goto failure; 277 ddf_fun_destroy(fnode); 278 return false; 286 279 } 287 280 288 281 return true; 289 290 failure:291 if (match_id != NULL)292 match_id->id = NULL;293 294 if (fnode != NULL) {295 fnode->driver_data = NULL;296 ddf_fun_destroy(fnode);297 }298 299 ddf_msg(LVL_ERROR, "Failed adding function '%s'.", name);300 301 return false;302 282 } 303 283 … … 349 329 static hw_resource_list_t *rootamdm37x_get_resources(ddf_fun_t *fnode) 350 330 { 351 rootamdm37x_fun_t *fun = ROOTARM_FUN(fnode);331 rootamdm37x_fun_t *fun = ddf_fun_data_get(fnode); 352 332 assert(fun != NULL); 353 333 return &fun->hw_resources;
Note:
See TracChangeset
for help on using the changeset viewer.