staging: vt6656: avoid discarding called function's return code
authorQuentin Deslandes <quentin.deslandes@itdev.co.uk>
Mon, 20 May 2019 16:39:02 +0000 (16:39 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 21 May 2019 06:25:03 +0000 (08:25 +0200)
Change some of the driver's functions in order to handle error codes
instead of discarding them. These function now returns 0 on success and
a negative errno value on error.

Signed-off-by: Quentin Deslandes <quentin.deslandes@itdev.co.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6656/baseband.c
drivers/staging/vt6656/baseband.h
drivers/staging/vt6656/card.c
drivers/staging/vt6656/int.c
drivers/staging/vt6656/int.h
drivers/staging/vt6656/mac.c
drivers/staging/vt6656/mac.h
drivers/staging/vt6656/rf.c
drivers/staging/vt6656/rf.h

index b29ba237fa2953f968864dc6376f3d5519160bec..8d19ae71e7cc9124f666f1807e8752e379a222b3 100644 (file)
@@ -329,7 +329,7 @@ void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
  * Return Value: none
  *
  */
-void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
+int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
 {
        switch (antenna_mode) {
        case ANT_TXA:
@@ -344,8 +344,8 @@ void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
                break;
        }
 
-       vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD,
-                       (u16)antenna_mode, 0, 0, NULL);
+       return vnt_control_out(priv, MESSAGE_TYPE_SET_ANTMD,
+                              (u16)antenna_mode, 0, 0, NULL);
 }
 
 /*
@@ -364,7 +364,7 @@ void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode)
 
 int vnt_vt3184_init(struct vnt_private *priv)
 {
-       int status;
+       int ret = 0;
        u16 length;
        u8 *addr;
        u8 *agc;
@@ -372,11 +372,10 @@ int vnt_vt3184_init(struct vnt_private *priv)
        u8 array[256];
        u8 data;
 
-       status = vnt_control_in(priv, MESSAGE_TYPE_READ, 0,
-                               MESSAGE_REQUEST_EEPROM, EEP_MAX_CONTEXT_SIZE,
-                                               priv->eeprom);
-       if (status != STATUS_SUCCESS)
-               return false;
+       ret = vnt_control_in(priv, MESSAGE_TYPE_READ, 0, MESSAGE_REQUEST_EEPROM,
+                            EEP_MAX_CONTEXT_SIZE, priv->eeprom);
+       if (ret)
+               goto end;
 
        priv->rf_type = priv->eeprom[EEP_OFS_RFTYPE];
 
@@ -423,8 +422,10 @@ int vnt_vt3184_init(struct vnt_private *priv)
                priv->bb_vga[3] = 0x0;
 
                /* Fix VT3226 DFC system timing issue */
-               vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
-                                   SOFTPWRCTL_RFLEOPT);
+               ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
+                                         SOFTPWRCTL_RFLEOPT);
+               if (ret)
+                       goto end;
        } else if (priv->rf_type == RF_VT3342A0) {
                priv->bb_rx_conf = vnt_vt3184_vt3226d0[10];
                length = sizeof(vnt_vt3184_vt3226d0);
@@ -438,48 +439,74 @@ int vnt_vt3184_init(struct vnt_private *priv)
                priv->bb_vga[3] = 0x0;
 
                /* Fix VT3226 DFC system timing issue */
-               vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
-                                   SOFTPWRCTL_RFLEOPT);
+               ret = vnt_mac_reg_bits_on(priv, MAC_REG_SOFTPWRCTL2,
+                                         SOFTPWRCTL_RFLEOPT);
+               if (ret)
+                       goto end;
        } else {
-               return true;
+               goto end;
        }
 
        memcpy(array, addr, length);
 
-       vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
-                       MESSAGE_REQUEST_BBREG, length, array);
+       ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
+                             MESSAGE_REQUEST_BBREG, length, array);
+       if (ret)
+               goto end;
 
        memcpy(array, agc, length_agc);
 
-       vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
-                       MESSAGE_REQUEST_BBAGC, length_agc, array);
+       ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
+                             MESSAGE_REQUEST_BBAGC, length_agc, array);
+       if (ret)
+               goto end;
 
        if ((priv->rf_type == RF_VT3226) ||
            (priv->rf_type == RF_VT3342A0)) {
-               vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
-                                  MAC_REG_ITRTMSET, 0x23);
-               vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
+               ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
+                                        MAC_REG_ITRTMSET, 0x23);
+               if (ret)
+                       goto end;
+
+               ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
+               if (ret)
+                       goto end;
        } else if (priv->rf_type == RF_VT3226D0) {
-               vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
-                                  MAC_REG_ITRTMSET, 0x11);
-               vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
+               ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_MACREG,
+                                        MAC_REG_ITRTMSET, 0x11);
+               if (ret)
+                       goto end;
+
+               ret = vnt_mac_reg_bits_on(priv, MAC_REG_PAPEDELAY, 0x01);
+               if (ret)
+                       goto end;
        }
 
-       vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f);
-       vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
+       ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x04, 0x7f);
+       if (ret)
+               goto end;
 
-       vnt_rf_table_download(priv);
+       ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
+       if (ret)
+               goto end;
+
+       ret = vnt_rf_table_download(priv);
+       if (ret)
+               goto end;
 
        /* Fix for TX USB resets from vendors driver */
-       vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4,
-                      MESSAGE_REQUEST_MEM, sizeof(data), &data);
+       ret = vnt_control_in(priv, MESSAGE_TYPE_READ, USB_REG4,
+                            MESSAGE_REQUEST_MEM, sizeof(data), &data);
+       if (ret)
+               goto end;
 
        data |= 0x2;
 
-       vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4,
-                       MESSAGE_REQUEST_MEM, sizeof(data), &data);
+       ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, USB_REG4,
+                             MESSAGE_REQUEST_MEM, sizeof(data), &data);
 
-       return true;
+end:
+       return ret;
 }
 
 /*
@@ -494,8 +521,9 @@ int vnt_vt3184_init(struct vnt_private *priv)
  * Return Value: none
  *
  */
-void vnt_set_short_slot_time(struct vnt_private *priv)
+int vnt_set_short_slot_time(struct vnt_private *priv)
 {
+       int ret = 0;
        u8 bb_vga = 0;
 
        if (priv->short_slot_time)
@@ -503,12 +531,18 @@ void vnt_set_short_slot_time(struct vnt_private *priv)
        else
                priv->bb_rx_conf |= 0x20;
 
-       vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga);
+       ret = vnt_control_in_u8(priv, MESSAGE_REQUEST_BBREG, 0xe7, &bb_vga);
+       if (ret)
+               goto end;
 
        if (bb_vga == priv->bb_vga[0])
                priv->bb_rx_conf |= 0x20;
 
-       vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a, priv->bb_rx_conf);
+       ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0a,
+                                priv->bb_rx_conf);
+
+end:
+       return ret;
 }
 
 void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
@@ -536,16 +570,30 @@ void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data)
  * Return Value: none
  *
  */
-void vnt_set_deep_sleep(struct vnt_private *priv)
+int vnt_set_deep_sleep(struct vnt_private *priv)
 {
-       vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);/* CR12 */
-       vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);/* CR13 */
+       int ret = 0;
+
+       /* CR12 */
+       ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x17);
+       if (ret)
+               return ret;
+
+       /* CR13 */
+       return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0xB9);
 }
 
-void vnt_exit_deep_sleep(struct vnt_private *priv)
+int vnt_exit_deep_sleep(struct vnt_private *priv)
 {
-       vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);/* CR12 */
-       vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);/* CR13 */
+       int ret = 0;
+
+       /* CR12 */
+       ret = vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0c, 0x00);
+       if (ret)
+               return ret;
+
+       /* CR13 */
+       return vnt_control_out_u8(priv, MESSAGE_REQUEST_BBREG, 0x0d, 0x01);
 }
 
 void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning)
index c3b8bbdb3ea1c3654414adb8a6fd28d213c042b5..dc42aa6ae1d937533b69af7c73ca23edb6d5cff5 100644 (file)
@@ -79,12 +79,12 @@ unsigned int vnt_get_frame_time(u8 preamble_type, u8 pkt_type,
 void vnt_get_phy_field(struct vnt_private *priv, u32 frame_length,
                       u16 tx_rate, u8 pkt_type, struct vnt_phy_field *phy);
 
-void vnt_set_short_slot_time(struct vnt_private *priv);
+int vnt_set_short_slot_time(struct vnt_private *priv);
 void vnt_set_vga_gain_offset(struct vnt_private *priv, u8 data);
-void vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode);
+int vnt_set_antenna_mode(struct vnt_private *priv, u8 antenna_mode);
 int vnt_vt3184_init(struct vnt_private *priv);
-void vnt_set_deep_sleep(struct vnt_private *priv);
-void vnt_exit_deep_sleep(struct vnt_private *priv);
+int vnt_set_deep_sleep(struct vnt_private *priv);
+int vnt_exit_deep_sleep(struct vnt_private *priv);
 void vnt_update_pre_ed_threshold(struct vnt_private *priv, int scanning);
 
 #endif /* __BASEBAND_H__ */
index 501f482b41c49087ec6753cb67d945a47d3ce1ba..08fc03d8740ed82f17ab17f06de2701db53a97c3 100644 (file)
@@ -674,7 +674,7 @@ void vnt_update_next_tbtt(struct vnt_private *priv, u64 tsf,
  */
 int vnt_radio_power_off(struct vnt_private *priv)
 {
-       int ret = true;
+       int ret = 0;
 
        switch (priv->rf_type) {
        case RF_AL2230:
@@ -683,17 +683,25 @@ int vnt_radio_power_off(struct vnt_private *priv)
        case RF_VT3226:
        case RF_VT3226D0:
        case RF_VT3342A0:
-               vnt_mac_reg_bits_off(priv, MAC_REG_SOFTPWRCTL,
-                                    (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
+               ret = vnt_mac_reg_bits_off(priv, MAC_REG_SOFTPWRCTL,
+                                       (SOFTPWRCTL_SWPE2 | SOFTPWRCTL_SWPE3));
                break;
        }
 
-       vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
+       if (ret)
+               goto end;
+
+       ret = vnt_mac_reg_bits_off(priv, MAC_REG_HOSTCR, HOSTCR_RXON);
+       if (ret)
+               goto end;
 
-       vnt_set_deep_sleep(priv);
+       ret = vnt_set_deep_sleep(priv);
+       if (ret)
+               goto end;
 
-       vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD);
+       ret = vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, GPIO3_INTMD);
 
+end:
        return ret;
 }
 
index 504424b19fcf9981ceb1a1ff28348ba8e2624c22..f40947955675f098a59b8c25684eb8b74c31e8b1 100644 (file)
@@ -39,18 +39,20 @@ static const u8 fallback_rate1[5][5] = {
        {RATE_54M, RATE_54M, RATE_36M, RATE_18M, RATE_18M}
 };
 
-void vnt_int_start_interrupt(struct vnt_private *priv)
+int vnt_int_start_interrupt(struct vnt_private *priv)
 {
+       int ret = 0;
        unsigned long flags;
-       int status;
 
        dev_dbg(&priv->usb->dev, "---->Interrupt Polling Thread\n");
 
        spin_lock_irqsave(&priv->lock, flags);
 
-       status = vnt_start_interrupt_urb(priv);
+       ret = vnt_start_interrupt_urb(priv);
 
        spin_unlock_irqrestore(&priv->lock, flags);
+
+       return ret;
 }
 
 static int vnt_int_report_rate(struct vnt_private *priv, u8 pkt_no, u8 tsr)
index 987c454e99e91c86d4af2236744b5dc9433d8bfc..8a6d60569ceb55b668ecc82b5920ef667eb4b626 100644 (file)
@@ -41,7 +41,7 @@ struct vnt_interrupt_data {
        u8 sw[2];
 } __packed;
 
-void vnt_int_start_interrupt(struct vnt_private *priv);
+int vnt_int_start_interrupt(struct vnt_private *priv);
 void vnt_int_process_data(struct vnt_private *priv);
 
 #endif /* __INT_H__ */
index 0b543854ea972bd6302692484f3b5efb85f60ea8..5cacf6e60e90b4a011f087e60b15cfb19eccf18f 100644 (file)
@@ -129,27 +129,26 @@ void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx,
                        (u8 *)&set_key);
 }
 
-void vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits)
+int vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits)
 {
        u8 data[2];
 
        data[0] = 0;
        data[1] = bits;
 
-       vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK,
-                       reg_ofs, MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data),
-                       data);
+       return vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs,
+                              MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
 }
 
-void vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits)
+int vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits)
 {
        u8 data[2];
 
        data[0] = bits;
        data[1] = bits;
 
-       vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs,
-                       MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
+       return vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, reg_ofs,
+                              MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
 }
 
 void vnt_mac_write_word(struct vnt_private *priv, u8 reg_ofs, u16 word)
@@ -224,13 +223,13 @@ void vnt_mac_set_beacon_interval(struct vnt_private *priv, u16 interval)
                        MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
 }
 
-void vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led)
+int vnt_mac_set_led(struct vnt_private *priv, u8 state, u8 led)
 {
        u8 data[2];
 
        data[0] = led;
        data[1] = state;
 
-       vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY,
-                       MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
+       return vnt_control_out(priv, MESSAGE_TYPE_WRITE_MASK, MAC_REG_PAPEDELAY,
+                              MESSAGE_REQUEST_MACREG, ARRAY_SIZE(data), data);
 }
index 3fd87f95c52420afb6aecfae366a9120b0d58df3..0a42308b81e9cc63af3de1754a9142caaef54270 100644 (file)
@@ -360,8 +360,8 @@ void vnt_mac_set_bb_type(struct vnt_private *priv, u8 type);
 void vnt_mac_disable_keyentry(struct vnt_private *priv, u8 entry_idx);
 void vnt_mac_set_keyentry(struct vnt_private *priv, u16 key_ctl, u32 entry_idx,
                          u32 key_idx, u8 *addr, u8 *key);
-void vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits);
-void vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits);
+int vnt_mac_reg_bits_off(struct vnt_private *priv, u8 reg_ofs, u8 bits);
+int vnt_mac_reg_bits_on(struct vnt_private *priv, u8 reg_ofs, u8 bits);
 void vnt_mac_write_word(struct vnt_private *priv, u8 reg_ofs, u16 word);
 void vnt_mac_set_bssid_addr(struct vnt_private *priv, u8 *addr);
 void vnt_mac_enable_protect_mode(struct vnt_private *priv);
@@ -369,6 +369,6 @@ void vnt_mac_disable_protect_mode(struct vnt_private *priv);
 void vnt_mac_enable_barker_preamble_mode(struct vnt_private *priv);
 void vnt_mac_disable_barker_preamble_mode(struct vnt_private *priv);
 void vnt_mac_set_beacon_interval(struct vnt_private *priv, u16 interval);
-void vnt_mac_set_led(struct vnt_private *privpriv, u8 state, u8 led);
+int vnt_mac_set_led(struct vnt_private *privpriv, u8 state, u8 led);
 
 #endif /* __MAC_H__ */
index 18f75dcc65d2129957cb958f7dd29d554425aae6..43237b7e1dbe1f5f6ae66b564d810556d9d9bc75 100644 (file)
@@ -811,8 +811,9 @@ void vnt_rf_rssi_to_dbm(struct vnt_private *priv, u8 rssi, long *dbm)
        *dbm = -1 * (a + b * 2);
 }
 
-void vnt_rf_table_download(struct vnt_private *priv)
+int vnt_rf_table_download(struct vnt_private *priv)
 {
+       int ret = 0;
        u16 length1 = 0, length2 = 0, length3 = 0;
        u8 *addr1 = NULL, *addr2 = NULL, *addr3 = NULL;
        u16 length, value;
@@ -865,8 +866,10 @@ void vnt_rf_table_download(struct vnt_private *priv)
        /* Init Table */
        memcpy(array, addr1, length1);
 
-       vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
-                       MESSAGE_REQUEST_RF_INIT, length1, array);
+       ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
+                             MESSAGE_REQUEST_RF_INIT, length1, array);
+       if (ret)
+               goto end;
 
        /* Channel Table 0 */
        value = 0;
@@ -878,8 +881,10 @@ void vnt_rf_table_download(struct vnt_private *priv)
 
                memcpy(array, addr2, length);
 
-               vnt_control_out(priv, MESSAGE_TYPE_WRITE,
-                               value, MESSAGE_REQUEST_RF_CH0, length, array);
+               ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, value,
+                                     MESSAGE_REQUEST_RF_CH0, length, array);
+               if (ret)
+                       goto end;
 
                length2 -= length;
                value += length;
@@ -896,8 +901,10 @@ void vnt_rf_table_download(struct vnt_private *priv)
 
                memcpy(array, addr3, length);
 
-               vnt_control_out(priv, MESSAGE_TYPE_WRITE,
-                               value, MESSAGE_REQUEST_RF_CH1, length, array);
+               ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, value,
+                                     MESSAGE_REQUEST_RF_CH1, length, array);
+               if (ret)
+                       goto end;
 
                length3 -= length;
                value += length;
@@ -913,8 +920,10 @@ void vnt_rf_table_download(struct vnt_private *priv)
                memcpy(array, addr1, length1);
 
                /* Init Table 2 */
-               vnt_control_out(priv, MESSAGE_TYPE_WRITE,
-                               0, MESSAGE_REQUEST_RF_INIT2, length1, array);
+               ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, 0,
+                                     MESSAGE_REQUEST_RF_INIT2, length1, array);
+               if (ret)
+                       goto end;
 
                /* Channel Table 0 */
                value = 0;
@@ -926,13 +935,18 @@ void vnt_rf_table_download(struct vnt_private *priv)
 
                        memcpy(array, addr2, length);
 
-                       vnt_control_out(priv, MESSAGE_TYPE_WRITE,
-                                       value, MESSAGE_REQUEST_RF_CH2,
-                                       length, array);
+                       ret = vnt_control_out(priv, MESSAGE_TYPE_WRITE, value,
+                                             MESSAGE_REQUEST_RF_CH2, length,
+                                             array);
+                       if (ret)
+                               goto end;
 
                        length2 -= length;
                        value += length;
                        addr2 += length;
                }
        }
+
+end:
+       return ret;
 }
index 6103117d6df56e0033c96972e2756c8a4d0ad8b0..7494546d71b8eb5048ce7c1aa1527e27d4a49732 100644 (file)
@@ -44,6 +44,6 @@ int vnt_rf_write_embedded(struct vnt_private *priv, u32 data);
 int vnt_rf_setpower(struct vnt_private *priv, u32 rate, u32 channel);
 int vnt_rf_set_txpower(struct vnt_private *priv, u8 power, u32 rate);
 void vnt_rf_rssi_to_dbm(struct vnt_private *priv, u8 rssi, long *dbm);
-void vnt_rf_table_download(struct vnt_private *priv);
+int vnt_rf_table_download(struct vnt_private *priv);
 
 #endif /* __RF_H__ */