Ignore:
File:
1 edited

Legend:

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

    rb7fd2a0 rf300523  
    217217 *  @param address  The place to store the address
    218218 *
    219  *  @return EOK if succeed, error code otherwise
     219 *  @return EOK if succeed, negative error code otherwise
    220220 */
    221221inline static void rtl8139_hw_get_addr(rtl8139_t *rtl8139,
     
    280280}
    281281
    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,
     282static int rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *);
     283static int rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info);
     284static int rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state);
     285static int rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,
    286286    nic_channel_mode_t *duplex, nic_role_t *role);
    287 static errno_t rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
     287static int rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
    288288    nic_channel_mode_t duplex, nic_role_t);
    289289
    290 static errno_t rtl8139_pause_get(ddf_fun_t*, nic_result_t*, nic_result_t*,
     290static int rtl8139_pause_get(ddf_fun_t*, nic_result_t*, nic_result_t*,
    291291    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,
     292static int rtl8139_pause_set(ddf_fun_t*, int, int, uint16_t);
     293
     294static int rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement);
     295static int rtl8139_autoneg_disable(ddf_fun_t *fun);
     296static int 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 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,
     299static int rtl8139_autoneg_restart(ddf_fun_t *fun);
     300
     301static int rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode);
     302static int rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode);
     303
     304static int 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 errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
     309static int 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 errno_t rtl8139_dev_add(ddf_dev_t *dev);
     336static int rtl8139_dev_add(ddf_dev_t *dev);
    337337
    338338/** Basic driver operations for RTL8139 driver */
     
    348348
    349349/* 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);
     350static int rtl8139_on_activated(nic_t *nic_data);
     351static int 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  *  @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 */
     847inline static int rtl8139_register_int_handler(nic_t *nic_data)
    849848{
    850849        rtl8139_t *rtl8139 = nic_get_specific(nic_data);
     
    857856        rtl8139_irq_code.cmds[2].addr = rtl8139->io_addr + ISR;
    858857        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);
    861860
    862861        RTL8139_IRQ_STRUCT_UNLOCK();
    863862
    864         return rc;
     863        return cap;
    865864}
    866865
     
    904903 *  @return EOK if activated successfully, error code otherwise
    905904 */
    906 static errno_t rtl8139_on_activated(nic_t *nic_data)
     905static int rtl8139_on_activated(nic_t *nic_data)
    907906{
    908907        assert(nic_data);
     
    919918        rtl8139_hw_int_set(rtl8139);
    920919
    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);
    922921        if (rc != EOK) {
    923922                rtl8139_on_stopped(nic_data);
     
    935934 *  @return EOK if succeed, error code otherwise
    936935 */
    937 static errno_t rtl8139_on_stopped(nic_t *nic_data)
     936static int rtl8139_on_stopped(nic_t *nic_data)
    938937{
    939938        assert(nic_data);
     
    955954
    956955
    957 static errno_t rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
     956static int rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
    958957    const nic_address_t *, size_t);
    959 static errno_t rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
     958static int rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
    960959    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);
     960static int rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode);
    962961
    963962
     
    10251024 *  @param hw_resources  Devices hardware resources
    10261025 *
    1027  *  @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
     1026 *  @return EOK if succeed, negative error code otherwise
     1027 */
     1028static int rtl8139_fill_resource_info(ddf_dev_t *dev, const hw_res_list_parsed_t
    10301029    *hw_resources)
    10311030{
     
    10651064 *  @param dev  The device structure
    10661065 *
    1067  *  @return EOK if succeed, error code otherwise
    1068  */
    1069 static errno_t rtl8139_get_resource_info(ddf_dev_t *dev)
     1066 *  @return EOK if succeed, negative error code otherwise
     1067 */
     1068static int rtl8139_get_resource_info(ddf_dev_t *dev)
    10701069{
    10711070        assert(dev);
     
    10781077
    10791078        /* 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);
    10811080        if (rc != EOK)
    10821081                return rc;
    10831082
    10841083        /* 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);
    10861085        hw_res_list_parsed_clean(&hw_res_parsed);
    10871086
     
    10981097 * @return EOK in the case of success, error code otherwise
    10991098 */
    1100 static errno_t rtl8139_buffers_create(rtl8139_t *rtl8139)
     1099static int rtl8139_buffers_create(rtl8139_t *rtl8139)
    11011100{
    11021101        size_t i = 0;
    1103         errno_t rc;
     1102        int rc;
    11041103
    11051104        ddf_msg(LVL_DEBUG, "Creating buffers");
     
    11471146 *  @param dev  The device information
    11481147 *
    1149  *  @return EOK if succeed, error code otherwise
    1150  */
    1151 static errno_t rtl8139_device_initialize(ddf_dev_t *dev)
     1148 *  @return EOK if succeed, negative error code otherwise
     1149 */
     1150static int rtl8139_device_initialize(ddf_dev_t *dev)
    11521151{
    11531152        ddf_msg(LVL_DEBUG, "rtl8139_dev_initialize %s", ddf_dev_get_name(dev));
    11541153
    1155         errno_t ret = EOK;
     1154        int ret = EOK;
    11561155
    11571156        ddf_msg(LVL_DEBUG, "rtl8139: creating device data");
     
    12061205 * @param dev  The RTL8139 device.
    12071206 *
    1208  * @return EOK if successed, error code otherwise
    1209  */
    1210 static errno_t rtl8139_pio_enable(ddf_dev_t *dev)
     1207 * @return EOK if successed, negative error code otherwise
     1208 */
     1209static int rtl8139_pio_enable(ddf_dev_t *dev)
    12111210{
    12121211        ddf_msg(LVL_DEBUG, NAME ": rtl8139_pio_enable %s", ddf_dev_get_name(dev));
     
    12561255 * @param dev  The RTL8139 device.
    12571256 *
    1258  * @return EOK if added successfully, error code otherwise
    1259  */
    1260 errno_t rtl8139_dev_add(ddf_dev_t *dev)
     1257 * @return EOK if added successfully, negative error code otherwise
     1258 */
     1259int rtl8139_dev_add(ddf_dev_t *dev)
    12611260{
    12621261        ddf_fun_t *fun;
     
    12661265
    12671266        /* Init device structure for rtl8139 */
    1268         errno_t rc = rtl8139_device_initialize(dev);
     1267        int rc = rtl8139_device_initialize(dev);
    12691268        if (rc != EOK)
    12701269                return rc;
     
    12881287
    12891288        /* 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;
    12931292                goto err_pio;
    12941293        }
     
    13391338 *  @param max_len  Maximal addresss length to store
    13401339 *
    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)
     1340 *  @return EOK if succeed, negative error code otherwise
     1341 */
     1342static int rtl8139_set_addr(ddf_fun_t *fun, const nic_address_t *addr)
    13441343{
    13451344        assert(fun);
     
    13521351        rtl8139_lock_all(rtl8139);
    13531352
    1354         errno_t rc = nic_report_address(nic_data, addr);
     1353        int rc = nic_report_address(nic_data, addr);
    13551354        if ( rc != EOK) {
    13561355                rtl8139_unlock_all(rtl8139);
     
    13711370 *  @return EOK
    13721371 */
    1373 static errno_t rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info)
     1372static int rtl8139_get_device_info(ddf_fun_t *fun, nic_device_info_t *info)
    13741373{
    13751374        assert(fun);
     
    14061405 *  @return EOK
    14071406 */
    1408 static errno_t rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
     1407static int rtl8139_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
    14091408{
    14101409        assert(fun);
     
    14251424/** Get operation mode of the device
    14261425 */
    1427 static errno_t rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,
     1426static int rtl8139_get_operation_mode(ddf_fun_t *fun, int *speed,
    14281427    nic_channel_mode_t *duplex, nic_role_t *role)
    14291428{
     
    15021501 *  @return EOK if succeed
    15031502 */
    1504 static errno_t rtl8139_pause_get(ddf_fun_t *fun, nic_result_t *we_send,
     1503static int rtl8139_pause_get(ddf_fun_t *fun, nic_result_t *we_send,
    15051504    nic_result_t *we_receive, uint16_t *time)
    15061505{
     
    15371536 *  @return EOK if succeed, INVAL if the pause frame has no sence
    15381537 */
    1539 static errno_t rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,
     1538static int rtl8139_pause_set(ddf_fun_t *fun, int allow_send, int allow_receive,
    15401539    uint16_t time)
    15411540{
     
    15671566 *
    15681567 */
    1569 static errno_t rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
     1568static int rtl8139_set_operation_mode(ddf_fun_t *fun, int speed,
    15701569    nic_channel_mode_t duplex, nic_role_t role)
    15711570{
     
    16111610 *  @returns EOK if advertisement mode set successfully
    16121611 */
    1613 static errno_t rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
     1612static int rtl8139_autoneg_enable(ddf_fun_t *fun, uint32_t advertisement)
    16141613{
    16151614        assert(fun);
     
    16571656 *  @returns EOK
    16581657 */
    1659 static errno_t rtl8139_autoneg_disable(ddf_fun_t *fun)
     1658static int rtl8139_autoneg_disable(ddf_fun_t *fun)
    16601659{
    16611660        assert(fun);
     
    17081707 *  @returns EOK
    17091708 */
    1710 static errno_t rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement,
     1709static int rtl8139_autoneg_probe(ddf_fun_t *fun, uint32_t *advertisement,
    17111710    uint32_t *their_adv, nic_result_t *result, nic_result_t *their_result)
    17121711{
     
    17451744 *  @returns EOK
    17461745 */
    1747 static errno_t rtl8139_autoneg_restart(ddf_fun_t *fun)
     1746static int rtl8139_autoneg_restart(ddf_fun_t *fun)
    17481747{
    17491748        assert(fun);
     
    17931792 *  @returns EOK
    17941793 */
    1795 static errno_t rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
     1794static int rtl8139_unicast_set(nic_t *nic_data, nic_unicast_mode_t mode,
    17961795    const nic_address_t *addr, size_t addr_cnt)
    17971796{
     
    18511850 *  @returns EOK
    18521851 */
    1853 static errno_t rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
     1852static int rtl8139_multicast_set(nic_t *nic_data, nic_multicast_mode_t mode,
    18541853    const nic_address_t *addr, size_t addr_count)
    18551854{
     
    18941893 *  @returns EOK
    18951894 */
    1896 static errno_t rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode)
     1895static int rtl8139_broadcast_set(nic_t *nic_data, nic_broadcast_mode_t mode)
    18971896{
    18981897        assert(nic_data);
     
    19221921 *  @param[out] mode    The current mode
    19231922 */
    1924 static errno_t rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
     1923static int rtl8139_defective_get_mode(ddf_fun_t *fun, uint32_t *mode)
    19251924{
    19261925        assert(fun);
     
    19471946 *  @returns EOK of mode was set
    19481947 */
    1949 static errno_t rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
     1948static int rtl8139_defective_set_mode(ddf_fun_t *fun, uint32_t mode)
    19501949{
    19511950        assert(fun);
     
    19791978 *  @returns ELIMIT if no more methods of this kind can be enabled
    19801979 */
    1981 static errno_t rtl8139_wol_virtue_add(nic_t *nic_data,
     1980static int rtl8139_wol_virtue_add(nic_t *nic_data,
    19821981        const nic_wol_virtue_t *virtue)
    19831982{
     
    20582057 *  @returns ENOTSUP if the mode is not supported
    20592058 */
    2060 static errno_t rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
     2059static int rtl8139_poll_mode_change(nic_t *nic_data, nic_poll_mode_t mode,
    20612060    const struct timeval *period)
    20622061{
    20632062        assert(nic_data);
    2064         errno_t rc = EOK;
     2063        int rc = EOK;
    20652064
    20662065        rtl8139_t *rtl8139 = nic_get_specific(nic_data);
     
    21432142        printf("%s: HelenOS RTL8139 network adapter driver\n", NAME);
    21442143
    2145         errno_t rc = nic_driver_init(NAME);
     2144        int rc = nic_driver_init(NAME);
    21462145        if (rc != EOK)
    21472146                return rc;
Note: See TracChangeset for help on using the changeset viewer.