linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup
@ 2020-05-07 11:54 Andy Shevchenko
  2020-05-07 11:54 ` [PATCH v1 2/2] spi: dw: Get rid of dma_inited flag Andy Shevchenko
  2020-05-07 12:43 ` [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-05-07 11:54 UTC (permalink / raw)
  To: Mark Brown, linux-spi, Wan Ahmad Zainie; +Cc: Andy Shevchenko

Generic DMA setup doesn't rely on certain type of DMA controller and thus
shouldn't use Intel Medfield settings, although it's harmless in this case.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-dw-mid.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index f3c85f92ef12c..8b7b94c5a9ccf 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -321,8 +321,6 @@ static const struct dw_spi_dma_ops generic_dma_ops = {
 
 static void dw_spi_mid_setup_dma_generic(struct dw_spi *dws)
 {
-	dws->dma_tx = &mid_dma_tx;
-	dws->dma_rx = &mid_dma_rx;
 	dws->dma_ops = &generic_dma_ops;
 }
 #else	/* CONFIG_SPI_DW_MID_DMA */
-- 
2.26.2


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

* [PATCH v1 2/2] spi: dw: Get rid of dma_inited flag
  2020-05-07 11:54 [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup Andy Shevchenko
@ 2020-05-07 11:54 ` Andy Shevchenko
  2020-05-07 12:43 ` [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-05-07 11:54 UTC (permalink / raw)
  To: Mark Brown, linux-spi, Wan Ahmad Zainie; +Cc: Andy Shevchenko

This flag is superfluous in all cases where it's being used, i.e.
 * ->can_dma() won't be called without dma_inited == 1
 * DMA ->exit() callback can rely on txchan and rxchan variables

So, get rid of dma_inited flag.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/spi/spi-dw-mid.c | 28 ++++++++++++++--------------
 drivers/spi/spi-dw.c     |  2 --
 drivers/spi/spi-dw.h     |  1 -
 3 files changed, 14 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
index 8b7b94c5a9ccf..177e1f5ec62b2 100644
--- a/drivers/spi/spi-dw-mid.c
+++ b/drivers/spi/spi-dw-mid.c
@@ -57,20 +57,21 @@ static int mid_spi_dma_init_mfld(struct device *dev, struct dw_spi *dws)
 	dws->rxchan = dma_request_channel(mask, mid_spi_dma_chan_filter, rx);
 	if (!dws->rxchan)
 		goto err_exit;
-	dws->master->dma_rx = dws->rxchan;
 
 	/* 2. Init tx channel */
 	tx->dma_dev = &dma_dev->dev;
 	dws->txchan = dma_request_channel(mask, mid_spi_dma_chan_filter, tx);
 	if (!dws->txchan)
 		goto free_rxchan;
+
+	dws->master->dma_rx = dws->rxchan;
 	dws->master->dma_tx = dws->txchan;
 
-	dws->dma_inited = 1;
 	return 0;
 
 free_rxchan:
 	dma_release_channel(dws->rxchan);
+	dws->rxchan = NULL;
 err_exit:
 	return -EBUSY;
 }
@@ -80,29 +81,31 @@ static int mid_spi_dma_init_generic(struct device *dev, struct dw_spi *dws)
 	dws->rxchan = dma_request_slave_channel(dev, "rx");
 	if (!dws->rxchan)
 		return -ENODEV;
-	dws->master->dma_rx = dws->rxchan;
 
 	dws->txchan = dma_request_slave_channel(dev, "tx");
 	if (!dws->txchan) {
 		dma_release_channel(dws->rxchan);
+		dws->rxchan = NULL;
 		return -ENODEV;
 	}
+
+	dws->master->dma_rx = dws->rxchan;
 	dws->master->dma_tx = dws->txchan;
 
-	dws->dma_inited = 1;
 	return 0;
 }
 
 static void mid_spi_dma_exit(struct dw_spi *dws)
 {
-	if (!dws->dma_inited)
-		return;
-
-	dmaengine_terminate_sync(dws->txchan);
-	dma_release_channel(dws->txchan);
+	if (dws->txchan) {
+		dmaengine_terminate_sync(dws->txchan);
+		dma_release_channel(dws->txchan);
+	}
 
-	dmaengine_terminate_sync(dws->rxchan);
-	dma_release_channel(dws->rxchan);
+	if (dws->rxchan) {
+		dmaengine_terminate_sync(dws->rxchan);
+		dma_release_channel(dws->rxchan);
+	}
 }
 
 static irqreturn_t dma_transfer(struct dw_spi *dws)
@@ -126,9 +129,6 @@ static bool mid_spi_can_dma(struct spi_controller *master,
 {
 	struct dw_spi *dws = spi_controller_get_devdata(master);
 
-	if (!dws->dma_inited)
-		return false;
-
 	return xfer->len > dws->fifo_len;
 }
 
diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
index b9f651e9ca028..6de196df9c966 100644
--- a/drivers/spi/spi-dw.c
+++ b/drivers/spi/spi-dw.c
@@ -470,7 +470,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 
 	dws->master = master;
 	dws->type = SSI_MOTO_SPI;
-	dws->dma_inited = 0;
 	dws->dma_addr = (dma_addr_t)(dws->paddr + DW_SPI_DR);
 	spin_lock_init(&dws->buf_lock);
 
@@ -509,7 +508,6 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
 		ret = dws->dma_ops->dma_init(dev, dws);
 		if (ret) {
 			dev_warn(dev, "DMA init failed\n");
-			dws->dma_inited = 0;
 		} else {
 			master->can_dma = dws->dma_ops->can_dma;
 		}
diff --git a/drivers/spi/spi-dw.h b/drivers/spi/spi-dw.h
index 490cff260a3eb..e92d43b9a9e60 100644
--- a/drivers/spi/spi-dw.h
+++ b/drivers/spi/spi-dw.h
@@ -141,7 +141,6 @@ struct dw_spi {
 	u32			current_freq;	/* frequency in hz */
 
 	/* DMA info */
-	int			dma_inited;
 	struct dma_chan		*txchan;
 	struct dma_chan		*rxchan;
 	unsigned long		dma_chan_busy;
-- 
2.26.2


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

* Re: [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup
  2020-05-07 11:54 [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup Andy Shevchenko
  2020-05-07 11:54 ` [PATCH v1 2/2] spi: dw: Get rid of dma_inited flag Andy Shevchenko
@ 2020-05-07 12:43 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2020-05-07 12:43 UTC (permalink / raw)
  To: linux-spi, Wan Ahmad Zainie, Andy Shevchenko

On Thu, 7 May 2020 14:54:48 +0300, Andy Shevchenko wrote:
> Generic DMA setup doesn't rely on certain type of DMA controller and thus
> shouldn't use Intel Medfield settings, although it's harmless in this case.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/spi/spi-dw-mid.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> [...]

Applied to

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

Thanks!

[1/2] spi: dw: Avoid useless assignments in generic DMA setup
      commit: 140e45e1e62dd56ed4c264db1443a5d4f5f40352
[2/2] spi: dw: Get rid of dma_inited flag
      commit: a041e672cb57201d152bfc314e52d41e7643375d

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

end of thread, other threads:[~2020-05-07 12:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 11:54 [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup Andy Shevchenko
2020-05-07 11:54 ` [PATCH v1 2/2] spi: dw: Get rid of dma_inited flag Andy Shevchenko
2020-05-07 12:43 ` [PATCH v1 1/2] spi: dw: Avoid useless assignments in generic DMA setup 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).