Skip to contentSkip to conversation

spi: Few cleanups while looking at num-cs

PATCH In review Krzysztof Kozlowski 3 participants 8 messages Aug 4

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

cover spi: Few cleanups while looking at num-cs

Few minor cleanups for DT bindings and Andes driver.

Patches do not have inter-dependencies.

Best regards,
Krzysztof

---
Krzysztof Kozlowski (5):
spi: dt-bindings: andestech,ae350-spi: Drop redundant num-cs
spi: dt-bindings: marvell,armada-3700-spi: Drop redundant num-cs
spi: dt-bindings: axiado,ax3000-spi: Drop duplicated type/ref
spi: dt-bindings: spi-cadence: Drop duplicated type/ref
spi: atcspi200: Drop redundant andestech,qilai-spi compatible

 Documentation/devicetree/bindings/spi/andestech,ae350-spi.yaml     | 4 ----
 Documentation/devicetree/bindings/spi/axiado,ax3000-spi.yaml       | 1 -
 Documentation/devicetree/bindings/spi/marvell,armada-3700-spi.yaml | 3 ---
 Documentation/devicetree/bindings/spi/spi-cadence.yaml             | 1 -
 drivers/spi/spi-atcspi200.c                                        | 1 -
 5 files changed, 10 deletions(-)

---
base-commit: 415606a7be939835db9b0d6b711887586646346d
change-id: 20260804-spi-num-cs-2a41ca406eb0

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>
#1 lore raw

PATCH 1/5 spi: dt-bindings: andestech,ae350-spi: Drop redundant num-cs

'num-cs' property is a single integer, thus the binding should not set maxItems. This could be replaced with proper min/max constraints for values, except that hardware (as expressed in driver) supports only one native chipselect, thus constraint of "const:1" would make the property implied by the compatible. spi-controller.yaml schema already defines this property, so its presence here is redundant.

---
 Documentation/devicetree/bindings/spi/andestech,ae350-spi.yaml | 4 ----
 1 file changed, 4 deletions(-)
Documentation/devicetree/bindings/spi/andestech,ae350-spi.yaml +0 -4
index 8e441742cee6..381042e07fd0 100644
@@ -24,10 +24,6 @@ properties:
   clocks:
     maxItems: 1
 
-  num-cs:
-    description: Number of chip selects supported
-    maxItems: 1
-
   dmas:
     items:
       - description: Transmit FIFO DMA channel
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/5 spi: dt-bindings: marvell,armada-3700-spi: Drop redundant num-cs

In reply to Krzysztof Kozlowski

'num-cs' property is a single integer, thus the binding should not set maxItems. This could be replaced with proper min/max constraints for values, except that such constraints are not known.

spi-controller.yaml schema already defines this property, so its presence here is redundant.

---
 Documentation/devicetree/bindings/spi/marvell,armada-3700-spi.yaml | 3 ---
 1 file changed, 3 deletions(-)
Documentation/devicetree/bindings/spi/marvell,armada-3700-spi.yaml +0 -3
index 61caa1d86188..75437c46e65a 100644
@@ -28,9 +28,6 @@ properties:
   clocks:
     maxItems: 1
 
-  num-cs:
-    maxItems: 1
-
 required:
   - compatible
   - reg
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/5 spi: dt-bindings: axiado,ax3000-spi: Drop duplicated type/ref

In reply to Krzysztof Kozlowski

spi-controller.yaml schema already defines this $ref for this property, so binding does not have to.

---
 Documentation/devicetree/bindings/spi/axiado,ax3000-spi.yaml | 1 -
 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/spi/axiado,ax3000-spi.yaml +0 -1
index cd2aac66fca2..be258c1f36b1 100644
@@ -37,7 +37,6 @@ properties:
   num-cs:
     description: |
       Number of chip selects used.
-    $ref: /schemas/types.yaml#/definitions/uint32
     minimum: 1
     maximum: 4
     default: 4
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/5 spi: dt-bindings: spi-cadence: Drop duplicated type/ref

In reply to Krzysztof Kozlowski

spi-controller.yaml schema already defines this $ref for this property, so binding does not have to.

---
 Documentation/devicetree/bindings/spi/spi-cadence.yaml | 1 -
 1 file changed, 1 deletion(-)
Documentation/devicetree/bindings/spi/spi-cadence.yaml +0 -1
index 347bed0c4956..429cd824156c 100644
@@ -43,7 +43,6 @@ properties:
       Number of chip selects used. If a decoder is used,
       this will be the number of chip selects after the
       decoder.
-    $ref: /schemas/types.yaml#/definitions/uint32
     minimum: 1
     maximum: 4
     default: 4
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/5 spi: atcspi200: Drop redundant andestech,qilai-spi compatible

In reply to Krzysztof Kozlowski

"andestech,qilai-spi" compatible can only be used with a fallback, which is already matched by the driver's OF device ID table, thus it is redundant in the driver.

---
 drivers/spi/spi-atcspi200.c | 1 -
 1 file changed, 1 deletion(-)
drivers/spi/spi-atcspi200.c +0 -1
index b6ea8e556335..b532c58c0ab9 100644
@@ -638,7 +638,6 @@ static int atcspi_resume(struct device *dev)
 static DEFINE_SIMPLE_DEV_PM_OPS(atcspi_pm_ops, atcspi_suspend, atcspi_resume);
 
 static const struct of_device_id atcspi_of_match[] = {
-	{ .compatible = "andestech,qilai-spi", },
 	{ .compatible = "andestech,ae350-spi", },
 	{ /* sentinel */ }
 };
Signature · 1 line
2.53.0
#6 lore raw

Re: [PATCH 5/5] spi: atcspi200: Drop redundant andestech,qilai-spi compatible

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Direct casting and dereferencing of potentially unaligned buffers to 'unsigned int *' causes undefined behavior and unaligned access faults. --

--- Patch [5]: [PATCH 5/5] spi: atcspi200: Drop redundant andestech,qilai-spi compatible --- commit 0adcd926abd385a3e807d5c95896eac0c48c12aa
Author: Krzysztof Kozlowski <[email protected]>

spi: atcspi200: Drop redundant andestech,qilai-spi compatible

"andestech,qilai-spi" compatible can only be used with a fallback, which is already matched by the driver's OF device ID table, thus it is redundant in the driver.

drivers/spi/spi-atcspi200.c

Quoted 4 lines
drivers/spi/spi-atcspi200.c +0 -0
index b6ea8e5563359..b532c58c0ab91 100644

[ ... ]

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this file I noticed a pre-existing issue that can cause unaligned access faults.

Looking at the transmit path in drivers/spi/spi-atcspi200.c:atcspi_xfer_data_poll():

			if (spi->data_merge)
				val = *(unsigned int *)tx_buf;

And on the receive path in the same function:

			if (spi->data_merge)
				*(unsigned int *)rx_buf = val;

Does this code directly cast and dereference potentially unaligned buffers?

Since spi->data_merge is enabled whenever the transfer size is a multiple of 4, it appears to ignore the memory alignment of the op->data.buf.out and op->data.buf.in input/output buffers.

On architectures that do not support hardware unaligned accesses, such as RISC-V CPUs lacking this feature, could this cause an unaligned access fault and kernel panic?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=5
maintainer
#7 lore raw
In reply to Krzysztof Kozlowski
Quoted 10 lines · Krzysztof Kozlowski

spi: Few cleanups while looking at num-cs

Few minor cleanups for DT bindings and Andes driver.

Patches do not have inter-dependencies.

Best regards,
Krzysztof

[...]

Applied to

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

Thanks!

[1/5] spi: dt-bindings: andestech,ae350-spi: Drop redundant num-cs

      https://git.kernel.org/broonie/spi/c/82024a7ae057
[2/5] spi: dt-bindings: marvell,armada-3700-spi: Drop redundant num-cs
      https://git.kernel.org/broonie/spi/c/9ec27e118da7
[3/5] spi: dt-bindings: axiado,ax3000-spi: Drop duplicated type/ref
      https://git.kernel.org/broonie/spi/c/577ada5875dc
[4/5] spi: dt-bindings: spi-cadence: Drop duplicated type/ref
      https://git.kernel.org/broonie/spi/c/ad0dcba3ab9c
[5/5] spi: atcspi200: Drop redundant andestech,qilai-spi compatible
      https://git.kernel.org/broonie/spi/c/463c840f54f8

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