Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3484332imu; Sun, 11 Nov 2018 16:09:02 -0800 (PST) X-Google-Smtp-Source: AJdET5eOC5DWxg466dogLihwBE3IkCKpzHGyDDD7oagVO7LzBZ0CyqLU8JZVzZVUbS0utoS1i5vW X-Received: by 2002:a62:a511:: with SMTP id v17-v6mr17896368pfm.18.1541981342561; Sun, 11 Nov 2018 16:09:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541981342; cv=none; d=google.com; s=arc-20160816; b=Az71yPdWaQK9dfH27nj4lwDdlrrfOcBk/854UMY6evjNPbCN6VLh5CvQOeB4gs7ct8 QIbaMR5FqdT9O+s1kLhpWfHY37YDFgEcAhuQI5ji1uVdozt7yOBxxInHTSYwxvVvz/ql 2w/UzhW6trClToHDwAtp00PPJbO3DlXlRGALXM2cZcRNwWLEZDc5x0KGHeBQo/brUmA8 QUU+XWGIYMSmMToE8ox+dXq8UWwY1oWp2c+QJ1AyukUMgGw5CuZBdH7ojySDnoodZc7u 6VRF63PtAY7LxdwPBmkIICwP8o6sBRqFTmKqG8PecP/JHNS4GG2NuRNRl1iAkUJIuoQx r7CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WBFpAyrugDKgQ2FrNTRMBrnpXFkuuKAFlB0UtzzSKx0=; b=qtLXlp9K/CL226vB4gH58zK3xagLlTXgNgy+FfnUxMb0D6pUS1qf26JYRLU3I8snma efzibEdiAufZXXG9o+L9IrMw87YKTWHRqeMRWTc3gXQdWrPQS4jz3Q3tplY2SGvPMsLR yfTdfKpL1RBaYCJozNqo0R5a6sEXi00J3PjQkIb9rU7xoSqgOWEUP8kd6In0SD35ypjE 7AXStcjxXcPDthQDjjIGqg+s7Fwf4VkX+SvI4fNIJPojVzXKCod1kZSKwY5syV/23rcq zDQtCuGzwhnNfycFX3tE89mQYnPK6K53K9zvbKcqkbfcb0NGlulH1CUw5/wzupOdeLU5 uusQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DTV3p2F9; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k5si14385837pgr.69.2018.11.11.16.08.47; Sun, 11 Nov 2018 16:09:02 -0800 (PST) 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=pass header.i=@kernel.org header.s=default header.b=DTV3p2F9; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731747AbeKLIRh (ORCPT + 99 others); Mon, 12 Nov 2018 03:17:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:33718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731159AbeKLIRf (ORCPT ); Mon, 12 Nov 2018 03:17:35 -0500 Received: from localhost (unknown [206.108.79.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 91DC521508; Sun, 11 Nov 2018 22:27:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1541975259; bh=fkzsZlrBTAUbV+JKw0i4H3/z1U1X0cPQiyQ8cyIu4nM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DTV3p2F9r4EoggjW/0PH9aavUgGeBPqfLLjsTHGWm6d2vSkQplbGq+scpEjnqBOZL oOHCT4Vjpk03cosEtMZt8V/chefofSMpnPBr1xsVa631zOghGgmXGcjwkcWebK/RsQ IYqkz1IaztvNoxgFTA5HqtdOWld3DlURoDt95/Nk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andrzej Hajda , Lorenzo Bianconi , Linus Walleij , Mark Brown , Sasha Levin Subject: [PATCH 4.19 106/361] spi: gpio: No MISO does not imply no RX Date: Sun, 11 Nov 2018 14:17:33 -0800 Message-Id: <20181111221634.498436046@linuxfoundation.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181111221619.915519183@linuxfoundation.org> References: <20181111221619.915519183@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Walleij [ Upstream commit abf5feef3ff0cefade0c76be53b59e55fdd46093 ] There is a logical problem in spi-gpio with host just assigning a MOSI line and no MISO: this is interpreted as the host cannot do RX and the host is flagged with SPI_MASTER_NO_RX. This is wrong: since GPIO lines can switch direction, in 3WIRE operation the host will simply reverse the direction of the GPIO line and start reading from it, there is even code for doing this in the driver, but it went unnoticed because it was tested by using a master with 4 wires but a device using just 3 wires. Remove the offending flag. Cc: Andrzej Hajda Cc: Lorenzo Bianconi Signed-off-by: Linus Walleij Signed-off-by: Mark Brown Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-gpio.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c @@ -295,9 +295,11 @@ static int spi_gpio_request(struct devic spi_gpio->miso = devm_gpiod_get_optional(dev, "miso", GPIOD_IN); if (IS_ERR(spi_gpio->miso)) return PTR_ERR(spi_gpio->miso); - if (!spi_gpio->miso) - /* HW configuration without MISO pin */ - *mflags |= SPI_MASTER_NO_RX; + /* + * No setting SPI_MASTER_NO_RX here - if there is only a MOSI + * pin connected the host can still do RX by changing the + * direction of the line. + */ spi_gpio->sck = devm_gpiod_get(dev, "sck", GPIOD_OUT_LOW); if (IS_ERR(spi_gpio->sck)) @@ -423,7 +425,7 @@ static int spi_gpio_probe(struct platfor spi_gpio->bitbang.chipselect = spi_gpio_chipselect; spi_gpio->bitbang.set_line_direction = spi_gpio_set_direction; - if ((master_flags & (SPI_MASTER_NO_TX | SPI_MASTER_NO_RX)) == 0) { + if ((master_flags & SPI_MASTER_NO_TX) == 0) { spi_gpio->bitbang.txrx_word[SPI_MODE_0] = spi_gpio_txrx_word_mode0; spi_gpio->bitbang.txrx_word[SPI_MODE_1] = spi_gpio_txrx_word_mode1; spi_gpio->bitbang.txrx_word[SPI_MODE_2] = spi_gpio_txrx_word_mode2;