Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1673527 > unrolled thread
| Started by | Amelie Delaunay <amelie.delaunay@st.com> |
|---|---|
| First post | 2017-06-23 15:00 +0200 |
| Last post | 2017-06-23 15:00 +0200 |
| Articles | 8 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH 0/8] STM32 SPI various fixes Amelie Delaunay <amelie.delaunay@st.com> - 2017-06-23 15:00 +0200
[PATCH 4/8] spi: stm32: replace st,spi-midi with st,spi-midi-ns to fit bindings Amelie Delaunay <amelie.delaunay@st.com> - 2017-06-23 15:00 +0200
Applied "spi: stm32: replace st, spi-midi with st, spi-midi-ns to fit bindings" to the spi tree Mark Brown <broonie@kernel.org> - 2017-06-28 21:30 +0200
[PATCH 5/8] spi: stm32: use normal conditional statements instead of ternary operator Amelie Delaunay <amelie.delaunay@st.com> - 2017-06-23 15:00 +0200
Applied "spi: stm32: use normal conditional statements instead of ternary operator" to the spi tree Mark Brown <broonie@kernel.org> - 2017-06-28 21:30 +0200
[PATCH 3/8] dt-bindings: spi: stm32: fix example with st,spi-midi-ns property Amelie Delaunay <amelie.delaunay@st.com> - 2017-06-23 15:00 +0200
Re: [PATCH 3/8] dt-bindings: spi: stm32: fix example with st,spi-midi-ns property Rob Herring <robh@kernel.org> - 2017-06-26 21:20 +0200
[PATCH 7/8] spi: stm32: enhance DMA error management Amelie Delaunay <amelie.delaunay@st.com> - 2017-06-23 15:00 +0200
| From | Amelie Delaunay <amelie.delaunay@st.com> |
|---|---|
| Date | 2017-06-23 15:00 +0200 |
| Subject | [PATCH 0/8] STM32 SPI various fixes |
| Message-ID | <tVwlP-2ge-5@gated-at.bofh.it> |
This patchset answers to the reviews done after STM32 SPI driver introduction.
Amelie Delaunay (8):
dt-bindings: spi: stm32: use SoC specific compatible
spi: stm32: fix compatible to fit with new bindings
dt-bindings: spi: stm32: fix example with st,spi-midi-ns property
spi: stm32: replace st,spi-midi with st,spi-midi-ns to fit bindings
spi: stm32: use normal conditional statements instead of ternary
operator
spi: stm32: add runtime PM support
spi: stm32: enhance DMA error management
spi: stm32: fix potential dereference null return value
.../devicetree/bindings/spi/spi-stm32.txt | 6 +-
drivers/spi/spi-stm32.c | 127 +++++++++++++++------
2 files changed, 94 insertions(+), 39 deletions(-)
--
1.9.1
[toc] | [next] | [standalone]
| From | Amelie Delaunay <amelie.delaunay@st.com> |
|---|---|
| Date | 2017-06-23 15:00 +0200 |
| Subject | [PATCH 4/8] spi: stm32: replace st,spi-midi with st,spi-midi-ns to fit bindings |
| Message-ID | <tVwlQ-2ge-17@gated-at.bofh.it> |
| In reply to | #1673527 |
This patch fixes the optional dt property used to set master inter-data idleness. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> --- drivers/spi/spi-stm32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index ca38c24..0997d6d 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -582,7 +582,7 @@ static int stm32_spi_prepare_msg(struct spi_master *master, /* SPI slave device may need time between data frames */ spi->cur_midi = 0; - if (np && !of_property_read_u32(np, "st,spi-midi", &spi->cur_midi)) + if (np && !of_property_read_u32(np, "st,spi-midi-ns", &spi->cur_midi)) dev_dbg(spi->dev, "%dns inter-data idleness\n", spi->cur_midi); if (spi_dev->mode & SPI_CPOL) -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2017-06-28 21:30 +0200 |
| Subject | Applied "spi: stm32: replace st, spi-midi with st, spi-midi-ns to fit bindings" to the spi tree |
| Message-ID | <tXqP2-1wb-65@gated-at.bofh.it> |
| In reply to | #1673528 |
The patch spi: stm32: replace st, spi-midi with st, spi-midi-ns to fit bindings has been applied to the spi tree at git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 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 From 042c1c60df7b85488de28574e7917b7977be3b00 Mon Sep 17 00:00:00 2001 From: Amelie Delaunay <amelie.delaunay@st.com> Date: Tue, 27 Jun 2017 17:45:16 +0200 Subject: [PATCH] spi: stm32: replace st, spi-midi with st, spi-midi-ns to fit bindings This patch fixes the optional dt property used to set master inter-data idleness. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> Signed-off-by: Mark Brown <broonie@kernel.org> --- drivers/spi/spi-stm32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 1eb07bef043e..3df4baa68d63 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -582,7 +582,7 @@ static int stm32_spi_prepare_msg(struct spi_master *master, /* SPI slave device may need time between data frames */ spi->cur_midi = 0; - if (np && !of_property_read_u32(np, "st,spi-midi", &spi->cur_midi)) + if (np && !of_property_read_u32(np, "st,spi-midi-ns", &spi->cur_midi)) dev_dbg(spi->dev, "%dns inter-data idleness\n", spi->cur_midi); if (spi_dev->mode & SPI_CPOL) -- 2.13.2
[toc] | [prev] | [next] | [standalone]
| From | Amelie Delaunay <amelie.delaunay@st.com> |
|---|---|
| Date | 2017-06-23 15:00 +0200 |
| Subject | [PATCH 5/8] spi: stm32: use normal conditional statements instead of ternary operator |
| Message-ID | <tVwlQ-2ge-23@gated-at.bofh.it> |
| In reply to | #1673527 |
This patch replace ternary operator use by normal condition statements
to ease code reading.
It also removes redundant !!.
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
drivers/spi/spi-stm32.c | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 0997d6d..72efc63 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -267,7 +267,10 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
return -EINVAL;
/* Determine the first power of 2 greater than or equal to div */
- mbrdiv = (div & (div - 1)) ? fls(div) : fls(div) - 1;
+ if (div & (div - 1))
+ mbrdiv = fls(div);
+ else
+ mbrdiv = fls(div) - 1;
spi->cur_speed = spi->clk_rate / (1 << mbrdiv);
@@ -285,9 +288,12 @@ static u32 stm32_spi_prepare_fthlv(struct stm32_spi *spi)
/* data packet should not exceed 1/2 of fifo space */
half_fifo = (spi->fifo_size / 2);
- fthlv = (spi->cur_bpw <= 8) ? half_fifo :
- (spi->cur_bpw <= 16) ? (half_fifo / 2) :
- (half_fifo / 4);
+ if (spi->cur_bpw <= 8)
+ fthlv = half_fifo;
+ else if (spi->cur_bpw <= 16)
+ fthlv = half_fifo / 2;
+ else
+ fthlv = half_fifo / 4;
/* align packet size with data registers access */
if (spi->cur_bpw > 8)
@@ -462,9 +468,9 @@ static bool stm32_spi_can_dma(struct spi_master *master,
struct stm32_spi *spi = spi_master_get_devdata(master);
dev_dbg(spi->dev, "%s: %s\n", __func__,
- (!!(transfer->len > spi->fifo_size)) ? "true" : "false");
+ (transfer->len > spi->fifo_size) ? "true" : "false");
- return !!(transfer->len > spi->fifo_size);
+ return (transfer->len > spi->fifo_size);
}
/**
@@ -493,7 +499,8 @@ static irqreturn_t stm32_spi_irq(int irq, void *dev_id)
* Full-Duplex, need to poll RXP event to know if there are remaining
* data, before disabling SPI.
*/
- mask |= ((spi->rx_buf && !spi->cur_usedma) ? SPI_SR_RXP : 0);
+ if (spi->rx_buf && !spi->cur_usedma)
+ mask |= SPI_SR_RXP;
if (!(sr & mask)) {
dev_dbg(spi->dev, "spurious IT (sr=0x%08x, ier=0x%08x)\n",
@@ -656,12 +663,18 @@ static void stm32_spi_dma_config(struct stm32_spi *spi,
enum dma_slave_buswidth buswidth;
u32 maxburst;
- buswidth = (spi->cur_bpw <= 8) ? DMA_SLAVE_BUSWIDTH_1_BYTE :
- (spi->cur_bpw <= 16) ? DMA_SLAVE_BUSWIDTH_2_BYTES :
- DMA_SLAVE_BUSWIDTH_4_BYTES;
+ if (spi->cur_bpw <= 8)
+ buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
+ else if (spi->cur_bpw <= 16)
+ buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
+ else
+ buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
/* Valid for DMA Half or Full Fifo threshold */
- maxburst = (spi->cur_fthlv == 2) ? 1 : spi->cur_fthlv;
+ if (spi->cur_fthlv == 2)
+ maxburst = 1;
+ else
+ maxburst = spi->cur_fthlv;
memset(dma_conf, 0, sizeof(struct dma_slave_config));
dma_conf->direction = dir;
@@ -920,9 +933,12 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
~cfg2_clrb) | cfg2_setb,
spi->base + STM32_SPI_CFG2);
- nb_words = DIV_ROUND_UP(transfer->len * 8,
- (spi->cur_bpw <= 8) ? 8 :
- (spi->cur_bpw <= 16) ? 16 : 32);
+ if (spi->cur_bpw <= 8)
+ nb_words = transfer->len;
+ else if (spi->cur_bpw <= 16)
+ nb_words = DIV_ROUND_UP(transfer->len * 8, 16);
+ else
+ nb_words = DIV_ROUND_UP(transfer->len * 8, 32);
nb_words <<= SPI_CR2_TSIZE_SHIFT;
if (nb_words <= SPI_CR2_TSIZE) {
--
1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Mark Brown <broonie@kernel.org> |
|---|---|
| Date | 2017-06-28 21:30 +0200 |
| Subject | Applied "spi: stm32: use normal conditional statements instead of ternary operator" to the spi tree |
| Message-ID | <tXqP0-1wb-19@gated-at.bofh.it> |
| In reply to | #1673529 |
The patch
spi: stm32: use normal conditional statements instead of ternary operator
has been applied to the spi tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
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
From 128ebb89c50e5452704de82d78845baeb3333c24 Mon Sep 17 00:00:00 2001
From: Amelie Delaunay <amelie.delaunay@st.com>
Date: Tue, 27 Jun 2017 17:45:17 +0200
Subject: [PATCH] spi: stm32: use normal conditional statements instead of
ternary operator
This patch replace ternary operator use by normal condition statements
to ease code reading.
It also removes redundant !!.
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/spi/spi-stm32.c | 44 ++++++++++++++++++++++++++++++--------------
1 file changed, 30 insertions(+), 14 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 3df4baa68d63..123529a1b40d 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -267,7 +267,10 @@ static int stm32_spi_prepare_mbr(struct stm32_spi *spi, u32 speed_hz)
return -EINVAL;
/* Determine the first power of 2 greater than or equal to div */
- mbrdiv = (div & (div - 1)) ? fls(div) : fls(div) - 1;
+ if (div & (div - 1))
+ mbrdiv = fls(div);
+ else
+ mbrdiv = fls(div) - 1;
spi->cur_speed = spi->clk_rate / (1 << mbrdiv);
@@ -285,9 +288,12 @@ static u32 stm32_spi_prepare_fthlv(struct stm32_spi *spi)
/* data packet should not exceed 1/2 of fifo space */
half_fifo = (spi->fifo_size / 2);
- fthlv = (spi->cur_bpw <= 8) ? half_fifo :
- (spi->cur_bpw <= 16) ? (half_fifo / 2) :
- (half_fifo / 4);
+ if (spi->cur_bpw <= 8)
+ fthlv = half_fifo;
+ else if (spi->cur_bpw <= 16)
+ fthlv = half_fifo / 2;
+ else
+ fthlv = half_fifo / 4;
/* align packet size with data registers access */
if (spi->cur_bpw > 8)
@@ -462,9 +468,9 @@ static bool stm32_spi_can_dma(struct spi_master *master,
struct stm32_spi *spi = spi_master_get_devdata(master);
dev_dbg(spi->dev, "%s: %s\n", __func__,
- (!!(transfer->len > spi->fifo_size)) ? "true" : "false");
+ (transfer->len > spi->fifo_size) ? "true" : "false");
- return !!(transfer->len > spi->fifo_size);
+ return (transfer->len > spi->fifo_size);
}
/**
@@ -493,7 +499,8 @@ static irqreturn_t stm32_spi_irq(int irq, void *dev_id)
* Full-Duplex, need to poll RXP event to know if there are remaining
* data, before disabling SPI.
*/
- mask |= ((spi->rx_buf && !spi->cur_usedma) ? SPI_SR_RXP : 0);
+ if (spi->rx_buf && !spi->cur_usedma)
+ mask |= SPI_SR_RXP;
if (!(sr & mask)) {
dev_dbg(spi->dev, "spurious IT (sr=0x%08x, ier=0x%08x)\n",
@@ -656,12 +663,18 @@ static void stm32_spi_dma_config(struct stm32_spi *spi,
enum dma_slave_buswidth buswidth;
u32 maxburst;
- buswidth = (spi->cur_bpw <= 8) ? DMA_SLAVE_BUSWIDTH_1_BYTE :
- (spi->cur_bpw <= 16) ? DMA_SLAVE_BUSWIDTH_2_BYTES :
- DMA_SLAVE_BUSWIDTH_4_BYTES;
+ if (spi->cur_bpw <= 8)
+ buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE;
+ else if (spi->cur_bpw <= 16)
+ buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES;
+ else
+ buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES;
/* Valid for DMA Half or Full Fifo threshold */
- maxburst = (spi->cur_fthlv == 2) ? 1 : spi->cur_fthlv;
+ if (spi->cur_fthlv == 2)
+ maxburst = 1;
+ else
+ maxburst = spi->cur_fthlv;
memset(dma_conf, 0, sizeof(struct dma_slave_config));
dma_conf->direction = dir;
@@ -920,9 +933,12 @@ static int stm32_spi_transfer_one_setup(struct stm32_spi *spi,
~cfg2_clrb) | cfg2_setb,
spi->base + STM32_SPI_CFG2);
- nb_words = DIV_ROUND_UP(transfer->len * 8,
- (spi->cur_bpw <= 8) ? 8 :
- (spi->cur_bpw <= 16) ? 16 : 32);
+ if (spi->cur_bpw <= 8)
+ nb_words = transfer->len;
+ else if (spi->cur_bpw <= 16)
+ nb_words = DIV_ROUND_UP(transfer->len * 8, 16);
+ else
+ nb_words = DIV_ROUND_UP(transfer->len * 8, 32);
nb_words <<= SPI_CR2_TSIZE_SHIFT;
if (nb_words <= SPI_CR2_TSIZE) {
--
2.13.2
[toc] | [prev] | [next] | [standalone]
| From | Amelie Delaunay <amelie.delaunay@st.com> |
|---|---|
| Date | 2017-06-23 15:00 +0200 |
| Subject | [PATCH 3/8] dt-bindings: spi: stm32: fix example with st,spi-midi-ns property |
| Message-ID | <tVwlQ-2ge-25@gated-at.bofh.it> |
| In reply to | #1673527 |
This patch aligns example with the optional property description. Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> --- Documentation/devicetree/bindings/spi/spi-stm32.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/spi/spi-stm32.txt b/Documentation/devicetree/bindings/spi/spi-stm32.txt index 415378b..25d2ed6 100644 --- a/Documentation/devicetree/bindings/spi/spi-stm32.txt +++ b/Documentation/devicetree/bindings/spi/spi-stm32.txt @@ -55,6 +55,6 @@ Example: compatible = "spidev"; reg = <0>; spi-max-frequency = <4000000>; - st,spi-midi = <4000>; + st,spi-midi-ns = <4000>; }; }; -- 1.9.1
[toc] | [prev] | [next] | [standalone]
| From | Rob Herring <robh@kernel.org> |
|---|---|
| Date | 2017-06-26 21:20 +0200 |
| Subject | Re: [PATCH 3/8] dt-bindings: spi: stm32: fix example with st,spi-midi-ns property |
| Message-ID | <tWHIe-6lD-13@gated-at.bofh.it> |
| In reply to | #1673530 |
On Fri, Jun 23, 2017 at 02:55:45PM +0200, Amelie Delaunay wrote: > This patch aligns example with the optional property description. > > Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com> > --- > Documentation/devicetree/bindings/spi/spi-stm32.txt | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/Documentation/devicetree/bindings/spi/spi-stm32.txt b/Documentation/devicetree/bindings/spi/spi-stm32.txt > index 415378b..25d2ed6 100644 > --- a/Documentation/devicetree/bindings/spi/spi-stm32.txt > +++ b/Documentation/devicetree/bindings/spi/spi-stm32.txt > @@ -55,6 +55,6 @@ Example: > compatible = "spidev"; As I mentioned in the original patch, please use a real compatible. > reg = <0>; > spi-max-frequency = <4000000>; > - st,spi-midi = <4000>; > + st,spi-midi-ns = <4000>; > }; > }; > -- > 1.9.1 >
[toc] | [prev] | [next] | [standalone]
| From | Amelie Delaunay <amelie.delaunay@st.com> |
|---|---|
| Date | 2017-06-23 15:00 +0200 |
| Subject | [PATCH 7/8] spi: stm32: enhance DMA error management |
| Message-ID | <tVwlQ-2ge-27@gated-at.bofh.it> |
| In reply to | #1673527 |
This patch reworks DMA error management. In case the DMA callback is
called while EOT (End Of Transfer) flag is not set, that means that DMA
encountered an error. This error will result in an auto-suspend of SPI
flow, which could also result in an overrun. So, in DMA mode, SUSP and
OVR flags are a condition to stop the current transfer.
Signed-off-by: Amelie Delaunay <amelie.delaunay@st.com>
---
drivers/spi/spi-stm32.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c
index 209afda..63af9d9 100644
--- a/drivers/spi/spi-stm32.c
+++ b/drivers/spi/spi-stm32.c
@@ -514,6 +514,12 @@ static irqreturn_t stm32_spi_irq(int irq, void *dev_id)
dev_warn(spi->dev, "Communication suspended\n");
if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
stm32_spi_read_rxfifo(spi, false);
+ /*
+ * If communication is suspended while using DMA, it means
+ * that something went wrong, so stop the current transfer
+ */
+ if (spi->cur_usedma)
+ end = true;
}
if (sr & SPI_SR_MODF) {
@@ -525,6 +531,12 @@ static irqreturn_t stm32_spi_irq(int irq, void *dev_id)
dev_warn(spi->dev, "Overrun: received value discarded\n");
if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0)))
stm32_spi_read_rxfifo(spi, false);
+ /*
+ * If overrun is detected while using DMA, it means that
+ * something went wrong, so stop the current transfer
+ */
+ if (spi->cur_usedma)
+ end = true;
}
if (sr & SPI_SR_EOT) {
@@ -645,12 +657,10 @@ static void stm32_spi_dma_cb(void *data)
spin_unlock_irqrestore(&spi->lock, flags);
- if (!(sr & SPI_SR_EOT)) {
- dev_warn(spi->dev, "DMA callback (sr=0x%08x)\n", sr);
+ if (!(sr & SPI_SR_EOT))
+ dev_warn(spi->dev, "DMA error (sr=0x%08x)\n", sr);
- spi_finalize_current_transfer(spi->master);
- stm32_spi_disable(spi);
- }
+ /* Now wait for EOT, or SUSP or OVR in case of error */
}
/**
--
1.9.1
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web