From patchwork Fri Jun 17 07:57:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andi Shyti X-Patchwork-Id: 9182917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A35486075F for ; Fri, 17 Jun 2016 07:57:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 92FB728308 for ; Fri, 17 Jun 2016 07:57:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 866162839C; Fri, 17 Jun 2016 07:57:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F392028308 for ; Fri, 17 Jun 2016 07:57:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754450AbcFQH5c (ORCPT ); Fri, 17 Jun 2016 03:57:32 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:55380 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752303AbcFQH5b (ORCPT ); Fri, 17 Jun 2016 03:57:31 -0400 Received: from epcpsbgr4.samsung.com (u144.gpu120.samsung.co.kr [203.254.230.144]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0O8W02OUBORT4000@mailout3.samsung.com>; Fri, 17 Jun 2016 16:57:29 +0900 (KST) Received: from epcpsbgm1new.samsung.com ( [172.20.52.115]) by epcpsbgr4.samsung.com (EPCPMTA) with SMTP id E2.22.04903.96DA3675; Fri, 17 Jun 2016 16:57:29 +0900 (KST) X-AuditID: cbfee690-f79056d000001327-ec-5763ad69e026 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 57.FD.06657.96DA3675; Fri, 17 Jun 2016 16:57:29 +0900 (KST) Received: from samsunx.samsung ([10.113.63.54]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0O8W00H9UORQH320@mmp2.samsung.com>; Fri, 17 Jun 2016 16:57:28 +0900 (KST) From: Andi Shyti To: Mark Brown Cc: Kukjin Kim , Krzysztof Kozlowski , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Andi Shyti , Andi Shyti Subject: [PATCH 1/5] spi: do not fail if the CS line is not connected Date: Fri, 17 Jun 2016 16:57:21 +0900 Message-id: <1466150245-2648-2-git-send-email-andi.shyti@samsung.com> X-Mailer: git-send-email 2.8.1 In-reply-to: <1466150245-2648-1-git-send-email-andi.shyti@samsung.com> References: <1466150245-2648-1-git-send-email-andi.shyti@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPLMWRmVeSWpSXmKPExsWyRsSkWDdzbXK4wbmlYhbbjzxjtVj84zmT xdSHT9gsXr8wtOh//JrZYtPja6wWl3fNYbNo/HiT3YHD4/qST8wem1Z1snlsXlLv0bdlFaPH 501yAaxRXDYpqTmZZalF+nYJXBkHOh6xFRzjqWh9sIG9gXECVxcjJ4eEgIlE+7KL7BC2mMSF e+vZuhi5OIQEVjBKnGqcwQJT9P/NbhaIxCxGidMdd6Ccj4wSV5atAatiE9CUaLr9gw3EFhFQ lrj6fS9YEbPAT0aJq3dawYqEBVwl7rZMZwWxWQRUJVbfmMwEYvMCxR8ufsQIsU5O4vL0B2CD OAXcJBZe+QwU5wDa5ipx8aUmyEwJgUXsEsd2QNzNIiAg8W3yI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Ts1 tSC1CKaPiYNTqoGx6r2HxHapx6dbu6Imvdfadngz+/L5e/N5f/Dm1t3/FS6i+okvUqPqhslk GbUWnvv8Ef+WbEs8p8x7bd5Nph2OdlplC0MFFjLc9bUuFH/RZ2FnYSMu0WKUM9tuycJCB4u9 N41rOTluGb2UMoozvfP3Hn/ogdl5bLou1rzxK32+l/fcfqk0oV2JpTgj0VCLuag4EQAFprMv vwIAAA== DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-CFilter-Loop: Reflected Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some SPI connected devices do not have any CS line connected as some devices are alway enabled. Indeed, until now, a common workaround was to assign to num_chipselect a -1 value or 255 (num_chipselect is unsigned). In this case do not fail and defer to the SPI device drivers the responsibility to check whether the num-cs is '0'. Signed-off-by: Andi Shyti --- drivers/spi/spi.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 77e6e45..f22dc27 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -504,8 +504,13 @@ int spi_add_device(struct spi_device *spi) struct device *dev = master->dev.parent; int status; - /* Chipselects are numbered 0..max; validate. */ - if (spi->chip_select >= master->num_chipselect) { + /* + * Chipselects are numbered 0..max; validate. + * If there is no chip select (i.e. num_chipselect == 0), + * the comparison doesn't make sense. + */ + if (master->num_chipselect && + spi->chip_select >= master->num_chipselect) { dev_err(dev, "cs%d >= max %d\n", spi->chip_select, master->num_chipselect); @@ -1851,12 +1856,6 @@ int spi_register_master(struct spi_master *master) if (status) return status; - /* even if it's just one always-selected device, there must - * be at least one chipselect - */ - if (master->num_chipselect == 0) - return -EINVAL; - if ((master->bus_num < 0) && master->dev.of_node) master->bus_num = of_alias_get_id(master->dev.of_node, "spi");