From patchwork Sun Aug 11 00:33:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 2842549 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0DDAC9F294 for ; Sun, 11 Aug 2013 00:35:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 25381201D3 for ; Sun, 11 Aug 2013 00:35:28 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 34484201BD for ; Sun, 11 Aug 2013 00:35:27 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V8JcN-0002wU-7P; Sun, 11 Aug 2013 00:34:47 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V8JcA-0005Q7-B3; Sun, 11 Aug 2013 00:34:34 +0000 Received: from mail-ee0-x233.google.com ([2a00:1450:4013:c00::233]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V8Jbr-0005Nn-98 for linux-arm-kernel@lists.infradead.org; Sun, 11 Aug 2013 00:34:16 +0000 Received: by mail-ee0-f51.google.com with SMTP id c1so2758724eek.38 for ; Sat, 10 Aug 2013 17:33:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aANrA6ZYomWZmoS3OVe7gvPuCcyS5xJSojMMVMG3TCM=; b=PeNk0Osuq73Jsq/ZxNJpbx5V4qnd7hjLJvKYpgLtb08fMZlHhPzRfAMEn8b05qlUbV iRHxZVJtebiO4Gg53DLAcx+xWy8VDtKfEawVEO3tSjhEe/xDBZamccnUFyg8FeBOfEIr 0b+JnHzbhxDhGhWW9xiqQFAz+9WJA7wfoQJXR3cntVj1l/HHSqqBs3+bM/jF69uiq1S/ 8io4YTX8W0WHTsERbXSinCawUrGe3esDWrRnGh4Sums6LeRyliOq4fZNdqAv7jwJl6/9 NwGKQLnANCnZVCJGflEwSGEaZ5NCu363HsG9SdZMsU6REAaw3JANbOC/aPd69C27yRJQ mtow== X-Received: by 10.14.194.133 with SMTP id m5mr6558543een.109.1376181230669; Sat, 10 Aug 2013 17:33:50 -0700 (PDT) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id r48sm36159729eev.14.2013.08.10.17.33.48 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 10 Aug 2013 17:33:49 -0700 (PDT) From: Tomasz Figa To: linux-spi@vger.kernel.org Subject: [PATCH 2/3] spi: s3c64xx: Do not request CS GPIO on subsequent calls to .setup() Date: Sun, 11 Aug 2013 02:33:29 +0200 Message-Id: <1376181210-14599-2-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1376181210-14599-1-git-send-email-tomasz.figa@gmail.com> References: <1376181210-14599-1-git-send-email-tomasz.figa@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130810_203415_456015_C286FE91 X-CRM114-Status: GOOD ( 11.27 ) X-Spam-Score: -2.0 (--) Cc: Kukjin Kim , Mark Brown , linux-samsung-soc@vger.kernel.org, Tomasz Figa , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Comments in linux/spi/spi.h and observed behavior show that .setup() callback can be called multiple times without corresponding calls to .cleanup(), what was incorrectly assumed by spi-s3c64xx driver, leading to failures trying to request CS GPIO multiple times. This patch modifies the behavior of spi-s3c64xx driver to request CS GPIO only on first call to .setup() after last .cleanup(). Signed-off-by: Tomasz Figa --- drivers/spi/spi-s3c64xx.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 1be162c..597dc2f 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c @@ -1068,20 +1068,21 @@ static int s3c64xx_spi_setup(struct spi_device *spi) return -ENODEV; } - /* Request gpio only if cs line is asserted by gpio pins */ - if (sdd->cs_gpio) { - err = gpio_request_one(cs->line, GPIOF_OUT_INIT_HIGH, - dev_name(&spi->dev)); - if (err) { - dev_err(&spi->dev, - "Failed to get /CS gpio [%d]: %d\n", - cs->line, err); - goto err_gpio_req; + if (!spi_get_ctldata(spi)) { + /* Request gpio only if cs line is asserted by gpio pins */ + if (sdd->cs_gpio) { + err = gpio_request_one(cs->line, GPIOF_OUT_INIT_HIGH, + dev_name(&spi->dev)); + if (err) { + dev_err(&spi->dev, + "Failed to get /CS gpio [%d]: %d\n", + cs->line, err); + goto err_gpio_req; + } } - } - if (!spi_get_ctldata(spi)) spi_set_ctldata(spi, cs); + } sci = sdd->cntrlr_info;