Changeset b7fd2a0 in mainline for uspace/drv/nic/ar9271/ar9271.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

File:
1 edited

Legend:

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

    r36f0738 rb7fd2a0  
    9999
    100100/* Callback when new device is to be controlled by this driver. */
    101 static int ar9271_add_device(ddf_dev_t *);
     101static errno_t ar9271_add_device(ddf_dev_t *);
    102102
    103103/* IEEE 802.11 callbacks */
    104 static int ar9271_ieee80211_start(ieee80211_dev_t *);
    105 static int ar9271_ieee80211_tx_handler(ieee80211_dev_t *, void *, size_t);
    106 static int ar9271_ieee80211_set_freq(ieee80211_dev_t *, uint16_t);
    107 static int ar9271_ieee80211_bssid_change(ieee80211_dev_t *, bool);
    108 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 *,
    109109    bool);
    110110
     
    128128static ieee80211_iface_t ar9271_ieee80211_iface;
    129129
    130 static int ar9271_get_device_info(ddf_fun_t *, nic_device_info_t *);
    131 static int ar9271_get_cable_state(ddf_fun_t *, nic_cable_state_t *);
    132 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 *,
    133133    nic_role_t *);
    134134
     
    144144 *
    145145 */
    146 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)
    147147{
    148148        assert(dev);
     
    164164 *
    165165 */
    166 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)
    167167{
    168168        *state = NIC_CS_PLUGGED;
     
    174174 *
    175175 */
    176 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,
    177177    nic_channel_mode_t *duplex, nic_role_t *role)
    178178{
     
    187187 *
    188188 */
    189 static int ar9271_on_multicast_mode_change(nic_t *nic,
     189static errno_t ar9271_on_multicast_mode_change(nic_t *nic,
    190190    nic_multicast_mode_t mode, const nic_address_t *addr, size_t addr_cnt)
    191191{
     
    210210 *
    211211 */
    212 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,
    213213    const nic_address_t *addr, size_t addr_cnt)
    214214{
     
    236236 *
    237237 */
    238 static int ar9271_on_broadcast_mode_change(nic_t *nic,
     238static errno_t ar9271_on_broadcast_mode_change(nic_t *nic,
    239239    nic_broadcast_mode_t mode)
    240240{
     
    258258}
    259259
    260 static int ar9271_data_polling(void *arg)
     260static errno_t ar9271_data_polling(void *arg)
    261261{
    262262        assert(arg);
     
    319319 *
    320320 */
    321 static int ar9271_ieee80211_set_freq(ieee80211_dev_t *ieee80211_dev,
     321static errno_t ar9271_ieee80211_set_freq(ieee80211_dev_t *ieee80211_dev,
    322322    uint16_t freq)
    323323{
     
    330330        wmi_send_command(ar9271->htc_device, WMI_STOP_RECV, NULL, 0, NULL);
    331331       
    332         int rc = hw_freq_switch(ar9271, freq);
     332        errno_t rc = hw_freq_switch(ar9271, freq);
    333333        if (rc != EOK) {
    334334                usb_log_error("Failed to HW switch frequency.\n");
     
    352352}
    353353
    354 static int ar9271_ieee80211_bssid_change(ieee80211_dev_t *ieee80211_dev,
     354static errno_t ar9271_ieee80211_bssid_change(ieee80211_dev_t *ieee80211_dev,
    355355    bool connected)
    356356{
     
    401401}
    402402
    403 static int ar9271_ieee80211_key_config(ieee80211_dev_t *ieee80211_dev,
     403static errno_t ar9271_ieee80211_key_config(ieee80211_dev_t *ieee80211_dev,
    404404    ieee80211_key_config_t *key_conf, bool insert)
    405405{
     
    519519}
    520520
    521 static int ar9271_ieee80211_tx_handler(ieee80211_dev_t *ieee80211_dev,
     521static errno_t ar9271_ieee80211_tx_handler(ieee80211_dev_t *ieee80211_dev,
    522522    void *buffer, size_t buffer_size)
    523523{
     
    608608}
    609609
    610 static int ar9271_ieee80211_start(ieee80211_dev_t *ieee80211_dev)
     610static errno_t ar9271_ieee80211_start(ieee80211_dev_t *ieee80211_dev)
    611611{
    612612        assert(ieee80211_dev);
     
    616616        wmi_send_command(ar9271->htc_device, WMI_FLUSH_RECV, NULL, 0, NULL);
    617617       
    618         int rc = hw_reset(ar9271);
     618        errno_t rc = hw_reset(ar9271);
    619619        if (rc != EOK) {
    620620                usb_log_error("Failed to do HW reset.\n");
     
    666666}
    667667
    668 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)
    669669{
    670670        ar9271->starting_up = true;
     
    680680        }
    681681       
    682         int rc = ath_usb_init(ar9271->ath_device, usb_device);
     682        errno_t rc = ath_usb_init(ar9271->ath_device, usb_device);
    683683        if (rc != EOK) {
    684684                free(ar9271->ath_device);
     
    737737 *
    738738 */
    739 static int ar9271_upload_fw(ar9271_t *ar9271)
     739static errno_t ar9271_upload_fw(ar9271_t *ar9271)
    740740{
    741741        usb_device_t *usb_device = ar9271->usb_device;
     
    775775                memcpy(buffer, current_data, chunk_size);
    776776                usb_pipe_t *ctrl_pipe = usb_device_get_default_pipe(usb_device);
    777                 int rc = usb_control_request_set(ctrl_pipe,
     777                errno_t rc = usb_control_request_set(ctrl_pipe,
    778778                    USB_REQUEST_TYPE_VENDOR,
    779779                    USB_REQUEST_RECIPIENT_DEVICE,
     
    803803        */
    804804        usb_pipe_t *ctrl_pipe = usb_device_get_default_pipe(usb_device);
    805         int rc = usb_control_request_set(ctrl_pipe,
     805        errno_t rc = usb_control_request_set(ctrl_pipe,
    806806            USB_REQUEST_TYPE_VENDOR,
    807807            USB_REQUEST_RECIPIENT_DEVICE,
     
    834834        /* USB framework initialization. */
    835835        const char *err_msg = NULL;
    836         int rc = usb_device_create_ddf(dev, endpoints, &err_msg);
     836        errno_t rc = usb_device_create_ddf(dev, endpoints, &err_msg);
    837837        if (rc != EOK) {
    838838                usb_log_error("Failed to create USB device: %s, "
     
    879879 * @return EOK if succeed, error code otherwise
    880880 */
    881 static int ar9271_add_device(ddf_dev_t *dev)
     881static errno_t ar9271_add_device(ddf_dev_t *dev)
    882882{
    883883        assert(dev);
     
    896896       
    897897        /* Initialize AR9271 HTC services. */
    898         int rc = htc_init(ar9271->htc_device);
     898        errno_t rc = htc_init(ar9271->htc_device);
    899899        if (rc != EOK) {
    900900                ar9271_delete_dev_data(ar9271);
Note: See TracChangeset for help on using the changeset viewer.