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: 7558121 Return-Path: X-Original-To: patchwork-linux-mediatek@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 602F99F399 for ; Thu, 5 Nov 2015 05:51:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 88E0920760 for ; Thu, 5 Nov 2015 05:51:03 +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 C10EA202E5 for ; Thu, 5 Nov 2015 05:51:02 +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 1ZuDRu-00054I-C8; Thu, 05 Nov 2015 05:51:02 +0000 Received: from mail-pa0-x22a.google.com ([2607:f8b0:400e:c03::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZuDRs-0004tU-09 for linux-mediatek@lists.infradead.org; Thu, 05 Nov 2015 05:51:00 +0000 Received: by padhx2 with SMTP id hx2so68615963pad.1 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=fkUMpfwR4KgH7tgdPA7TFR1GgAhZusKDBDLHHa02IJd/uyx8/siwlxL8jETUhYZhoJ jCxjUdqbb8vOd1ZvE2vDQ8JFgQuEU2IN6mVSbW2Uvwr4VBitq6QmCngc4zgj/BMydIdg o6RPK4rIajvhMXPNmbIG5MfR6wp16bnbv84+paLnXvB7ppKNuGE9XD2kKp6DAilVLOP6 G/1jBgiERLYxR+yXziep0SIlhMFOENBlcKhRbmO35UgO48WAxd9sg/h4dEI2ft/7WEO5 H06KvNdSgyQhIhd6xRko1k5cEKqLypFzXbU42U5hLIhVBLbsaGesZHHiV7m6RFKLv6N7 Gyng== X-Gm-Message-State: ALoCoQkMYu94fr+84VpDMKqn/uZKjk0WBcqCXGhBKq4PavgTlTJu82gQTJzEbeU0Ke/s0UE2tfUx 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_111026_C68CD709 X-CRM114-Status: GOOD ( 15.15 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-mediatek@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-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=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; + } } } }