From: Mark Brown <broonie@kernel.org> To: Radu Pirea <radu.pirea@microchip.com> Cc: devicetree@vger.kernel.org, linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org, mark.rutland@arm.com, robh+dt@kernel.org, lee.jones@linaro.org, gregkh@linuxfoundation.org, jslaby@suse.com, richard.genoud@gmail.com, alexandre.belloni@bootlin.com, nicolas.ferre@microchip.com Subject: Re: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi Date: Thu, 17 May 2018 14:04:06 +0900 [thread overview] Message-ID: <20180517050406.GF20254@sirena.org.uk> (raw) In-Reply-To: <20180511103822.31698-6-radu.pirea@microchip.com> [-- Attachment #1: Type: text/plain, Size: 1903 bytes --] On Fri, May 11, 2018 at 01:38:21PM +0300, Radu Pirea wrote: > +config SPI_AT91_USART > + tristate "Atmel USART Controller as SPI" > + depends on HAS_DMA > + depends on (ARCH_AT91 || COMPILE_TEST) > + select MFD_AT91_USART > + help > + This selects a driver for the AT91 USART Controller as SPI Master, > + present on AT91 and SAMA5 SoC series. > + This looks like there's some tab/space mixing going on here. > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Driver for AT91 USART Controllers as SPI > + * > + * Copyright (C) 2018 Microchip Technology Inc. Make the entire block a C++ comment so it looks more intentional rather tha mixing C and C++. > +static inline void at91_usart_spi_tx(struct at91_usart_spi *aus) > +{ > + unsigned int len = aus->current_transfer->len; > + unsigned int remaining = aus->current_tx_remaining_bytes; > + const u8 *tx_buf = aus->current_transfer->tx_buf; > + > + if (tx_buf && remaining) { > + if (at91_usart_spi_tx_ready(aus)) > + spi_writel(aus, THR, tx_buf[len - remaining]); > + aus->current_tx_remaining_bytes--; Missing braces here - we only write to the FIFO if there's space but we unconditionally decrement the counter. > + } else { > + if (at91_usart_spi_tx_ready(aus)) > + spi_writel(aus, THR, US_DUMMY_TX); > + } > +} This looks like you're open coding SPI_CONTROLLER_MUST_TX > + int len = aus->current_transfer->len; > + int remaining = aus->current_rx_remaining_bytes; > + u8 *rx_buf = aus->current_transfer->rx_buf; > + > + if (aus->current_rx_remaining_bytes) { > + rx_buf[len - remaining] = spi_readb(aus, RHR); > + aus->current_rx_remaining_bytes--; > + } else { > + spi_readb(aus, RHR); > + } Similarly for _MUST_RX. > + controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; You're actually setting both flags... this means that the handling for cases with missing TX or RX buffers can't happen. [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 488 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: broonie@kernel.org (Mark Brown) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi Date: Thu, 17 May 2018 14:04:06 +0900 [thread overview] Message-ID: <20180517050406.GF20254@sirena.org.uk> (raw) In-Reply-To: <20180511103822.31698-6-radu.pirea@microchip.com> On Fri, May 11, 2018 at 01:38:21PM +0300, Radu Pirea wrote: > +config SPI_AT91_USART > + tristate "Atmel USART Controller as SPI" > + depends on HAS_DMA > + depends on (ARCH_AT91 || COMPILE_TEST) > + select MFD_AT91_USART > + help > + This selects a driver for the AT91 USART Controller as SPI Master, > + present on AT91 and SAMA5 SoC series. > + This looks like there's some tab/space mixing going on here. > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Driver for AT91 USART Controllers as SPI > + * > + * Copyright (C) 2018 Microchip Technology Inc. Make the entire block a C++ comment so it looks more intentional rather tha mixing C and C++. > +static inline void at91_usart_spi_tx(struct at91_usart_spi *aus) > +{ > + unsigned int len = aus->current_transfer->len; > + unsigned int remaining = aus->current_tx_remaining_bytes; > + const u8 *tx_buf = aus->current_transfer->tx_buf; > + > + if (tx_buf && remaining) { > + if (at91_usart_spi_tx_ready(aus)) > + spi_writel(aus, THR, tx_buf[len - remaining]); > + aus->current_tx_remaining_bytes--; Missing braces here - we only write to the FIFO if there's space but we unconditionally decrement the counter. > + } else { > + if (at91_usart_spi_tx_ready(aus)) > + spi_writel(aus, THR, US_DUMMY_TX); > + } > +} This looks like you're open coding SPI_CONTROLLER_MUST_TX > + int len = aus->current_transfer->len; > + int remaining = aus->current_rx_remaining_bytes; > + u8 *rx_buf = aus->current_transfer->rx_buf; > + > + if (aus->current_rx_remaining_bytes) { > + rx_buf[len - remaining] = spi_readb(aus, RHR); > + aus->current_rx_remaining_bytes--; > + } else { > + spi_readb(aus, RHR); > + } Similarly for _MUST_RX. > + controller->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX; You're actually setting both flags... this means that the handling for cases with missing TX or RX buffers can't happen. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20180517/75f75572/attachment-0001.sig>
next prev parent reply other threads:[~2018-05-17 16:46 UTC|newest] Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-05-11 10:38 [PATCH v3 0/6] Driver for at91 usart in spi mode Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` [PATCH v3 1/6] MAINTAINERS: add at91 usart mfd driver Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` [PATCH v3 2/6] mfd: at91-usart: added mfd driver for usart Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-18 22:19 ` Rob Herring 2018-05-18 22:19 ` Rob Herring 2018-05-19 7:08 ` Alexandre Belloni 2018-05-19 7:08 ` Alexandre Belloni 2018-05-11 10:38 ` [PATCH v3 3/6] MAINTAINERS: add at91 usart spi driver Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-13 13:14 ` Andy Shevchenko 2018-05-13 13:14 ` Andy Shevchenko 2018-05-11 10:38 ` [PATCH v3 4/6] dt-bindings: add binding for at91-usart in spi mode Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-18 21:40 ` Rob Herring 2018-05-18 21:40 ` Rob Herring 2018-05-11 10:38 ` [PATCH v3 5/6] spi: at91-usart: add driver for at91-usart as spi Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-13 13:33 ` Andy Shevchenko 2018-05-13 13:33 ` Andy Shevchenko 2018-05-13 13:35 ` Andy Shevchenko 2018-05-13 13:35 ` Andy Shevchenko [not found] ` <5a3930b867cf8c279953d08c5d5dd1d93113a43b.camel@microchip.com> 2018-05-14 17:38 ` Andy Shevchenko 2018-05-14 17:38 ` Andy Shevchenko 2018-05-15 9:22 ` Radu Pirea 2018-05-15 9:22 ` Radu Pirea 2018-05-15 9:22 ` Radu Pirea 2018-05-17 4:54 ` Mark Brown 2018-05-17 4:54 ` Mark Brown 2018-05-24 16:04 ` Radu Pirea 2018-05-24 16:04 ` Radu Pirea 2018-05-24 16:04 ` Radu Pirea 2018-05-24 17:56 ` Alexandre Belloni 2018-05-24 17:56 ` Alexandre Belloni 2018-05-24 18:16 ` Mark Brown 2018-05-24 18:16 ` Mark Brown 2018-05-24 18:15 ` Mark Brown 2018-05-24 18:15 ` Mark Brown 2018-05-15 9:25 ` Radu Pirea 2018-05-15 9:25 ` Radu Pirea 2018-05-15 9:25 ` Radu Pirea 2018-05-17 5:04 ` Mark Brown [this message] 2018-05-17 5:04 ` Mark Brown 2018-05-23 8:10 ` Radu Pirea 2018-05-23 8:10 ` Radu Pirea 2018-05-23 8:10 ` Radu Pirea 2018-05-23 8:30 ` Mark Brown 2018-05-23 8:30 ` Mark Brown 2018-05-11 10:38 ` [PATCH v3 6/6] tty/serial: atmel: changed the driver to work under at91-usart mfd Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-11 10:38 ` Radu Pirea 2018-05-14 10:57 ` Richard Genoud 2018-05-14 10:57 ` Richard Genoud 2018-05-14 10:57 ` Richard Genoud 2018-05-14 16:56 ` Andy Shevchenko 2018-05-14 16:56 ` Andy Shevchenko 2018-05-15 6:28 ` Richard Genoud 2018-05-15 6:28 ` Richard Genoud 2018-05-15 12:47 ` Radu Pirea 2018-05-15 12:47 ` Radu Pirea 2018-05-15 12:47 ` Radu Pirea 2018-05-15 13:14 ` Richard Genoud 2018-05-15 13:14 ` Richard Genoud 2018-05-25 12:17 ` Radu Pirea 2018-05-25 12:17 ` Radu Pirea 2018-05-25 12:17 ` Radu Pirea 2018-05-25 13:35 ` Richard Genoud 2018-05-25 13:35 ` Richard Genoud 2018-05-25 14:07 ` Radu Pirea 2018-05-25 14:07 ` Radu Pirea 2018-05-25 14:07 ` Radu Pirea
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20180517050406.GF20254@sirena.org.uk \ --to=broonie@kernel.org \ --cc=alexandre.belloni@bootlin.com \ --cc=devicetree@vger.kernel.org \ --cc=gregkh@linuxfoundation.org \ --cc=jslaby@suse.com \ --cc=lee.jones@linaro.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-serial@vger.kernel.org \ --cc=linux-spi@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=nicolas.ferre@microchip.com \ --cc=radu.pirea@microchip.com \ --cc=richard.genoud@gmail.com \ --cc=robh+dt@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.