Changeset 8b1e15ac in mainline for uspace/drv/rootpc/rootpc.c
- Timestamp:
- 2011-02-11T22:26:36Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 68414f4a
- Parents:
- 1b367b4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/rootpc/rootpc.c
r1b367b4 r8b1e15ac 55 55 #define NAME "rootpc" 56 56 57 typedef struct rootpc_ child_dev_data {57 typedef struct rootpc_fun_data { 58 58 hw_resource_list_t hw_resources; 59 } rootpc_ child_dev_data_t;59 } rootpc_fun_data_t; 60 60 61 61 static int rootpc_add_device(device_t *dev); … … 82 82 }; 83 83 84 static rootpc_ child_dev_data_t pci_data = {84 static rootpc_fun_data_t pci_data = { 85 85 .hw_resources = { 86 86 1, … … 89 89 }; 90 90 91 static hw_resource_list_t *rootpc_get_ child_resources(device_t *dev)92 { 93 rootpc_ child_dev_data_t *data;94 95 data = (rootpc_ child_dev_data_t *) dev->driver_data;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 96 if (NULL == data) 97 97 return NULL; … … 100 100 } 101 101 102 static bool rootpc_enable_ child_interrupt(device_t *dev)102 static bool rootpc_enable_fun_interrupt(function_t *fun) 103 103 { 104 104 /* TODO */ … … 107 107 } 108 108 109 static hw_res_ops_t child_hw_res_ops = {110 &rootpc_get_ child_resources,111 &rootpc_enable_ child_interrupt109 static hw_res_ops_t fun_hw_res_ops = { 110 &rootpc_get_fun_resources, 111 &rootpc_enable_fun_interrupt 112 112 }; 113 113 114 114 /* Initialized in root_pc_init() function. */ 115 static device_ops_t rootpc_ child_ops;115 static device_ops_t rootpc_fun_ops; 116 116 117 117 static bool 118 rootpc_add_ child(device_t *parent, const char *name, const char *str_match_id,119 rootpc_ child_dev_data_t *drv_data)120 { 121 printf(NAME ": adding new child device'%s'.\n", name);122 123 device_t *child= NULL;118 rootpc_add_fun(device_t *parent, const char *name, const char *str_match_id, 119 rootpc_fun_data_t *drv_data) 120 { 121 printf(NAME ": adding new function '%s'.\n", name); 122 123 function_t *fun = NULL; 124 124 match_id_t *match_id = NULL; 125 125 126 126 /* Create new device. */ 127 child = create_device();128 if ( NULL == child)127 fun = create_function(); 128 if (fun == NULL) 129 129 goto failure; 130 130 131 child->name = name; 132 child->driver_data = drv_data; 131 fun->name = name; 132 fun->driver_data = drv_data; 133 fun->ftype = fun_inner; 133 134 134 135 /* Initialize match id list */ … … 139 140 match_id->id = str_match_id; 140 141 match_id->score = 100; 141 add_match_id(& child->match_ids, match_id);142 add_match_id(&fun->match_ids, match_id); 142 143 143 144 /* Set provided operations to the device. */ 144 child->ops = &rootpc_child_ops;145 146 /* Register child device. */147 if (EOK != child_device_register(child, parent))145 fun->ops = &rootpc_fun_ops; 146 147 /* Register function. */ 148 if (EOK != register_function(fun, parent)) 148 149 goto failure; 150 printf(NAME ": registered function handle = %u\n", fun->handle); 149 151 150 152 return true; … … 154 156 match_id->id = NULL; 155 157 156 if (NULL != child) {157 child->name = NULL;158 delete_ device(child);159 } 160 161 printf(NAME ": failed to add child device'%s'.\n", name);158 if (NULL != fun) { 159 fun->name = NULL; 160 delete_function(fun); 161 } 162 163 printf(NAME ": failed to add function '%s'.\n", name); 162 164 163 165 return false; 164 166 } 165 167 166 static bool rootpc_add_ children(device_t *dev)167 { 168 return rootpc_add_ child(dev, "pci0", "intel_pci", &pci_data);168 static bool rootpc_add_functions(device_t *dev) 169 { 170 return rootpc_add_fun(dev, "pci0", "intel_pci", &pci_data); 169 171 } 170 172 … … 180 182 (int)dev->handle); 181 183 182 /* Register child devices. */183 if (!rootpc_add_ children(dev)) {184 printf(NAME ": failed to add child devices for PC platform.\n");184 /* Register functions. */ 185 if (!rootpc_add_functions(dev)) { 186 printf(NAME ": failed to add functions for PC platform.\n"); 185 187 } 186 188 … … 190 192 static void root_pc_init(void) 191 193 { 192 rootpc_ child_ops.interfaces[HW_RES_DEV_IFACE] = &child_hw_res_ops;194 rootpc_fun_ops.interfaces[HW_RES_DEV_IFACE] = &fun_hw_res_ops; 193 195 } 194 196
Note:
See TracChangeset
for help on using the changeset viewer.