Skip to content

Commit 76ebfa3

Browse files
juhosgbroonie
authored andcommitted
spi: spi-qpic-snand: extend FIELD_PREP() macro usage
Large part of the code uses the FIELD_PREP() macro already to construct values to be written to hardware registers. Change the code to use also the macro for more registers of which the corresponding bitmasks are defined already. 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-2-11729aeae73b@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2abf107 commit 76ebfa3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/spi/spi-qpic-snand.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ static void qcom_spi_set_read_loc_first(struct qcom_nand_controller *snandc,
130130
int is_last_read_loc)
131131
{
132132
__le32 locreg_val;
133-
u32 val = (((cw_offset) << READ_LOCATION_OFFSET) |
134-
((read_size) << READ_LOCATION_SIZE) | ((is_last_read_loc)
135-
<< READ_LOCATION_LAST));
133+
u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
134+
FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
135+
FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);
136136

137137
locreg_val = cpu_to_le32(val);
138138

@@ -151,9 +151,9 @@ static void qcom_spi_set_read_loc_last(struct qcom_nand_controller *snandc,
151151
int is_last_read_loc)
152152
{
153153
__le32 locreg_val;
154-
u32 val = (((cw_offset) << READ_LOCATION_OFFSET) |
155-
((read_size) << READ_LOCATION_SIZE) | ((is_last_read_loc)
156-
<< READ_LOCATION_LAST));
154+
u32 val = FIELD_PREP(READ_LOCATION_OFFSET_MASK, cw_offset) |
155+
FIELD_PREP(READ_LOCATION_SIZE_MASK, read_size) |
156+
FIELD_PREP(READ_LOCATION_LAST_MASK, is_last_read_loc);
157157

158158
locreg_val = cpu_to_le32(val);
159159

@@ -352,7 +352,7 @@ static int qcom_spi_ecc_init_ctx_pipelined(struct nand_device *nand)
352352
FIELD_PREP(ECC_MODE_MASK, 0) |
353353
FIELD_PREP(ECC_PARITY_SIZE_BYTES_BCH_MASK, ecc_cfg->ecc_bytes_hw);
354354

355-
ecc_cfg->ecc_buf_cfg = 0x203 << NUM_STEPS;
355+
ecc_cfg->ecc_buf_cfg = FIELD_PREP(NUM_STEPS_MASK, 0x203);
356356
ecc_cfg->clrflashstatus = FS_READY_BSY_N;
357357
ecc_cfg->clrreadstatus = 0xc0;
358358

0 commit comments

Comments
 (0)