Changes in uspace/drv/nic/rtl8139/driver.c [f300523:b7fd2a0] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/nic/rtl8139/driver.c
rf300523 rb7fd2a0 217 217 * @param address The place to store the address 218 218 * 219 * @return EOK if succeed, negativeerror code otherwise219 * @return EOK if succeed, error code otherwise 220 220 */ 221 221 inline static void rtl8139_hw_get_addr(rtl8139_t *rtl8139, … … 280 280 } 281 281 282 static int rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *);283 static int rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info);284 static int rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state);285 static int rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,282 static errno_t rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *); 283 static errno_t rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info); 284 static errno_t rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state); 285 static errno_t rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed, 286 286 nic_channel_mode_t *duplex, nic_role_t *role); 287 static int rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,287 static errno_t rtl8139_set_operation_mode(ddf_fun_t *fun, int speed, 288 288 nic_channel_mode_t duplex, nic_role_t); 289 289 290 static int rtl8139_pause_get(ddf_fun_t*, nic_result_t*, nic_result_t*,290 static errno_t rtl8139_pause_get(ddf_fun_t*, nic_result_t*, nic_result_t*, 291 291 uint16_t *); 292 static int rtl8139_pause_set(ddf_fun_t*, int, int, uint16_t);293 294 static int rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement);295 static int rtl8139_autoneg_disable(ddf_fun_t *fun);296 static int rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *our_advertisement,292 static errno_t rtl8139_pause_set(ddf_fun_t*, int, int, uint16_t); 293 294 static errno_t rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement); 295 static errno_t rtl8139_autoneg_disable(ddf_fun_t *fun); 296 static errno_t rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *our_advertisement, 297 297 uint32_t *their_advertisement, nic_result_t *result, 298 298 nic_result_t *their_result); 299 static int rtl8139_autoneg_restart(ddf_fun_t *fun);300 301 static int rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode);302 static int rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode);303 304 static int rtl8139_wol_virtue_add(nic_t *nic_data,299 static errno_t rtl8139_autoneg_restart(ddf_fun_t *fun); 300 301 static errno_t rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode); 302 static errno_t rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode); 303 304 static errno_t rtl8139_wol_virtue_add(nic_t *nic_data, 305 305 const nic_wol_virtue_t *virtue); 306 306 static void rtl8139_wol_virtue_rem(nic_t *nic_data, 307 307 const nic_wol_virtue_t *virtue); 308 308 309 static int rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,309 static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode, 310 310 const struct timeval *period); 311 311 static void rtl8139_poll(nic_t *nic_data); … … 334 334 static ddf_dev_ops_t rtl8139_dev_ops; 335 335 336 static int rtl8139_dev_add(ddf_dev_t *dev);336 static errno_t rtl8139_dev_add(ddf_dev_t *dev); 337 337 338 338 /** Basic driver operations for RTL8139 driver */ … … 348 348 349 349 /* The default implementation callbacks */ 350 static int rtl8139_on_activated(nic_t *nic_data);351 static int rtl8139_on_stopped(nic_t *nic_data);350 static errno_t rtl8139_on_activated(nic_t *nic_data); 351 static errno_t rtl8139_on_stopped(nic_t *nic_data); 352 352 static void rtl8139_send_frame(nic_t *nic_data, void *data, size_t size); 353 353 … … 842 842 * @param nic_data The driver data 843 843 * 844 * @return IRQ capability handle if the handler was registered. 845 * @return Negative error code otherwise. 846 */ 847 inline static int rtl8139_register_int_handler(nic_t *nic_data) 844 * @param[out] handle IRQ capability handle if the handler was registered. 845 * 846 * @return An error code otherwise. 847 */ 848 inline static errno_t rtl8139_register_int_handler(nic_t *nic_data, cap_handle_t *handle) 848 849 { 849 850 rtl8139_t *rtl8139 = nic_get_specific(nic_data); … … 856 857 rtl8139_irq_code.cmds[2].addr = rtl8139->io_addr + ISR; 857 858 rtl8139_irq_code.cmds[3].addr = rtl8139->io_addr + IMR; 858 int cap= register_interrupt_handler(nic_get_ddf_dev(nic_data),859 rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code );859 errno_t rc = register_interrupt_handler(nic_get_ddf_dev(nic_data), 860 rtl8139->irq, rtl8139_interrupt_handler, &rtl8139_irq_code, handle); 860 861 861 862 RTL8139_IRQ_STRUCT_UNLOCK(); 862 863 863 return cap;864 return rc; 864 865 } 865 866 … … 903 904 * @return EOK if activated successfully, error code otherwise 904 905 */ 905 static int rtl8139_on_activated(nic_t *nic_data)906 static errno_t rtl8139_on_activated(nic_t *nic_data) 906 907 { 907 908 assert(nic_data); … … 918 919 rtl8139_hw_int_set(rtl8139); 919 920 920 int rc = hw_res_enable_interrupt(rtl8139->parent_sess, rtl8139->irq);921 errno_t rc = hw_res_enable_interrupt(rtl8139->parent_sess, rtl8139->irq); 921 922 if (rc != EOK) { 922 923 rtl8139_on_stopped(nic_data); … … 934 935 * @return EOK if succeed, error code otherwise 935 936 */ 936 static int rtl8139_on_stopped(nic_t *nic_data)937 static errno_t rtl8139_on_stopped(nic_t *nic_data) 937 938 { 938 939 assert(nic_data); … … 954 955 955 956 956 static int rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,957 static errno_t rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 957 958 const nic_address_t *, size_t); 958 static int rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,959 static errno_t rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode, 959 960 const nic_address_t *addr, size_t addr_count); 960 static int rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode);961 static errno_t rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode); 961 962 962 963 … … 1024 1025 * @param hw_resources Devices hardware resources 1025 1026 * 1026 * @return EOK if succeed, negativeerror code otherwise1027 */ 1028 static int rtl8139_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t1027 * @return EOK if succeed, error code otherwise 1028 */ 1029 static errno_t rtl8139_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t 1029 1030 *hw_resources) 1030 1031 { … … 1064 1065 * @param dev The device structure 1065 1066 * 1066 * @return EOK if succeed, negativeerror code otherwise1067 */ 1068 static int rtl8139_get_resource_info(ddf_dev_t *dev)1067 * @return EOK if succeed, error code otherwise 1068 */ 1069 static errno_t rtl8139_get_resource_info(ddf_dev_t *dev) 1069 1070 { 1070 1071 assert(dev); … … 1077 1078 1078 1079 /* Get hw resources form parent driver */ 1079 int rc = nic_get_resources(nic_data, &hw_res_parsed);1080 errno_t rc = nic_get_resources(nic_data, &hw_res_parsed); 1080 1081 if (rc != EOK) 1081 1082 return rc; 1082 1083 1083 1084 /* Fill resources information to the device */ 1084 int ret = rtl8139_fill_resource_info(dev, &hw_res_parsed);1085 errno_t ret = rtl8139_fill_resource_info(dev, &hw_res_parsed); 1085 1086 hw_res_list_parsed_clean(&hw_res_parsed); 1086 1087 … … 1097 1098 * @return EOK in the case of success, error code otherwise 1098 1099 */ 1099 static int rtl8139_buffers_create(rtl8139_t *rtl8139)1100 static errno_t rtl8139_buffers_create(rtl8139_t *rtl8139) 1100 1101 { 1101 1102 size_t i = 0; 1102 int rc;1103 errno_t rc; 1103 1104 1104 1105 ddf_msg(LVL_DEBUG, "Creating buffers"); … … 1146 1147 * @param dev The device information 1147 1148 * 1148 * @return EOK if succeed, negativeerror code otherwise1149 */ 1150 static int rtl8139_device_initialize(ddf_dev_t *dev)1149 * @return EOK if succeed, error code otherwise 1150 */ 1151 static errno_t rtl8139_device_initialize(ddf_dev_t *dev) 1151 1152 { 1152 1153 ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev)); 1153 1154 1154 int ret = EOK;1155 errno_t ret = EOK; 1155 1156 1156 1157 ddf_msg(LVL_DEBUG, "rtl8139: creating device data"); … … 1205 1206 * @param dev The RTL8139 device. 1206 1207 * 1207 * @return EOK if successed, negativeerror code otherwise1208 */ 1209 static int rtl8139_pio_enable(ddf_dev_t *dev)1208 * @return EOK if successed, error code otherwise 1209 */ 1210 static errno_t rtl8139_pio_enable(ddf_dev_t *dev) 1210 1211 { 1211 1212 ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev)); … … 1255 1256 * @param dev The RTL8139 device. 1256 1257 * 1257 * @return EOK if added successfully, negativeerror code otherwise1258 */ 1259 int rtl8139_dev_add(ddf_dev_t *dev)1258 * @return EOK if added successfully, error code otherwise 1259 */ 1260 errno_t rtl8139_dev_add(ddf_dev_t *dev) 1260 1261 { 1261 1262 ddf_fun_t *fun; … … 1265 1266 1266 1267 /* Init device structure for rtl8139 */ 1267 int rc = rtl8139_device_initialize(dev);1268 errno_t rc = rtl8139_device_initialize(dev); 1268 1269 if (rc != EOK) 1269 1270 return rc; … … 1287 1288 1288 1289 /* Register interrupt handler */ 1289 int irq_cap = rtl8139_register_int_handler(nic_data);1290 if (irq_cap < 0) {1291 rc = irq_cap;1290 int irq_cap; 1291 rc = rtl8139_register_int_handler(nic_data, &irq_cap); 1292 if (rc != EOK) { 1292 1293 goto err_pio; 1293 1294 } … … 1338 1339 * @param max_len Maximal addresss length to store 1339 1340 * 1340 * @return EOK if succeed, negativeerror code otherwise1341 */ 1342 static int rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *addr)1341 * @return EOK if succeed, error code otherwise 1342 */ 1343 static errno_t rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *addr) 1343 1344 { 1344 1345 assert(fun); … … 1351 1352 rtl8139_lock_all(rtl8139); 1352 1353 1353 int rc = nic_report_address(nic_data, addr);1354 errno_t rc = nic_report_address(nic_data, addr); 1354 1355 if ( rc != EOK) { 1355 1356 rtl8139_unlock_all(rtl8139); … … 1370 1371 * @return EOK 1371 1372 */ 1372 static int rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info)1373 static errno_t rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info) 1373 1374 { 1374 1375 assert(fun); … … 1405 1406 * @return EOK 1406 1407 */ 1407 static int rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)1408 static errno_t rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state) 1408 1409 { 1409 1410 assert(fun); … … 1424 1425 /** Get operation mode of the device 1425 1426 */ 1426 static int rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,1427 static errno_t rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed, 1427 1428 nic_channel_mode_t *duplex, nic_role_t *role) 1428 1429 { … … 1501 1502 * @return EOK if succeed 1502 1503 */ 1503 static int rtl8139_pause_get(ddf_fun_t *fun, nic_result_t *we_send,1504 static errno_t rtl8139_pause_get(ddf_fun_t *fun, nic_result_t *we_send, 1504 1505 nic_result_t *we_receive, uint16_t *time) 1505 1506 { … … 1536 1537 * @return EOK if succeed, INVAL if the pause frame has no sence 1537 1538 */ 1538 static int rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,1539 static errno_t rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive, 1539 1540 uint16_t time) 1540 1541 { … … 1566 1567 * 1567 1568 */ 1568 static int rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,1569 static errno_t rtl8139_set_operation_mode(ddf_fun_t *fun, int speed, 1569 1570 nic_channel_mode_t duplex, nic_role_t role) 1570 1571 { … … 1610 1611 * @returns EOK if advertisement mode set successfully 1611 1612 */ 1612 static int rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)1613 static errno_t rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement) 1613 1614 { 1614 1615 assert(fun); … … 1656 1657 * @returns EOK 1657 1658 */ 1658 static int rtl8139_autoneg_disable(ddf_fun_t *fun)1659 static errno_t rtl8139_autoneg_disable(ddf_fun_t *fun) 1659 1660 { 1660 1661 assert(fun); … … 1707 1708 * @returns EOK 1708 1709 */ 1709 static int rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement,1710 static errno_t rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement, 1710 1711 uint32_t *their_adv, nic_result_t *result, nic_result_t *their_result) 1711 1712 { … … 1744 1745 * @returns EOK 1745 1746 */ 1746 static int rtl8139_autoneg_restart(ddf_fun_t *fun)1747 static errno_t rtl8139_autoneg_restart(ddf_fun_t *fun) 1747 1748 { 1748 1749 assert(fun); … … 1792 1793 * @returns EOK 1793 1794 */ 1794 static int rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,1795 static errno_t rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode, 1795 1796 const nic_address_t *addr, size_t addr_cnt) 1796 1797 { … … 1850 1851 * @returns EOK 1851 1852 */ 1852 static int rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,1853 static errno_t rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode, 1853 1854 const nic_address_t *addr, size_t addr_count) 1854 1855 { … … 1893 1894 * @returns EOK 1894 1895 */ 1895 static int rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode)1896 static errno_t rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode) 1896 1897 { 1897 1898 assert(nic_data); … … 1921 1922 * @param[out] mode The current mode 1922 1923 */ 1923 static int rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)1924 static errno_t rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode) 1924 1925 { 1925 1926 assert(fun); … … 1946 1947 * @returns EOK of mode was set 1947 1948 */ 1948 static int rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode)1949 static errno_t rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode) 1949 1950 { 1950 1951 assert(fun); … … 1978 1979 * @returns ELIMIT if no more methods of this kind can be enabled 1979 1980 */ 1980 static int rtl8139_wol_virtue_add(nic_t *nic_data,1981 static errno_t rtl8139_wol_virtue_add(nic_t *nic_data, 1981 1982 const nic_wol_virtue_t *virtue) 1982 1983 { … … 2057 2058 * @returns ENOTSUP if the mode is not supported 2058 2059 */ 2059 static int rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,2060 static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode, 2060 2061 const struct timeval *period) 2061 2062 { 2062 2063 assert(nic_data); 2063 int rc = EOK;2064 errno_t rc = EOK; 2064 2065 2065 2066 rtl8139_t *rtl8139 = nic_get_specific(nic_data); … … 2142 2143 printf("%s: HelenOS RTL8139 network adapter driver\n", NAME); 2143 2144 2144 int rc = nic_driver_init(NAME);2145 errno_t rc = nic_driver_init(NAME); 2145 2146 if (rc != EOK) 2146 2147 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.