Re: [PATCH] spi: atcspi200: validate data buswidth to fix FIELD_PREP build error

From: CL Wang

Date: Mon Feb 23 2026 - 01:37:11 EST


Hi Pei,

Thanks for the patch to address the GCC compiler warning.

While I understand that the SPI framework theoretically guarantees
op->data.buswidth won't produce an out-of-bounds value here, I have
some concerns regarding the proposed error handling.

Using a direct return; inside atcspi_set_trans_ctl() creates a silent failure.
Since the function returns void, the callers (atcspi_prepare_trans and
atcspi_exec_mem_op) remain completely unaware of the error. They will blindly
proceed with the transfer, leaving the hardware in an unconfigured or unknown
state. Additionally, using a forced bitwise truncation could also lead to
uncontrollable hardware behavior.

A safer approach would be to either modify the function signatures to propagate
the error (e.g., returning -EINVAL), or at least fall back to a safe default
(like forcing width_code = 0 for standard 1-bit mode) along with
a WARN_ON_ONCE().

Since this requires a bit more structural adjustment in the driver, would you
mind if I take this over and submit a proper fix? I will make sure to add a
Suggested-by tag to acknowledge your effort in bringing this up.

Thanks again for catching this!

Best regards,
CL
>