From patchwork Thu Nov 5 05:50:33 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Boichat X-Patchwork-Id: 7558171 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8BE579F399 for ; Thu, 5 Nov 2015 05:52:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C224C20845 for ; Thu, 5 Nov 2015 05:52:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE49F20840 for ; Thu, 5 Nov 2015 05:52:45 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZuDRv-00054V-No; Thu, 05 Nov 2015 05:51:03 +0000 Received: from mail-pa0-x236.google.com ([2607:f8b0:400e:c03::236]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZuDRs-0004tV-0n for linux-arm-kernel@lists.infradead.org; Thu, 05 Nov 2015 05:51:00 +0000 Received: by pacdm15 with SMTP id dm15so52417147pac.3 for ; Wed, 04 Nov 2015 21:50:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=K5meKewKg5BsqHGUTQjdyR8rsBaUrtK8U9BTXIXfcl0=; b=Hp69+1nUGsOXkOyvEs6rIr/f/i+lFftD+UWmQAC8viWjZ6PLfVtGEdeCHQwywBsL+5 jr0fHUBKGdlla5CkACRMHQeXx8+r7tYWmdmwa+Zxd9J4QFS2PNATVD6y+k6yPMxgFT6f jIfQNcPdsq6z33diBGGFL9CtkoJGB7GIwtCEQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K5meKewKg5BsqHGUTQjdyR8rsBaUrtK8U9BTXIXfcl0=; b=K55X09dnJHt7aiSfoC3Y9+Xu+qvR8AC8yszaP69Kow/PllSjboSV/HmNEJxeYQgxY8 kCxu/xE/Opa4Tr2cQmu7xm+q/IXjBz47uWigFZrRKQkdiTmxm4Ow6XaY+fJvjs8s/qmT x44q6y800Ns0q4FWtDCn7i5QJ5nwYCRIiEoTzVr5JHmu/5r8d2DBGCs8vfSteUhPQMEb NnkDVR5CnL6O068b1Da9KvLlfj1uoDxEmzKp6H3+Ro9q3pZ/rCvcl4KkskYcNbYNP394 UmuZd5yE0d9L1hunYlqwl61lZXXF0uptzMlVFHWFzVn0BmHH1njYmOY4GlsGMO2G3vTt 4kRA== X-Gm-Message-State: ALoCoQkFMHiEO2wVy3WMFn4Zmb44A4G7d3JQ4KjPyQ7xbHwNqBHRGNyK5/SM0bJh4sAFWAZJffmV X-Received: by 10.68.203.168 with SMTP id kr8mr7120270pbc.60.1446702638819; Wed, 04 Nov 2015 21:50:38 -0800 (PST) Received: from drinkcat.tpe.corp.google.com ([172.30.210.53]) by smtp.gmail.com with ESMTPSA id qk7sm5378129pbb.80.2015.11.04.21.50.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Nov 2015 21:50:38 -0800 (PST) From: Nicolas Boichat To: Mark Brown Subject: [PATCH] spi: mediatek: single device does not require cs_gpios Date: Thu, 5 Nov 2015 13:50:33 +0800 Message-Id: <1446702633-14019-1-git-send-email-drinkcat@chromium.org> X-Mailer: git-send-email 2.6.0.rc2.230.g3dd15c0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151104_215100_099116_278DFBE2 X-CRM114-Status: GOOD ( 16.85 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leilk Liu , linux-kernel@vger.kernel.org, linux-spi@vger.kernel.org, linux-mediatek@lists.infradead.org, Matthias Brugger , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When only one device is present, it is not necessary to specify cs_gpios, as the CS line can be controlled by the hardware module. Without this patch, older device tree bindings used before 37457607 "spi: mediatek: mt8173 spi multiple devices support" would cause a panic on boot. This fixes the crash, and re-introduces backward compatibility. Signed-off-by: Nicolas Boichat --- Applies on top of broonie/spi.git topic/mtk. Thanks! drivers/spi/spi-mt65xx.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-mt65xx.c b/drivers/spi/spi-mt65xx.c index 563954a..f694031 100644 --- a/drivers/spi/spi-mt65xx.c +++ b/drivers/spi/spi-mt65xx.c @@ -410,7 +410,7 @@ static int mtk_spi_setup(struct spi_device *spi) if (!spi->controller_data) spi->controller_data = (void *)&mtk_default_chip_info; - if (mdata->dev_comp->need_pad_sel) + if (mdata->dev_comp->need_pad_sel && spi->cs_gpio >= 0) gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); return 0; @@ -632,13 +632,23 @@ static int mtk_spi_probe(struct platform_device *pdev) goto err_put_master; } - for (i = 0; i < master->num_chipselect; i++) { - ret = devm_gpio_request(&pdev->dev, master->cs_gpios[i], - dev_name(&pdev->dev)); - if (ret) { - dev_err(&pdev->dev, - "can't get CS GPIO %i\n", i); - goto err_put_master; + if (!master->cs_gpios && master->num_chipselect > 1) { + dev_err(&pdev->dev, + "cs_gpios not specified and num_chipselect > 1\n"); + ret = -EINVAL; + goto err_put_master; + } + + if (master->cs_gpios) { + for (i = 0; i < master->num_chipselect; i++) { + ret = devm_gpio_request(&pdev->dev, + master->cs_gpios[i], + dev_name(&pdev->dev)); + if (ret) { + dev_err(&pdev->dev, + "can't get CS GPIO %i\n", i); + goto err_put_master; + } } } }