Commit 07ba60a1 authored by Quentin Deslandes's avatar Quentin Deslandes Committed by Greg Kroah-Hartman

staging: vt6656: clean-up registers initialization error path

Avoid discarding function's return code during register initialization.
Handle it instead and return 0 on success or a negative errno value on
error.
Signed-off-by: default avatarQuentin Deslandes <quentin.deslandes@itdev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d8c28693
...@@ -109,33 +109,38 @@ static void vnt_set_options(struct vnt_private *priv) ...@@ -109,33 +109,38 @@ static void vnt_set_options(struct vnt_private *priv)
*/ */
static int vnt_init_registers(struct vnt_private *priv) static int vnt_init_registers(struct vnt_private *priv)
{ {
int ret = 0;
struct vnt_cmd_card_init *init_cmd = &priv->init_command; struct vnt_cmd_card_init *init_cmd = &priv->init_command;
struct vnt_rsp_card_init *init_rsp = &priv->init_response; struct vnt_rsp_card_init *init_rsp = &priv->init_response;
u8 antenna; u8 antenna;
int ii; int ii;
int status = STATUS_SUCCESS;
u8 tmp; u8 tmp;
u8 calib_tx_iq = 0, calib_tx_dc = 0, calib_rx_iq = 0; u8 calib_tx_iq = 0, calib_tx_dc = 0, calib_rx_iq = 0;
dev_dbg(&priv->usb->dev, "---->INIbInitAdapter. [%d][%d]\n", dev_dbg(&priv->usb->dev, "---->INIbInitAdapter. [%d][%d]\n",
DEVICE_INIT_COLD, priv->packet_type); DEVICE_INIT_COLD, priv->packet_type);
if (!vnt_check_firmware_version(priv)) { ret = vnt_check_firmware_version(priv);
if (vnt_download_firmware(priv) == true) { if (ret) {
if (vnt_firmware_branch_to_sram(priv) == false) { ret = vnt_download_firmware(priv);
if (ret) {
dev_dbg(&priv->usb->dev, dev_dbg(&priv->usb->dev,
" vnt_firmware_branch_to_sram fail\n"); "Could not download firmware: %d.\n", ret);
return false; goto end;
} }
} else {
dev_dbg(&priv->usb->dev, "FIRMWAREbDownload fail\n"); ret = vnt_firmware_branch_to_sram(priv);
return false; if (ret) {
dev_dbg(&priv->usb->dev,
"Could not branch to SRAM: %d.\n", ret);
goto end;
} }
} }
if (!vnt_vt3184_init(priv)) { ret = vnt_vt3184_init(priv);
if (ret) {
dev_dbg(&priv->usb->dev, "vnt_vt3184_init fail\n"); dev_dbg(&priv->usb->dev, "vnt_vt3184_init fail\n");
return false; goto end;
} }
init_cmd->init_class = DEVICE_INIT_COLD; init_cmd->init_class = DEVICE_INIT_COLD;
...@@ -146,28 +151,27 @@ static int vnt_init_registers(struct vnt_private *priv) ...@@ -146,28 +151,27 @@ static int vnt_init_registers(struct vnt_private *priv)
init_cmd->long_retry_limit = priv->long_retry_limit; init_cmd->long_retry_limit = priv->long_retry_limit;
/* issue card_init command to device */ /* issue card_init command to device */
status = vnt_control_out(priv, MESSAGE_TYPE_CARDINIT, 0, 0, ret = vnt_control_out(priv, MESSAGE_TYPE_CARDINIT, 0, 0,
sizeof(struct vnt_cmd_card_init), sizeof(struct vnt_cmd_card_init),
(u8 *)init_cmd); (u8 *)init_cmd);
if (status != STATUS_SUCCESS) { if (ret) {
dev_dbg(&priv->usb->dev, "Issue Card init fail\n"); dev_dbg(&priv->usb->dev, "Issue Card init fail\n");
return false; goto end;
} }
status = vnt_control_in(priv, MESSAGE_TYPE_INIT_RSP, 0, 0, ret = vnt_control_in(priv, MESSAGE_TYPE_INIT_RSP, 0, 0,
sizeof(struct vnt_rsp_card_init), sizeof(struct vnt_rsp_card_init),
(u8 *)init_rsp); (u8 *)init_rsp);
if (status != STATUS_SUCCESS) { if (ret) {
dev_dbg(&priv->usb->dev, dev_dbg(&priv->usb->dev, "Cardinit request in status fail!\n");
"Cardinit request in status fail!\n"); goto end;
return false;
} }
/* local ID for AES functions */ /* local ID for AES functions */
status = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_LOCALID, ret = vnt_control_in(priv, MESSAGE_TYPE_READ, MAC_REG_LOCALID,
MESSAGE_REQUEST_MACREG, 1, &priv->local_id); MESSAGE_REQUEST_MACREG, 1, &priv->local_id);
if (status != STATUS_SUCCESS) if (ret)
return false; goto end;
/* do MACbSoftwareReset in MACvInitialize */ /* do MACbSoftwareReset in MACvInitialize */
...@@ -253,7 +257,9 @@ static int vnt_init_registers(struct vnt_private *priv) ...@@ -253,7 +257,9 @@ static int vnt_init_registers(struct vnt_private *priv)
} }
/* Set initial antenna mode */ /* Set initial antenna mode */
vnt_set_antenna_mode(priv, priv->rx_antenna_mode); ret = vnt_set_antenna_mode(priv, priv->rx_antenna_mode);
if (ret)
goto end;
/* get Auto Fall Back type */ /* get Auto Fall Back type */
priv->auto_fb_ctrl = AUTO_FB_0; priv->auto_fb_ctrl = AUTO_FB_0;
...@@ -275,33 +281,41 @@ static int vnt_init_registers(struct vnt_private *priv) ...@@ -275,33 +281,41 @@ static int vnt_init_registers(struct vnt_private *priv)
/* CR255, enable TX/RX IQ and /* CR255, enable TX/RX IQ and
* DC compensation mode * DC compensation mode
*/ */
vnt_control_out_u8(priv, ret = vnt_control_out_u8(priv,
MESSAGE_REQUEST_BBREG, MESSAGE_REQUEST_BBREG,
0xff, 0xff, 0x03);
0x03); if (ret)
goto end;
/* CR251, TX I/Q Imbalance Calibration */ /* CR251, TX I/Q Imbalance Calibration */
vnt_control_out_u8(priv, ret = vnt_control_out_u8(priv,
MESSAGE_REQUEST_BBREG, MESSAGE_REQUEST_BBREG,
0xfb, 0xfb, calib_tx_iq);
calib_tx_iq); if (ret)
goto end;
/* CR252, TX DC-Offset Calibration */ /* CR252, TX DC-Offset Calibration */
vnt_control_out_u8(priv, ret = vnt_control_out_u8(priv,
MESSAGE_REQUEST_BBREG, MESSAGE_REQUEST_BBREG,
0xfC, 0xfC, calib_tx_dc);
calib_tx_dc); if (ret)
goto end;
/* CR253, RX I/Q Imbalance Calibration */ /* CR253, RX I/Q Imbalance Calibration */
vnt_control_out_u8(priv, ret = vnt_control_out_u8(priv,
MESSAGE_REQUEST_BBREG, MESSAGE_REQUEST_BBREG,
0xfd, 0xfd, calib_rx_iq);
calib_rx_iq); if (ret)
goto end;
} else { } else {
/* CR255, turn off /* CR255, turn off
* BB Calibration compensation * BB Calibration compensation
*/ */
vnt_control_out_u8(priv, ret = vnt_control_out_u8(priv,
MESSAGE_REQUEST_BBREG, MESSAGE_REQUEST_BBREG,
0xff, 0xff, 0x0);
0x0); if (ret)
goto end;
} }
} }
} }
...@@ -323,37 +337,52 @@ static int vnt_init_registers(struct vnt_private *priv) ...@@ -323,37 +337,52 @@ static int vnt_init_registers(struct vnt_private *priv)
else else
priv->short_slot_time = false; priv->short_slot_time = false;
vnt_set_short_slot_time(priv); ret = vnt_set_short_slot_time(priv);
if (ret)
goto end;
priv->radio_ctl = priv->eeprom[EEP_OFS_RADIOCTL]; priv->radio_ctl = priv->eeprom[EEP_OFS_RADIOCTL];
if ((priv->radio_ctl & EEP_RADIOCTL_ENABLE) != 0) { if ((priv->radio_ctl & EEP_RADIOCTL_ENABLE) != 0) {
status = vnt_control_in(priv, MESSAGE_TYPE_READ, ret = vnt_control_in(priv, MESSAGE_TYPE_READ,
MAC_REG_GPIOCTL1, MAC_REG_GPIOCTL1, MESSAGE_REQUEST_MACREG,
MESSAGE_REQUEST_MACREG, 1, &tmp); 1, &tmp);
if (ret)
if (status != STATUS_SUCCESS) goto end;
return false;
if ((tmp & GPIO3_DATA) == 0) if ((tmp & GPIO3_DATA) == 0) {
vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1, ret = vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL1,
GPIO3_INTMD); GPIO3_INTMD);
else } else {
vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1, ret = vnt_mac_reg_bits_off(priv, MAC_REG_GPIOCTL1,
GPIO3_INTMD); GPIO3_INTMD);
} }
vnt_mac_set_led(priv, LEDSTS_TMLEN, 0x38); if (ret)
goto end;
}
vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_SLOW);
vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL0, 0x01); ret = vnt_mac_set_led(priv, LEDSTS_TMLEN, 0x38);
if (ret)
goto end;
ret = vnt_mac_set_led(priv, LEDSTS_STS, LEDSTS_SLOW);
if (ret)
goto end;
vnt_radio_power_on(priv); ret = vnt_mac_reg_bits_on(priv, MAC_REG_GPIOCTL0, 0x01);
if (ret)
goto end;
ret = vnt_radio_power_on(priv);
if (ret)
goto end;
dev_dbg(&priv->usb->dev, "<----INIbInitAdapter Exit\n"); dev_dbg(&priv->usb->dev, "<----INIbInitAdapter Exit\n");
return true; end:
return ret;
} }
static void vnt_free_tx_bufs(struct vnt_private *priv) static void vnt_free_tx_bufs(struct vnt_private *priv)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment