Changeset e86b8f0 in mainline for uspace/drv/nic/lo/lo.c
- Timestamp:
- 2012-01-21T12:50:28Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 77a69ea, 86c71de
- Parents:
- 3fe58d3c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/lo/lo.c
r3fe58d3c re86b8f0 80 80 static int lo_dev_add(ddf_dev_t *dev) 81 81 { 82 nic_t *nic_data = nic_create_and_bind(dev); 83 if (nic_data == NULL) { 82 ddf_fun_t *fun = NULL; 83 bool bound = false; 84 85 nic_t *nic = nic_create_and_bind(dev); 86 if (nic == NULL) { 84 87 printf("%s: Failed to initialize\n", NAME); 85 88 return ENOMEM; 86 89 } 87 90 88 dev->driver_data = nic _data;89 nic_set_send_frame_handler(nic _data, lo_send_frame);91 dev->driver_data = nic; 92 nic_set_send_frame_handler(nic, lo_send_frame); 90 93 91 int rc = nic_connect_to_services(nic _data);94 int rc = nic_connect_to_services(nic); 92 95 if (rc != EOK) { 93 96 printf("%s: Failed to connect to services\n", NAME); 94 nic_unbind_and_destroy(dev); 95 return rc; 97 goto error; 96 98 } 97 99 98 rc = nic_register_as_ddf_fun(nic_data, &lo_dev_ops); 100 fun = ddf_fun_create(nic_get_ddf_dev(nic), fun_exposed, "port0"); 101 if (fun == NULL) { 102 printf("%s: Failed creating function\n", NAME); 103 rc = ENOMEM; 104 goto error; 105 } 106 nic_set_ddf_fun(nic, fun); 107 fun->ops = &lo_dev_ops; 108 fun->driver_data = nic; 109 110 rc = nic_report_address(nic, &lo_addr); 99 111 if (rc != EOK) { 100 printf("%s: Failed to register as DDF function\n", NAME); 101 nic_unbind_and_destroy(dev); 102 return rc; 112 printf("%s: Failed to setup loopback address\n", NAME); 113 goto error; 103 114 } 104 115 105 rc = nic_report_address(nic_data, &lo_addr);116 rc = ddf_fun_bind(fun); 106 117 if (rc != EOK) { 107 printf("%s: Failed to setup loopback address\n", NAME); 108 nic_unbind_and_destroy(dev); 109 return rc; 118 printf("%s: Failed binding function\n", NAME); 119 goto error; 110 120 } 121 bound = true; 122 123 rc = ddf_fun_add_to_category(fun, DEVICE_CATEGORY_NIC); 124 if (rc != EOK) 125 goto error; 111 126 112 127 printf("%s: Adding loopback device '%s'\n", NAME, dev->name); 113 128 return EOK; 129 error: 130 if (bound) 131 ddf_fun_unbind(fun); 132 if (fun != NULL) 133 ddf_fun_destroy(fun); 134 135 nic_unbind_and_destroy(dev); 136 return rc; 114 137 } 115 138
Note:
See TracChangeset
for help on using the changeset viewer.