Skip to content

Commit 2abf107

Browse files
juhosgbroonie
authored andcommitted
spi: spi-qpic-snand: use CW_PER_PAGE_MASK bitmask
Change the code to use the already defined CW_PER_PAGE_MASK bitmask along with the FIELD_PREP() macro instead of using magic values. This makes the code more readable. It also syncs the affected codes with their counterparts in the 'qcom_nandc' driver, so it makes it easier to spot the differences between the two implementations. No functional changes intended. Signed-off-by: Gabor Juhos <j4g8y7@gmail.com> Reviewed-by: Md Sadre Alam <quic_mdalam@quicinc.com> Link: https://patch.msgid.link/20250515-qpic-snand-use-bitmasks-v1-1-11729aeae73b@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4614fd6 commit 2abf107

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

drivers/spi/spi-qpic-snand.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,8 @@ static int qcom_spi_block_erase(struct qcom_nand_controller *snandc)
483483
snandc->regs->cmd = snandc->qspi->cmd;
484484
snandc->regs->addr0 = snandc->qspi->addr1;
485485
snandc->regs->addr1 = snandc->qspi->addr2;
486-
snandc->regs->cfg0 = cpu_to_le32(ecc_cfg->cfg0_raw & ~(7 << CW_PER_PAGE));
486+
snandc->regs->cfg0 = cpu_to_le32((ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) |
487+
FIELD_PREP(CW_PER_PAGE_MASK, 0));
487488
snandc->regs->cfg1 = cpu_to_le32(ecc_cfg->cfg1_raw);
488489
snandc->regs->exec = cpu_to_le32(1);
489490

@@ -544,8 +545,8 @@ static int qcom_spi_read_last_cw(struct qcom_nand_controller *snandc,
544545
snandc->regs->addr0 = (snandc->qspi->addr1 | cpu_to_le32(col));
545546
snandc->regs->addr1 = snandc->qspi->addr2;
546547

547-
cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) |
548-
0 << CW_PER_PAGE;
548+
cfg0 = (ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) |
549+
FIELD_PREP(CW_PER_PAGE_MASK, 0);
549550
cfg1 = ecc_cfg->cfg1_raw;
550551
ecc_bch_cfg = ECC_CFG_ECC_DISABLE;
551552

@@ -687,8 +688,8 @@ static int qcom_spi_read_cw_raw(struct qcom_nand_controller *snandc, u8 *data_bu
687688
qcom_clear_bam_transaction(snandc);
688689
raw_cw = num_cw - 1;
689690

690-
cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) |
691-
0 << CW_PER_PAGE;
691+
cfg0 = (ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) |
692+
FIELD_PREP(CW_PER_PAGE_MASK, 0);
692693
cfg1 = ecc_cfg->cfg1_raw;
693694
ecc_bch_cfg = ECC_CFG_ECC_DISABLE;
694695

@@ -808,8 +809,8 @@ static int qcom_spi_read_page_ecc(struct qcom_nand_controller *snandc,
808809
snandc->buf_start = 0;
809810
qcom_clear_read_regs(snandc);
810811

811-
cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) |
812-
(num_cw - 1) << CW_PER_PAGE;
812+
cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) |
813+
FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1);
813814
cfg1 = ecc_cfg->cfg1;
814815
ecc_bch_cfg = ecc_cfg->ecc_bch_cfg;
815816

@@ -904,8 +905,8 @@ static int qcom_spi_read_page_oob(struct qcom_nand_controller *snandc,
904905
qcom_clear_read_regs(snandc);
905906
qcom_clear_bam_transaction(snandc);
906907

907-
cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) |
908-
(num_cw - 1) << CW_PER_PAGE;
908+
cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) |
909+
FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1);
909910
cfg1 = ecc_cfg->cfg1;
910911
ecc_bch_cfg = ecc_cfg->ecc_bch_cfg;
911912

@@ -1015,8 +1016,8 @@ static int qcom_spi_program_raw(struct qcom_nand_controller *snandc,
10151016
int num_cw = snandc->qspi->num_cw;
10161017
u32 cfg0, cfg1, ecc_bch_cfg;
10171018

1018-
cfg0 = (ecc_cfg->cfg0_raw & ~(7U << CW_PER_PAGE)) |
1019-
(num_cw - 1) << CW_PER_PAGE;
1019+
cfg0 = (ecc_cfg->cfg0_raw & ~CW_PER_PAGE_MASK) |
1020+
FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1);
10201021
cfg1 = ecc_cfg->cfg1_raw;
10211022
ecc_bch_cfg = ECC_CFG_ECC_DISABLE;
10221023

@@ -1098,8 +1099,8 @@ static int qcom_spi_program_ecc(struct qcom_nand_controller *snandc,
10981099
int num_cw = snandc->qspi->num_cw;
10991100
u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg;
11001101

1101-
cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) |
1102-
(num_cw - 1) << CW_PER_PAGE;
1102+
cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) |
1103+
FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1);
11031104
cfg1 = ecc_cfg->cfg1;
11041105
ecc_bch_cfg = ecc_cfg->ecc_bch_cfg;
11051106
ecc_buf_cfg = ecc_cfg->ecc_buf_cfg;
@@ -1175,8 +1176,8 @@ static int qcom_spi_program_oob(struct qcom_nand_controller *snandc,
11751176
int num_cw = snandc->qspi->num_cw;
11761177
u32 cfg0, cfg1, ecc_bch_cfg, ecc_buf_cfg;
11771178

1178-
cfg0 = (ecc_cfg->cfg0 & ~(7U << CW_PER_PAGE)) |
1179-
(num_cw - 1) << CW_PER_PAGE;
1179+
cfg0 = (ecc_cfg->cfg0 & ~CW_PER_PAGE_MASK) |
1180+
FIELD_PREP(CW_PER_PAGE_MASK, num_cw - 1);
11801181
cfg1 = ecc_cfg->cfg1;
11811182
ecc_bch_cfg = ecc_cfg->ecc_bch_cfg;
11821183
ecc_buf_cfg = ecc_cfg->ecc_buf_cfg;

0 commit comments

Comments
 (0)