Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/nic/ar9271/ar9271.c

    r908d634 rb7fd2a0  
    4242#include <ddf/interrupt.h>
    4343#include <errno.h>
     44#include <str_error.h>
    4445#include <nic.h>
    4546#include <macros.h>
     
    9899
    99100/* Callback when new device is to be controlled by this driver. */
    100 static int ar9271_add_device(ddf_dev_t *);
     101static errno_t ar9271_add_device(ddf_dev_t *);
    101102
    102103/* IEEE 802.11 callbacks */
    103 static int ar9271_ieee80211_start(ieee80211_dev_t *);
    104 static int ar9271_ieee80211_tx_handler(ieee80211_dev_t *, void *, size_t);
    105 static int ar9271_ieee80211_set_freq(ieee80211_dev_t *, uint16_t);
    106 static int ar9271_ieee80211_bssid_change(ieee80211_dev_t *, bool);
    107 static int ar9271_ieee80211_key_config(ieee80211_dev_t *, ieee80211_key_config_t *,
     104static errno_t ar9271_ieee80211_start(ieee80211_dev_t *);
     105static errno_t ar9271_ieee80211_tx_handler(ieee80211_dev_t *, void *, size_t);
     106static errno_t ar9271_ieee80211_set_freq(ieee80211_dev_t *, uint16_t);
     107static errno_t ar9271_ieee80211_bssid_change(ieee80211_dev_t *, bool);
     108static errno_t ar9271_ieee80211_key_config(ieee80211_dev_t *, ieee80211_key_config_t *,
    108109    bool);
    109110
     
    127128static ieee80211_iface_t ar9271_ieee80211_iface;
    128129
    129 static int ar9271_get_device_info(ddf_fun_t *, nic_device_info_t *);
    130 static int ar9271_get_cable_state(ddf_fun_t *, nic_cable_state_t *);
    131 static int ar9271_get_operation_mode(ddf_fun_t *, int *, nic_channel_mode_t *,
     130static errno_t ar9271_get_device_info(ddf_fun_t *, nic_device_info_t *);
     131static errno_t ar9271_get_cable_state(ddf_fun_t *, nic_cable_state_t *);
     132static errno_t ar9271_get_operation_mode(ddf_fun_t *, int *, nic_channel_mode_t *,
    132133    nic_role_t *);
    133134
     
    143144 *
    144145 */
    145 static int ar9271_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)
     146static errno_t ar9271_get_device_info(ddf_fun_t *dev, nic_device_info_t *info)
    146147{
    147148        assert(dev);
     
    163164 *
    164165 */
    165 static int ar9271_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
     166static errno_t ar9271_get_cable_state(ddf_fun_t *fun, nic_cable_state_t *state)
    166167{
    167168        *state = NIC_CS_PLUGGED;
     
    173174 *
    174175 */
    175 static int ar9271_get_operation_mode(ddf_fun_t *fun, int *speed,
     176static errno_t ar9271_get_operation_mode(ddf_fun_t *fun, int *speed,
    176177    nic_channel_mode_t *duplex, nic_role_t *role)
    177178{
     
    186187 *
    187188 */
    188 static int ar9271_on_multicast_mode_change(nic_t *nic,
     189static errno_t ar9271_on_multicast_mode_change(nic_t *nic,
    189190    nic_multicast_mode_t mode, const nic_address_t *addr, size_t addr_cnt)
    190191{
     
    209210 *
    210211 */
    211 static int ar9271_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,
     212static errno_t ar9271_on_unicast_mode_change(nic_t *nic, nic_unicast_mode_t mode,
    212213    const nic_address_t *addr, size_t addr_cnt)
    213214{
     
    235236 *
    236237 */
    237 static int ar9271_on_broadcast_mode_change(nic_t *nic,
     238static errno_t ar9271_on_broadcast_mode_change(nic_t *nic,
    238239    nic_broadcast_mode_t mode)
    239240{
     
    257258}
    258259
    259 static int ar9271_data_polling(void *arg)
     260static errno_t ar9271_data_polling(void *arg)
    260261{
    261262        assert(arg);
     
    318319 *
    319320 */
    320 static int ar9271_ieee80211_set_freq(ieee80211_dev_t *ieee80211_dev,
     321static errno_t ar9271_ieee80211_set_freq(ieee80211_dev_t *ieee80211_dev,
    321322    uint16_t freq)
    322323{
     
    329330        wmi_send_command(ar9271->htc_device, WMI_STOP_RECV, NULL, 0, NULL);
    330331       
    331         int rc = hw_freq_switch(ar9271, freq);
     332        errno_t rc = hw_freq_switch(ar9271, freq);
    332333        if (rc != EOK) {
    333334                usb_log_error("Failed to HW switch frequency.\n");
     
    351352}
    352353
    353 static int ar9271_ieee80211_bssid_change(ieee80211_dev_t *ieee80211_dev,
     354static errno_t ar9271_ieee80211_bssid_change(ieee80211_dev_t *ieee80211_dev,
    354355    bool connected)
    355356{
     
    400401}
    401402
    402 static int ar9271_ieee80211_key_config(ieee80211_dev_t *ieee80211_dev,
     403static errno_t ar9271_ieee80211_key_config(ieee80211_dev_t *ieee80211_dev,
    403404    ieee80211_key_config_t *key_conf, bool insert)
    404405{
     
    518519}
    519520
    520 static int ar9271_ieee80211_tx_handler(ieee80211_dev_t *ieee80211_dev,
     521static errno_t ar9271_ieee80211_tx_handler(ieee80211_dev_t *ieee80211_dev,
    521522    void *buffer, size_t buffer_size)
    522523{
     
    607608}
    608609
    609 static int ar9271_ieee80211_start(ieee80211_dev_t *ieee80211_dev)
     610static errno_t ar9271_ieee80211_start(ieee80211_dev_t *ieee80211_dev)
    610611{
    611612        assert(ieee80211_dev);
     
    615616        wmi_send_command(ar9271->htc_device, WMI_FLUSH_RECV, NULL, 0, NULL);
    616617       
    617         int rc = hw_reset(ar9271);
     618        errno_t rc = hw_reset(ar9271);
    618619        if (rc != EOK) {
    619620                usb_log_error("Failed to do HW reset.\n");
     
    665666}
    666667
    667 static int ar9271_init(ar9271_t *ar9271, usb_device_t *usb_device)
     668static errno_t ar9271_init(ar9271_t *ar9271, usb_device_t *usb_device)
    668669{
    669670        ar9271->starting_up = true;
     
    679680        }
    680681       
    681         int rc = ath_usb_init(ar9271->ath_device, usb_device);
     682        errno_t rc = ath_usb_init(ar9271->ath_device, usb_device);
    682683        if (rc != EOK) {
    683684                free(ar9271->ath_device);
     
    733734 * @param ar9271 AR9271 device structure
    734735 *
    735  * @return EOK if succeed, negative error code otherwise
    736  *
    737  */
    738 static int ar9271_upload_fw(ar9271_t *ar9271)
     736 * @return EOK if succeed, error code otherwise
     737 *
     738 */
     739static errno_t ar9271_upload_fw(ar9271_t *ar9271)
    739740{
    740741        usb_device_t *usb_device = ar9271->usb_device;
     
    774775                memcpy(buffer, current_data, chunk_size);
    775776                usb_pipe_t *ctrl_pipe = usb_device_get_default_pipe(usb_device);
    776                 int rc = usb_control_request_set(ctrl_pipe,
     777                errno_t rc = usb_control_request_set(ctrl_pipe,
    777778                    USB_REQUEST_TYPE_VENDOR,
    778779                    USB_REQUEST_RECIPIENT_DEVICE,
     
    784785                        free(buffer);
    785786                        usb_log_error("Error while uploading firmware. "
    786                             "Error: %d\n", rc);
     787                            "Error: %s\n", str_error_name(rc));
    787788                        return rc;
    788789                }
     
    802803        */
    803804        usb_pipe_t *ctrl_pipe = usb_device_get_default_pipe(usb_device);
    804         int rc = usb_control_request_set(ctrl_pipe,
     805        errno_t rc = usb_control_request_set(ctrl_pipe,
    805806            USB_REQUEST_TYPE_VENDOR,
    806807            USB_REQUEST_RECIPIENT_DEVICE,
     
    833834        /* USB framework initialization. */
    834835        const char *err_msg = NULL;
    835         int rc = usb_device_create_ddf(dev, endpoints, &err_msg);
     836        errno_t rc = usb_device_create_ddf(dev, endpoints, &err_msg);
    836837        if (rc != EOK) {
    837838                usb_log_error("Failed to create USB device: %s, "
    838                     "ERR_NUM = %d\n", err_msg, rc);
     839                    "ERR_NUM = %s\n", err_msg, str_error_name(rc));
    839840                return NULL;
    840841        }
     
    853854        if (rc != EOK) {
    854855                free(ar9271);
    855                 usb_log_error("Failed to initialize AR9271 structure: %d\n",
    856                     rc);
     856                usb_log_error("Failed to initialize AR9271 structure: %s\n",
     857                    str_error_name(rc));
    857858                return NULL;
    858859        }
     
    876877 * @param dev The device structure.
    877878 *
    878  * @return EOK if succeed, negative error code otherwise
    879  */
    880 static int ar9271_add_device(ddf_dev_t *dev)
     879 * @return EOK if succeed, error code otherwise
     880 */
     881static errno_t ar9271_add_device(ddf_dev_t *dev)
    881882{
    882883        assert(dev);
     
    895896       
    896897        /* Initialize AR9271 HTC services. */
    897         int rc = htc_init(ar9271->htc_device);
     898        errno_t rc = htc_init(ar9271->htc_device);
    898899        if (rc != EOK) {
    899900                ar9271_delete_dev_data(ar9271);
Note: See TracChangeset for help on using the changeset viewer.