linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/3] spi: Minor smatch fixes
@ 2025-05-01 15:01 Krzysztof Kozlowski
  2025-05-01 15:01 ` [PATCH v2 1/3] spi: atmel-quadspi: Fix printed error code during DMA setup Krzysztof Kozlowski
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-01 15:01 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	David Rhodes, Richard Fitzgerald
  Cc: linux-spi, linux-arm-kernel, linux-kernel, linux-sound, patches,
	Krzysztof Kozlowski

Just few fixes.

Changes in v2:
1. IS_ERR_OR_NULL->IS_ERR in cs42l43
2. Drop patch which was already fixed in the meantime by other person

v1: https://lore.kernel.org/all/20250104205437.184782-1-krzysztof.kozlowski@linaro.org/

Best regards,
Krzysztof

---
Krzysztof Kozlowski (3):
      spi: atmel-quadspi: Fix printed error code during DMA setup
      spi: cs42l43: Make handling missing spk-id GPIOs explicit
      spi: cadence-quadspi: Assume device could match via platform

 drivers/spi/atmel-quadspi.c       | 9 +++++----
 drivers/spi/spi-cadence-quadspi.c | 2 +-
 drivers/spi/spi-cs42l43.c         | 4 +++-
 3 files changed, 9 insertions(+), 6 deletions(-)
---
base-commit: 6b7e080d43429e85b40355986026eb69ef775df9
change-id: 20250501-n-smatch-fixes-2e9e6d8fd3e3

Best regards,
-- 
Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>



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

* [PATCH v2 1/3] spi: atmel-quadspi: Fix printed error code during DMA setup
  2025-05-01 15:01 [PATCH v2 0/3] spi: Minor smatch fixes Krzysztof Kozlowski
@ 2025-05-01 15:01 ` Krzysztof Kozlowski
  2025-05-01 15:02 ` [PATCH v2 2/3] spi: cs42l43: Make handling missing spk-id GPIOs explicit Krzysztof Kozlowski
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-01 15:01 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	David Rhodes, Richard Fitzgerald
  Cc: linux-spi, linux-arm-kernel, linux-kernel, linux-sound, patches,
	Krzysztof Kozlowski

On dma_request_chan() failure driver NULL-ifies the 'rx_chan' and
immediately uses it as PTR_ERR() so dev_err_probe() prints incorrect
error code.  Rework the code so proper error code will be printed and
NULL-ifying of 'rx_chan' will happen in common error handling block
(failure of DMA setup is not fatal for the driver and further code
depends on 'rx_chan' being non-NULL for DMA operations).

Reported by Smatch:
  drivers/spi/atmel-quadspi.c:1287 atmel_qspi_dma_init() warn: passing zero to 'PTR_ERR'

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/spi/atmel-quadspi.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/atmel-quadspi.c b/drivers/spi/atmel-quadspi.c
index 244ac010686298c58427fadc0ebfff5e62d18880..fc36751763887cc14bc71e2f398a25e56e9c5e42 100644
--- a/drivers/spi/atmel-quadspi.c
+++ b/drivers/spi/atmel-quadspi.c
@@ -1287,9 +1287,9 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl)
 
 	aq->rx_chan = dma_request_chan(&aq->pdev->dev, "rx");
 	if (IS_ERR(aq->rx_chan)) {
-		aq->rx_chan = NULL;
-		return dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->rx_chan),
-				     "RX DMA channel is not available\n");
+		ret = dev_err_probe(&aq->pdev->dev, PTR_ERR(aq->rx_chan),
+				    "RX DMA channel is not available\n");
+		goto null_rx_chan;
 	}
 
 	aq->tx_chan = dma_request_chan(&aq->pdev->dev, "tx");
@@ -1310,8 +1310,9 @@ static int atmel_qspi_dma_init(struct spi_controller *ctrl)
 
 release_rx_chan:
 	dma_release_channel(aq->rx_chan);
-	aq->rx_chan = NULL;
 	aq->tx_chan = NULL;
+null_rx_chan:
+	aq->rx_chan = NULL;
 	return ret;
 }
 

-- 
2.45.2



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

* [PATCH v2 2/3] spi: cs42l43: Make handling missing spk-id GPIOs explicit
  2025-05-01 15:01 [PATCH v2 0/3] spi: Minor smatch fixes Krzysztof Kozlowski
  2025-05-01 15:01 ` [PATCH v2 1/3] spi: atmel-quadspi: Fix printed error code during DMA setup Krzysztof Kozlowski
@ 2025-05-01 15:02 ` Krzysztof Kozlowski
  2025-05-01 15:33   ` Charles Keepax
  2025-05-01 15:02 ` [PATCH v2 3/3] spi: cadence-quadspi: Assume device could match via platform Krzysztof Kozlowski
  2025-05-05 23:46 ` [PATCH v2 0/3] spi: Minor smatch fixes Mark Brown
  3 siblings, 1 reply; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-01 15:02 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	David Rhodes, Richard Fitzgerald
  Cc: linux-spi, linux-arm-kernel, linux-kernel, linux-sound, patches,
	Krzysztof Kozlowski

gpiod_get_array_optional() for spk-id GPIOs can return NULL, if they are
missing, so do not pass the value to PTR_ERR but instead explicitly
treat NULL as acceptable condition.  The old code was correct, but
misleading because PTR_ERR usually is used on errors.

Reported by Smatch:
  drivers/spi/spi-cs42l43.c:241 cs42l43_get_speaker_id_gpios() warn: passing zero to 'PTR_ERR'

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/spi/spi-cs42l43.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cs42l43.c b/drivers/spi/spi-cs42l43.c
index ceefc253c54904b51a12ff112988d1dfbeed39c1..b28a840b3b04b5a4cce15539188bca02bf36716a 100644
--- a/drivers/spi/spi-cs42l43.c
+++ b/drivers/spi/spi-cs42l43.c
@@ -237,7 +237,9 @@ static int cs42l43_get_speaker_id_gpios(struct cs42l43_spi *priv, int *result)
 	int i, ret;
 
 	descs = gpiod_get_array_optional(priv->dev, "spk-id", GPIOD_IN);
-	if (IS_ERR_OR_NULL(descs))
+	if (!descs)
+		return 0;
+	else if (IS_ERR(descs))
 		return PTR_ERR(descs);
 
 	spkid = 0;

-- 
2.45.2



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

* [PATCH v2 3/3] spi: cadence-quadspi: Assume device could match via platform
  2025-05-01 15:01 [PATCH v2 0/3] spi: Minor smatch fixes Krzysztof Kozlowski
  2025-05-01 15:01 ` [PATCH v2 1/3] spi: atmel-quadspi: Fix printed error code during DMA setup Krzysztof Kozlowski
  2025-05-01 15:02 ` [PATCH v2 2/3] spi: cs42l43: Make handling missing spk-id GPIOs explicit Krzysztof Kozlowski
@ 2025-05-01 15:02 ` Krzysztof Kozlowski
  2025-05-05 23:46 ` [PATCH v2 0/3] spi: Minor smatch fixes Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Kozlowski @ 2025-05-01 15:02 UTC (permalink / raw)
  To: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	David Rhodes, Richard Fitzgerald
  Cc: linux-spi, linux-arm-kernel, linux-kernel, linux-sound, patches,
	Krzysztof Kozlowski

Driver has only of_device_id table, however it also has MODULE_ALIAS()
for platform name, thus assume there is a configuration where this can
be loaded outside of OF system.  In such case of_device_get_match_data()
will return NULL, which is already checked in one place of probe()
function but not in the other, leading to Smatch warning:

  drivers/spi/spi-cadence-quadspi.c:1942 cqspi_probe() error: we previously assumed 'ddata' could be null (see line 1885)

Driver should be consistent, so assume device can be matched via
platform bus and of_device_get_match_data() can indeed return NULL.
This is also possible with malformed DTS on OF-platform: no unit address
and device node name matching driver name.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
 drivers/spi/spi-cadence-quadspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index c90462783b3f9f05e477d337ab4187224992c0a0..fe0f122f07b0206e80cf89bd031106bf8051c789 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1949,7 +1949,7 @@ static int cqspi_probe(struct platform_device *pdev)
 
 	host->num_chipselect = cqspi->num_chipselect;
 
-	if (ddata->quirks & CQSPI_SUPPORT_DEVICE_RESET)
+	if (ddata && (ddata->quirks & CQSPI_SUPPORT_DEVICE_RESET))
 		cqspi_device_reset(cqspi);
 
 	if (cqspi->use_direct_mode) {

-- 
2.45.2



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

* Re: [PATCH v2 2/3] spi: cs42l43: Make handling missing spk-id GPIOs explicit
  2025-05-01 15:02 ` [PATCH v2 2/3] spi: cs42l43: Make handling missing spk-id GPIOs explicit Krzysztof Kozlowski
@ 2025-05-01 15:33   ` Charles Keepax
  0 siblings, 0 replies; 6+ messages in thread
From: Charles Keepax @ 2025-05-01 15:33 UTC (permalink / raw)
  To: Krzysztof Kozlowski
  Cc: Mark Brown, Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
	David Rhodes, Richard Fitzgerald, linux-spi, linux-arm-kernel,
	linux-kernel, linux-sound, patches

On Thu, May 01, 2025 at 05:02:00PM +0200, Krzysztof Kozlowski wrote:
> gpiod_get_array_optional() for spk-id GPIOs can return NULL, if they are
> missing, so do not pass the value to PTR_ERR but instead explicitly
> treat NULL as acceptable condition.  The old code was correct, but
> misleading because PTR_ERR usually is used on errors.
> 
> Reported by Smatch:
>   drivers/spi/spi-cs42l43.c:241 cs42l43_get_speaker_id_gpios() warn: passing zero to 'PTR_ERR'
> 
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---

Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>

Thanks,
Charles


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

* Re: [PATCH v2 0/3] spi: Minor smatch fixes
  2025-05-01 15:01 [PATCH v2 0/3] spi: Minor smatch fixes Krzysztof Kozlowski
                   ` (2 preceding siblings ...)
  2025-05-01 15:02 ` [PATCH v2 3/3] spi: cadence-quadspi: Assume device could match via platform Krzysztof Kozlowski
@ 2025-05-05 23:46 ` Mark Brown
  3 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2025-05-05 23:46 UTC (permalink / raw)
  To: Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, David Rhodes,
	Richard Fitzgerald, Krzysztof Kozlowski
  Cc: linux-spi, linux-arm-kernel, linux-kernel, linux-sound, patches

On Thu, 01 May 2025 17:01:58 +0200, Krzysztof Kozlowski wrote:
> Just few fixes.
> 
> Changes in v2:
> 1. IS_ERR_OR_NULL->IS_ERR in cs42l43
> 2. Drop patch which was already fixed in the meantime by other person
> 
> v1: https://lore.kernel.org/all/20250104205437.184782-1-krzysztof.kozlowski@linaro.org/
> 
> [...]

Applied to

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

Thanks!

[1/3] spi: atmel-quadspi: Fix printed error code during DMA setup
      commit: 075812e45e9ef1b882aa66b9d122d8b8739aae59
[2/3] spi: cs42l43: Make handling missing spk-id GPIOs explicit
      commit: f4ea37a485e97234af9550b63c52394d029037ee
[3/3] spi: cadence-quadspi: Assume device could match via platform
      commit: 222a87f6b94f6f177e896d6fcdc7881480344e34

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



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

end of thread, other threads:[~2025-05-06  5:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 15:01 [PATCH v2 0/3] spi: Minor smatch fixes Krzysztof Kozlowski
2025-05-01 15:01 ` [PATCH v2 1/3] spi: atmel-quadspi: Fix printed error code during DMA setup Krzysztof Kozlowski
2025-05-01 15:02 ` [PATCH v2 2/3] spi: cs42l43: Make handling missing spk-id GPIOs explicit Krzysztof Kozlowski
2025-05-01 15:33   ` Charles Keepax
2025-05-01 15:02 ` [PATCH v2 3/3] spi: cadence-quadspi: Assume device could match via platform Krzysztof Kozlowski
2025-05-05 23:46 ` [PATCH v2 0/3] spi: Minor smatch fixes Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).