Changes in / [1f1fa64:cbfece7] in mainline
- Location:
- uspace
- Files:
-
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/hc.c
r1f1fa64 rcbfece7 193 193 instance->rh.address = 1; 194 194 rc = usb_device_manager_request_address( 195 &instance->generic ->dev_manager, &instance->rh.address, false,195 &instance->generic.dev_manager, &instance->rh.address, false, 196 196 USB_SPEED_FULL); 197 197 if (rc != EOK) { … … 204 204 205 205 rc = usb_endpoint_manager_add_ep( 206 &instance->generic ->ep_manager, instance->rh.address, 0,206 &instance->generic.ep_manager, instance->rh.address, 0, 207 207 USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, USB_SPEED_FULL, 64, 208 208 0, NULL, NULL); … … 231 231 fun_bound = true; 232 232 233 rc = usb_device_manager_bind_address(&instance->generic ->dev_manager,233 rc = usb_device_manager_bind_address(&instance->generic.dev_manager, 234 234 instance->rh.address, ddf_fun_get_handle(hub_fun)); 235 235 if (rc != EOK) { … … 244 244 if (ep_added) { 245 245 usb_endpoint_manager_remove_ep( 246 &instance->generic ->ep_manager, instance->rh.address, 0,246 &instance->generic.ep_manager, instance->rh.address, 0, 247 247 USB_DIRECTION_BOTH, NULL, NULL); 248 248 } 249 249 if (addr_reqd) { 250 250 usb_device_manager_release_address( 251 &instance->generic ->dev_manager, instance->rh.address);251 &instance->generic.dev_manager, instance->rh.address); 252 252 } 253 253 return rc; … … 257 257 * 258 258 * @param[in] instance Memory place for the structure. 259 * @param[in] HC function node260 259 * @param[in] regs Device's I/O registers range. 261 260 * @param[in] interrupts True if w interrupts should be used 262 261 * @return Error code 263 262 */ 264 int hc_init(hc_t *instance, ddf_fun_t *fun,addr_range_t *regs, bool interrupts)263 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 265 264 { 266 265 assert(instance); … … 275 274 list_initialize(&instance->pending_batches); 276 275 277 instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t)); 278 if (instance->generic == NULL) { 279 usb_log_error("Out of memory.\n"); 280 return ENOMEM; 281 } 282 283 hcd_init(instance->generic, USB_SPEED_FULL, 276 hcd_init(&instance->generic, USB_SPEED_FULL, 284 277 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 285 instance->generic ->private_data = instance;286 instance->generic ->schedule = hc_schedule;287 instance->generic ->ep_add_hook = ohci_endpoint_init;288 instance->generic ->ep_remove_hook = ohci_endpoint_fini;278 instance->generic.private_data = instance; 279 instance->generic.schedule = hc_schedule; 280 instance->generic.ep_add_hook = ohci_endpoint_init; 281 instance->generic.ep_remove_hook = ohci_endpoint_fini; 289 282 290 283 rc = hc_init_memory(instance); -
uspace/drv/bus/usb/ohci/hc.h
r1f1fa64 rcbfece7 35 35 #define DRV_OHCI_HC_H 36 36 37 #include <ddf/driver.h>38 37 #include <ddf/interrupt.h> 39 38 #include <fibril.h> … … 54 53 typedef struct hc { 55 54 /** Generic USB hc driver */ 56 hcd_t *generic;55 hcd_t generic; 57 56 58 57 /** Memory mapped I/O registers area */ … … 80 79 int hc_register_irq_handler(ddf_dev_t *, addr_range_t *, int, 81 80 interrupt_handler_t); 82 int hc_register_hub(hc_t * , ddf_fun_t *);83 int hc_init(hc_t * , ddf_fun_t *, addr_range_t *, bool);81 int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun); 82 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts); 84 83 85 84 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/ohci/ohci.c
r1f1fa64 rcbfece7 34 34 */ 35 35 36 /* XXX Fix this */ 37 #define _DDF_DATA_IMPLANT 38 36 39 #include <errno.h> 37 40 #include <str_error.h> … … 162 165 163 166 ddf_fun_set_ops(instance->hc_fun, &hc_ops); 167 ddf_fun_data_implant(instance->hc_fun, &instance->hc); 164 168 165 169 instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh"); … … 210 214 } 211 215 212 rc = hc_init(&instance->hc, instance->hc_fun,®s, interrupts);216 rc = hc_init(&instance->hc, ®s, interrupts); 213 217 if (rc != EOK) { 214 218 usb_log_error("Failed to init ohci_hcd: %s.\n", str_error(rc)); -
uspace/drv/bus/usb/uhci/hc.c
r1f1fa64 rcbfece7 230 230 * 231 231 * @param[in] instance Memory place to initialize. 232 * @param[in] HC function node233 232 * @param[in] regs Range of device's I/O control registers. 234 233 * @param[in] interrupts True if hw interrupts should be used. … … 239 238 * interrupt fibrils. 240 239 */ 241 int hc_init(hc_t *instance, ddf_fun_t *fun,addr_range_t *regs, bool interrupts)240 int hc_init(hc_t *instance, addr_range_t *regs, bool interrupts) 242 241 { 243 242 assert(regs->size >= sizeof(uhci_regs_t)); … … 267 266 } 268 267 269 instance->generic = ddf_fun_data_alloc(fun, sizeof(hcd_t)); 270 if (instance->generic == NULL) { 271 usb_log_error("Out of memory.\n"); 272 return ENOMEM; 273 } 274 275 hcd_init(instance->generic, USB_SPEED_FULL, 268 hcd_init(&instance->generic, USB_SPEED_FULL, 276 269 BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11); 277 270 278 instance->generic ->private_data = instance;279 instance->generic ->schedule = hc_schedule;280 instance->generic ->ep_add_hook = NULL;271 instance->generic.private_data = instance; 272 instance->generic.schedule = hc_schedule; 273 instance->generic.ep_add_hook = NULL; 281 274 282 275 hc_init_hw(instance); -
uspace/drv/bus/usb/uhci/hc.h
r1f1fa64 rcbfece7 36 36 #define DRV_UHCI_HC_H 37 37 38 #include <ddf/driver.h>39 38 #include <ddf/interrupt.h> 40 39 #include <device/hw_res_parsed.h> … … 94 93 typedef struct hc { 95 94 /** Generic HCD driver structure */ 96 hcd_t *generic;95 hcd_t generic; 97 96 98 97 /** Addresses of I/O registers */ … … 127 126 addr_range_t *); 128 127 void hc_interrupt(hc_t *instance, uint16_t status); 129 int hc_init(hc_t * , ddf_fun_t *, addr_range_t *, bool);128 int hc_init(hc_t *instance, addr_range_t *regs, bool interupts); 130 129 131 130 /** Safely dispose host controller internal structures -
uspace/drv/bus/usb/uhci/uhci.c
r1f1fa64 rcbfece7 34 34 */ 35 35 36 /* XXX Fix this */ 37 #define _DDF_DATA_IMPLANT 38 36 39 #include <errno.h> 37 40 #include <stdbool.h> … … 59 62 hc_t hc; 60 63 /** Internal driver's representation of UHCI root hub */ 61 rh_t *rh;64 rh_t rh; 62 65 } uhci_t; 63 66 … … 183 186 184 187 ddf_fun_set_ops(instance->hc_fun, &hc_ops); 188 ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic); 185 189 186 190 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh"); … … 192 196 193 197 ddf_fun_set_ops(instance->rh_fun, &rh_ops); 194 instance->rh = ddf_fun_data_alloc(instance->rh_fun, sizeof(rh_t));198 ddf_fun_data_implant(instance->rh_fun, &instance->rh); 195 199 196 200 addr_range_t regs; … … 232 236 } 233 237 234 rc = hc_init(&instance->hc, instance->hc_fun,®s, interrupts);238 rc = hc_init(&instance->hc, ®s, interrupts); 235 239 if (rc != EOK) { 236 240 usb_log_error("Failed to init uhci_hcd: %s.\n", str_error(rc)); … … 256 260 } 257 261 258 rc = rh_init( instance->rh, instance->rh_fun, ®s, 0x10, 4);262 rc = rh_init(&instance->rh, instance->rh_fun, ®s, 0x10, 4); 259 263 if (rc != EOK) { 260 264 usb_log_error("Failed to setup UHCI root hub: %s.\n", -
uspace/drv/bus/usb/uhcirh/port.c
r1f1fa64 rcbfece7 269 269 int ret, count = MAX_ERROR_COUNT; 270 270 do { 271 port->attached_device.fun = ddf_fun_create(port->rh, fun_inner, 272 NULL); 273 if (port->attached_device.fun == NULL) { 274 ret = ENOMEM; 275 continue; 276 } 277 278 ret = usb_hc_new_device_wrapper(port->rh, 279 port->attached_device.fun, 280 &port->hc_connection, 271 ret = usb_hc_new_device_wrapper(port->rh, &port->hc_connection, 281 272 speed, uhci_port_reset_enable, port, 282 &port->attached_device.address, NULL); 283 284 if (ret != EOK) { 285 ddf_fun_destroy(port->attached_device.fun); 286 port->attached_device.fun = NULL; 287 } 288 273 &port->attached_device.address, NULL, NULL, 274 &port->attached_device.fun); 289 275 } while (ret != EOK && count-- > 0); 290 276 -
uspace/drv/bus/usb/usbhid/usbhid.c
r1f1fa64 rcbfece7 415 415 } 416 416 417 /* Initialize subdrivers */ 417 /* 418 * 1) subdriver vytvori vlastnu ddf_fun, vlastne ddf_dev_ops, ktore da 419 * do nej. 420 * 2) do tych ops do .interfaces[DEV_IFACE_USBHID (asi)] priradi 421 * vyplnenu strukturu usbhid_iface_t. 422 * 3) klientska aplikacia - musi si rucne vytvorit telefon 423 * (devman_device_connect() - cesta k zariadeniu (/hw/pci0/...) az 424 * k tej fcii. 425 * pouzit usb/classes/hid/iface.h - prvy int je telefon 426 */ 418 427 bool ok = false; 419 428 for (unsigned i = 0; i < hid_dev->subdriver_count; ++i) { -
uspace/drv/bus/usb/usbhub/port.c
r1f1fa64 rcbfece7 424 424 ddf_fun_t *child_fun; 425 425 426 child_fun = ddf_fun_create(data->hub->usb_device->ddf_dev,427 fun_inner, NULL);428 if (child_fun == NULL)429 return ENOMEM;430 431 426 const int rc = usb_hc_new_device_wrapper(data->hub->usb_device->ddf_dev, 432 child_fun, &data->hub->usb_device->hc_conn, data->speed,433 enable_port_callback, data->port, &new_address, NULL);427 &data->hub->usb_device->hc_conn, data->speed, enable_port_callback, 428 data->port, &new_address, NULL, NULL, &child_fun); 434 429 435 430 if (rc == EOK) { … … 445 440 ddf_fun_get_handle(child_fun)); 446 441 } else { 447 ddf_fun_destroy(child_fun);448 442 usb_log_error("Failed registering device on port %zu: %s.\n", 449 443 data->port->port_number, str_error(rc)); -
uspace/drv/bus/usb/usbmid/explore.c
r1f1fa64 rcbfece7 34 34 * Exploration of available interfaces in the USB device. 35 35 */ 36 #include <ddf/driver.h>37 36 #include <errno.h> 38 37 #include <str_error.h> … … 71 70 * @param config_descriptor_size Size of configuration descriptor in bytes. 72 71 * @param list List where to add the interfaces. 73 * @return EOK on success, ENOMEM if out of memory. 74 */ 75 static int create_interfaces(usb_mid_t *mid, const uint8_t *config_descriptor, 76 size_t config_descriptor_size) 72 */ 73 static void create_interfaces(const uint8_t *config_descriptor, 74 size_t config_descriptor_size, list_t *list) 77 75 { 78 76 const usb_dp_parser_data_t data = { … … 103 101 104 102 /* Skip alternate interfaces. */ 105 if (interface_in_list(&mid->interface_list, 106 interface->interface_number)) { 103 if (interface_in_list(list, interface->interface_number)) { 107 104 /* TODO: add the alternatives and create match ids 108 105 * for them. */ 109 106 continue; 110 107 } 111 112 /* Create the function */ 113 ddf_fun_t *fun = ddf_fun_create(mid->dev, fun_inner, NULL); 114 if (fun == NULL) 115 goto error; 116 117 usbmid_interface_t *iface = ddf_fun_data_alloc(fun, 118 sizeof(usbmid_interface_t)); 119 if (iface == NULL) 120 goto error; 108 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t)); 109 if (iface == NULL) { 110 //TODO: Do something about that failure. 111 break; 112 } 121 113 122 114 link_initialize(&iface->link); 123 iface->fun = fun;115 iface->fun = NULL; 124 116 iface->interface_no = interface->interface_number; 125 117 iface->interface = interface; 126 118 127 list_append(&iface->link, &mid->interface_list); 128 } 129 130 return EOK; 131 error: 132 while (!list_empty(&mid->interface_list)) { 133 link_t *link = list_first(&mid->interface_list); 134 usbmid_interface_t *iface = list_get_instance(link, 135 usbmid_interface_t, link); 136 137 ddf_fun_destroy(iface->fun); 138 } 139 140 return ENOMEM; 119 list_append(&iface->link, list); 120 } 141 121 } 142 122 … … 185 165 } 186 166 187 usb_mid->dev = dev->ddf_dev;188 189 167 /* Create control function. */ 190 168 usb_mid->ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl"); … … 204 182 } 205 183 184 206 185 /* Create interface children. */ 207 186 list_initialize(&usb_mid->interface_list); 208 create_interfaces(usb_mid, config_descriptor_raw, config_descriptor_size); 187 create_interfaces(config_descriptor_raw, config_descriptor_size, 188 &usb_mid->interface_list); 209 189 210 190 /* Start child function for every interface. */ -
uspace/drv/bus/usb/usbmid/usbmid.c
r1f1fa64 rcbfece7 30 30 * @{ 31 31 */ 32 33 /* XXX Fix this */ 34 #define _DDF_DATA_IMPLANT 32 35 33 36 /** … … 99 102 const usb_standard_interface_descriptor_t *interface_descriptor) 100 103 { 104 ddf_fun_t *child = NULL; 101 105 char *child_name = NULL; 102 106 int rc; … … 110 114 usb_str_class(interface_descriptor->interface_class), 111 115 interface_descriptor->interface_number); 112 if (rc < 0) 116 if (rc < 0) { 113 117 return ENOMEM; 118 } 114 119 115 rc = ddf_fun_set_name(iface->fun, child_name); 120 /* Create the device. */ 121 child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name); 116 122 free(child_name); 117 if ( rc != EOK)123 if (child == NULL) { 118 124 return ENOMEM; 125 } 119 126 120 127 match_id_list_t match_ids; … … 123 130 rc = usb_device_create_match_ids_from_interface(device_descriptor, 124 131 interface_descriptor, &match_ids); 125 if (rc != EOK) 132 if (rc != EOK) { 133 ddf_fun_destroy(child); 126 134 return rc; 135 } 127 136 128 137 list_foreach(match_ids.ids, link, match_id_t, match_id) { 129 rc = ddf_fun_add_match_id( iface->fun, match_id->id, match_id->score);138 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 130 139 if (rc != EOK) { 131 140 clean_match_ids(&match_ids); 141 ddf_fun_destroy(child); 132 142 return rc; 133 143 } … … 135 145 clean_match_ids(&match_ids); 136 146 137 ddf_fun_set_ops(iface->fun, &child_device_ops); 147 rc = ddf_fun_bind(child); 148 if (rc != EOK) { 149 /* This takes care of match_id deallocation as well. */ 150 ddf_fun_destroy(child); 151 return rc; 152 } 138 153 139 rc = ddf_fun_bind(iface->fun);140 if (rc != EOK)141 return rc;154 iface->fun = child; 155 ddf_fun_data_implant(child, iface); 156 ddf_fun_set_ops(child, &child_device_ops); 142 157 143 158 return EOK; -
uspace/drv/bus/usb/usbmid/usbmid.h
r1f1fa64 rcbfece7 60 60 /** Container to hold all the function pointers */ 61 61 typedef struct usb_mid { 62 ddf_dev_t *dev;63 62 ddf_fun_t *ctl_fun; 64 63 list_t interface_list; -
uspace/drv/bus/usb/vhc/hub.c
r1f1fa64 rcbfece7 94 94 { 95 95 ddf_fun_t *hc_dev = (ddf_fun_t *) arg; 96 97 /* 98 * Wait until parent device is properly initialized. 99 */ 100 async_sess_t *sess; 101 do { 102 sess = devman_device_connect(EXCHANGE_SERIALIZE, 103 ddf_fun_get_handle(hc_dev), 0); 104 } while (!sess); 105 async_hangup(sess); 106 96 107 int rc; 97 108 … … 103 114 104 115 ddf_fun_t *hub_dev; 105 106 hub_dev = ddf_fun_create(ddf_fun_get_dev(hc_dev), fun_inner, NULL); 107 if (hub_dev == NULL) { 108 rc = ENOMEM; 109 usb_log_fatal("Failed to create root hub: %s.\n", 110 str_error(rc)); 111 return rc; 112 } 113 114 rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), hub_dev, 115 &hc_conn, USB_SPEED_FULL, pretend_port_rest, NULL, NULL, &rh_ops); 116 rc = usb_hc_new_device_wrapper(ddf_fun_get_dev(hc_dev), &hc_conn, USB_SPEED_FULL, 117 pretend_port_rest, NULL, NULL, &rh_ops, hc_dev, &hub_dev); 116 118 if (rc != EOK) { 117 119 usb_log_fatal("Failed to create root hub: %s.\n", 118 120 str_error(rc)); 119 ddf_fun_destroy(hub_dev);120 121 } 121 122 -
uspace/drv/nic/e1k/e1k.c
r1f1fa64 rcbfece7 71 71 /** ddf_fun_t * -> nic_driver_data_t* cast */ 72 72 #define NIC_DATA_FUN(fun) \ 73 ((nic_t *) ddf_ dev_data_get(ddf_fun_get_dev(fun)))73 ((nic_t *) ddf_fun_data_get(fun)) 74 74 75 75 /** ddf_dev_t * -> nic_driver_data_t* cast */ -
uspace/drv/nic/rtl8169/driver.c
r1f1fa64 rcbfece7 439 439 nic_set_ddf_fun(nic_data, fun); 440 440 ddf_fun_set_ops(fun, &rtl8169_dev_ops); 441 //ddf_fun_data_implant(fun, nic_data);441 ddf_fun_data_implant(fun, nic_data); 442 442 443 443 rc = ddf_fun_bind(fun); -
uspace/lib/drv/generic/driver.c
r1f1fa64 rcbfece7 36 36 /** @file 37 37 */ 38 39 #define _DDF_DATA_IMPLANT 38 40 39 41 #include <assert.h> … … 594 596 } 595 597 598 /** Implant foreign driver-specific device data. 599 * 600 * XXX This is used to transition USB to new interface. Do not use 601 * in new code. Use of this function must be removed. 602 */ 603 void ddf_fun_data_implant(ddf_fun_t *fun, void *data) 604 { 605 assert(fun->driver_data == NULL); 606 fun->driver_data = data; 607 } 608 596 609 /** Return driver-specific device data. */ 597 610 void *ddf_dev_data_get(ddf_dev_t *dev) -
uspace/lib/drv/include/ddf/driver.h
r1f1fa64 rcbfece7 111 111 } driver_t; 112 112 113 /** XXX Only to transition USB */ 114 #ifdef _DDF_DATA_IMPLANT 115 extern void ddf_fun_data_implant(ddf_fun_t *, void *); 116 #endif 117 113 118 extern int ddf_driver_main(const driver_t *); 114 119 -
uspace/lib/nic/src/nic_driver.c
r1f1fa64 rcbfece7 47 47 #include <ops/nic.h> 48 48 #include <errno.h> 49 50 #include <io/log.h>51 49 52 50 #include "nic_driver.h" … … 438 436 int rc = nic_ev_addr_changed(nic_data->client_session, 439 437 address); 440 log_msg(LOG_DEFAULT, LVL_WARN, "rc=%d", rc);441 442 438 if (rc != EOK) { 443 439 fibril_rwlock_write_unlock(&nic_data->main_lock); -
uspace/lib/nic/src/nic_impl.c
r1f1fa64 rcbfece7 179 179 180 180 nic_data->send_frame(nic_data, data, size); 181 fibril_rwlock_read_unlock(&nic_data->main_lock);182 181 return EOK; 183 182 } -
uspace/lib/usbdev/include/usb/dev/hub.h
r1f1fa64 rcbfece7 44 44 #include <usb/hc.h> 45 45 46 extern int usb_hc_new_device_wrapper(ddf_dev_t *, ddf_fun_t *,47 usb_hc_connection_t *, usb_speed_t, int (*)(void *), void *,48 usb_address_t *, ddf_dev_ops_t*);46 extern int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t, 47 int (*)(void *), void *, usb_address_t *, ddf_dev_ops_t *, void *, 48 ddf_fun_t **); 49 49 50 50 /** Info about device attached to host controller. -
uspace/lib/usbdev/include/usb/dev/recognise.h
r1f1fa64 rcbfece7 52 52 53 53 extern int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, 54 ddf_dev_t *, ddf_ fun_t *, ddf_dev_ops_t*);54 ddf_dev_t *, ddf_dev_ops_t *, void *, ddf_fun_t **); 55 55 56 56 #endif -
uspace/lib/usbdev/src/hub.c
r1f1fa64 rcbfece7 155 155 * request or requests for descriptors when creating match ids). 156 156 */ 157 int usb_hc_new_device_wrapper(ddf_dev_t *parent, ddf_fun_t *fun,157 int usb_hc_new_device_wrapper(ddf_dev_t *parent, 158 158 usb_hc_connection_t *hc_conn, usb_speed_t dev_speed, 159 159 int (*enable_port)(void *arg), void *arg, usb_address_t *assigned_address, 160 ddf_dev_ops_t *dev_ops )160 ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun) 161 161 { 162 if ( hc_conn == NULL)162 if ((new_fun == NULL) || (hc_conn == NULL)) 163 163 return EINVAL; 164 164 … … 271 271 /* Register the device with devman. */ 272 272 /* FIXME: create device_register that will get opened ctrl pipe. */ 273 ddf_fun_t *child_fun; 273 274 rc = usb_device_register_child_in_devman(&ctrl_pipe, 274 parent, fun, dev_ops);275 parent, dev_ops, new_dev_data, &child_fun); 275 276 if (rc != EOK) { 276 277 goto leave_release_free_address; … … 279 280 const usb_hub_attached_device_t new_device = { 280 281 .address = dev_addr, 281 .fun = fun,282 .fun = child_fun, 282 283 }; 283 284 … … 287 288 if (rc != EOK) { 288 289 /* The child function is already created. */ 290 ddf_fun_destroy(child_fun); 289 291 rc = EDESTADDRREQ; 290 292 goto leave_release_free_address; … … 294 296 *assigned_address = dev_addr; 295 297 } 298 299 *new_fun = child_fun; 296 300 297 301 rc = EOK; -
uspace/lib/usbdev/src/recognise.c
r1f1fa64 rcbfece7 33 33 * Functions for recognition of attached devices. 34 34 */ 35 36 /** XXX Fix this */ 37 #define _DDF_DATA_IMPLANT 35 38 36 39 #include <sys/types.h> … … 315 318 */ 316 319 int usb_device_register_child_in_devman(usb_pipe_t *ctrl_pipe, 317 ddf_dev_t *parent, ddf_fun_t *fun, ddf_dev_ops_t *dev_ops) 320 ddf_dev_t *parent, ddf_dev_ops_t *dev_ops, void *dev_data, 321 ddf_fun_t **child_fun) 318 322 { 319 if (c trl_pipe == NULL)323 if (child_fun == NULL || ctrl_pipe == NULL) 320 324 return EINVAL; 321 325 322 if (!dev_ops && d df_fun_data_get(fun) != NULL) {326 if (!dev_ops && dev_data) { 323 327 usb_log_warning("Using standard fun ops with arbitrary " 324 328 "driver data. This does not have to work.\n"); … … 330 334 (size_t) atomic_preinc(&device_name_index); 331 335 336 ddf_fun_t *child = NULL; 332 337 int rc; 333 338 … … 343 348 } 344 349 345 rc = ddf_fun_set_name(fun, child_name); 346 if (rc != EOK) 350 child = ddf_fun_create(parent, fun_inner, child_name); 351 if (child == NULL) { 352 rc = ENOMEM; 347 353 goto failure; 354 } 348 355 349 356 if (dev_ops != NULL) 350 ddf_fun_set_ops( fun, dev_ops);357 ddf_fun_set_ops(child, dev_ops); 351 358 else 352 ddf_fun_set_ops(fun, &child_ops); 359 ddf_fun_set_ops(child, &child_ops); 360 361 ddf_fun_data_implant(child, dev_data); 353 362 354 363 /* … … 356 365 * driver data if there is no other data 357 366 */ 358 if ( ddf_fun_data_get(fun) == NULL) {367 if (!dev_data) { 359 368 usb_hub_attached_device_t *new_device = ddf_fun_data_alloc( 360 fun, sizeof(usb_hub_attached_device_t));369 child, sizeof(usb_hub_attached_device_t)); 361 370 if (!new_device) { 362 371 rc = ENOMEM; … … 365 374 366 375 new_device->address = ctrl_pipe->wire->address; 367 new_device->fun = fun;376 new_device->fun = child; 368 377 } 369 378 … … 375 384 376 385 list_foreach(match_ids.ids, link, match_id_t, match_id) { 377 rc = ddf_fun_add_match_id( fun, match_id->id, match_id->score);386 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 378 387 if (rc != EOK) { 379 388 clean_match_ids(&match_ids); … … 384 393 clean_match_ids(&match_ids); 385 394 386 rc = ddf_fun_bind( fun);395 rc = ddf_fun_bind(child); 387 396 if (rc != EOK) 388 397 goto failure; 389 398 399 *child_fun = child; 390 400 return EOK; 391 401 392 402 failure: 403 if (child != NULL) { 404 /* This takes care of match_id deallocation as well. */ 405 ddf_fun_destroy(child); 406 } 407 393 408 return rc; 394 409 } -
uspace/srv/net/ethip/ethip_nic.c
r1f1fa64 rcbfece7 231 231 ipc_call_t *call) 232 232 { 233 uint8_t *addr; 234 size_t size; 235 int rc; 236 237 rc = async_data_write_accept((void **)&addr, false, 0, 0, 0, &size); 238 if (rc != EOK) { 239 log_msg(LOG_DEFAULT, LVL_DEBUG, "data_write_accept() failed"); 240 return; 241 } 242 243 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_changed(): " 244 "new addr=%02x:%02x:%02x:%02x:%02x:%02x", 245 addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); 246 247 free(addr); 248 async_answer_0(callid, EOK); 233 log_msg(LOG_DEFAULT, LVL_DEBUG, "ethip_nic_addr_changed()"); 234 async_answer_0(callid, ENOTSUP); 249 235 } 250 236 … … 309 295 break; 310 296 default: 311 log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %d", IPC_GET_IMETHOD(call));312 297 async_answer_0(callid, ENOTSUP); 313 298 }
Note:
See TracChangeset
for help on using the changeset viewer.