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