Changeset 68414f4a in mainline for uspace/drv/rootpc/rootpc.c
- Timestamp:
- 2011-02-13T20:03:45Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bab6388
- Parents:
- 8b1e15ac
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/rootpc/rootpc.c
r8b1e15ac r68414f4a 55 55 #define NAME "rootpc" 56 56 57 typedef struct rootpc_fun_data { 57 /** Obtain function soft-state from DDF function node */ 58 #define ROOTPC_FUN(fnode) ((rootpc_fun_t *) (fnode)->driver_data) 59 60 typedef struct rootpc_fun { 58 61 hw_resource_list_t hw_resources; 59 } rootpc_fun_ data_t;62 } rootpc_fun_t; 60 63 61 64 static int rootpc_add_device(device_t *dev); … … 82 85 }; 83 86 84 static rootpc_fun_ data_t pci_data = {87 static rootpc_fun_t pci_data = { 85 88 .hw_resources = { 86 89 1, … … 89 92 }; 90 93 91 static hw_resource_list_t *rootpc_get_fun_resources(function_t *fun) 92 { 93 rootpc_fun_data_t *data; 94 95 data = (rootpc_fun_data_t *) fun->driver_data; 96 if (NULL == data) 97 return NULL; 98 99 return &data->hw_resources; 100 } 101 102 static bool rootpc_enable_fun_interrupt(function_t *fun) 94 static hw_resource_list_t *rootpc_get_resources(function_t *fnode) 95 { 96 rootpc_fun_t *fun = ROOTPC_FUN(fnode); 97 98 assert(fun != NULL); 99 return &fun->hw_resources; 100 } 101 102 static bool rootpc_enable_interrupt(function_t *fun) 103 103 { 104 104 /* TODO */ … … 108 108 109 109 static hw_res_ops_t fun_hw_res_ops = { 110 &rootpc_get_ fun_resources,111 &rootpc_enable_ fun_interrupt110 &rootpc_get_resources, 111 &rootpc_enable_interrupt 112 112 }; 113 113 … … 116 116 117 117 static bool 118 rootpc_add_fun(device_t * parent, const char *name, const char *str_match_id,119 rootpc_fun_ data_t *drv_data)118 rootpc_add_fun(device_t *dev, const char *name, const char *str_match_id, 119 rootpc_fun_t *fun) 120 120 { 121 121 printf(NAME ": adding new function '%s'.\n", name); 122 122 123 function_t *f un= NULL;123 function_t *fnode = NULL; 124 124 match_id_t *match_id = NULL; 125 125 126 126 /* Create new device. */ 127 f un= create_function();128 if (f un== NULL)127 fnode = create_function(); 128 if (fnode == NULL) 129 129 goto failure; 130 130 131 f un->name = name;132 f un->driver_data = drv_data;133 f un->ftype = fun_inner;131 fnode->name = name; 132 fnode->driver_data = fun; 133 fnode->ftype = fun_inner; 134 134 135 135 /* Initialize match id list */ 136 136 match_id = create_match_id(); 137 if ( NULL == match_id)137 if (match_id == NULL) 138 138 goto failure; 139 139 140 140 match_id->id = str_match_id; 141 141 match_id->score = 100; 142 add_match_id(&f un->match_ids, match_id);142 add_match_id(&fnode->match_ids, match_id); 143 143 144 144 /* Set provided operations to the device. */ 145 f un->ops = &rootpc_fun_ops;145 fnode->ops = &rootpc_fun_ops; 146 146 147 147 /* Register function. */ 148 if ( EOK != register_function(fun, parent))148 if (register_function(fnode, dev) != EOK) 149 149 goto failure; 150 printf(NAME ": registered function handle = %u\n", f un->handle);150 printf(NAME ": registered function handle = %u\n", fnode->handle); 151 151 152 152 return true; 153 153 154 154 failure: 155 if ( NULL != match_id)155 if (match_id != NULL) 156 156 match_id->id = NULL; 157 157 158 if ( NULL != fun) {159 f un->name = NULL;160 delete_function(f un);158 if (fnode != NULL) { 159 fnode->name = NULL; 160 delete_function(fnode); 161 161 } 162 162
Note:
See TracChangeset
for help on using the changeset viewer.