AW: [PATCH v2] spi: Raise limit on number of chip selects
From: Hohn, Torben
Date: Mon Jul 07 2025 - 03:35:34 EST
Hello Mark,
-Bruker Confidential-
+AD4- On Thu, Jun 26, 2025 at 04:58:20PM +-0000, Hohn, Torben wrote:
+AD4- +AD4- Hello Marc,
+AD4-
+AD4- That isn't my name...
Sorry for that. I was also communicating with Marc Kleine-Budde and got confused.
+AD4-
+AD4- +AD4- +-+ACM-define SPI+AF8-CS+AF8-CNT+AF8-MAX 16
+AD4-
+AD4- +AD4- If this is increased to 24 now, we need to carry another patch on top of mainline again once we add another Chipselect
+AD4- +AD4- into our FPGA, or into the next iteration of our hardware. We would really prefer that a Kconfig value is used.
+AD4- +AD4- We have handed a patch to pengutronix, because they can send proper emails.
+AD4- +AD4- In the IIO framework there is a Konfig Value for something similar:
+AD4- +AD4- https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/iio/trigger.h+ACM-n74
+AD4-
+AD4- This doesn't really work, we're supposed to support single kernel image
+AD4- so putting per platform configuration in Kconfig ends up being at best a
+AD4- usability problem. At some point it's better to just bite the bullet
+AD4- and make things dynamic.
After looking a bit more throughly at the code, i dont think it is necessary to make this dynamic.
The Value at hand is actually the number of Chipselects a Device might have and not the the maximum number
of Chipselects a Controller might have.
However, the check that is failing is this one:
if (ctlr-+AD4-num+AF8-chipselect +AD4- SPI+AF8-CS+AF8-CNT+AF8-MAX) +AHs-
dev+AF8-err(+ACY-ctlr-+AD4-dev, +ACI-No. of CS is more than max. no. of supported CS+AFw-n+ACI-)+ADs-
return -EINVAL+ADs-
+AH0-
I do now believe, that the proper fix is to remove this check, and then reduce SPI+AF8-CS+AF8-CNT+AF8-MAX to 4 again.
Because it was increased to 16 only to satify this condition here. The code however does not depend on ctrl-+AD4-num+AF8-chipselects being smaller
than SPI+AF8-CS+AF8-CNT+AF8-MAX. The only occurence of this in struct spi+AF8-controller is the last+AF8-cs stuff, which just requires array sizes of the maximum
number a device might have.
I guess the define should get a better name that makes this relationship more clear. like SPI+AF8-CS+AF8-CNT+AF8-MAX+AF8-PER+AF8-DEV or something ?
We have discovered the b4 web submit and are now able to post proper patches. Will do that once we have tested this here.
Regards,
Torben