staging: rts5208: Remove unnecessary braces {}

This patch fixes the checkpatch.pl warning "braces {} are not necessary"
in the rts5208 driver. Mostly applies to single-line return/goto if
blocks.

Signed-off-by: Aymen Qader <qader.aymen@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Aymen Qader 2018-09-20 14:22:25 +01:00 committed by Greg Kroah-Hartman
parent bddd3c2546
commit 9f902b495b
8 changed files with 759 additions and 1459 deletions

File diff suppressed because it is too large Load Diff

View File

@ -647,9 +647,8 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
dev_dbg(rtsx_dev(chip), "Switch SSC clock to %dMHz (cur_clk = %d)\n",
clk, chip->cur_clk);
if ((clk <= 2) || (n > max_n)) {
if ((clk <= 2) || (n > max_n))
return STATUS_FAIL;
}
mcu_cnt = (u8)(125 / clk + 3);
if (mcu_cnt > 7)
@ -688,15 +687,13 @@ int switch_ssc_clock(struct rtsx_chip *chip, int clk)
}
retval = rtsx_send_cmd(chip, 0, WAIT_TIME);
if (retval < 0) {
if (retval < 0)
return STATUS_ERROR;
}
udelay(10);
retval = rtsx_write_register(chip, CLK_CTL, CLK_LOW_FREQ, 0);
if (retval) {
if (retval)
return retval;
}
chip->cur_clk = clk;
@ -790,49 +787,41 @@ int switch_normal_clock(struct rtsx_chip *chip, int clk)
}
retval = rtsx_write_register(chip, CLK_CTL, 0xFF, CLK_LOW_FREQ);
if (retval) {
if (retval)
return retval;
}
if (sd_vpclk_phase_reset) {
retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
PHASE_NOT_RESET, 0);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
PHASE_NOT_RESET, 0);
if (retval) {
if (retval)
return retval;
}
}
retval = rtsx_write_register(chip, CLK_DIV, 0xFF,
(div << 4) | mcu_cnt);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CLK_SEL, 0xFF, sel);
if (retval) {
if (retval)
return retval;
}
if (sd_vpclk_phase_reset) {
udelay(200);
retval = rtsx_write_register(chip, SD_VPCLK0_CTL,
PHASE_NOT_RESET, PHASE_NOT_RESET);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, SD_VPCLK1_CTL,
PHASE_NOT_RESET, PHASE_NOT_RESET);
if (retval) {
if (retval)
return retval;
}
udelay(200);
}
retval = rtsx_write_register(chip, CLK_CTL, 0xFF, 0);
if (retval) {
if (retval)
return retval;
}
chip->cur_clk = clk;
@ -878,9 +867,8 @@ int enable_card_clock(struct rtsx_chip *chip, u8 card)
clk_en |= MS_CLK_EN;
retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, clk_en);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -898,9 +886,8 @@ int disable_card_clock(struct rtsx_chip *chip, u8 card)
clk_en |= MS_CLK_EN;
retval = rtsx_write_register(chip, CARD_CLK_EN, clk_en, 0);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -924,9 +911,8 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val1);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
udelay(chip->pmos_pwr_on_interval);
@ -934,9 +920,8 @@ int card_power_on(struct rtsx_chip *chip, u8 card)
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_PWR_CTL, mask, val2);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
@ -955,9 +940,8 @@ int card_power_off(struct rtsx_chip *chip, u8 card)
}
retval = rtsx_write_register(chip, CARD_PWR_CTL, mask, val);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -969,9 +953,8 @@ int card_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
unsigned int lun = SCSI_LUN(srb);
int i;
if (!chip->rw_card[lun]) {
if (!chip->rw_card[lun])
return STATUS_FAIL;
}
for (i = 0; i < 3; i++) {
chip->rw_need_retry = 0;
@ -1009,36 +992,33 @@ int card_share_mode(struct rtsx_chip *chip, int card)
if (CHECK_PID(chip, 0x5208)) {
mask = CARD_SHARE_MASK;
if (card == SD_CARD) {
if (card == SD_CARD)
value = CARD_SHARE_48_SD;
} else if (card == MS_CARD) {
else if (card == MS_CARD)
value = CARD_SHARE_48_MS;
} else if (card == XD_CARD) {
else if (card == XD_CARD)
value = CARD_SHARE_48_XD;
} else {
else
return STATUS_FAIL;
}
} else if (CHECK_PID(chip, 0x5288)) {
mask = 0x03;
if (card == SD_CARD) {
if (card == SD_CARD)
value = CARD_SHARE_BAROSSA_SD;
} else if (card == MS_CARD) {
else if (card == MS_CARD)
value = CARD_SHARE_BAROSSA_MS;
} else if (card == XD_CARD) {
else if (card == XD_CARD)
value = CARD_SHARE_BAROSSA_XD;
} else {
else
return STATUS_FAIL;
}
} else {
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_SHARE_MODE, mask, value);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -1050,28 +1030,25 @@ int select_card(struct rtsx_chip *chip, int card)
if (chip->cur_card != card) {
u8 mod;
if (card == SD_CARD) {
if (card == SD_CARD)
mod = SD_MOD_SEL;
} else if (card == MS_CARD) {
else if (card == MS_CARD)
mod = MS_MOD_SEL;
} else if (card == XD_CARD) {
else if (card == XD_CARD)
mod = XD_MOD_SEL;
} else if (card == SPI_CARD) {
else if (card == SPI_CARD)
mod = SPI_MOD_SEL;
} else {
else
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_SELECT, 0x07, mod);
if (retval) {
if (retval)
return retval;
}
chip->cur_card = card;
retval = card_share_mode(chip, card);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
}
return STATUS_SUCCESS;
@ -1120,9 +1097,8 @@ int detect_card_cd(struct rtsx_chip *chip, int card)
}
status = rtsx_readl(chip, RTSX_BIPR);
if (!(status & card_cd)) {
if (!(status & card_cd))
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}

View File

@ -1062,9 +1062,8 @@ static inline int card_power_off_all(struct rtsx_chip *chip)
int retval;
retval = rtsx_write_register(chip, CARD_PWR_CTL, 0x0F, 0x0F);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}

File diff suppressed because it is too large Load Diff

View File

@ -507,9 +507,8 @@ static int inquiry(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
buf = vmalloc(scsi_bufflen(srb));
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
#ifdef SUPPORT_MAGIC_GATE
if ((chip->mspro_formatter_enable) &&
@ -637,9 +636,8 @@ static int request_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
buf = vmalloc(scsi_bufflen(srb));
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
tmp = (unsigned char *)sense;
memcpy(buf, tmp, scsi_bufflen(srb));
@ -783,9 +781,8 @@ static int mode_sense(struct scsi_cmnd *srb, struct rtsx_chip *chip)
#endif
buf = kmalloc(data_size, GFP_KERNEL);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
page_code = srb->cmnd[2] & 0x3f;
@ -999,9 +996,8 @@ static int read_format_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip)
buf_len = (scsi_bufflen(srb) > 12) ? 0x14 : 12;
buf = kmalloc(buf_len, GFP_KERNEL);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
buf[i++] = 0;
buf[i++] = 0;
@ -1076,9 +1072,8 @@ static int read_capacity(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
buf = kmalloc(8, GFP_KERNEL);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
card_size = get_card_size(chip, lun);
buf[0] = (unsigned char)((card_size - 1) >> 24);
@ -1116,9 +1111,8 @@ static int read_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = ((u16)srb->cmnd[4] << 8) | srb->cmnd[5];
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
retval = rtsx_force_power_on(chip, SSC_PDCTL);
if (retval != STATUS_SUCCESS) {
@ -1180,9 +1174,8 @@ static int write_eeprom(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb),
len);
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@ -1227,9 +1220,8 @@ static int read_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
retval = rtsx_force_power_on(chip, SSC_PDCTL);
if (retval != STATUS_SUCCESS) {
@ -1282,9 +1274,8 @@ static int write_mem(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len);
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@ -1702,41 +1693,35 @@ static int set_chip_mode(struct scsi_cmnd *srb, struct rtsx_chip *chip)
if (phy_debug_mode) {
chip->phy_debug_mode = 1;
retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
rtsx_disable_bus_int(chip);
retval = rtsx_read_phy_register(chip, 0x1C, &reg);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
reg |= 0x0001;
retval = rtsx_write_phy_register(chip, 0x1C, reg);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
chip->phy_debug_mode = 0;
retval = rtsx_write_register(chip, CDRESUMECTL, 0x77, 0x77);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
rtsx_enable_bus_int(chip);
retval = rtsx_read_phy_register(chip, 0x1C, &reg);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
reg &= 0xFFFE;
retval = rtsx_write_phy_register(chip, 0x1C, reg);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
}
return TRANSPORT_GOOD;
@ -1840,9 +1825,8 @@ static int read_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip)
if (len) {
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
retval = rtsx_force_power_on(chip, SSC_PDCTL);
if (retval != STATUS_SUCCESS) {
@ -1903,9 +1887,8 @@ static int write_phy_register(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len);
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@ -1999,9 +1982,8 @@ static int read_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = ((u16)srb->cmnd[6] << 8) | srb->cmnd[7];
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
retval = rtsx_force_power_on(chip, SSC_PDCTL);
if (retval != STATUS_SUCCESS) {
@ -2049,9 +2031,8 @@ static int write_eeprom2(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len);
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@ -2096,9 +2077,8 @@ static int read_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = srb->cmnd[5];
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
retval = rtsx_force_power_on(chip, SSC_PDCTL);
if (retval != STATUS_SUCCESS) {
@ -2147,9 +2127,8 @@ static int write_efuse(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = (u8)min_t(unsigned int, scsi_bufflen(srb), len);
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@ -2215,29 +2194,25 @@ exit:
vfree(buf);
retval = card_power_off(chip, SPI_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_ERROR;
}
if (chip->asic_code) {
retval = rtsx_write_register(chip, PWR_GATE_CTRL,
LDO3318_PWR_MASK, LDO_OFF);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_ERROR;
}
wait_timeout(600);
retval = rtsx_write_phy_register(chip, 0x08, val);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_ERROR;
}
retval = rtsx_write_register(chip, PWR_GATE_CTRL,
LDO3318_PWR_MASK, LDO_ON);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_ERROR;
}
}
return result;
@ -2278,9 +2253,8 @@ static int read_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
retval = rtsx_read_cfg_seq(chip, func, addr, buf, len);
if (retval != STATUS_SUCCESS) {
@ -2335,9 +2309,8 @@ static int write_cfg_byte(struct scsi_cmnd *srb, struct rtsx_chip *chip)
len = (unsigned short)min_t(unsigned int, scsi_bufflen(srb), len);
buf = vmalloc(len);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
rtsx_stor_get_xfer_buf(buf, len, srb);
scsi_set_resid(srb, scsi_bufflen(srb) - len);
@ -2657,9 +2630,8 @@ static int spi_vendor_cmd(struct scsi_cmnd *srb, struct rtsx_chip *chip)
rtsx_write_register(chip, CARD_GPIO_DIR, 0x07, gpio_dir);
if (result != STATUS_SUCCESS) {
if (result != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
return TRANSPORT_GOOD;
}
@ -2849,9 +2821,8 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
buf = kmalloc(buf_len, GFP_KERNEL);
if (!buf) {
if (!buf)
return TRANSPORT_ERROR;
}
i = 0;
/* GET Memory Stick Media Information Response Header */
@ -3025,9 +2996,8 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
(srb->cmnd[8] == 0x04) &&
(srb->cmnd[9] == 0x1C)) {
retval = mg_get_local_EKB(srb, chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
set_sense_type(chip, lun,
@ -3041,9 +3011,8 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
(srb->cmnd[8] == 0x00) &&
(srb->cmnd[9] == 0x24)) {
retval = mg_get_rsp_chg(srb, chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
set_sense_type(chip, lun,
@ -3062,9 +3031,8 @@ static int mg_report_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
(srb->cmnd[4] == 0x00) &&
(srb->cmnd[5] < 32)) {
retval = mg_get_ICV(srb, chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
set_sense_type(chip, lun,
@ -3131,9 +3099,8 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
(srb->cmnd[8] == 0x00) &&
(srb->cmnd[9] == 0x0C)) {
retval = mg_set_leaf_id(srb, chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
set_sense_type(chip, lun,
@ -3147,9 +3114,8 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
(srb->cmnd[8] == 0x00) &&
(srb->cmnd[9] == 0x0C)) {
retval = mg_chg(srb, chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
set_sense_type(chip, lun,
@ -3163,9 +3129,8 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
(srb->cmnd[8] == 0x00) &&
(srb->cmnd[9] == 0x0C)) {
retval = mg_rsp(srb, chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
set_sense_type(chip, lun,
@ -3184,9 +3149,8 @@ static int mg_send_key(struct scsi_cmnd *srb, struct rtsx_chip *chip)
(srb->cmnd[4] == 0x00) &&
(srb->cmnd[5] < 32)) {
retval = mg_set_ICV(srb, chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return TRANSPORT_FAILED;
}
} else {
set_sense_type(chip, lun,

File diff suppressed because it is too large Load Diff

View File

@ -41,14 +41,12 @@ static int spi_init(struct rtsx_chip *chip)
retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
CS_POLARITY_LOW | DTO_MSB_FIRST
| SPI_MASTER | SPI_MODE0 | SPI_AUTO);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
SAMPLE_DELAY_HALF);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -60,42 +58,35 @@ static int spi_set_init_para(struct rtsx_chip *chip)
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF,
(u8)(spi->clk_div >> 8));
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF,
(u8)(spi->clk_div));
if (retval) {
if (retval)
return retval;
}
retval = switch_clock(chip, spi->spi_clock);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = select_card(chip, SPI_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
SPI_CLK_EN);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
SPI_OUTPUT_EN);
if (retval) {
if (retval)
return retval;
}
wait_timeout(10);
retval = spi_init(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
@ -247,47 +238,39 @@ static int spi_init_eeprom(struct rtsx_chip *chip)
clk = CLK_30;
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER1, 0xFF, 0x00);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, SPI_CLK_DIVIDER0, 0xFF, 0x27);
if (retval) {
if (retval)
return retval;
}
retval = switch_clock(chip, clk);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = select_card(chip, SPI_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_CLK_EN, SPI_CLK_EN,
SPI_CLK_EN);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_OE, SPI_OUTPUT_EN,
SPI_OUTPUT_EN);
if (retval) {
if (retval)
return retval;
}
wait_timeout(10);
retval = rtsx_write_register(chip, SPI_CONTROL, 0xFF,
CS_POLARITY_HIGH | SPI_EEPROM_AUTO);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, SPI_TCTL, EDO_TIMING_MASK,
SAMPLE_DELAY_HALF);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -306,9 +289,8 @@ static int spi_eeprom_program_enable(struct rtsx_chip *chip)
SPI_TRANSFER0_END);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
@ -318,14 +300,12 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip)
int retval;
retval = spi_init_eeprom(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = spi_eeprom_program_enable(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -339,14 +319,12 @@ int spi_erase_eeprom_chip(struct rtsx_chip *chip)
SPI_TRANSFER0_END);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -356,14 +334,12 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr)
int retval;
retval = spi_init_eeprom(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = spi_eeprom_program_enable(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -379,14 +355,12 @@ int spi_erase_eeprom_byte(struct rtsx_chip *chip, u16 addr)
SPI_TRANSFER0_END);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -397,9 +371,8 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val)
u8 data;
retval = spi_init_eeprom(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -416,23 +389,20 @@ int spi_read_eeprom(struct rtsx_chip *chip, u16 addr, u8 *val)
SPI_TRANSFER0_END);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
wait_timeout(5);
retval = rtsx_read_register(chip, SPI_DATA, &data);
if (retval) {
if (retval)
return retval;
}
if (val)
*val = data;
retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -442,14 +412,12 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val)
int retval;
retval = spi_init_eeprom(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = spi_eeprom_program_enable(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -466,14 +434,12 @@ int spi_write_eeprom(struct rtsx_chip *chip, u16 addr, u8 val)
SPI_TRANSFER0_END);
retval = rtsx_send_cmd(chip, 0, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_GPIO_DIR, 0x01, 0x01);
if (retval) {
if (retval)
return retval;
}
return STATUS_SUCCESS;
}
@ -577,9 +543,8 @@ int spi_read_flash_id(struct scsi_cmnd *srb, struct rtsx_chip *chip)
if (len) {
buf = kmalloc(len, GFP_KERNEL);
if (!buf) {
if (!buf)
return STATUS_ERROR;
}
retval = rtsx_read_ppbuf(chip, buf, len);
if (retval != STATUS_SUCCESS) {
@ -621,9 +586,8 @@ int spi_read_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL);
if (!buf) {
if (!buf)
return STATUS_ERROR;
}
while (len) {
u16 pagelen = SF_PAGE_LEN - (u8)addr;
@ -716,9 +680,8 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
if (program_mode == BYTE_PROGRAM) {
buf = kmalloc(4, GFP_KERNEL);
if (!buf) {
if (!buf)
return STATUS_ERROR;
}
while (len) {
retval = sf_enable_write(chip, SPI_WREN);
@ -762,14 +725,12 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
int first_byte = 1;
retval = sf_enable_write(chip, SPI_WREN);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
buf = kmalloc(4, GFP_KERNEL);
if (!buf) {
if (!buf)
return STATUS_ERROR;
}
while (len) {
rtsx_stor_access_xfer_buf(buf, 1, srb, &index, &offset,
@ -808,19 +769,16 @@ int spi_write_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
kfree(buf);
retval = sf_disable_write(chip, SPI_WRDI);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = sf_polling_status(chip, 100);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
} else if (program_mode == PAGE_PROGRAM) {
buf = kmalloc(SF_PAGE_LEN, GFP_KERNEL);
if (!buf) {
if (!buf)
return STATUS_NOMEM;
}
while (len) {
u16 pagelen = SF_PAGE_LEN - (u8)addr;
@ -893,24 +851,20 @@ int spi_erase_flash(struct scsi_cmnd *srb, struct rtsx_chip *chip)
if (erase_mode == PAGE_ERASE) {
retval = sf_enable_write(chip, SPI_WREN);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = sf_erase(chip, ins, 1, addr);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
} else if (erase_mode == CHIP_ERASE) {
retval = sf_enable_write(chip, SPI_WREN);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = sf_erase(chip, ins, 0, 0);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
} else {
spi_set_err_code(chip, SPI_INVALID_COMMAND);
return STATUS_FAIL;
@ -935,9 +889,8 @@ int spi_write_flash_status(struct scsi_cmnd *srb, struct rtsx_chip *chip)
}
retval = sf_enable_write(chip, ewsr);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);

View File

@ -60,9 +60,8 @@ static int xd_set_init_para(struct rtsx_chip *chip)
xd_card->xd_clock = CLK_50;
retval = switch_clock(chip, xd_card->xd_clock);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
@ -73,14 +72,12 @@ static int xd_switch_clock(struct rtsx_chip *chip)
int retval;
retval = select_card(chip, XD_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = switch_clock(chip, xd_card->xd_clock);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
@ -102,9 +99,8 @@ static int xd_read_id(struct rtsx_chip *chip, u8 id_cmd, u8 *id_buf, u8 buf_len)
rtsx_add_cmd(chip, READ_REG_CMD, (u16)(XD_ADDRESS1 + i), 0, 0);
retval = rtsx_send_cmd(chip, XD_CARD, 20);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
ptr = rtsx_get_cmd_data(chip) + 1;
if (id_buf && buf_len) {
@ -173,9 +169,8 @@ static int xd_read_redundant(struct rtsx_chip *chip, u32 page_addr,
rtsx_add_cmd(chip, READ_REG_CMD, XD_PARITY, 0, 0);
retval = rtsx_send_cmd(chip, XD_CARD, 500);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
if (buf && buf_len) {
u8 *ptr = rtsx_get_cmd_data(chip) + 1;
@ -193,9 +188,8 @@ static int xd_read_data_from_ppb(struct rtsx_chip *chip, int offset,
{
int retval, i;
if (!buf || (buf_len < 0)) {
if (!buf || (buf_len < 0))
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -220,9 +214,8 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
int retval;
u8 reg;
if (!buf || (buf_len < 10)) {
if (!buf || (buf_len < 10))
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -246,36 +239,31 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
}
retval = rtsx_read_register(chip, XD_PAGE_STATUS, &reg);
if (retval) {
if (retval)
return retval;
}
if (reg != XD_GPG) {
rtsx_clear_xd_error(chip);
return STATUS_FAIL;
}
retval = rtsx_read_register(chip, XD_CTL, &reg);
if (retval) {
if (retval)
return retval;
}
if (!(reg & XD_ECC1_ERROR) || !(reg & XD_ECC1_UNCORRECTABLE)) {
retval = xd_read_data_from_ppb(chip, 0, buf, buf_len);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
if (reg & XD_ECC1_ERROR) {
u8 ecc_bit, ecc_byte;
retval = rtsx_read_register(chip, XD_ECC_BIT1,
&ecc_bit);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_read_register(chip, XD_ECC_BYTE1,
&ecc_byte);
if (retval) {
if (retval)
return retval;
}
dev_dbg(rtsx_dev(chip), "ECC_BIT1 = 0x%x, ECC_BYTE1 = 0x%x\n",
ecc_bit, ecc_byte);
@ -291,22 +279,19 @@ static int xd_read_cis(struct rtsx_chip *chip, u32 page_addr, u8 *buf,
rtsx_clear_xd_error(chip);
retval = xd_read_data_from_ppb(chip, 256, buf, buf_len);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
if (reg & XD_ECC2_ERROR) {
u8 ecc_bit, ecc_byte;
retval = rtsx_read_register(chip, XD_ECC_BIT2,
&ecc_bit);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_read_register(chip, XD_ECC_BYTE2,
&ecc_byte);
if (retval) {
if (retval)
return retval;
}
dev_dbg(rtsx_dev(chip), "ECC_BIT2 = 0x%x, ECC_BYTE2 = 0x%x\n",
ecc_bit, ecc_byte);
@ -404,68 +389,58 @@ static int xd_pull_ctl_disable(struct rtsx_chip *chip)
XD_D2_PD |
XD_D1_PD |
XD_D0_PD);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL2, 0xFF,
XD_D7_PD |
XD_D6_PD |
XD_D5_PD |
XD_D4_PD);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL3, 0xFF,
XD_WP_PD |
XD_CE_PD |
XD_CLE_PD |
XD_CD_PU);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL4, 0xFF,
XD_RDY_PD |
XD_WE_PD |
XD_RE_PD |
XD_ALE_PD);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL5, 0xFF,
MS_INS_PU |
SD_WP_PD |
SD_CD_PU |
SD_CMD_PD);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL6, 0xFF,
MS_D5_PD | MS_D4_PD);
if (retval) {
if (retval)
return retval;
}
} else if (CHECK_PID(chip, 0x5288)) {
if (CHECK_BARO_PKG(chip, QFN)) {
retval = rtsx_write_register(chip, CARD_PULL_CTL1,
0xFF, 0x55);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL2,
0xFF, 0x55);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL3,
0xFF, 0x4B);
if (retval) {
if (retval)
return retval;
}
retval = rtsx_write_register(chip, CARD_PULL_CTL4,
0xFF, 0x69);
if (retval) {
if (retval)
return retval;
}
}
}
@ -479,9 +454,8 @@ static int reset_xd(struct rtsx_chip *chip)
u8 *ptr, id_buf[4], redunt[11];
retval = select_card(chip, XD_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -505,15 +479,13 @@ static int reset_xd(struct rtsx_chip *chip)
rtsx_add_cmd(chip, WRITE_REG_CMD, CARD_OE, XD_OUTPUT_EN, 0);
retval = rtsx_send_cmd(chip, XD_CARD, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
if (!chip->ft2_fast_mode) {
retval = card_power_off(chip, XD_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
wait_timeout(250);
@ -529,14 +501,12 @@ static int reset_xd(struct rtsx_chip *chip)
}
retval = rtsx_send_cmd(chip, XD_CARD, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
retval = card_power_on(chip, XD_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
#ifdef SUPPORT_OCP
wait_timeout(50);
@ -565,17 +535,15 @@ static int reset_xd(struct rtsx_chip *chip)
rtsx_add_cmd(chip, WRITE_REG_CMD, XD_CTL, XD_CE_DISEN, XD_CE_DISEN);
retval = rtsx_send_cmd(chip, XD_CARD, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
if (!chip->ft2_fast_mode)
wait_timeout(200);
retval = xd_set_init_para(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
/* Read ID to check if the timing setting is right */
for (i = 0; i < 4; i++) {
@ -598,9 +566,8 @@ static int reset_xd(struct rtsx_chip *chip)
rtsx_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0);
retval = rtsx_send_cmd(chip, XD_CARD, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
ptr = rtsx_get_cmd_data(chip) + 1;
@ -612,9 +579,8 @@ static int reset_xd(struct rtsx_chip *chip)
continue;
retval = xd_read_id(chip, READ_ID, id_buf, 4);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
dev_dbg(rtsx_dev(chip), "READ_ID: 0x%x 0x%x 0x%x 0x%x\n",
id_buf[0], id_buf[1], id_buf[2], id_buf[3]);
@ -694,9 +660,8 @@ static int reset_xd(struct rtsx_chip *chip)
/* Confirm timing setting */
for (j = 0; j < 10; j++) {
retval = xd_read_id(chip, READ_ID, id_buf, 4);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
if (id_buf[1] != xd_card->device_code)
break;
@ -716,22 +681,19 @@ static int reset_xd(struct rtsx_chip *chip)
}
retval = xd_read_id(chip, READ_xD_ID, id_buf, 4);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
dev_dbg(rtsx_dev(chip), "READ_xD_ID: 0x%x 0x%x 0x%x 0x%x\n",
id_buf[0], id_buf[1], id_buf[2], id_buf[3]);
if (id_buf[2] != XD_ID_CODE) {
if (id_buf[2] != XD_ID_CODE)
return STATUS_FAIL;
}
/* Search CIS block */
for (i = 0; i < 24; i++) {
u32 page_addr;
if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS)
return STATUS_FAIL;
}
page_addr = (u32)i << xd_card->block_shift;
@ -769,9 +731,8 @@ static int reset_xd(struct rtsx_chip *chip)
page_addr += j;
retval = xd_read_cis(chip, page_addr, buf, 10);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
if ((buf[0] == 0x01) && (buf[1] == 0x03) &&
(buf[2] == 0xD9) &&
@ -841,17 +802,15 @@ static int xd_init_l2p_tbl(struct rtsx_chip *chip)
dev_dbg(rtsx_dev(chip), "%s: zone_cnt = %d\n", __func__,
xd_card->zone_cnt);
if (xd_card->zone_cnt < 1) {
if (xd_card->zone_cnt < 1)
return STATUS_FAIL;
}
size = xd_card->zone_cnt * sizeof(struct zone_entry);
dev_dbg(rtsx_dev(chip), "Buffer size for l2p table is %d\n", size);
xd_card->zone = vmalloc(size);
if (!xd_card->zone) {
if (!xd_card->zone)
return STATUS_ERROR;
}
for (i = 0; i < xd_card->zone_cnt; i++) {
xd_card->zone[i].build_flag = 0;
@ -1028,19 +987,16 @@ int reset_xd_card(struct rtsx_chip *chip)
xd_card->delay_write.delay_write_flag = 0;
retval = enable_card_clock(chip, XD_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = reset_xd(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = xd_init_l2p_tbl(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
@ -1054,9 +1010,8 @@ static int xd_mark_bad_block(struct rtsx_chip *chip, u32 phy_blk)
dev_dbg(rtsx_dev(chip), "mark block 0x%x as bad block\n", phy_blk);
if (phy_blk == BLK_NOT_FOUND) {
if (phy_blk == BLK_NOT_FOUND)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -1107,12 +1062,10 @@ static int xd_init_page(struct rtsx_chip *chip, u32 phy_blk,
dev_dbg(rtsx_dev(chip), "Init block 0x%x\n", phy_blk);
if (start_page > end_page) {
if (start_page > end_page)
return STATUS_FAIL;
}
if (phy_blk == BLK_NOT_FOUND) {
if (phy_blk == BLK_NOT_FOUND)
return STATUS_FAIL;
}
rtsx_init_cmd(chip);
@ -1164,13 +1117,11 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk,
dev_dbg(rtsx_dev(chip), "Copy page from block 0x%x to block 0x%x\n",
old_blk, new_blk);
if (start_page > end_page) {
if (start_page > end_page)
return STATUS_FAIL;
}
if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND)) {
if ((old_blk == BLK_NOT_FOUND) || (new_blk == BLK_NOT_FOUND))
return STATUS_FAIL;
}
old_page = (old_blk << xd_card->block_shift) + start_page;
new_page = (new_blk << xd_card->block_shift) + start_page;
@ -1179,9 +1130,8 @@ static int xd_copy_page(struct rtsx_chip *chip, u32 old_blk, u32 new_blk,
retval = rtsx_write_register(chip, CARD_DATA_SOURCE, 0x01,
PINGPONG_BUFFER);
if (retval) {
if (retval)
return retval;
}
for (i = start_page; i < end_page; i++) {
if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
@ -1287,9 +1237,8 @@ static int xd_reset_cmd(struct rtsx_chip *chip)
rtsx_add_cmd(chip, READ_REG_CMD, XD_CTL, 0, 0);
retval = rtsx_send_cmd(chip, XD_CARD, 100);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
ptr = rtsx_get_cmd_data(chip) + 1;
if (((ptr[0] & READY_FLAG) == READY_STATE) && (ptr[1] & XD_RDY))
@ -1305,9 +1254,8 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk)
u8 reg = 0, *ptr;
int i, retval;
if (phy_blk == BLK_NOT_FOUND) {
if (phy_blk == BLK_NOT_FOUND)
return STATUS_FAIL;
}
page_addr = phy_blk << xd_card->block_shift;
@ -1333,9 +1281,8 @@ static int xd_erase_block(struct rtsx_chip *chip, u32 phy_blk)
}
xd_set_err_code(chip, XD_ERASE_FAIL);
retval = xd_reset_cmd(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
continue;
}
@ -1382,17 +1329,15 @@ static int xd_build_l2p_tbl(struct rtsx_chip *chip, int zone_no)
if (!zone->l2p_table) {
zone->l2p_table = vmalloc(2000);
if (!zone->l2p_table) {
if (!zone->l2p_table)
goto build_fail;
}
}
memset((u8 *)(zone->l2p_table), 0xff, 2000);
if (!zone->free_table) {
zone->free_table = vmalloc(XD_FREE_TABLE_CNT * 2);
if (!zone->free_table) {
if (!zone->free_table)
goto build_fail;
}
}
memset((u8 *)(zone->free_table), 0xff, XD_FREE_TABLE_CNT * 2);
@ -1555,9 +1500,8 @@ static int xd_send_cmd(struct rtsx_chip *chip, u8 cmd)
XD_TRANSFER_END, XD_TRANSFER_END);
retval = rtsx_send_cmd(chip, XD_CARD, 200);
if (retval < 0) {
if (retval < 0)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}
@ -1636,17 +1580,15 @@ static int xd_read_multiple_pages(struct rtsx_chip *chip, u32 phy_blk,
fail:
retval = rtsx_read_register(chip, XD_PAGE_STATUS, &reg_val);
if (retval) {
if (retval)
return retval;
}
if (reg_val != XD_GPG)
xd_set_err_code(chip, XD_PRG_ERROR);
retval = rtsx_read_register(chip, XD_CTL, &reg_val);
if (retval) {
if (retval)
return retval;
}
if (((reg_val & (XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) ==
(XD_ECC1_ERROR | XD_ECC1_UNCORRECTABLE)) ||
@ -1702,9 +1644,8 @@ static int xd_finish_write(struct rtsx_chip *chip,
dev_dbg(rtsx_dev(chip), "new_blk = 0x%x, ", new_blk);
dev_dbg(rtsx_dev(chip), "log_blk = 0x%x\n", log_blk);
if (page_off > xd_card->page_off) {
if (page_off > xd_card->page_off)
return STATUS_FAIL;
}
zone_no = (int)(log_blk / 1000);
log_off = (u16)(log_blk % 1000);
@ -1760,9 +1701,8 @@ static int xd_prepare_write(struct rtsx_chip *chip,
if (page_off) {
retval = xd_copy_page(chip, old_blk, new_blk, 0, page_off);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
}
return STATUS_SUCCESS;
@ -1858,9 +1798,8 @@ static int xd_write_multiple_pages(struct rtsx_chip *chip, u32 old_blk,
fail:
retval = rtsx_read_register(chip, XD_DAT, &reg_val);
if (retval) {
if (retval)
return retval;
}
if (reg_val & PROGRAM_ERROR) {
xd_set_err_code(chip, XD_PRG_ERROR);
xd_mark_bad_block(chip, new_blk);
@ -1880,9 +1819,8 @@ int xd_delay_write(struct rtsx_chip *chip)
if (delay_write->delay_write_flag) {
dev_dbg(rtsx_dev(chip), "%s\n", __func__);
retval = xd_switch_clock(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
delay_write->delay_write_flag = 0;
retval = xd_finish_write(chip,
@ -1890,9 +1828,8 @@ int xd_delay_write(struct rtsx_chip *chip)
delay_write->new_phyblock,
delay_write->logblock,
delay_write->pageoff);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
}
return STATUS_SUCCESS;
@ -1924,9 +1861,8 @@ int xd_rw(struct scsi_cmnd *srb, struct rtsx_chip *chip,
ptr = (u8 *)scsi_sglist(srb);
retval = xd_switch_clock(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
if (detect_card_cd(chip, XD_CARD) != STATUS_SUCCESS) {
chip->card_fail |= XD_CARD;
@ -2180,34 +2116,29 @@ int xd_power_off_card3v3(struct rtsx_chip *chip)
int retval;
retval = disable_card_clock(chip, XD_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
retval = rtsx_write_register(chip, CARD_OE, XD_OUTPUT_EN, 0);
if (retval) {
if (retval)
return retval;
}
if (!chip->ft2_fast_mode) {
retval = card_power_off(chip, XD_CARD);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
wait_timeout(50);
}
if (chip->asic_code) {
retval = xd_pull_ctl_disable(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
} else {
retval = rtsx_write_register(chip, FPGA_PULL_CTL, 0xFF, 0xDF);
if (retval) {
if (retval)
return retval;
}
}
return STATUS_SUCCESS;
@ -2227,9 +2158,8 @@ int release_xd_card(struct rtsx_chip *chip)
xd_free_l2p_tbl(chip);
retval = xd_power_off_card3v3(chip);
if (retval != STATUS_SUCCESS) {
if (retval != STATUS_SUCCESS)
return STATUS_FAIL;
}
return STATUS_SUCCESS;
}