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: 7558101 Return-Path: X-Original-To: patchwork-linux-spi@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 AAB2A9F399 for ; Thu, 5 Nov 2015 05:50:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BB2DB2083C for ; Thu, 5 Nov 2015 05:50:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3B932083B for ; Thu, 5 Nov 2015 05:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756319AbbKEFuk (ORCPT ); Thu, 5 Nov 2015 00:50:40 -0500 Received: from mail-pa0-f51.google.com ([209.85.220.51]:32903 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753226AbbKEFuj (ORCPT ); Thu, 5 Nov 2015 00:50:39 -0500 Received: by pabfh17 with SMTP id fh17so76668844pab.0 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=hMtm9PQPdvE0Z3xDpD/APjeWurQAIctHvPdttHEAiRvJzT/iORQyk1U7yusnLzT+nF 9DN3+mzxkME9ZV2gHlGb+ZlLT3vXQ1O6nnpk1rmE2C+ZQcQVQXF2CbO8D4rT4R3HQYB4 JXn0z8RK0XGK2CV7cJ6Q75rIWY4Wv5QGwRJLjuGQynhZlkl/Rusuo/2ePqQz4RPhEzjD i6z8a2Iu24pJKI19067X2aAH67oXk58auL8j0weENYfSPbAUh7dPP1wtpr5drBrEdehN b9AyqlpbbZEfmOIkxINup6lWEkwBIgcZ2R/8ZKY6XtVXfzdOyv8eyILIUFby/GLmyjtj RUog== X-Gm-Message-State: ALoCoQmbDHa0X4hx41LwkHSWVUUz7mVkXltI/nWi4UKn0g2ghX4Cz3vbRsvIOhCXtXJm2p9ZyT7N 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 Cc: Leilk Liu , Matthias Brugger , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org 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 Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham 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; + } } } }