Skip to contentSkip to conversation

spi: axiado: cond_no_effect and kernel-doc fixes

PATCH In review Babanpreet Singh 4 participants 7 messages Jul 13 – Jul 20

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover spi: axiado: cond_no_effect and kernel-doc fixes

Two small cleanups for the Axiado SPI driver, both defects present since the driver was added in e75a6b00ad79 ("spi: axiado: Add driver for Axiado SPI DB controller").

Patch 1 addresses the coccinelle cond_no_effect warning reported by the kernel test robot on 2026-07-12 [1]: the RX-only/full-duplex else-if arm and the trailing else arm in ax_transfer_one() have identical bodies, so the second condition has no effect. The arms are merged; no functional change (on x86_64/gcc 14, only ax_transfer_one()'s object code changes, dropping the dead condition evaluation).

Patch 2 fixes the kernel-doc comments in the driver: a copy-pasted function name on ax_spi_get_rx_byte_for_irq(), a /** block with no identifier line on ax_spi_process_rx_and_finalize(), and stale/missing member documentation on struct ax_spi. This silences the driver's two W=1 kernel-doc warnings plus five more visible when kernel-doc is run on the header directly.

Both patches are against spi/for-next; they are independent of each other except for touching the same file.

[1] https://lore.kernel.org/r/[email protected]/

Babanpreet Singh (2):
spi: axiado: merge identical if/else branches in ax_transfer_one()
spi: axiado: fix kernel-doc comments

 drivers/spi/spi-axiado.c | 20 ++++++++++----------
 drivers/spi/spi-axiado.h |  5 +++--
 2 files changed, 13 insertions(+), 12 deletions(-)

base-commit: 5f1b513690edf51727e6928b97705b6437f9a98e

Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/2 spi: axiado: merge identical if/else branches in ax_transfer_one()

The else-if arm taken for RX-only and full-duplex transfers and the trailing else arm in the RX bookkeeping setup of ax_transfer_one() have identical bodies, so the second condition has no effect:

drivers/spi/spi-axiado.c:433:8-10: WARNING: possible condition with no effect (if == else)

The trailing else arm (neither TX nor RX buffer) is also unreachable:
the SPI core only calls the ->transfer_one() callback for transfers that carry at least one buffer, see spi_transfer_one_message().

Merge the two arms into a single else branch and fold their comments. No functional change. The redundant condition has been present since the driver was added in commit e75a6b00ad79 ("spi: axiado: Add driver for Axiado SPI DB controller").

---
 drivers/spi/spi-axiado.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/spi/spi-axiado.c +4 -8
index 649f149617ce..c4bc7a50d6c9 100644
@@ -430,15 +430,11 @@ static int ax_transfer_one(struct spi_controller *ctlr,
 		/* TX mode: discard all received data */
 		xspi->rx_discard = transfer->len;
 		xspi->rx_copy_remaining = 0;
-	} else if ((!transfer->tx_buf && transfer->rx_buf) ||
-		   (transfer->tx_buf && transfer->rx_buf)) {
-		/* RX mode: generate clock by filling TX FIFO with dummy bytes
-		 * Full-duplex mode: generate clock by filling TX FIFO
-		 */
-		xspi->rx_discard = 0;
-		xspi->rx_copy_remaining = transfer->len;
 	} else {
-		/* No TX and RX */
+		/* RX-only or full-duplex mode: copy received data, with the
+		 * clock generated by filling the TX FIFO (with dummy bytes
+		 * in RX-only mode)
+		 */
 		xspi->rx_discard = 0;
 		xspi->rx_copy_remaining = transfer->len;
 	}

base-commit: 5f1b513690edf51727e6928b97705b6437f9a98e

Signature · 1 line
2.43.0
maintainer Tested-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] spi: axiado: merge identical if/else branches in ax_transfer_one()

Quoted 4 lines · Babanpreet Singh

Merge the two arms into a single else branch and fold their comments. No functional change. The redundant condition has been present since the driver was added in commit e75a6b00ad79 ("spi: axiado: Add driver for Axiado SPI DB controller").

Hi Babanpreet,

I tested this patch on the Axiado AX3000 platform with SPI NOR read/write operations, and no regressions were observed.

Thanks,
Swark

maintainer Acked-by on v1 1/2
#3 lore raw

Re: [PATCH 1/2] spi: axiado: merge identical if/else branches in ax_transfer_one()

In reply to Babanpreet Singh
Quoted 53 lines · Babanpreet Singh

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

The else-if arm taken for RX-only and full-duplex transfers and the trailing else arm in the RX bookkeeping setup of ax_transfer_one() have identical bodies, so the second condition has no effect:

drivers/spi/spi-axiado.c:433:8-10: WARNING: possible condition with no effect (if == else)

The trailing else arm (neither TX nor RX buffer) is also unreachable:
the SPI core only calls the ->transfer_one() callback for transfers that carry at least one buffer, see spi_transfer_one_message().

Merge the two arms into a single else branch and fold their comments. No functional change. The redundant condition has been present since the driver was added in commit e75a6b00ad79 ("spi: axiado: Add driver for Axiado SPI DB controller").

---
 drivers/spi/spi-axiado.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
drivers/spi/spi-axiado.c +4 -8
index 649f149617ce..c4bc7a50d6c9 100644
@@ -430,15 +430,11 @@ static int ax_transfer_one(struct spi_controller *ctlr,
                /* TX mode: discard all received data */
                xspi->rx_discard = transfer->len;
                xspi->rx_copy_remaining = 0;
-       } else if ((!transfer->tx_buf && transfer->rx_buf) ||
-                  (transfer->tx_buf && transfer->rx_buf)) {
-               /* RX mode: generate clock by filling TX FIFO with dummy bytes
-                * Full-duplex mode: generate clock by filling TX FIFO
-                */
-               xspi->rx_discard = 0;
-               xspi->rx_copy_remaining = transfer->len;
        } else {
-               /* No TX and RX */
+               /* RX-only or full-duplex mode: copy received data, with the
+                * clock generated by filling the TX FIFO (with dummy bytes
+                * in RX-only mode)
+                */
                xspi->rx_discard = 0;
                xspi->rx_copy_remaining = transfer->len;
        }
Quoted 4 lines

base-commit: 5f1b513690edf51727e6928b97705b6437f9a98e --
2.43.0

Hi Babanpreet,

Thanks for your contribution. It looks good to me.

Best regards,
TH

#4 lore raw

PATCH 2/2 spi: axiado: fix kernel-doc comments

In reply to Babanpreet Singh

Running kernel-doc -Wall on the driver reports 7 warnings, all present since the driver was added in commit e75a6b00ad79 ("spi: axiado: Add driver for Axiado SPI DB controller"). Two are in spi-axiado.c and also show up in W=1 builds of drivers/spi:

Warning: drivers/spi/spi-axiado.c:226 expecting prototype for ax_spi_get_rx_byte(). Prototype was for ax_spi_get_rx_byte_for_irq() instead
Warning: drivers/spi/spi-axiado.c:248 This comment starts with '/**', but isn't a kernel-doc comment. Refer to Documentation/doc-guide/kernel-doc.rst

The other five are for struct ax_spi in spi-axiado.h, seen when kernel-doc is invoked on the header directly (headers are not scanned by the build-time kernel-doc checks):

Warning: drivers/spi/spi-axiado.h:130 Excess struct member 'rxbuf' description in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 Excess struct member 'txbuf' description in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 struct member 'clk_rate' not described in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 struct member 'rx_buf' not described in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 struct member 'tx_buf' not described in 'ax_spi'

Fix the three underlying defects:

- The comment on ax_spi_get_rx_byte_for_irq() carries the name of ax_spi_get_rx_byte(), from which it was evidently copied when the IRQ variant was split out; fix the function name.

- The comment on ax_spi_process_rx_and_finalize() is opened with the kernel-doc /** marker but has no identifier line; turn it into proper kernel-doc (identifier line, @ctlr, Return:) since it already describes the behavior and the return value.

- The struct ax_spi comment documents @txbuf and @rxbuf while the members are named tx_buf and rx_buf, and does not document clk_rate; fix the member names and describe clk_rate.

No functional change.

Assisted-by Claude:claude-fable-5 [kernel-doc]
---
 drivers/spi/spi-axiado.c | 8 ++++++--
 drivers/spi/spi-axiado.h | 5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/spi/spi-axiado.c +6 -2
index c4bc7a50d6c9..25561aa9f76f 100644
@@ -213,7 +213,7 @@ static void ax_spi_fill_tx_fifo(struct ax_spi *xspi)
 }
 
 /**
- * ax_spi_get_rx_byte - Gets a byte from the RX FIFO buffer
+ * ax_spi_get_rx_byte_for_irq - Gets a byte from the RX FIFO buffer
  * @xspi: Controller private data (struct ax_spi *)
  *
  * This function handles the logic of extracting bytes from the 32-bit RX FIFO.
@@ -246,9 +246,13 @@ static u8 ax_spi_get_rx_byte_for_irq(struct ax_spi *xspi)
 }
 
 /**
+ * ax_spi_process_rx_and_finalize - Process RX bytes and check for completion
+ * @ctlr:	Pointer to spi_controller structure
+ *
  * Helper function to process received bytes and check for transfer completion.
  * This avoids code duplication and centralizes the completion logic.
- * Returns true if the transfer was finalized.
+ *
+ * Return: true if the transfer was finalized.
  */
 static bool ax_spi_process_rx_and_finalize(struct spi_controller *ctlr)
 {
drivers/spi/spi-axiado.h +3 -2
index 6cf0e5bf5879..d24d31c3a446 100644
@@ -98,9 +98,10 @@
  * @regs:					Virtual address of the SPI controller registers
  * @ref_clk:					Pointer to the peripheral clock
  * @pclk:					Pointer to the APB clock
+ * @clk_rate:					Reference clock rate in Hz
  * @speed_hz:					Current SPI bus clock speed in Hz
- * @txbuf:					Pointer	to the TX buffer
- * @rxbuf:					Pointer to the RX buffer
+ * @tx_buf:					Pointer	to the TX buffer
+ * @rx_buf:					Pointer to the RX buffer
  * @tx_bytes:					Number of bytes left to transfer
  * @rx_bytes:					Number of bytes requested
  * @tx_fifo_depth:				Depth of the TX FIFO
Signature · 1 line
2.43.0
maintainer Acked-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] spi: axiado: fix kernel-doc comments

Quoted 100 lines · Babanpreet Singh

CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.

Running kernel-doc -Wall on the driver reports 7 warnings, all present since the driver was added in commit e75a6b00ad79 ("spi: axiado: Add driver for Axiado SPI DB controller"). Two are in spi-axiado.c and also show up in W=1 builds of drivers/spi:

Warning: drivers/spi/spi-axiado.c:226 expecting prototype for ax_spi_get_rx_byte(). Prototype was for ax_spi_get_rx_byte_for_irq() instead
Warning: drivers/spi/spi-axiado.c:248 This comment starts with '/**', but isn't a kernel-doc comment. Refer to Documentation/doc-guide/kernel-doc.rst

The other five are for struct ax_spi in spi-axiado.h, seen when kernel-doc is invoked on the header directly (headers are not scanned by the build-time kernel-doc checks):

Warning: drivers/spi/spi-axiado.h:130 Excess struct member 'rxbuf' description in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 Excess struct member 'txbuf' description in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 struct member 'clk_rate' not described in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 struct member 'rx_buf' not described in 'ax_spi'
Warning: drivers/spi/spi-axiado.h:130 struct member 'tx_buf' not described in 'ax_spi'

Fix the three underlying defects:

- The comment on ax_spi_get_rx_byte_for_irq() carries the name of ax_spi_get_rx_byte(), from which it was evidently copied when the IRQ variant was split out; fix the function name.

- The comment on ax_spi_process_rx_and_finalize() is opened with the kernel-doc /** marker but has no identifier line; turn it into proper kernel-doc (identifier line, @ctlr, Return:) since it already describes the behavior and the return value.

- The struct ax_spi comment documents @txbuf and @rxbuf while the members are named tx_buf and rx_buf, and does not document clk_rate; fix the member names and describe clk_rate.

No functional change.

Assisted-by Claude:claude-fable-5 [kernel-doc]
---
 drivers/spi/spi-axiado.c | 8 ++++++--
 drivers/spi/spi-axiado.h | 5 +++--
 2 files changed, 9 insertions(+), 4 deletions(-)
drivers/spi/spi-axiado.c +6 -2
index c4bc7a50d6c9..25561aa9f76f 100644
@@ -213,7 +213,7 @@ static void ax_spi_fill_tx_fifo(struct ax_spi *xspi)
 }
 
 /**
- * ax_spi_get_rx_byte - Gets a byte from the RX FIFO buffer
+ * ax_spi_get_rx_byte_for_irq - Gets a byte from the RX FIFO buffer
  * @xspi: Controller private data (struct ax_spi *)
  *
  * This function handles the logic of extracting bytes from the 32-bit RX FIFO.
@@ -246,9 +246,13 @@ static u8 ax_spi_get_rx_byte_for_irq(struct ax_spi *xspi)
 }
 
 /**
+ * ax_spi_process_rx_and_finalize - Process RX bytes and check for completion
+ * @ctlr:      Pointer to spi_controller structure
+ *
  * Helper function to process received bytes and check for transfer completion.
  * This avoids code duplication and centralizes the completion logic.
- * Returns true if the transfer was finalized.
+ *
+ * Return: true if the transfer was finalized.
  */
 static bool ax_spi_process_rx_and_finalize(struct spi_controller *ctlr)
 {
drivers/spi/spi-axiado.h +3 -3
index 6cf0e5bf5879..d24d31c3a446 100644
@@ -98,9 +98,10 @@
  * @regs:                                      Virtual address of the SPI controller registers
  * @ref_clk:                                   Pointer to the peripheral clock
  * @pclk:                                      Pointer to the APB clock
+ * @clk_rate:                                  Reference clock rate in Hz
  * @speed_hz:                                  Current SPI bus clock speed in Hz
- * @txbuf:                                     Pointer to the TX buffer
- * @rxbuf:                                     Pointer to the RX buffer
+ * @tx_buf:                                    Pointer to the TX buffer
+ * @rx_buf:                                    Pointer to the RX buffer
  * @tx_bytes:                                  Number of bytes left to transfer
  * @rx_bytes:                                  Number of bytes requested
  * @tx_fifo_depth:                             Depth of the TX FIFO
--
Quoted 2 lines

2.43.0

Thanks!

maintainer
#6 lore raw
In reply to Babanpreet Singh
Quoted 14 lines · Babanpreet Singh

spi: axiado: cond_no_effect and kernel-doc fixes

Two small cleanups for the Axiado SPI driver, both defects present since the driver was added in e75a6b00ad79 ("spi: axiado: Add driver for Axiado SPI DB controller").

Patch 1 addresses the coccinelle cond_no_effect warning reported by the kernel test robot on 2026-07-12 [1]: the RX-only/full-duplex else-if arm and the trailing else arm in ax_transfer_one() have identical bodies, so the second condition has no effect. The arms are merged; no functional change (on x86_64/gcc 14, only ax_transfer_one()'s object code changes, dropping the dead condition evaluation).

Quoted 1 line

[...]

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-7.3

Thanks!

[1/2] spi: axiado: merge identical if/else branches in ax_transfer_one()

      https://git.kernel.org/broonie/spi/c/fc46551cfa3b
[2/2] spi: axiado: fix kernel-doc comments
      https://git.kernel.org/broonie/spi/c/7720f98d08fd

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark