Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp3504458imm; Thu, 17 May 2018 09:46:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZo4tsEXS8CPNwzih5ILedyJKME3qFbLaw0XAgKVzBttbCsw2jq0KJ4LMC2gg+uN0WZWzIM7 X-Received: by 2002:a17:902:7446:: with SMTP id e6-v6mr5778534plt.369.1526575587400; Thu, 17 May 2018 09:46:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526575587; cv=none; d=google.com; s=arc-20160816; b=uK0qIdkHFtuwak33O1ILGVPgQ0MlLUR4/lto8P9C9DFwwfVPtviEfSiZ/KXYjvDt45 QwmiG5zp9L+kEOv31zAt6FRp43FDqj431M5ptW2zuJE7T6bvqYMi/rw6O5lp/s5l2cZ5 8Cv6S9GrtlMX6LBTWLkrNPkNdvMF/KxyGYGH0WwiuTryPqAtaWrtTIu9VRGzN9lAsgZi D5BGp2PvJM5lVnbmr9d1Y5WddGBfgrArBNUwWiYYFHHbOcYW4+jX7UbIdG4wFbwAyuUi zzrdtZFYUR4kLKehbymKOgygdFtMoAm8oyYzUELEqv56Qj6BK9VAMWF6xyvImGSBAZoR y6Fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=aoF6wgOzVENTV2xURQxIdaTaJtc/xBM6Phj+ientQ+4=; b=gWed1jFE6KYapiUiqI3qwD+3+PCvgh4ZF0PFIKIS5bla+yfb9DFSi0Cr3jmwvM3Fyo zyaXgVIcPczH24UXqcb1O90Os3rqA9wITyt9zBqTPKp+fEk1OF22slw+TmVtwx7RxWtr 8bjAQpDmxTJC6RkwnCRiN1E8cpmq440Wx1cpA0S4nxeMxPopl/klFay9kPT00NV46J5q ZlSLW6rsIzeEz9zrpqqfyEZy+Ppr3zsHSNe9NZVTtTQ791+Y17S2DMDsth9H+3yLFzA6 3LF6YhxiQepj3RyKJNWhmSMYCuwvT/gAoTEO1EyYBvPLEGP2hRQCel26G+/W5gjAOsF3 ao/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=puyo5BTc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z3-v6si5054908pln.292.2018.05.17.09.46.13; Thu, 17 May 2018 09:46:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=puyo5BTc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752289AbeEQQqE (ORCPT + 99 others); Thu, 17 May 2018 12:46:04 -0400 Received: from heliosphere.sirena.org.uk ([172.104.155.198]:59304 "EHLO heliosphere.sirena.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752874AbeEQQpG (ORCPT ); Thu, 17 May 2018 12:45:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=aoF6wgOzVENTV2xURQxIdaTaJtc/xBM6Phj+ientQ+4=; b=puyo5BTc7XE7XSc01czS258Tj hS092h1tW9SrOOuY6da2N3uoZVX77BQ8U9wYP5Koc0PNN767bjOIgyvPh6vvEaSxaxqWjAClLx8/n 1L6PP5a2XV/TtncJM76zc4E4I2bANfqsuzNkXs0lFFj75M/XtAhI5j5Pz2NBJCZoaAsHc=; Received: from [37.205.61.206] (helo=finisterre.ee.mobilebroadband) by heliosphere.sirena.org.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1fJM1O-000165-9q; Thu, 17 May 2018 16:44:54 +0000 Received: by finisterre.ee.mobilebroadband (Postfix, from userid 1000) id 5D76A440089; Thu, 17 May 2018 06:04:06 +0100 (BST) Date: Thu, 17 May 2018 14:04:06 +0900 From: Mark Brown To: Radu Pirea 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 Message-ID: <20180517050406.GF20254@sirena.org.uk> References: <20180511103822.31698-1-radu.pirea@microchip.com> <20180511103822.31698-6-radu.pirea@microchip.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ChQOR20MqfxkMJg9" Content-Disposition: inline In-Reply-To: <20180511103822.31698-6-radu.pirea@microchip.com> X-Cookie: Are you a turtle? User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ChQOR20MqfxkMJg9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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. --ChQOR20MqfxkMJg9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEreZoqmdXGLWf4p/qJNaLcl1Uh9AFAlr9DUUACgkQJNaLcl1U h9AZ8Af/TfudZuJqOMwmfzPzpWNjaK16fM6QqAxtb/t4AgLJi7gFUUFADP73Gxjs 2AMjNTH3hGmf6kHuRu2EcTmkLqg3a2TKXJ/pjJJxVABTwqwJ9X79hT9Sbt9lTRN9 jF2g/jHD21IbEEuC6q5W6m1sxmeJ5h5RKLLVy4D3k/Vtsak0iMN7STU/JoHHHjes bge+7JUXHaJ4/L2p/a2tagPZ2UYtO/QstgEbytrtfVBXoG96KWL9zQ6gs7jNIFqb iEaA/sdu9hEht0UgO3HAeKDj5wVaoo0W3vaFxxWXwc0bmUTjDT89KtjpjTkc+eY3 DAbap8+AlVu9k34DVGRPV1G13go1ZQ== =o0Db -----END PGP SIGNATURE----- --ChQOR20MqfxkMJg9--