Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/rtl8139/driver.c

    rf300523 rb7fd2a0  
    217217 *  @param address  The place to store the address
    218218 *
    219  *  @return EOK if succeed, negative error code otherwise
     219 *  @return EOK if succeed, error code otherwise
    220220 */
    221221inline static void rtl8139_hw_get_addr(rtl8139_t *rtl8139,
     
    280280}
    281281
    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,
     282static errno_t rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *);
     283static errno_t rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info);
     284static errno_t rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state);
     285static errno_t rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,
    286286    nic_channel_mode_t *duplex, nic_role_t *role);
    287 static int rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
     287static errno_t rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
    288288    nic_channel_mode_t duplex, nic_role_t);
    289289
    290 static int rtl8139_pause_get(ddf_fun_t*, nic_result_t*, nic_result_t*,
     290static errno_t rtl8139_pause_get(ddf_fun_t*, nic_result_t*, nic_result_t*,
    291291    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,
     292static errno_t rtl8139_pause_set(ddf_fun_t*, int, int, uint16_t);
     293
     294static errno_t rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement);
     295static errno_t rtl8139_autoneg_disable(ddf_fun_t *fun);
     296static errno_t rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *our_advertisement,
    297297    uint32_t *their_advertisement, nic_result_t *result,
    298298    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,
     299static errno_t rtl8139_autoneg_restart(ddf_fun_t *fun);
     300
     301static errno_t rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode);
     302static errno_t rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode);
     303
     304static errno_t rtl8139_wol_virtue_add(nic_t *nic_data,
    305305        const nic_wol_virtue_t *virtue);
    306306static void rtl8139_wol_virtue_rem(nic_t *nic_data,
    307307        const nic_wol_virtue_t *virtue);
    308308
    309 static int rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
     309static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
    310310    const struct timeval *period);
    311311static void rtl8139_poll(nic_t *nic_data);
     
    334334static ddf_dev_ops_t rtl8139_dev_ops;
    335335
    336 static int rtl8139_dev_add(ddf_dev_t *dev);
     336static errno_t rtl8139_dev_add(ddf_dev_t *dev);
    337337
    338338/** Basic driver operations for RTL8139 driver */
     
    348348
    349349/* The default implementation callbacks */
    350 static int rtl8139_on_activated(nic_t *nic_data);
    351 static int rtl8139_on_stopped(nic_t *nic_data);
     350static errno_t rtl8139_on_activated(nic_t *nic_data);
     351static errno_t rtl8139_on_stopped(nic_t *nic_data);
    352352static void rtl8139_send_frame(nic_t *nic_data, void *data, size_t size);
    353353
     
    842842 *  @param nic_data  The driver data
    843843 *
    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 */
     848inline static errno_t rtl8139_register_int_handler(nic_t *nic_data, cap_handle_t *handle)
    848849{
    849850        rtl8139_t *rtl8139 = nic_get_specific(nic_data);
     
    856857        rtl8139_irq_code.cmds[2].addr = rtl8139->io_addr + ISR;
    857858        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);
    860861
    861862        RTL8139_IRQ_STRUCT_UNLOCK();
    862863
    863         return cap;
     864        return rc;
    864865}
    865866
     
    903904 *  @return EOK if activated successfully, error code otherwise
    904905 */
    905 static int rtl8139_on_activated(nic_t *nic_data)
     906static errno_t rtl8139_on_activated(nic_t *nic_data)
    906907{
    907908        assert(nic_data);
     
    918919        rtl8139_hw_int_set(rtl8139);
    919920
    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);
    921922        if (rc != EOK) {
    922923                rtl8139_on_stopped(nic_data);
     
    934935 *  @return EOK if succeed, error code otherwise
    935936 */
    936 static int rtl8139_on_stopped(nic_t *nic_data)
     937static errno_t rtl8139_on_stopped(nic_t *nic_data)
    937938{
    938939        assert(nic_data);
     
    954955
    955956
    956 static int rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
     957static errno_t rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
    957958    const nic_address_t *, size_t);
    958 static int rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
     959static errno_t rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
    959960    const nic_address_t *addr, size_t addr_count);
    960 static int rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode);
     961static errno_t rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode);
    961962
    962963
     
    10241025 *  @param hw_resources  Devices hardware resources
    10251026 *
    1026  *  @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
     1027 *  @return EOK if succeed, error code otherwise
     1028 */
     1029static errno_t rtl8139_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t
    10291030    *hw_resources)
    10301031{
     
    10641065 *  @param dev  The device structure
    10651066 *
    1066  *  @return EOK if succeed, negative error code otherwise
    1067  */
    1068 static int rtl8139_get_resource_info(ddf_dev_t *dev)
     1067 *  @return EOK if succeed, error code otherwise
     1068 */
     1069static errno_t rtl8139_get_resource_info(ddf_dev_t *dev)
    10691070{
    10701071        assert(dev);
     
    10771078
    10781079        /* 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);
    10801081        if (rc != EOK)
    10811082                return rc;
    10821083
    10831084        /* 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);
    10851086        hw_res_list_parsed_clean(&hw_res_parsed);
    10861087
     
    10971098 * @return EOK in the case of success, error code otherwise
    10981099 */
    1099 static int rtl8139_buffers_create(rtl8139_t *rtl8139)
     1100static errno_t rtl8139_buffers_create(rtl8139_t *rtl8139)
    11001101{
    11011102        size_t i = 0;
    1102         int rc;
     1103        errno_t rc;
    11031104
    11041105        ddf_msg(LVL_DEBUG, "Creating buffers");
     
    11461147 *  @param dev  The device information
    11471148 *
    1148  *  @return EOK if succeed, negative error code otherwise
    1149  */
    1150 static int rtl8139_device_initialize(ddf_dev_t *dev)
     1149 *  @return EOK if succeed, error code otherwise
     1150 */
     1151static errno_t rtl8139_device_initialize(ddf_dev_t *dev)
    11511152{
    11521153        ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev));
    11531154
    1154         int ret = EOK;
     1155        errno_t ret = EOK;
    11551156
    11561157        ddf_msg(LVL_DEBUG, "rtl8139: creating device data");
     
    12051206 * @param dev  The RTL8139 device.
    12061207 *
    1207  * @return EOK if successed, negative error code otherwise
    1208  */
    1209 static int rtl8139_pio_enable(ddf_dev_t *dev)
     1208 * @return EOK if successed, error code otherwise
     1209 */
     1210static errno_t rtl8139_pio_enable(ddf_dev_t *dev)
    12101211{
    12111212        ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev));
     
    12551256 * @param dev  The RTL8139 device.
    12561257 *
    1257  * @return EOK if added successfully, negative error code otherwise
    1258  */
    1259 int rtl8139_dev_add(ddf_dev_t *dev)
     1258 * @return EOK if added successfully, error code otherwise
     1259 */
     1260errno_t rtl8139_dev_add(ddf_dev_t *dev)
    12601261{
    12611262        ddf_fun_t *fun;
     
    12651266
    12661267        /* Init device structure for rtl8139 */
    1267         int rc = rtl8139_device_initialize(dev);
     1268        errno_t rc = rtl8139_device_initialize(dev);
    12681269        if (rc != EOK)
    12691270                return rc;
     
    12871288
    12881289        /* 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) {
    12921293                goto err_pio;
    12931294        }
     
    13381339 *  @param max_len  Maximal addresss length to store
    13391340 *
    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)
     1341 *  @return EOK if succeed, error code otherwise
     1342 */
     1343static errno_t rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
    13431344{
    13441345        assert(fun);
     
    13511352        rtl8139_lock_all(rtl8139);
    13521353
    1353         int rc = nic_report_address(nic_data, addr);
     1354        errno_t rc = nic_report_address(nic_data, addr);
    13541355        if ( rc != EOK) {
    13551356                rtl8139_unlock_all(rtl8139);
     
    13701371 *  @return EOK
    13711372 */
    1372 static int rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info)
     1373static errno_t rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info)
    13731374{
    13741375        assert(fun);
     
    14051406 *  @return EOK
    14061407 */
    1407 static int rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
     1408static errno_t rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
    14081409{
    14091410        assert(fun);
     
    14241425/** Get operation mode of the device
    14251426 */
    1426 static int rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,
     1427static errno_t rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,
    14271428    nic_channel_mode_t *duplex, nic_role_t *role)
    14281429{
     
    15011502 *  @return EOK if succeed
    15021503 */
    1503 static int rtl8139_pause_get(ddf_fun_t *fun, nic_result_t *we_send,
     1504static errno_t rtl8139_pause_get(ddf_fun_t *fun, nic_result_t *we_send,
    15041505    nic_result_t *we_receive, uint16_t *time)
    15051506{
     
    15361537 *  @return EOK if succeed, INVAL if the pause frame has no sence
    15371538 */
    1538 static int rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,
     1539static errno_t rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,
    15391540    uint16_t time)
    15401541{
     
    15661567 *
    15671568 */
    1568 static int rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
     1569static errno_t rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
    15691570    nic_channel_mode_t duplex, nic_role_t role)
    15701571{
     
    16101611 *  @returns EOK if advertisement mode set successfully
    16111612 */
    1612 static int rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
     1613static errno_t rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
    16131614{
    16141615        assert(fun);
     
    16561657 *  @returns EOK
    16571658 */
    1658 static int rtl8139_autoneg_disable(ddf_fun_t *fun)
     1659static errno_t rtl8139_autoneg_disable(ddf_fun_t *fun)
    16591660{
    16601661        assert(fun);
     
    17071708 *  @returns EOK
    17081709 */
    1709 static int rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement,
     1710static errno_t rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement,
    17101711    uint32_t *their_adv, nic_result_t *result, nic_result_t *their_result)
    17111712{
     
    17441745 *  @returns EOK
    17451746 */
    1746 static int rtl8139_autoneg_restart(ddf_fun_t *fun)
     1747static errno_t rtl8139_autoneg_restart(ddf_fun_t *fun)
    17471748{
    17481749        assert(fun);
     
    17921793 *  @returns EOK
    17931794 */
    1794 static int rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
     1795static errno_t rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
    17951796    const nic_address_t *addr, size_t addr_cnt)
    17961797{
     
    18501851 *  @returns EOK
    18511852 */
    1852 static int rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
     1853static errno_t rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
    18531854    const nic_address_t *addr, size_t addr_count)
    18541855{
     
    18931894 *  @returns EOK
    18941895 */
    1895 static int rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode)
     1896static errno_t rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode)
    18961897{
    18971898        assert(nic_data);
     
    19211922 *  @param[out] mode    The current mode
    19221923 */
    1923 static int rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
     1924static errno_t rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
    19241925{
    19251926        assert(fun);
     
    19461947 *  @returns EOK of mode was set
    19471948 */
    1948 static int rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
     1949static errno_t rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
    19491950{
    19501951        assert(fun);
     
    19781979 *  @returns ELIMIT if no more methods of this kind can be enabled
    19791980 */
    1980 static int rtl8139_wol_virtue_add(nic_t *nic_data,
     1981static errno_t rtl8139_wol_virtue_add(nic_t *nic_data,
    19811982        const nic_wol_virtue_t *virtue)
    19821983{
     
    20572058 *  @returns ENOTSUP if the mode is not supported
    20582059 */
    2059 static int rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
     2060static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
    20602061    const struct timeval *period)
    20612062{
    20622063        assert(nic_data);
    2063         int rc = EOK;
     2064        errno_t rc = EOK;
    20642065
    20652066        rtl8139_t *rtl8139 = nic_get_specific(nic_data);
     
    21422143        printf("%s: HelenOS RTL8139 network adapter driver\n", NAME);
    21432144
    2144         int rc = nic_driver_init(NAME);
     2145        errno_t rc = nic_driver_init(NAME);
    21452146        if (rc != EOK)
    21462147                return rc;
Note: See TracChangeset for help on using the changeset viewer.