linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] spi: pxa2xx: Adapt reset_sccr1() to the case when no message available
@ 2021-07-21 12:15 Andy Shevchenko
  2021-07-22 17:09 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2021-07-21 12:15 UTC (permalink / raw)
  To: Mark Brown, Andy Shevchenko, linux-arm-kernel, linux-spi, linux-kernel
  Cc: Daniel Mack, Haojian Zhuang, Robert Jarzmik, Dan Carpenter

In some cases reset_sccr1() can be called when no message available.
This means that there is no associated chip to receive that message
and hence no threshold needs to be set. Adapt the function to such
cases.

Fixes: 3bbdc083262d ("spi: pxa2xx: Reuse int_stop_and_reset() in couple of places")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-pxa2xx.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index 793cb80f92c7..2b4d633dd9df 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -594,8 +594,15 @@ static int u32_reader(struct driver_data *drv_data)
 
 static void reset_sccr1(struct driver_data *drv_data)
 {
-	struct chip_data *chip = spi_get_ctldata(drv_data->controller->cur_msg->spi);
-	u32 mask = drv_data->int_cr1 | drv_data->dma_cr1;
+	u32 mask = drv_data->int_cr1 | drv_data->dma_cr1, threshold;
+	struct chip_data *chip;
+
+	if (drv_data->controller->cur_msg) {
+		chip = spi_get_ctldata(drv_data->controller->cur_msg->spi);
+		threshold = chip->threshold;
+	} else {
+		threshold = 0;
+	}
 
 	switch (drv_data->ssp_type) {
 	case QUARK_X1000_SSP:
@@ -609,7 +616,7 @@ static void reset_sccr1(struct driver_data *drv_data)
 		break;
 	}
 
-	pxa2xx_spi_update(drv_data, SSCR1, mask, chip->threshold);
+	pxa2xx_spi_update(drv_data, SSCR1, mask, threshold);
 }
 
 static void int_stop_and_reset(struct driver_data *drv_data)
-- 
2.30.2


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

* Re: [PATCH v1 1/1] spi: pxa2xx: Adapt reset_sccr1() to the case when no message available
  2021-07-21 12:15 [PATCH v1 1/1] spi: pxa2xx: Adapt reset_sccr1() to the case when no message available Andy Shevchenko
@ 2021-07-22 17:09 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2021-07-22 17:09 UTC (permalink / raw)
  To: linux-spi, linux-arm-kernel, linux-kernel, Andy Shevchenko
  Cc: Mark Brown, Dan Carpenter, Daniel Mack, Robert Jarzmik, Haojian Zhuang

On Wed, 21 Jul 2021 15:15:20 +0300, Andy Shevchenko wrote:
> In some cases reset_sccr1() can be called when no message available.
> This means that there is no associated chip to receive that message
> and hence no threshold needs to be set. Adapt the function to such
> cases.

Applied to

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

Thanks!

[1/1] spi: pxa2xx: Adapt reset_sccr1() to the case when no message available
      commit: e3aa9acc71778266cc4743217ff1a1a53caf15d6

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] 2+ messages in thread

end of thread, other threads:[~2021-07-22 17:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 12:15 [PATCH v1 1/1] spi: pxa2xx: Adapt reset_sccr1() to the case when no message available Andy Shevchenko
2021-07-22 17:09 ` 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).