Changeset b7fd2a0 in mainline for uspace/drv/nic/ar9271/hw.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/hw.c

    r36f0738 rb7fd2a0  
    5252 *
    5353 */
    54 static int hw_read_wait(ar9271_t *ar9271, uint32_t offset, uint32_t mask,
     54static errno_t hw_read_wait(ar9271_t *ar9271, uint32_t offset, uint32_t mask,
    5555    uint32_t value)
    5656{
     
    6767}
    6868
    69 static int hw_reset_power_on(ar9271_t *ar9271)
     69static errno_t hw_reset_power_on(ar9271_t *ar9271)
    7070{
    7171        wmi_reg_t buffer[] = {
     
    9393        wmi_reg_write(ar9271->htc_device, AR9271_RTC_RESET, 1);
    9494       
    95         int rc = hw_read_wait(ar9271,
     95        errno_t rc = hw_read_wait(ar9271,
    9696            AR9271_RTC_STATUS,
    9797            AR9271_RTC_STATUS_MASK,
     
    105105}
    106106
    107 static int hw_set_reset(ar9271_t *ar9271, bool cold)
     107static errno_t hw_set_reset(ar9271_t *ar9271, bool cold)
    108108{
    109109        uint32_t reset_value = AR9271_RTC_RC_MAC_WARM;
     
    135135        wmi_reg_write(ar9271->htc_device, AR9271_RTC_RC, 0);
    136136       
    137         int rc = hw_read_wait(ar9271, AR9271_RTC_RC, AR9271_RTC_RC_MASK, 0);
     137        errno_t rc = hw_read_wait(ar9271, AR9271_RTC_RC, AR9271_RTC_RC_MASK, 0);
    138138        if (rc != EOK) {
    139139                usb_log_error("Failed to wait for RTC RC register.\n");
     
    148148}
    149149
    150 static int hw_addr_init(ar9271_t *ar9271)
     150static errno_t hw_addr_init(ar9271_t *ar9271)
    151151{
    152152        uint32_t value;
     
    164164        nic_t *nic = nic_get_from_ddf_dev(ar9271->ddf_dev);
    165165       
    166         int rc = nic_report_address(nic, &ar9271_address);
     166        errno_t rc = nic_report_address(nic, &ar9271_address);
    167167        if (rc != EOK) {
    168168                usb_log_error("Failed to report NIC HW address.\n");
     
    173173}
    174174
    175 static int hw_gpio_set_output(ar9271_t *ar9271, uint32_t gpio, uint32_t type)
     175static errno_t hw_gpio_set_output(ar9271_t *ar9271, uint32_t gpio, uint32_t type)
    176176{
    177177        uint32_t address;
     
    204204}
    205205
    206 static int hw_gpio_set_value(ar9271_t *ar9271, uint32_t gpio, uint32_t value)
     206static errno_t hw_gpio_set_value(ar9271_t *ar9271, uint32_t gpio, uint32_t value)
    207207{
    208208        wmi_reg_set_clear_bit(ar9271->htc_device, AR9271_GPIO_IN_OUT,
     
    218218 *
    219219 */
    220 static int hw_init_proc(ar9271_t *ar9271)
    221 {
    222         int rc = hw_reset_power_on(ar9271);
     220static errno_t hw_init_proc(ar9271_t *ar9271)
     221{
     222        errno_t rc = hw_reset_power_on(ar9271);
    223223        if (rc != EOK) {
    224224                usb_log_error("Failed to HW reset power on.\n");
     
    241241}
    242242
    243 static int hw_init_led(ar9271_t *ar9271)
    244 {
    245         int rc = hw_gpio_set_output(ar9271, AR9271_LED_PIN,
     243static errno_t hw_init_led(ar9271_t *ar9271)
     244{
     245        errno_t rc = hw_gpio_set_output(ar9271, AR9271_LED_PIN,
    246246            AR9271_GPIO_OUT_MUX_AS_OUT);
    247247        if (rc != EOK) {
     
    259259}
    260260
    261 static int hw_activate_phy(ar9271_t *ar9271)
     261static errno_t hw_activate_phy(ar9271_t *ar9271)
    262262{
    263263        wmi_reg_write(ar9271->htc_device, AR9271_PHY_ACTIVE, 1);
     
    267267}
    268268
    269 static int hw_set_operating_mode(ar9271_t *ar9271,
     269static errno_t hw_set_operating_mode(ar9271_t *ar9271,
    270270    ieee80211_operating_mode_t op_mode)
    271271{
     
    295295}
    296296
    297 static int hw_reset_operating_mode(ar9271_t *ar9271)
    298 {
    299         int rc = hw_set_operating_mode(ar9271, IEEE80211_OPMODE_STATION);
     297static errno_t hw_reset_operating_mode(ar9271_t *ar9271)
     298{
     299        errno_t rc = hw_set_operating_mode(ar9271, IEEE80211_OPMODE_STATION);
    300300        if (rc != EOK) {
    301301                usb_log_error("Failed to set opmode to station.\n");
     
    306306}
    307307
    308 static int hw_noise_floor_calibration(ar9271_t *ar9271)
     308static errno_t hw_noise_floor_calibration(ar9271_t *ar9271)
    309309{
    310310        uint32_t value;
     
    325325            AR9271_AGC_CONTROL_NF_CALIB);
    326326       
    327         int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,
     327        errno_t rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,
    328328            AR9271_AGC_CONTROL_NF_CALIB, 0);
    329329        if (rc != EOK) {
     
    344344}
    345345
    346 static int hw_set_freq(ar9271_t *ar9271, uint16_t freq)
     346static errno_t hw_set_freq(ar9271_t *ar9271, uint16_t freq)
    347347{
    348348        /* Not supported channel frequency. */
     
    373373}
    374374
    375 int hw_freq_switch(ar9271_t *ar9271, uint16_t freq)
     375errno_t hw_freq_switch(ar9271_t *ar9271, uint16_t freq)
    376376{
    377377        wmi_reg_write(ar9271->htc_device, AR9271_PHY_RFBUS_KILL, 0x1);
    378378       
    379         int rc = hw_read_wait(ar9271, AR9271_PHY_RFBUS_GRANT, 0x1, 0x1);
     379        errno_t rc = hw_read_wait(ar9271, AR9271_PHY_RFBUS_GRANT, 0x1, 0x1);
    380380        if (rc != EOK) {
    381381                usb_log_error("Failed to kill RF bus.\n");
     
    407407}
    408408
    409 int hw_set_rx_filter(ar9271_t *ar9271, bool assoc)
     409errno_t hw_set_rx_filter(ar9271_t *ar9271, bool assoc)
    410410{
    411411        uint32_t additional_bits = 0;
     
    425425}
    426426
    427 int hw_set_bssid(ar9271_t *ar9271)
     427errno_t hw_set_bssid(ar9271_t *ar9271)
    428428{
    429429        ieee80211_dev_t *ieee80211_dev = ar9271->ieee80211_dev;
     
    445445}
    446446
    447 int hw_rx_init(ar9271_t *ar9271)
     447errno_t hw_rx_init(ar9271_t *ar9271)
    448448{
    449449        wmi_reg_write(ar9271->htc_device, AR9271_COMMAND,
    450450            AR9271_COMMAND_RX_ENABLE);
    451451       
    452         int rc = hw_set_rx_filter(ar9271, false);
     452        errno_t rc = hw_set_rx_filter(ar9271, false);
    453453        if (rc != EOK) {
    454454                usb_log_error("Failed to set RX filtering.\n");
     
    465465}
    466466
    467 static int hw_init_pll(ar9271_t *ar9271)
     467static errno_t hw_init_pll(ar9271_t *ar9271)
    468468{
    469469        /* Some magic here (set for 2GHz channels). But VERY important :-) */
     
    510510}
    511511
    512 static int hw_calibration(ar9271_t *ar9271)
     512static errno_t hw_calibration(ar9271_t *ar9271)
    513513{
    514514        wmi_reg_set_bit(ar9271->htc_device, AR9271_CARRIER_LEAK_CONTROL,
     
    523523            AR9271_AGC_CONTROL_CALIB);
    524524       
    525         int rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,
     525        errno_t rc = hw_read_wait(ar9271, AR9271_AGC_CONTROL,
    526526            AR9271_AGC_CONTROL_CALIB, 0);
    527527        if (rc != EOK) {
     
    540540}
    541541
    542 int hw_reset(ar9271_t *ar9271)
     542errno_t hw_reset(ar9271_t *ar9271)
    543543{
    544544        /* Set physical layer as deactivated. */
     
    559559                hw_set_reset(ar9271, true);
    560560       
    561         int rc = hw_init_pll(ar9271);
     561        errno_t rc = hw_init_pll(ar9271);
    562562        if (rc != EOK) {
    563563                usb_log_error("Failed to init PLL.\n");
     
    638638 * @return EOK if succeed, error code otherwise.
    639639 */
    640 int hw_init(ar9271_t *ar9271)
    641 {
    642         int rc = hw_init_proc(ar9271);
     640errno_t hw_init(ar9271_t *ar9271)
     641{
     642        errno_t rc = hw_init_proc(ar9271);
    643643        if (rc != EOK) {
    644644                usb_log_error("Failed to HW reset device.\n");
Note: See TracChangeset for help on using the changeset viewer.