public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: atcspi200: validate data buswidth to fix FIELD_PREP build error
@ 2026-02-18  8:21 xiaopeitux
  2026-02-23  6:36 ` CL Wang
  0 siblings, 1 reply; 3+ messages in thread
From: xiaopeitux @ 2026-02-18  8:21 UTC (permalink / raw)
  To: cl634, broonie, linux-spi, linux-kernel; +Cc: Pei Xiao, kernel test robot

From: Pei Xiao <xiaopei01@kylinos.cn>

TRANS_DUAL_QUAD only two bit, limit to range 0~3.
which gcc complains about:
error: FIELD_PREP: value too large for the field
drivers/spi/spi-atcspi200.c:198:9: note: in expansion of macro
'TRANS_DUAL_QUAD'
tc |= TRANS_DUAL_QUAD(ffs(op->data.buswidth) - 1);

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202602140738.P7ZozxzI-lkp@intel.com/
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
 drivers/spi/spi-atcspi200.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-atcspi200.c b/drivers/spi/spi-atcspi200.c
index 60a37ff5c6f5..87a2dedcee55 100644
--- a/drivers/spi/spi-atcspi200.c
+++ b/drivers/spi/spi-atcspi200.c
@@ -195,7 +195,10 @@ static void atcspi_set_trans_ctl(struct atcspi_dev *spi,
 	if (op->addr.buswidth > 1)
 		tc |= TRANS_ADDR_FMT;
 	if (op->data.nbytes) {
-		tc |= TRANS_DUAL_QUAD(ffs(op->data.buswidth) - 1);
+		unsigned int width_code = ffs(op->data.buswidth) - 1;
+		if(unlikely(width_code > 3))
+                        return;
+		tc |= TRANS_DUAL_QUAD(width_code);
 		if (op->data.dir == SPI_MEM_DATA_IN) {
 			if (op->dummy.nbytes)
 				tc |= TRANS_MODE_DMY_READ |
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-02-23  7:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-18  8:21 [PATCH] spi: atcspi200: validate data buswidth to fix FIELD_PREP build error xiaopeitux
2026-02-23  6:36 ` CL Wang
2026-02-23  7:45   ` Pei Xiao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox