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