Skip to content

Commit 4026c6b

Browse files
juhosgbroonie
authored andcommitted
spi: spi-qpic-snand: reuse qcom_spi_check_raw_flash_errors()
The qcom_spi_check_raw_flash_errors() function can be used to verify the flash status after raw operations. Move the function slightly up in the code and change the qcom_spi_read_last_cw() function to call it instead of using an open coded implementation of the same check. Signed-off-by: Gabor Juhos <j4g8y7@gmail.com> Link: https://patch.msgid.link/20250514-qpic-snand-error-check-v1-1-c0ebd3aae72a@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 70e5f38 commit 4026c6b

File tree

1 file changed

+19
-21
lines changed

1 file changed

+19
-21
lines changed

drivers/spi/spi-qpic-snand.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,22 @@ static void qcom_spi_config_single_cw_page_read(struct qcom_nand_controller *sna
524524
qcom_read_reg_dma(snandc, NAND_FLASH_STATUS, 1, 0);
525525
}
526526

527+
static int qcom_spi_check_raw_flash_errors(struct qcom_nand_controller *snandc, int cw_cnt)
528+
{
529+
int i;
530+
531+
qcom_nandc_dev_to_mem(snandc, true);
532+
533+
for (i = 0; i < cw_cnt; i++) {
534+
u32 flash = le32_to_cpu(snandc->reg_read_buf[i]);
535+
536+
if (flash & (FS_OP_ERR | FS_MPU_ERR))
537+
return -EIO;
538+
}
539+
540+
return 0;
541+
}
542+
527543
static int qcom_spi_read_last_cw(struct qcom_nand_controller *snandc,
528544
const struct spi_mem_op *op)
529545
{
@@ -569,11 +585,9 @@ static int qcom_spi_read_last_cw(struct qcom_nand_controller *snandc,
569585
return ret;
570586
}
571587

572-
qcom_nandc_dev_to_mem(snandc, true);
573-
u32 flash = le32_to_cpu(snandc->reg_read_buf[0]);
574-
575-
if (flash & (FS_OP_ERR | FS_MPU_ERR))
576-
return -EIO;
588+
ret = qcom_spi_check_raw_flash_errors(snandc, 1);
589+
if (ret)
590+
return ret;
577591

578592
bbpos = mtd->writesize - ecc_cfg->cw_size * (num_cw - 1);
579593

@@ -654,22 +668,6 @@ static int qcom_spi_check_error(struct qcom_nand_controller *snandc, u8 *data_bu
654668
return 0;
655669
}
656670

657-
static int qcom_spi_check_raw_flash_errors(struct qcom_nand_controller *snandc, int cw_cnt)
658-
{
659-
int i;
660-
661-
qcom_nandc_dev_to_mem(snandc, true);
662-
663-
for (i = 0; i < cw_cnt; i++) {
664-
u32 flash = le32_to_cpu(snandc->reg_read_buf[i]);
665-
666-
if (flash & (FS_OP_ERR | FS_MPU_ERR))
667-
return -EIO;
668-
}
669-
670-
return 0;
671-
}
672-
673671
static int qcom_spi_read_cw_raw(struct qcom_nand_controller *snandc, u8 *data_buf,
674672
u8 *oob_buf, int cw)
675673
{

0 commit comments

Comments
 (0)