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: 2842545 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 C7D1E9F271 for ; Sun, 11 Aug 2013 00:33:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D703D2020A for ; Sun, 11 Aug 2013 00:33:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D41A20204 for ; Sun, 11 Aug 2013 00:33:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751227Ab3HKAdz (ORCPT ); Sat, 10 Aug 2013 20:33:55 -0400 Received: from mail-ee0-f49.google.com ([74.125.83.49]:36450 "EHLO mail-ee0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750990Ab3HKAdw (ORCPT ); Sat, 10 Aug 2013 20:33:52 -0400 Received: by mail-ee0-f49.google.com with SMTP id d41so2762306eek.36 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 Cc: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Kukjin Kim , Mark Brown , Tomasz Figa 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> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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;