From patchwork Mon Nov 30 15:02:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Welling X-Patchwork-Id: 7726771 Return-Path: X-Original-To: patchwork-linux-spi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id A3C06BEEE1 for ; Mon, 30 Nov 2015 15:03:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1C452053D for ; Mon, 30 Nov 2015 15:03:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D12CC20534 for ; Mon, 30 Nov 2015 15:03:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754310AbbK3PDI (ORCPT ); Mon, 30 Nov 2015 10:03:08 -0500 Received: from mail-io0-f170.google.com ([209.85.223.170]:36825 "EHLO mail-io0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754272AbbK3PDH (ORCPT ); Mon, 30 Nov 2015 10:03:07 -0500 Received: by iofh3 with SMTP id h3so176759025iof.3; Mon, 30 Nov 2015 07:03:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=Mgz5wFemd9x8k3j7AeCgWq/hPnF8NteYLAj91Or/ehk=; b=baFyk+GHGQWIIZ9PrSekV3hCxbY77OD6uFWzvsGUf+F3mMPWJXlcxGLKz0gTxpwhKo LDztmVx230aHf3D5pWGVbOrdTLL3CGGZjXXHpDKmLLsk7058KFVnrZtk04bjHMmKtP/n hsnd/QhZ9j6zadovdy4/Hgmt0XReq7U5uVIN0kdrZa9jtIrstu7VHtVc/whv/vxoUBSs cLYnOLNJoamP6JFfOWVxrfio/kDKrq4XSTcTCw7dQMFv8ye/hSMzRNPPop7rDBN2Ei38 ck/+DYTCDKKQqPXoceb8gfZIG2aTEtx6++EaoLGlHZsQVtsTmfAoCYHVQMpfMtPAqU1J 21ww== X-Received: by 10.107.167.18 with SMTP id q18mr55857001ioe.141.1448895785766; Mon, 30 Nov 2015 07:03:05 -0800 (PST) Received: from qwerty.qwertyembedded (173-22-240-187.client.mchsi.com. [173.22.240.187]) by smtp.gmail.com with ESMTPSA id c2sm8106414igg.4.2015.11.30.07.03.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 30 Nov 2015 07:03:05 -0800 (PST) From: Michael Welling To: Mark Brown , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Joseph Bell Cc: Michael Welling Subject: [PATCH] spi: omap2-mcspi: Prevent duplicate gpio_request Date: Mon, 30 Nov 2015 09:02:39 -0600 Message-Id: <1448895759-4282-1-git-send-email-mwelling@ieee.org> X-Mailer: git-send-email 2.1.4 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 Occasionally the setup function will be called multiple times. Only request the gpio the first time otherwise -EBUSY will occur on subsequent calls to setup. Reported-by: Joseph Bell Signed-off-by: Michael Welling --- drivers/spi/spi-omap2-mcspi.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c index 02aa1d0..7273820 100644 --- a/drivers/spi/spi-omap2-mcspi.c +++ b/drivers/spi/spi-omap2-mcspi.c @@ -1025,6 +1025,16 @@ static int omap2_mcspi_setup(struct spi_device *spi) spi->controller_state = cs; /* Link this to context save list */ list_add_tail(&cs->node, &ctx->cs); + + if (gpio_is_valid(spi->cs_gpio)) { + ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); + if (ret) { + dev_err(&spi->dev, "failed to request gpio\n"); + return ret; + } + gpio_direction_output(spi->cs_gpio, + !(spi->mode & SPI_CS_HIGH)); + } } if (!mcspi_dma->dma_rx || !mcspi_dma->dma_tx) { @@ -1033,15 +1043,6 @@ static int omap2_mcspi_setup(struct spi_device *spi) return ret; } - if (gpio_is_valid(spi->cs_gpio)) { - ret = gpio_request(spi->cs_gpio, dev_name(&spi->dev)); - if (ret) { - dev_err(&spi->dev, "failed to request gpio\n"); - return ret; - } - gpio_direction_output(spi->cs_gpio, !(spi->mode & SPI_CS_HIGH)); - } - ret = pm_runtime_get_sync(mcspi->dev); if (ret < 0) return ret;